cnhis-design-vue 3.0.6 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
3
  "private": false,
4
- "version": "3.0.6",
4
+ "version": "3.0.9",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",
7
7
  "scripts": {
@@ -15,13 +15,13 @@
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@vicons/ionicons5": "^0.12.0",
18
- "naive-ui": "^2.28.1"
18
+ "naive-ui": "^2.29.0"
19
19
  },
20
20
  "dependencies": {
21
21
  "@vicons/ionicons5": "^0.12.0",
22
22
  "crypto-js": "^4.1.1",
23
23
  "moment": "^2.29.1",
24
- "naive-ui": "^2.28.1",
24
+ "naive-ui": "^2.29.0",
25
25
  "vue": "^3.2.25",
26
26
  "vue-router": "^4.0.13",
27
27
  "vuedraggable": "^4.1.0",
@@ -26,9 +26,9 @@
26
26
  </p>
27
27
  <template v-if="state.visibleCheckAllWrapMore && !props.asyncCount">
28
28
  <p v-if="!visibleCancelCheckAllBtn" class="check-wrap-btn" @click="handleCheckAll">
29
- <span v-if="pageVO.total > MAX_CHECK_SIZE">
30
- <!-- {{ `最大勾选“${tableName}” ${MAX_CHECK_SIZE}条数据` }} -->
31
- {{ `勾选全部页 ${MAX_CHECK_SIZE}条数据` }}
29
+ <span v-if="pageVO.total > maxCheckSize">
30
+ <!-- {{ `最大勾选“${tableName}” ${maxCheckSize}条数据` }} -->
31
+ {{ `勾选全部页 ${maxCheckSize}条数据` }}
32
32
  </span>
33
33
  <span v-else>
34
34
  <!-- {{ $t("1.9.598", { name: tableName, total }) }} -->
@@ -96,6 +96,7 @@
96
96
  iconOpen: 'iconfont icon-a-xitongtubiaozhediejian',
97
97
  iconClose: 'iconfont icon-a-xitongtubiaotianjia',
98
98
  }"
99
+ :keyboard-config="columnConfig.keyboardConfig || {}"
99
100
  @cell-dblclick="rowdblclick"
100
101
  @cell-click="handlerClickRow"
101
102
  @checkbox-change="selectionChange"
@@ -171,14 +172,11 @@ import { useFormat } from "./hooks/useFormat";
171
172
  import { useTableParse } from "./hooks/useTableParse";
172
173
  import { useBatchEditing } from "./hooks/useBatchEditing";
173
174
  import { useNestTable } from "./hooks/useNestTable";
174
- import { useEdit } from './hooks/useEdit';
175
+ import { useEdit, comps } from './hooks/useEdit';
175
176
  import { SettingsSharp, SyncOutline, CopyOutline, CaretDown, CaretForward } from "@vicons/ionicons5";
176
177
  import NoData from "./components/NoData.vue";
177
178
  import TextOverTooltip from "./components/TextOverTooltip.vue";
178
179
  import SvgIcon from '@/component/svg/index.vue';
179
- import EditInput from './components/edit-form/edit-input.vue'
180
- import EditSelect from './components/edit-form/edit-select.vue'
181
- import EditDate from './components/edit-form/edit-date.vue'
182
180
  import {
183
181
  NButton,
184
182
  NCheckbox,
@@ -292,7 +290,7 @@ const currentCheckedKeys = computed(() => {
292
290
  });
293
291
  const visibleCancelCheckAllBtn = computed(() => {
294
292
  let isCurrentPageAllCheck = state.currentPageSelectedLength === state.curAbleCheckedLen;
295
- let isMaxChecked = currentCheckedKeys.value.length === props.MAX_CHECK_SIZE;
293
+ let isMaxChecked = currentCheckedKeys.value.length === props.maxCheckSize;
296
294
  let isCheckedTotal = currentCheckedKeys.value.length === props.pageVO.total;
297
295
 
298
296
  return isMaxChecked || !isCurrentPageAllCheck || isCheckedTotal;
@@ -706,23 +704,32 @@ const formatColumns = (map: any) => {
706
704
  const formatterEdit = (params: any, col: any) => {
707
705
  let { row, column, $rowIndex, rowIndex } = params
708
706
  let formType = column.formType || col.formType || ''
707
+ let formatMap = column.formatMap || col.formatMap || null
708
+ if (!formType) return null
709
709
  if (formType === 'custom') {
710
710
  return col.slotFn(params)
711
711
  }
712
- const propsData = {
712
+ const Comp = comps[formType] || ''
713
+ if (!Comp) return null
714
+ const propsData: any = {
713
715
  col,
714
716
  row,
715
- index: $rowIndex
716
- }
717
- if (formType === 'input' || formType === 'number') {
718
- return <EditInput {...propsData} type={formType} v-model={[row[col.columnName], 'value']} onFormChange={onFormChange} />
717
+ index: $rowIndex,
718
+ // vModel: [row[col.columnName], formType === 'date' ? 'formattedValue' :'value'],
719
+ type: formType,
720
+ onFormChange
721
+ }
722
+ if (formType === 'date') {
723
+ propsData.defaultFormattedValue = row[col.columnName]
724
+ } else if(formatMap){
725
+ propsData.defaultValue = row[formatMap.value]
726
+ } else {
727
+ propsData.defaultValue = row[col.columnName]
719
728
  }
720
729
  if (formType === 'select') {
721
- return <EditSelect {...propsData} v-model={[row[col.columnName], 'value']} onSetOptions={(options: any[]) => row[`${col.columnName}_options`] = options} onFormChange={onFormChange} />
722
- }
723
- if (formType === 'date') {
724
- return <EditDate {...propsData} v-model={[row[col.columnName], 'formattedValue']} onFormChange={onFormChange} />
730
+ propsData.onSetOptions = (options: any[]) => (row[`${col.columnName}_options`] = options)
725
731
  }
732
+ return <Comp {...propsData} />
726
733
  }
727
734
  const getEditBtn = (row: any, col: any, index: number) => {
728
735
  return col.tileBtnList?.map((btn: any) => {
@@ -822,8 +829,7 @@ const formatter = (params: any, col: any) => {
822
829
  return getOrCode(row, own, attrType);
823
830
  }
824
831
  if (column.property === "operatorColumn") {
825
- // if (props.columnConfig.isEdit && !row.initRow) {
826
- if (props.columnConfig.isEdit) {
832
+ if (props.columnConfig.isEdit && !row.initRow) {
827
833
  return getEditBtn(row, col, $rowIndex)
828
834
  }
829
835
 
@@ -1216,8 +1222,8 @@ const refreshTable = () => {
1216
1222
  };
1217
1223
  /* 全选相关 */
1218
1224
  const handleCheckAll = () => {
1219
- if (props.pageVO.total > props.MAX_CHECK_SIZE) {
1220
- let text = `当前列表共${props.pageVO.total}条数据,为了确保系统安全,只能单次操作${props.MAX_CHECK_SIZE}条,你可以通过高级筛选过滤再次尝试`;
1225
+ if (props.pageVO.total > props.maxCheckSize) {
1226
+ let text = `当前列表共${props.pageVO.total}条数据,为了确保系统安全,只能单次操作${props.maxCheckSize}条,你可以通过高级筛选过滤再次尝试`;
1221
1227
  (window as any).$message.warning(text);
1222
1228
  // return false;
1223
1229
  }
@@ -1323,8 +1329,7 @@ const getAsyncTableData = (params: any) => {
1323
1329
  };
1324
1330
  const setChecklist = (list: any) => {
1325
1331
  return list.map((i: any) => {
1326
- // this.$set(i, 'checked', false);
1327
- i["checked"] = false;
1332
+ i["checked"] = i.checked || false;
1328
1333
  if (state.isTree == 2) {
1329
1334
  const treeNodeKey = state.levelLazyLoadSetting.childCountKey;
1330
1335
  const { isTreeOrList = "" } = props.tableParams;
@@ -1609,8 +1614,8 @@ const addCheckedRows = (rows: any) => {
1609
1614
  removeCheckedDisabledRows(state);
1610
1615
  let checkedRows = state.checkedRows;
1611
1616
 
1612
- if (currentCheckedKeys.value.length + rows.length > props.MAX_CHECK_SIZE) {
1613
- (window as any).$message.warning(`为了保证系统安全,单次操作数据量限额为${props.MAX_CHECK_SIZE}条,你可以通过高级筛选过滤后再次尝试`);
1617
+ if (currentCheckedKeys.value.length + rows.length > props.maxCheckSize) {
1618
+ (window as any).$message.warning(`为了保证系统安全,单次操作数据量限额为${props.maxCheckSize}条,你可以通过高级筛选过滤后再次尝试`);
1614
1619
  return false;
1615
1620
  }
1616
1621
 
@@ -1683,10 +1688,21 @@ const showDrawer = () => {
1683
1688
  emit("setNestTableClickSetting", props.isNestTable);
1684
1689
  emit("showDrawer", theads);
1685
1690
  };
1691
+ let scrollEvent = (params: any) => {
1692
+ emit('scroll', params)
1693
+ }
1694
+ const initScroll = () => {
1695
+ const { throttle = false, throttleTime = 800, throttleOptions = {} } = props.columnConfig?.scrollConfig || {}
1696
+ if (throttle) {
1697
+ scrollEvent = vexutils.throttle(scrollEvent, throttleTime, throttleOptions)
1698
+ }
1699
+ }
1700
+ initScroll()
1686
1701
  const handlerScroll = (params: any) => {
1687
1702
  if (params.isX) {
1688
1703
  hideFilterWrap(state, props);
1689
1704
  }
1705
+ scrollEvent(params)
1690
1706
  };
1691
1707
  const handleCellMouseenter = ({ column, $event }: any) => {
1692
1708
  // vxe-table@2.10+ 触发tooltip给vxe-cell父节点设置了title 导致显示有误
@@ -41,7 +41,8 @@ const bigTableEmits: string[] = [
41
41
  "selectionChangeLocal",
42
42
  "switchBtnOnChange",
43
43
  "asyncTableChange",
44
- "formChange"
44
+ "formChange",
45
+ "scroll"
45
46
  ];
46
47
 
47
48
  export default bigTableEmits;
@@ -1,6 +1,6 @@
1
1
  const bigTableProps = {
2
2
  data: { type: Array, default: () => [] },
3
- MAX_CHECK_SIZE: { type: Number, default: 0 },
3
+ maxCheckSize: { type: Number, default: 0 },
4
4
  showFooter: Boolean,
5
5
  sumData: { type: Object, default: () => ({}) },
6
6
  avgData: { type: Object, default: () => ({}) },
@@ -24,18 +24,51 @@ export default defineComponent({
24
24
  },
25
25
  emits: ['formChange'],
26
26
  setup (props, { attrs, slots, emit }) {
27
- const onConfirm = (value: number | [number, number] | null, formattedValue: string | [string, string] | null) => {
28
- console.log('时间选择->', value)
27
+ const onConfirm = (value: any) => {
29
28
  emit('formChange', { value, row: props.row, column: props.col, index: props.index })
30
29
  }
31
- const config = {
30
+ const { isStartDate = false, isEndDate = false, connectField } = props.col
31
+ const setDateDisabled = (cur: number, date: number) => {
32
+ if (isStartDate && connectField) {
33
+ return cur > date
34
+ }
35
+ if(isEndDate && connectField) {
36
+ return cur < date
37
+ }
38
+ return false
39
+ }
40
+ const isDateDisabled = (ts: number) => {
41
+ return setDateDisabled(ts, new Date(props.row[connectField]).getTime())
42
+ }
43
+ const isTimeDisabled = (ts: number) => {
44
+ const date = new Date(props.row[connectField] || ts)
45
+ const h = date.getHours()
46
+ const m = date.getMinutes()
47
+ const s = date.getSeconds()
48
+ return {
49
+ isHourDisabled: (hour: number) => {
50
+ return setDateDisabled(hour, h)
51
+ },
52
+ isMinuteDisabled: (minute: number) => {
53
+ return setDateDisabled(minute, m)
54
+ },
55
+ isSecondDisabled: (second: number) => {
56
+ return setDateDisabled(second, s)
57
+ }
58
+ }
59
+ }
60
+ const config: any = {
32
61
  type: props.col.type || 'datetime',
33
62
  clearable: props.col.clearable || true,
34
63
  disabled: props.col.disabled || false,
35
64
  valueFormat: props.col.valueFormat || 'yyyy-MM-dd HH:mm:ss',
36
- to: false
65
+ to: false,
66
+ isDateDisabled: props.col.isDateDisabled || isDateDisabled
67
+ }
68
+ if (config.type.includes('time')) {
69
+ config.isTimeDisabled = props.col.isTimeDisabled || isTimeDisabled
37
70
  }
38
- return () => <NDatePicker {...attrs} {...config} onConfirm={onConfirm} />
71
+ return () => <NDatePicker {...attrs} {...config} onUpdateFormattedValue={onConfirm} />
39
72
  }
40
73
  })
41
74
  </script>
@@ -48,6 +48,7 @@ export default defineComponent({
48
48
  emit('formChange', { value, row: props.row, column: props.col, index: props.index })
49
49
  }
50
50
 
51
+ console.log(attrs)
51
52
  return () => [
52
53
  <NSelect
53
54
  {...attrs}
@@ -1,4 +1,15 @@
1
1
  import { computed, ref, reactive, watch, onMounted } from 'vue'
2
+ import EditInput from '../components/edit-form/edit-input.vue'
3
+ import EditSelect from '../components/edit-form/edit-select.vue'
4
+ import EditDate from '../components/edit-form/edit-date.vue'
5
+
6
+
7
+ export const comps = {
8
+ 'input': EditInput,
9
+ 'number': EditInput,
10
+ 'select': EditSelect,
11
+ 'date': EditDate
12
+ }
2
13
 
3
14
  export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
4
15
 
@@ -71,15 +82,35 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
71
82
  xGrid.value.clearActived()
72
83
  }
73
84
 
74
- const onFormChange = ({ value, row, column }: {value: number | string | null, row: any, column: any}) => {
75
- emit('formChange', { value, row, column })
85
+ const getLabel = (opts: any[], value: any): any => {
86
+ return opts.find((opt: any) => opt.value === value)?.label || '';
87
+ };
88
+
89
+ const onFormChange = ({ value, row, column, index }: {value: number | string | null, row: any, column: any, index: number}) => {
90
+ let oldValue: any = row[column.columnName]
91
+ if ((column?.formType === 'input' || column?.formType === 'number') && props.columnConfig?.formValidate) {
92
+ row[column.columnName] = props.columnConfig?.formValidate({row, column, current: value, old: row[column.columnName]})
93
+ } else if (column?.formatMap) {
94
+ oldValue = {
95
+ label: row[column.formatMap.label],
96
+ value: row[column.formatMap.value]
97
+ }
98
+ row[column.formatMap.label] = getLabel(row[column.columnName+'_options'] || [], value)
99
+ row[column.formatMap.value] = value
100
+ } else {
101
+ row[column.columnName] = value
102
+ }
103
+ emit('formChange', { value, row, column, index, oldValue })
76
104
  }
77
105
 
78
106
  const getDefaultValue = (params: any, item: any) => {
79
107
  const value = params.row[item.columnName]
80
108
  if (item.formType === 'select') {
109
+ if( item.formatMap ) {
110
+ return params.row[item.formatMap.label]
111
+ }
81
112
  if (item.options) {
82
- return item.options.find((v: any) => v.value === value)?.label || ''
113
+ return item.options.find((v: any) => v.value == value)?.label || ''
83
114
  }
84
115
  if (item.queryOptions) {
85
116
  return (params.row[`${item.columnName}_options`]?.find((v: any) => v.value === value)?.label) || ''
@@ -97,4 +128,4 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
97
128
  onFormChange,
98
129
  getDefaultValue
99
130
  }
100
- }
131
+ }
package/packages/index.ts CHANGED
@@ -5,6 +5,7 @@ import { default as CBigTable } from './big-table';
5
5
  import { default as CFieldSet } from './field-set';
6
6
  import { default as CDragLayout } from './drag-layout';
7
7
  import { default as CButtonPrint } from './button-print';
8
+ import { default as CSelectPerson } from './select-person';
8
9
 
9
10
  // 存储组件列表
10
11
  const components: any[] = [
@@ -12,7 +13,8 @@ const components: any[] = [
12
13
  CBigTable,
13
14
  CFieldSet,
14
15
  CDragLayout,
15
- CButtonPrint
16
+ CButtonPrint,
17
+ CSelectPerson
16
18
  ];
17
19
  // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
18
20
  const install = function(app: App) {
@@ -27,7 +29,8 @@ export {
27
29
  CBigTable,
28
30
  CFieldSet,
29
31
  CDragLayout,
30
- CButtonPrint
32
+ CButtonPrint,
33
+ CSelectPerson
31
34
  }
32
35
 
33
36
  export default {
@@ -0,0 +1,11 @@
1
+ import type { App } from "vue";
2
+ // 导入组件
3
+ import SelectPerson from './src/SelectPerson.vue'
4
+
5
+ // 为组件提供 install 安装方法,供按需引入
6
+ SelectPerson.install = function(app: App) {
7
+ app.component(SelectPerson.name, SelectPerson);
8
+ };
9
+
10
+ // 默认导出组件
11
+ export default SelectPerson;