diff --git a/package.json b/package.json index 46f7eca0..8e29791c 100644 --- a/package.json +++ b/package.json @@ -47,10 +47,7 @@ "vue-router": "^3.0.1", "vue-splitpane": "^1.0.4", "vuedraggable": "^2.20.0", - "vuex": "^3.1.0", - "vxe-table": "^3.6.10", - "vxe-table-plugin-antd": "^1.11.2", - "xe-utils": "^3.5.7" + "vuex": "^3.1.0" }, "devDependencies": { "@babel/polyfill": "^7.2.5", diff --git a/src/components/JVxeCells/JVxeFileCell.vue b/src/components/JVxeCells/JVxeFileCell.vue deleted file mode 100644 index b54a321e..00000000 --- a/src/components/JVxeCells/JVxeFileCell.vue +++ /dev/null @@ -1,232 +0,0 @@ - - - - - diff --git a/src/components/JVxeCells/JVxeImageCell.vue b/src/components/JVxeCells/JVxeImageCell.vue deleted file mode 100644 index b149175c..00000000 --- a/src/components/JVxeCells/JVxeImageCell.vue +++ /dev/null @@ -1,245 +0,0 @@ - - - - - diff --git a/src/components/JVxeCells/JVxePopupCell.vue b/src/components/JVxeCells/JVxePopupCell.vue deleted file mode 100644 index 3c2b429f..00000000 --- a/src/components/JVxeCells/JVxePopupCell.vue +++ /dev/null @@ -1,63 +0,0 @@ - - - - - diff --git a/src/components/JVxeCells/JVxeRadioCell.vue b/src/components/JVxeCells/JVxeRadioCell.vue deleted file mode 100644 index 6f8f48f5..00000000 --- a/src/components/JVxeCells/JVxeRadioCell.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - - - diff --git a/src/components/JVxeCells/JVxeSelectDictSearchCell.js b/src/components/JVxeCells/JVxeSelectDictSearchCell.js deleted file mode 100644 index a984c05d..00000000 --- a/src/components/JVxeCells/JVxeSelectDictSearchCell.js +++ /dev/null @@ -1,262 +0,0 @@ -import debounce from 'lodash/debounce' -import { getAction } from '@/api/manage' -import { cloneObject } from '@/utils/util' -import { filterDictText } from '@/components/dict/JDictSelectUtil' -import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api' -import JVxeCellMixins, { dispatchEvent } from '@/components/jero/JVxeTable/mixins/JVxeCellMixins' - -/** 公共资源 */ -const common = { - /** value - label map,防止重复查询(刷新清空缓存) */ - labelMap: new Map(), - - /** 公共data */ - data () { - return { - loading: false, - innerSelectValue: null, - innerOptions: [] - } - }, - /** 公共计算属性 */ - computed: { - dict () { - return this.originColumn.dict - }, - options () { - if (this.isAsync) { - return this.innerOptions - } else { - return this.originColumn.options || [] - } - }, - // 是否是异步模式 - isAsync () { - const isAsync = this.originColumn.async - return (isAsync != null && isAsync !== '') ? !!isAsync : true - } - }, - /** 公共属性监听 */ - watch: { - innerValue: { - immediate: true, - handler (value) { - if (value == null || value === '') { - this.innerSelectValue = null - } else { - this.loadDataByValue(value) - } - } - }, - dict () { - this.loadDataByDict() - } - }, - /** 公共方法 */ - methods: { - - // 根据 value 查询数据,用于回显 - async loadDataByValue (value) { - if (this.isAsync) { - if (this.innerSelectValue !== value) { - if (common.labelMap.has(value)) { - this.innerOptions = cloneObject(common.labelMap.get(value)) - } else { - const { success, result } = await getAction(`/sys/dict/loadDictItem/${this.dict}`, { key: value }) - if (success && result && result.length > 0) { - this.innerOptions = [{ value: value, text: result[0] }] - common.labelMap.set(value, cloneObject(this.innerOptions)) - } - } - } - } - this.innerSelectValue = (value || '').toString() - }, - - // 初始化字典 - async loadDataByDict () { - if (!this.isAsync) { - // 如果字典项集合有数据 - if (!this.originColumn.options || this.originColumn.options.length === 0) { - // 根据字典Code, 初始化字典数组 - let dictStr = '' - if (this.dict) { - const arr = this.dict.split(',') - if (arr[0].indexOf('where') > 0) { - const tbInfo = arr[0].split('where') - dictStr = tbInfo[0].trim() + ',' + arr[1] + ',' + arr[2] + ',' + encodeURIComponent(tbInfo[1]) - } else { - dictStr = this.dict - } - if (this.dict.indexOf(',') === -1) { - // 优先从缓存中读取字典配置 - const cache = getDictItemsFromCache(this.dict) - if (cache) { - this.innerOptions = cache - return - } - } - const { success, result } = await ajaxGetDictItems(dictStr, null) - if (success) { - this.innerOptions = result - } - } - } - } - } - - } - -} - -// 显示组件,自带翻译 -export const DictSearchSpanCell = { - name: 'JVxeSelectSearchSpanCell', - mixins: [JVxeCellMixins], - data () { - return { - ...common.data.apply(this) - } - }, - computed: { - ...common.computed - }, - watch: { - ...common.watch - }, - methods: { - ...common.methods - }, - render (h) { - return h('span', {}, [ - filterDictText(this.innerOptions, this.innerSelectValue || this.innerValue) - ]) - } -} - -// 请求id -let requestId = 0 - -// 输入选择组件 -export const DictSearchInputCell = { - name: 'JVxeSelectSearchInputCell', - mixins: [JVxeCellMixins], - data () { - return { - ...common.data.apply(this), - - hasRequest: false, - scopedSlots: { - notFoundContent: () => { - if (this.loading) { - return - } else if (this.hasRequest) { - return
没有查询到任何数据
- } else { - return
{this.tipsContent}
- } - } - } - } - }, - computed: { - ...common.computed, - tipsContent () { - return this.originColumn.tipsContent || '请输入搜索内容' - }, - filterOption () { - if (this.isAsync) { - return null - } - return (input, option) => option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 - } - }, - watch: { - ...common.watch - }, - created () { - this.loadData = debounce(this.loadData, 300)// 消抖 - }, - methods: { - ...common.methods, - - loadData (value) { - const currentRequestId = ++requestId - this.loading = true - this.innerOptions = [] - if (value == null || value.trim() === '') { - this.loading = false - this.hasRequest = false - return - } - // 字典code格式:table,text,code - this.hasRequest = true - getAction(`/sys/dict/loadDict/${this.dict}`, { keyword: value }).then(res => { - if (currentRequestId !== requestId) { - return - } - const { success, result, message } = res - if (success) { - this.innerOptions = result - result.forEach((item) => { - common.labelMap.set(item.value, [item]) - }) - } else { - this.$message.warning(message) - } - }).finally(() => { - this.loading = false - }) - }, - - handleChange (selectedValue) { - this.innerSelectValue = selectedValue - this.handleChangeCommon(this.innerSelectValue) - }, - handleSearch (value) { - if (this.isAsync) { - // 在输入时也应该开启加载,因为loadData加了消抖,所以会有800ms的用户主观上认为的卡顿时间 - this.loading = true - if (this.innerOptions.length > 0) { - this.innerOptions = [] - } - this.loadData(value) - } - }, - - renderOptionItem () { - const options = [] - this.options.forEach(({ value, text, label, title, disabled }) => { - options.push( - {text || label || title} - ) - }) - return options - } - }, - render () { - return ( - - {this.renderOptionItem()} - - ) - }, - // 【组件增强】注释详见:JVxeCellMixins.js - enhanced: { - aopEvents: { - editActived (event) { - dispatchEvent.call(this, event, 'ant-select') - } - } - } -} diff --git a/src/components/JVxeCells/install.js b/src/components/JVxeCells/install.js deleted file mode 100644 index aae811fe..00000000 --- a/src/components/JVxeCells/install.js +++ /dev/null @@ -1,36 +0,0 @@ -import { installCell, JVXETypes } from '@/components/jero/JVxeTable' -import JVxePopupCell from './JVxePopupCell' -import { DictSearchInputCell, DictSearchSpanCell } from './JVxeSelectDictSearchCell' -import JVxeFileCell from './JVxeFileCell' -import JVxeImageCell from './JVxeImageCell' -import JVxeRadioCell from './JVxeRadioCell' -import JVxeSelectCell from '@comp/jero/JVxeTable/components/cells/JVxeSelectCell' -import JVxeTextareaCell from '@comp/jero/JVxeTable/components/cells/JVxeTextareaCell' - -// 注册online组件 -JVXETypes.input_pop = 'input_pop' -JVXETypes.list_multi = 'list_multi' -JVXETypes.sel_search = 'sel_search' -installCell(JVXETypes.input_pop, JVxeTextareaCell) -installCell(JVXETypes.list_multi, JVxeSelectCell) -installCell(JVXETypes.sel_search, JVxeSelectCell) - -// 注册【popup】组件(普通封装方式) -JVXETypes.popup = 'popup' -installCell(JVXETypes.popup, JVxePopupCell) - -// 注册【字典搜索下拉】组件(高级封装方式) -JVXETypes.selectDictSearch = 'select-dict-search' -installCell(JVXETypes.selectDictSearch, DictSearchInputCell, DictSearchSpanCell) - -// 注册【文件上传】组件 -JVXETypes.file = 'file' -installCell(JVXETypes.file, JVxeFileCell) - -// 注册【图片上传】组件 -JVXETypes.image = 'image' -installCell(JVXETypes.image, JVxeImageCell) - -// 注册【单选框】组件 -JVXETypes.radio = 'radio' -installCell(JVXETypes.radio, JVxeRadioCell) diff --git a/src/components/chart/AreaChartTy.vue b/src/components/chart/AreaChartTy.vue deleted file mode 100644 index 969a636b..00000000 --- a/src/components/chart/AreaChartTy.vue +++ /dev/null @@ -1,88 +0,0 @@ - - - - - diff --git a/src/components/chart/Bar.vue b/src/components/chart/Bar.vue deleted file mode 100644 index 52ba196b..00000000 --- a/src/components/chart/Bar.vue +++ /dev/null @@ -1,50 +0,0 @@ - - - diff --git a/src/components/chart/BarAndLine.vue b/src/components/chart/BarAndLine.vue deleted file mode 100644 index a2b1900f..00000000 --- a/src/components/chart/BarAndLine.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - diff --git a/src/components/chart/BarMultid.vue b/src/components/chart/BarMultid.vue deleted file mode 100644 index c3f66187..00000000 --- a/src/components/chart/BarMultid.vue +++ /dev/null @@ -1,96 +0,0 @@ - - - - - diff --git a/src/components/chart/DashChartDemo.vue b/src/components/chart/DashChartDemo.vue deleted file mode 100644 index 6d541c45..00000000 --- a/src/components/chart/DashChartDemo.vue +++ /dev/null @@ -1,187 +0,0 @@ - - - diff --git a/src/components/chart/IndexBar.vue b/src/components/chart/IndexBar.vue deleted file mode 100644 index f756f1ac..00000000 --- a/src/components/chart/IndexBar.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - diff --git a/src/components/chart/LineChartMultid.vue b/src/components/chart/LineChartMultid.vue deleted file mode 100644 index 8c1ab207..00000000 --- a/src/components/chart/LineChartMultid.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - - - diff --git a/src/components/chart/Liquid.vue b/src/components/chart/Liquid.vue deleted file mode 100644 index 2e1d7773..00000000 --- a/src/components/chart/Liquid.vue +++ /dev/null @@ -1,80 +0,0 @@ - - - - - diff --git a/src/components/chart/MiniArea.vue b/src/components/chart/MiniArea.vue deleted file mode 100644 index 3b8da0bb..00000000 --- a/src/components/chart/MiniArea.vue +++ /dev/null @@ -1,69 +0,0 @@ - - - - - diff --git a/src/components/chart/MiniBar.vue b/src/components/chart/MiniBar.vue deleted file mode 100644 index 76c211aa..00000000 --- a/src/components/chart/MiniBar.vue +++ /dev/null @@ -1,76 +0,0 @@ - - - - - diff --git a/src/components/chart/MiniProgress.vue b/src/components/chart/MiniProgress.vue deleted file mode 100644 index b7c59448..00000000 --- a/src/components/chart/MiniProgress.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - - - diff --git a/src/components/chart/Pie.vue b/src/components/chart/Pie.vue deleted file mode 100644 index 3e1a3062..00000000 --- a/src/components/chart/Pie.vue +++ /dev/null @@ -1,70 +0,0 @@ - - - diff --git a/src/components/chart/README.md b/src/components/chart/README.md deleted file mode 100644 index 9aacf09d..00000000 --- a/src/components/chart/README.md +++ /dev/null @@ -1,367 +0,0 @@ -# 报表组件文档 - -## 柱状图 - -##### 引用方式 - -```js -import Bar from '@/components/chart/Bar' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|------------|--------|----|------------| -| title | string | | 报表标题 | -| dataSource | array | ✔️ | 报表数据源 | -| height | number | | 报表高度,默认254 | - -##### dataSource 示例 - -```json -[ - { - "x": "1月", - "y": 320 - }, - { - "x": "2月", - "y": 457 - }, - { - "x": "3月", - "y": 182 - } -] -``` - -##### 代码示例 - -```html - - - - - -``` - -## 多列柱状图 - -##### 引用方式 - -```js -import BarMultid from '@/components/chart/BarMultid' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|------------|--------|----|------------| -| title | string | | 报表标题 | -| fields | array | | 主列字段列表 | -| dataSource | array | | 报表数据源 | -| height | number | | 报表高度,默认254 | - -##### fields 示例 - -```json -["Jan.", "Feb.", "Mar.", "Apr.", "May", "Jun.", "Jul.", "Aug."] -``` - -##### dataSource 示例 - -```json -[ - { - "type": "jero", // 列名 - "Jan.": 18.9, - "Feb.": 28.8, - "Mar.": 39.3, - "Apr.": 81.4, - "May": 47, - "Jun.": 20.3, - "Jul.": 24, - "Aug.": 35.6 - }, - { - "type": "jeroTwo", - "Jan.": 12.4, - "Feb.": 23.2, - "Mar.": 34.5, - "Apr.": 99.7, - "May": 52.6, - "Jun.": 35.5, - "Jul.": 37.4, - "Aug.": 42.4 - } -] -``` - -## 迷你柱状图 - -不带标题和数据轴的柱状图 - -##### 引用方式 - -```js -import MiniBar from '@/components/chart/MiniBar' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|------------|--------|----|---------------| -| width | number | | 报表宽度度,默认自适应宽度 | -| height | number | | 报表高度,默认200 | -| dataSource | array | | 报表数据源 | - -##### dataSource 示例 - -```json -[ - { - "x": "1月", - "y": 320 - }, - { - "x": "2月", - "y": 457 - }, - { - "x": "3月", - "y": 182 - } -] -``` - -## 面积图 - -##### 引用方式 - -```js -import AreaChartTy from '@/components/chart/AreaChartTy' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|------------|--------|----|------------| -| title | string | | 报表标题 | -| dataSource | array | ✔️ | 报表数据源 | -| height | number | | 报表高度,默认254 | -| lineSize | number | | 线的粗细,默认2 | - -##### dataSource 示例 - -```json -[ - { - "x": "1月", - "y": 320 - }, - { - "x": "2月", - "y": 457 - }, - { - "x": "3月", - "y": 182 - } -] -``` - -## 多行折线图 - -##### 引用方式 - -```js -import LineChartMultid from '@/components/chart/LineChartMultid' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|------------|--------|----|------------| -| title | string | | 报表标题 | -| fields | array | | 主列字段列表 | -| dataSource | array | | 报表数据源 | -| height | number | | 报表高度,默认254 | - -##### fields 示例 - -```json -["jero", "jeroTwo"] -``` - -##### dataSource 示例 - -```json -[ - { - "type": "Jan", // 列名 - "jero": 7, - "jeroTwo": 3.9 - }, - { "type": "Feb", "jero": 6.9, "jeroTwo": 4.2 }, - { "type": "Mar", "jero": 9.5, "jeroTwo": 5.7 }, - { "type": "Apr", "jero": 14.5, "jeroTwo": 8.5 }, - { "type": "May", "jero": 18.4, "jeroTwo": 11.9 }, - { "type": "Jun", "jero": 21.5, "jeroTwo": 15.2 }, - { "type": "Jul", "jero": 25.2, "jeroTwo": 17 }, - { "type": "Aug", "jero": 26.5, "jeroTwo": 16.6 }, - { "type": "Sep", "jero": 23.3, "jeroTwo": 14.2 }, - { "type": "Oct", "jero": 18.3, "jeroTwo": 10.3 }, - { "type": "Nov", "jero": 13.9, "jeroTwo": 6.6 }, - { "type": "Dec", "jero": 9.6, "jeroTwo": 4.8 } -] -``` - -## 饼状图 - -##### 引用方式 - -```js -import Pie from '@/components/chart/Pie' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|------------|--------|----|------------| -| dataSource | array | | 报表数据源 | -| height | number | | 报表高度,默认254 | - -##### dataSource 示例 - -```json -[ - // 所有的 percent 相加等于 100 - { "item": "一月", "percent": 40 }, - { "item": "二月", "percent": 21 }, - { "item": "三月", "percent": 17 }, - { "item": "四月", "percent": 13 }, - { "item": "五月", "percent": 9 } -] -``` - -## 雷达图 - -##### 引用方式 - -```js -import Radar from '@/components/chart/Radar' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|------------|--------|----|------------| -| dataSource | array | | 报表数据源 | -| height | number | | 报表高度,默认254 | - -##### dataSource 示例 - -```json -[ - // score 最小值为 0,最大值为 100 - { "item": "一月", "score": 40 }, - { "item": "二月", "score": 20 }, - { "item": "三月", "score": 67 }, - { "item": "四月", "score": 43 }, - { "item": "五月", "score": 90 } -] -``` - -## 进度条 - -##### 引用方式 - -```js -import MiniProgress from '@/components/chart/MiniProgress' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|------------|--------|----|-------------------| -| percentage | number | | 当前进度百分比,默认0,最高100 | -| target | number | | 目标值,默认10 | -| height | number | | 进度条高度,默认10 | -| color | string | | 进度条颜色,默认 #13C2C2 | - -## 仪表盘 - -##### 引用方式 - -```js -import DashChartDemo from '@/components/chart/DashChartDemo' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|--------|--------|----|----------------| -| title | string | | 报表标题 | -| value | number | | 当前值,默认6.7,最大为9 | -| height | number | | 报表高度,默认254 | - -## 排名列表 - -##### 引用方式 - -```js -import RankList from '@/components/chart/RankList' -``` - -##### 参数列表 - -| 参数名 | 类型 | 必填 | 说明 | -|--------|--------|----|--------------| -| title | string | | 报表标题 | -| list | array | | 排名列表数据 | -| height | number | | 报表高度,默认自适应高度 | - -##### list 示例 - -```json -[ - { - "name": "北京朝阳 1 号店", - "total": 1981 - }, - { "name": "北京朝阳 2 号店", "total": 1359 }, - { "name": "北京朝阳 3 号店", "total": 1354 }, - { "name": "北京朝阳 4 号店", "total": 263 }, - { "name": "北京朝阳 5 号店", "total": 446 }, - { "name": "北京朝阳 6 号店", "total": 796 } -] -``` \ No newline at end of file diff --git a/src/components/chart/Radar.vue b/src/components/chart/Radar.vue deleted file mode 100644 index c186da26..00000000 --- a/src/components/chart/Radar.vue +++ /dev/null @@ -1,90 +0,0 @@ - - - - - diff --git a/src/components/chart/RankList.vue b/src/components/chart/RankList.vue deleted file mode 100644 index 6376b167..00000000 --- a/src/components/chart/RankList.vue +++ /dev/null @@ -1,81 +0,0 @@ - - - - - diff --git a/src/components/chart/StackBar.vue b/src/components/chart/StackBar.vue deleted file mode 100644 index ca8ffb37..00000000 --- a/src/components/chart/StackBar.vue +++ /dev/null @@ -1,54 +0,0 @@ - - - diff --git a/src/components/chart/TransferBar.vue b/src/components/chart/TransferBar.vue deleted file mode 100644 index 8cd94c7c..00000000 --- a/src/components/chart/TransferBar.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - diff --git a/src/components/chart/Trend.vue b/src/components/chart/Trend.vue deleted file mode 100644 index 7b5ba71e..00000000 --- a/src/components/chart/Trend.vue +++ /dev/null @@ -1,84 +0,0 @@ - - - - - diff --git a/src/components/chart/chart.less b/src/components/chart/chart.less deleted file mode 100644 index e04fa095..00000000 --- a/src/components/chart/chart.less +++ /dev/null @@ -1,13 +0,0 @@ -.antv-chart-mini { - position: relative; - width: 100%; - - .chart-wrapper { - position: absolute; - bottom: -28px; - width: 100%; - -/* margin: 0 -5px; - overflow: hidden;*/ - } -} \ No newline at end of file diff --git a/src/components/chart/mixins/ChartMixins.js b/src/components/chart/mixins/ChartMixins.js deleted file mode 100644 index 7484ffbc..00000000 --- a/src/components/chart/mixins/ChartMixins.js +++ /dev/null @@ -1,10 +0,0 @@ -export const ChartEventMixins = { - methods: { - handleClick (event, chart) { - this.handleEvent('click', event, chart) - }, - handleEvent (eventName, event, chart) { - this.$emit(eventName, event, chart) - } - } -} diff --git a/src/components/jero/JVxeTable/components/JVxeDetailsModal.vue b/src/components/jero/JVxeTable/components/JVxeDetailsModal.vue deleted file mode 100644 index 99157269..00000000 --- a/src/components/jero/JVxeTable/components/JVxeDetailsModal.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/src/components/jero/JVxeTable/components/JVxePagination.vue b/src/components/jero/JVxeTable/components/JVxePagination.vue deleted file mode 100644 index 8106a96c..00000000 --- a/src/components/jero/JVxeTable/components/JVxePagination.vue +++ /dev/null @@ -1,67 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/JVxeSubPopover.vue b/src/components/jero/JVxeTable/components/JVxeSubPopover.vue deleted file mode 100644 index 488683f9..00000000 --- a/src/components/jero/JVxeTable/components/JVxeSubPopover.vue +++ /dev/null @@ -1,181 +0,0 @@ - - - - diff --git a/src/components/jero/JVxeTable/components/JVxeTable.js b/src/components/jero/JVxeTable/components/JVxeTable.js deleted file mode 100644 index 975dc828..00000000 --- a/src/components/jero/JVxeTable/components/JVxeTable.js +++ /dev/null @@ -1,1472 +0,0 @@ -import XEUtils from 'xe-utils' -import PropTypes from 'ant-design-vue/es/_util/vue-types' -import { JVXETypes } from '@/components/jero/JVxeTable/jvxeTypes' -import VxeWebSocketMixins from '../mixins/vxe.web.socket.mixins' -import { initDictOptions } from '@/components/dict/JDictSelectUtil' - -import { getRefPromise } from '../utils/vxeUtils' -import { getEnhancedMixins, replaceProps } from '../utils/cellUtils' - -import JVxeToolbar from './JVxeToolbar' -import JVxeSubPopover from './JVxeSubPopover' -import JVxeDetailsModal from './JVxeDetailsModal' -import JVxePagination from './JVxePagination' -import { cloneObject, getVmParentByName, pushIfNotExist, randomString, simpleDebounce } from '@/utils/util' -import { UtilTools } from 'vxe-table/packages/tools/utils' -import { getNoAuthCols } from '@/utils/authFilter' - -export default { - name: 'JVxeTable', - provide () { - return { - superTrigger: (name, event) => this.trigger(name, event) - } - }, - mixins: [VxeWebSocketMixins], - components: { JVxeToolbar, JVxeSubPopover, JVxeDetailsModal, JVxePagination }, - props: { - rowKey: PropTypes.string.def('id'), - // 列信息 - columns: { - type: Array, - required: true - }, - // 数据源 - dataSource: { - type: Array, - required: true - }, - authPre: { - type: String, - required: false, - default: '' - }, - // 是否显示工具栏 - toolbar: PropTypes.bool.def(false), - // 工具栏配置 - toolbarConfig: PropTypes.object.def(() => ({ - // prefix 前缀;suffix 后缀; - slots: ['prefix', 'suffix'], - // add 新增按钮;remove 删除按钮;clearSelection 清空选择按钮;collapse 展开收起 - btns: ['add', 'remove', 'clearSelection'] - })), - // 是否显示行号 - rowNumber: PropTypes.bool.def(false), - // 是否可选择行 - rowSelection: PropTypes.bool.def(false), - // 选择行类型 - rowSelectionType: PropTypes.oneOf(['checkbox', 'radio']).def('checkbox'), - // 是否可展开行 - rowExpand: PropTypes.bool.def(false), - // 展开行配置 - expandConfig: PropTypes.object.def(() => ({})), - // 页面是否在加载中 - loading: PropTypes.bool.def(false), - height: PropTypes.instanceOf([Number, String]).def('auto'), - // 最大高度 - maxHeight: { - type: Number, - default: () => null - }, - // 要禁用的行 TODO 未实现 - disabledRows: PropTypes.object.def(() => ({})), - // 是否禁用全部组件 - disabled: PropTypes.bool.def(false), - // 是否可拖拽排序 TODO 仅实现上下排序,未实现拖拽排序(可能无法实现或较为困难) - dragSort: PropTypes.bool.def(false), - // 排序字段保存的Key - dragSortKey: PropTypes.string.def('orderNum'), - // 大小,可选值有:medium(中)、small(小)、mini(微)、tiny(非常小) - size: PropTypes.oneOf(['medium', 'small', 'mini', 'tiny']).def('medium'), - // 是否显示边框线 - bordered: PropTypes.bool.def(false), - // 分页器参数,设置了即可显示分页器 - pagination: PropTypes.object.def(() => ({})), - // 点击行时是否显示子表单 - clickRowShowSubForm: PropTypes.bool.def(false), - // 点击行时是否显示主表单 - clickRowShowMainForm: PropTypes.bool.def(false), - // 是否点击选中行,优先级最低 - clickSelectRow: PropTypes.bool.def(false), - // 是否开启 reload 数据效果 - reloadEffect: PropTypes.bool.def(false), - // 校验规则 - editRules: PropTypes.object.def(() => ({})), - // 是否异步删除行,如果你要实现异步删除,那么需要把这个选项开启, - // 在remove事件里调用confirmRemove方法才会真正删除(除非删除的全是新增的行) - asyncRemove: PropTypes.bool.def(false), - // 是否一直显示组件,如果为false则只有点击的时候才出现组件 - // 注:该参数不能动态修改;如果行、列字段多的情况下,会根据机器性能造成不同程度的卡顿。 - alwaysEdit: PropTypes.bool.def(false), - // 联动配置,数组,详情配置见文档 - linkageConfig: PropTypes.array.def(() => []) - }, - data () { - return { - isJVXETable: true, - // caseId,表格唯一标识 - caseId: `_j-vxe-${randomString(8)}_`, - // 内置columns - _innerColumns: [], - // 内置 EditRules - _innerEditRules: [], - // 记录滚动条位置 - scroll: { top: 0, left: 0 }, - // 当前是否正在滚动 - scrolling: false, - // vxe 默认配置 - defaultVxeProps: { - 'row-id': this.rowKey, - // 高亮hover的行 - 'highlight-hover-row': true, - // 溢出隐藏并显示tooltip - 'show-overflow': true, - // 表头溢出隐藏并显示tooltip - 'show-header-overflow': true, - 'show-footer-overflow': true, - // 可编辑配置 - 'edit-config': { trigger: 'click', mode: 'cell', showStatus: true }, - 'expand-config': { - iconClose: 'ant-table-row-expand-icon ant-table-row-collapsed', - iconOpen: 'ant-table-row-expand-icon ant-table-row-expanded' - }, - // 虚拟滚动配置,y轴大于30条数据时启用虚拟滚动 - // 'scroll-y': { - // gt: 30 - // }, - // 'scroll-x': { - // gt: 15 - // }, - 'radio-config': { highlight: true }, - 'checkbox-config': { highlight: true } - }, - // 绑定左侧选择框 - selectedRows: [], - // 绑定左侧选择框已选择的id - selectedRowIds: [], - // 统计列配置 - statistics: { - has: false, - sum: [], - average: [] - }, - // 允许执行刷新特效的行ID - reloadEffectRowKeysMap: {}, - // 配置了但是没有授权的按钮和列 集合 - excludeCode: [], - // 联动下拉选项(用于隔离不同的下拉选项) - // 内部联动配置,map - _innerLinkageConfig: null - } - }, - computed: { - - // vxe 最终 columns - vxeColumns () { - this._innerColumns.forEach(column => { - const renderOptions = { - caseId: this.caseId, - bordered: this.bordered, - disabled: this.disabled, - scrolling: this.scrolling, - reloadEffect: this.reloadEffect, - reloadEffectRowKeysMap: this.reloadEffectRowKeysMap, - listeners: this.cellListeners - } - if (column.$type === JVXETypes.rowDragSort) { - renderOptions.dragSortKey = this.dragSortKey - } - // slot 组件特殊处理 - if (column.$type === JVXETypes.slot) { - if (Object.prototype.hasOwnProperty.call(this.$scopedSlots, column.slotName)) { - renderOptions.slot = this.$scopedSlots[column.slotName] - renderOptions.target = this - } - } - // 处理联动列,联动列只能作用于 select 组件 - if (column.$type === JVXETypes.select && this._innerLinkageConfig != null) { - // 判断当前列是否是联动列 - if (this._innerLinkageConfig.has(column.key)) { - renderOptions.linkage = { - config: this._innerLinkageConfig.get(column.key), - getLinkageOptionsSibling: this.getLinkageOptionsSibling, - getLinkageOptionsAsync: this.getLinkageOptionsAsync, - linkageSelectChange: this.linkageSelectChange - } - } - } - if (column.editRender) { - Object.assign(column.editRender, renderOptions) - } - if (column.cellRender) { - Object.assign(column.cellRender, renderOptions) - } - // 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' - } - } - // 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) { - const 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) { - const width = column.width && column.width.endsWith('px') ? Number.parseInt(column.width.substr(0, column.width.length - 2)) : 0 - if (width <= 135) { - column.width = '135px' - } - } - // update--end--autor:lvdandan-----date:20201211------for:JT-118 【online】 日期、时间控件长度较小 - }) - return this._innerColumns - }, - // vxe 最终 editRules - vxeEditRules () { - return Object.assign({}, this.editRules, this._innerEditRules) - }, - // vxe 最终 props - vxeProps () { - const expandConfig = Object.assign({}, this.defaultVxeProps['expand-config'], this.expandConfig) - - return Object.assign({}, this.defaultVxeProps, { - showFooter: this.statistics.has - }, this.$attrs, { - loading: this.loading, - columns: this.vxeColumns, - editRules: this.vxeEditRules, - // data: this.dataSource, - height: this.height === 'auto' ? null : this.height, - maxHeight: this.maxHeight, - border: this.bordered, - expandConfig: expandConfig, - footerMethod: this.handleFooterMethod - // footerSpanMethod: this.handleFooterSpanMethod, - }) - }, - // vxe 最终 events - vxeEvents () { - // 内置事件 - const events = { - scroll: this.handleVxeScroll, - 'cell-click': this.handleCellClick, - 'edit-closed': this.handleEditClosed, - 'edit-actived': this.handleEditActived, - 'radio-change': this.handleVxeRadioChange, - 'checkbox-all': this.handleVxeCheckboxAll, - 'checkbox-change': this.handleVxeCheckboxChange - } - // 用户传递的事件,进行合并操作 - Object.keys(this.$listeners).forEach(key => { - let listen = this.$listeners[key] - if (Object.prototype.hasOwnProperty.call(events, key)) { - if (Array.isArray(listen)) { - listen.push(events[key]) - } else { - listen = [events[key], listen] - } - } - events[key] = listen - }) - return events - }, - // 组件监听事件 - cellListeners () { - return { - trigger: (name, event) => this.trigger(name, event), - valueChange: event => this.trigger('valueChange', event), - /** 当前行向上移一位 */ - rowMoveUp: rowIndex => this.rowResort(rowIndex, rowIndex - 1), - /** 当前行向下移一位 */ - rowMoveDown: rowIndex => this.rowResort(rowIndex, rowIndex + 1), - /** 在当前行下面插入一行 */ - rowInsertDown: rowIndex => this.insertRows({}, rowIndex + 1) - } - } - }, - watch: { - dataSource: { - // deep: true, - immediate: true, - async handler () { - const vxe = await getRefPromise(this, 'vxe') - - this.dataSource.forEach((data, idx) => { - // 开启了排序就自动计算排序值 - if (this.dragSort) { - this.$set(data, this.dragSortKey, idx + 1) - } - // 处理联动回显数据 - if (this._innerLinkageConfig != null) { - for (const configItem of this._innerLinkageConfig.values()) { - this.autoSetLinkageOptionsByData(data, '', configItem, 0) - } - } - }) - - // 阻断vue监听大数据,提高性能 - vxe.loadData(this.dataSource) - - // TODO 解析disabledRows - // let disabled = false - // - // let disabledRowIds = (this.disabledRowIds || []) - // // 解析disabledRows - // Object.keys(this.disabledRows).forEach(disabledColKey => { - // // 判断是否有该属性 - // if (data.hasOwnProperty(disabledColKey)) { - // if (disabled !== true) { - // let temp = this.disabledRows[disabledColKey] - // // 禁用规则可以是一个数组 - // if (Array.isArray(temp)) { - // disabled = temp.includes(data[disabledColKey]) - // } else { - // disabled = (temp === data[disabledColKey]) - // } - // if (disabled) { - // disabledRowIds.push(row.id) - // } - // } - // } - // }) - } - }, - columns: { - immediate: true, - handler (columns) { - // 获取不需要显示列 - this.loadExcludeCode() - const _innerColumns = [] - const _innerEditRules = {} - const { rowNumber, rowSelection, rowExpand, dragSort } = this - let expandColumn, seqColumn, checkboxColumn, radioColumn, dragSortColumn - if (Array.isArray(columns)) { - this.statistics.has = false - this.statistics.sum = [] - this.statistics.average = [] - - // 处理成vxe可识别的columns - columns.forEach((column, columnIndex) => { - if (this.excludeCode.indexOf(column.key) >= 0) { - return false - } - const col = { ...column } - const { type } = col - const enhanced = getEnhancedMixins(type) - if (type === JVXETypes.rowNumber) { - seqColumn = col - } else if (type === JVXETypes.rowCheckbox) { - checkboxColumn = col - } else if (type === JVXETypes.rowRadio) { - radioColumn = col - } else if (type === JVXETypes.rowExpand) { - expandColumn = col - } else if (type === JVXETypes.rowDragSort) { - dragSortColumn = col - } else { - col.field = col.key - // 防止和vxeTable自带的type起冲突 - col.$type = col.type - delete col.type - let renderName = 'cellRender' - const renderOptions = { name: JVXETypes._prefix + type } - if (type) { - // hidden 是特殊的组件 - if (type === JVXETypes.hidden) { - col.visible = false - } else if (enhanced.switches.editRender) { - renderName = 'editRender' - renderOptions.type = (enhanced.switches.visible || this.alwaysEdit) ? 'visible' : 'default' - } - } else { - renderOptions.name = JVXETypes._prefix + JVXETypes.normal - } - col[renderName] = renderOptions - // 处理字典 - if (col.dictCode) { - this._loadDictConcatToOptions(col, columnIndex) - } - // 处理校验 - if (col.validateRules) { - const rules = [] - if (Array.isArray(col.validateRules)) { - for (const rule of col.validateRules) { - const replace = { - message: replaceProps(col, rule.message) - } - if (rule.unique || rule.pattern === 'only') { - // 唯一校验器 - rule.validator = uniqueValidator.bind(this) - } else if (rule.pattern) { - // 非空 - if (rule.pattern === fooPatterns[0].value) { - rule.required = true - delete rule.pattern - } else { - // 兼容Online表单的特殊规则 - for (const foo of fooPatterns) { - if (foo.value === rule.pattern) { - rule.pattern = foo.pattern - break - } - } - } - } else if (typeof rule.handler === 'function') { - // 自定义函数校验 - rule.validator = handlerConvertToValidator.bind(this) - } - rules.push(Object.assign({}, rule, replace)) - } - } - _innerEditRules[col.key] = rules - } - // 处理统计列 - // sum = 求和、average = 平均值 - if (Array.isArray(col.statistics)) { - this.statistics.has = true - col.statistics.forEach(item => { - const arr = this.statistics[item.toLowerCase()] - if (Array.isArray(arr)) { - pushIfNotExist(arr, col.key) - } - }) - } - _innerColumns.push(col) - } - }) - } - // 判断是否开启了序号 - if (rowNumber) { - let col = { type: 'seq', title: '#', width: 60, fixed: 'left', align: 'center' } - if (seqColumn) { - col = Object.assign(col, seqColumn, { type: 'seq' }) - } - _innerColumns.unshift(col) - } - // 判断是否开启了可选择行 - if (rowSelection) { - let width = 40 - if (this.statistics.has && !rowExpand && !dragSort) { - width = 60 - } - let col = { type: this.rowSelectionType, width, fixed: 'left', align: 'center' } - // radio - if (this.rowSelectionType === 'radio' && radioColumn) { - col = Object.assign(col, radioColumn, { type: 'radio' }) - } - // checkbox - if (this.rowSelectionType === 'checkbox' && checkboxColumn) { - col = Object.assign(col, checkboxColumn, { type: 'checkbox' }) - } - _innerColumns.unshift(col) - } - // 是否可展开行 - if (rowExpand) { - let width = 40 - if (this.statistics.has && !dragSort) { - width = 60 - } - let col = { type: 'expand', title: '', width, fixed: 'left', align: 'center', slots: { content: 'expandContent' } } - if (expandColumn) { - col = Object.assign(col, expandColumn, { type: 'expand' }) - } - _innerColumns.unshift(col) - } - // 是否可拖动排序 - if (dragSort) { - let width = 40 - if (this.statistics.has) { - width = 60 - } - 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 }) - } - _innerColumns.unshift(col) - } - - this._innerColumns = _innerColumns - this._innerEditRules = _innerEditRules - } - }, - // watch linkageConfig - // 整理多级联动配置 - linkageConfig: { - immediate: true, - handler () { - if (Array.isArray(this.linkageConfig) && this.linkageConfig.length > 0) { - // 获取联动的key顺序 - const getLcKeys = (key, arr) => { - const col = this._innerColumns.find(col => col.key === key) - if (col) { - arr.push(col.key) - if (col.linkageKey) { - return getLcKeys(col.linkageKey, arr) - } - } - return arr - } - const configMap = new Map() - this.linkageConfig.forEach(lc => { - const keys = getLcKeys(lc.key, []) - // 多个key共享一个,引用地址 - const configItem = { - ...lc, - keys, - optionsMap: new Map() - } - keys.forEach(k => configMap.set(k, configItem)) - }) - this._innerLinkageConfig = configMap - } else { - this._innerLinkageConfig = null - } - } - } - }, - created () { - }, - mounted () { - this.handleTabsChange() - }, - methods: { - - /** - * 自动判断父级是否是 组件,然后添加事件监听,自动重置表格 - */ - handleTabsChange () { - // 获取父级 - const tabs = getVmParentByName(this, 'ATabs') - const tabPane = getVmParentByName(this, 'ATabPane') - if (tabs && tabPane) { - // 用户自定义的 key - const currentKey = tabPane.$vnode.key - // 添加 activeKey 监听 - const unwatch = tabs.$children[0].$watch('$data._activeKey', async (key) => { - // 切换到自己时重新计算 - if (currentKey === key) { - await this.$nextTick() - await this.refreshScroll() - await this.recalculate() - } - }) - // 当前实例销毁时取消监听 - this.$on('beforeDestroy', () => unwatch()) - } - }, - - handleVxeScroll (event) { - const { $refs, scroll } = this - - // 记录滚动条的位置 - scroll.top = event.scrollTop - scroll.left = event.scrollLeft - if ($refs.subPopover) { - $refs.subPopover.close() - } - this.scrolling = true - this.closeScrolling() - }, - // 当手动勾选单选时触发的事件 - handleVxeRadioChange (event) { - const row = event.$table.getRadioRecord() - this.selectedRows = row ? [row] : [] - this.handleSelectChange('radio', this.selectedRows, event) - }, - // 当手动勾选全选时触发的事件 - handleVxeCheckboxAll (event) { - this.selectedRows = event.$table.getCheckboxRecords() - this.handleSelectChange('checkbox-all', this.selectedRows, event) - }, - // 当手动勾选并且值发生改变时触发的事件 - handleVxeCheckboxChange (event) { - this.selectedRows = event.$table.getCheckboxRecords() - this.handleSelectChange('checkbox', this.selectedRows, event) - }, - // 行选择change事件 - handleSelectChange (type, selectedRows, $event) { - let action - if (type === 'radio') { - action = 'selected' - } else if (type === 'checkbox') { - action = selectedRows.includes($event.row) ? 'selected' : 'unselected' - } else { - action = 'selected-all' - } - - this.selectedRowIds = selectedRows.map(row => row.id) - this.trigger('selectRowChange', { - type: type, - action: action, - $event: $event, - row: $event.row, - selectedRows: this.selectedRows, - selectedRowIds: this.selectedRowIds - }) - }, - - // 点击单元格时触发的事件 - handleCellClick (event) { - const { row, column, $event, $table } = event - const { $refs } = this - - // 点击了可编辑的 - if (column.editRender) { - if ($refs.subPopover) { - $refs.subPopover.close() - } - return - } - - // 显示详细信息 - if (column.params && column.params.showDetails) { - // 两个如果同时存在的话会出现死循环 - if ($refs.subPopover) { - $refs.subPopover.close() - } - if ($refs.detailsModal) { - $refs.detailsModal.open(event) - } - } else if ($refs.subPopover) { - $refs.subPopover.toggle(event) - } else if (this.clickSelectRow) { - let className = $event.target.className || '' - className = typeof className === 'string' ? className : className.toString() - // 点击的是expand,不做处理 - if (className.includes('vxe-table--expand-btn')) { - return - } - // 点击的是checkbox,不做处理 - if (className.includes('vxe-checkbox--icon') || className.includes('vxe-cell--checkbox')) { - return - } - // 点击的是radio,不做处理 - if (className.includes('vxe-radio--icon') || className.includes('vxe-cell--radio')) { - return - } - if (this.rowSelectionType === 'radio') { - $table.setRadioRow(row) - this.handleVxeRadioChange(event) - } else { - $table.toggleCheckboxRow(row) - this.handleVxeCheckboxChange(event) - } - } - }, - - // 单元格编辑状态下被关闭时会触发该事件 - handleEditClosed ({ column }) { - // 执行增强 - getEnhancedMixins(column.params.type, 'aopEvents').editClosed.apply(this, arguments) - }, - - // 单元格被激活编辑时会触发该事件 - handleEditActived ({ column }) { - // 执行增强 - if (column.params && column.params.type) { - getEnhancedMixins(column.params.type, 'aopEvents').editActived.apply(this, arguments) - } - }, - - /** 表尾数据处理方法,用于显示统计信息 */ - handleFooterMethod ({ columns, data }) { - const { statistics } = this - const footers = [] - if (statistics.has) { - if (statistics.sum.length > 0) { - footers.push(this.getFooterStatisticsMap({ - columns: columns, - title: '合计', - checks: statistics.sum, - method: (column) => XEUtils.sum(data, column.property) - })) - } - if (statistics.average.length > 0) { - footers.push(this.getFooterStatisticsMap({ - columns: columns, - title: '平均', - checks: statistics.average, - method: (column) => XEUtils.mean(data, column.property) - })) - } - } - return footers - }, - - getFooterStatisticsMap ({ columns, title, checks, method }) { - return columns.map((column, columnIndex) => { - if (columnIndex === 0) { - return title - } - if (checks.includes(column.property)) { - return method(column, columnIndex) - } - return null - }) - }, - - /** 表尾单元格合并方法 */ - handleFooterSpanMethod (event) { - if (event.columnIndex === 0) { - return { colspan: 2 } - } - }, - - /* --- 外部可调用接口方法 --- */ - - /** - * 重置滚动条Top位置 - * @param top 新top位置,留空则滚动到上次记录的位置,用于解决切换tab选项卡时导致白屏以及自动将滚动条滚动到顶部的问题 - */ - resetScrollTop (top) { - this.scrollTo(null, (top == null || top === '') ? this.scroll.top : top) - }, - - /** - * 加载新数据,和 loadData 不同的是,用该方法加载的数据都是相当于点新增按钮新增的数据。 - * 适用于不是数据库里查出来的没有id的临时数据 - * @param dataSource - */ - async loadNewData (dataSource) { - if (Array.isArray(dataSource)) { - const { xTable } = this.$refs.vxe.$refs - // issues/2784 - // 先清空所有数据 - xTable.loadData([]) - - dataSource.forEach((data, idx) => { - // 开启了排序就自动计算排序值 - if (this.dragSort) { - this.$set(data, this.dragSortKey, idx + 1) - } - // 处理联动回显数据 - if (this._innerLinkageConfig != null) { - for (const configItem of this._innerLinkageConfig.values()) { - this.autoSetLinkageOptionsByData(data, '', configItem, 0) - } - } - }) - // 再新增 - return xTable.insertAt(dataSource) - } - return [] - }, - - // 校验table,失败返回errMap,成功返回null - async validateTable () { - const errMap = await this.validate().catch(errMap => errMap) - return errMap || null - }, - // 完整校验 - async fullValidateTable () { - const errMap = await this.fullValidate().catch(errMap => errMap) - return errMap || null - }, - - /** 设置某行某列的值 */ - setValues (values) { - if (!Array.isArray(values)) { - console.warn(`JVxeTable.setValues:必须传递数组`) - return - } - values.forEach((item) => { - const { rowKey, values: record } = item - const { row } = this.getIfRowById(rowKey) - if (!row) { - return - } - Object.keys(record).forEach(colKey => { - const column = this.getColumnByKey(colKey) - if (column) { - const oldValue = row[colKey] - const newValue = record[colKey] - if (newValue !== oldValue) { - this.$set(row, colKey, newValue) - // 触发 valueChange 事件 - this.trigger('valueChange', { - type: column.params.type, - value: newValue, - oldValue: oldValue, - col: column.params, - column: column, - isSetValues: true - }) - } - } else { - console.warn(`JVxeTable.setValues:没有找到key为"${colKey}"的列`) - } - }) - }) - }, - - /** 获取所有的数据,包括values、deleteIds */ - getAll () { - return { - tableData: this.getTableData(), - deleteData: this.getDeleteData() - } - }, - /** 获取表格表单里的值 */ - getValues (callback, rowIds) { - const tableData = this.getTableData({ rowIds: rowIds }) - const msg = '' - callback(msg, tableData) - }, - /** 获取表格数据 */ - getTableData (options = {}) { - const { rowIds } = options - let tableData - // 仅查询指定id的行 - if (Array.isArray(rowIds) && rowIds.length > 0) { - tableData = [] - rowIds.forEach(rowId => { - const { row } = this.getIfRowById(rowId) - if (row) { - tableData.push(row) - } - }) - } else { - // 查询所有行 - tableData = this.$refs.vxe.getTableData().fullData - } - return this.filterNewRows(tableData, false) - }, - /** 仅获取新增的数据 */ - getNewData () { - const newData = cloneObject(this.$refs.vxe.getInsertRecords()) - newData.forEach(row => delete row.id) - return newData - }, - /** 仅获取新增的数据,带有id */ - getNewDataWithId () { - return cloneObject(this.$refs.vxe.getInsertRecords()) - }, - /** 根据ID获取行,新增的行也能查出来 */ - getIfRowById (id) { - let row = this.getRowById(id) - let isNew = false - if (!row) { - row = this.getNewRowById(id) - if (!row) { - console.warn(`JVxeTable.getIfRowById:没有找到id为"${id}"的行`) - return { row: null } - } - isNew = true - } - return { row, isNew } - }, - /** 通过临时ID获取新增的行 */ - getNewRowById (id) { - const records = this.getInsertRecords() - for (const record of records) { - if (record.id === id) { - return record - } - } - return null - }, - /** 仅获取被删除的数据(新增又被删除的数据不会被获取到) */ - getDeleteData () { - return cloneObject(this.$refs.vxe.getRemoveRecords()) - }, - /** - * 添加一行或多行 - * - * @param rows - * @param isOnlJs 是否是onlineJS增强触发的 - * @return - */ - async addRows (rows = {}, isOnlJs) { - return this._addOrInsert(rows, -1, 'added', isOnlJs) - }, - - /** - * 添加一行或多行 - * - * @param rows - * @param index 添加下标,数字,必填 - * @return - */ - async insertRows (rows, index) { - if (typeof index !== 'number' || index < 0) { - console.warn(`【JVXETable】insertRows:index必须传递数字,且大于-1`) - return - } - return this._addOrInsert(rows, index, 'inserted') - }, - /** - * 添加一行或多行临时数据,不会填充默认值,传什么就添加进去什么 - * @param rows - * @param options 选项 - * @param options.setActive 是否激活最后一行的编辑模式 - */ - async pushRows (rows = {}, options = {}) { - const { xTable } = this.$refs.vxe.$refs - let { setActive, index } = options - setActive = setActive == null ? false : !!setActive - index = index == null ? -1 : index - index = index === -1 ? index : xTable.tableFullData[index] - // 插入行 - const result = await xTable.insertAt(rows, index) - if (setActive) { - // 激活最后一行的编辑模式 - xTable.setActiveRow(result.rows[result.rows.length - 1]) - } - await this._recalcSortNumber() - return result - }, - - /** 清空选择行 */ - clearSelection () { - const event = { $table: this.$refs.vxe, target: this } - if (this.rowSelectionType === JVXETypes.rowRadio) { - this.$refs.vxe.clearRadioRow() - this.handleVxeRadioChange(event) - } else { - this.$refs.vxe.clearCheckboxRow() - this.handleVxeCheckboxChange(event) - } - }, - - /** 删除一行或多行数据 */ - async removeRows (rows) { - const res = await this._remove(rows) - await this._recalcSortNumber() - return res - }, - - /** 根据id删除一行或多行 */ - removeRowsById (rowId) { - let rowIds - if (Array.isArray(rowId)) { - rowIds = rowId - } else { - rowIds = [rowId] - } - const rows = rowIds.map((id) => { - const { row } = this.getIfRowById(id) - if (!row) { - return - } - if (row) { - return row - } else { - console.warn(`【JVXETable】removeRowsById:${id}不存在`) - return null - } - }).filter((row) => row != null) - return this.removeRows(rows) - }, - - getColumnByKey () { - return this.$refs.vxe.getColumnByField.apply(this.$refs.vxe, arguments) - }, - - /* --- 辅助方法 --- */ - - // 触发事件 - trigger (name, event = {}) { - event.$target = this - event.$table = this.$refs.vxe - // online增强参数兼容 - event.target = this - this.$emit(name, event) - }, - - /** 【多级联动】获取同级联动下拉选项 */ - getLinkageOptionsSibling (row, col, config, request) { - // 如果当前列不是顶级列 - let key = '' - if (col.key !== config.key) { - // 就找出联动上级列 - const idx = config.keys.findIndex(k => col.key === k) - const parentKey = config.keys[idx - 1] - key = row[parentKey] - // 如果联动上级列没有选择数据,就直接返回空数组 - if (key === '' || key == null) { - return [] - } - } else { - key = 'root' - } - let options = config.optionsMap.get(key) - if (!Array.isArray(options)) { - if (request) { - const parent = key === 'root' ? '' : key - return this.getLinkageOptionsAsync(config, parent) - } else { - options = [] - } - } - return options - }, - /** 【多级联动】获取联动下拉选项(异步) */ - getLinkageOptionsAsync (config, parent) { - return new Promise(resolve => { - const key = parent || 'root' - let options - if (config.optionsMap.has(key)) { - options = config.optionsMap.get(key) - if (options instanceof Promise) { - options.then(opt => { - config.optionsMap.set(key, opt) - resolve(opt) - }) - } else { - resolve(options) - } - } else if (typeof config.requestData === 'function') { - // 调用requestData方法,通过传入parent来获取子级 - const promise = config.requestData(parent) - config.optionsMap.set(key, promise) - promise.then(opt => { - config.optionsMap.set(key, opt) - resolve(opt) - }) - } else { - resolve([]) - } - }) - }, - // 【多级联动】 用于回显数据,自动填充 optionsMap - autoSetLinkageOptionsByData (data, parent, config, level) { - if (level === 0) { - this.getLinkageOptionsAsync(config, '') - } else { - this.getLinkageOptionsAsync(config, parent) - } - if (config.keys.length - 1 > level) { - const value = data[config.keys[level]] - if (value) { - this.autoSetLinkageOptionsByData(data, value, config, level + 1) - } - } - }, - // 【多级联动】联动组件change时,清空下级组件 - linkageSelectChange (row, col, config, value) { - if (col.linkageKey) { - this.getLinkageOptionsAsync(config, value) - const idx = config.keys.findIndex(k => k === col.key) - const values = {} - for (let i = idx; i < config.keys.length; i++) { - values[config.keys[i]] = '' - } - // 清空后几列的数据 - this.setValues([{ rowKey: row.id, values }]) - } - }, - - /** 加载数据字典并合并到 options */ - _loadDictConcatToOptions (column, columnIndex) { - initDictOptions(column.dictCode).then((res) => { - if (res.success) { - const newOptions = (column.options || [])// .concat(res.result) - res.result.forEach(item => { - // 过滤重复数据 - for (const option of newOptions) if (option.value === item.value) return - newOptions.push(item) - }) - this.$set(column, 'options', newOptions) - const newParams = Object.assign(column.params, { options: newOptions }) - this.$set(column, 'params', newParams) - this.$set(this._innerColumns, columnIndex, column) - } else { - console.group(`JVxeTable 查询字典(${column.dictCode})发生异常`) - console.warn(res.message) - console.groupEnd() - } - }) - }, - // options自定义赋值 刷新 - virtualRefresh () { - this.scrolling = true - this.closeScrolling() - }, - // 设置 this.scrolling 防抖模式 - closeScrolling: simpleDebounce(function () { - this.scrolling = false - }, 100), - - /** - * 过滤添加的行 - * @param rows 要筛选的行数据 - * @param remove true = 删除新增,false=只删除id - * @param handler function - */ - filterNewRows (rows, remove = true, handler) { - const insertRecords = this.$refs.vxe.getInsertRecords() - const records = [] - for (const row of rows) { - const item = cloneObject(row) - if (insertRecords.includes(row)) { - if (handler) { - handler({ item, row, insertRecords }) - } - if (remove) { - continue - } - delete item.id - } - records.push(item) - } - return records - }, - - // 删除选中的数据 - async removeSelection () { - const res = await this._remove(this.selectedRows) - this.clearSelection() - await this._recalcSortNumber() - return res - }, - - /** - * 【删除指定行数据】(重写vxeTable的内部方法,添加了从keepSource中删除) - * 如果传 row 则删除一行 - * 如果传 rows 则删除多行 - * 如果为空则删除所有 - */ - _remove (rows) { - const xTable = this.$refs.vxe.$refs.xTable - - const { afterFullData, tableFullData, tableSourceData, editStore, treeConfig, checkboxOpts, selection, isInsertByRow, scrollYLoad } = xTable - const { actived, removeList, insertList } = editStore - const { checkField: property } = checkboxOpts - let rest = [] - const nowData = afterFullData - if (treeConfig) { - throw new Error(UtilTools.getLog('vxe.error.noTree', ['remove'])) - } - if (!rows) { - rows = tableFullData - } else if (!XEUtils.isArray(rows)) { - rows = [rows] - } - // 如果是新增,则保存记录 - rows.forEach(row => { - if (!isInsertByRow(row)) { - removeList.push(row) - } - }) - // 如果绑定了多选属性,则更新状态 - if (!property) { - XEUtils.remove(selection, row => rows.indexOf(row) > -1) - } - // 从数据源中移除 - if (tableFullData === rows) { - rows = rest = tableFullData.slice(0) - tableFullData.length = 0 - nowData.length = 0 - } else { - rest = XEUtils.remove(tableFullData, row => rows.indexOf(row) > -1) - XEUtils.remove(nowData, row => rows.indexOf(row) > -1) - } - // 【从keepSource中删除】 - if (xTable.keepSource) { - const rowIdSet = new Set(rows.map(row => row.id)) - XEUtils.remove(tableSourceData, row => rowIdSet.has(row.id)) - } - - // 如果当前行被激活编辑,则清除激活状态 - if (actived.row && rows.indexOf(actived.row) > -1) { - xTable.clearActived() - } - // 从新增中移除已删除的数据 - XEUtils.remove(insertList, row => rows.indexOf(row) > -1) - xTable.handleTableData() - xTable.updateFooter() - xTable.updateCache && xTable.updateCache() - xTable.checkSelectionStatus() - if (scrollYLoad) { - xTable.updateScrollYSpace() - } - return xTable.$nextTick().then(() => { - xTable.recalculate() - return { row: rest.length ? rest[rest.length - 1] : null, rows: rest } - }) - }, - - /** 行重新排序 */ - async rowResort (oldIndex, newIndex) { - const xTable = this.$refs.vxe.$refs.xTable - window.xTable = xTable - const sort = (array) => { - // 存储旧数据,并删除旧项目 - const row = array.splice(oldIndex, 1)[0] - // 向新项目里添加旧数据 - array.splice(newIndex, 0, row) - } - sort(xTable.tableFullData) - if (xTable.keepSource) { - sort(xTable.tableSourceData) - } - await this.$nextTick() - await this._recalcSortNumber() - }, - - /** 重新计算排序字段的数值 */ - async _recalcSortNumber () { - const xTable = this.$refs.vxe.$refs.xTable - if (this.dragSort) { - xTable.tableFullData.forEach((data, idx) => { - data[this.dragSortKey] = (idx + 1) - }) - } - if (xTable.updateCache) { - await xTable.updateCache(true) - } - return await xTable.updateData() - }, - - async _addOrInsert (rows = {}, index, triggerName, isOnlJs) { - const { xTable } = this.$refs.vxe.$refs - let records - if (Array.isArray(rows)) { - records = rows - } else { - records = [rows] - } - // 遍历添加默认值 - records.forEach(record => this._createRow(record)) - const result = await this.pushRows(records, { index: index, setActive: true }) - // 遍历插入的行 - // update--begin--autor:lvdandan-----date:20201117------for:LOWCOD-987 【新行编辑】js增强附表内置方法调用问题 #1819 - // online js增强时以传过来值为准,不再赋默认值 - if (isOnlJs !== true) { - for (let i = 0; i < result.rows.length; i++) { - const row = result.rows[i] - this.trigger(triggerName, { - row: row, - $table: xTable, - target: this - }) - } - } - // update--end--autor:lvdandan-----date:20201117------for:LOWCOD-987 【新行编辑】js增强附表内置方法调用问题 #1819 - return result - }, - // 创建新行,自动添加默认值 - _createRow (record = {}) { - const { xTable } = this.$refs.vxe.$refs - // 添加默认值 - xTable.tableFullColumn.forEach(column => { - const col = column.params || {} - if (col.key && (record[col.key] == null || record[col.key] === '')) { - // 设置默认值 - const createValue = getEnhancedMixins(col.$type || col.type, 'createValue') - record[col.key] = createValue({ row: record, column, $table: xTable }) - } - // update-begin--author:sunjianlei---date:20210819------for: 处理联动列,联动列只能作用于 select 组件 - if (col.$type === JVXETypes.select && this._innerLinkageConfig != null) { - // 判断当前列是否是联动列 - if (this._innerLinkageConfig.has(col.key)) { - const configItem = this._innerLinkageConfig.get(col.key) - this.getLinkageOptionsAsync(configItem, '') - } - } - // update-end--author:sunjianlei---date:20210819------for: 处理联动列,联动列只能作用于 select 组件 - }) - return record - }, - - /* --- 渲染函数 --- */ - - // 渲染 vxe - renderVxeGrid (h) { - return h('vxe-grid', { - ref: 'vxe', - class: ['j-vxe-table'], - props: this.vxeProps, - on: this.vxeEvents, - // 作用域插槽的格式为 - scopedSlots: this.$scopedSlots - }) - }, - // 渲染工具栏 - renderToolbar (h) { - if (this.toolbar) { - return h('j-vxe-toolbar', { - props: { - toolbarConfig: this.toolbarConfig, - excludeCode: this.excludeCode, - size: this.size, - disabled: this.disabled, - disabledRows: this.disabledRows, - selectedRowIds: this.selectedRowIds - }, - on: { - // 新增事件 - add: () => this.addRows(), - // 保存事件 - save: () => this.trigger('save', { - $table: this.$refs.vxe, - target: this - }), - // 删除事件 - remove: () => { - const $table = this.$refs.vxe - const deleteRows = this.filterNewRows(this.selectedRows) - // 触发删除事件 - if (deleteRows.length > 0) { - const removeEvent = { deleteRows, $table, target: this } - if (this.asyncRemove) { - // 确认删除,只有调用这个方法才会真删除 - removeEvent.confirmRemove = () => this.removeSelection() - } else { - this.removeSelection() - } - this.trigger('remove', removeEvent) - } else { - this.removeSelection() - } - }, - // 清除选择事件 - clearSelection: this.clearSelection - }, - scopedSlots: { - toolbarPrefix: this.$scopedSlots.toolbarPrefix, - toolbarSuffix: this.$scopedSlots.toolbarSuffix - } - }) - } - return null - }, - // 渲染 toolbarAfter 插槽 - renderToolbarAfterSlot () { - if (this.$scopedSlots.toolbarAfter) { - return this.$scopedSlots.toolbarAfter() - } - return null - }, - // 渲染点击时弹出的子表 - renderSubPopover (h) { - if (this.clickRowShowSubForm && this.$scopedSlots.subForm) { - return h('j-vxe-sub-popover', { - ref: 'subPopover', - scopedSlots: { - subForm: this.$scopedSlots.subForm - } - }) - } - return null - }, - // 渲染点击时弹出的详细信息 - renderDetailsModal (h) { - if (this.clickRowShowMainForm && this.$scopedSlots.mainForm) { - return h('j-vxe-details-modal', { - ref: 'detailsModal', - scopedSlots: { - subForm: this.clickRowShowSubForm ? this.$scopedSlots.subForm : null, - mainForm: this.$scopedSlots.mainForm - } - }) - } - }, - // 渲染分页器 - renderPagination (h) { - if (this.pagination && Object.keys(this.pagination).length > 0) { - return h('j-vxe-pagination', { - props: { - size: this.size, - disabled: this.disabled, - pagination: this.pagination - }, - on: { - change: (e) => this.trigger('pageChange', e) - } - }) - } - return null - }, - loadExcludeCode () { - if (!this.authPre || this.authPre.length === 0) { - this.excludeCode = [] - } else { - let pre = this.authPre - if (!pre.endsWith(':')) { - pre += ':' - } - this.excludeCode = getNoAuthCols(pre) - } - } - - }, - render (h) { - return h('div', { - class: ['j-vxe-table-box', `size--${this.size}`] - }, [ - this.renderSubPopover(h), - this.renderDetailsModal(h), - this.renderToolbar(h), - this.renderToolbarAfterSlot(), - this.renderVxeGrid(h), - this.renderPagination(h) - ]) - }, - beforeDestroy () { - this.$emit('beforeDestroy') - } -} - -// 兼容 online 的规则 -const fooPatterns = [ - { title: '非空', value: '*', pattern: /^.+$/ }, - { 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: 'e', pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/ }, - { title: '手机号码', value: 'm', pattern: /^1[3456789]\d{9}$/ }, - { title: '邮政编码', value: 'p', pattern: /^[1-9]\d{5}$/ }, - { 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,2}))$/ } -] - -/** 旧版handler转为新版Validator */ -function handlerConvertToValidator (event) { - const { column, rule } = event - return new Promise((resolve, reject) => { - rule.handler(event, (flag, msg) => { - let message = rule.message - if (typeof msg === 'string') { - message = replaceProps(column.params, msg) - } - if (flag == null) { - resolve(message) - } else if (flag) { - resolve(message) - } else { - reject(new Error(message)) - } - }, this, event) - }) -} - -/** 唯一校验器 */ -function uniqueValidator (event) { - const { cellValue, column, rule } = event - const tableData = this.getTableData() - let findCount = 0 - for (const rowData of tableData) { - if (rowData[column.params.key] === cellValue) { - if (++findCount >= 2) { - return Promise.reject(new Error(rule.message)) - } - } - } - return Promise.resolve() -} diff --git a/src/components/jero/JVxeTable/components/JVxeToolbar.vue b/src/components/jero/JVxeTable/components/JVxeToolbar.vue deleted file mode 100644 index 6c501bd3..00000000 --- a/src/components/jero/JVxeTable/components/JVxeToolbar.vue +++ /dev/null @@ -1,127 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeCheckboxCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeCheckboxCell.vue deleted file mode 100644 index 56ded30d..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeCheckboxCell.vue +++ /dev/null @@ -1,103 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeDateCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeDateCell.vue deleted file mode 100644 index 14f4392b..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeDateCell.vue +++ /dev/null @@ -1,68 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeDepartSelectCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeDepartSelectCell.vue deleted file mode 100644 index 26eb5bdd..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeDepartSelectCell.vue +++ /dev/null @@ -1,128 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeDragSortCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeDragSortCell.vue deleted file mode 100644 index c49ce432..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeDragSortCell.vue +++ /dev/null @@ -1,138 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeInputCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeInputCell.vue deleted file mode 100644 index 623ba02b..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeInputCell.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeNormalCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeNormalCell.vue deleted file mode 100644 index 630f64c9..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeNormalCell.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeProgressCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeProgressCell.vue deleted file mode 100644 index be963e9c..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeProgressCell.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeSelectCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeSelectCell.vue deleted file mode 100644 index a3dbead2..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeSelectCell.vue +++ /dev/null @@ -1,219 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeSlotCell.js b/src/components/jero/JVxeTable/components/cells/JVxeSlotCell.js deleted file mode 100644 index 61317c3d..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeSlotCell.js +++ /dev/null @@ -1,46 +0,0 @@ -import JVxeCellMixins from '@/components/jero/JVxeTable/mixins/JVxeCellMixins' - -// 插槽 -export default { - name: 'JVxeSlotCell', - mixins: [JVxeCellMixins], - computed: { - slotProps () { - return { - value: this.innerValue, - row: this.row, - column: this.originColumn, - - params: this.params, - $table: this.params.$table, - rowId: this.params.rowid, - index: this.params.rowIndex, - rowIndex: this.params.rowIndex, - columnIndex: this.params.columnIndex, - - target: this.renderOptions.target, - caseId: this.renderOptions.target.caseId, - scrolling: this.renderOptions.scrolling, - reloadEffect: this.renderOptions.reloadEffect, - - triggerChange: (v) => this.handleChangeCommon(v) - } - } - }, - render (h) { - const { slot } = this.renderOptions - if (slot) { - return h('div', {}, slot(this.slotProps)) - } else { - return h('div') - } - }, - // 【组件增强】注释详见:JVxeCellMixins.js - enhanced: { - switches: { - editRender: false - } - } -} - -// :isNotPass="notPassedIds.includes(col.key+row.id)" diff --git a/src/components/jero/JVxeTable/components/cells/JVxeTagsCell.js b/src/components/jero/JVxeTable/components/cells/JVxeTagsCell.js deleted file mode 100644 index ce9f098f..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeTagsCell.js +++ /dev/null @@ -1,145 +0,0 @@ -import JVxeCellMixins from '@/components/jero/JVxeTable/mixins/JVxeCellMixins' - -// tags 组件的显示组件 -export const TagsSpanCell = { - name: 'JVxeTagsCell', - mixins: [JVxeCellMixins], - data () { - return { - innerTags: [] - } - }, - watch: { - innerValue: { - immediate: true, - handler (value) { - if (value !== this.innerTags.join(';')) { - const rv = replaceValue(value) - this.innerTags = rv.split(';') - this.handleChangeCommon(rv) - } - } - } - }, - methods: { - renderTags (h) { - const tags = [] - for (const tag of this.innerTags) { - if (tag) { - const tagProps = {} - const tagStyle = {} - const setTagColor = this.originColumn.setTagColor - if (typeof setTagColor === 'function') { - /** - * 设置 tag 颜色 - * - * @param event 包含的字段: - * event.tagValue 当前tag的值 - * event.value 当前原始值 - * event.row 当前行的所有值 - * event.column 当前列的配置 - * event.column.own 当前列的原始配置 - * @return Array | String 可以返回一个数组,数据第一项是tag背景颜色,第二项是字体颜色。也可以返回一个字符串,即tag背景颜色 - */ - const color = setTagColor({ - tagValue: tag, - value: this.innerValue, - row: this.row, - column: this.column - }) - if (Array.isArray(color)) { - tagProps.color = color[0] - tagStyle.color = color[1] - } else if (color && typeof color === 'string') { - tagProps.color = color - } - } - tags.push(h('a-tag', { - props: tagProps, - style: tagStyle - }, [tag])) - } - } - return tags - } - }, - render (h) { - return h('div', {}, [ - this.renderTags(h) - ]) - } -} - -// tags 组件的输入框 -export const TagsInputCell = { - name: 'JVxeTagsInputCell', - mixins: [JVxeCellMixins], - data () { - return { - innerTagValue: '' - } - }, - watch: { - innerValue: { - immediate: true, - handler (value) { - if (value !== this.innerTagValue) { - this.handleInputChange(value) - } - } - } - }, - methods: { - - handleInputChange (value, event) { - this.innerTagValue = replaceValue(value, event) - this.handleChangeCommon(this.innerTagValue) - return this.innerTagValue - } - - }, - render (h) { - return h('a-input', { - props: { - value: this.innerValue, - ...this.cellProps - }, - on: { - change: (event) => { - const { target, target: { value } } = event - const newValue = this.handleInputChange(value, event) - if (newValue !== value) { - target.value = newValue - } - } - } - }) - } -} - -// 将值每隔两位加上一个分号 -function replaceValue (value, event) { - if (value) { - // 首先去掉现有的分号 - value = value.replace(/;/g, '') - // 然后再遍历添加分号 - let rv = '' - const splitArr = value.split('') - let count = 0 - splitArr.forEach((val, index) => { - rv += val - const position = index + 1 - if (position % 2 === 0 && position < splitArr.length) { - count++ - rv += ';' - } - }) - if (event && count > 0) { - const { target, target: { selectionStart } } = event - target.selectionStart = selectionStart + count - target.selectionEnd = selectionStart + count - } - return rv - } - return '' -} diff --git a/src/components/jero/JVxeTable/components/cells/JVxeTextareaCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeTextareaCell.vue deleted file mode 100644 index 939c8beb..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeTextareaCell.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeUploadCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeUploadCell.vue deleted file mode 100644 index 51a01659..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeUploadCell.vue +++ /dev/null @@ -1,190 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/JVxeUserSelectCell.vue b/src/components/jero/JVxeTable/components/cells/JVxeUserSelectCell.vue deleted file mode 100644 index 196d05c2..00000000 --- a/src/components/jero/JVxeTable/components/cells/JVxeUserSelectCell.vue +++ /dev/null @@ -1,129 +0,0 @@ - - - - - diff --git a/src/components/jero/JVxeTable/components/cells/ReloadEffect.js b/src/components/jero/JVxeTable/components/cells/ReloadEffect.js deleted file mode 100644 index 1c1e6402..00000000 --- a/src/components/jero/JVxeTable/components/cells/ReloadEffect.js +++ /dev/null @@ -1,84 +0,0 @@ -import '../../less/reload-effect.less' -import { randomString } from '@/utils/util' - -// 修改数据特效 -export default { - props: { - vNode: null, - // 是否启用特效 - effect: Boolean - }, - data () { - return { - // vNode: null, - innerEffect: false, - // 应付同时多个特效 - effectIdx: 0, - effectList: [] - } - }, - watch: { - vNode: { - deep: true, - immediate: true, - handler (vNode, old) { - this.innerEffect = this.effect - if (this.innerEffect && old != null) { - const topLayer = this.renderSpan(old, 'top') - this.effectList.push(topLayer) - } - } - } - }, - methods: { - - // 条件渲染内容 span - renderVNode () { - if (this.vNode == null) { - return null - } - const bottom = this.renderSpan(this.vNode, 'bottom') - // 启用了特效,并且有旧数据,就渲染特效顶层 - if (this.innerEffect && this.effectList.length > 0) { - this.$emit('effect-begin') - // 1.4s 以后关闭特效 - window.setTimeout(() => { - const item = this.effectList[this.effectIdx] - if (item && item.elm) { - // 特效结束后,展示先把 display 设为 none,而不是直接删掉该元素, - // 目的是为了防止页面重新渲染,导致动画重置 - item.elm.style.display = 'none' - } - // 当所有的层级动画都结束时,再删掉所有元素 - if (++this.effectIdx === this.effectList.length) { - this.innerEffect = false - this.effectIdx = 0 - this.effectList = [] - this.$emit('effect-end') - } - }, 1400) - return [this.effectList, bottom] - } else { - return bottom - } - }, - // 渲染内容 span - renderSpan (vNode, layer) { - const options = { - key: layer + this.effectIdx + randomString(6), - class: ['j-vxe-reload-effect-span', `layer-${layer}`], - style: {} - } - if (layer === 'top') { - // 最新渲染的在下面 - options.style['z-index'] = (9999 - this.effectIdx) - } - return this.$createElement('span', options, [vNode]) - } - }, - render (h) { - return h('div', { - class: ['j-vxe-reload-effect-box'] - }, [this.renderVNode()]) - } -} diff --git a/src/components/jero/JVxeTable/index.js b/src/components/jero/JVxeTable/index.js deleted file mode 100644 index cce161a0..00000000 --- a/src/components/jero/JVxeTable/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import * as jvxeTypes from './jvxeTypes' -import { installCell, mapCell } from './install' -import JVxeTable from './components/JVxeTable' - -import JVxeSlotCell from './components/cells/JVxeSlotCell' -import JVxeNormalCell from './components/cells/JVxeNormalCell' -import JVxeInputCell from './components/cells/JVxeInputCell' -import JVxeDateCell from './components/cells/JVxeDateCell' -import JVxeSelectCell from './components/cells/JVxeSelectCell' -import JVxeCheckboxCell from './components/cells/JVxeCheckboxCell' -import JVxeUploadCell from './components/cells/JVxeUploadCell' -import { TagsInputCell, TagsSpanCell } from './components/cells/JVxeTagsCell' -import JVxeProgressCell from './components/cells/JVxeProgressCell' -import JVxeTextareaCell from './components/cells/JVxeTextareaCell' -import JVxeDragSortCell from './components/cells/JVxeDragSortCell' -import JVxeDepartSelectCell from './components/cells/JVxeDepartSelectCell' -import JVxeUserSelectCell from './components/cells/JVxeUserSelectCell' - -// update--begin--autor:lvdandan-----date:20201216------for:JVxeTable--JVXETypes 【online】代码结构调整,便于online打包 -// 组件类型 -export const JVXETypes = jvxeTypes.JVXETypes -// update--end--autor:lvdandan-----date:20201216------for:JVxeTable--JVXETypes 【online】代码结构调整,便于online打包 - -// 注册自定义组件 -export const AllCells = { - ...mapCell(JVXETypes.normal, JVxeNormalCell), - ...mapCell(JVXETypes.input, JVxeInputCell), - ...mapCell(JVXETypes.inputNumber, JVxeInputCell), - ...mapCell(JVXETypes.checkbox, JVxeCheckboxCell), - ...mapCell(JVXETypes.select, JVxeSelectCell), - ...mapCell(JVXETypes.selectSearch, JVxeSelectCell), // 下拉搜索 - ...mapCell(JVXETypes.selectMultiple, JVxeSelectCell), // 下拉多选 - ...mapCell(JVXETypes.date, JVxeDateCell), - ...mapCell(JVXETypes.datetime, JVxeDateCell), - ...mapCell(JVXETypes.upload, JVxeUploadCell), - ...mapCell(JVXETypes.textarea, JVxeTextareaCell), - - ...mapCell(JVXETypes.tags, TagsInputCell, TagsSpanCell), - ...mapCell(JVXETypes.progress, JVxeProgressCell), - - ...mapCell(JVXETypes.rowDragSort, JVxeDragSortCell), - ...mapCell(JVXETypes.slot, JVxeSlotCell), - ...mapCell(JVXETypes.departSelect, JVxeDepartSelectCell), - ...mapCell(JVXETypes.userSelect, JVxeUserSelectCell) - - /* hidden 是特殊的组件,不在这里注册 */ -} - -export { installCell, mapCell } - -export default JVxeTable diff --git a/src/components/jero/JVxeTable/install.js b/src/components/jero/JVxeTable/install.js deleted file mode 100644 index 36252590..00000000 --- a/src/components/jero/JVxeTable/install.js +++ /dev/null @@ -1,105 +0,0 @@ -import Vue from 'vue' -import { getEventPath, evil } from '@/utils/util' -import JVxeTable, { AllCells, JVXETypes } from './index' -import './less/j-vxe-table.less' -// 引入 vxe-table -import 'xe-utils' -import VXETable, { Grid } from 'vxe-table' -import VXETablePluginAntd from 'vxe-table-plugin-antd' -import 'vxe-table/lib/index.css' -import 'vxe-table-plugin-antd/dist/style.css' -import { getEnhancedMixins, installAllCell, installOneCell } from '@/components/jero/JVxeTable/utils/cellUtils' - -// VxeGrid所有的方法映射 -const VxeGridMethodsMap = {} -Object.keys(Grid.methods).forEach(key => { - // 使用eval可以避免闭包(但是要注意不要写es6的代码) - VxeGridMethodsMap[key] = evil(`(function(){return this.$refs.vxe.${key}.apply(this.$refs.vxe,arguments)})`) -}) -// 将Grid所有的方法都映射(继承)到JVxeTable上 -JVxeTable.methods = Object.assign({}, VxeGridMethodsMap, JVxeTable.methods) - -// VXETable 全局配置 -const VXETableSettings = { - // z-index 起始值 - zIndex: 1000, - table: { - validConfig: { - // 校验提示方式:强制使用tooltip - message: 'tooltip' - } - } -} - -// 执行注册方法 -Vue.use(VXETable, VXETableSettings) -VXETable.use(VXETablePluginAntd) -Vue.component(JVxeTable.name, JVxeTable) - -// 注册自定义组件 -installAllCell(VXETable) - -// 添加事件拦截器 event.clearActived -// 比如点击了某个组件的弹出层面板之后,此时被激活单元格不应该被自动关闭,通过返回 false 可以阻止默认的行为。 -VXETable.interceptor.add('event.clearActived', function (params) { - // 获取组件增强 - const col = params.column.params || {} - const interceptor = getEnhancedMixins(col.$type, 'interceptor') - // 执行增强 - const flag = interceptor['event.clearActived'].apply(this, arguments) - if (flag === false) { - return false - } - // 此处判断一下event是否存在,防止后续内容报错 - const path = params.$event ? getEventPath(params.$event) : [] - for (const p of path) { - let className = p.className || '' - className = typeof className === 'string' ? className : className.toString() - - /* --- 特殊处理以下组件,点击以下标签时不清空编辑状态 --- */ - - // 点击的标签是JInputPop - if (className.includes('j-input-pop')) { - return false - } - // 点击的标签是JPopup的弹出层、部门选择、用户选择 - if (className.includes('j-popup-modal') || className.includes('j-depart-select-modal') || className.includes('j-user-select-modal')) { - return false - } - // 执行增强 - const flag = interceptor['event.clearActived.className'].apply(this, [className, ...arguments]) - if (flag === false) { - return false - } - } -}) - -/** - * 注册map - * @param type 类型 - * @param cell 输入组件 - * @param span 显示组件,可空,默认为 JVxeNormalCell 组件 - */ -export function mapCell (type, cell, span) { - const cells = { [type]: cell } - if (span) { - cells[type + ':span'] = span - } - return cells -} - -/** - * 注册自定义组件 - * - * @param type 类型 - * @param cell 输入组件 - * @param span 显示组件,可空,默认为 JVxeNormalCell 组件 - */ -export function installCell (type, cell, span) { - const exclude = [JVXETypes.rowNumber, JVXETypes.rowCheckbox, JVXETypes.rowRadio, JVXETypes.rowExpand, JVXETypes.rowDragSort] - if (exclude.includes(type)) { - throw new Error(`【installCell】不能使用"${type}"作为组件的type,因为这是关键字。`) - } - Object.assign(AllCells, mapCell(type, cell, span)) - installOneCell(VXETable, type) -} diff --git a/src/components/jero/JVxeTable/jvxeTypes.js b/src/components/jero/JVxeTable/jvxeTypes.js deleted file mode 100644 index 84433aea..00000000 --- a/src/components/jero/JVxeTable/jvxeTypes.js +++ /dev/null @@ -1,43 +0,0 @@ -// 组件类型 -export const JVXETypes = { - // 为了防止和 vxe 内置的类型冲突,所以加上一个前缀 - // 前缀是自动加的,代码中直接用就行(JVXETypes.input) - _prefix: 'j-', - - // 行号列 - rowNumber: 'row-number', - // 选择列 - rowCheckbox: 'row-checkbox', - // 单选列 - rowRadio: 'row-radio', - // 展开列 - rowExpand: 'row-expand', - // 上下排序 - rowDragSort: 'row-drag-sort', - - input: 'input', - inputNumber: 'inputNumber', - textarea: 'textarea', - select: 'select', - date: 'date', - datetime: 'datetime', - checkbox: 'checkbox', - upload: 'upload', - // 下拉搜索 - selectSearch: 'select-search', - // 下拉多选 - selectMultiple: 'select-multiple', - // 进度条 - progress: 'progress', - // 部门选择 - departSelect: 'sel_depart', - // 用户选择 - userSelect: 'sel_user', - - // 拖轮Tags(暂无用) - tags: 'tags', - - slot: 'slot', - normal: 'normal', - hidden: 'hidden' -} diff --git a/src/components/jero/JVxeTable/less/j-vxe-table.less b/src/components/jero/JVxeTable/less/j-vxe-table.less deleted file mode 100644 index 7b834784..00000000 --- a/src/components/jero/JVxeTable/less/j-vxe-table.less +++ /dev/null @@ -1,59 +0,0 @@ -@import "size/tiny"; - -.j-vxe-table-box { - - // 工具栏 - .j-vxe-toolbar { - margin-bottom: 8px; - } - - // 分页器 - .j-vxe-pagination { - margin-top: 8px; - text-align: right; - - .ant-pagination-options-size-changer.ant-select { - margin-right: 0; - } - - &.show-quick-jumper { - .ant-pagination-options-size-changer.ant-select { - margin-right: 8px; - } - } - } - - // 更改 header 底色 - .vxe-table.border--default .vxe-table--header-wrapper, - .vxe-table.border--full .vxe-table--header-wrapper, - .vxe-table.border--outer .vxe-table--header-wrapper { - background-color: #FFFFFF; - } - -} - -// 更改 tooltip 校验失败的颜色 -.vxe-table--tooltip-wrapper.vxe-table--valid-error { - background-color: #f5222d !important; -} - -// 更改 输入框 校验失败的颜色 -.col--valid-error > .vxe-cell > .ant-input, -.col--valid-error > .vxe-cell > .ant-select .ant-input, -.col--valid-error > .vxe-cell > .ant-select .ant-select-selection, -.col--valid-error > .vxe-cell > .ant-input-number, -.col--valid-error > .vxe-cell > .ant-cascader-picker .ant-cascader-input, -.col--valid-error > .vxe-cell > .ant-calendar-picker .ant-calendar-picker-input, -.col--valid-error > .vxe-tree-cell > .ant-input, -.col--valid-error > .vxe-tree-cell > .ant-select .ant-input, -.col--valid-error > .vxe-tree-cell > .ant-select .ant-select-selection, -.col--valid-error > .vxe-tree-cell > .ant-input-number, -.col--valid-error > .vxe-tree-cell > .ant-cascader-picker .ant-cascader-input, -.col--valid-error > .vxe-tree-cell > .ant-calendar-picker .ant-calendar-picker-input { - border-color: #f5222d !important; -} - -// 拖拽排序列样式 -.vxe-table .col--row-drag-sort .vxe-cell { - height: 100%; -} \ No newline at end of file diff --git a/src/components/jero/JVxeTable/less/reload-effect.less b/src/components/jero/JVxeTable/less/reload-effect.less deleted file mode 100644 index c794ea7b..00000000 --- a/src/components/jero/JVxeTable/less/reload-effect.less +++ /dev/null @@ -1,46 +0,0 @@ -.j-vxe-reload-effect-box { - - &, - .j-vxe-reload-effect-span { - display: inline; - height: 100%; - position: relative; - } - - .j-vxe-reload-effect-span { - - &.layer-top { - display: inline-block; - width: 100%; - - position: absolute; - z-index: 2; - background-color: white; - - transform-origin: 0 0; - animation: reload-effect 1.5s forwards; - } - - &.layer-bottom { - z-index: 1; - } - } - - // 定义动画 - @keyframes reload-effect { - 0% { - opacity: 1; - transform: rotateX(0); - } - 10% { - opacity: 1; - } - 90% { - opacity: 0; - } - 100% { - opacity: 0; - transform: rotateX(180deg); - } - } -} \ No newline at end of file diff --git a/src/components/jero/JVxeTable/less/size/tiny.less b/src/components/jero/JVxeTable/less/size/tiny.less deleted file mode 100644 index 5682f2af..00000000 --- a/src/components/jero/JVxeTable/less/size/tiny.less +++ /dev/null @@ -1,332 +0,0 @@ -.j-vxe-table-box { - - @height: 24px; - @lineHeight: 1.5; - @spacing: 4px; - @fontSize: 14px; - @borderRadius: 2px; - - &.size--tiny { - - .vxe-table--header .vxe-cell--checkbox { - position: relative; - top: 2px; - right: 1px; - } - - .vxe-table--body .vxe-cell--checkbox { - line-height: 2; - } - - .vxe-cell { - padding: 0 5px; - font-size: @fontSize; - line-height: @lineHeight; - } - - .vxe-table .vxe-header--column .vxe-cell { - font-size: 12px; - } - - .vxe-body--column.col--actived { - padding: 0; - - .vxe-cell { - padding: 0; - } - - } - - // ant输入框 - .ant-input, - // ant下拉框 - .ant-select-selection { - padding: 2px @spacing; - height: @height; - font-size: @fontSize; - border-radius: @borderRadius; - line-height: @lineHeight; - } - - // 输入框图标对齐 - .ant-input-affix-wrapper { - & .ant-input-prefix { - left: 4px; - } - - & .ant-input:not(:first-child) { - padding-left: 20px; - } - } - - // 按钮 addon - .ant-input-group-addon { - border-color: transparent; - border-radius: @borderRadius; - } - - - // ant下拉多选框 - .ant-select-selection--multiple { - min-height: @height; - - & .ant-select-selection__rendered > ul > li { - height: calc(@height - 6px); - font-size: calc(@fontSize - 2px); - margin-top: 0; - line-height: @lineHeight; - padding: 0 18px 0 4px; - - } - - & .ant-select-selection__clear, - & .ant-select-arrow { - top: 12px; - } - } - - - // ant按钮 - .ant-upload { - width: 100%; - - .ant-btn { - width: 100%; - height: @height; - padding: 0 8px; - font-size: @fontSize; - border-color: transparent; - background-color: transparent; - border-radius: @borderRadius; - - &:hover { - background-color: rgba(255, 255, 255, 0.3); - } - } - } - - .ant-select-selection__rendered { - line-height: @lineHeight; - margin-left: 0; - } - - - // 工具栏 - .j-vxe-toolbar { - margin-bottom: 4px; - - .ant-form-item-label, - .ant-form-item-control { - line-height: 22px; - } - - .ant-form-inline .ant-form-item { - margin-right: 4px; - } - - } - } - - /** 内置属性 */ - - .vxe-table.size--tiny { - & .vxe-table--expanded { - padding-right: 0; - } - - & .vxe-body--expanded-cell { - padding: 8px; - } - } - - .size--tiny .vxe-loading .vxe-loading--spinner { - width: 38px; - height: 38px - } - - .vxe-table.size--tiny .vxe-body--column.col--ellipsis, - .vxe-table.size--tiny .vxe-footer--column.col--ellipsis, - .vxe-table.size--tiny .vxe-header--column.col--ellipsis, - .vxe-table.vxe-editable.size--tiny .vxe-body--column { - height: @height; - } - - .vxe-table.size--tiny { - font-size: 12px - } - - .vxe-table.size--tiny .vxe-table--empty-block, - .vxe-table.size--tiny .vxe-table--empty-placeholder { - min-height: @height; - } - - .vxe-table.size--tiny .vxe-body--column:not(.col--ellipsis), - .vxe-table.size--tiny .vxe-footer--column:not(.col--ellipsis), - .vxe-table.size--tiny .vxe-header--column:not(.col--ellipsis) { - padding: 4px 0 - } - - .vxe-table.size--tiny .vxe-cell .vxe-default-input, - .vxe-table.size--tiny .vxe-cell .vxe-default-select, - .vxe-table.size--tiny .vxe-cell .vxe-default-textarea { - height: @height; - } - - .vxe-table.size--tiny .vxe-cell .vxe-default-input[type=date]::-webkit-inner-spin-button { - margin-top: 1px - } - - .vxe-table.size--tiny.virtual--x .col--ellipsis .vxe-cell, - .vxe-table.size--tiny.virtual--y .col--ellipsis .vxe-cell, - .vxe-table.size--tiny .vxe-body--column.col--ellipsis .vxe-cell, - .vxe-table.size--tiny .vxe-footer--column.col--ellipsis .vxe-cell, - .vxe-table.size--tiny .vxe-header--column.col--ellipsis .vxe-cell { - max-height: @height; - } - - .vxe-table.size--tiny .vxe-cell--checkbox .vxe-checkbox--icon, - .vxe-table.size--tiny .vxe-cell--radio .vxe-radio--icon { - font-size: 14px - } - - - .vxe-table.size--tiny .vxe-table--filter-option > .vxe-checkbox--icon, - .vxe-table.size--small .vxe-table--filter-option > .vxe-checkbox--icon { - font-size: 14px - } - - .vxe-modal--wrapper.size--tiny .vxe-export--panel-column-option > .vxe-checkbox--icon, - .vxe-modal--wrapper.size--small .vxe-export--panel-column-option > .vxe-checkbox--icon { - font-size: 14px - } - - .vxe-grid.size--tiny { - font-size: 12px - } - - .vxe-toolbar.size--tiny { - font-size: 12px; - height: 46px - } - - .vxe-toolbar.size--tiny .vxe-custom--option > .vxe-checkbox--icon { - font-size: 14px - } - - .vxe-pager.size--tiny { - font-size: 12px; - height: @height; - } - - .vxe-checkbox.size--tiny { - font-size: 12px - } - - .vxe-checkbox.size--tiny .vxe-checkbox--icon { - font-size: 14px - } - - .vxe-radio-button.size--tiny .vxe-radio--label { - line-height: 26px - } - - .vxe-radio.size--tiny { - font-size: 12px - } - - .vxe-radio.size--tiny .vxe-radio--icon { - font-size: 14px - } - - .vxe-input.size--tiny { - font-size: 12px; - height: @height; - } - - .vxe-input.size--tiny .vxe-input--inner[type=date]::-webkit-inner-spin-button, - .vxe-input.size--tiny .vxe-input--inner[type=month]::-webkit-inner-spin-button, - .vxe-input.size--tiny .vxe-input--inner[type=week]::-webkit-inner-spin-button { - margin-top: 0 - } - - .vxe-dropdown--panel.size--tiny { - font-size: 12px - } - - .vxe-textarea--autosize.size--tiny, - .vxe-textarea.size--tiny { - font-size: 12px - } - - .vxe-textarea.size--tiny:not(.is--autosize) { - min-height: @height; - } - - .vxe-button.size--tiny { - font-size: 12px - } - - .vxe-button.size--tiny.type--button { - height: @height; - } - - .vxe-button.size--tiny.type--button.is--circle { - min-width: @height; - } - - .vxe-button.size--tiny.type--button.is--round { - border-radius: 14px - } - - .vxe-button.size--tiny .vxe-button--icon, - .vxe-button.size--tiny .vxe-button--loading-icon { - min-width: 12px - } - - .vxe-modal--wrapper.size--tiny { - font-size: 12px - } - - .vxe-form.size--tiny { - font-size: 12px - } - - .vxe-form.size--tiny .vxe-form--item-inner { - min-height: 30px - } - - .vxe-form.size--tiny .vxe-default-input[type=reset], - .vxe-form.size--tiny .vxe-default-input[type=submit] { - line-height: 26px - } - - .vxe-form.size--tiny .vxe-default-input, - .vxe-form.size--tiny .vxe-default-select { - height: @height; - } - - .vxe-select--panel.size--tiny, - .vxe-select.size--tiny { - font-size: 12px - } - - .vxe-select--panel.size--tiny .vxe-optgroup--title, - .vxe-select--panel.size--tiny .vxe-select-option { - height: 24px; - line-height: 24px - } - - .vxe-switch.size--tiny { - font-size: 12px - } - - - .vxe-pulldown--panel.size--tiny, - .vxe-pulldown.size--tiny { - font-size: 12px - } - - -} - - diff --git a/src/components/jero/JVxeTable/mixins/JVxeCellMixins.js b/src/components/jero/JVxeTable/mixins/JVxeCellMixins.js deleted file mode 100644 index ca0251e4..00000000 --- a/src/components/jero/JVxeTable/mixins/JVxeCellMixins.js +++ /dev/null @@ -1,322 +0,0 @@ -import PropTypes from 'ant-design-vue/es/_util/vue-types' -import { filterDictText } from '@/components/dict/JDictSelectUtil' -import { getEnhancedMixins, JVXERenderType, replaceProps } from '@/components/jero/JVxeTable/utils/cellUtils' - -// noinspection JSUnusedLocalSymbols -export default { - inject: { - getParentContainer: { default: () => (node) => node.parentNode } - }, - props: { - value: PropTypes.any, - row: PropTypes.object, - column: PropTypes.object, - // 组件参数 - params: PropTypes.object, - // 渲染选项 - renderOptions: PropTypes.object, - // 渲染类型 - renderType: PropTypes.string.def('default') - }, - data () { - return { - innerValue: null - } - }, - computed: { - caseId () { - return this.renderOptions.caseId - }, - originColumn () { - return this.column.params || {} - }, - $type () { - return this.originColumn.type - }, - rows () { - return this.params.data - }, - fullDataLength () { - return this.params.$table.tableFullData.length - }, - rowIndex () { - return this.params.rowIndex - }, - columnIndex () { - return this.params.columnIndex - }, - cellProps () { - const { originColumn: col, renderOptions } = this - - const props = {} - - // 输入占位符 - props.placeholder = replaceProps(col, col.placeholder) - - // 解析props - if (typeof col.props === 'object') { - Object.keys(col.props).forEach(key => { - props[key] = replaceProps(col, col.props[key]) - }) - } - - // 判断是否是禁用的列 - props.disabled = (typeof col.disabled === 'boolean' ? col.disabled : props.disabled) - - // TODO 判断是否是禁用的行 - // if (props['disabled'] !== true) { - // props['disabled'] = ((this.disabledRowIds || []).indexOf(row.id) !== -1) - // } - - // 判断是否禁用所有组件 - if (renderOptions.disabled === true) { - props.disabled = true - } - - return props - } - }, - watch: { - $type: { - immediate: true, - handler ($type) { - this.enhanced = getEnhancedMixins($type) - this.listeners = getListeners.call(this) - } - }, - value: { - immediate: true, - handler (val) { - let value = val - - // 验证值格式 - const originValue = this.row[this.column.property] - const getValue = this.enhanced.getValue.call(this, originValue) - if (originValue !== getValue) { - // 值格式不正确,重新赋值 - value = getValue - vModel.call(this, value) - } - - this.innerValue = this.enhanced.setValue.call(this, value) - - // 判断是否启用翻译 - if (this.renderType === JVXERenderType.spaner && this.enhanced.translate.enabled) { - const res = this.enhanced.translate.handler.call(this, value) - // 异步翻译,目前仅【多级联动】使用 - if (res instanceof Promise) { - res.then(value => { - this.innerValue = value - }) - } else { - this.innerValue = res - } - } - } - } - }, - created () { - }, - methods: { - - /** 通用处理change事件 */ - handleChangeCommon (value) { - const handle = this.enhanced.getValue.call(this, value) - this.trigger('change', { value: handle }) - // 触发valueChange事件 - this.parentTrigger('valueChange', { - type: this.$type, - value: handle, - oldValue: this.value, - col: this.originColumn, - rowIndex: this.params.rowIndex, - columnIndex: this.params.columnIndex - }) - }, - /** 通用处理blur事件 */ - handleBlurCommon (value) { - this.trigger('blur', { value }) - }, - - /** - * 如果事件存在的话,就触发 - * @param name 事件名 - * @param event 事件参数 - * @param args 其他附带参数 - */ - trigger (name, event, args = []) { - const listener = this.listeners[name] - if (typeof listener === 'function') { - if (typeof event === 'object') { - event = this.packageEvent(name, event) - } - listener(event, ...args) - } - }, - parentTrigger (name, event, args = []) { - args.unshift(this.packageEvent(name, event)) - this.trigger('trigger', name, args) - }, - packageEvent (name, event = {}) { - event.row = this.row - event.column = this.column - // online增强参数兼容 - event.column.key = this.column.property - event.cellTarget = this - if (!event.type) { - event.type = name - } - if (!event.cellType) { - event.cellType = this.$type - } - // 是否校验表单,默认为true - if (typeof event.validate !== 'boolean') { - event.validate = true - } - return event - } - - }, - model: { - prop: 'value', - event: 'change' - }, - /** - * 【自定义增强】用于实现一些增强事件 - * 【注】这里只是定义接口,具体功能需要到各个组件内实现(也有部分功能实现) - * 【注】该属性不是Vue官方属性,是JVxeTable组件自定义的 - * 所以方法内的 this 指向并不是当前组件,而是方法自身, - * 也就是说并不能 this 打点调实例里的任何方法 - */ - enhanced: { - // 注册参数(详见:https://xuliangzhan_admin.gitee.io/vxe-table/#/table/renderer/edit) - installOptions: { - // 自动聚焦的 class 类名 - autofocus: '' - }, - // 事件拦截器(用于兼容) - interceptor: { - // 已实现:event.clearActived - // 说明:比如点击了某个组件的弹出层面板之后,此时被激活单元格不应该被自动关闭,通过返回 false 可以阻止默认的行为。 - 'event.clearActived' (params, event, target) { - return true - }, - // 自定义:event.clearActived.className - // 说明:比原生的多了一个参数:className,用于判断点击的元素的样式名(递归到顶层) - 'event.clearActived.className' (params, event, target) { - return true - } - }, - // 【功能开关】 - switches: { - // 是否使用 editRender 模式(仅当前组件,并非全局) - // 如果设为true,则表头上方会出现一个可编辑的图标 - editRender: true, - // false = 组件触发后可视);true = 组件一直可视 - visible: false - }, - // 【切面增强】切面事件处理,一般在某些方法执行后同步执行 - aopEvents: { - // 单元格被激活编辑时会触发该事件 - editActived () { - }, - // 单元格编辑状态下被关闭时会触发该事件 - editClosed () { - } - }, - // 【翻译增强】可以实现例如select组件保存的value,但是span模式下需要显示成text - translate: { - // 是否启用翻译 - enabled: false, - /** - * 【翻译处理方法】如果handler留空,则使用默认的翻译方法 - * (this指向当前组件) - * - * @param value 需要翻译的值 - * @returns{*} 返回翻译后的数据 - */ - handler (value) { - // 默认翻译方法 - return filterDictText(this.column.own.options, value) - } - }, - /** - * 【获取值增强】组件抛出的值 - * (this指向当前组件) - * - * @param value 保存到数据库里的值 - * @returns{*} 返回处理后的值 - */ - getValue (value) { - return value - }, - /** - * 【设置值增强】设置给组件的值 - * (this指向当前组件) - * - * @param value 组件触发的值 - * @returns{*} 返回处理后的值 - */ - setValue (value) { - return value - }, - /** - * 【新增行增强】在用户点击新增时触发的事件,返回新行的默认值 - * - * @param row 行数据 - * @param column 列配置,.own 是用户配置的参数 - * @param $table vxe 实例 - * @param renderOptions 渲染选项 - * @param params 可以在这里获取 $table - * - * @returns 返回新值 - */ - createValue ({ row, column, $table, renderOptions, params }) { - return (column.params || {}).defaultValue - } - } -} - -function getListeners () { - const listeners = Object.assign({}, (this.renderOptions.listeners || {})) - if (!listeners.change) { - listeners.change = async (event) => { - vModel.call(this, event.value) - await this.$nextTick() - // 处理 change 事件相关逻辑(例如校验) - this.params.$table.updateStatus(this.params) - } - } - return listeners -} - -export function vModel (value, row, property) { - if (!row) { - row = this.row - } - if (!property) { - property = this.column.property - } - this.$set(row, property, value) -} - -/** 模拟触发事件 */ -export function dispatchEvent ({ cell, $event }, className, handler) { - // alwaysEdit 下不模拟触发事件,否者会导致触发两次 - if (this && this.alwaysEdit) { - return - } - window.setTimeout(() => { - const element = cell ? cell.getElementsByClassName(className) : null - if (element && element.length > 0) { - if (typeof handler === 'function') { - handler(element[0]) - } else { - // 模拟触发点击事件 - if ($event) { - element[0].dispatchEvent($event) - } - } - } - }, 10) -} diff --git a/src/components/jero/JVxeTable/mixins/vxe.web.socket.mixins.js b/src/components/jero/JVxeTable/mixins/vxe.web.socket.mixins.js deleted file mode 100644 index 60c32381..00000000 --- a/src/components/jero/JVxeTable/mixins/vxe.web.socket.mixins.js +++ /dev/null @@ -1,264 +0,0 @@ -import store from '@/store/' -import { randomUUID } from '@/utils/util' -// vxe socket -const vs = { - // 页面唯一 id,用于标识同一用户,不同页面的websocket - pageId: randomUUID(), - // webSocket 对象 - ws: null, - // 一些常量 - constants: { - // 消息类型 - TYPE: 'type', - // 消息数据 - DATA: 'data', - // 消息类型:心跳检测 - TYPE_HB: 'heart_beat', - // 消息类型:通用数据传递 - TYPE_CSD: 'common_send_date', - // 消息类型:更新vxe table数据 - TYPE_UVT: 'update_vxe_table' - }, - // 心跳检测 - heartCheck: { - // 间隔时间,间隔多久发送一次心跳消息 - interval: 10000, - // 心跳消息超时时间,心跳消息多久没有回复后重连 - timeout: 6000, - timeoutTimer: null, - clear () { - clearTimeout(this.timeoutTimer) - return this - }, - start () { - vs.sendMessage(vs.constants.TYPE_HB, '') - // 如果超过一定时间还没重置,说明后端主动断开了 - this.timeoutTimer = window.setTimeout(() => { - vs.reconnect() - }, this.timeout) - return this - }, - // 心跳消息返回 - back () { - this.clear() - window.setTimeout(() => this.start(), this.interval) - } - }, - - /** 初始化 WebSocket */ - initialWebSocket () { - if (this.ws === null) { - const userId = store.getters.userInfo.id - const domain = window._CONFIG.domianWebSocketURL.replace('https://', 'wss://').replace('http://', 'ws://') - const url = `${domain}/vxeSocket/${userId}/${this.pageId}` - - this.ws = new WebSocket(url) - this.ws.onopen = this.on.open.bind(this) - this.ws.onerror = this.on.error.bind(this) - this.ws.onmessage = this.on.message.bind(this) - this.ws.onclose = this.on.close.bind(this) - - console.log('this.ws: ', this.ws) - } - }, - - // 发送消息 - sendMessage (type, message) { - try { - const ws = this.ws - if (ws != null && ws.readyState === ws.OPEN) { - ws.send(JSON.stringify({ - type: type, - data: message - })) - } - } catch (err) { - console.warn('【VXEWebSocket】发送消息失败:(' + err.code + ')') - } - }, - - /** 绑定全局VXE表格 */ - tableMap: new Map(), - CSDMap: new Map(), - /** 添加绑定 */ - addBind (map, key, value) { - const binds = map.get(key) - if (Array.isArray(binds)) { - binds.push(value) - } else { - map.set(key, [value]) - } - }, - /** 移除绑定 */ - removeBind (map, key, value) { - const binds = map.get(key) - if (Array.isArray(binds)) { - for (let i = 0; i < binds.length; i++) { - const bind = binds[i] - if (bind === value) { - binds.splice(i, 1) - break - } - } - if (binds.length === 0) { - map.delete(key) - } - } else { - map.delete(key) - } - }, - // 呼叫绑定的表单 - callBind (map, key, callback) { - const binds = map.get(key) - if (Array.isArray(binds)) { - binds.forEach(callback) - } - }, - - lockReconnect: false, - /** 尝试重连 */ - reconnect () { - if (this.lockReconnect) return - this.lockReconnect = true - setTimeout(() => { - if (this.ws && this.ws.close) { - this.ws.close() - } - this.ws = null - console.info('【VXEWebSocket】尝试重连...') - this.initialWebSocket() - this.lockReconnect = false - }, 5000) - }, - - on: { - open () { - console.log('【VXEWebSocket】连接成功') - this.heartCheck.start() - }, - error (e) { - console.warn('【VXEWebSocket】连接发生错误:', e) - this.reconnect() - }, - message (e) { - // 解析消息 - let json - try { - json = JSON.parse(e.data) - } catch (e) { - console.warn('【VXEWebSocket】收到无法解析的消息:', e.data) - return - } - const type = json[this.constants.TYPE] - const data = json[this.constants.DATA] - switch (type) { - // 心跳检测 - case this.constants.TYPE_HB: - this.heartCheck.back() - break - // 通用数据传递 - case this.constants.TYPE_CSD: - this.callBind(this.CSDMap, data.key, (fn) => fn.apply(this, data.args)) - break - // 更新form数据 - case this.constants.TYPE_UVT: - this.callBind(this.tableMap, data.socketKey, (vm) => this.onVM.onUpdateTable.apply(vm, data.args)) - break - default: - console.warn('【VXEWebSocket】收到不识别的消息类型:' + type) - break - } - }, - close (e) { - console.log('【VXEWebSocket】连接被关闭:', e) - this.reconnect() - } - }, - - onVM: { - /** 收到更新表格的消息 */ - onUpdateTable (row, caseId) { - // 判断是不是自己发的消息 - if (this.caseId !== caseId) { - const tableRow = this.getIfRowById(row.id).row - // 局部保更新数据 - if (tableRow) { - // 特殊处理拖轮状态 - if (row.tug_status && tableRow.tug_status) { - row.tug_status = Object.assign({}, tableRow.tug_status, row.tug_status) - } - // 判断是否启用重载特效 - if (this.reloadEffect) { - this.$set(this.reloadEffectRowKeysMap, row.id, true) - } - Object.keys(row).forEach(key => { - if (key !== 'id') { - this.$set(tableRow, key, row[key]) - } - }) - this.$refs.vxe.reloadRow(tableRow) - } - } - } - } - -} - -export default { - props: { - // 是否开启使用 webSocket 无痕刷新 - socketReload: { - type: Boolean, - default: false - }, - socketKey: { - type: String, - default: 'vxe-default' - } - }, - data () { - return {} - }, - mounted () { - if (this.socketReload) { - vs.initialWebSocket() - vs.addBind(vs.tableMap, this.socketKey, this) - } - }, - methods: { - - /** 发送socket消息更新行 */ - socketSendUpdateRow (row) { - vs.sendMessage(vs.constants.TYPE_UVT, { - socketKey: this.socketKey, - args: [row, this.caseId] - }) - } - - }, - beforeDestroy () { - vs.removeBind(vs.tableMap, this.socketKey, this) - } -} - -/** - * 添加WebSocket通用数据传递绑定,相同的key可以添加多个方法绑定 - * @param key 唯一key - * @param fn 当消息来的时候触发的回调方法 - */ -export function addBindSocketCSD (key, fn) { - if (typeof fn === 'function') { - vs.addBind(vs.CSDMap, key, fn) - } -} - -/** - * 移除WebSocket通用数据传递绑定 - * @param key 唯一key - * @param fn 要移除的方法,必须和添加时的方法内存层面上保持一致才可以正确移除 - */ -export function removeBindSocketCSD (key, fn) { - if (typeof fn === 'function') { - vs.removeBind(vs.CSDMap, key, fn) - } -} diff --git a/src/components/jero/JVxeTable/utils/cellUtils.js b/src/components/jero/JVxeTable/utils/cellUtils.js deleted file mode 100644 index 680432ad..00000000 --- a/src/components/jero/JVxeTable/utils/cellUtils.js +++ /dev/null @@ -1,130 +0,0 @@ -import { AllCells, JVXETypes } from '@/components/jero/JVxeTable' -import JVxeCellMixins from '../mixins/JVxeCellMixins' - -export const JVXERenderType = { - editer: 'editer', - spaner: 'spaner', - default: 'default' -} - -/** 安装所有vxe组件 */ -export function installAllCell (VXETable) { - // 遍历所有组件批量注册 - Object.keys(AllCells).forEach(type => installOneCell(VXETable, type)) -} - -/** 安装单个vxe组件 */ -export function installOneCell (VXETable, type) { - const switches = getEnhancedMixins(type, 'switches') - if (switches.editRender === false) { - installCellRender(VXETable, type, AllCells[type]) - } else { - installEditRender(VXETable, type, AllCells[type]) - } -} - -/** 注册可编辑组件 */ -export function installEditRender (VXETable, type, comp, spanComp) { - // 获取当前组件的增强 - const enhanced = getEnhancedMixins(type) - // span 组件 - if (!spanComp && AllCells[type + ':span']) { - spanComp = AllCells[type + ':span'] - } else { - spanComp = AllCells[JVXETypes.normal] - } - // 如果是常显的cell,显示模板和编辑模板都用编辑模板 - const cellRender = enhanced.switches.visible ? createRender(comp, enhanced, JVXERenderType.editer) : createRender(spanComp, enhanced, JVXERenderType.spaner) - // 添加渲染 - VXETable.renderer.add(JVXETypes._prefix + type, { - // 可编辑模板 - renderEdit: createRender(comp, enhanced, JVXERenderType.editer), - // 显示模板 - renderCell: cellRender, - // 增强注册 - ...enhanced.installOptions - }) -} - -/** 注册普通组件 */ -export function installCellRender (VXETable, type, comp = AllCells[JVXETypes.normal]) { - // 获取当前组件的增强 - const enhanced = getEnhancedMixins(type) - VXETable.renderer.add(JVXETypes._prefix + type, { - // 默认显示模板 - renderDefault: createRender(comp, enhanced, JVXERenderType.default), - // 增强注册 - ...enhanced.installOptions - }) -} - -export function createRender (comp, enhanced, renderType) { - return function (h, renderOptions, params) { - return [h(comp, { - props: { - value: params.row[params.column.property], - row: params.row, - column: params.column, - params: params, - renderOptions: renderOptions, - renderType: renderType - } - })] - } -} - -// 已混入的组件增强 -const AllCellsMixins = new Map() - -/** 获取某个组件的增强 */ -export function getEnhanced (type) { - const cell = AllCells[type] - if (cell && cell.enhanced) { - return cell.enhanced - } - return null -} - -/** - * 获取某个组件的增强(混入默认值) - * - * @param type JVXETypes - * @param name 可空,增强名称,留空返回所有增强 - */ -export function getEnhancedMixins (type, name) { - const getByName = (e) => name ? e[name] : e - if (AllCellsMixins.has(type)) { - return getByName(AllCellsMixins.get(type)) - } - const defEnhanced = JVxeCellMixins.enhanced - const enhanced = getEnhanced(type) - if (enhanced) { - Object.keys(defEnhanced).forEach(key => { - const def = defEnhanced[key] - if (Object.prototype.hasOwnProperty.call(enhanced, key)) { - // 方法如果存在就不覆盖 - if (typeof def !== 'function' && typeof def !== 'string') { - enhanced[key] = Object.assign({}, def, enhanced[key]) - } - } else { - enhanced[key] = def - } - }) - AllCellsMixins.set(type, enhanced) - return getByName(enhanced) - } - AllCellsMixins.set(type, defEnhanced) - return getByName(defEnhanced) -} - -/** 辅助方法:替换${...}变量 */ -export function replaceProps (col, value) { - if (value && typeof value === 'string') { - let text = value - text = text.replace(/\${title}/g, col.title) - text = text.replace(/\${key}/g, col.key) - text = text.replace(/\${defaultValue}/g, col.defaultValue) - return text - } - return value -} diff --git a/src/components/jero/JVxeTable/utils/vxeUtils.js b/src/components/jero/JVxeTable/utils/vxeUtils.js deleted file mode 100644 index 63561f77..00000000 --- a/src/components/jero/JVxeTable/utils/vxeUtils.js +++ /dev/null @@ -1,220 +0,0 @@ -import { getVmParentByName } from '@/utils/util' -import { JVXETypes } from '@comp/jero/JVxeTable' - -export const VALIDATE_FAILED = Symbol('') - -/** - * 获取指定的 $refs 对象 - * 有时候可能会遇到组件未挂载到页面中的情况,导致无法获取 $refs 中的某个对象 - * 这个方法可以等待挂载完成之后再返回 $refs 的对象,避免报错 - * @author sunjianlei - **/ -export function getRefPromise (vm, name) { - return new Promise((resolve) => { - (function next () { - const ref = vm.$refs[name] - if (ref) { - resolve(ref) - } else { - setTimeout(() => { - next() - }, 10) - } - })() - }) -} - -/** 获取某一数字输入框列中的最大的值 */ -export function getInputNumberMaxValue (col, rowsValues) { - let maxNum = 0 - Object.values(rowsValues).forEach((rowValue, index) => { - const val = rowValue[col.key]; let num - try { - num = Number.parseFloat(val) - } catch { - num = 0 - } - // 把首次循环的结果当成最大值 - if (index === 0) { - maxNum = num - } else { - maxNum = (num > maxNum) ? num : maxNum - } - }) - return maxNum -} - -/** - * - * 根据 tagName 获取父级节点 - * - * @param dom 一级dom节点 - * @param tagName 标签名,不区分大小写 - * @return {HTMLElement} - */ -export function getParentNodeByTagName (dom, tagName = 'body') { - if (tagName === 'body') { - return document.body - } - if (dom.parentNode) { - if (dom.parentNode.tagName.toLowerCase() === tagName.trim().toLowerCase()) { - return dom.parentNode - } else { - return getParentNodeByTagName(dom.parentNode, tagName) - } - } else { - return null - } -} - -/** - * vxe columns 封装成高级查询可识别的选项 - * @param columns - * @param handler 单独处理方法 - */ -export function vxePackageToSuperQuery (columns, handler) { - if (Array.isArray(columns)) { - // 高级查询所需要的参数 - const fieldList = [] - // 遍历列 - for (let i = 0; i < columns.length; i++) { - const col = columns[i] - if (col.type === JVXETypes.rowCheckbox || - col.type === JVXETypes.rowRadio || - col.type === JVXETypes.rowExpand || - col.type === JVXETypes.rowNumber - ) { - continue - } - const field = { - type: 'string', - value: col.key, - text: col.title, - dictCode: col.dictCode || col.dict - } - if (col.type === JVXETypes.date || col.type === JVXETypes.datetime) { - field.type = col.type - field.format = col.format - } - if (col.type === JVXETypes.inputNumber) { - field.type = 'int' - } - if (Array.isArray(col.options)) { - field.options = col.options - } - if (typeof handler === 'function') { - Object.assign(field, handler(col)) - } - fieldList.push(field) - } - return fieldList - } else { - console.error('columns必须是一个数组') - } - return null -} - -/** - * 一次性验证主表单和所有的次表单 - * @param form 主表单 form 对象 - * @param cases 接收一个数组,每项都是一个JVxeTable实例 - * @param autoJumpTab - * @returns {Promise} - * @author sunjianlei - */ -export async function validateFormAndTables (form, cases, autoJumpTab) { - if (!(form && typeof form.validateFields === 'function')) { - throw new Error(`form 参数需要的是一个form对象,而传入的却是${typeof form}`) - } - let dataMap = {} - const values = await new Promise((resolve, reject) => { - // 验证主表表单 - form.validateFields((err, values) => { - err ? reject({ error: VALIDATE_FAILED, originError: err }) : resolve(values) - }) - }) - Object.assign(dataMap, { formValue: values }) - // 验证所有子表的表单 - const subData = await validateTables(cases, autoJumpTab) - // 合并最终数据 - dataMap = Object.assign(dataMap, { tablesValue: subData }) - return dataMap -} - -/** - * 一次性验证主表单和所有的次表单 - * @param form 主表单 form 对象 - * @param formData - * @param cases 接收一个数组,每项都是一个JVxeTable实例 - * @param autoJumpTab - * @returns {Promise} - * @author sunjianlei - */ -export async function validateFormModelAndTables (form, formData, cases, autoJumpTab) { - if (!(form && typeof form.validate === 'function')) { - throw new Error(`form 参数需要的是一个form对象,而传入的却是${typeof form}`) - } - let dataMap = {} - const values = await new Promise((resolve, reject) => { - // 验证主表表单 - form.validate((valid) => { - valid ? resolve(formData) : reject({ error: VALIDATE_FAILED, originError: valid }) - }) - }) - Object.assign(dataMap, { formValue: values }) - // 验证所有子表的表单 - const subData = await validateTables(cases, autoJumpTab) - // 合并最终数据 - dataMap = Object.assign(dataMap, { tablesValue: subData }) - return dataMap -} - -/** - * 验证并获取一个或多个表格的所有值 - * - * @param cases 接收一个数组,每项都是一个JVxeTable实例 - * @param autoJumpTab 校验失败后,是否自动跳转tab选项 - */ -export function validateTables (cases, autoJumpTab = true) { - if (!Array.isArray(cases)) { - throw new Error(`'validateTables'函数的'cases'参数需要的是一个数组,而传入的却是${typeof cases}`) - } - return new Promise((resolve, reject) => { - const tablesData = [] - let index = 0 - if (!cases || cases.length === 0) { - resolve() - } - (function next () { - const vm = cases[index] - vm.validateTable().then(errMap => { - // 校验通过 - if (!errMap) { - tablesData[index] = vm.getAll() - // 判断校验是否全部完成,完成返回成功,否则继续进行下一步校验 - if (++index === cases.length) { - resolve(tablesData) - } else { - ( - next() - ) - } - } else { - // 尝试获取tabKey,如果在ATab组件内即可获取 - let paneKey - const tabPane = getVmParentByName(vm, 'ATabPane') - if (tabPane) { - paneKey = tabPane.$vnode.key - // 自动跳转到该表格 - if (autoJumpTab) { - const tabs = getVmParentByName(tabPane, 'Tabs') - tabs && tabs.setActiveKey && tabs.setActiveKey(paneKey) - } - } - // 出现未验证通过的表单,不再进行下一步校验,直接返回失败 - reject({ error: VALIDATE_FAILED, index, paneKey, errMap }) - } - }) - })() - }) -} diff --git a/src/components/tools/HeaderNotice.vue b/src/components/tools/HeaderNotice.vue index ddddd27b..8b2d7939 100644 --- a/src/components/tools/HeaderNotice.vue +++ b/src/components/tools/HeaderNotice.vue @@ -119,7 +119,7 @@ export default { mounted () { this.loadData() // this.timerFun(); - this.initWebSocket() + // this.initWebSocket() // this.heartCheckFun(); }, destroyed: function () { // 离开页面生命周期函数 diff --git a/src/components/tools/ShowAnnouncement.vue b/src/components/tools/ShowAnnouncement.vue index eaecca0e..b5935df2 100644 --- a/src/components/tools/ShowAnnouncement.vue +++ b/src/components/tools/ShowAnnouncement.vue @@ -23,13 +23,9 @@