AssignTasks.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. <template>
  2. <!-- 分配任务3(可做公共组件) -->
  3. <div style="padding:20px;height:100%;background:white">
  4. <div class="header1">
  5. <div>
  6. <span>总件数:{{totalNumber}}</span>
  7. <span> 剩余件数:{{ leaveNumber}}</span>
  8. </div>
  9. <div>
  10. <label for="">任务类型:</label>
  11. <el-select v-model="taskType">
  12. <el-option label="对比任务" value="2"></el-option>
  13. <el-option label="初筛任务" value="3"></el-option>
  14. </el-select>
  15. </div>
  16. <!-- 平均分配 -->
  17. <div>
  18. <el-button type="primary" size="small" style="height:40px" @click="handleConfirm">平均分配</el-button>
  19. <el-button @click="getPerson">添加人员</el-button>
  20. <el-button @click="finish" v-if="params">完成</el-button >
  21. </div>
  22. </div>
  23. <div style="margin-top:20px">
  24. <el-table
  25. :data="checkList"
  26. v-loading="loading"
  27. style="width: 100%"
  28. border
  29. >
  30. <el-table-column prop="name" label="人员名称" align="center" show-overflow-tooltip></el-table-column>
  31. <!-- <el-table-column prop="personnelEmail" label="Email" align="center" show-overflow-tooltip></el-table-column> -->
  32. <el-table-column prop="tenantName" label="所属租户" align="center" show-overflow-tooltip></el-table-column>
  33. <el-table-column prop="email" label="邮箱" align="center" show-overflow-tooltip></el-table-column>
  34. <el-table-column prop="assignCount" label="件数" align="center" show-overflow-tooltip>
  35. <template slot-scope="scope">
  36. <span v-if="scope.row.vVisible">{{scope.row.assignCount}}</span>
  37. <span v-if="!scope.row.vVisible">
  38. <el-input v-model="scope.row.assignCount" size="small" placeholder="请输入件数"></el-input>
  39. </span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="操作" align="center" width="300px">
  43. <template slot-scope="scope">
  44. <div class="special">
  45. <el-button v-if="scope.row.vVisible" class="items" @click.native="edit(scope.row)" :disabled="scope.row.isChoose">编辑</el-button>
  46. <el-button v-if="!scope.row.vVisible" class="items" @click.native="save(scope.row)">保存</el-button>
  47. <!-- <span>&nbsp;|&nbsp;</span> -->
  48. <el-button @click="chosePatentFile(scope.row)" v-if="scope.row.isChoose!=true">选择</el-button>
  49. <el-button @click="cancelChoose(scope.row)" v-else>取消选择</el-button>
  50. <el-button @click="removePerson(scope.row)" type="danger">移除</el-button>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. </div>
  56. <el-dialog title="人员列表" :visible.sync="personInformation" width="1000px">
  57. <Personnel-List @checked="getCheck" :checkS="checkListA" ></Personnel-List>
  58. </el-dialog>
  59. <el-dialog title="选择专利" :visible.sync="patentInformation" width="1000px">
  60. <Patent-Table ref="getPatent" :tableData="tableData" @PersonPatent="getPersonPatent" @onForm="onFormTable" :isSubmit="isSubmit" :queryParams="queryParams"></Patent-Table>
  61. <div class="pagination">
  62. <el-pagination :current-page.sync="queryParams.current" :page-size="queryParams.size" :total="total" @current-change="handleCurrentChange" layout="total, prev, pager, next, jumper" background></el-pagination>
  63. </div>
  64. <div slot="footer" class="dialog-footer">
  65. <el-button @click="close">取 消</el-button>
  66. <el-button type="primary" @click="submitPatent">确 定</el-button>
  67. </div>
  68. </el-dialog>
  69. <el-dialog title="任务名称" :visible.sync="taskInformation" width="1000px" :before-close="close2">
  70. <el-form ref="form" :model="form" :rules="taskRules">
  71. <el-form-item label="任务名称">
  72. <el-input v-model="form.name" placeholder="请输入任务名称"></el-input>
  73. </el-form-item>
  74. <el-form-item label="截止日期 :" prop="date">
  75. <el-date-picker style="width:100%"
  76. v-model="form.date"
  77. type="datetime"
  78. value-format="yyyy-MM-dd HH:mm:ss"
  79. placeholder="选择日期">
  80. </el-date-picker>
  81. </el-form-item>
  82. <el-form-item label="备注 :" >
  83. <el-input v-model="form.remark" type="textarea" placeholder="输入备注" />
  84. </el-form-item>
  85. </el-form>
  86. <div slot="footer" class="dialog-footer">
  87. <el-button @click="close2">取 消</el-button>
  88. <el-button type="primary" @click="submitTask">确 定</el-button>
  89. </div>
  90. </el-dialog>
  91. <el-dialog title="温馨提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
  92. <div class="spanDiv">
  93. <div>
  94. <span class="spanCountdown">{{ countdown }}</span>
  95. <span class="spanCenter">秒后跳转到<span class="spanJump" @click="dialogVisibleSure">报告管理</span>页面</span>
  96. </div>
  97. </div>
  98. </el-dialog>
  99. </div>
  100. </template>
  101. <script>
  102. import PersonnelList from '../../components/personnelList.vue';//导入相对特征页面
  103. import PatentTable from '../../components/patentTable.vue'
  104. export default {
  105. components: {
  106. PersonnelList,
  107. PatentTable
  108. },
  109. props:['reportId','isFinish','patentNo',"personId",'reportName'],
  110. data() {
  111. return {
  112. isFirst:true,
  113. dialogVisible:false,
  114. countdown:3,
  115. taskType:"2",
  116. taskInformation:false,
  117. form:{
  118. },
  119. patentInformation:false,
  120. personInformation: false,
  121. // totalNumber: this.tableDataA.length!=0?tableDataA.length:"",//总件数
  122. // leaveNumber: this.tableDataA.length!=0?tableDataA.length:null,//剩余件数
  123. totalNumber: '',//总件数
  124. leaveNumber: null,//剩余件数
  125. loading: false,
  126. checkList: [],
  127. patentCheck:[],
  128. pj: false,
  129. num: 0,
  130. isEqually:true,//是否点击平均分配
  131. personIdS:this.personId?this.personId:this.$route.query.personId,
  132. tableData:[],
  133. data:[],
  134. isSubmit:false,
  135. total:0,
  136. queryParams:{
  137. size:10,
  138. current:1,
  139. reportId: this.reportId?this.reportId:this.$route.query.reportId,
  140. patentName: "",
  141. // patentNo: "",
  142. patentNo: '',
  143. abstractStr:"",
  144. applicationNo:"",
  145. },
  146. taskRules:{
  147. date: [
  148. { required: true, message: '请选择日期', trigger: 'change' }
  149. ],
  150. },
  151. checkListA: [],
  152. reportNameA: {},
  153. params:{},
  154. FilterList:''
  155. }
  156. },
  157. computed:{
  158. userInfo(){
  159. return this.$store.state.admin.userinfo
  160. },
  161. },
  162. watch:{
  163. dialogVisible(val){
  164. if(val){
  165. this.out()
  166. }
  167. },
  168. // 'checkList'(val){
  169. // console.log(this.userInfo)
  170. // if (val.length == 0) {
  171. // console.log("进");
  172. // this.fu()
  173. // }
  174. // },
  175. isFinish(val) {
  176. console.log(val);
  177. if(val){
  178. this.showTask()
  179. }
  180. },
  181. },
  182. created() {
  183. // this.personIdS=this.$route.params.personId
  184. // this.queryParams.reportId=this.$route.params.reportId
  185. // this.queryParams.patentNo=this.$route.params.patentNo
  186. this.reportNameA=this.$route.query.reportName
  187. this.params =this.$route.query.params?JSON.parse(this.$route.query.params):null
  188. // console.log(this.tableDataA);
  189. },
  190. mounted() {
  191. console.log(this.reportName,this.params)
  192. if (this.params) {
  193. console.log(2)
  194. this.getList2()
  195. } else {
  196. console.log(1)
  197. this.getList()
  198. }
  199. },
  200. methods: {
  201. // 接收子组件值,筛选
  202. onFormTable(val) {
  203. this.FilterList = val
  204. // let value=JSON.parse(val)
  205. if (Object.keys(val).length != 0) {
  206. if (this.params) {
  207. for (let key in val) {
  208. this.params[key]=val[key]
  209. }
  210. this.getList2()
  211. } else {
  212. for (let key in val) {
  213. this.queryParams[key]=val[key]
  214. }
  215. this.getList()
  216. }
  217. } else {
  218. // this.getList()
  219. if (this.params) {
  220. for (let key in val) {
  221. this.params[key]=val[key]
  222. }
  223. this.getList2()
  224. } else {
  225. for (let key in val) {
  226. this.queryParams[key]=val[key]
  227. }
  228. // this.queryParams.patentName = "";
  229. // this.queryParams.patentNo = "";
  230. // this.queryParams.abstractStr = "";
  231. // this.queryParams.applicationNo = "";
  232. // this.queryParams.applicationName = "";
  233. // this.queryParams.obligeeName = "";
  234. this.getList()
  235. }
  236. }
  237. },
  238. //完成
  239. finish() {
  240. this.showTask()
  241. },
  242. // 负责人
  243. fu() {
  244. let par = {
  245. size: 10,
  246. current: 1,
  247. ID: this.personIdS,
  248. }
  249. this.$api.getPartPersonnelID(par).then(res => {
  250. if (res.code==200) {
  251. console.log(res);
  252. // res.data.name = res.data[0].personnelName
  253. // res.data[0].tenantName = res.data.personnelName
  254. res.data[0].patentNos=[]
  255. res.data[0].isChoose = false
  256. res.data[0].isEdit = false
  257. res.data[0].assignCount = this.totalNumber
  258. this.leaveNumber=0
  259. res.data[0].vVisible = true
  260. res.data[0].personId = res.data[0].id
  261. this.checkList.push(res.data[0])
  262. }
  263. })
  264. },
  265. //保存任务
  266. submitTask(){
  267. console.log(this.queryParams.reportId)
  268. var a = {
  269. taskType:this.taskType,
  270. taskName:this.form.name,
  271. reportId:this.queryParams.reportId,
  272. endTime:this.form.date,
  273. remark:this.form.remark,
  274. assigns:this.checkList,
  275. }
  276. if(this.params){
  277. a.patentVO = this.params
  278. }
  279. this.$api.addAssTask(a).then(response=>{
  280. if(response.code == 200){
  281. this.taskInformation = false
  282. this.dialogVisible = true
  283. // this.$emit('addTask',true)
  284. }
  285. })
  286. },
  287. out(){
  288. this.timer = setInterval(() => {
  289. if (this.countdown == 0) {
  290. this.$router.replace("/admin/rManage");
  291. clearInterval(this.timer);
  292. this.dialogVisible = false
  293. } else {
  294. this.countdown--;
  295. }
  296. }, 1000);
  297. },
  298. dialogVisibleSure() {
  299. this.$router.replace("/admin/rManage");
  300. },
  301. handleClose() {
  302. clearInterval(this.timer);
  303. this.dialogVisible = false;
  304. },
  305. showTask(){
  306. if(this.checkList.length>0){
  307. console.log(this.reportName)
  308. this.taskInformation = true
  309. this.form = {
  310. name:this.reportName?this.reportName + (this.taskType=="2"?'对比':'初筛')+'任务':this.reportNameA + (this.taskType=="2"?'对比':'初筛')+'任务'
  311. }
  312. }else{
  313. this.$alert('您未添加分配人员', '提示', {
  314. confirmButtonText: '确定',
  315. type:'warning',
  316. callback: action => {
  317. this.$emit('addTask',false)
  318. }
  319. });
  320. }
  321. },
  322. getCheck(val) {//人员信息
  323. console.log("getCheck",val)
  324. this.checkList = val
  325. this.personInformation=false
  326. },
  327. edit(row) {//编辑
  328. this.num = row.assignCount
  329. row.vVisible = !row.vVisible
  330. this.checkList = JSON.parse(JSON.stringify(this.checkList))
  331. },
  332. save(row){//保存
  333. row.vVisible = !row.vVisible
  334. var a= row.assignCount
  335. row.isEdit = false
  336. for(var i=0;i<this.checkList.length;i++){
  337. if(this.checkList[i].isChoose==true||this.checkList[i].isEdit==true){
  338. a = Number(a) + Number(this.checkList[i].assignCount)
  339. }
  340. }
  341. if(a>this.totalNumber){
  342. row.assignCount = this.num
  343. }else{
  344. if(row.assignCount!=0){
  345. row.isEdit = true
  346. }
  347. this.leaveNumber = Number(this.totalNumber) - Number(a)
  348. }
  349. if(this.isEqually){
  350. this.beforeHandleConfirm()
  351. }
  352. },
  353. getPerson() {
  354. this.personInformation = true
  355. this.checkListA = JSON.parse(JSON.stringify(this.checkList))
  356. console.log(this.checkListA);
  357. },
  358. //移除人员
  359. removePerson(row){
  360. var index = this.checkList.findIndex(item=>{
  361. return item.id == row.id
  362. })
  363. if(index !=-1){
  364. this.checkList.splice(index,1)
  365. this.leaveNumber = Number(this.leaveNumber) + row.assignCount
  366. }
  367. },
  368. submit() {
  369. this.personInformation = false
  370. },
  371. beforeHandleConfirm(){
  372. if(this.checkList.length>0){
  373. var data = JSON.parse(JSON.stringify(this.checkList))
  374. for(var i = 0;i<data.length;i++){
  375. if(data[i].isChoose==false&&data[i].isEdit==false){
  376. // this.leaveNumber = Number(this.leaveNumber) + Number(data[i].assignCount)
  377. data[i].assignCount=0
  378. }
  379. }
  380. this.checkList = data
  381. this.handleConfirm()
  382. }
  383. },
  384. // 平均分配
  385. handleConfirm() {
  386. this.isEqually = true
  387. if (this.checkList.length > 0) {
  388. // var num = parseInt(Number(this.totalNumber) / Number(this.checkList.length))
  389. var a = 0
  390. for(var i=0;i<this.checkList.length;i++){
  391. if(this.checkList[i].isChoose==true||this.checkList[i].isEdit==true){
  392. a = Number(a) + Number(this.checkList[i].assignCount)
  393. } else {
  394. this.checkList[i].assignCount=0
  395. }
  396. }
  397. this.leaveNumber = Number(this.totalNumber) - Number(a)
  398. console.log(this.leaveNumber);
  399. var data = JSON.parse(JSON.stringify(this.checkList))
  400. if(this.leaveNumber>0){
  401. this.getRowNumber(data)
  402. }
  403. // data.forEach(item => {
  404. // item.assignCount = num
  405. // });
  406. // this.leaveNumber = Number(this.totalNumber) % Number(this.checkList.length)
  407. // // this.getList()
  408. this.checkList = data
  409. }
  410. },
  411. getRowNumber(data){
  412. for(var i = 0;i<data.length;i++){
  413. if(this.leaveNumber>0){
  414. if(data[i].isChoose==false&&data[i].isEdit==false){
  415. data[i].assignCount+=1
  416. this.leaveNumber-=1
  417. }
  418. }else{
  419. i=data.length
  420. }
  421. }
  422. if(this.leaveNumber>0){
  423. this.getRowNumber(data)
  424. }
  425. },
  426. chosePatentFile(row) {
  427. console.log(this.FilterList)
  428. this.isSubmit = true
  429. this.patentInformation=true
  430. // this.$refs.getPatent.opens(this.tableData)
  431. this.personIdS = row.id
  432. this.queryParams.current = 1
  433. if (this.params) {
  434. this.params.current = 1
  435. for (let key in this.FilterList) {
  436. this.params[key]=''
  437. }
  438. this.getList2()
  439. } else {
  440. for (let key in this.FilterList) {
  441. this.queryParams[key]=''
  442. }
  443. this.getList()
  444. }
  445. },
  446. cancelChoose(row){
  447. row.isChoose = false
  448. row.isEdit = false
  449. row.assignCount = 0
  450. // this.leaveNumber = this.leaveNumber+row.patentNos.length
  451. row.patentNos = []
  452. var a = 0
  453. for(var i=0;i<this.checkList.length;i++){
  454. if(this.checkList[i].isChoose==true||this.checkList[i].isEdit==true){
  455. a = Number(a) + Number(this.checkList[i].assignCount)
  456. }
  457. }
  458. this.leaveNumber = Number(this.totalNumber) - Number(a)
  459. if(this.isEqually){
  460. this.beforeHandleConfirm()
  461. }
  462. },
  463. close(){
  464. this.isSubmit = false
  465. this.patentInformation = false
  466. },
  467. close2(){
  468. this.taskInformation = false
  469. this.$emit('addTask',false)
  470. },
  471. getPersonPatent(val){
  472. this.patentCheck = val
  473. },
  474. submitPatent(){
  475. if(this.patentCheck.length>0){
  476. var index = this.checkList.findIndex(item=>{
  477. return item.id == this.personIdS
  478. })
  479. if(index!=-1){
  480. var data = JSON.parse(JSON.stringify(this.checkList))
  481. data[index].patentNos = this.patentCheck
  482. data[index].isChoose = true
  483. data[index].assignCount = this.patentCheck.length
  484. this.checkList = data
  485. var a = 0
  486. for(var i=0;i<this.checkList.length;i++){
  487. if(this.checkList[i].isChoose==true||this.checkList[i].isEdit==true){
  488. a = Number(a) + Number(this.checkList[i].assignCount)
  489. }
  490. }
  491. if(a>this.totalNumber){
  492. data[index].patentNos = []
  493. data[index].isChoose = false
  494. data[index].assignCount = 0
  495. }else{
  496. this.leaveNumber = Number(this.totalNumber) - Number(a)
  497. }
  498. // this.leaveNumber = this.leaveNumber - this.patentCheck.length
  499. if(this.isEqually){
  500. this.beforeHandleConfirm()
  501. }
  502. }
  503. }
  504. console.log(this.patentCheck)
  505. this.close()
  506. },
  507. handleCurrentChange(val) {//分页
  508. if (this.params) {
  509. this.params.current = val;
  510. this.getList2()
  511. } else {
  512. this.queryParams.current = val;
  513. this.getList()
  514. }
  515. },
  516. //获取专利
  517. async getList() {
  518. await this.$api.getSureCompareFile(this.queryParams).then(response=>{
  519. if(response.code==200){
  520. this.tableData = response.data.records
  521. this.total = response.data.total
  522. if(this.isFirst==true){
  523. this.totalNumber = this.total
  524. this.leaveNumber = this.leaveNumber===null?this.total:this.leaveNumber
  525. }
  526. this.isFirst = false
  527. // var a = []
  528. // var b=this.tableData
  529. for(var i=0;i<this.checkList.length;i++){
  530. if(this.checkList[i].patentNos.length>0){
  531. for(var j=0;j<this.checkList[i].patentNos.length;j++){
  532. // console.log(b)
  533. var index = this.tableData.findIndex(item=>{
  534. return item.patentNo == this.checkList[i].patentNos[j]
  535. })
  536. if(index!=-1){
  537. this.tableData[index].disabled = true
  538. }
  539. }
  540. }
  541. }
  542. if (this.checkList.length==0) {
  543. this.fu()
  544. }
  545. }
  546. })
  547. },
  548. async getList2() {
  549. // 需要根据报告id查询所有对比文件
  550. await this.$api.getSureCompareFile(this.params).then(response => {
  551. // console.log(res);
  552. if(response.code==200){
  553. this.tableData = response.data.records
  554. console.log(this.tableData,response.data.records);
  555. this.total = response.data.total
  556. this.totalNumber = this.total
  557. this.leaveNumber = this.leaveNumber===null?this.total:this.leaveNumber
  558. // var a = []
  559. // var b=this.tableData
  560. for(var i=0;i<this.checkList.length;i++){
  561. if(this.checkList[i].patentNos.length>0){
  562. for(var j=0;j<this.checkList[i].patentNos.length;j++){
  563. // console.log(b)
  564. var index = this.tableData.findIndex(item=>{
  565. return item.patentNo == this.checkList[i].patentNos[j]
  566. })
  567. if(index!=-1){
  568. this.tableData[index].disabled = true
  569. }
  570. }
  571. }
  572. }
  573. if (this.checkList.length==0) {
  574. this.fu()
  575. }
  576. }
  577. })
  578. },
  579. },
  580. getData(){
  581. }
  582. }
  583. </script>
  584. <style lang="scss" scoped>
  585. .header1{
  586. display: flex;
  587. justify-content: space-between;
  588. align-items:center;
  589. }
  590. .spanDiv{
  591. display: flex;
  592. justify-content: center;
  593. height: 100px ;
  594. }
  595. .spanCountdown{
  596. color: red;
  597. font-size: 24px;
  598. margin: 10px;
  599. }
  600. .spanCenter{
  601. margin: 0;
  602. font-size: 16px;
  603. }
  604. .spanJump:hover{
  605. cursor :pointer;
  606. color: red;
  607. text-decoration:underline;
  608. }
  609. .spanJump{
  610. font-size: 16px;
  611. margin: 10px 0;
  612. color: #42A5F5;
  613. }
  614. </style>