splitPage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <!-- 权要拆分类型等 -->
  3. <div class="height_100">
  4. <el-container>
  5. <el-header v-if="isResult != 'noShow'" style="display: flex; justify-content: space-between;">
  6. <div style="display:flex;align-items:center">
  7. <div>
  8. <slot name="handleLeft"></slot>
  9. </div>
  10. <div v-if="isEdit">
  11. <el-button-group>
  12. <el-button @click="merge" :disabled="checkList.length > 1 ? false : true">合并</el-button>
  13. <el-button @click="split" :disabled="checkList.length > 0 ? false : true">拆分</el-button>
  14. </el-button-group>
  15. </div>
  16. </div>
  17. <div>
  18. <el-select v-if="isEdit" placeholder="请选择拆分类型" :value="splitType" style="margin-left: 50px;"
  19. @change="splitSelect($event, 'type')">
  20. <el-option label="仅拆主权要" value="0"></el-option>
  21. <el-option label="全部拆分" value="1"></el-option>
  22. </el-select>
  23. <el-select v-if="isEdit" placeholder="请选择拆分符号" :value="splitBy" style="margin-left: 10px;"
  24. @change="splitSelect($event, 'by')">
  25. <el-option label="逗号拆分" value="0"></el-option>
  26. <el-option label="分号拆分" value="1"></el-option>
  27. <el-option label="逗号和分号拆分" value="2"></el-option>
  28. </el-select>
  29. <el-select placeholder="请选择显示类型" v-model="showType" style="margin-left: 10px;" @change="typeSelect($event)">
  30. <el-option label="全部显示" value="0"></el-option>
  31. <el-option label="仅显示主权要" value="1"></el-option>
  32. </el-select>
  33. </div>
  34. <div style="display:flex;align-items:center;">
  35. <div class="margin-right_10">
  36. <slot name="handleRight"></slot>
  37. </div>
  38. <div v-if="(isEdit || isResult != 2) && isResult != 9">
  39. <el-button @click="save" type="primary">保存</el-button>
  40. </div>
  41. </div>
  42. </el-header>
  43. <el-main>
  44. <el-table :data="tableData2" border ref="table" height="calc(100%)" :span-method="objectSpanMethod"
  45. v-loading="loading" style="width: 100%;overflow: auto;" :cell-class-name="isResult==3?checkDel:''">
  46. <el-table-column prop="pRightName" label="权要" align="center">
  47. <template slot-scope="scope">
  48. <!-- <el-tooltip class="item" effect="dark"
  49. :content="rightList.length > 0 ? rightList.filter(item => { return item.sort == scope.row.rightSort })[0].content : '暂无数据'"
  50. placement="top"> -->
  51. <el-tooltip class="item" effect="dark" :content="scope.row.pContent" placement="top">
  52. <span>{{ scope.row.pRightName }}</span>
  53. </el-tooltip>
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="content" label="特征" min-width="300" align="center">
  57. <template slot-scope="scope">
  58. <div v-if="isEdit">
  59. <el-checkbox-group v-model="checkList">
  60. <el-checkbox :label="scope.row.featureId" @change="getRow(scope)"
  61. style="display: flex;align-items: center;width:100%">
  62. <el-input type="textarea" autosize v-model="scope.row.content">
  63. {{ scope.row.content }}</el-input>
  64. </el-checkbox>
  65. </el-checkbox-group>
  66. </div>
  67. <div v-else-if="isResult == 9">
  68. <el-checkbox-group v-model="checkList">
  69. <el-checkbox :label="scope.row.featureId" @change="getRow(scope)"
  70. style="display: flex;align-items: center;width:100%">
  71. <div v-html="scope.row.content"> </div>
  72. </el-checkbox>
  73. </el-checkbox-group>
  74. </div>
  75. <div v-else v-html="scope.row.content"> </div>
  76. </template>
  77. </el-table-column>
  78. <el-table-column prop="explainText" label="解释(可粘贴图片)" align="center">
  79. <template slot-scope="scope">
  80. <div v-if="isEdit">
  81. <myRichText style="text-align:left" v-model="scope.row.explainText" placeholder="请输入解释(可粘贴图片)">
  82. </myRichText>
  83. </div>
  84. <div v-else v-html="scope.row.explainText"></div>
  85. </template>
  86. </el-table-column>
  87. <!-- 父组件传递栏位 -->
  88. <el-table-column v-for="(item, index) in columnList" :key="index" :label="item.name"
  89. align="center" min-width="160px">
  90. <template slot-scope="scope">
  91. <div v-if="item.type == 'String'">
  92. <div v-if="isEdit || item.disabled">
  93. <myRichText style="text-align:left" :value="getColumnData(scope.row, item)"
  94. @input="getValue($event, scope.row, item)" :placeholder="'请输入' + item.name">
  95. </myRichText>
  96. </div>
  97. <div v-else v-html="getColumnData(scope.row, item)"></div>
  98. </div>
  99. <div v-else-if="item.type == 'Array'">
  100. <div v-if="isEdit || item.disabled">
  101. <el-select :value="getColumnData(scope.row, item)" @input="getValue($event, scope.row, item)"
  102. placeholder="请选择">
  103. <el-option v-for="optionItem in item.options" :key="optionItem.value" :label="optionItem.label"
  104. :value="optionItem.value">
  105. </el-option>
  106. </el-select>
  107. </div>
  108. <div v-else v-html="getColumnData(scope.row, item)"></div>
  109. </div>
  110. <div v-if="item.type == 'btn'" >
  111. <span v-for="(btn, index) in item.btn" :key="index">
  112. <component :is="btn.type" @click="$emit('changeResult', scope.row)">{{ btn.name }}</component>
  113. </span>
  114. </div>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. </el-main>
  119. </el-container>
  120. </div>
  121. </template>
  122. <script>
  123. export default {
  124. props: {
  125. // 信息(patentNo,reportId)
  126. patentNo: '',
  127. projectId: '',
  128. // 数据源
  129. tableData: {
  130. type: Array,
  131. default: () => {
  132. return []
  133. }
  134. },
  135. // 是否可读
  136. isEdit: {
  137. type: Boolean,
  138. default: true
  139. },
  140. // 栏位参数
  141. columnList: {
  142. type: Array,
  143. default: () => {
  144. return []
  145. }
  146. },
  147. //9:不显示保存且选择特征
  148. isResult: '',
  149. reportType:'',
  150. checkFeatures:{},
  151. checkData:{}
  152. },
  153. data() {
  154. return {
  155. tableData2: [],//显示数据
  156. splitType: '1',//拆分类型0仅拆主权要,1全部拆分
  157. splitBy: '2',//拆分符号0逗号拆分,1分号拆分,2逗号和分号拆分
  158. showType: '0',//显示类型0全部显示1仅显示主权要
  159. typeArr: [1],//显示权要还是全部显示
  160. // 表格的loading
  161. loading: false,
  162. // 表格的高度
  163. tableHeight: 0,
  164. // 勾选中的特征数据
  165. checkList: this.checkFeatures || [],
  166. // 计算表格合并行的数量
  167. mergeObj: {},
  168. // 表格合并行的栏位
  169. mergeArr: ['id', 'pRightName'],
  170. // 特征行数据
  171. scopeRow: this.checkData || [],
  172. //权要列表
  173. rightList: [],
  174. }
  175. },
  176. watch: {
  177. tableData: {
  178. handler(newVal, oldVal) {
  179. this.typeSelect(this.showType)
  180. },
  181. deep: true
  182. },
  183. patentNo(val){
  184. if(val){
  185. this.getRight()
  186. }
  187. },
  188. checkFeatures(val){
  189. if(val){
  190. this.checkList = val
  191. }
  192. },
  193. checkData(val){
  194. if(val){
  195. this.scopeRow = val
  196. }
  197. },
  198. },
  199. async mounted() {
  200. this.scopeRow = this.checkData || []
  201. this.checkList = this.checkFeatures || []
  202. //获取权要
  203. this.getRight()
  204. if (this.tableData.length > 0) {
  205. this.typeSelect(this.showType)
  206. }
  207. },
  208. methods: {
  209. getCheckList(){
  210. this.$emit('getCheckList',this.scopeRow)
  211. },
  212. // 获取数据
  213. getColumnData(row, field) {
  214. if (typeof field.value == 'string') {
  215. return row[field.value]
  216. } else {
  217. var str = row
  218. if (field.value && field.value.length > 0) {
  219. try {
  220. field.value.forEach(item => {
  221. if (str[item] != 0 && !str[item]) {
  222. throw Error();
  223. }
  224. str = str[item]
  225. })
  226. }
  227. catch (e) {
  228. return ''
  229. }
  230. }
  231. if (this.isEdit || field.disabled) {
  232. } else {
  233. if (field.options && field.options.length > 0) {
  234. let a = field.options.find(item => {
  235. return item.value == str
  236. })
  237. if (a) {
  238. return a.label
  239. } else {
  240. return ''
  241. }
  242. }
  243. }
  244. return str
  245. }
  246. },
  247. getValue(value, row, field) {
  248. if (typeof field.value == 'string') {
  249. row[field.value] = value
  250. } else {
  251. var str = row
  252. if (field.value && field.value.length > 0) {
  253. try {
  254. field.value.forEach((item, index) => {
  255. if (index == field.value.length - 1) {
  256. this.$set(str, item, value)
  257. return
  258. } else {
  259. if (!str[item]) {
  260. this.$set(str, item, {})
  261. }
  262. }
  263. str = str[item]
  264. })
  265. }
  266. catch (e) {
  267. return ''
  268. }
  269. }
  270. }
  271. },
  272. //获取权要
  273. getRight() {
  274. if (this.rightList.length > 0) {
  275. return false
  276. }
  277. if(!this.patentNo){
  278. return false
  279. }
  280. let params = {
  281. patentNo: this.patentNo,
  282. }
  283. this.$api.getPatentRight(params).then(res => {
  284. if (res.code == 200) {
  285. this.rightList = res.data.data
  286. }
  287. })
  288. },
  289. //获取每个元素所需合并的行数
  290. getSpanArr(data) {
  291. this.scopeRow = this.checkData || []
  292. this.mergeArr.forEach((key, index1) => {
  293. let count = 0;
  294. this.mergeObj[key] = [];
  295. data.forEach((item, index) => {
  296. if (index === 0) {
  297. this.mergeObj[key].push(1);
  298. } else {
  299. if (item[key] === data[index - 1][key] && item[key] !== 'explainText') {
  300. this.mergeObj[key][count] += 1;
  301. this.mergeObj[key].push(0);
  302. } else {
  303. count = index;
  304. this.mergeObj[key].push(1);
  305. }
  306. }
  307. })
  308. })
  309. },
  310. // 表格合并行
  311. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  312. if (!row) {
  313. return false
  314. }
  315. if (this.mergeArr.indexOf(column.property) !== -1) {
  316. if (this.mergeObj[column.property][rowIndex]) {
  317. return [this.mergeObj[column.property][rowIndex], 1]
  318. } else {
  319. return [0, 0];
  320. }
  321. }
  322. },
  323. // 保存
  324. save() {
  325. this.$message.warning('正在保存中......')
  326. this.$emit('isSave', this.tableData2)
  327. },
  328. // 选择拆分类型或拆分符号
  329. splitSelect(val, type) {
  330. this.$confirm('重新进行拆分将会清空所有的解释以及其他栏位信息,此操作不可逆, 是否继续?', '提示', {
  331. confirmButtonText: '确定',
  332. cancelButtonText: '取消',
  333. type: 'warning'
  334. }).then(() => {
  335. if (type == 'type') {
  336. this.splitType = val
  337. } else {
  338. this.splitBy = val
  339. }
  340. var split = {
  341. splitBy: this.splitBy,
  342. splitType: this.splitType
  343. }
  344. this.$emit('splitSelect', split)
  345. }).catch(() => {
  346. this.$message.info('已取消删除');
  347. });
  348. },
  349. // 选择显示类型
  350. typeSelect(val) {
  351. this.typeArr = []
  352. if (val == 1) {
  353. this.typeArr.push(1)
  354. } else {
  355. this.typeArr.push(1, 0)
  356. }
  357. var data = this.tableData.filter(item => {
  358. return this.typeArr.includes(item.pType)
  359. })
  360. this.tableData2 = JSON.parse(JSON.stringify(data))
  361. this.getSpanArr(this.tableData2)
  362. },
  363. // 获取当前行的数据
  364. getRow(scope) {
  365. let Index = this.scopeRow.findIndex(item => { return item.featureId == scope.row.featureId })
  366. if (Index < 0) {
  367. scope.row.$index = scope.$index
  368. this.scopeRow.push(scope.row)
  369. } else {
  370. this.scopeRow.splice(Index, 1)
  371. }
  372. },
  373. // 将栏位值合并
  374. columnMerge() {
  375. var arr = ['content', 'explainText']
  376. if (this.columnList && this.columnList.length > 0) {
  377. this.columnList.forEach(item => {
  378. arr.push(item.value)
  379. })
  380. }
  381. return arr
  382. },
  383. // 特征等合并
  384. merge() {
  385. if (this.scopeRow.length > 1) {
  386. // 判断是否可以合并
  387. for (let i = 0; i < this.scopeRow.length - 1; i++) {
  388. // 跨权要不能合并特征
  389. if (this.scopeRow[i].rightSort != this.scopeRow[i + 1].rightSort) {
  390. this.$alert("不能跨权要合并特征", "提示", {
  391. type: 'warning',
  392. confirmButtonText: '确定',
  393. })
  394. return false
  395. } else {//不相邻特征不能合并
  396. let Index_rowArr = this.scopeRow.sort((a, b) => {
  397. return a.$index - b.$index
  398. })
  399. // console.log(this.Index_row,Index_rowArr);
  400. if (Index_rowArr[i + 1].$index - Index_rowArr[i].$index != 1) {
  401. this.$alert("非相邻不能合并特征", "提示", {
  402. type: 'warning',
  403. confirmButtonText: '确定',
  404. })
  405. return false
  406. }
  407. }
  408. }
  409. var merge = {}
  410. var arr = this.columnMerge()
  411. arr.forEach(item => {
  412. merge[item] = ''
  413. })
  414. let splitDisable = this.splitDisable()
  415. if (!splitDisable) {
  416. return false
  417. }
  418. // 将内容合并起来
  419. this.scopeRow.forEach((rowItem, rowIndex) => {
  420. for (let m = 0; m < arr.length; m++) {
  421. merge[arr[m]] = merge[arr[m]] + rowItem[arr[m]]
  422. }
  423. let Index1 = this.tableData.findIndex(item => { return rowItem.featureId == item.featureId })
  424. if (Index1 != -1) {
  425. if (rowIndex < this.scopeRow.length - 1) {
  426. this.tableData.splice(Index1, 1)
  427. } else if (rowIndex == this.scopeRow.length - 1) {
  428. for (let j = 0; j < arr.length; j++) {
  429. this.tableData[Index1][arr[j]] = merge[arr[j]]
  430. }
  431. this.tableData[Index1].ifChange = true
  432. }
  433. }
  434. })
  435. console.log(this.tableData)
  436. this.handleSort(this.scopeRow[0].rightSort)
  437. this.typeSelect(this.showType)
  438. this.scopeRow = []
  439. this.checkList = []
  440. }
  441. },
  442. // 拆分
  443. split() {
  444. //不能同时拆分
  445. if (this.scopeRow.length > 0) {
  446. if (this.scopeRow.length > 1) {
  447. this.$alert("不能同时拆分多个特征", "提示", {
  448. type: 'warning',
  449. confirmButtonText: '确定',
  450. })
  451. return false
  452. }
  453. let splitDisable = this.splitDisable()
  454. if (!splitDisable) {
  455. return false
  456. }
  457. var rowId = Math.floor((Math.random() * 9999) + 1000);
  458. var arr = this.columnMerge()
  459. this.scopeRow.forEach((rowItem, rowIndex) => {
  460. rowItem.ifChange=true
  461. // 将字段的值给到拆分新数据
  462. var splitAdd = JSON.parse(JSON.stringify(rowItem))
  463. splitAdd.featureId = rowItem.featureId + rowId + "a"
  464. // 将部分展示字段置为空
  465. for (let i = 0; i < arr.length; i++) {
  466. splitAdd[arr[i]] = ''
  467. }
  468. this.tableData.splice(this.scopeRow[0].$index + 1, 0, splitAdd)
  469. })
  470. this.handleSort(this.scopeRow[0].rightSort)
  471. this.typeSelect(this.showType)
  472. this.scopeRow = []
  473. this.checkList = []
  474. }
  475. },
  476. // 侵权分析或FTO有对比结果禁止进行合并、拆分操作
  477. splitDisable() {
  478. if (this.reportType == 5) {
  479. return true
  480. }
  481. try {
  482. for (var i = 0; i < this.scopeRow.length; i++){
  483. for (var j = 0; j < this.columnList.length; j++){
  484. var str = this.getColumnData(this.scopeRow[i], this.columnList[j])
  485. if (str != 0 && !str) {
  486. } else {
  487. throw Error();
  488. }
  489. }
  490. }
  491. return true
  492. }
  493. catch (e) {
  494. this.$message.error('您勾选的特征已填写对比结果信息,无法对勾选的特征进行合并、拆分等操作')
  495. return false
  496. }
  497. },
  498. // 拆分或合并后重新排序
  499. handleSort(rightSort) {
  500. // var data = this.tableData2.filter(item => {
  501. // return item.rightSort == rightSort
  502. // })
  503. // for (var i = 0; i < data.length; i++) {
  504. // data[i].sysOrder = i + 1
  505. // }
  506. },
  507. // 协同对比结果高亮
  508. checkDel({ row, rowIndex }) {
  509. for (let k in row.finalRecordVO) {
  510. if (k != 'id') {
  511. if (row.finalRecordVO[k] != row.currentRecordVO[k]) {
  512. return 'success-rowCheck'
  513. }
  514. }
  515. }
  516. }
  517. },
  518. }
  519. </script>
  520. <style>
  521. .success-rowCheck {
  522. background: #e1b0a7;
  523. }
  524. </style>
  525. <style lang="scss" scoped></style>