customFields.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <template>
  2. <div class="patent-tree-filter">
  3. <el-container>
  4. <el-header class="patent-query-filter-header" v-if="isHidden">
  5. <!-- <template v-if="readList.length>0"> -->
  6. <div class="query-read-status" style="margin: 0px 5px 0px 5px;" v-for="(item, key) in readList" :class="{ 'query-read-status_is-active' : readStatus[key].value == returnData.read }" @click="handleReadQuery(readStatus[key].value)">
  7. <span class="a">(<span class="b">{{ item }}</span>)</span>
  8. <span class="c">{{ readStatus[key].lable }}</span>
  9. </div>
  10. <!-- </template>
  11. <template v-else>
  12. <div style="margin: 0 auto;" >
  13. 暂无数据
  14. </div>
  15. </template> -->
  16. <!-- <div class="query-read-status" style="margin: 0px 5px 0px 5px;" v-for="(item, key) in readList" :class="{ 'query-read-status_is-active' : readStatus[key].value == returnData.read }" @click="handleReadQuery(readStatus[key].value)">
  17. <span class="a">(<span class="b">{{ item }}</span>)</span>
  18. <span class="c">{{ readStatus[key].lable }}</span>
  19. </div> -->
  20. </el-header>
  21. <el-main class="patent-tree-filter-main" >
  22. <template v-if="field.length>0">
  23. <el-collapse v-model="activeNames" @change="handleChange" style="margin: 0px 5px 0px 5px;">
  24. <!-- v-if="sourceQuery[item.key]" -->
  25. <el-collapse-item v-for="item in field" :title="item.name" :name="item.id" v-if="sourceQuery[item.id] && item.type!=2">
  26. <div class="patent-query-filter-search">
  27. <div class="patent-query-filter-search-input">
  28. <el-input v-if="(item.type!=1&&item.type!=6)" v-model="sourceQuery[item.id].name" size="small" placeholder="请输入查询内容"></el-input>
  29. <div v-else-if="item.type!=6" class="year-data-picker">
  30. <el-date-picker clear-icon size="small" v-model="sourceQuery[item.id].datePicker[0]" type="year" value-format="yyyy" placeholder="请选择时间"></el-date-picker>
  31. <span style="margin: 5px;">至</span>
  32. <el-date-picker clear-icon size="small" v-model="sourceQuery[item.id].datePicker[1]" type="year" value-format="yyyy" placeholder="请选择时间"></el-date-picker>
  33. </div>
  34. </div>
  35. <el-button v-if="item.type!=6" @click="handleSearch(item)" size="small" type="primary" icon="el-icon-search" circle></el-button>
  36. </div>
  37. <!-- <el-checkbox-group v-model="sourceQuery[item.key].checked" @change="onChange(item.key)"> -->
  38. <!-- v-moudel勾选 -->
  39. <el-checkbox-group v-if="item.type!=6" v-model="sourceQuery[item.id].checked" @change="onChange(item.id)">
  40. <div class="source-checkbox">
  41. <el-checkbox v-for="source in sourceData[item.id]" :label="source.key">
  42. <span class="source-checkbox-label" :title="source.label">{{source.label}}</span>
  43. <span class="source-checkbox-count">({{source.count}})</span>
  44. </el-checkbox>
  45. </div>
  46. </el-checkbox-group>
  47. <el-tree
  48. v-else
  49. @check-change="onChangeTree"
  50. :ref="item.id"
  51. :data="item.option"
  52. show-checkbox
  53. node-key="id"
  54. check-strictly
  55. default-expand-all
  56. >
  57. <div class="custom-filter-tree-node" slot-scope="{ node, data }">
  58. <span class="name">{{ data.name }}</span>
  59. <span class="total">({{ getCount(item.id, data.id) }})</span>
  60. </div>
  61. </el-tree>
  62. <div class="patent-query-filter-search-bottom" v-if="item.type!=6">
  63. <el-button type="success" size="small" @click="handleSelectAll(item)" >全选</el-button>
  64. <el-button type="danger" size="small" @click="handleSelectCancel(item)">取消</el-button>
  65. <el-button v-if="!sourceQuery[item.id].isEnd" type="primary" size="small" @click="handleLoadMore(item)"
  66. :loading="sourceQuery[item.id].loading">加载更多</el-button>
  67. <span v-else></span>
  68. </div>
  69. </el-collapse-item>
  70. </el-collapse>
  71. <el-collapse style="margin: 0px 5px 0px 5px;border-top:0">
  72. <el-collapse-item v-if="!taskId" v-for="item in taskSources" :title="item.taskType" >
  73. <el-tree
  74. :data="item.personDates"
  75. show-checkbox
  76. @check="onChangeTree1"
  77. >
  78. <span class="custom-tree-node" slot-scope="{ node, data }">
  79. <span>{{ data.name }}</span>
  80. <span >({{ data.number }})</span>
  81. </span>
  82. </el-tree>
  83. </el-collapse-item>
  84. </el-collapse>
  85. </template>
  86. <template v-else>
  87. <!-- <template > -->
  88. <div class="no-data">暂无数据</div>
  89. </template>
  90. </el-main>
  91. </el-container>
  92. </div>
  93. </template>
  94. <script>
  95. import { patentQueryMixins } from "@/views/task/components/mixins";
  96. import { getTreeLastChildren, getTreeDataList } from "@/utils";
  97. export default {
  98. mixins: [patentQueryMixins],
  99. props:["reportId","taskId","isHidden"],
  100. data() {
  101. return {
  102. taskSources:[],
  103. taskSources1:[],
  104. notAssignTypes:[],
  105. activeNames: [],
  106. hasSource: [],
  107. sourceQuery: [],
  108. queryParams: {
  109. reportId: this.reportId,
  110. folder: null,
  111. fieldId: "",
  112. // type:6,
  113. taskId: this.taskId,
  114. current: 1,
  115. size: 10,
  116. total: 0,
  117. },
  118. sourceData: [],
  119. // switchType: false,
  120. onChanges: [],
  121. // selected: {},
  122. field: [],//数据
  123. visible: false,
  124. form: [],
  125. data: [],
  126. loading: false,
  127. // btnLoading: false,
  128. // btnLoading2: false,
  129. readList: {
  130. },
  131. returnData: {
  132. taskStatus: '',
  133. filedOptions: [],
  134. read:"3",
  135. },
  136. keyId: "",
  137. readStatus: {
  138. all: {
  139. lable: "全部",
  140. value:"3"
  141. },
  142. read: {
  143. lable: "已读",
  144. value:"1"
  145. },
  146. noRead: {
  147. lable: "未读",
  148. value:"0"
  149. },
  150. },
  151. taskStatus:"",
  152. }
  153. },
  154. watch: {
  155. closeFieldDrawer() {
  156. this.getPatentQueryField()
  157. },
  158. // submitIndexSetting() {
  159. // this.refreshSourceData()
  160. // }
  161. },
  162. mounted() {
  163. // this.getPatentQueryTreeSource()
  164. },
  165. methods: {
  166. async loadData() {
  167. await this.getPatentQueryField(false, true)
  168. await this.getTaskSources()
  169. this.taskReTaskStateCount()
  170. },
  171. getCount(id, node) {
  172. //console.log(this.sourceData,id,node);
  173. if (!this.sourceData[id]) {
  174. return 0;
  175. }
  176. const data = this.sourceData[id].find(item => parseInt(item.key) === node)
  177. if (data) {
  178. return data.count
  179. }
  180. return 0
  181. },
  182. //模糊查询,每个面板中查询自定义字段的选项
  183. handleSearch(item) {
  184. //console.log(item, this.sourceData, this.sourceQuery);
  185. this.sourceData[item.id] = []
  186. this.sourceQuery[item.id].checked = []
  187. this.sourceQuery[item.id].current = 1
  188. // //console.log(item);
  189. let sourceQueryName = this.sourceQuery[item.id].name
  190. let a = {
  191. fieldId: item.id,
  192. name: sourceQueryName,
  193. }
  194. this.$api.getPatentField(a).then(res => {
  195. //console.log("查询成功", res);
  196. res.data.map(item => {
  197. item.label = item.name
  198. // item.key = item.id
  199. return item
  200. })
  201. this.$set(this.sourceData,item.id,res.data)
  202. })
  203. },
  204. onChangeTree1(a,b){
  205. //console.log(a,b)
  206. // var c = this.taskSources1.findIndex(ele=>{
  207. // return ele.taskTypeId == b.halfCheckedNodes[0].taskTypeId
  208. // })
  209. // if(c!=-1){
  210. // this.taskSources1= []
  211. // var notAssignTypes = []
  212. // }else{
  213. // }
  214. if(a.name == '未分配'){
  215. var c = this.notAssignTypes.findIndex(ele=>{
  216. return ele == a.taskTypeId
  217. })
  218. if(c!=-1){
  219. this.notAssignTypes.splice(c,1)
  220. }
  221. }else{
  222. this.taskSources1 = this.taskSources1.filter(item=>{
  223. var c = b.halfCheckedNodes.length>0?b.halfCheckedNodes[0].taskTypeId:a.taskTypeId
  224. //console.log(item.taskTypeId,c,item.taskTypeId != c)
  225. return item.taskTypeId != c
  226. })
  227. //console.log(this.taskSources1)
  228. // this.taskSources1.forEach((item,index)=>{
  229. // if(item.taskTypeId == b.halfCheckedNodes.length>0?b.halfCheckedNodes[0].taskTypeId:a.taskTypeId){
  230. // //console.log(index)
  231. // this.taskSources1.splice(index,1)
  232. // }
  233. // })
  234. }
  235. b.checkedNodes.forEach(item=>{
  236. if(item.name == '未分配'){
  237. this.notAssignTypes.push(a.taskTypeId)
  238. }else{
  239. this.taskSources1.push({
  240. taskTypeId:b.halfCheckedNodes.length>0?b.halfCheckedNodes[0].taskTypeId:b.checkedNodes[0].taskTypeId,
  241. taskIds:b.halfCheckedNodes.length>0?b.halfCheckedNodes[0].taskIds:b.checkedNodes[0].taskIds,
  242. personId:b.halfCheckedNodes.length>0?b.halfCheckedNodes[0].personId:b.checkedNodes[0].personId,
  243. state:item.name == '已完成'?1:0
  244. })
  245. }
  246. })
  247. var c = {
  248. taskSources:this.taskSources1,
  249. notAssignTypes:this.notAssignTypes
  250. }
  251. //console.log(c)
  252. this.$emit('search',c)
  253. },
  254. // 树类型勾选后进行筛选
  255. onChangeTree(a, b) {
  256. //console.log(a,b);
  257. if (b) {
  258. this.sourceQuery[a.fieldId].checked.push(a.id);
  259. if (a.children) {
  260. this.onTree(a.children)
  261. }
  262. } else {
  263. //console.log(this.sourceQuery[a.fieldId].checked);
  264. let aId=this.sourceQuery[a.fieldId].checked.findIndex(item => {
  265. return item==a.id
  266. })
  267. if (aId!=-1) {
  268. this.sourceQuery[a.fieldId].checked.splice(aId,1)
  269. }
  270. if (a.children) {
  271. this.onTree2(a.children)
  272. }
  273. }
  274. this.onChange();
  275. },
  276. onTree2(data) {
  277. //console.log(data,"进来");
  278. for (let i = 0; i < data.length; i++){
  279. let aId=this.sourceQuery[data[i].fieldId].checked.findIndex(item => {
  280. return item==data[i].id
  281. })
  282. //console.log(aId);
  283. if (aId!=-1) {
  284. this.sourceQuery[data[i].fieldId].checked.splice(aId, 1)
  285. //console.log(this.sourceQuery[data[i].fieldId].checked);
  286. }
  287. if (this.sourceQuery[data[i].fieldId].checked.length>0) {
  288. //console.log("进来子节点");
  289. if (data[i].children) {
  290. this.onTree2(data[i].children)
  291. }
  292. }
  293. }
  294. },
  295. onTree(data) {
  296. //console.log(data);
  297. data.forEach(item => {
  298. this.sourceQuery[item.fieldId].checked.push(item.id)
  299. if (item.children) {
  300. this.onTree(item.children)
  301. }
  302. })
  303. },
  304. //勾选后进行筛选
  305. onChange(id) {
  306. let field = []
  307. //console.log(this.sourceQuery);
  308. let k = this.sourceQuery.filter(item => {
  309. return item.checked.length>0
  310. })
  311. //console.log(k,id);
  312. k.forEach(item => {
  313. for (let i = 0; i < item.checked.length; i++){
  314. field.push({
  315. fieldId: item.key,
  316. key:item.checked[i]
  317. })
  318. }
  319. })
  320. //console.log(field);
  321. this.$emit("onChange",field)
  322. },
  323. //全选,点击勾选全部的自定义选项并查找相关专利
  324. handleSelectAll(item) {//全选
  325. // //console.log(item);
  326. const key = item.id
  327. let params = {
  328. // projectId: this.sourceQuery[key].projectId,
  329. // folder: this.sourceQuery[key].folder,
  330. // key: this.isClassNumber(key) ? (key + '-' + this.sourceQuery[key].classId) : this.sourceQuery[key].key,
  331. fieldId: key,
  332. taskId:this.taskId,
  333. reportId: this.reportId,
  334. type: this.sourceQuery[key].type,
  335. startDate: this.sourceQuery[key].datePicker[0],
  336. endDate: this.sourceQuery[key].datePicker[1],
  337. }
  338. this.sourceQuery[key].loading = true
  339. // 查询源接口(返回的数据是自定义选项)
  340. this.$api.sourceQueryPatentField(params).then(response => {
  341. // //console.log(response.data);
  342. const records = response.data
  343. this.sourceQuery[key].checked = records.map(item => item.key)
  344. this.onChange(key)
  345. this.sourceQuery[key].loading = false
  346. }).catch(error => {
  347. this.sourceQuery[key].loading = false
  348. })
  349. },
  350. //取消
  351. handleSelectCancel(item) { //取消
  352. const key = item.id
  353. this.sourceQuery[key].checked = []
  354. this.onChange(key)
  355. },
  356. //加载更多
  357. handleLoadMore(item){
  358. this.sourceQuery[item.id].current = this.sourceQuery[item.id].current + 1
  359. this.getPatentQueryFieldSource(item.id)
  360. },
  361. initFieldQueryForm() {
  362. this.form.map((item) => {
  363. const temp = this.sourceQuery[item.id]
  364. if (!temp) {
  365. this.$set(this.sourceQuery, item.id, {
  366. reportId: this.reportId,
  367. // folder: this.queryParams.folder,
  368. key: item.id,
  369. current: 1,
  370. size: 9999,
  371. // order: 'desc',
  372. label: '',
  373. loading: false,
  374. checked: [],
  375. // classId: '1',
  376. type: item.type,
  377. isEnd: false,
  378. datePicker: ['', '']
  379. })
  380. }
  381. //console.log(this.sourceQuery);
  382. })
  383. this.handleChange([this.form[0].id])
  384. },
  385. //获取每个人的完成情况
  386. async getTaskSources(){
  387. var params = {
  388. reportId:this.reportId
  389. }
  390. await this.$api.getTaskSources(params).then(response=>{
  391. if(response.code == 200){
  392. response.data.forEach(item=>{
  393. item.personDates.forEach(i=>{
  394. i.taskTypeId=item.taskType == '对比任务'?2:3
  395. i.name = i.personName
  396. i.number = Number(i.doneNum) + Number(i.notDoneNum)
  397. i.children=[{
  398. name:'已完成',
  399. number:i.doneNum,
  400. taskTypeId:item.taskType == '对比任务'?2:3
  401. },
  402. {
  403. name:'未完成',
  404. number:i.notDoneNum,
  405. taskTypeId:item.taskType == '对比任务'?2:3
  406. }]
  407. })
  408. item.personDates.push({
  409. name:'未分配',
  410. number:item.notAssignNum,
  411. taskTypeId:item.taskType == '对比任务'?2:3
  412. })
  413. })
  414. this.taskSources = response.data
  415. }
  416. })
  417. },
  418. // 初始化获取
  419. async getPatentQueryField(refresh, loadForm) {
  420. let params = {
  421. reportId: this.reportId,
  422. // taskId:this.taskId,
  423. }
  424. //获取用户的自定义字段
  425. await this.$api.listPatentField(params).then(res => {
  426. if (res.code==200&&res.data.length>0) {
  427. this.data = res.data
  428. this.activeNames.push(this.data[0].id)
  429. this.data.forEach((item) => {
  430. if (item.type == 6) {
  431. let paramr = {
  432. fieldId:item.id,
  433. type :item.type,
  434. reportId :this.reportId ,
  435. }
  436. this.$api.listPatentFieldOption(paramr).then(resA => {
  437. this.$set(item,"option",resA.data)
  438. })
  439. }
  440. })
  441. }
  442. })
  443. //获取用户的自定义字段后调用initFieldData将数据给到field
  444. if (this.data.length>0) {
  445. this.initFieldData(this.data)
  446. if (loadForm) {
  447. this.initFieldQueryForm()
  448. }
  449. //???
  450. if (refresh) {
  451. this.visible = false
  452. }
  453. // this.reset()
  454. }
  455. },
  456. //将自定义字段全部数据给field
  457. initFieldData(data) {
  458. // //console.log("initFieldData",data);
  459. this.field = data
  460. this.form = JSON.parse(JSON.stringify(data))
  461. },
  462. // 请求自定义选项列表
  463. getPatentQueryFieldSource(id, refresh = false) {//(key, refresh = false)
  464. // //console.log(this.params);
  465. // let data = JSON.parse(JSON.stringify(this.params))
  466. let value = {
  467. fieldId: id,
  468. taskId:this.taskId,
  469. // projectId: this.sourceQuery[id].projectId,
  470. // folder: this.sourceQuery[key].folder,
  471. // key: this.isClassNumber(key) ? (key + '-' + this.sourceQuery[key].classId) : this.sourceQuery[key].key,
  472. current: this.sourceQuery[id].current,
  473. size: this.sourceQuery[id].size,
  474. // order: this.sourceQuery[id].order,
  475. label: this.sourceQuery[id].label,
  476. type: this.sourceQuery[id].type,
  477. startDate: this.sourceQuery[id].datePicker[0],
  478. endDate: this.sourceQuery[id].datePicker[1],
  479. refresh: false,
  480. }
  481. this.$api.sourceQueryPatentField(value).then(response => {
  482. // //console.log(response.data);
  483. if (response.code == 200) {
  484. // //console.log("每一项自定义字段数据中的值", response.data);
  485. // if (response.data.type==1) {
  486. // response.data
  487. // }
  488. const records = response.data
  489. //console.log(response.data);
  490. let temp = this.sourceData[id]
  491. if (!temp || refresh) {
  492. temp = records
  493. } else {
  494. temp.push(...records)
  495. }
  496. //console.log(temp);
  497. this.sourceQuery[id].isEnd = temp.length >= response.data.length
  498. this.$set(this.sourceData, id, temp)
  499. }
  500. })
  501. },
  502. // 每一行事件,每点击一次调用一次接口,传入自定义字段id
  503. handleChange(data) {
  504. // //console.log("每一项自定义字段数据", this.data);
  505. const val = data[data.length - 1];
  506. if (val && this.hasSource.indexOf(val) === -1) {
  507. this.hasSource.push(val)
  508. this.getPatentQueryFieldSource(val)
  509. }
  510. },
  511. // 自定义头部事件(全部/已读/未读)
  512. handleReadQuery(type) {
  513. //console.log(type);
  514. //all read unread
  515. this.taskStatus = type
  516. this.returnData.read = type
  517. this.refreshSourceData()
  518. this.$emit('onTaskStatus', this.taskStatus)
  519. },
  520. refreshSourceData() {
  521. this.activeNames = []
  522. this.hasSource = []
  523. this.sourceData = {}
  524. for (let key in this.sourceQuery) {
  525. this.sourceQuery[key].current = 1
  526. this.sourceQuery[key].label = ''
  527. }
  528. },
  529. // readList: {
  530. // 3: '全部',
  531. // 1: '已读',
  532. // 0: '未读',
  533. // },
  534. taskReTaskStateCount() {
  535. var a ={
  536. reportId:this.reportId
  537. }
  538. if(this.taskId){
  539. a.taskId = this.taskId
  540. //console.log(this.taskId);
  541. this.$api.taskReTaskStateCount(a).then(res => {
  542. //console.log(res);
  543. this.readList=res.data
  544. })
  545. }else {
  546. this.$api.ReStateCount(a).then(res => {
  547. //console.log(res);
  548. this.readList=res.data
  549. })
  550. }
  551. }
  552. }
  553. }
  554. </script>
  555. <style lang="scss">
  556. .patent-tree-filter {
  557. height: 100%;
  558. .patent-tree-filter-main {
  559. height: 100%;
  560. padding: 10px 0;
  561. .no-data {
  562. text-align: center;
  563. color: #6b6868;
  564. }
  565. }
  566. .change-show-type {
  567. font-size: 13px;
  568. .change-show-type-info {
  569. color: #6b6868;
  570. padding-left: 10px;
  571. }
  572. .el-form-item__label{
  573. padding: 0 !important;
  574. line-height: 20px;
  575. }
  576. .el-form-item__content {
  577. height: 30px;
  578. line-height: 30px;
  579. }
  580. }
  581. }
  582. .patent-query-filter-search{
  583. display: flex;
  584. }
  585. .patent-query-filter-search-input{
  586. margin-right: 5px;
  587. }
  588. .patent-query-filter-search-bottom{
  589. text-align: center;
  590. margin-top: 10px;
  591. }
  592. .year-data-picker {
  593. width: 200px;
  594. display: flex;
  595. justify-content: space-between;
  596. .el-input__prefix {
  597. display: none;
  598. }
  599. .el-input__inner {
  600. padding: 10px;
  601. text-align: center;
  602. }
  603. }
  604. .year-data-input{
  605. width: 100px;
  606. }
  607. .source-checkbox {
  608. margin-top: 10px;
  609. span {
  610. display: inline-block;
  611. font-size: 13px;
  612. }
  613. .el-checkbox {
  614. display: block;
  615. }
  616. .el-checkbox__label {
  617. position: relative;
  618. top: 5px;
  619. }
  620. .source-checkbox-count {
  621. color: #409EFF;
  622. position: relative;
  623. top: -4px;
  624. left: 10px;
  625. }
  626. .source-checkbox-label {
  627. max-width: 190px;
  628. padding-left: 5px;
  629. overflow: hidden;
  630. white-space: nowrap;
  631. text-overflow: ellipsis;
  632. }
  633. }
  634. .query-read-status {
  635. font-size: 12px;
  636. height: 25px;
  637. line-height: 25px;
  638. cursor: pointer;
  639. background: #dcdcdc;
  640. border-radius: 3px;
  641. padding: 0 5px;
  642. span {
  643. display: inline-block;
  644. }
  645. .a {
  646. }
  647. .b {
  648. text-align: center;
  649. width: 30px;
  650. }
  651. .c {
  652. padding-left: 5px;
  653. }
  654. }
  655. .query-read-status_is-active {
  656. background: #409EFF !important;
  657. color: #ffffff !important;
  658. }
  659. </style>