cnhis-design-vue 3.0.7 → 3.1.0

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.7",
4
+ "version": "3.1.0",
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"
@@ -289,7 +290,7 @@ const currentCheckedKeys = computed(() => {
289
290
  });
290
291
  const visibleCancelCheckAllBtn = computed(() => {
291
292
  let isCurrentPageAllCheck = state.currentPageSelectedLength === state.curAbleCheckedLen;
292
- let isMaxChecked = currentCheckedKeys.value.length === props.MAX_CHECK_SIZE;
293
+ let isMaxChecked = currentCheckedKeys.value.length === props.maxCheckSize;
293
294
  let isCheckedTotal = currentCheckedKeys.value.length === props.pageVO.total;
294
295
 
295
296
  return isMaxChecked || !isCurrentPageAllCheck || isCheckedTotal;
@@ -703,6 +704,7 @@ const formatColumns = (map: any) => {
703
704
  const formatterEdit = (params: any, col: any) => {
704
705
  let { row, column, $rowIndex, rowIndex } = params
705
706
  let formType = column.formType || col.formType || ''
707
+ let formatMap = column.formatMap || col.formatMap || null
706
708
  if (!formType) return null
707
709
  if (formType === 'custom') {
708
710
  return col.slotFn(params)
@@ -716,9 +718,11 @@ const formatterEdit = (params: any, col: any) => {
716
718
  // vModel: [row[col.columnName], formType === 'date' ? 'formattedValue' :'value'],
717
719
  type: formType,
718
720
  onFormChange
719
- }
721
+ }
720
722
  if (formType === 'date') {
721
723
  propsData.defaultFormattedValue = row[col.columnName]
724
+ } else if(formatMap){
725
+ propsData.defaultValue = row[formatMap.value]
722
726
  } else {
723
727
  propsData.defaultValue = row[col.columnName]
724
728
  }
@@ -1218,8 +1222,8 @@ const refreshTable = () => {
1218
1222
  };
1219
1223
  /* 全选相关 */
1220
1224
  const handleCheckAll = () => {
1221
- if (props.pageVO.total > props.MAX_CHECK_SIZE) {
1222
- let text = `当前列表共${props.pageVO.total}条数据,为了确保系统安全,只能单次操作${props.MAX_CHECK_SIZE}条,你可以通过高级筛选过滤再次尝试`;
1225
+ if (props.pageVO.total > props.maxCheckSize) {
1226
+ let text = `当前列表共${props.pageVO.total}条数据,为了确保系统安全,只能单次操作${props.maxCheckSize}条,你可以通过高级筛选过滤再次尝试`;
1223
1227
  (window as any).$message.warning(text);
1224
1228
  // return false;
1225
1229
  }
@@ -1325,8 +1329,7 @@ const getAsyncTableData = (params: any) => {
1325
1329
  };
1326
1330
  const setChecklist = (list: any) => {
1327
1331
  return list.map((i: any) => {
1328
- // this.$set(i, 'checked', false);
1329
- i["checked"] = false;
1332
+ i["checked"] = i.checked || false;
1330
1333
  if (state.isTree == 2) {
1331
1334
  const treeNodeKey = state.levelLazyLoadSetting.childCountKey;
1332
1335
  const { isTreeOrList = "" } = props.tableParams;
@@ -1611,8 +1614,8 @@ const addCheckedRows = (rows: any) => {
1611
1614
  removeCheckedDisabledRows(state);
1612
1615
  let checkedRows = state.checkedRows;
1613
1616
 
1614
- if (currentCheckedKeys.value.length + rows.length > props.MAX_CHECK_SIZE) {
1615
- (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}条,你可以通过高级筛选过滤后再次尝试`);
1616
1619
  return false;
1617
1620
  }
1618
1621
 
@@ -1685,10 +1688,21 @@ const showDrawer = () => {
1685
1688
  emit("setNestTableClickSetting", props.isNestTable);
1686
1689
  emit("showDrawer", theads);
1687
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()
1688
1701
  const handlerScroll = (params: any) => {
1689
1702
  if (params.isX) {
1690
1703
  hideFilterWrap(state, props);
1691
1704
  }
1705
+ scrollEvent(params)
1692
1706
  };
1693
1707
  const handleCellMouseenter = ({ column, $event }: any) => {
1694
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: () => ({}) },
@@ -27,12 +27,46 @@ export default defineComponent({
27
27
  const onConfirm = (value: any) => {
28
28
  emit('formChange', { value, row: props.row, column: props.col, index: props.index })
29
29
  }
30
- 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 = {
31
61
  type: props.col.type || 'datetime',
32
62
  clearable: props.col.clearable || true,
33
63
  disabled: props.col.disabled || false,
34
64
  valueFormat: props.col.valueFormat || 'yyyy-MM-dd HH:mm:ss',
35
- 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
36
70
  }
37
71
  return () => <NDatePicker {...attrs} {...config} onUpdateFormattedValue={onConfirm} />
38
72
  }
@@ -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}
@@ -82,16 +82,35 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
82
82
  xGrid.value.clearActived()
83
83
  }
84
84
 
85
- const onFormChange = ({ value, row, column }: {value: number | string | null, row: any, column: any}) => {
86
- row[column.columnName] = value
87
- 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 })
88
104
  }
89
105
 
90
106
  const getDefaultValue = (params: any, item: any) => {
91
107
  const value = params.row[item.columnName]
92
108
  if (item.formType === 'select') {
109
+ if( item.formatMap ) {
110
+ return params.row[item.formatMap.label]
111
+ }
93
112
  if (item.options) {
94
- return item.options.find((v: any) => v.value === value)?.label || ''
113
+ return item.options.find((v: any) => v.value == value)?.label || ''
95
114
  }
96
115
  if (item.queryOptions) {
97
116
  return (params.row[`${item.columnName}_options`]?.find((v: any) => v.value === value)?.label) || ''
@@ -376,6 +376,7 @@ const initCRM = async (formatListResult: any) => {
376
376
  state.formatList = formatListResult ? formatFormatList(formatListResult.obj) : [];
377
377
  console.log('formatListResult', formatListResult)
378
378
  state.currentFormatId = getDefaultFormatId(state.formatList, 'defaultFlag');
379
+ setOptions()
379
380
 
380
381
  if (!state.currentFormatId) {
381
382
  (window as any).$message.error('获取打印格式失败,请联系管理员!');
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 {