merge.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <template>
  2. <div>
  3. <el-drawer class="custom-drawer-form" :title="title" size="1000px" :visible.sync="drawer" direction="rtl"
  4. :before-close="close" destroy-on-close>
  5. <el-container>
  6. <el-header style="display:flex;align-items:center;justify-content: space-between;">
  7. <!-- 检索 -->
  8. <div>
  9. <!-- <el-form :inline="true" class="margin-left_20">
  10. <el-form-item label="名称">
  11. <el-input v-model="queryParams.name" size="small" placeholder="请输入名称" clearable @clear="getList"></el-input>
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" size="small" @click="getList">查询</el-button>
  15. </el-form-item>
  16. </el-form> -->
  17. <!-- 后端没有根据检索式检索 -->
  18. <mySearch style="width: 500px" :SearchFields="searchFiled" @search="search" :searchValue="searchOption">
  19. </mySearch>
  20. </div>
  21. <el-button type="primary" size="small" @click="handleMerge">合并</el-button>
  22. </el-header>
  23. <el-main class="container-common-main">
  24. <!-- <el-table v-loading="loading" :data="tableData" border header-row-class-name="custom-table-header"
  25. v-el-table-infinite-scroll="getList" :infinite-scroll-distance="10" :infinite-scroll-disabled="disabled"> -->
  26. <el-table v-loading="loading" :data="tableData" border header-row-class-name="custom-table-header" @sort-change="sortChange">
  27. <el-table-column align="center" width="60">
  28. <template slot-scope="scope">
  29. <el-checkbox @change="(val)=>onChange(val,scope.row)" v-if="refresh"
  30. :checked="mergedList.findIndex(item=> item.name == scope.row.name) !== -1"></el-checkbox>
  31. </template>
  32. </el-table-column>
  33. <el-table-column prop="name" label="名称" align="center" show-overflow-tooltip></el-table-column>
  34. <el-table-column prop="address" label="地址" align="center" show-overflow-tooltip></el-table-column>
  35. <el-table-column prop="remark" label="备注" align="center" show-overflow-tooltip></el-table-column>
  36. <el-table-column label="操作" align="center" width="100">
  37. <template slot-scope="scope" v-if="scope.row.mergeId">
  38. <el-button type="text" size="small"
  39. @click="handleEdit(scope.row)">编辑</el-button>
  40. <el-button type="text" size="small"
  41. @click="handleDelete1(scope.row)" style="color: red;">删除</el-button>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <div class="pagination" style="margin-top: 20px;">
  46. <el-pagination :current-page.sync="queryParams.pageNum" :page-size="queryParams.pageSize" :total="total"
  47. @current-change="handleCurrentChange" layout="total, prev, pager, next, jumper" background></el-pagination>
  48. </div>
  49. </el-main>
  50. <el-footer class="footer-common">
  51. <el-button @click="close">关 闭</el-button>
  52. </el-footer>
  53. </el-container>
  54. </el-drawer>
  55. <el-dialog :title="mergeTitle" :visible.sync="visible" width="500px" append-to-body destroy-on-close
  56. :before-close="closeDialog" top="3vh">
  57. <div class="patent-applicant-merge-select">
  58. <div style="margin-bottom:20px">
  59. <el-divider content-position="left">基本信息</el-divider>
  60. <!-- <div style="display:flex;justify-content: flex-end;margin: 10px 0 10px 0px;">
  61. <el-button type="primary" size="small" :loading="btnLoading" @click="handleSave">保存</el-button>
  62. </div> -->
  63. </div>
  64. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px">
  65. <el-form-item label="名称" prop="name">
  66. <el-input v-model="ruleForm.name" placeholder="请输入名称"></el-input>
  67. </el-form-item>
  68. <template v-if="mergeType == 0">
  69. <el-form-item label="简称" prop="abbreviation">
  70. <el-input v-model="ruleForm.abbreviation" placeholder="请输入名称"></el-input>
  71. </el-form-item>
  72. <el-form-item label="国家" prop="country" >
  73. <el-select v-model="ruleForm.country" @change="changeCountry" placeholder="请选择" filterable class="width_100">
  74. <el-option v-for="(item, index) in commonData" :label="item.label" :key="index"
  75. :value="item.label"></el-option>
  76. </el-select>
  77. </el-form-item>
  78. <el-form-item label="省/直辖市" prop="province" v-if="ruleForm.country=='中国'">
  79. <el-cascader ref="myCascader" @change="changeCas" v-model="ruleForm.provinceOld" :options="areaOptions"
  80. class="width_100"></el-cascader>
  81. </el-form-item>
  82. </template>
  83. <el-form-item label="详细地址" prop="address">
  84. <el-input v-model="ruleForm.address" placeholder="请输入地址"></el-input>
  85. </el-form-item>
  86. <el-form-item label="备注" prop="remark">
  87. <el-input v-model="ruleForm.remark" placeholder="请输入备注" type="textarea"></el-input>
  88. </el-form-item>
  89. </el-form>
  90. <template >
  91. <div style="margin: 20px 0px 0px 0px;">
  92. <el-divider content-position="left">合并信息</el-divider>
  93. <div style="display:flex;justify-content: flex-end;margin: 10px 0 10px 0px;">
  94. <el-button type="primary" size="small" @click="addName">新增</el-button>
  95. </div>
  96. </div>
  97. <el-table :data="ruleFormTableData" border header-row-class-name="custom-table-header">
  98. <el-table-column prop="name" label="合并人名称" align="center" show-overflow-tooltip>
  99. <template slot-scope="scope">
  100. <div>
  101. {{ scope.row.name }}
  102. </div>
  103. </template>
  104. </el-table-column>
  105. <!-- <el-table-column prop="country" label="国家" align="center" width="150"
  106. show-overflow-tooltip></el-table-column>
  107. <el-table-column prop="address" label="地址" align="center" show-overflow-tooltip></el-table-column> -->
  108. <el-table-column label="操作" align="center">
  109. <template slot-scope="scope">
  110. <el-link type="danger" @click="handleDelete(scope)">移除</el-link>
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. </template>
  115. </div>
  116. <div slot="footer" class="dialog-footer">
  117. <el-button @click="closeDialog">关 闭</el-button>
  118. <!-- <el-button v-if="!ruleForm.id" :loading="btnLoading" type="primary" @click="handleSave">确认</el-button> -->
  119. <el-button :loading="btnLoading" type="primary" @click="handleSave">确认</el-button>
  120. </div>
  121. </el-dialog>
  122. <mergeTableDialog ref="mergeTableDialog" :projectId="projectId" :mergeType="mergeType" @checked="getChecked"></mergeTableDialog>
  123. </div>
  124. </template>
  125. <script>
  126. import mergeTableDialog from './mergeTableDialog.vue'
  127. export default {
  128. components: {
  129. mergeTableDialog
  130. },
  131. props: {
  132. projectId: '',
  133. },
  134. data() {
  135. return {
  136. // 抽屉标题
  137. title: '',
  138. // 控制抽屉开关
  139. drawer: false,
  140. // 查询表格的loading
  141. loading: false,
  142. // 表格的数据源
  143. tableData: [],
  144. // 存放勾选的值的数据
  145. mergedList: [],
  146. //检索字段
  147. searchFiled: [
  148. {
  149. label: '名称',
  150. value: 'name',
  151. type: 'String',
  152. }
  153. ],
  154. //检索条件
  155. searchOption: {},
  156. //禁用懒加载
  157. disabled: true,
  158. queryParams: {
  159. pageNum: 1,
  160. pageSize: 10,
  161. },
  162. // 总条数
  163. total: 0,
  164. // 判断是2发明人还是0申请人与权利人
  165. mergeType: null,
  166. // 刷新
  167. refresh: true,
  168. // 排序
  169. sort:[],
  170. /**编辑合并人及基本信息 start*/
  171. // 控制弹窗开关
  172. visible: false,
  173. // 弹窗的title
  174. mergeTitle: '',
  175. // 基本信息的数据
  176. ruleForm: {},
  177. ruleFormTableData:[],
  178. // 校验
  179. rules: {
  180. name: [{ required: true, message: '请输入名称', trigger: 'blur' },],
  181. },
  182. // 国家
  183. commonData: {},
  184. // 省市区地址
  185. areaOptions: [],
  186. /**编辑合并人及基本信息 end*/
  187. btnLoading:false,
  188. //是否有修改
  189. hasChange:false,
  190. }
  191. },
  192. mounted() {
  193. },
  194. methods: {
  195. changeCountry(val){
  196. if(val != '中国'){
  197. this.$set(this.ruleForm,'provinceOld','')
  198. }
  199. },
  200. // 表格排序 等后端
  201. sortChange({ column, prop, order }) {
  202. let obj = {
  203. orderBy: prop,
  204. orderType:order
  205. }
  206. this.sort=[obj]
  207. // this.getList()
  208. },
  209. changeCas(val) {
  210. this.ruleForm.province = this.$refs.myCascader.getCheckedNodes()[0].pathLabels[0]
  211. },
  212. // 移除合并人员
  213. handleDelete(scope) {
  214. var row = scope.row
  215. this.ruleFormTableData.splice(scope.$index, 1)
  216. if(row.sign){
  217. if(!this.ruleForm.delMergePersonDTOS){
  218. this.ruleForm.delMergePersonDTOS = []
  219. }
  220. this.ruleForm.delMergePersonDTOS.push(row)
  221. }
  222. // let params = {
  223. // projectId: this.projectId,
  224. // name: this.ruleForm.name,
  225. // delName: row.name,
  226. // type: this.mergeType,
  227. // }
  228. // this.$confirm('此操作将删除该人员, 是否继续?', '提示', {
  229. // confirmButtonText: '确定',
  230. // cancelButtonText: '取消',
  231. // type: 'warning'
  232. // }).then(() => {
  233. // this.$api.delMergedName(params).then(res => {
  234. // if (res.code == 200) {
  235. // this.$message.success('移除人员成功')
  236. // // this.$emit('close')
  237. // this.hasChange = true
  238. // let index = this.ruleForm.mergedName.indexOf(row.name)
  239. // if (index != -1) {
  240. // this.ruleFormTableData.splice(scope.$index, 1)
  241. // this.ruleForm.mergedName.splice(index, 1)
  242. // }
  243. // // this.getMerge(this.ruleForm)
  244. // }
  245. // })
  246. // }).catch(() => {
  247. // this.$message.info('已取消操作');
  248. // });
  249. },
  250. // 查询合并的数据
  251. getMerge(row) {
  252. let params = {
  253. projectId: this.projectId,
  254. id: row.mergeId,
  255. type: this.mergeType,
  256. }
  257. this.$api.selectMergePersonDetail(params).then(res => {
  258. if (res.code == 200) {
  259. this.ruleForm = res.data
  260. var data = this.ruleForm.mergedName
  261. this.ruleFormTableData = data.map(item=>{
  262. return {
  263. name:item,
  264. sign:true
  265. }
  266. })
  267. this.getShowProvince()
  268. }
  269. })
  270. },
  271. // 获取省市区并显示
  272. getShowProvince() {
  273. if (this.ruleForm.province) {
  274. let obj = this.areaOptions.find(item => {
  275. return item.label == this.ruleForm.province
  276. })
  277. this.ruleForm.provinceOld = [obj.value]
  278. }
  279. },
  280. // 编辑合并的信息
  281. handleEdit(row) {
  282. this.getMerge(row)
  283. this.mergeTitle = '编辑合并'
  284. this.visible = true
  285. },
  286. // 删除表格数据
  287. handleDelete1(row) {
  288. this.$confirm('确认删除本条数据吗?', '提示', {
  289. confirmButtonText: '确定',
  290. cancelButtonText: '取消',
  291. type: 'warning'
  292. }).then(() => {
  293. this.loading = true
  294. let params = {
  295. id: row.mergeId,
  296. type: this.mergeType,
  297. }
  298. this.$api.delMergePerson(params).then(response => {
  299. if (response.code == 200) {
  300. this.$message.success('删除成功')
  301. // this.loading = false
  302. this.getList()
  303. }
  304. }).catch(error => {
  305. this.$message.error('删除失败')
  306. this.loading = false
  307. })
  308. })
  309. },
  310. // 关闭弹窗
  311. closeDialog() {
  312. this.$refs.ruleForm.resetFields()
  313. this.visible = false
  314. },
  315. clearRuleForm(){
  316. this.ruleForm = {}
  317. this.$set(this, 'mergedList', [])
  318. this.refresh = false
  319. this.$nextTick(() => {
  320. this.refresh = true
  321. })
  322. },
  323. //编辑时候添加申请人
  324. addName(){
  325. var titles={
  326. 0:'选择申请人/权利人',
  327. 2:'选择发明人'
  328. }
  329. var data = this.ruleFormTableData.filter(item=>{
  330. return !item.sign
  331. })
  332. if(this.ruleForm.id){
  333. var disabled = [
  334. {
  335. mergeId:this.ruleForm.id
  336. }
  337. ]
  338. }else{
  339. var disabled = []
  340. }
  341. this.$refs.mergeTableDialog.open(titles[this.mergeType],data,disabled)
  342. },
  343. getChecked(value){
  344. var signData = this.ruleFormTableData.filter(item=>{
  345. return item.sign
  346. })
  347. this.ruleFormTableData = signData.concat(value)
  348. },
  349. // 弹窗中的完成和保存事件
  350. handleSave() {
  351. this.$refs.ruleForm.validate((valid) => {
  352. if (valid) {
  353. this.ruleForm.projectId = this.projectId
  354. this.ruleForm.type = this.mergeType
  355. this.btnLoading = true
  356. var api = 'commonMerge'
  357. var message = {
  358. success:'',
  359. error:''
  360. }
  361. // if(this.ruleFormTableData.length>0){
  362. // for(var i =0;i<this.ruleFormTableData.length;i++){
  363. // var item = this.ruleFormTableData[i]
  364. // if(item.mergeId){
  365. // this.ruleForm.needMergedName.push(item.name)
  366. // }else{
  367. // this.ruleForm.mergedName.push(item.name)
  368. // }
  369. // }
  370. // }
  371. this.ruleForm.mergePersonDTOS = this.ruleFormTableData.filter(item=>{
  372. return !item.sign
  373. })
  374. if(this.ruleForm.id){//编辑
  375. // api = 'updateMergePerson'
  376. message = {
  377. success:'编辑成功',
  378. error:'编辑失败'
  379. }
  380. }else{
  381. message = {
  382. success:'合并成功',
  383. error:'合并失败'
  384. }
  385. // if (this.ruleForm.needMergedName && this.ruleForm.needMergedName.length == 0) {//新增
  386. // api = 'mergePerson'
  387. // message = {
  388. // success:'合并成功',
  389. // error:'合并失败'
  390. // }
  391. // } else {
  392. // api = 'mergePersonAgain'
  393. // message = {
  394. // success:'合并成功',
  395. // error:'合并失败'
  396. // }
  397. // }
  398. }
  399. this.$api[api](this.ruleForm).then(res => {
  400. if (res.code == 200) {
  401. this.$message.success(message.success)
  402. // this.$emit('close')
  403. this.hasChange = true
  404. this.mergedList = []
  405. this.btnLoading = false
  406. this.clearRuleForm()
  407. this.closeDialog()
  408. this.getList()
  409. }
  410. }).catch(error=>{
  411. this.$message.error(message.error)
  412. this.btnLoading = false
  413. })
  414. }
  415. })
  416. },
  417. onChange(val,row) {
  418. if (val) {
  419. this.mergedList.push(row)
  420. } else {
  421. var index = this.mergedList.findIndex(item => item.name == row.name)
  422. if(index!=-1){
  423. this.mergedList.splice(index, 1)
  424. }
  425. }
  426. },
  427. // 合并事件
  428. handleMerge() {
  429. if (this.mergedList.length === 0) {
  430. let text = this.mergeType == 2 ? '请选择发明人' : '请选择申请人/权利人'
  431. this.$message.error(text)
  432. return false
  433. }
  434. this.mergeTitle = '合并'
  435. var mergedData = this.mergedList[this.mergedList.length-1]
  436. // for (let k in mergedData) {
  437. // this.$set(this.ruleForm, [k], mergedData[k])
  438. // }
  439. this.ruleForm = {
  440. ...mergedData
  441. }
  442. this.getShowProvince()
  443. this.ruleForm.id = null
  444. this.ruleFormTableData = this.mergedList
  445. this.visible = true
  446. },
  447. // 打开抽屉
  448. open(row, title) {
  449. this.mergeType = row.mergeType
  450. this.title = title
  451. this.getList()
  452. this.drawer = true
  453. // 获取国家和地区的数据
  454. if (this.mergeType == 0) {
  455. this.getAllCountry()
  456. this.getAreaList()
  457. }
  458. },
  459. //获取检索条件检索
  460. search(val) {
  461. let params = {}
  462. val.forEach(item => {
  463. if (item.type == 3) {
  464. params[item.value] = item.searchValue.map(itemValue => {
  465. return itemValue.value
  466. })
  467. } else {
  468. params[item.value] = item.searchValue.label
  469. }
  470. })
  471. // 返回条件对象
  472. this.searchOption = this.$commonJS.ArrayToArray(val)
  473. // 调用查询接口
  474. this.queryParams.pageNum = 1
  475. this.getList()
  476. },
  477. handleCurrentChange(val) {
  478. this.queryParams.pageNum = val;
  479. this.getList();
  480. },
  481. //生成字符串
  482. getString(val){
  483. var data = []
  484. if (val.constructor == Object) {
  485. if (Object.keys(val).length > 0) {
  486. Object.keys(val).forEach(item => {
  487. data.push(
  488. {
  489. key: item,
  490. value: val[item]
  491. }
  492. )
  493. })
  494. } else {
  495. return ''
  496. }
  497. } else if (val.constructor == Array) {
  498. if (val.length > 0) {
  499. data = val
  500. } else {
  501. return ''
  502. }
  503. } else {
  504. return val
  505. }
  506. var str = ''
  507. data.forEach(item => {
  508. var value = ''
  509. if (Array.isArray(item.value)) {
  510. value = '('
  511. item.value.forEach((i,index)=>{
  512. if(/\s/.test(i)){
  513. value += `"${i}"`
  514. }else{
  515. value += i
  516. }
  517. if(index!= item.value.length- 1){
  518. value += ' OR '
  519. }
  520. })
  521. value += ')'
  522. } else {
  523. if (item.value) {
  524. // var values = this.$commonJS.AddQuotationMarks(item.value)
  525. // value = values.join('')
  526. value = `(${item.value})`
  527. } else {
  528. return
  529. }
  530. }
  531. var str2 = ''
  532. if(item.key == 'name'){
  533. if(this.mergeType == 2){
  534. str2 = 'MINM=(' + value +')'
  535. }else{
  536. str2 = '(MATM=(' + value + ') OR MRHM=(' + value +'))'
  537. }
  538. }
  539. if (str) {
  540. str = str + ' AND ' + str2
  541. } else {
  542. str = str + str2
  543. }
  544. })
  545. return str
  546. },
  547. // 获取发明人或者申请人、权利人数据,包括已合并的数据
  548. getList() {
  549. let params = {
  550. ...this.queryParams,//分页信息
  551. searchQuery: this.getString(this.searchOption || []),//检索条件
  552. projectId: this.projectId,//项目id
  553. type: this.mergeType,
  554. }
  555. this.loading = true
  556. this.$api.getMergePerson(params).then(res => {
  557. if (res.code == 200) {
  558. this.tableData = res.data.data
  559. this.total = res.data.total
  560. this.loading =false
  561. this.refresh = false
  562. this.$nextTick(() => {
  563. this.refresh = true
  564. })
  565. }
  566. }).catch(error => {
  567. this.tableData = []
  568. this.total = 0
  569. this.loading =false
  570. })
  571. },
  572. // 关闭抽屉
  573. close() {
  574. this.queryParams ={
  575. pageNum: 1,
  576. pageSize: 10,
  577. },
  578. this.searchOption = {}
  579. this.mergedList = []
  580. if(this.hasChange){
  581. this.$emit('close')
  582. this.hasChange = false
  583. }
  584. this.drawer = false
  585. },
  586. // 获取国家和地区
  587. getAllCountry() {
  588. this.$api.getAllCountry().then(response => {
  589. this.commonData = response.data
  590. })
  591. },
  592. // 获取中国所有地区(省、自治区、特别行政区)
  593. getAreaList() {
  594. this.$api.getAllProvince().then(response => {
  595. this.areaOptions = response.data
  596. })
  597. },
  598. },
  599. }
  600. </script>
  601. <style lang="scss" scoped></style>