zhuliu hace 1 año
padre
commit
6321fc4ad2

+ 43 - 55
src/views/components/import/components/importPatent.vue

@@ -15,68 +15,55 @@
                         <div style="margin-top:50px">
                             <span>栏位:</span>
                             <span>
-                                <el-select v-model="customFieldId" @change="changeCustomField">
-                                    <el-option v-for="item in customField" :key="item.name" :value="item.keyValue">{{ item.name }} </el-option>
+                                <el-select v-model="customFieldId" @change="changeCustomField"  placeholder="请选择">
+                                    <el-option
+                                    v-for="item in customField"
+                                    :key="item.name"
+                                    :label="item.name"
+                                    :value="item.keyValue">
+                                    </el-option>
                                 </el-select>
                             </span>
                         </div>
-                        <el-table :data="tableData" :show-header="false">
-                        <el-table-column type="expand">
-                            <template slot-scope="props">
-                            <el-form label-position="top" class="custom-field-form">
-                                
-                                <template v-if="props.row.field === 'folder'">
+                        <div style="margin-top:20px" v-if="customFieldId">
+                            <template v-if="choseField.type === 0 || choseField.type === 2">
+                                <el-input v-model="choseField.fieldValue" placeholder="请输入内容" size="small" @change="changeValue"></el-input>
+                            </template>
+                            <template v-if="choseField.type === 1">
+                                <el-date-picker v-model="choseField.fieldValue"  value-format="yyyy-MM-dd" type="date" size="small" placeholder="选择日期" style="width: 100%;" @change="changeValue"></el-date-picker>
+                            </template>
+                            <!-- <template v-if="choseField.type === 3">
+                                <el-select v-model="form.json.field[choseField.id].value" size="small" placeholder="请选择" class="width_100">
+                                    <el-option v-for="option in choseField.options" :key="option.name" :value="option.id" :label="option.name"></el-option>
+                                </el-select>
+                            </template> -->
+                            <template v-if="choseField.type === 4">
+                                <el-radio-group v-model="choseField.fieldValue" @change="changeValue">
+                                    <el-radio v-for="option in choseField.options" :key="option.name" :label="option.id">{{ option.name }}</el-radio>
+                                </el-radio-group>
+                            </template>
+                            <template v-if="choseField.type === 5">
+                                <el-checkbox-group v-model="choseField.fieldValue" >
+                                    <el-checkbox v-for="option in choseField.options" :key="option.name" :label="option.id" @change="changeValue(option.id,option)">{{ option.name }}</el-checkbox>
+                                </el-checkbox-group>
+                            </template>
+                            <template v-if="choseField.type === 6">
                                 <el-tree
-                                    ref="folderTree"
-                                    :data="customField.folder"
-                                    check-strictly
-                                    :default-checked-keys="form.json.field.folder"
-                                    show-checkbox
+                                    :ref="choseField.id"
+                                    :data="choseField.options"
                                     node-key="id"
-                                    :props="defaultProps"
-                                ></el-tree>
-                                </template>
-                                <template v-else v-for="(item, index) in customField[props.row.field]">
-                                <el-form-item :label="`${index + 1}. ${item.name}`">
-                                    <template v-if="item.type === 0 || item.type === 2">
-                                    <el-input v-model="form.json.field[item.id].value" placeholder="请输入内容" size="small"></el-input>
-                                    </template>
-                                    <template v-if="item.type === 1">
-                                    <el-date-picker v-model="form.json.field[item.id].value" value-format="yyyy-MM-dd" type="date" size="small" placeholder="选择日期" style="width: 100%;"></el-date-picker>
-                                    </template>
-                                    <template v-if="item.type === 3">
-                                    <el-select v-model="form.json.field[item.id].value" size="small" placeholder="请选择" class="width_100">
-                                        <el-option v-for="option in item.option" :value="option.id" :label="option.name"></el-option>
-                                    </el-select>
-                                    </template>
-                                    <template v-if="item.type === 4">
-                                    <el-radio-group v-model="form.json.field[item.id].value">
-                                        <el-radio v-for="option in item.option" :label="option.id">{{ option.name }}</el-radio>
-                                    </el-radio-group>
-                                    </template>
-                                    <template v-if="item.type === 5">
-                                    <el-checkbox-group v-model="form.json.field[item.id].value">
-                                        <el-checkbox v-for="option in item.option" :label="option.id">{{ option.name }}</el-checkbox>
+                                    :props="treeProp"
+                                    :expand-on-click-node="false"
+                                    :default-expand-all="true"
+                                >
+                                <span class="custom-tree-node" slot-scope="{ node, data }">
+                                    <el-checkbox-group v-model="choseField.fieldValue" >
+                                        <el-checkbox :label="data.id" @change="changeValue(data.id,data)">{{ data.name }}</el-checkbox>
                                     </el-checkbox-group>
-                                    </template>
-                                    <template v-if="item.type === 6">
-                                    <el-tree
-                                        :ref="item.id"
-                                        :data="item.option"
-                                        check-strictly
-                                        :default-checked-keys="form.json.field[item.id].value"
-                                        show-checkbox
-                                        node-key="id"
-                                        :props="defaultProps"
-                                    ></el-tree>
-                                    </template>
-                                </el-form-item>
-                                </template>
-                            </el-form>
+                                </span>
+                                </el-tree>
                             </template>
-                        </el-table-column>
-                        <el-table-column prop="name" show-overflow-tooltip></el-table-column>
-                        </el-table>
+                        </div>
                     </el-form-item>
                     <el-form-item label="数据来源:">
                         <select style="width:300px;border:0;outline:none" name="" id="" v-model="form.sourceId">
@@ -168,6 +155,7 @@ export default {
             }
             
         }
+        // console.log(this.assoImportTaskFieldVOS)
         this.addImportTask(this.form)
       
     }

+ 95 - 22
src/views/components/import/mixins/index.js

@@ -21,9 +21,15 @@ export default{
             ],
             form:this.importData,
             customField: [],
-            customFieldId:'',
+            customFieldId:null,
+            choseField:{},
             ExcelConfig:[],
-            projectDetails:{}
+            projectDetails:{},
+            treeProp:{
+                children:'child',
+                label: 'name'
+            },
+            assoImportTaskFieldVOS:[]
         }
     },
     mounted() {
@@ -34,15 +40,90 @@ export default{
         this.getAllCustomField()
     },
     methods: {
+        changeValue(value,data){
+            if(this.choseField.type == 5 || this.choseField.type == 6){
+                var index = this.assoImportTaskFieldVOS.findIndex(item=>{
+                    return item.fieldValueId == value
+                })
+                if(obj){
+                    this.assoImportTaskFieldVOS.splice(index,1)
+                }else{
+                    this.assoImportTaskFieldVOS.push(
+                        {
+                            projectId:this.form.importToId,
+                            fieldType:this.choseField.type,//类型
+                            fieldId:this.choseField.id,//栏位ID
+                            fieldValueId:value
+                        }
+                    )
+                }
+            }else{
+                var obj = this.assoImportTaskFieldVOS.find(item=>{
+                    return item.fieldId == this.choseField.id
+                })
+                if(obj){
+                    obj.fieldValueId = value
+                }else{
+                    this.assoImportTaskFieldVOS.push(
+                        {
+                            projectId:this.form.importToId,
+                            fieldType:this.choseField.type,//类型
+                            fieldId:this.choseField.id,//栏位ID
+                            fieldValueId:value
+                        }
+                    )
+                }
+            }
+        },
         //修改选择的栏位
         changeCustomField(val){
-            // var obj = this.customField
+            if(!val){
+                return false
+            }
+            this.choseField = this.customField.find(item=>{
+                return item.keyValue == val
+            })
+            if(this.choseField){
+                if(this.choseField.options && this.choseField.options.length>0){
+                    return false
+                }else{
+                    if(this.choseField.isProduct){
+                        this.getProduct()
+                    }else{
+                        this.getFieldOption()
+                    }
+                }
+            }
+        },
+        //获取自定义选项
+        getFieldOption(){
+            let params = {
+                customFieldId: this.choseField.id,
+              }
+            this.$api.queryCustomOption(params).then(response => {
+                this.$set(this.choseField,'options',response.data.data)
+              }).catch(error => {
+              })
+        },
+        //获取产品架构
+        getProduct(){
+            let params = {
+                name: this.choseField.name,//名称
+                type: this.choseField.isProduct,//类型:1产品类别,2产品,3技术分类,4自定义树
+                typeId: this.choseField.id,//产品或类别id
+              }
+            this.$api.queryTreeNodeTree(params).then(res => {
+                if (res.code == 200) {
+                    this.$set(this.choseField,'options',res.data.data)
+                }
+              }).catch(err => {
+              })
         },
         //获取所有栏位
         async getAllCustomField(){
             const [project,product] = await Promise.allSettled([this.getProjectField(),this.getProjectDetails()])
-            var projectField = chartData.status =='fulfilled'?chartData.value:[]
-            this.projectDetails= companyAndArea.status =='fulfilled'?companyAndArea.value:{}
+            var projectField = project.status =='fulfilled'?project.value:[]
+            this.projectDetails= product.status =='fulfilled'?product.value:{}
             if(this.projectDetails.productOrCategory){
                 projectField.push(
                     {
@@ -53,9 +134,15 @@ export default{
                     }
                 )
             }
-            this.customField = projectField.forEach((item,index)=>{
-                item.keyValue = index
+             projectField.forEach((item,index)=>{
+                item.keyValue = (index+1)+''
+                if(item.type == 5 || item.type == 6){
+                    this.$set(item,'fieldValue',[])
+                }else{
+                    this.$set(item,'fieldValue','')
+                }
             })
+            this.customField =projectField
         },
         //获取自定义栏位
         async getProjectField(){
@@ -78,21 +165,7 @@ export default{
               }
               return await this.$api.queryPatentProject(params).then( async response=>await response.data.data[0])
         },
-        // //获取产品架构
-        // getProduct(){
-        //     let params = {
-        //         name: this.productName,//名称
-        //         type: this.row.type,//类型:1产品类别,2产品,3技术分类,4自定义树
-        //         typeId: this.row.id,//产品或类别id
-        //       }
-        //     this.$api.queryTreeNodeTree(params).then(res => {
-        //         if (res.code == 200) {
-        //           this.treeData = res.data.data
-        //         }
-        //       }).catch(err => {
-        //         this.$message.error(err.message)
-        //       })
-        // },
+        
         getExcelConfig() {
             this.$api.getExcelConfig().then(response => {
               this.ExcelConfig = response.data.data

+ 89 - 2
src/views/components/import/task/components/index.vue

@@ -7,7 +7,7 @@
             </div>
         </el-header>
         <el-main>
-            <el-table v-loading="loading" :data="tableData" border header-row-class-name="custom-table-header" @sort-change="sortChange" :maxHeight="tableHeight - 220">
+            <el-table v-loading="loading" :data="tableData" border header-row-class-name="custom-table-header" @sort-change="sortChange">
                 <el-table-column label="#" type="index" align="center" width="55">
                 <template slot-scope="scope">
                     <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
@@ -62,6 +62,7 @@
 </template>
 
 <script>
+import { mapGetters } from "vuex";
 export default {
   components: {},
   props: {
@@ -99,6 +100,7 @@ export default {
   },
   watch: {},
   computed: {
+    ...mapGetters(['webSocket', 'userinfo']),
     importType(){
         var a = this.$store.state.dictMessage.dictMessage.IMPORT_TASK_TYPE || []
         if(a.length>0){
@@ -126,12 +128,57 @@ export default {
   },
   created() {},
   async mounted() {
+    this.initTask()
     this.columnList = await this.$commonJS.getCustomField('importTask')
     //获取table栏位及分组字段
     await this.getColumn()
     this.getList()
   },
   methods: {
+    initTask() {
+      var webSocket = this.webSocket
+      webSocket.onmessage = (e) => {
+        const { code, data, message } = JSON.parse(e.data)
+        console.log({ code, data, message });
+        if (code === 903 || code === 904) {
+          const index = this.tableData.findIndex(item=>{return item.id == data.taskId})
+          // const index = this.taskData.findIndex(item=>{return item.id == data.id})
+          if (index === -1) {
+            if(data.projectId == this.projectId){
+              this.getList()
+            }
+            
+            // this.taskData.unshift(data)
+          } else {
+            var arr = this.tableData[index]
+            arr.index = data.index
+            arr.percentage = data.percentage
+            arr.successNum =  data.index
+            arr.status =  data.taskStatus
+            this.$set(this.tableData, index, arr)
+          }
+          if (data.complete) {
+            if(data.taskType!=2){
+              this.$message.success(`导入任务完成`)
+               for(var i = 0;i<this.tableData.length;i++){
+                if(this.tableData[i].complete==true){
+                  this.tableData.splice(i,1)
+                }
+              }
+            }else{
+              this.$message.success(`导出任务完成`)
+            }
+            
+            // console.log(this.form)
+           
+            this.getList()
+          }
+        } else if (code === 803 || code === 804) {
+          this.$message.error(message)
+          this.getList()
+        }
+      }
+    },
     //显示视图?
     showViews() {
       this.showView = false
@@ -216,6 +263,7 @@ export default {
         this.queryParams.current = val 
         this.getList()
     },
+    //排序
     sortChange({ column, prop, order }) {
       //如需要多个字段排序,则不需要清空
       var params = {
@@ -225,11 +273,50 @@ export default {
         order,
       }
       this.sort = this.$commonJS.getSortData(params)
-      this.params.current = 0
+      this.queryParams.current = 0
       this.disabled = false
       this.tableData=[]
       this.getList()
     },
+     // 网站导入暂停,继续任务操作
+     async handleSuspend(row) {
+    //   if (row.status==1) {//暂停pauseJobTask
+    //    await this.$api.pauseJobTask({taskId: row.id}).then(res => {
+    //       if (res.code == 200) {
+    //         row.status==4
+    //         this.$message.success('已成功暂停该任务')
+    //       }
+    //     })
+    //   } else if (row.status==4) {//继续
+    //    await this.$api.resumeJobTask({taskId: row.id}).then(res => {
+    //       if (res.code == 200) {
+    //         row.status==res.data
+    //         this.$message.success('继续执行该任务')
+    //       }
+    //     })
+    //   }
+    },
+     // 实时进度取消
+     cancel(row) {
+        // let task = {
+        //     taskId: row.id,
+        // }
+        // this.$api.cancelTask(task).then(res => {
+        //     if (res.code==200) {
+        //         this.$message.success('任务已取消')
+        //         if(this.taskData){
+        //             var index = this.taskData.findIndex(item=>{return item.id == row.id})
+        //             if(index!=-1){
+        //                 this.taskData.splice(index,1)
+        //             }
+        //         }else{
+        //             row.status = 5
+        //             this.getList()
+        //         }
+        //     }
+        // }).catch(error => {
+        // })
+    },
   },
 };
 </script>

+ 17 - 1
src/views/project/components/drawer/form.vue

@@ -230,6 +230,8 @@ export default {
       },
       //选择产品或产品类别
       productVisible:false,
+      //产品或产品类别架构
+      structureList:[],
       //委托方
       clientList:{
         queryParams:{
@@ -238,7 +240,7 @@ export default {
         },
         data:[],
         cb:null
-      }
+      },
       
 
     };
@@ -277,6 +279,20 @@ export default {
               valueIds:[]
       }
       this.closeProduct()
+      this.getFramework()
+    },
+    //获取产品架构集合
+    getFramework(){
+      let params = {
+        type: this.ruleForm.products.treeType,//类型:1产品类别,2产品,3技术分类,4自定义树
+        typeId: this.ruleForm.products.fieldId,//产品或类别id
+      }
+      this.$api.queryTreeNodeTree(params).then(res => {
+        if (res.code == 200) {
+          this.structureList = res.data.data
+        }
+      }).catch(err => {
+      })
     },
     //删除选择的产品或产品类别
     delProduct(){