n20-common-lib 3.0.78 → 3.0.79

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.
@@ -263,6 +263,25 @@
263
263
  </template>
264
264
  </vxe-column>
265
265
  </template>
266
+ <!-- 固定操作列 -->
267
+ <vxe-column
268
+ v-if="isOperateFixed && btnList && btnList.length > 0"
269
+ :title="$lc('操作')"
270
+ field="__operate__"
271
+ :width="operateColumnWidth"
272
+ fixed="right"
273
+ align="center"
274
+ >
275
+ <template #header>
276
+ <div class="flex-box flex-v flex-c">
277
+ {{ $lc('操作') }}
278
+ <i class="v3-icon-unlock vxe-table--column__icon m-l-ss pointer" @click.stop="unfixOperateColumn"></i>
279
+ </div>
280
+ </template>
281
+ <template #default="{ row, $rowIndex }">
282
+ <OperateBtns :btn-list="btnList" :row="row" @command="(c) => handleOperateCommand(c, row, $rowIndex)" />
283
+ </template>
284
+ </vxe-column>
266
285
  <template #empty>
267
286
  <slot name="empty">
268
287
  <empty type="noData" :content="$lc('暂无数据')" :height="100" :width="100" />
@@ -273,17 +292,20 @@
273
292
  <tableOperate
274
293
  :show-column="showColumn"
275
294
  :show-setsize="showSetsize"
295
+ :show-pin-btn="btnList && btnList.length > 0"
296
+ :is-operate-fixed="isOperateFixed"
276
297
  :size="sizeC"
277
298
  v-bind="$attrs"
278
299
  @update:size="sizeUp"
279
300
  @resize="sizeSet"
280
301
  @toggle-expand="toggleExpand"
302
+ @toggle-operate-fixed="handleToggleOperateFixed"
281
303
  @visible-column="dialogVisible = !dialogVisible"
282
304
  />
283
305
  <!-- 操作列的悬浮按钮组 -->
284
306
  <transition name="hover-btns-fade">
285
307
  <div
286
- v-if="showHoverBtns && visibleHoverBtns.length > 0"
308
+ v-if="showHoverBtns && visibleHoverBtns.length > 0 && !isOperateFixed"
287
309
  class="table-hover-btns"
288
310
  :style="hoverBtnsStyle"
289
311
  @mouseenter="handleBtnGroupEnter"
@@ -350,6 +372,7 @@
350
372
  import empty from '../../Empty'
351
373
  import tableOperate from '../../TableOperate/index.vue'
352
374
  import tableShowColumn from '../../ShowColumn/index.vue'
375
+ import OperateBtns from '../../TableProOperateColumn/OperateBtns.vue'
353
376
 
354
377
  import { $lc } from '../../../utils/i18n/index.js'
355
378
 
@@ -373,7 +396,8 @@ export default {
373
396
  tableOperate,
374
397
  tableShowColumn,
375
398
  empty,
376
- renderer
399
+ renderer,
400
+ OperateBtns
377
401
  },
378
402
  props: {
379
403
  scrollY: {
@@ -541,6 +565,7 @@ export default {
541
565
  hoverHideTimer: null, // 隐藏延迟定时器
542
566
  isHoverOnBtnGroup: false, // 鼠标是否在按钮组上
543
567
  isDropdownVisible: false, // "更多"下拉菜单是否展开
568
+ isOperateFixed: true, // 操作按钮是否固定为列模式
544
569
  hoverHeaderProp: null, // 当前悬停表头列的 prop
545
570
  hoverIconKey: null, // 当前悬停的静态列头图标标识
546
571
  isExpand: false,
@@ -597,6 +622,10 @@ export default {
597
622
  const hasExpand = this.$attrs.treeConfig || this.$attrs['tree-config']
598
623
  const activeCount = [this.showColumn, this.showSetsize, hasExpand].filter(Boolean).length
599
624
  return activeCount === 3 ? 112 : 76
625
+ },
626
+ // 固定操作列宽度
627
+ operateColumnWidth() {
628
+ return 180
600
629
  }
601
630
  },
602
631
  watch: {
@@ -704,6 +733,32 @@ export default {
704
733
  // 手动触发 colsKey 刷新,让 vxe-table 重新渲染列配置
705
734
  this.colsKey = this.colsKey + 1
706
735
  },
736
+ // 固定操作列为内联列
737
+ fixOperateColumn() {
738
+ this.isOperateFixed = true
739
+ this.hideHoverBtns()
740
+ this.colsKey = this.colsKey + 1
741
+ this.$emit('operate-fixed-change', true)
742
+ },
743
+ // 取消固定,切换回悬浮按钮组
744
+ unfixOperateColumn() {
745
+ this.isOperateFixed = false
746
+ this.colsKey = this.colsKey + 1
747
+ this.$emit('operate-fixed-change', false)
748
+ },
749
+ // 处理固定操作列的按钮事件
750
+ handleOperateCommand(command, row, rowIndex) {
751
+ this.$emit(command, row, rowIndex)
752
+ this.$emit('hover-btn-click', { btn: { command }, row, rowIndex })
753
+ },
754
+ // 处理 tableOperate 固定/取消固定切换
755
+ handleToggleOperateFixed(fixed) {
756
+ if (fixed) {
757
+ this.fixOperateColumn()
758
+ } else {
759
+ this.unfixOperateColumn()
760
+ }
761
+ },
707
762
  // 判断按鈕是否显示
708
763
  hasBtn(isHas, row) {
709
764
  if (isHas === undefined || isHas === null) {
@@ -955,8 +1010,8 @@ export default {
955
1010
  },
956
1011
  // 鼠标进入单元格事件(防抖处理)
957
1012
  handleCellMouseEnter({ row, rowIndex, $rowIndex, $event }) {
958
- // 如果没有配置悬浮按钮,不处理
959
- if (!this.btnList || this.btnList.length === 0) {
1013
+ // 如果没有配置悬浮按钮,或已固定为列模式,不处理
1014
+ if (!this.btnList || this.btnList.length === 0 || this.isOperateFixed) {
960
1015
  return
961
1016
  }
962
1017
  // 清理隐藏定时器
@@ -979,8 +1034,8 @@ export default {
979
1034
  },
980
1035
  // 鼠标离开单元格事件(防抖处理)
981
1036
  handleCellMouseLeave({ row, rowIndex, $event }) {
982
- // 如果没有配置悬浮按钮,不处理
983
- if (!this.btnList || this.btnList.length === 0) {
1037
+ // 如果没有配置悬浮按钮,或已固定为列模式,不处理
1038
+ if (!this.btnList || this.btnList.length === 0 || this.isOperateFixed) {
984
1039
  return
985
1040
  }
986
1041
  // 清理显示定时器
@@ -1176,8 +1231,8 @@ export default {
1176
1231
  return column
1177
1232
  })
1178
1233
 
1179
- // 悬浮按钮:给最后一列预留按钮组空间
1180
- if (this.btnList?.length && calcColumns.length > 0) {
1234
+ // 悬浮按钮:给最后一列预留按钮组空间(固定模式下不需要)
1235
+ if (!this.isOperateFixed && this.btnList?.length && calcColumns.length > 0) {
1181
1236
  const lastColumn = calcColumns[calcColumns.length - 1]
1182
1237
  const baseWidth = lastColumn._baseWidth_ || 0
1183
1238
  if (baseWidth <= HOVER_BTNS_WIDTH) {