cnhis-design-vue 3.0.8 → 3.1.1
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/CHANGELOG.md +34 -0
- package/es/big-table/index.js +101 -14
- package/es/button-print/index.css +4 -0
- package/es/button-print/index.js +112 -44
- package/es/drag-layout/index.css +4 -0
- package/es/field-set/index.css +46 -42
- package/es/grid/index.css +62 -58
- package/es/index.css +4 -0
- package/es/index.js +213 -58
- package/es/select-person/index.css +62 -58
- package/package.json +1 -1
- package/packages/big-table/src/BigTable.vue +9 -3
- package/packages/big-table/src/components/edit-form/edit-date.vue +36 -2
- package/packages/big-table/src/components/edit-form/edit-select.vue +37 -7
- package/packages/big-table/src/hooks/useEdit.ts +21 -2
- package/packages/button-print/src/ButtonPrint.vue +16 -3
|
@@ -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
|
|
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
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, ref, reactive } from 'vue'
|
|
3
3
|
import { NSelect } from 'naive-ui'
|
|
4
|
+
import vexutils from '@/utils/vexutils.js'
|
|
4
5
|
|
|
5
6
|
export default defineComponent({
|
|
6
7
|
name: 'EditSelect',
|
|
@@ -26,8 +27,12 @@ export default defineComponent({
|
|
|
26
27
|
setup (props, { attrs, slots, emit }) {
|
|
27
28
|
|
|
28
29
|
const state = reactive({
|
|
29
|
-
options: [] as any
|
|
30
|
+
options: [] as any,
|
|
31
|
+
loading: false,
|
|
32
|
+
keyword: '',
|
|
33
|
+
config: {} as any
|
|
30
34
|
})
|
|
35
|
+
|
|
31
36
|
const setOptions = async () => {
|
|
32
37
|
if (props.col.options) {
|
|
33
38
|
state.options = JSON.parse(JSON.stringify(props.col.options))
|
|
@@ -35,28 +40,53 @@ export default defineComponent({
|
|
|
35
40
|
// 此处需要缓存第一次请求到的options,不需要每次都请求,
|
|
36
41
|
// 此处的row参数应当是selectTable的row
|
|
37
42
|
const optionsName = `${props.col.columnName}_options`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
const obj = {
|
|
44
|
+
keyword: state.keyword,
|
|
45
|
+
row: props.row,
|
|
46
|
+
column: props.col,
|
|
47
|
+
index: props.index
|
|
41
48
|
}
|
|
49
|
+
// state.options = props.row[optionsName] || await props.col.queryOptions(obj)
|
|
50
|
+
state.options = await props.col.queryOptions(obj)
|
|
51
|
+
state.loading = false
|
|
52
|
+
// if (!props.row[optionsName]) {
|
|
53
|
+
emit('setOptions', state.options)
|
|
54
|
+
// }
|
|
42
55
|
}
|
|
43
56
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
|
|
58
|
+
let selectSearch = (value: string) => {
|
|
59
|
+
state.keyword = value
|
|
60
|
+
state.loading = true
|
|
61
|
+
setOptions()
|
|
62
|
+
}
|
|
63
|
+
selectSearch = vexutils.debounce(selectSearch, 800)
|
|
47
64
|
const onUpdateValue = (value: any[] | string | number | null) => {
|
|
48
65
|
emit('formChange', { value, row: props.row, column: props.col, index: props.index })
|
|
49
66
|
}
|
|
50
67
|
|
|
68
|
+
const init = () => {
|
|
69
|
+
if (props.col.options) {
|
|
70
|
+
setOptions()
|
|
71
|
+
} else {
|
|
72
|
+
state.config.remote = true
|
|
73
|
+
state.config.onSearch = selectSearch
|
|
74
|
+
// 初始化搜索
|
|
75
|
+
selectSearch('')
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
init()
|
|
51
79
|
return () => [
|
|
52
80
|
<NSelect
|
|
53
81
|
{...attrs}
|
|
82
|
+
{...state.config}
|
|
54
83
|
options={state.options}
|
|
55
84
|
consistentMenuWidth={false}
|
|
56
85
|
clearable
|
|
57
86
|
filterable
|
|
58
87
|
to={false}
|
|
59
88
|
placeholder="请选择"
|
|
89
|
+
loading={state.loading}
|
|
60
90
|
onUpdateValue={onUpdateValue}
|
|
61
91
|
/>
|
|
62
92
|
]
|
|
@@ -82,14 +82,33 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
|
|
|
82
82
|
xGrid.value.clearActived()
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
const getLabel = (opts: any[], value: any): any => {
|
|
86
|
+
return opts.find((opt: any) => opt.value === value)?.label || '';
|
|
87
|
+
};
|
|
88
|
+
|
|
85
89
|
const onFormChange = ({ value, row, column, index }: {value: number | string | null, row: any, column: any, index: number}) => {
|
|
86
|
-
row[column.columnName]
|
|
87
|
-
|
|
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
113
|
return item.options.find((v: any) => v.value == value)?.label || ''
|
|
95
114
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<span @click="handleClickWrap">
|
|
3
3
|
<NDropdown
|
|
4
|
+
class="rowFoldHideBtnList-dropdown"
|
|
4
5
|
placement="bottom-start"
|
|
5
6
|
:show="state.visible"
|
|
6
7
|
@clickoutside="handleClickOutside"
|
|
7
8
|
:options="options"
|
|
8
9
|
@select="handleSelect"
|
|
10
|
+
:render-label="renderLabel"
|
|
9
11
|
>
|
|
10
12
|
<slot
|
|
11
13
|
name="button"
|
|
@@ -30,14 +32,14 @@
|
|
|
30
32
|
</span>
|
|
31
33
|
</template>
|
|
32
34
|
|
|
33
|
-
<script lang="
|
|
35
|
+
<script lang="tsx">
|
|
34
36
|
import create from '@/core/create.js';
|
|
35
37
|
export default create({
|
|
36
38
|
name: "ButtonPrint"
|
|
37
39
|
})
|
|
38
40
|
</script>
|
|
39
41
|
|
|
40
|
-
<script setup lang="
|
|
42
|
+
<script setup lang="tsx">
|
|
41
43
|
import { ref, reactive, computed, watch, onMounted, nextTick } from 'vue'
|
|
42
44
|
import { NDropdown, NButton, NIcon } from 'naive-ui'
|
|
43
45
|
import { ChevronDown, Reload } from "@vicons/ionicons5";
|
|
@@ -117,6 +119,9 @@ const currentFormatItem = computed(() => {
|
|
|
117
119
|
})
|
|
118
120
|
const formatTitle = computed(() => (currentFormatItem.value as any).name || '格式选择')
|
|
119
121
|
|
|
122
|
+
const renderLabel = (option: DropdownOption) => {
|
|
123
|
+
return <span class={{'active': option.key === state.currentFormatId}}>{option.label}</span>
|
|
124
|
+
}
|
|
120
125
|
const getTemplateIdByFormatId = (id: string | number) => {
|
|
121
126
|
let find: any = state.formatList.find((item: any) => item.id === id);
|
|
122
127
|
return find.templateId;
|
|
@@ -266,6 +271,7 @@ const handleSelect = (key: string) => {
|
|
|
266
271
|
break;
|
|
267
272
|
default:
|
|
268
273
|
state.currentFormatId = key;
|
|
274
|
+
state.visible = false
|
|
269
275
|
break;
|
|
270
276
|
}
|
|
271
277
|
}
|
|
@@ -376,6 +382,7 @@ const initCRM = async (formatListResult: any) => {
|
|
|
376
382
|
state.formatList = formatListResult ? formatFormatList(formatListResult.obj) : [];
|
|
377
383
|
console.log('formatListResult', formatListResult)
|
|
378
384
|
state.currentFormatId = getDefaultFormatId(state.formatList, 'defaultFlag');
|
|
385
|
+
setOptions()
|
|
379
386
|
|
|
380
387
|
if (!state.currentFormatId) {
|
|
381
388
|
(window as any).$message.error('获取打印格式失败,请联系管理员!');
|
|
@@ -392,7 +399,6 @@ const initCRM = async (formatListResult: any) => {
|
|
|
392
399
|
} else {
|
|
393
400
|
return requestError();
|
|
394
401
|
}
|
|
395
|
-
|
|
396
402
|
state.printParams = formatParams(state.templateParams, props.params);
|
|
397
403
|
}
|
|
398
404
|
const init = async () => {
|
|
@@ -473,3 +479,10 @@ watch(() => props.params,
|
|
|
473
479
|
margin-bottom: 8px;
|
|
474
480
|
}
|
|
475
481
|
</style>
|
|
482
|
+
<style lang="less">
|
|
483
|
+
.rowFoldHideBtnList-dropdown {
|
|
484
|
+
.n-dropdown-menu-wrapper span.active {
|
|
485
|
+
color: #5585f5;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
</style>
|