cnhis-design-vue 0.3.2-beta → 0.3.5-beta
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/env.d.ts +2 -0
- package/es/big-table/index.css +1 -0
- package/es/big-table/index.js +97 -64
- package/es/button-print/index.css +1 -0
- package/es/button-print/index.js +8806 -11
- package/es/drag-layout/index.css +2 -1
- package/es/drag-layout/index.js +33 -58
- package/es/grid/index.css +2 -1
- package/es/grid/index.js +3 -4
- package/es/index.css +2 -1
- package/es/index.js +9467 -664
- package/package.json +5 -2
- package/packages/big-table/index.ts +17 -0
- package/packages/big-table/src/BigTable.vue +2514 -0
- package/packages/big-table/src/assets/iconfont/iconfont.less +21 -0
- package/packages/big-table/src/assets/iconfont/iconfont.ttf +0 -0
- package/packages/big-table/src/assets/img/failure.png +0 -0
- package/packages/big-table/src/assets/img/icon-asc.png +0 -0
- package/packages/big-table/src/assets/img/icon-desc.png +0 -0
- package/packages/big-table/src/assets/img/no-permission.png +0 -0
- package/packages/big-table/src/assets/img/nodata.png +0 -0
- package/packages/big-table/src/assets/img/notfound.png +0 -0
- package/packages/big-table/src/assets/img/qr.png +0 -0
- package/packages/big-table/src/assets/img/video_default_cover.png +0 -0
- package/packages/big-table/src/assets/img/xb_big.png +0 -0
- package/packages/big-table/src/assets/img/xb_small.png +0 -0
- package/packages/big-table/src/assets/style/table-base.less +275 -0
- package/packages/big-table/src/assets/style/table-global.less +167 -0
- package/packages/big-table/src/bigTableEmits.ts +46 -0
- package/packages/big-table/src/bigTableProps.ts +125 -0
- package/packages/big-table/src/bigTableState.ts +62 -0
- package/packages/big-table/src/components/NoData.vue +90 -0
- package/packages/big-table/src/components/SvgIcon.vue +49 -0
- package/packages/big-table/src/components/TextOverTooltip.vue +110 -0
- package/packages/big-table/src/components/edit-form/EditForm.vue +426 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-date-picker/edit-date-picker.vue +66 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-digital/edit-digital.vue +60 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-input/edit-input.vue +38 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-input-password/edit-input-password.vue +89 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-month-picker/edit-month-picker.vue +38 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-search/edit-search.vue +63 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-search-more/edit-search-more.vue +69 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-select/edit-select.vue +51 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-select-multiple/edit-select-multiple.vue +60 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-textarea/edit-textarea.vue +34 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-time-picker/edit-time-picker.vue +42 -0
- package/packages/big-table/src/components/edit-form/edit-component/editFormProps.ts +91 -0
- package/packages/big-table/src/components/edit-form/edit-component/register-com.ts +18 -0
- package/packages/big-table/src/components/edit-form/hooks/useConfigData.ts +79 -0
- package/packages/big-table/src/components/edit-form/hooks/useDateType.ts +184 -0
- package/packages/big-table/src/components/edit-form/hooks/useFormCommon.ts +373 -0
- package/packages/big-table/src/components/edit-form/hooks/useItemDefault.ts +638 -0
- package/packages/big-table/src/components/edit-form/hooks/useSearch.ts +910 -0
- package/packages/big-table/src/components/edit-form/hooks/useValidateRules.ts +387 -0
- package/packages/big-table/src/components/edit-form/interface.ts +53 -0
- package/packages/big-table/src/components/edit-form/types.ts +3 -0
- package/packages/big-table/src/components/edit-form/utils.ts +247 -0
- package/packages/big-table/src/hooks/useBatchEditing.ts +574 -0
- package/packages/big-table/src/hooks/useFormat.ts +612 -0
- package/packages/big-table/src/hooks/useNestTable.ts +109 -0
- package/packages/big-table/src/hooks/useTableParse.ts +169 -0
- package/packages/big-table/src/utils.ts +705 -0
- package/packages/button-print/index.ts +15 -0
- package/packages/button-print/src/ButtonPrint.vue +697 -0
- package/packages/button-print/src/components/IdentityVerification.vue +149 -0
- package/packages/button-print/src/interfaces.ts +19 -0
- package/packages/button-print/src/utils/crypto.js +25 -0
- package/packages/button-print/src/utils/print.es.min.js +1 -0
- package/packages/drag-layout/index.ts +15 -0
- package/packages/drag-layout/src/DragFormLeftItem.vue +131 -0
- package/packages/drag-layout/src/DragFormRightItem.vue +277 -0
- package/packages/drag-layout/src/DragLayout.vue +712 -0
- package/packages/grid/index.ts +17 -0
- package/packages/grid/src/Grid.tsx +22 -0
- package/packages/grid/src/hooks.ts +168 -0
- package/packages/index.ts +36 -0
- package/src/component/svg/index.vue +49 -0
- package/src/core/create.ts +5 -0
- package/src/global/variable.ts +2 -0
- package/src/utils/clickoutside.ts +80 -0
- package/src/utils/crypto.js +25 -0
- package/src/utils/vexutils.ts +811 -0
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
import { onMounted, inject, nextTick, ref } from 'vue';
|
|
2
|
+
import type { FormItemRule } from 'naive-ui'
|
|
3
|
+
import type { DateProp } from '../interface'
|
|
4
|
+
import vexutils from '@/utils/vexutils';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
import { handleSysParams, hanldeGetTargetList, handlerGetIdcatInfo, getAgeInfo } from '../utils'
|
|
7
|
+
|
|
8
|
+
/** form methods */
|
|
9
|
+
// TODE 目前支支持单个值
|
|
10
|
+
// 赋值给表单
|
|
11
|
+
export const hanldeSetFieldsValue = (setObj = {}, item: any, props: any) => {
|
|
12
|
+
const setVal = { ...setObj };
|
|
13
|
+
if (typeof setVal === 'object') {
|
|
14
|
+
let list = Object.entries(setVal || {});
|
|
15
|
+
list.forEach(f => {
|
|
16
|
+
let [key, value] = f;
|
|
17
|
+
if (!key) return;
|
|
18
|
+
if (item) {
|
|
19
|
+
props.defaultValue[item.name] = value;
|
|
20
|
+
} else {
|
|
21
|
+
if (props.formFieldObj[key]) {
|
|
22
|
+
let name = props.formFieldObj[key].name;
|
|
23
|
+
name && (props.defaultValue[name] = value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
item.useFormValue = value
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const useItemDefault = (props: any, emit: any) => {
|
|
32
|
+
const editFormState: any = inject('state')
|
|
33
|
+
const userInfo: any = inject('userInfo')
|
|
34
|
+
const paramsObj = { defaultValue: props.defaultValue, userInfo: userInfo.value, dbParams: props.dbParams }
|
|
35
|
+
let open = ref(false)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// 根据末次月经时间推算预产期、孕周、孕阶段等
|
|
39
|
+
const handlerSetMenstrual = (v?: any, i?: any) => {
|
|
40
|
+
let mapList = hanldeGetTargetList(i, props.defaultFieldList);
|
|
41
|
+
|
|
42
|
+
if (!v) {
|
|
43
|
+
// function CompareDate(param) { }
|
|
44
|
+
mapList.forEach((item: any) => {
|
|
45
|
+
const { validate } = item;
|
|
46
|
+
const list = ['due_date', 'gestational_weeks', 'gestational_weeks_week', 'gestational_weeks_day', 'gestational_stage'];
|
|
47
|
+
if (validate?.obj_type && list.includes(validate.obj_type)) {
|
|
48
|
+
item.useFormValue = ''
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!v || v.type === 'blur') return;
|
|
53
|
+
const curDateStr = v.format('YYYY-MM-DD');
|
|
54
|
+
const nowDateStr = vexutils.toDateString(new Date(), 'yyyy-MM-dd');
|
|
55
|
+
let timeDiff: any;
|
|
56
|
+
function CompareDate(d1: string, d2: string) {
|
|
57
|
+
return new Date(d1.replace(/-/g, '/')) < new Date(d2.replace(/-/g, '/'));
|
|
58
|
+
}
|
|
59
|
+
if (CompareDate(curDateStr, nowDateStr)) {
|
|
60
|
+
timeDiff = vexutils.getDateDiff(curDateStr, nowDateStr);
|
|
61
|
+
} else if (curDateStr == nowDateStr) {
|
|
62
|
+
timeDiff = { time: 0 };
|
|
63
|
+
} else if (CompareDate(nowDateStr, curDateStr)) {
|
|
64
|
+
timeDiff = vexutils.getDateDiff(nowDateStr, curDateStr);
|
|
65
|
+
timeDiff.time = -timeDiff.time;
|
|
66
|
+
}
|
|
67
|
+
if (!timeDiff) return;
|
|
68
|
+
const [year, month, day] = curDateStr.split('-');
|
|
69
|
+
let gestationalWeeks: number | string, gestation: string, dueDate: string; // 孕周 孕期 预产期
|
|
70
|
+
const w = parseInt(String(timeDiff.time / 3600 / 24 / 1000 / 7));
|
|
71
|
+
const d = (timeDiff.time / 3600 / 24 / 1000) % 7;
|
|
72
|
+
gestationalWeeks = `${w}周${d}天`;
|
|
73
|
+
if (d >= 0 && w >= 0 && w <= 12) {
|
|
74
|
+
gestation = '孕早期';
|
|
75
|
+
} else if (w > 12 && w <= 25) {
|
|
76
|
+
gestation = '孕中期';
|
|
77
|
+
} else if (w > 25) {
|
|
78
|
+
gestation = '孕晚期';
|
|
79
|
+
}
|
|
80
|
+
let dueDateM: string | number = parseInt(month) + 9 > 12 ? parseInt(month) - 3 : parseInt(month) + 9;
|
|
81
|
+
dueDateM = dueDateM >= 10 ? dueDateM : '0' + dueDateM;
|
|
82
|
+
const dueDateY = parseInt(month) + 9 > 12 ? parseInt(year) + 1 : year;
|
|
83
|
+
dueDate = vexutils.toDateString(vexutils.getWhatDay(`${dueDateY}-${dueDateM}-${day}`, 7), 'yyyy-MM-dd');
|
|
84
|
+
mapList.forEach((item: any) => {
|
|
85
|
+
const { validate } = item;
|
|
86
|
+
if (validate) {
|
|
87
|
+
switch (validate.obj_type) {
|
|
88
|
+
case 'due_date':
|
|
89
|
+
hanldeSetFieldsValue(
|
|
90
|
+
{
|
|
91
|
+
[item.val_key]: moment(dueDate, 'YYYY-MM-DD')
|
|
92
|
+
},
|
|
93
|
+
item,
|
|
94
|
+
props
|
|
95
|
+
);
|
|
96
|
+
break;
|
|
97
|
+
case 'gestational_weeks':
|
|
98
|
+
hanldeSetFieldsValue(
|
|
99
|
+
{
|
|
100
|
+
[item.val_key]: gestationalWeeks
|
|
101
|
+
},
|
|
102
|
+
item,
|
|
103
|
+
props
|
|
104
|
+
);
|
|
105
|
+
break;
|
|
106
|
+
case 'gestational_weeks_week':
|
|
107
|
+
hanldeSetFieldsValue(
|
|
108
|
+
{
|
|
109
|
+
[item.val_key]: w
|
|
110
|
+
},
|
|
111
|
+
item,
|
|
112
|
+
props
|
|
113
|
+
);
|
|
114
|
+
break;
|
|
115
|
+
case 'gestational_weeks_day':
|
|
116
|
+
hanldeSetFieldsValue(
|
|
117
|
+
{
|
|
118
|
+
[item.val_key]: d
|
|
119
|
+
},
|
|
120
|
+
item,
|
|
121
|
+
props
|
|
122
|
+
);
|
|
123
|
+
break;
|
|
124
|
+
case 'gestational_stage':
|
|
125
|
+
hanldeSetFieldsValue({ [item.val_key]: gestation }, item, props);
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** 默认的电话号码校验 */
|
|
134
|
+
const handlecheckPhone = (item: any = {}) => {
|
|
135
|
+
const checkingInput = editFormState.editForm[item.val_key]
|
|
136
|
+
const selectedReg = /(^[0-9]{11,11}$)/;
|
|
137
|
+
if (!checkingInput) return { status: 'noPass' };
|
|
138
|
+
if (!selectedReg.test(checkingInput)) {
|
|
139
|
+
// this.$t("1.1.7.29")
|
|
140
|
+
editFormState.editForm[item.val_key] = checkingInput
|
|
141
|
+
// this.baseForm.setFields({
|
|
142
|
+
// [item.val_key]: {
|
|
143
|
+
// value: checkingInput,
|
|
144
|
+
// errors: [
|
|
145
|
+
// {
|
|
146
|
+
// message: `请输入正确的手机号码`
|
|
147
|
+
// }
|
|
148
|
+
// ]
|
|
149
|
+
// }
|
|
150
|
+
// });
|
|
151
|
+
return { status: 'noPass' };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const handleGetOperationalKey = (str: string) => {
|
|
155
|
+
// table.dept_name 提取 dept_name
|
|
156
|
+
const getVal = (t: string, r: RegExp, s?: string) => {
|
|
157
|
+
return t.replace(r, function() {
|
|
158
|
+
var pKey = arguments[1];
|
|
159
|
+
return pKey || '';
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
if (typeof str === 'string') {
|
|
163
|
+
if (str.includes('form.')) {
|
|
164
|
+
str = getVal(str, /form.(.*?)/g, 'form');
|
|
165
|
+
} else if (str.includes('sys.')) {
|
|
166
|
+
str = getVal(str, /sys.(.*?)/g, 'sys');
|
|
167
|
+
} else if (str.includes('db.')) {
|
|
168
|
+
str = getVal(str, /db.(.*?)/g, 'db');
|
|
169
|
+
} else if (str.includes('table.')) {
|
|
170
|
+
str = getVal(str, /table.(.*?)/g, 'table');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return str;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 表单运算
|
|
177
|
+
*/
|
|
178
|
+
const hanldeOperational = (v: any) => {
|
|
179
|
+
let curKey = v.val_key;
|
|
180
|
+
// let curTarget = `table.${curKey}`;
|
|
181
|
+
const {
|
|
182
|
+
operationalForm = [
|
|
183
|
+
/** 调试数据
|
|
184
|
+
{
|
|
185
|
+
operationalRule: "${table.dept_id} * ${table.user_name}",
|
|
186
|
+
operationalResult: "table.dept_name",
|
|
187
|
+
operationalPrecision: "2",
|
|
188
|
+
operationFormParam: ["table.dept_id", "table.user_name"],
|
|
189
|
+
index: "1599208860405"
|
|
190
|
+
}
|
|
191
|
+
*/
|
|
192
|
+
]
|
|
193
|
+
} = editFormState || {};
|
|
194
|
+
setTimeout(async () => {
|
|
195
|
+
let formValue = editFormState.editForm;
|
|
196
|
+
let obj = {
|
|
197
|
+
table: formValue,
|
|
198
|
+
form: formValue,
|
|
199
|
+
sys: userInfo.value?.map?.sysParams || {}
|
|
200
|
+
};
|
|
201
|
+
operationalForm.forEach((v: any) => {
|
|
202
|
+
let itemRes: any;
|
|
203
|
+
let operationalRule = vexutils.handleSysParams(v.operationalRule, obj, 0);
|
|
204
|
+
let operationFormParam = v.operationFormParam;
|
|
205
|
+
let f = operationFormParam.find((v: string) => v.includes(curKey));
|
|
206
|
+
if (!f) return;
|
|
207
|
+
let operationalResult = handleGetOperationalKey(v.operationalResult);
|
|
208
|
+
let targetValueStr = 'itemRes=' + operationalRule;
|
|
209
|
+
try {
|
|
210
|
+
eval(targetValueStr);
|
|
211
|
+
let operationalPrecision = +v.operationalPrecision;
|
|
212
|
+
if (typeof itemRes === 'number' && !isFinite(itemRes)) {
|
|
213
|
+
itemRes = 0;
|
|
214
|
+
}
|
|
215
|
+
// 计算结果有小数点才 精确小数位
|
|
216
|
+
if (operationalPrecision && String(itemRes).includes('.')) {
|
|
217
|
+
itemRes = itemRes.toFixed(operationalPrecision);
|
|
218
|
+
}
|
|
219
|
+
hanldeSetFieldsValue({
|
|
220
|
+
[operationalResult]: itemRes
|
|
221
|
+
}, {}, props);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
console.log(error, '计算出错');
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}, 16);
|
|
227
|
+
}
|
|
228
|
+
const handleTriggerCheck = (item: any) => {
|
|
229
|
+
if (['PHONE_TYPE', 'IDCARD_TYPE'].includes(item.html_type)) {
|
|
230
|
+
let mapList = props.defaultFieldList;
|
|
231
|
+
if (item.group) {
|
|
232
|
+
mapList = props.defaultFieldList.filter((v: any) => v.group == item.group);
|
|
233
|
+
}
|
|
234
|
+
let targetList = mapList.filter((t: any) => t.validate && ['mobile', 'telephone', 'id_card'].includes(t.validate.vali_obj));
|
|
235
|
+
targetList.forEach((v: any) => {
|
|
236
|
+
checkMultipleIdCard(v);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// 失去焦点
|
|
241
|
+
/**
|
|
242
|
+
* @param data
|
|
243
|
+
* @param v // 时间类型的 值
|
|
244
|
+
* @param eventType // 事件类型标识
|
|
245
|
+
*/
|
|
246
|
+
const handlerInputBlur = (data: any = {}, v: any = {}, eventType = 'blur', eventConfig = {}) => {
|
|
247
|
+
const { validate, html_type } = data;
|
|
248
|
+
if (html_type == 'SEARCH_MORE' || html_type == 'SEARCH' || html_type == 'SELECT' || html_type == 'PHONE_TYPE' || html_type == 'IDCARD_TYPE' || html_type == 'GUAGE') {
|
|
249
|
+
open.value = false;
|
|
250
|
+
if (html_type == 'GUAGE') {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// select 类型 失去焦点 不触发事件
|
|
255
|
+
if (eventType === 'select-blur') {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
let valiStatus = 'id_card_noReg';
|
|
259
|
+
// 大陆/港澳台多种身份证及手机号校验
|
|
260
|
+
if (validate && validate.vali_obj) {
|
|
261
|
+
let vali_objFlag = checkMultipleIdCard(data);
|
|
262
|
+
if (['id_card', 'mobile', 'telephone'].includes(validate.obj_type)) {
|
|
263
|
+
valiStatus = vali_objFlag.status;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// 身份证
|
|
267
|
+
if (valiStatus === 'id_card_noReg' && validate && (validate.obj_type == 'id_card' || validate.vali_obj == 'id_card')) {
|
|
268
|
+
handlerSetIdCarInfo(data);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (validate && validate.obj_type == 'birthday') {
|
|
272
|
+
// birthday
|
|
273
|
+
// change 事件才计算年龄。
|
|
274
|
+
eventType == 'change' && handleBirthday(v, data);
|
|
275
|
+
} else if (validate && validate.obj_type == 'last_menstrual') {
|
|
276
|
+
// 末次月经
|
|
277
|
+
handlerSetMenstrual(v, data);
|
|
278
|
+
} else if (['mobile_noReg', 'telephone_noReg'].includes(valiStatus) && validate && validate.vali_obj == 'mobile') {
|
|
279
|
+
handlecheckPhone(data);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (['DIGITAL'].includes(html_type)) {
|
|
283
|
+
hanldeOperational(data);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
handleTriggerCheck(data);
|
|
287
|
+
|
|
288
|
+
const formValueObj = JSON.parse(JSON.stringify({ ...editFormState.editForm}))
|
|
289
|
+
// 通讯事件
|
|
290
|
+
// if (eventType == "change") {
|
|
291
|
+
// this.autoVal = null;
|
|
292
|
+
// this.mainForm.formfieldOnChange(data);
|
|
293
|
+
// }
|
|
294
|
+
|
|
295
|
+
emit('hanldeFromBlur', { ...formValueObj });
|
|
296
|
+
|
|
297
|
+
// this.handleGetFieldsError(data.val_key);
|
|
298
|
+
}
|
|
299
|
+
const handleBirthdayToAge = (v: any) => {
|
|
300
|
+
const res: DateProp = {};
|
|
301
|
+
const curDateStr = v.format('YYYY-MM-DD');
|
|
302
|
+
const [year, month, day] = curDateStr.split('-');
|
|
303
|
+
const d = new Date();
|
|
304
|
+
const monthFloor = d.getMonth() + 1 < parseInt(month, 10) || (d.getMonth() + 1 == parseInt(month, 10) && d.getDate() < parseInt(day, 10)) ? 1 : 0;
|
|
305
|
+
let age = d.getFullYear() - parseInt(year, 10) - monthFloor;
|
|
306
|
+
if (age < 0) {
|
|
307
|
+
age = 0;
|
|
308
|
+
}
|
|
309
|
+
res.year = isNaN(age) ? '' : age;
|
|
310
|
+
res.day = moment(d).diff(moment(new Date(curDateStr)), 'days') || 0;
|
|
311
|
+
res.month = moment(d).diff(moment(new Date(curDateStr)), 'months') || 0;
|
|
312
|
+
return res;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 年龄组件的单位改变
|
|
316
|
+
* @param {String} val YEAR 、 MONTH、 DAY
|
|
317
|
+
* @param {Object} item
|
|
318
|
+
* @returns
|
|
319
|
+
*/
|
|
320
|
+
const changeAgeSelect = (val: string, item: any) => {
|
|
321
|
+
const values = val.toLowerCase();
|
|
322
|
+
const matchAgeItem = props.defaultFieldList.find((v: any) => v.html_type == 'AGE' && v.validate?.obj_type == 'age');
|
|
323
|
+
if (matchAgeItem && matchAgeItem.isFillAge) {
|
|
324
|
+
const mapList = props.defaultFieldList;
|
|
325
|
+
mapList.forEach((v: any) => {
|
|
326
|
+
const { validate, html_type } = v;
|
|
327
|
+
if (validate && validate.obj_type == 'age' && html_type == 'AGE') {
|
|
328
|
+
item.ageRes = v.ageRes;
|
|
329
|
+
hanldeSetFieldsValue(
|
|
330
|
+
{
|
|
331
|
+
[v.val_key]: v.ageRes[values]
|
|
332
|
+
},
|
|
333
|
+
v, props
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
} else {
|
|
338
|
+
if (!item.ageRes) return;
|
|
339
|
+
hanldeSetFieldsValue(
|
|
340
|
+
{
|
|
341
|
+
[item.val_key]: item.ageRes[values]
|
|
342
|
+
},
|
|
343
|
+
item,
|
|
344
|
+
props
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
nextTick(() => {
|
|
348
|
+
props.form.value?.validate(null, (rule: FormItemRule) => rule?.key === item.val_key)
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
/** 出生日期推算年龄的单位
|
|
352
|
+
* @param {Object} ageInfo {year: 0, day: 108, month: 3}
|
|
353
|
+
*/
|
|
354
|
+
const handleGetAgeUnit = (ageInfo = {}) => {
|
|
355
|
+
if (Object.keys(ageInfo || {}).length === 0) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const list = ['year', 'month', 'day'];
|
|
359
|
+
|
|
360
|
+
let f = list.find(v => ageInfo[v] > 0) || 'day';
|
|
361
|
+
return f;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* 设置年龄组件的单位
|
|
365
|
+
* @param {*} ageInfo
|
|
366
|
+
* @param {*} item
|
|
367
|
+
*/
|
|
368
|
+
const handleSetAgeUnit = (ageInfo: any, item: any) => {
|
|
369
|
+
let f = handleGetAgeUnit(ageInfo);
|
|
370
|
+
if (f && item.val_key_unit) {
|
|
371
|
+
f = f.toLocaleUpperCase();
|
|
372
|
+
hanldeSetFieldsValue({
|
|
373
|
+
[item.val_key_unit]: f
|
|
374
|
+
}, {}, props);
|
|
375
|
+
if (typeof changeAgeSelect === 'function') {
|
|
376
|
+
changeAgeSelect(f, item);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* @param v val 值
|
|
382
|
+
* @param i item 表单数据
|
|
383
|
+
* @param isDef 是否默认赋值
|
|
384
|
+
*/
|
|
385
|
+
const handleBirthday = (v: any, i: any, isDef = false) => {
|
|
386
|
+
let mapList = hanldeGetTargetList(i, props.defaultFieldList);
|
|
387
|
+
if (v && v.format) {
|
|
388
|
+
const birthdayInfo = handleBirthdayToAge(v);
|
|
389
|
+
mapList.forEach(item => {
|
|
390
|
+
const { validate } = item;
|
|
391
|
+
if (validate && validate.obj_type == 'age') {
|
|
392
|
+
let hasDef = handleSysParams(item.default_val || '', paramsObj) || props.defaultValue[item.name];
|
|
393
|
+
if (item.html_type != 'AGE_JSON') {
|
|
394
|
+
if (isDef) {
|
|
395
|
+
if (hasDef || [0, '0'].includes(hasDef) || isNaN(hasDef)) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
let values = 'year';
|
|
400
|
+
const curUnit = (item.val_key_unit && item.val_key_unit?.useFormValue) || '';
|
|
401
|
+
if (item.option && item.option.length > 0) {
|
|
402
|
+
values = curUnit?.toLowerCase() || item.option[0].value.toLowerCase();
|
|
403
|
+
}
|
|
404
|
+
item['ageRes'] = birthdayInfo
|
|
405
|
+
item['isFillAge'] = true
|
|
406
|
+
hanldeSetFieldsValue(
|
|
407
|
+
{
|
|
408
|
+
[item.val_key]: birthdayInfo[values]
|
|
409
|
+
},
|
|
410
|
+
item,
|
|
411
|
+
props
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
// 推算年龄的单位
|
|
415
|
+
handleSetAgeUnit(birthdayInfo, item);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (item.html_type == 'AGE_JSON') {
|
|
419
|
+
if (isDef) {
|
|
420
|
+
if (hasDef && hasDef.days > 0) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
const curDateStr = v.format('YYYY-MM-DD');
|
|
425
|
+
let obj = getAgeInfo(curDateStr);
|
|
426
|
+
hanldeSetFieldsValue({
|
|
427
|
+
[item.val_key]: { ...obj, days: birthdayInfo.day }
|
|
428
|
+
}, {}, props);
|
|
429
|
+
}
|
|
430
|
+
handlerInputBlur(item);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
} else {
|
|
434
|
+
mapList.forEach(item => {
|
|
435
|
+
const { validate } = item;
|
|
436
|
+
if (validate && validate.obj_type == 'age') {
|
|
437
|
+
item['useFormValue'] = ''
|
|
438
|
+
handlerInputBlur(item);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
// 设置身份证的信息
|
|
444
|
+
const handlerSetIdCarInfo = (data: any = {}) => {
|
|
445
|
+
const { validate } = data;
|
|
446
|
+
// 不是 field_toggle 的事件类型返回(默认触发不校验事件类型)
|
|
447
|
+
if (!validate) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const idCarItem = data;
|
|
451
|
+
let mapList = hanldeGetTargetList(data, props.defaultFieldList);
|
|
452
|
+
if (idCarItem) {
|
|
453
|
+
const idCarNo = idCarItem['val_key']?.useFormValue;
|
|
454
|
+
if (!idCarNo) {
|
|
455
|
+
if (validate.obj_type == 'id_card') {
|
|
456
|
+
mapList.forEach(item => {
|
|
457
|
+
const { validate } = item;
|
|
458
|
+
if (validate && (validate.obj_type == 'age' || validate.obj_type == 'sex' || validate.obj_type == 'birthday')) {
|
|
459
|
+
item['useFormValue'] = ''
|
|
460
|
+
handlerInputBlur(item);
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const pat = /^\d{6}(((19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\d{3}([0-9]|x|X))|(\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\d{3}))$/;
|
|
467
|
+
if (!pat.test(idCarNo)) {
|
|
468
|
+
if (validate.vali_obj == 'id_card') {
|
|
469
|
+
editFormState.editForm[idCarItem['val_key']] = idCarNo
|
|
470
|
+
// this.baseForm.setFields({
|
|
471
|
+
// [idCarItem['val_key']]: {
|
|
472
|
+
// value: idCarNo,
|
|
473
|
+
// errors: [
|
|
474
|
+
// {
|
|
475
|
+
// message: this.$t('1.1.7.32')
|
|
476
|
+
// }
|
|
477
|
+
// ]
|
|
478
|
+
// }
|
|
479
|
+
// });
|
|
480
|
+
if (validate.obj_type == 'id_card') {
|
|
481
|
+
mapList.forEach(item => {
|
|
482
|
+
const { validate } = item;
|
|
483
|
+
if (validate && (validate.obj_type == 'age' || validate.obj_type == 'sex' || validate.obj_type == 'birthday')) {
|
|
484
|
+
item['useFormValue'] = ''
|
|
485
|
+
handlerInputBlur(item);
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
// resetFields
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
if (validate.obj_type != 'id_card') return;
|
|
495
|
+
const idCarInfo = handlerGetIdcatInfo(idCarNo);
|
|
496
|
+
// 回填上
|
|
497
|
+
mapList.forEach(item => {
|
|
498
|
+
const { validate, html_type } = item;
|
|
499
|
+
if (validate && validate.obj_type == 'age') {
|
|
500
|
+
if (html_type != 'AGE_JSON') {
|
|
501
|
+
let values = 'year';
|
|
502
|
+
if (item.val_key_unit) {
|
|
503
|
+
const curUnit = editFormState.editForm[item.val_key_unit]
|
|
504
|
+
if (item.option && item.option.length > 0) {
|
|
505
|
+
values = curUnit?.toLowerCase() || item.option[0].value.toLowerCase();
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
item['ageRes'] = idCarInfo
|
|
509
|
+
item['isFillAge'] = true
|
|
510
|
+
hanldeSetFieldsValue(
|
|
511
|
+
{
|
|
512
|
+
[item.val_key]: idCarInfo[values]
|
|
513
|
+
},
|
|
514
|
+
item,
|
|
515
|
+
props
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
if (html_type == 'AGE_JSON') {
|
|
519
|
+
let v = moment(idCarInfo['birthday'], 'YYYY-MM-DD');
|
|
520
|
+
handleBirthday(v, item);
|
|
521
|
+
}
|
|
522
|
+
// 表单配置事件
|
|
523
|
+
handlerInputBlur(item);
|
|
524
|
+
} else if (validate && validate.obj_type == 'sex') {
|
|
525
|
+
hanldeSetFieldsValue(
|
|
526
|
+
{
|
|
527
|
+
[item.val_key]: idCarInfo['sex']
|
|
528
|
+
},
|
|
529
|
+
item,
|
|
530
|
+
props
|
|
531
|
+
);
|
|
532
|
+
// 表单配置事件
|
|
533
|
+
handlerInputBlur(item, idCarInfo['sex']);
|
|
534
|
+
} else if (validate && validate.obj_type == 'birthday') {
|
|
535
|
+
hanldeSetFieldsValue(
|
|
536
|
+
{
|
|
537
|
+
[item.val_key]: moment(idCarInfo['birthday'], 'YYYY-MM-DD')
|
|
538
|
+
},
|
|
539
|
+
item,
|
|
540
|
+
props
|
|
541
|
+
);
|
|
542
|
+
// 表单配置事件
|
|
543
|
+
handlerInputBlur(item, moment(idCarInfo['birthday'], 'YYYY-MM-DD'));
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
// 大陆/港澳台多种身份证及手机号校验
|
|
549
|
+
const checkMultipleIdCard = (data: any) => {
|
|
550
|
+
const {
|
|
551
|
+
group,
|
|
552
|
+
val_key,
|
|
553
|
+
validate: { obj_type }
|
|
554
|
+
} = data;
|
|
555
|
+
// let options = JSON.parse(this.$refs[phone_idcard_type].$attrs.optionData);
|
|
556
|
+
const is_PHONE_TYPE = obj_type == 'mobile' || obj_type == 'telephone';
|
|
557
|
+
const is_IDCARD_TYPE = obj_type == 'id_card';
|
|
558
|
+
const findHtmlType = is_PHONE_TYPE ? 'PHONE_TYPE' : is_IDCARD_TYPE ? 'IDCARD_TYPE' : '';
|
|
559
|
+
|
|
560
|
+
let targetItem = props.defaultFieldList.find((v: any) => v.html_type == findHtmlType);
|
|
561
|
+
if (!targetItem) return { status: `${obj_type}_noReg` };
|
|
562
|
+
const options = targetItem.option;
|
|
563
|
+
const selectedValue = targetItem.val_key?.useFormValue;
|
|
564
|
+
// let selectedText = options.filter(item => item.value === selectedValue)[0]
|
|
565
|
+
// .text;
|
|
566
|
+
let StrVal = String(selectedValue);
|
|
567
|
+
if (!selectedValue && StrVal !== '0') return { status: 'none' };
|
|
568
|
+
|
|
569
|
+
const regKey = obj_type === 'id_card' ? 'reg' : obj_type === 'mobile' ? 'mobileReg' : 'telephoneReg';
|
|
570
|
+
const findList = options.filter((item: any) => item.value == selectedValue);
|
|
571
|
+
if (!findList[0]) return { status: 'noOptions' };
|
|
572
|
+
const selectedRegStr = findList[0][regKey];
|
|
573
|
+
const selectedReg = new RegExp(selectedRegStr);
|
|
574
|
+
const checkingInput = val_key?.useFormValue;
|
|
575
|
+
if (!checkingInput) return { status: 'noPass' };
|
|
576
|
+
if (!selectedReg.test(checkingInput)) {
|
|
577
|
+
editFormState.editForm[val_key] = checkingInput
|
|
578
|
+
// props.form.value.setFields({
|
|
579
|
+
// [val_key]: {
|
|
580
|
+
// value: checkingInput,
|
|
581
|
+
// errors: [
|
|
582
|
+
// {
|
|
583
|
+
// message: `请输入正确的号码`
|
|
584
|
+
// }
|
|
585
|
+
// ]
|
|
586
|
+
// }
|
|
587
|
+
// });
|
|
588
|
+
return { status: 'noPass' };
|
|
589
|
+
} else {
|
|
590
|
+
editFormState.editForm[val_key] = checkingInput
|
|
591
|
+
// this.baseForm.setFields({
|
|
592
|
+
// [val_key]: {
|
|
593
|
+
// value: checkingInput
|
|
594
|
+
// }
|
|
595
|
+
// });
|
|
596
|
+
if (selectedValue === 'CN') {
|
|
597
|
+
handlerSetIdCarInfo(data);
|
|
598
|
+
}
|
|
599
|
+
return { status: 'pass' };
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const defaultInit = () => {
|
|
604
|
+
// this.formFieldListCopy = JSON.parse(JSON.stringify(this.formFieldList));
|
|
605
|
+
const { validate = {}, name, default_val } = props.item;
|
|
606
|
+
let targetStr = props.defaultValue[name] || default_val;
|
|
607
|
+
targetStr = handleSysParams(targetStr, paramsObj);
|
|
608
|
+
if (['last_menstrual'].includes(validate.obj_type)) {
|
|
609
|
+
targetStr && handlerInputBlur(props.item, moment(targetStr));
|
|
610
|
+
} else if (['birthday'].includes(validate.obj_type)) {
|
|
611
|
+
targetStr && handleBirthday(moment(targetStr), props.item, true);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// 默认值有值触发表单绑定的事件。
|
|
615
|
+
// if (this.$utils.notEmpty(targetStr)) {
|
|
616
|
+
// this.handlerInputBlur(this.item, null, "blur", { eventType: "init" });
|
|
617
|
+
// }
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// 普通下拉框设置open值
|
|
621
|
+
const dropdownVisibleChange = (e: boolean) => {
|
|
622
|
+
nextTick(() => {
|
|
623
|
+
open.value = e;
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
onMounted(() => {
|
|
628
|
+
nextTick(() => {
|
|
629
|
+
defaultInit()
|
|
630
|
+
})
|
|
631
|
+
})
|
|
632
|
+
|
|
633
|
+
return {
|
|
634
|
+
open,
|
|
635
|
+
dropdownVisibleChange,
|
|
636
|
+
handlerInputBlur
|
|
637
|
+
}
|
|
638
|
+
}
|