n20-common-lib 3.2.54 → 3.2.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "3.2.54",
3
+ "version": "3.2.55",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -175,9 +175,7 @@
175
175
  <el-button v-if="authList.includes('pass')" type="primary" @click="checkFlowFn">{{
176
176
  $lc(btnsNames['pass'])
177
177
  }}</el-button>
178
- <el-button v-if="authList.includes('refuse')" plain @click="rejectFn">{{
179
- $lc(btnsNames['refuse'])
180
- }}</el-button>
178
+ <el-button v-if="authList.includes('refuse')" plain @click="rejectFn">{{ $lc(btnsNames['refuse']) }}</el-button>
181
179
  <el-button v-if="authList.includes('takeOff')" plain @click="qjFn">{{ $lc(btnsNames['takeOff']) }}</el-button>
182
180
  <!-- END -->
183
181
  <el-button v-if="authList.includes('approval')" type="primary" @click="showAdvancePop">{{
@@ -447,10 +447,10 @@ export default {
447
447
  type: String,
448
448
  default: 'left-right'
449
449
  },
450
- seeTypes: {
451
- type: RegExp,
452
- default: /\.(jpg|png|gif|svg|pdf|swf|xlsx|xls|docx|doc|txt)$/i
453
- }
450
+ seeTypes: {
451
+ type: RegExp,
452
+ default: () => /\.(jpg|png|gif|svg|pdf|swf|xlsx|xls|docx|doc|txt)$/i
453
+ }
454
454
  },
455
455
  data() {
456
456
  this.viewerOptions = {
@@ -32,11 +32,15 @@
32
32
  :height="height"
33
33
  border
34
34
  @selection-change="(selection) => (selectionList = selection)"
35
- @sort-change="onSortChange"
36
35
  >
37
36
  <slot name="selection-column">
38
37
  <el-table-column type="selection" width="50" align="center" />
39
38
  </slot>
39
+ <el-table-column :label="'排序' | $lc" width="50" align="center">
40
+ <template slot-scope="{ row }">
41
+ <i class="n20-icon-tuodong file-upload-table__drag-handle" :data-row-key="row[keys.rowKey]"></i>
42
+ </template>
43
+ </el-table-column>
40
44
  <template v-if="dataPorp.slotHeader">
41
45
  <el-table-column
42
46
  v-for="item in dataPorp.slotHeader"
@@ -320,13 +324,15 @@
320
324
  </template>
321
325
 
322
326
  <script>
323
- import aiCheckDialog from './aiCheckDialog.vue'
324
- import getJsonc from '../../assets/getJsonc.js'
325
327
  import _axios from 'axios'
326
328
  import dayjs from 'dayjs'
329
+ import Sortable from 'sortablejs'
330
+ import 'viewerjs/dist/viewer.css'
327
331
  import XEUtils from 'xe-utils'
328
332
 
329
- import 'viewerjs/dist/viewer.css'
333
+ import aiCheckDialog from './aiCheckDialog.vue'
334
+
335
+ import getJsonc from '../../assets/getJsonc.js'
330
336
  import auth from '../../utils/auth'
331
337
  import axios from '../../utils/axios'
332
338
  import { $lc } from '../../utils/i18n/index'
@@ -402,7 +408,7 @@ export default {
402
408
  },
403
409
  action: {
404
410
  type: String,
405
- default: '/bems/1.0/attach'
411
+ default: '/neams/eamsbaserecord/batchSavejson'
406
412
  },
407
413
  batchPrintMethod: {
408
414
  type: Function,
@@ -510,7 +516,8 @@ export default {
510
516
  officeStatus: false,
511
517
  batchUploading: false,
512
518
  // 批量上传使用的文件数据(避免直接修改计算属性)
513
- _batchFileData: null
519
+ _batchFileData: null,
520
+ sortable: null
514
521
  }
515
522
  },
516
523
  computed: {
@@ -553,32 +560,64 @@ export default {
553
560
  },
554
561
  immediate: true,
555
562
  deep: true
563
+ },
564
+ tableKey() {
565
+ this.initSortable()
556
566
  }
557
567
  },
558
568
  mounted() {
559
569
  this.getConfiguration()
570
+ this.initSortable()
571
+ },
572
+ beforeDestroy() {
573
+ this.destroySortable()
560
574
  },
561
575
  methods: {
562
- // 点击附件名称表头排序(替代原拖动排序)
563
- onSortChange({ prop, order }) {
564
- // 仅处理附件名称列;order 为 null(取消排序)时不处理
565
- if (prop !== this.keys.name || !order) {
566
- return
567
- }
568
- const nameKey = this.keys.name
569
- // 与显示一致:去除扩展名后再比较
570
- const stripName = (v) => (v == null ? '' : String(v).replace(/\.[A-z0-9]+$/, ''))
571
- const dir = order === 'ascending' ? 1 : -1
572
- const sorted = [...this.tableData].sort(
573
- (a, b) => stripName(a[nameKey]).localeCompare(stripName(b[nameKey]), 'zh-CN', { numeric:true }) * dir
574
- )
575
- // 原地更新 tableData(沿用现有 splice 修改 prop 数组的模式)
576
- this.tableData.splice(0, this.tableData.length, ...sorted)
577
- this.$emit('sort', this.tableData.slice())
578
- this.saveFileSort().catch(() => {
579
- this.$message.error($lc('附件排序保存失败'))
576
+ initSortable() {
577
+ this.$nextTick(() => {
578
+ this.destroySortable()
579
+
580
+ const $tbody = this.$refs.elTable?.$el?.querySelector('.el-table__body-wrapper > table > tbody')
581
+ if (!$tbody) {
582
+ return
583
+ }
584
+
585
+ this.sortable = Sortable.create($tbody, {
586
+ handle: '.file-upload-table__drag-handle',
587
+ ghostClass: 'file-upload-table__sortable-ghost',
588
+ setData(dataTransfer) {
589
+ dataTransfer.setData('Text', '')
590
+ },
591
+ onEnd: ({ oldIndex, newIndex }) => {
592
+ if (
593
+ oldIndex === newIndex ||
594
+ oldIndex === undefined ||
595
+ newIndex === undefined ||
596
+ oldIndex < 0 ||
597
+ newIndex < 0
598
+ ) {
599
+ return
600
+ }
601
+
602
+ const targetRow = this.tableData.splice(oldIndex, 1)[0]
603
+ if (!targetRow) {
604
+ return
605
+ }
606
+ this.tableData.splice(newIndex, 0, targetRow)
607
+ this.$emit('sort', this.tableData.slice())
608
+ this.saveFileSort().catch(() => {
609
+ this.$message.error($lc('附件排序保存失败'))
610
+ })
611
+ }
612
+ })
580
613
  })
581
614
  },
615
+ destroySortable() {
616
+ if (this.sortable) {
617
+ this.sortable.destroy()
618
+ this.sortable = null
619
+ }
620
+ },
582
621
  async saveFileSort() {
583
622
  const sortList = this.tableData
584
623
  .map((row, index) => ({
@@ -629,7 +668,7 @@ export default {
629
668
  })
630
669
  } else {
631
670
  if (!this.AIOptions.bussType) {
632
- this.$message.error($lc("请先配置bussType"))
671
+ this.$message.error($lc('请先配置bussType'))
633
672
  return false
634
673
  }
635
674
  let { data, code } = await axios.post(
@@ -653,7 +692,7 @@ export default {
653
692
  // ai识别
654
693
  async AiFn(row) {
655
694
  if (!this.AIOptions.bussType) {
656
- this.$message.error($lc("请先配置bussType"))
695
+ this.$message.error($lc('请先配置bussType'))
657
696
  return false
658
697
  }
659
698
  const { data, code } = await axios.post(
@@ -822,11 +861,7 @@ export default {
822
861
  return
823
862
  }
824
863
  let placeholderIndex = this.tableData.findIndex(
825
- (item) =>
826
- item[this.keys.type] === type &&
827
- !item[this.keys.url] &&
828
- !item[this.keys.name] &&
829
- !item._name
864
+ (item) => item[this.keys.type] === type && !item[this.keys.url] && !item[this.keys.name] && !item._name
830
865
  )
831
866
  if (placeholderIndex > -1) {
832
867
  this.tableData.splice(placeholderIndex, 1)
@@ -1006,9 +1041,11 @@ export default {
1006
1041
  type: 'error',
1007
1042
  confirmButtonText: $lc('确认'),
1008
1043
  cancelButtonText: $lc('取消')
1009
- }).then(() => {
1010
- this.$emit('delete-rows', this.selectionList)
1011
- }).catch(() => undefined)
1044
+ })
1045
+ .then(() => {
1046
+ this.$emit('delete-rows', this.selectionList)
1047
+ })
1048
+ .catch(() => undefined)
1012
1049
  },
1013
1050
 
1014
1051
  async getFileInfo(row, type) {
@@ -1231,4 +1268,21 @@ export default {
1231
1268
  right: 46px;
1232
1269
  top: 10px;
1233
1270
  }
1271
+
1272
+ .file-upload-table__drag-handle {
1273
+ display: inline-block;
1274
+ color: #909399;
1275
+ font-size: 16px;
1276
+ cursor: move;
1277
+ }
1278
+
1279
+ .file-upload-table__drag-handle:hover {
1280
+ color: #606266;
1281
+ }
1282
+
1283
+ .file-upload-table__sortable-ghost {
1284
+ opacity: 0.8;
1285
+ color: #fff !important;
1286
+ background: #42b983 !important;
1287
+ }
1234
1288
  </style>