index.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. import systemTask from "../task/components/index.vue"
  2. import FieldDrawer from '@/views/components/drawer/Field.vue'
  3. export default{
  4. components: {
  5. systemTask,
  6. FieldDrawer
  7. },
  8. props:{
  9. importData:{
  10. default:()=>{
  11. return {}
  12. }
  13. }
  14. },
  15. data() {
  16. return {
  17. tableData: [
  18. {
  19. name: '标引',
  20. field: 'index'
  21. }, {
  22. name: '分类',
  23. field: 'classify'
  24. }
  25. ],
  26. form:this.importData,
  27. customField: [],
  28. customFieldId:null,
  29. choseField:{},
  30. ExcelConfig:[],
  31. projectDetails:{},
  32. treeProp:{
  33. children:'child',
  34. label: 'name'
  35. },
  36. assoImportTaskFieldVOS:[],
  37. importContent:['0','1','2','3']
  38. }
  39. },
  40. computed:{
  41. importContents(){
  42. return this.$store.state.dictMessage.dictMessage.IMPORT_CONTENT
  43. }
  44. },
  45. mounted() {
  46. if(this.form.type == 1){
  47. this.getExcelConfig()
  48. }
  49. if(!this.form.importToId){
  50. return false
  51. }
  52. if(this.form.importToId && this.form.importToType != 2){
  53. //获取所有栏位
  54. this.getAllCustomField()
  55. }else{
  56. this.choseField = {
  57. id:this.form.importToId,
  58. name:this.form.name,
  59. type:6,
  60. isProduct:2,
  61. fieldValue:[]
  62. }
  63. this.customFieldId = this.form.importToId
  64. this.getProductTree()
  65. }
  66. },
  67. methods: {
  68. changeValue(value,data){
  69. if(this.choseField.type == 5 || this.choseField.type == 6){
  70. var index = this.assoImportTaskFieldVOS.findIndex(item=>{
  71. return item.fieldValueId == value
  72. })
  73. if(index!=-1){
  74. this.assoImportTaskFieldVOS.splice(index,1)
  75. }else{
  76. this.assoImportTaskFieldVOS.push(
  77. {
  78. projectId:this.form.importToId,
  79. fieldType:this.choseField.type,//类型
  80. fieldId:this.choseField.id,//栏位ID
  81. fieldValueId:value,
  82. keyValue:this.choseField.keyValue,
  83. fieldValueStr:data.name,
  84. fieldName:this.choseField.name
  85. }
  86. )
  87. }
  88. }else{
  89. var obj = this.assoImportTaskFieldVOS.find(item=>{
  90. return item.fieldId == this.choseField.id
  91. })
  92. if(obj){
  93. obj.fieldValueId = value
  94. }else{
  95. this.assoImportTaskFieldVOS.push(
  96. {
  97. projectId:this.form.importToId,
  98. fieldType:this.choseField.type,//类型
  99. fieldId:this.choseField.id,//栏位ID
  100. fieldValueId:value,
  101. keyValue:this.choseField.keyValue,
  102. fieldValueStr:data?data.name:value,
  103. fieldName:this.choseField.name
  104. }
  105. )
  106. }
  107. }
  108. },
  109. del(index,item){
  110. this.assoImportTaskFieldVOS.splice(index,1)
  111. var obj = this.customField.find(item=>{
  112. return item.keyValue == item.keyValue
  113. })
  114. if(obj){
  115. var index = obj.fieldValue.indexOf(item.fieldValueId)
  116. if(obj.type == 5 || obj.type == 6){
  117. obj.fieldValue.splice(index,1)
  118. }else{
  119. obj.fieldValue = ''
  120. }
  121. }
  122. },
  123. //修改选择的栏位
  124. changeCustomField(val){
  125. if(!val){
  126. return false
  127. }
  128. this.choseField = this.customField.find(item=>{
  129. return item.keyValue == val
  130. })
  131. if(this.choseField){
  132. if(this.choseField.options && this.choseField.options.length>0){
  133. return false
  134. }else{
  135. if(this.choseField.isProduct){
  136. this.getProductTree()
  137. }else{
  138. this.getFieldOption()
  139. }
  140. }
  141. }
  142. },
  143. //获取自定义选项
  144. getFieldOption(){
  145. let params = {
  146. customFieldId: this.choseField.id,
  147. }
  148. this.$api.queryCustomOption(params).then(response => {
  149. this.$set(this.choseField,'options',response.data.data)
  150. }).catch(error => {
  151. })
  152. },
  153. //获取产品架构
  154. getProductTree(){
  155. let params = {
  156. name: this.choseField.name,//名称
  157. type: this.choseField.isProduct,//类型:1产品类别,2产品,3技术分类,4自定义树
  158. typeId: this.choseField.id,//产品或类别id
  159. }
  160. this.$api.queryTreeNodeTree(params).then(res => {
  161. if (res.code == 200) {
  162. this.$set(this.choseField,'options',res.data.data)
  163. }
  164. }).catch(err => {
  165. })
  166. },
  167. //获取所有栏位
  168. async getAllCustomField(){
  169. const [project,product] = await Promise.allSettled([this.getProjectField(),this.getProjectDetails()])
  170. var projectField = project.status =='fulfilled'?project.value:[]
  171. this.projectDetails= product.status =='fulfilled'?product.value:{}
  172. if(this.ods){
  173. this.ods.data = [
  174. this.projectDetails
  175. ]
  176. this.$set(this.form,'importToId',this.form.importToId)
  177. }
  178. if(this.projectDetails.productOrCategory){
  179. projectField.push(
  180. {
  181. id:this.projectDetails.productOrCategory.id,
  182. name:this.projectDetails.productOrCategory.name,
  183. type:6,
  184. isProduct:this.projectDetails.productOrCategory.type,
  185. }
  186. )
  187. }
  188. projectField.forEach((item,index)=>{
  189. item.keyValue = (index+1)+''
  190. if(item.type == 5 || item.type == 6){
  191. this.$set(item,'fieldValue',[])
  192. }else{
  193. this.$set(item,'fieldValue','')
  194. }
  195. })
  196. this.customField =projectField
  197. },
  198. //获取自定义栏位
  199. async getProjectField(){
  200. var params = {
  201. searchQuery:`projectId=${this.form.importToId}`,
  202. orderDTOList: [
  203. {
  204. "orderBy": "type",
  205. "orderType": 1
  206. }
  207. ],
  208. }
  209. return await this.$api.queryCustomField(params).then( async response=>await response.data.data)
  210. },
  211. //获取项目信息
  212. async getProjectDetails(){
  213. if(this.form.importToType != 0){
  214. return {
  215. status:''
  216. }
  217. }
  218. var params = {
  219. searchQuery: `id=${this.form.importToId}`,//检索条件
  220. orderDTOList: [],//排序
  221. }
  222. return await this.$api.queryPatentProject(params).then( async response=>await response.data.data[0])
  223. },
  224. getExcelConfig() {
  225. this.$api.getExcelConfig().then(response => {
  226. this.ExcelConfig = response.data.data
  227. })
  228. },
  229. handleManage(){
  230. this.$refs.FieldDrawer.open(this.form.importToId)
  231. },
  232. closeFieldDrawer(){
  233. this.getAllCustomField()
  234. },
  235. //添加导入任务
  236. addImportTask(form){
  237. this.btnLoading = true
  238. this.loading = true
  239. this.$api.addImportTask(form).then(response => {
  240. this.$message.success('任务创建成功')
  241. this.form = this.importData
  242. this.btnLoading = false
  243. this.loading = false
  244. // this.getQueueList()
  245. this.getConfirm()
  246. }).catch(error => {
  247. this.btnLoading = false
  248. this.loading = false
  249. })
  250. },
  251. getQueueList() {
  252. this.$refs.systemTask.getList()
  253. },
  254. //弹窗
  255. getConfirm() {
  256. const h = this.$createElement;
  257. this.$msgbox({
  258. title: "提示",
  259. message: h("p", null, [
  260. h("span", null, "任务正在导入,查看任务进度请前往"),
  261. h(
  262. "span",
  263. {
  264. class: "MessageBoxClass",
  265. on: {
  266. click: () => {
  267. this.toTaskList();
  268. // 通过close关闭消息弹窗,this.$confirm就是this.$confirm.close(false),其他同理
  269. this.$msgbox.close(false);
  270. },
  271. },
  272. },
  273. "任务清单"
  274. ),
  275. ]),
  276. type: "warning",
  277. showConfirmButton: false,
  278. }).then((action) => {});
  279. },
  280. //跳转到任务清单
  281. toTaskList() {
  282. // 传专题库id是查到当前专题库的导入任务,不传是查看所有导入任务
  283. this.$router.push({
  284. path: "/taskList",
  285. query:{
  286. importToId:this.form.importToId
  287. }
  288. });
  289. },
  290. // 获取时间
  291. handleData(val) {
  292. if (this.form.dateType=='') {
  293. this.$message.error('请先选择更新周期')
  294. return false
  295. }
  296. this.form.crons=val
  297. },
  298. getDateType(val) {
  299. this.form.crons = ''
  300. },
  301. },
  302. }