addAndEditProject.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <div>
  3. <el-dialog :title="title" :visible.sync="dialogVisible" width="850" :before-close="handleClose">
  4. <el-form :model="form" status-icon :rules="rules" ref="form" label-width="120px" class="demo-ruleForm">
  5. <template>
  6. <!-- 研发项目 -->
  7. <el-divider content-position="left">研发项目</el-divider>
  8. <el-row>
  9. <el-col :span="12">
  10. <el-form-item label="研发编号:">
  11. <el-autocomplete class="inline-input" v-model="form.rdnumber" value-key="name" v-SelectLazyLoading="load"
  12. :fetch-suggestions="querySearchQuestion" placeholder="请选择研发项目编号" :trigger-on-focus="false"
  13. style="width: 100%;">
  14. </el-autocomplete>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="12">
  18. <el-form-item label="研发名称:" prop="rdName">
  19. <el-input v-model="form.rdName" placeholder="请输入研发项目名称"></el-input>
  20. </el-form-item>
  21. </el-col>
  22. </el-row>
  23. <el-row>
  24. <el-col :span="12">
  25. <el-form-item label="产品:" prop="product">
  26. <el-input v-model="form.product" placeholder="请输入产品名称"></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="12">
  30. <el-form-item label="产品阶段:">
  31. <el-input v-model="form.productPhase" placeholder="请输入产品阶段"></el-input>
  32. </el-form-item>
  33. </el-col>
  34. </el-row>
  35. </template>
  36. <el-divider content-position="left">挖掘项目</el-divider>
  37. <el-row>
  38. <el-col :span="12">
  39. <el-form-item label="项目名称:" prop="name">
  40. <el-input v-model="form.name" placeholder="请输入项目名称"></el-input>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="12">
  44. <el-form-item label="技术方向:">
  45. <el-input v-model="form.type" placeholder="请输入技术方向"></el-input>
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. <el-row>
  50. <!-- <el-col :span="12">
  51. <el-form-item label="技术方向:">
  52. <el-input v-model="form.productPhase" placeholder="请输入产品阶段"></el-input>
  53. </el-form-item>
  54. </el-col> -->
  55. <!-- <el-col :span="12">
  56. <el-form-item label="产出:">
  57. <el-input v-model="form.output" placeholder="请输入产出"></el-input>
  58. </el-form-item>
  59. </el-col> -->
  60. </el-row>
  61. <el-row>
  62. <el-col :span="12">
  63. <el-form-item label="相关竞争对手:">
  64. <el-input v-model="form.relatedCompetitors" placeholder="请输入相关竞争对手"></el-input>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="12">
  68. <el-form-item label="技术关键词:">
  69. <el-input v-model="form.technicalKeyword" placeholder="请输入技术关键词"></el-input>
  70. </el-form-item>
  71. </el-col>
  72. </el-row>
  73. <el-row>
  74. <el-col :span="12">
  75. <el-form-item label="产出:">
  76. <el-input v-model="form.output" placeholder="请输入产出"></el-input>
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="12">
  80. <el-form-item label="是否检索:">
  81. <el-switch v-model="form.ifSearch" active-color="#13ce66" inactive-color="#ff4949">
  82. </el-switch>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="12">
  86. <!-- <el-form-item label="是否审核:">
  87. <el-switch v-model="form.examine" active-color="#13ce66" inactive-color="#ff4949">
  88. </el-switch>
  89. </el-form-item> -->
  90. </el-col>
  91. </el-row>
  92. <el-row>
  93. <el-col :span="24">
  94. <el-form-item label="参与人:">
  95. <div class="manage">
  96. <el-button size="small" @click="showDialog(2)">选择</el-button>
  97. <div v-html="getNames(form.adminPersons)">
  98. </div>
  99. </div>
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. <el-row>
  104. <el-col :span="24">
  105. <el-form-item label="负责人:">
  106. <el-select v-model="form.headId" placeholder="请选择负责人" style="width: 100%;" filterable remote
  107. :remote-method="remoteMethodPerson" v-SelectLazyLoading="lazyLoadingPerson"
  108. :loading="personnelList.loading">
  109. <el-option v-for="item in personnelList.data" :key="item.id" :label="item.name" :value="item.id">
  110. </el-option>
  111. </el-select>
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. <el-row>
  116. <el-col :span="24">
  117. <el-form-item label="附件:">
  118. <myUpload :file-list="form.systemFileList" @on-change="onchange" @on-remove="onRemove"
  119. style="height: 180px;" :autoUpload="true"></myUpload>
  120. </el-form-item>
  121. </el-col>
  122. </el-row>
  123. <el-row>
  124. <el-col :span="24">
  125. <el-form-item label="项目备注:">
  126. <el-input type="textarea" :rows="3" placeholder="请输入内容" v-model="form.remark"></el-input>
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. </el-form>
  131. <span slot="footer" class="dialog-footer">
  132. <el-button @click="handleClose">取 消</el-button>
  133. <el-button type="primary" @click="submit">确 定</el-button>
  134. </span>
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. export default {
  140. components: {},
  141. props: {},
  142. data() {
  143. return {
  144. dialogVisible: false,
  145. title: '',
  146. form: {},
  147. rules: {
  148. name: [{ required: true, message: '请输入项目名称', trigger: 'blur' },],
  149. },
  150. options: [],//负责人数组
  151. value: '',//负责人
  152. //人员列表懒加载
  153. personnelList: {
  154. queryParams: {
  155. current: 1,
  156. size: 10
  157. },
  158. data: []
  159. },
  160. // 研发编号列表懒加载
  161. rdNumberArr: {
  162. queryParams: {
  163. current: 1,
  164. size: 10,
  165. },
  166. eventInput: '',
  167. data: []
  168. },
  169. };
  170. },
  171. watch: {},
  172. computed: {},
  173. created() { },
  174. mounted() {
  175. // 获取人员列表
  176. this.getPermissionPersonnel();
  177. },
  178. methods: {
  179. // 打开参与人人员弹窗
  180. showDialog() {
  181. // this.$refs.choosePerson.open(this.form.adminIds,this.form.adminPersons)
  182. },
  183. // 处理参与人数据
  184. getNames(row){
  185. if(!row){
  186. return ''
  187. }
  188. var arr = row.map(item=>{
  189. return item.name
  190. })
  191. return arr.join('、')
  192. },
  193. // 研发编号懒加载方法
  194. load() {
  195. if (this.rdNumberArr.queryParams.current * this.rdNumberArr.queryParams.size >= this.rdNumberArr.queryParams.total) {
  196. return false
  197. }
  198. this.rdNumberArr.queryParams.current++
  199. this.getRdProjectByNumber()
  200. },
  201. // 查询研发编号
  202. async getRdProjectByNumber() {
  203. let searchValue = { name: this.rdNumberArr.eventInput }
  204. let params = {
  205. ...this.rdNumberArr.queryParams,//分页信息
  206. searchQuery: this.$commonJS.objectToString(searchValue)//输入的建议
  207. }
  208. await this.$api.getRdProjectByNumber(params).then(res => {
  209. if (res.code == 200) {
  210. this.rdNumberArr.data.push(...res.data.data)
  211. this.rdNumberArr.queryParams.total = res.data.total
  212. this.rdNumberArr.cb(this.rdNumberArr.data);
  213. }
  214. })
  215. },
  216. //获取下拉建议研发编号数据
  217. async querySearchQuestion(queryString, cb) {
  218. this.rdNumberArr.queryParams.current = 1
  219. this.rdNumberArr.eventInput = queryString
  220. this.rdNumberArr.data = []
  221. this.rdNumberArr.cb = cb
  222. await this.getRdProjectByNumber()
  223. },
  224. // 人员列表远程搜索
  225. remoteMethodPerson(query) {
  226. this.personnelList.data = []
  227. this.personnelList.queryParams.current = 1
  228. this.personnelList.queryParams.name = query
  229. this.getPermissionPersonnel()
  230. },
  231. // 获取所有人员列表懒加载
  232. lazyLoadingPerson() {
  233. if (this.personnelList.queryParams.current * this.personnelList.queryParams.size >= this.personnelList.queryParams.total) {
  234. return false
  235. }
  236. this.personnelList.queryParams.current += 1
  237. this.getPermissionPersonnel()
  238. },
  239. //获取所有人员列表(修改不要一次性获取,可以使用懒加载加远程搜索 )
  240. getPermissionPersonnel() {
  241. this.personnelList.loading = true;
  242. this.$api.getPermissionPersonnel(this.personnelList.queryParams).then((response) => {
  243. if (response.code == 200) {
  244. this.personnelList.loading = false;
  245. this.personnelList.data.push(...response.data)
  246. this.personnelList.queryParams.total = response.pageColumn.total
  247. }
  248. })
  249. },
  250. // 上传的文件监听
  251. onchange(file, fileList) {
  252. if (file.guid) {
  253. let index = this.form.systemFileList.findIndex(item => {
  254. return item.uid == file.uid
  255. })
  256. if (index != -1) {
  257. this.form.systemFileList.splice(index, 1, file)
  258. this.form.fileGuids.push(file.guid)
  259. }
  260. } else {
  261. this.form.systemFileList.push(file.raw)
  262. }
  263. },
  264. // 删除上传的文件
  265. onRemove(file, fileList) {
  266. let index = this.form.systemFileList.findIndex(item => {
  267. return item.uid == file.uid
  268. })
  269. if (index != -1) {
  270. if (file.guid) {
  271. let index2 = this.form.fileGuids.findIndex(item => {
  272. return item == file.guid
  273. })
  274. if (index2 != -1) {
  275. this.form.fileGuids.splice(index, 1)
  276. }
  277. }
  278. this.form.systemFileList.splice(index, 1)
  279. }
  280. },
  281. //打开弹窗
  282. open(form) {
  283. if (form && form.id) {
  284. this.form = JSON.parse(JSON.stringify(form))
  285. this.title = '编辑专利挖掘项目'
  286. } else {
  287. this.title = '新增专利挖掘项目'
  288. }
  289. this.dialogVisible = true
  290. },
  291. //关闭弹窗
  292. handleClose() {
  293. // this.$refs.upload.clearFiles()
  294. this.$refs.form.resetFields()
  295. this.form = {}
  296. this.dialogVisible = false
  297. },
  298. //提交数据
  299. submit() {
  300. this.$refs.form.validate((valid) => {
  301. if (valid) {
  302. // 判断文件是否全部上传完毕
  303. if ((this.form.fileGuids && this.form.fileGuids.length) != (this.form.systemFileList && this.form.systemFileList.length)) {
  304. this.$message.error('您有文件未上传完毕,请您稍等片刻')
  305. return false
  306. }
  307. if (!this.form.id) {//新增
  308. if (this.form.examine) {//审核任务
  309. } else {//不审核直接创建项目
  310. this.$api.addPatentDigProject(this.form).then(res => {
  311. if (res.code == 200) {
  312. this.$message.success('新增专利挖掘项目成功')
  313. this.$emit('isSuccess', true)
  314. this.handleClose()
  315. }
  316. })
  317. }
  318. } else {//编辑
  319. this.$api.edit(this.form).then(res => {
  320. if (res.code == 200) {
  321. this.$message.success('更新专利挖掘项目成功')
  322. this.$emit('isSuccess', true)
  323. this.handleClose()
  324. }
  325. })
  326. }
  327. } else {
  328. this.$message.error('信息未输入完整')
  329. }
  330. });
  331. },
  332. // 审核任务
  333. examine(data) {
  334. let params = {
  335. }
  336. this.$api.task(params).then(res => {
  337. if (res.code == 200) {
  338. }
  339. })
  340. },
  341. },
  342. };
  343. </script>
  344. <style lang="scss" scoped></style>