zenglf
2023-10-18 73250e481e966dd8e3372c518530203ac047da14
src/components/jeecg/JVxeTable/components/JVxeTable.js
@@ -48,7 +48,7 @@
      // prefix 前缀;suffix 后缀;
      slots: ['prefix', 'suffix'],
      // add 新增按钮;remove 删除按钮;clearSelection 清空选择按钮;collapse 展开收起
      btns: ['add', 'remove', 'clearSelection'],
      btns: ['add', 'remove', 'clearSelection']
    })),
    // 是否显示行号
    rowNumber: PropTypes.bool.def(false),
@@ -66,7 +66,7 @@
    // 最大高度
    maxHeight: {
      type: Number,
      default: () => null,
      default: () => null
    },
    // 要禁用的行 TODO 未实现
    disabledRows: PropTypes.object.def(() => ({})),
@@ -99,7 +99,7 @@
    // 注:该参数不能动态修改;如果行、列字段多的情况下,会根据机器性能造成不同程度的卡顿。
    alwaysEdit: PropTypes.bool.def(false),
    // 联动配置,数组,详情配置见文档
    linkageConfig: PropTypes.array.def(() => []),
    linkageConfig: PropTypes.array.def(() => [])
  },
  data() {
    return {
@@ -138,7 +138,7 @@
        //   gt: 15
        // },
        'radio-config': {highlight: true},
        'checkbox-config': {highlight: true},
        'checkbox-config': { highlight: true }
      },
      // 绑定左侧选择框
      selectedRows: [],
@@ -148,7 +148,7 @@
      statistics: {
        has: false,
        sum: [],
        average: [],
        average: []
      },
      // 允许执行刷新特效的行ID
      reloadEffectRowKeysMap: {},
@@ -156,7 +156,7 @@
      excludeCode:[],
      // 联动下拉选项(用于隔离不同的下拉选项)
      // 内部联动配置,map
      innerLinkageConfig: null,
      innerLinkageConfig: null
    }
  },
  computed: {
@@ -171,7 +171,7 @@
          scrolling: this.scrolling,
          reloadEffect: this.reloadEffect,
          reloadEffectRowKeysMap: this.reloadEffectRowKeysMap,
          listeners: this.cellListeners,
          listeners: this.cellListeners
        }
        if (column.$type === JVXETypes.rowDragSort) {
          renderOptions.dragSortKey = this.dragSortKey
@@ -191,7 +191,7 @@
              config: this.innerLinkageConfig.get(column.key),
              getLinkageOptionsSibling: this.getLinkageOptionsSibling,
              getLinkageOptionsAsync: this.getLinkageOptionsAsync,
              linkageSelectChange: this.linkageSelectChange,
              linkageSelectChange: this.linkageSelectChange
            }
          }
        }
@@ -204,20 +204,20 @@
        // update--begin--autor:lvdandan-----date:20201019------for:LOWCOD-882 【新行编辑】列表上带按钮的遮挡问题
        if (column.$type === JVXETypes.file || column.$type === JVXETypes.image) {
          if (column.width && column.width.endsWith('px')) {
            column.width = Number.parseInt(column.width.substr(0,column.width.length-2))+Number.parseInt(1)+'px';
            column.width = Number.parseInt(column.width.substr(0, column.width.length - 2)) + Number.parseInt(1) + 'px'
          }
        }
        // update--begin--autor:lvdandan-----date:20201019------for:LOWCOD-882 【新行编辑】列表上带按钮的遮挡问题
        // update--begin--autor:lvdandan-----date:20201211------for:JT-118 【online】 日期、时间控件长度较小
        if (column.$type === JVXETypes.datetime || column.$type === JVXETypes.userSelect || column.$type === JVXETypes.departSelect) {
          let width = column.width && column.width.endsWith('px')?Number.parseInt(column.width.substr(0,column.width.length-2)):0;
          let width = column.width && column.width.endsWith('px') ? Number.parseInt(column.width.substr(0, column.width.length - 2)) : 0
          if(width <= 190){
            column.width = '190px'
          }
        }
        if (column.$type === JVXETypes.date) {
          let width = column.width && column.width.endsWith('px')?Number.parseInt(column.width.substr(0,column.width.length-2)):0;
          let width = column.width && column.width.endsWith('px') ? Number.parseInt(column.width.substr(0, column.width.length - 2)) : 0
          if(width <= 135){
            column.width = '135px'
          }
@@ -235,7 +235,7 @@
      let expandConfig = Object.assign({}, this.defaultVxeProps['expand-config'], this.expandConfig)
      return Object.assign({}, this.defaultVxeProps, {
        showFooter: this.statistics.has,
        showFooter: this.statistics.has
      }, this.$attrs, {
        loading: this.loading,
        columns: this.vxeColumns,
@@ -245,7 +245,7 @@
        maxHeight: this.maxHeight,
        border: this.bordered,
        expandConfig: expandConfig,
        footerMethod: this.handleFooterMethod,
        footerMethod: this.handleFooterMethod
        // footerSpanMethod: this.handleFooterSpanMethod,
      })
    },
@@ -259,7 +259,7 @@
        'edit-actived': this.handleEditActived,
        'radio-change': this.handleVxeRadioChange,
        'checkbox-all': this.handleVxeCheckboxAll,
        'checkbox-change': this.handleVxeCheckboxChange,
        'checkbox-change': this.handleVxeCheckboxChange
      }
      // 用户传递的事件,进行合并操作
      Object.keys(this.$listeners).forEach(key => {
@@ -285,9 +285,9 @@
        /** 当前行向下移一位 */
        rowMoveDown: rowIndex => this.rowResort(rowIndex, rowIndex + 1),
        /** 在当前行下面插入一行 */
        rowInsertDown: rowIndex => this.insertRows({}, rowIndex + 1),
        rowInsertDown: rowIndex => this.insertRows({}, rowIndex + 1)
      }
    },
    }
  },
  watch: {
    dataSource: {
@@ -334,7 +334,7 @@
        //     }
        //   }
        // })
      },
      }
    },
    columns: {
      immediate: true,
@@ -470,7 +470,14 @@
          if (this.statistics.has && !dragSort) {
            width = 60
          }
          let col = {type: 'expand', title: '', width, fixed: 'left', align: 'center', slots: {content: 'expandContent'}}
          let col = {
            type: 'expand',
            title: '',
            width,
            fixed: 'left',
            align: 'center',
            slots: { content: 'expandContent' }
          }
          if (expandColumn) {
            col = Object.assign(col, expandColumn, {type: 'expand'})
          }
@@ -482,7 +489,14 @@
          if (this.statistics.has) {
            width = 60
          }
          let col = {type: JVXETypes.rowDragSort, title: '', width, fixed: 'left', align: 'center', cellRender: {name: JVXETypes._prefix + JVXETypes.rowDragSort}}
          let col = {
            type: JVXETypes.rowDragSort,
            title: '',
            width,
            fixed: 'left',
            align: 'center',
            cellRender: { name: JVXETypes._prefix + JVXETypes.rowDragSort }
          }
          if (dragSortColumn) {
            col = Object.assign(col, dragSortColumn, {type: JVXETypes.rowDragSort})
          }
@@ -525,7 +539,7 @@
          this.innerLinkageConfig = null
        }
      }
    },
    }
  },
  created() {
  },
@@ -791,7 +805,7 @@
                oldValue: oldValue,
                col: column.own,
                column: column,
                isSetValues: true,
                isSetValues: true
              })
            }
          } else {
@@ -802,10 +816,10 @@
      // 【issues/3828】数据更新后,重新计算统计列
      if (updated && this.statistics.has) {
        this.$nextTick(async () => {
          let {xTable} = this.$refs.vxe.$refs;
          await xTable.updateCache(true);
          await xTable.updateData();
        });
          let { xTable } = this.$refs.vxe.$refs
          await xTable.updateCache(true)
          await xTable.updateData()
        })
      }
    },
@@ -885,9 +899,9 @@
     * @param isOnlJs 是否是onlineJS增强触发的
     * @return
     */
  /*   async addRows(rows = {}, isOnlJs) {
    async addRows(rows = {}, isOnlJs) {
      return this._addOrInsert(rows, -1, 'added', isOnlJs)
    }, */
    },
    /**
     * 添加一行或多行
@@ -1134,7 +1148,17 @@
    _remove(rows) {
      const xTable = this.$refs.vxe.$refs.xTable
      const {afterFullData, tableFullData, tableSourceData, editStore, treeConfig, checkboxOpts, selection, isInsertByRow, scrollYLoad} = xTable
      const {
        afterFullData,
        tableFullData,
        tableSourceData,
        editStore,
        treeConfig,
        checkboxOpts,
        selection,
        isInsertByRow,
        scrollYLoad
      } = xTable
      const {actived, removeList, insertList} = editStore
      const {checkField: property} = checkboxOpts
      let rest = []
@@ -1239,7 +1263,7 @@
          this.trigger(triggerName, {
            row: row,
            $table: xTable,
            target: this,
            target: this
          })
        }
      }
@@ -1280,7 +1304,7 @@
        props: this.vxeProps,
        on: this.vxeEvents,
        // 作用域插槽的格式为
        scopedSlots: this.$scopedSlots,
        scopedSlots: this.$scopedSlots
      })
    },
    // 渲染工具栏
@@ -1293,7 +1317,7 @@
            size: this.size,
            disabled: this.disabled,
            disabledRows: this.disabledRows,
            selectedRowIds: this.selectedRowIds,
            selectedRowIds: this.selectedRowIds
          },
          on: {
            // 新增事件
@@ -1301,7 +1325,7 @@
            // 保存事件
            save: () => this.trigger('save', {
              $table: this.$refs.vxe,
              target: this,
              target: this
            }),
            // 删除事件
            remove: () => {
@@ -1326,8 +1350,8 @@
          },
          scopedSlots: {
            toolbarPrefix: this.$scopedSlots.toolbarPrefix,
            toolbarSuffix: this.$scopedSlots.toolbarSuffix,
          },
            toolbarSuffix: this.$scopedSlots.toolbarSuffix
          }
        })
      }
      return null
@@ -1345,7 +1369,7 @@
        return h('j-vxe-sub-popover', {
          ref: 'subPopover',
          scopedSlots: {
            subForm: this.$scopedSlots.subForm,
            subForm: this.$scopedSlots.subForm
          }
        })
      }
@@ -1374,7 +1398,7 @@
          },
          on: {
            change: (e) => this.trigger('pageChange', e)
          },
          }
        })
      }
      return null
@@ -1401,7 +1425,7 @@
      this.renderToolbar(h),
      this.renderToolbarAfterSlot(),
      this.renderVxeGrid(h),
      this.renderPagination(h),
      this.renderPagination(h)
    ])
  },
  beforeDestroy() {
@@ -1415,14 +1439,18 @@
  {title: '6到16位数字', value: 'n6-16', pattern: /^\d{6,16}$/},
  {title: '6到16位任意字符', value: '*6-16', pattern: /^.{6,16}$/},
  {title: '6到18位字母', value: 's6-18', pattern: /^[a-z|A-Z]{6,18}$/},
  {title: '网址', value: 'url', pattern: /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/},
  {
    title: '网址',
    value: 'url',
    pattern: /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/
  },
  {title: '电子邮件', value: 'e', pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/},
  {title: '手机号码', value: 'm', pattern: /^1[3456789]\d{9}$/},
  {title: '邮政编码', value: 'p', pattern: /^[0-9]{6}$/},
  {title: '字母', value: 's', pattern: /^[A-Z|a-z]+$/},
  {title: '数字', value: 'n', pattern: /^-?\d+(\.?\d+|\d?)$/},
  {title: '整数', value: 'z', pattern: /^-?\d+$/},
  {title: '金额', value: 'money', pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,5}))$/},
  { title: '金额', value: 'money', pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,5}))$/ }
]
/** 旧版handler转为新版Validator */