splitPage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <!-- 权要拆分类型等 -->
  3. <div class="height_100">
  4. <el-container>
  5. <el-header 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>
  36. <slot name="handleRight"></slot>
  37. </div>
  38. <div v-if="isEdit">
  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%">
  46. <el-table-column prop="pRightName" label="权要" width="180" 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="特征" 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;">
  62. <el-input type="textarea" style="width:250px" 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 v-html="scope.row.content"> </div>
  68. </template>
  69. </el-table-column>
  70. <el-table-column prop="explainText" label="解释(可粘贴图片)" align="center">
  71. <template slot-scope="scope">
  72. <div v-if="isEdit">
  73. <myRichText style="text-align:left" v-model="scope.row.explainText" placeholder="请输入解释(可粘贴图片)">
  74. </myRichText>
  75. </div>
  76. <div v-else v-html="scope.row.explainText"></div>
  77. </template>
  78. </el-table-column>
  79. <!-- 父组件传递栏位 -->
  80. <el-table-column v-for="item in columnList" :key="item.value" :prop="item.value" :label="item.name"
  81. align="center">
  82. <template slot-scope="scope">
  83. <div v-if="isEdit">
  84. <myRichText style="text-align:left" v-model="scope.row[item.value]" :placeholder="'请输入' + item.name">
  85. </myRichText>
  86. </div>
  87. <div v-else v-html="scope.row[item.value]"></div>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. </el-main>
  92. </el-container>
  93. </div>
  94. </template>
  95. <script>
  96. export default {
  97. props: {
  98. // 信息(patentNo,reportId)
  99. word: {
  100. type: Object,
  101. default: () => {
  102. return {
  103. patentNo: '',
  104. projectId: ''
  105. }
  106. }
  107. },
  108. // 数据源
  109. tableData: {
  110. type: Array,
  111. default: () => {
  112. return []
  113. }
  114. },
  115. // 是否可读
  116. isEdit: {
  117. type: Boolean,
  118. default: true
  119. },
  120. // 栏位参数
  121. columnList: {
  122. type: Array,
  123. default: () => {
  124. return []
  125. }
  126. },
  127. },
  128. data() {
  129. return {
  130. tableData2: [],//显示数据
  131. splitType: '1',//拆分类型0仅拆主权要,1全部拆分
  132. splitBy: '2',//拆分符号0逗号拆分,1分号拆分,2逗号和分号拆分
  133. showType: '0',//显示类型0全部显示1仅显示主权要
  134. typeArr: [1],//显示权要还是全部显示
  135. // 表格的loading
  136. loading: false,
  137. // 表格的高度
  138. tableHeight: 0,
  139. // 勾选中的特征数据
  140. checkList: [],
  141. // 计算表格合并行的数量
  142. mergeObj: {},
  143. // 表格合并行的栏位
  144. mergeArr: ['id', 'pRightName'],
  145. // 特征行数据
  146. scopeRow: [],
  147. //权要列表
  148. rightList: [],
  149. }
  150. },
  151. watch: {
  152. tableData: {
  153. handler(newVal, oldVal) {
  154. this.typeSelect(this.showType)
  155. },
  156. deep: true
  157. },
  158. },
  159. async mounted() {
  160. //获取权要
  161. this.getRight()
  162. },
  163. methods: {
  164. // 查询拆分信息
  165. // async getSplitMessage() {
  166. // let params = {
  167. // ...this.word,
  168. // }
  169. // await this.$api.getSplitMessage(params).then(res => {
  170. // if (res.code == 200) {
  171. // this.splitType = res.data.data.splitType.toString()
  172. // this.splitBy = res.data.data.splitBy.toString()
  173. // let obj = {
  174. // splitType: this.splitType,
  175. // splitBy: this.splitBy
  176. // }
  177. // this.$emit('splitSelect', obj)
  178. // }
  179. // }).catch(error => {
  180. // this.splitType = ''
  181. // this.splitBy = ''
  182. // this.showType = '0'
  183. // })
  184. // },
  185. //获取权要
  186. getRight() {
  187. let params = {
  188. patentNo: this.word.patentNo,
  189. }
  190. this.$api.getPatentRight(params).then(res => {
  191. if (res.code == 200) {
  192. this.rightList = res.data.data
  193. }
  194. })
  195. },
  196. //获取每个元素所需合并的行数
  197. getSpanArr(data) {
  198. this.scopeRow = []
  199. this.mergeArr.forEach((key, index1) => {
  200. let count = 0;
  201. this.mergeObj[key] = [];
  202. data.forEach((item, index) => {
  203. if (index === 0) {
  204. this.mergeObj[key].push(1);
  205. } else {
  206. if (item[key] === data[index - 1][key] && item[key] !== 'explainText') {
  207. this.mergeObj[key][count] += 1;
  208. this.mergeObj[key].push(0);
  209. } else {
  210. count = index;
  211. this.mergeObj[key].push(1);
  212. }
  213. }
  214. })
  215. })
  216. },
  217. // 表格合并行
  218. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  219. if (!row) {
  220. return false
  221. }
  222. if (this.mergeArr.indexOf(column.property) !== -1) {
  223. if (this.mergeObj[column.property][rowIndex]) {
  224. return [this.mergeObj[column.property][rowIndex], 1]
  225. } else {
  226. return [0, 0];
  227. }
  228. }
  229. },
  230. // 保存
  231. save() {
  232. this.$message.warning('正在保存中......')
  233. this.$emit('isSave', this.tableData2)
  234. },
  235. // 选择拆分类型或拆分符号
  236. splitSelect(val, type) {
  237. this.$confirm('重新进行拆分将会清空所有的解释以及回避设计信息,此操作不可逆, 是否继续?', '提示', {
  238. confirmButtonText: '确定',
  239. cancelButtonText: '取消',
  240. type: 'warning'
  241. }).then(() => {
  242. if (type == 'type') {
  243. this.splitType = val
  244. } else {
  245. this.splitBy = val
  246. }
  247. var split = {
  248. splitBy: this.splitBy,
  249. splitType: this.splitType
  250. }
  251. this.$emit('splitSelect', split)
  252. }).catch(() => {
  253. this.$message.info('已取消删除');
  254. });
  255. },
  256. // 选择显示类型
  257. typeSelect(val) {
  258. this.typeArr = []
  259. if (val == 1) {
  260. this.typeArr.push(1)
  261. } else {
  262. this.typeArr.push(1, 0)
  263. }
  264. var data = this.tableData.filter(item => {
  265. return this.typeArr.includes(item.pType)
  266. })
  267. this.tableData2 = JSON.parse(JSON.stringify(data))
  268. this.getSpanArr(this.tableData2)
  269. },
  270. // 获取当前行的数据
  271. getRow(scope) {
  272. let Index = this.scopeRow.findIndex(item => { return item.featureId == scope.row.featureId })
  273. if (Index < 0) {
  274. scope.row.$index = scope.$index
  275. this.scopeRow.push(scope.row)
  276. } else {
  277. this.scopeRow.splice(Index, 1)
  278. }
  279. },
  280. // 将栏位值合并
  281. columnMerge() {
  282. var arr = ['content', 'explainText']
  283. if (this.columnList && this.columnList.length > 0) {
  284. this.columnList.forEach(item => {
  285. arr.push(item.value)
  286. })
  287. }
  288. return arr
  289. },
  290. // 特征等合并
  291. merge() {
  292. if (this.scopeRow.length > 1) {
  293. // 判断是否可以合并
  294. for (let i = 0; i < this.scopeRow.length - 1; i++) {
  295. // 跨权要不能合并特征
  296. if (this.scopeRow[i].rightSort != this.scopeRow[i + 1].rightSort) {
  297. this.$alert("不能跨权要合并特征", "提示", {
  298. type: 'warning',
  299. confirmButtonText: '确定',
  300. })
  301. return false
  302. } else {//不相邻特征不能合并
  303. let Index_rowArr = this.scopeRow.sort((a, b) => {
  304. return a.$index - b.$index
  305. })
  306. // console.log(this.Index_row,Index_rowArr);
  307. if (Index_rowArr[i + 1].$index - Index_rowArr[i].$index != 1) {
  308. this.$alert("非相邻不能合并特征", "提示", {
  309. type: 'warning',
  310. confirmButtonText: '确定',
  311. })
  312. return false
  313. }
  314. }
  315. }
  316. var merge = {}
  317. var arr = this.columnMerge()
  318. arr.forEach(item => {
  319. merge[item] = ''
  320. })
  321. // 将内容合并起来
  322. this.scopeRow.forEach((rowItem, rowIndex) => {
  323. for (let m = 0; m < arr.length; m++) {
  324. merge[arr[m]] = merge[arr[m]] + rowItem[arr[m]]
  325. }
  326. let Index1 = this.tableData.findIndex(item => { return rowItem.id == item.id })
  327. if (Index1 != -1) {
  328. if (rowIndex < this.scopeRow.length - 1) {
  329. this.tableData.splice(Index1, 1)
  330. } else if (rowIndex == this.scopeRow.length - 1) {
  331. for (let j = 0; j < arr.length; j++) {
  332. this.tableData[Index1][arr[j]] = merge[arr[j]]
  333. }
  334. }
  335. }
  336. })
  337. this.handleSort(this.scopeRow[0].rightSort)
  338. this.typeSelect(this.showType)
  339. this.scopeRow = []
  340. this.checkList = []
  341. }
  342. },
  343. // 拆分
  344. split() {
  345. //不能同时拆分
  346. if (this.scopeRow.length > 0) {
  347. if (this.scopeRow.length > 1) {
  348. this.$alert("不能同时拆分多个特征", "提示", {
  349. type: 'warning',
  350. confirmButtonText: '确定',
  351. })
  352. return false
  353. }
  354. var rowId = Math.floor((Math.random() * 9999) + 1000);
  355. var arr = this.columnMerge()
  356. this.scopeRow.forEach((rowItem, rowIndex) => {
  357. // 将字段的值给到拆分新数据
  358. var splitAdd = JSON.parse(JSON.stringify(rowItem))
  359. splitAdd.id = rowItem.id + rowId + "a"
  360. // 将部分展示字段置为空
  361. for (let i = 0; i < arr.length; i++) {
  362. splitAdd[arr[i]] = ''
  363. }
  364. this.tableData.splice(this.scopeRow[0].$index + 1, 0, splitAdd)
  365. })
  366. this.handleSort(this.scopeRow[0].rightSort)
  367. this.typeSelect(this.showType)
  368. this.scopeRow = []
  369. this.checkList = []
  370. }
  371. },
  372. // 拆分或合并后重新排序
  373. handleSort(rightSort) {
  374. var data = this.tableData2.filter(item => {
  375. return item.rightSort == rightSort
  376. })
  377. for (var i = 0; i < data.length; i++){
  378. data[i].sysOrder = i + 1
  379. }
  380. },
  381. },
  382. }
  383. </script>
  384. <style lang="scss" scoped></style>