zhuliu 1 год назад
Родитель
Сommit
2d7a761b14

+ 4 - 1
src/views/components/dialog/ClientTable.vue

@@ -29,8 +29,9 @@
           <el-table-column width="55" align="center">
             <template slot-scope="scope">
               <div>
+                <!-- (personIds.indexOf(scope.row.id) != -1 || personIds.indexOf(scope.row.id+'')!=-1) -->
                 <el-checkbox
-                  :checked="(personIds.indexOf(scope.row.id) != -1 || personIds.indexOf(scope.row.id+'')!=-1)"
+                  :checked="personIds.filter(item=>{return item==scope.row.id}).length>0"
                   @change="getCheck(scope.row)"
                   v-if="showCheck"
                 ></el-checkbox>
@@ -86,9 +87,11 @@
 export default {
   props: {
     personIds: {
+      type:Array,
       default: [],
     },
     persons: {
+      type:Array,
       default: [],
     },
   },

+ 10 - 40
src/views/project/patentCollection/components/mixins/index.js

@@ -35,11 +35,17 @@ export const projectData = {
     //仅展示
     onlyReveal:{
       default:false
-    } 
+    } ,
+    patentNoList:{
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
   },
+
   data() {
     return {
-      // refresh:false
     }
   },
 
@@ -67,7 +73,7 @@ export const projectData = {
         if(this.projectId){
           this.patentNoList.push(patent.patentNo)
         }else{
-          this.patentNoList.push(patent.applicationNo)
+          this.patentNoList.push(patent.appNo)
         }
         
       } else {
@@ -80,20 +86,9 @@ export const projectData = {
 export const handleData = {
   // mixins: [highlight],
   props: {
-    selected: {
-      type: Array
-    },
-    patentNoList:{
-      type: Array,
-      default: () => {
-        return []
-      }
-    }
   },
   data() {
     return {
-      // refresh: true,
-      click: false,
     }
   },
   mounted() {
@@ -186,32 +181,7 @@ export const handleData = {
           break
       }
     },
-    // 勾选中专利进行处理
-    changeSelect(patent) {
-      this.click = true
-      const index1 = this.patentNoList.indexOf(patent.patentNo)
-      if (index1 === -1) {
-        if(this.projectId){
-          this.patentNoList.push(patent.patentNo)
-        }else{
-          this.patentNoList.push(patent.appNo)
-        }
-        
-      } else {
-        this.patentNoList.splice(index1, 1)
-      }
-      if(patent.id){
-         const index = this.selected.indexOf(patent.id)
-          if (index === -1) {
-            this.selected.push(patent.id)
-          } else {
-            this.selected.splice(index, 1)
-          }
-      }
-      
-      this.$emit('select-change', this.selected)
-      this.$emit('addSelect',patent.applicationNo)
-    },
+
   },
 }
 

+ 1 - 1
src/views/project/patentCollection/components/views/Table.vue

@@ -4,7 +4,7 @@
       <el-table-column label="#" width="60" type="index" align="center">
         <template slot-scope="scope">
           <div v-if="refresh">
-            <el-checkbox :label="scope.row.id" @change="changeSelect(scope.row)" :checked="patentNoList.indexOf(scope.row.patentNo)!== -1 || patentNoList.indexOf(scope.row.applicationNo)!== -1 ">
+            <el-checkbox :label="scope.row.id" @change="changeSelect(scope.row)" :checked="patentNoList.filter(item=>{return item==scope.row.patentNo || item == scope.row.appNo}).length>0 ">
               <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
             </el-checkbox>
           </div>

+ 92 - 130
src/views/report/components/allocationTask/components/allocationTask.vue

@@ -21,15 +21,15 @@
       </div>
     </div>
     <div style="margin-top:20px">
-      <el-table :data="tableData" v-loading="loading" style="width: 100%" border>
+      <el-table v-if="showTable" :data="tableData" v-loading="loading" style="width: 100%" border>
         <el-table-column prop="name" label="人员名称" align="center" show-overflow-tooltip></el-table-column>
         <el-table-column prop="tenantName" label="所属租户" align="center" show-overflow-tooltip></el-table-column>
         <el-table-column prop="email" label="邮箱" align="center" show-overflow-tooltip></el-table-column>
-        <el-table-column prop="assignCount" label="件数" align="center" show-overflow-tooltip>
+        <el-table-column prop="patentNum" label="件数" align="center" show-overflow-tooltip>
           <template slot-scope="scope">
-            <span v-if="scope.row.vVisible">{{ scope.row.assignCount }}</span>
+            <span v-if="scope.row.vVisible">{{ scope.row.patentNum }}</span>
             <span v-if="!scope.row.vVisible">
-              <el-input v-model="scope.row.assignCount" size="small" placeholder="请输入件数"></el-input>
+              <el-input v-model="scope.row.patentNum2" size="small" placeholder="请输入件数"></el-input>
             </span>
           </template>
         </el-table-column>
@@ -38,12 +38,12 @@
             <div class="special">
               <el-button v-if="scope.row.vVisible" class="items" @click.native="edit(scope.row)"
                 :disabled="scope.row.isChoose">编辑</el-button>
-              <el-button v-if="!scope.row.vVisible" class="items" @click.native="save(scope.row)">保存</el-button>
+              <el-button v-else class="items" @click.native="save(scope.row)">保存</el-button>
               <el-button @click="chosePatentFile(scope.row)" v-if="scope.row.isChoose != true">选择</el-button>
               <el-tooltip v-else class="item" effect="dark" content="取消选择的专利" placement="top">
                 <el-button @click="cancelChoose(scope.row)">取消</el-button>
               </el-tooltip>
-              <el-button @click="removePerson(scope.row)" type="danger">移除</el-button>
+              <el-button @click="removePerson(scope)" type="danger">移除</el-button>
             </div>
           </template>
         </el-table-column>
@@ -97,7 +97,7 @@ export default {
     }
     return {
       totalNumber: 0,//总件数
-      leaveNumber: null,//剩余件数
+      leaveNumber: 0,//剩余件数
       // 任务类型
       taskType: "2",
       // 表格数据源
@@ -109,14 +109,14 @@ export default {
       },
       // 表格的loading
       loading: false,
-      // 编辑时候的数字
-      num: 0,
       // 控制温馨提示弹窗
       dialogVisible: false,
       // 倒计时初始值
       countdown: 3,
-      //是否点击平均分配
-      isEqually:true,
+      //当前数据
+      row:{},
+      //
+      showTable:true,
       // 完成???
       params: {},
 
@@ -156,7 +156,7 @@ export default {
     },
     getUser() {
       let user = JSON.parse(JSON.stringify(this.userinfo))
-      user.assignCount = this.totalNumber
+      user.patentNum = this.totalNumber
       user.vVisible = true
       user.isChoose = false
       user.isEdit = false
@@ -171,119 +171,74 @@ export default {
       this.dialogVisible = false;
     },
     //移除人员
-    removePerson(row) {
-      let index = this.tableData.findIndex(item => {
-        return item.id == row.id
-      })
+    removePerson(scope) {
+      let index = scope.$index
       if (index != -1) {
         this.tableData.splice(index, 1)
       }
+      this.handleConfirm()
     },
     // 取消
     cancelChoose(row) {
-
+      row.patentNos = []
+      this.$set(row,'patentNum', 0)
+      row.isChoose  =false
+      this.handleConfirm()
     },
     // 选择专利
     chosePatentFile(row) {
+      this.row = row
       this.$refs.checkPatent.open(this.projectId)
     },
     // 子组件选择的专利号数组数据 
     checkPatentList(val) {
-      console.log(val);
-      if (val.length > 0) {
-        var index = this.tableData.findIndex(item => {
-          return item.id == this.personIdS
-        })
-        if (index != -1) {
-          var data = JSON.parse(JSON.stringify(this.tableData))
-          data[index].patentNos = val
-          data[index].isChoose = true
-          data[index].assignCount = val.length
-          this.tableData = data
-          var a = 0
-          for (var i = 0; i < this.tableData.length; i++) {
-            if (this.tableData[i].isChoose == true || this.tableData[i].isEdit == true) {
-              a = Number(a) + Number(this.tableData[i].assignCount)
-            }
-          }
-          if (a > this.totalNumber) {
-            data[index].patentNos = []
-            data[index].isChoose = false
-            data[index].assignCount = 0
-          } else {
-            this.leaveNumber = Number(this.totalNumber) - Number(a)
-          }
-          // this.leaveNumber = this.leaveNumber - this.patentCheck.length
-
-          if (this.isEqually) {
-            this.beforeHandleConfirm()
-          }
-        }
-      }
-    },
-    // 公用方法
-    beforeHandleConfirm() {
-      if (this.tableData.length > 0) {
-        var data = JSON.parse(JSON.stringify(this.tableData))
-        for (var i = 0; i < data.length; i++) {
-          if (data[i].isChoose == false && data[i].isEdit == false) {
-            data[i].assignCount = 0
-          }
-        }
-        this.tableData = data
+      if(val.length>0){
+        this.row.isChoose = true
+        this.row.patentNos = val
+        this.$set(this.row,'patentNum', val.length)
         this.handleConfirm()
       }
     },
+   
     //编辑
     edit(row) {
-      this.num = row.assignCount
+      this.$set(row,'patentNum2',row.patentNum)
       row.vVisible = !row.vVisible
-      this.tableData = JSON.parse(JSON.stringify(this.tableData))
+      // this.tableData = JSON.parse(JSON.stringify(this.tableData))
     },
     //保存
     save(row) {
-      if (isNaN(row.assignCount)) {
+      if (isNaN(row.patentNum2)) {
         this.$message.error('请输入数字')
         return false
-      } else if (Number(row.assignCount) < 0 || Number(row.assignCount) + this.leaveNumber > this.totalNumber) {
+      } else if (Number(row.patentNum2) < 0 || Number(row.patentNum2) + this.leaveNumber > this.totalNumber) {
         this.$message.error('请输入正确数量')
         return false
       }
       row.vVisible = !row.vVisible
-      var a = row.assignCount
-      row.isEdit = false
-      for (var i = 0; i < this.tableData.length; i++) {
-        if (this.tableData[i].isChoose == true || this.tableData[i].isEdit == true) {
-          a = Number(a) + Number(this.tableData[i].assignCount)
-        }
-      }
-      if (a > this.totalNumber) {
-        row.assignCount = this.num
-      } else {
-        if (row.assignCount != 0) {
-          row.isEdit = true
-        }
-
-        this.leaveNumber = Number(this.totalNumber) - Number(a)
-      }
-      if (this.isEqually) {
-        this.beforeHandleConfirm()
-      }
+      // row.patentNum = row.patentNum2
+      this.$set(row,'patentNum',row.patentNum2)
+      row.isEdit = true
+      row.patentNos = []
+      this.handleConfirm()
     },
     //完成
     finish() {
 
     },
+
     // 添加人员
     getPerson() {
-      this.$refs.personList.open()
+      var personIds = this.tableData.map(item=>item.id)
+      var persons = JSON.parse(JSON.stringify(this.tableData))
+      this.$refs.personList.open(personIds,persons)
     },
     //获取子组件返回的人员信息
     getPersonIds({ personIds, persons }) {
       if (persons.length > 0) {
         persons.forEach(item => {
-          item.assignCount = 0
-          item.vVisible = true
+          item.patentNum = 0
+          this.$set(item,'vVisible',true)
           if (this.tableData.length > 0) {
             let index = this.tableData.findIndex(dataItem => {
               return dataItem.id == item.id
@@ -297,61 +252,68 @@ export default {
             this.tableData.push(item)
           }
         });
-        console.log(this.tableData);
+        this.handleConfirm()
       }
     },
+
     // 平均分配
     handleConfirm() {
-      this.isEqually = true
-      if (this.tableData.length > 0) {
-
-        if (this.tableData.length == 1) {
-          // isChoose是否禁用编辑
-          if (this.tableData[0].isChoose == false && this.tableData[0].isEdit == false) {
-            this.tableData[0].assignCount = this.totalNumber
-            this.leaveNumber = 0
-          }
-          return true
+      if(this.tableData.length==0){
+        this.$message.warning('请先选择人员!!!')
+        return false
+      }
+      var {user,leaveNumber} = this.clearPatentNum()
+      if(user.length == 0){
+        this.leaveNumber = leaveNumber
+        return
+      }
+      
+        var pjNum = parseInt(leaveNumber / user.length)?parseInt(leaveNumber / user.length):0
+        if(pjNum!=0){
+          user.forEach(item=>{
+            this.$set(item,'patentNum',pjNum)
+          })
         }
-
-
-        var a = 0
-        for (var i = 0; i < this.tableData.length; i++) {
-          if (this.tableData[i].isChoose == true || this.tableData[i].isEdit == true) {
-            a = Number(a) + Number(this.tableData[i].assignCount)
-          } else {
-            this.tableData[i].assignCount = 0
-          }
+        var leaveNumber2 = leaveNumber - (user.length * pjNum)
+        try{
+          user.forEach(item=>{
+            if(leaveNumber2>0){
+              var num = item.patentNum + 1
+              this.$set(item,'patentNum',num)
+              leaveNumber2--
+            }else{
+              throw Error();
+            }
+          })
         }
+        catch{
 
-
-        this.leaveNumber = Number(this.totalNumber) - Number(a)
-        //console.log(this.leaveNumber,this.tableData);
-        var data = JSON.parse(JSON.stringify(this.tableData))
-        if (this.leaveNumber > 0) {
-          this.getRowNumber(data)
         }
-        this.tableData = data
-      }
+      this.leaveNumber = 0
+      this.refreshTable()
     },
-    getRowNumber(data) {
-      var a = false
-      for (var i = 0; i < data.length; i++) {
-        if (this.leaveNumber > 0) {
-          if (data[i].isChoose == false && data[i].isEdit == false) {
-            a = true
-            data[i].assignCount += 1
-            this.leaveNumber -= 1
-          }
-        } else {
-          i = data.length
-        }
-      }
-
-      if (data.length > 1 && a) {
-        if (this.leaveNumber > 0) {
-          this.getRowNumber(data)
+    //刷新表格
+    refreshTable(){
+      this.showTable = false
+      this.$nextTick(()=>{
+        this.showTable = true
+      })
+    },
+    //清空人员分配专利数量
+    clearPatentNum(){
+      var user = []
+      var leaveNumber = this.totalNumber
+      this.tableData.forEach(item=>{
+        if(!item.isChoose && !item.isEdit){
+          item.patentNum = 0
+          user.push(item)
+        }else{
+          leaveNumber -= item.patentNum
         }
+      })
+      return {
+        user,
+        leaveNumber
       }
     },
 

+ 5 - 1
src/views/report/components/checkPatent/checkPatent.vue

@@ -3,7 +3,7 @@
   <div>
     <el-dialog title="选择专利" :visible.sync="dialogVisible" width="800px" :before-close="handleClose">
 
-      <Table :column="column" :tableData="tableData" :queryParams="queryParams" :refresh="true"
+      <Table :column="column" :tableData="tableData" :queryParams="queryParams" :refresh="refresh"
         :patentNoList="patentNoList" :projectId="projectId"></Table>
 
       <div style="text-align:center;margin-top:10px;">
@@ -78,6 +78,7 @@ export default {
       ],
       // 选中的数据
       patentNoList: [],
+      refresh:true
     }
   },
   mounted() {
@@ -86,6 +87,7 @@ export default {
   methods: {
     // 打开弹窗
     open(projectId) {
+      this.refresh = true
       this.projectId = projectId
       this.getList()
       this.dialogVisible = true
@@ -97,6 +99,8 @@ export default {
     },
     // 关闭弹窗
     handleClose() {
+      this.patentNoList = []
+      this.refresh = false
       this.dialogVisible = false
     },
    

+ 2 - 2
src/views/report/components/patentList/patentList.vue

@@ -173,10 +173,10 @@ export default {
           this.toAllocationTask()
           break;
         case '2'://专利号导入
-          this.patentImport(1)
+          this.patentImport(2)
           break;
         case '3'://excel导入
-          this.patentImport(2)
+          this.patentImport(1)
           break;
         case '4'://检索导入
           this.patentImport(4)