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,910 @@
|
|
|
1
|
+
import { reactive, ref, inject, onMounted, nextTick, computed } from 'vue'
|
|
2
|
+
import axios from 'axios'
|
|
3
|
+
import qs from 'qs'
|
|
4
|
+
import vexutils from '@/utils/vexutils';
|
|
5
|
+
import { handleSysParams, handleGetJsonStr } from '../utils'
|
|
6
|
+
import { hanldeSetFieldsValue } from './useItemDefault'
|
|
7
|
+
import type { SelectOption } from 'naive-ui'
|
|
8
|
+
|
|
9
|
+
const SELECT_LIST = ["SEARCH_MORE", "SEARCH", "SEARCH_CASCADE", "LEVEL_SEARCH_CASCADE"];
|
|
10
|
+
|
|
11
|
+
interface Option {
|
|
12
|
+
rowData?: any
|
|
13
|
+
keyword?: string
|
|
14
|
+
wordbook?: any
|
|
15
|
+
fieldList?: any
|
|
16
|
+
myUniqueKey?: any
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const useSearch = (props: any, emit: any, handlerInputBlur: Function) => {
|
|
20
|
+
const editFormState: any = inject('state')
|
|
21
|
+
const userInfo: any = inject('userInfo')
|
|
22
|
+
const paramsObj = { defaultValue: props.defaultValue, userInfo: userInfo.value, dbParams: props.dbParams }
|
|
23
|
+
const itemRef: any = ref(null)
|
|
24
|
+
|
|
25
|
+
const selectIsOpen = computed(() => {
|
|
26
|
+
const { html_type, show_type } = props.item;
|
|
27
|
+
if (['SEARCH_MORE', 'SEARCH'].includes(html_type)) {
|
|
28
|
+
return !['pop', 'dialog'].includes(show_type);
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const state = reactive({
|
|
34
|
+
fetching: false,
|
|
35
|
+
timeout: null as any,
|
|
36
|
+
curOptions: [] as any[],
|
|
37
|
+
selectedOptions: [] as any[],
|
|
38
|
+
levelNum: 1, // 级联来加载 层级标识 从 1 开始。
|
|
39
|
+
cascaderInitLabel: true,
|
|
40
|
+
defList: [] as any[],
|
|
41
|
+
panelOpen: false,
|
|
42
|
+
searchAddObj: {},
|
|
43
|
+
searchPageConfig: {
|
|
44
|
+
// search 翻页配置
|
|
45
|
+
keyword: undefined as (string | undefined),
|
|
46
|
+
isFetching: false,
|
|
47
|
+
isRequest: false, // 是否已请求
|
|
48
|
+
page: 1, // 当前页
|
|
49
|
+
total: 1 // 总页数
|
|
50
|
+
},
|
|
51
|
+
optionsMaxWidth: "100%",
|
|
52
|
+
cacheReqOptionsParams: "",
|
|
53
|
+
hotSearchConfig: {
|
|
54
|
+
hotList: [],
|
|
55
|
+
latestList: [],
|
|
56
|
+
isRequest: false,
|
|
57
|
+
isclose: true
|
|
58
|
+
},
|
|
59
|
+
searchShowHotList: false.valueOf,
|
|
60
|
+
optionsRequestSource: {} as any,
|
|
61
|
+
loadDataPrimary_key: null as any,
|
|
62
|
+
dropdownHide: false,
|
|
63
|
+
noAllow_check_mid_level: false,
|
|
64
|
+
Choose_to_complete: false
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const setCurOptions = (options: any[]) => {
|
|
68
|
+
return options.map((v: any, i: number) => {
|
|
69
|
+
return {
|
|
70
|
+
...v,
|
|
71
|
+
value: `${v[props.item.wordbook.value_key]}>>>${v['myUniqueKey']}`,
|
|
72
|
+
label: hanlderGetSearchLabel(props.item, v),
|
|
73
|
+
disabled: i === 0 && props.item.wordbook.render_key && props.item.wordbook.render_key.length > 1,
|
|
74
|
+
index: i
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 检索的默认参数
|
|
80
|
+
* @param keyword 检索关键字
|
|
81
|
+
* @param itemData 表单配置项
|
|
82
|
+
*/
|
|
83
|
+
const getSearchDefParams = (keyword: string, itemData: any = {}, other: any = {}) => {
|
|
84
|
+
const { wordbook, html_type, autograph } = itemData;
|
|
85
|
+
const isCascade = html_type.includes("SEARCH_CASCADE");
|
|
86
|
+
const fieldKeys = wordbook.fieldKeys || wordbook.search_key;
|
|
87
|
+
let conObj = wordbook.conObj;
|
|
88
|
+
// if (Array.isArray(conObj)) {
|
|
89
|
+
// conObj.forEach(v => {
|
|
90
|
+
// v.value = this.handleSysParams(v.value);
|
|
91
|
+
// });
|
|
92
|
+
// }
|
|
93
|
+
// let SEARCH_CASCADE
|
|
94
|
+
const extraParams = {
|
|
95
|
+
primaryKey: wordbook.primary_key,
|
|
96
|
+
levelKey: wordbook.level_key
|
|
97
|
+
};
|
|
98
|
+
const pageSizeConfig = {
|
|
99
|
+
pageSize: isCascade ? 10000 : 20
|
|
100
|
+
};
|
|
101
|
+
// 请求参数
|
|
102
|
+
const params = {
|
|
103
|
+
wordbookId: wordbook.id,
|
|
104
|
+
autograph: autograph,
|
|
105
|
+
wordbookType: wordbook.type || "WORDBOOK",
|
|
106
|
+
preConObj: wordbook.preConObj ? JSON.stringify(wordbook.preConObj) : undefined,
|
|
107
|
+
conObj: conObj ? JSON.stringify(conObj) : undefined,
|
|
108
|
+
preSqlExpression: wordbook.preSqlExpression || undefined,
|
|
109
|
+
sqlExpression: wordbook.sqlExpression || undefined,
|
|
110
|
+
fieldKeys: fieldKeys ? JSON.stringify(fieldKeys) : undefined,
|
|
111
|
+
keyword: keyword || "",
|
|
112
|
+
// pageSize: isCascade ? 10000 : 20,
|
|
113
|
+
page: 1,
|
|
114
|
+
...(isCascade ? extraParams : {}),
|
|
115
|
+
...(isCascade ? pageSizeConfig : {}) // 不是“级联”类型的,后台读取列表配置的 “pageSize”
|
|
116
|
+
};
|
|
117
|
+
// 分页
|
|
118
|
+
if (other.page) {
|
|
119
|
+
params.page = other.page;
|
|
120
|
+
state.searchPageConfig.isFetching = true;
|
|
121
|
+
}
|
|
122
|
+
return params;
|
|
123
|
+
}
|
|
124
|
+
const handleQueryParams = (formData: any, queryParams: any) => {
|
|
125
|
+
let tempFormData = {};
|
|
126
|
+
if (queryParams.length) {
|
|
127
|
+
queryParams.forEach((v: any) => {
|
|
128
|
+
if (v in formData) {
|
|
129
|
+
tempFormData[v] = formData[v];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return tempFormData;
|
|
134
|
+
}
|
|
135
|
+
const handleRequestedUniqueKey = (id: string) => {
|
|
136
|
+
const starTiem = +new Date();
|
|
137
|
+
|
|
138
|
+
const getUniqueKey = (resolve: Function, reject: Function) => {
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
const res = props.cacheUniqueKey?.[id];
|
|
141
|
+
if (res && res.status) {
|
|
142
|
+
resolve(res.value);
|
|
143
|
+
} else {
|
|
144
|
+
let curTime = +new Date();
|
|
145
|
+
if (curTime - starTiem > 5000) {
|
|
146
|
+
reject("获取UniqueKe 异常!!");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
getUniqueKey(resolve, reject);
|
|
150
|
+
}
|
|
151
|
+
}, 16);
|
|
152
|
+
};
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
getUniqueKey(resolve, reject);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// 取消请求 handleRequestedOptions
|
|
158
|
+
const cancelOptionsRequest = () => {
|
|
159
|
+
if (state.optionsRequestSource && typeof state.optionsRequestSource.cancel === "function") {
|
|
160
|
+
// 取消请求
|
|
161
|
+
state.optionsRequestSource.cancel("请求已取消!");
|
|
162
|
+
state.optionsRequestSource = null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 检索框切换分页,滚动条置顶
|
|
167
|
+
*/
|
|
168
|
+
const handleSearchScrollTop = (item: any) => {
|
|
169
|
+
try {
|
|
170
|
+
let c = `.search-menu-${item.val_key}`;
|
|
171
|
+
let list = document.querySelectorAll(c);
|
|
172
|
+
list.forEach(v => {
|
|
173
|
+
let u = v.querySelector(".ant-select-dropdown-menu");
|
|
174
|
+
if (u) {
|
|
175
|
+
u.scrollTop = 0;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.log(error, "handleSearchScrollTop");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const hanldeRemoveDuplicates = (list = [], config: any = {}) => {
|
|
183
|
+
if (!Array.isArray(list)) return [];
|
|
184
|
+
const { key } = config;
|
|
185
|
+
let obj: any = {};
|
|
186
|
+
if (!key) return list;
|
|
187
|
+
|
|
188
|
+
let resList = list.reduce((cur, next) => {
|
|
189
|
+
obj[next[key]] ? "" : (obj[next[key]] = true && cur.push(next));
|
|
190
|
+
return cur;
|
|
191
|
+
}, []);
|
|
192
|
+
|
|
193
|
+
return [...resList];
|
|
194
|
+
}
|
|
195
|
+
const hanldeGetCascadelabel = (v = [], k = {}) => {
|
|
196
|
+
if (Array.isArray(v) && v.length) {
|
|
197
|
+
const l: string[] = [];
|
|
198
|
+
v.forEach(i => {
|
|
199
|
+
l.push(k[i]);
|
|
200
|
+
});
|
|
201
|
+
return l.join("_");
|
|
202
|
+
}
|
|
203
|
+
return "";
|
|
204
|
+
}
|
|
205
|
+
// 处理级联数据
|
|
206
|
+
const handleFormCascade = (list = [], v: any = {}, level = 1) => {
|
|
207
|
+
list.forEach((item: any) => {
|
|
208
|
+
item.myLabel = hanldeGetCascadelabel(v.render_key, item) || item[v["value_key"]];
|
|
209
|
+
item.myUniqueKey = item[v.myUniqueKey];
|
|
210
|
+
item.myUniqueLabel = v.myUniqueKey;
|
|
211
|
+
if (v.isLoadData) {
|
|
212
|
+
item.isLeaf = v.level_num ? state.levelNum >= v.level_num : false;
|
|
213
|
+
} else {
|
|
214
|
+
if (level >= v.level_num) {
|
|
215
|
+
delete item.children;
|
|
216
|
+
}
|
|
217
|
+
if (item.children && item.children.length) {
|
|
218
|
+
handleFormCascade(item.children, v, level + 1);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
const handleCalculateOptionsMaxWidth = () => {
|
|
224
|
+
if (!SELECT_LIST.includes(props.item?.html_type || undefined)) return;
|
|
225
|
+
nextTick(() => {
|
|
226
|
+
const $el = itemRef.value.$el
|
|
227
|
+
const offsetWidth = $el.offsetWidth;
|
|
228
|
+
let res = offsetWidth,
|
|
229
|
+
maxwith;
|
|
230
|
+
try {
|
|
231
|
+
let item = $el.querySelector(".ant-select");
|
|
232
|
+
const itemRect = item.getBoundingClientRect();
|
|
233
|
+
let baseDom = props.form.$el.querySelector(".base-form");
|
|
234
|
+
const baseRect = baseDom.getBoundingClientRect();
|
|
235
|
+
maxwith = baseRect.right - itemRect.left;
|
|
236
|
+
|
|
237
|
+
if (typeof offsetWidth === "number" && isFinite(maxwith)) {
|
|
238
|
+
if (maxwith > offsetWidth) {
|
|
239
|
+
res = maxwith;
|
|
240
|
+
} else {
|
|
241
|
+
res = offsetWidth;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (error) {
|
|
245
|
+
res = offsetWidth;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
res = parseInt(res, 10);
|
|
249
|
+
state.optionsMaxWidth = `${res}px`;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
const handlerSearchOnFocus = (item: any) => {
|
|
253
|
+
if (selectIsOpen.value) return;
|
|
254
|
+
let { queryParamsType, queryParams = [] } = item.wordbook || {};
|
|
255
|
+
// setTimeout(() => {
|
|
256
|
+
nextTick(() => {
|
|
257
|
+
// this.selsectVisible = true;
|
|
258
|
+
let formData = editFormState.editForm;
|
|
259
|
+
let params = formData;
|
|
260
|
+
if (queryParamsType == 1) {
|
|
261
|
+
params = handleQueryParams(formData, queryParams);
|
|
262
|
+
}
|
|
263
|
+
// 弹窗列表选项事件推出
|
|
264
|
+
emit("opentableSelect", true, props.item, params);
|
|
265
|
+
});
|
|
266
|
+
// }, 300);
|
|
267
|
+
}
|
|
268
|
+
const handleCascaderTracher = () =>{
|
|
269
|
+
if (!state.Choose_to_complete) return;
|
|
270
|
+
const CASCADELIST = ["LEVEL_SEARCH_CASCADE", "SEARCH_CASCADE"];
|
|
271
|
+
nextTick(() => {
|
|
272
|
+
if (!CASCADELIST.includes(props.item.html_type)) return;
|
|
273
|
+
if (Array.isArray(state.selectedOptions) && state.selectedOptions.length > 0) {
|
|
274
|
+
let val = editFormState.editForm[props.item.val_key];
|
|
275
|
+
let keyword = "";
|
|
276
|
+
if (vexutils.isJSON(val)) {
|
|
277
|
+
keyword = JSON.parse(val)?.objStr || "";
|
|
278
|
+
}
|
|
279
|
+
if (!keyword) return;
|
|
280
|
+
// this.handleSearchTracher(item, {
|
|
281
|
+
// select: val,
|
|
282
|
+
// keyword: keyword
|
|
283
|
+
// });
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
state.Choose_to_complete = false;
|
|
287
|
+
}
|
|
288
|
+
const handlerDropdownVisibleChange = (show: boolean, data : any) => {
|
|
289
|
+
const searchList = ["SEARCH_MORE", "SEARCH"];
|
|
290
|
+
if (show) {
|
|
291
|
+
handleCalculateOptionsMaxWidth();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let isRequest = true;
|
|
295
|
+
|
|
296
|
+
if (state.optionsMaxWidth === "100%") {
|
|
297
|
+
// 100% 是默认值,如果已经计算过了,不用再算
|
|
298
|
+
handleCalculateOptionsMaxWidth();
|
|
299
|
+
}
|
|
300
|
+
state.dropdownHide = !show;
|
|
301
|
+
if (Object.keys(data || {}).length > 0) {
|
|
302
|
+
const searchList = ["SEARCH_CASCADE", "LEVEL_SEARCH_CASCADE"];
|
|
303
|
+
if (searchList.includes(data.html_type)) {
|
|
304
|
+
isRequest = !(state.curOptions && state.curOptions.length);
|
|
305
|
+
}
|
|
306
|
+
if (show && ["SEARCH_MORE", "SEARCH"].includes(data.html_type)) {
|
|
307
|
+
handlerSearchOnFocus(data);
|
|
308
|
+
}
|
|
309
|
+
if (show && isRequest) {
|
|
310
|
+
handleRequestedOptions(data);
|
|
311
|
+
}
|
|
312
|
+
if (!show && state.noAllow_check_mid_level && searchList.includes(data.html_type)) {
|
|
313
|
+
setTimeout(() => {
|
|
314
|
+
data['useFormValue'] = null
|
|
315
|
+
}, 16);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (!show) {
|
|
320
|
+
// 弹窗关闭才收集级联“常用”值,避免还没选完重复提交。
|
|
321
|
+
handleCascaderTracher();
|
|
322
|
+
setTimeout(() => {
|
|
323
|
+
state.searchPageConfig.keyword = undefined;
|
|
324
|
+
}, 300);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/* 解析下拉选择接口返回字段 */
|
|
328
|
+
const formatField = (value: string | any) => {
|
|
329
|
+
let res = value;
|
|
330
|
+
try {
|
|
331
|
+
if (res && typeof res == "string" && res.startsWith("###")) {
|
|
332
|
+
res = res.slice(3);
|
|
333
|
+
res = JSON.parse(res);
|
|
334
|
+
res = res.change_text;
|
|
335
|
+
}
|
|
336
|
+
return res || "";
|
|
337
|
+
} catch (error) {
|
|
338
|
+
return "";
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/* 解析下拉选择接口返回字段 直接改变原有的 */
|
|
342
|
+
const formatFieldValue = (value: string | any) => {
|
|
343
|
+
try {
|
|
344
|
+
if (value && typeof value == "string" && value.startsWith("###")) {
|
|
345
|
+
value = value.slice(3);
|
|
346
|
+
value = JSON.parse(value);
|
|
347
|
+
value = value.value;
|
|
348
|
+
}
|
|
349
|
+
return value || "";
|
|
350
|
+
} catch (error) {
|
|
351
|
+
console.log(error);
|
|
352
|
+
return "";
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* 检索请求去重,自定义处理
|
|
357
|
+
* @param rows list
|
|
358
|
+
* @param itemData 表单配置项
|
|
359
|
+
* @param uniqueConfig 唯一标识配置
|
|
360
|
+
*/
|
|
361
|
+
const handleRowUnique = (rows: any[], itemData: any, uniqueConfig: any = {}) => {
|
|
362
|
+
const { myUniqueKey, reqUniqueKey } = uniqueConfig;
|
|
363
|
+
const { wordbook } = itemData;
|
|
364
|
+
return rows.reduce((acc, cur) => {
|
|
365
|
+
cur.setting = wordbook.setting;
|
|
366
|
+
cur.showLabel = "";
|
|
367
|
+
cur.myUniqueKey = cur[myUniqueKey] || "";
|
|
368
|
+
cur.myUniqueLabel = reqUniqueKey || "";
|
|
369
|
+
if (wordbook.render_key && wordbook.render_key.length > 0) {
|
|
370
|
+
wordbook.render_key.forEach((ren: string) => {
|
|
371
|
+
cur.showLabel += `≌${formatField(cur[ren])}`;
|
|
372
|
+
});
|
|
373
|
+
cur.showLabel = cur.showLabel.slice(1);
|
|
374
|
+
} else {
|
|
375
|
+
cur.showLabel = cur[wordbook.value_key];
|
|
376
|
+
}
|
|
377
|
+
if (typeof cur === "object") {
|
|
378
|
+
Object.keys(cur || {}).forEach(t => (cur[t] = formatFieldValue(cur[t])));
|
|
379
|
+
}
|
|
380
|
+
return acc.some((v: any) => {
|
|
381
|
+
return (
|
|
382
|
+
`${v[wordbook.value_key]}-${v[myUniqueKey]}` ==
|
|
383
|
+
`${cur[wordbook.value_key]}-${cur[myUniqueKey]}`
|
|
384
|
+
);
|
|
385
|
+
})
|
|
386
|
+
? acc
|
|
387
|
+
: [...acc, cur];
|
|
388
|
+
}, []);
|
|
389
|
+
}
|
|
390
|
+
// 下拉搜索框获取字段title
|
|
391
|
+
const getTitleHeader = (fieldList: any[], renderKey: any) => {
|
|
392
|
+
let titleHeader = "";
|
|
393
|
+
let renderKeyArr = [];
|
|
394
|
+
if (Array.isArray(renderKey)) {
|
|
395
|
+
renderKeyArr = [...renderKey];
|
|
396
|
+
} else {
|
|
397
|
+
renderKeyArr = [renderKey];
|
|
398
|
+
}
|
|
399
|
+
renderKeyArr.forEach(render => {
|
|
400
|
+
for (let i = 0; i < fieldList.length; i++) {
|
|
401
|
+
if (render === fieldList[i].columnName) {
|
|
402
|
+
titleHeader += `≌${fieldList[i].title}`;
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
titleHeader = titleHeader.slice(1);
|
|
408
|
+
return titleHeader;
|
|
409
|
+
}
|
|
410
|
+
// 搜索框选中
|
|
411
|
+
const handleSearchSelect = (value: string, option: any, type: string, eventConfig: any) => {
|
|
412
|
+
const setList = option?.bindEventSetting || [];
|
|
413
|
+
const isInit = "init" === eventConfig?.eventType;
|
|
414
|
+
const formData = editFormState.editForm;
|
|
415
|
+
// 如果有绑定事件,先触发绑定的事件。
|
|
416
|
+
try {
|
|
417
|
+
if (Array.isArray(setList)) {
|
|
418
|
+
handlerInputBlur(option, null, "blur", eventConfig);
|
|
419
|
+
}
|
|
420
|
+
} catch (err) {
|
|
421
|
+
console.log(err);
|
|
422
|
+
}
|
|
423
|
+
// hasOwnProperty
|
|
424
|
+
const searchOption = state.curOptions;
|
|
425
|
+
// 当前选中的对象
|
|
426
|
+
let selectItem: any = searchOption.find(
|
|
427
|
+
ele => `${ele[option.wordbook.value_key]}>>>${ele["myUniqueKey"]}` === value
|
|
428
|
+
);
|
|
429
|
+
// 标识是自由输入的值
|
|
430
|
+
const is_free = selectItem?.is_free_entry_input__add || false;
|
|
431
|
+
// 自由输入的 数据是前端生成的要清空,避免”带出“事件赋值
|
|
432
|
+
if (is_free) {
|
|
433
|
+
selectItem = {};
|
|
434
|
+
}
|
|
435
|
+
const setting = option?.wordbook?.setting || {};
|
|
436
|
+
// if (Object.keys(selectItem || {}).length > 0 && type === "select") {
|
|
437
|
+
// this.hanlderSendSelectLog(option, selectItem);
|
|
438
|
+
// }
|
|
439
|
+
|
|
440
|
+
if (selectItem && setting) {
|
|
441
|
+
Object.keys(selectItem).forEach(s => {
|
|
442
|
+
if (
|
|
443
|
+
selectItem[s] &&
|
|
444
|
+
typeof selectItem[s] == "string" &&
|
|
445
|
+
selectItem[s].startsWith("###")
|
|
446
|
+
) {
|
|
447
|
+
selectItem[s] = selectItem[s].slice(3);
|
|
448
|
+
selectItem[s] = JSON.parse(selectItem[s]);
|
|
449
|
+
selectItem[s] = selectItem[s].value;
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
const multipleSelect = (e: any, item: any) => {
|
|
455
|
+
const valKey = item.wordbook.value_key;
|
|
456
|
+
const selectList: any[] = state.selectedOptions || [];
|
|
457
|
+
const isSelect = selectList.some(v => `${v[valKey]}-${v["myUniqueKey"]}` == e.key);
|
|
458
|
+
let selectItem = {};
|
|
459
|
+
if (!isSelect) {
|
|
460
|
+
const fdItem = state.curOptions.find(v => `${v[valKey]}-${v["myUniqueKey"]}` == e.key) || {};
|
|
461
|
+
selectList.push({ ...fdItem });
|
|
462
|
+
selectItem = fdItem;
|
|
463
|
+
}
|
|
464
|
+
state.selectedOptions = [...selectList];
|
|
465
|
+
emit("valueOnChange", [...selectList], item);
|
|
466
|
+
// this.hanlderSendSelectLog(item, selectItem);
|
|
467
|
+
handlerInputBlur(item, null, 'blur');
|
|
468
|
+
}
|
|
469
|
+
const multipleDeselect = (e: any, item: any) => {
|
|
470
|
+
const valKey = item.wordbook.value_key;
|
|
471
|
+
const selectList = state.selectedOptions || [];
|
|
472
|
+
const fnIndex = selectList.findIndex(v => `${v[valKey]}-${v["myUniqueKey"]}` == e.key);
|
|
473
|
+
if (fnIndex != -1) {
|
|
474
|
+
selectList.splice(fnIndex, 1);
|
|
475
|
+
}
|
|
476
|
+
state.selectedOptions = [...selectList];
|
|
477
|
+
emit("valueOnChange", [...selectList], item);
|
|
478
|
+
}
|
|
479
|
+
const searchMoreOnChange = (value: any, item: any) => {
|
|
480
|
+
// 此处是否需要添加ant 中的select事件和deselect事件
|
|
481
|
+
// if (value?.length) {
|
|
482
|
+
// multipleSelect(value[value.length - 1], props.item) // 或者执行multipleDeselect()
|
|
483
|
+
// }
|
|
484
|
+
// 标识用户有修改该值。
|
|
485
|
+
editFormState.formType[item.val_key].isOnchange = "00";
|
|
486
|
+
if (!value || value.length === 0) {
|
|
487
|
+
emit("valueOnChange", [], item);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// 通讯事件
|
|
491
|
+
// this.mainForm.formfieldOnChange(this.item);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* 检索默认值处理
|
|
495
|
+
* @param defFalg 是否默认值处理
|
|
496
|
+
* @param rowData 请求数据
|
|
497
|
+
* @param itemData 表单配置项
|
|
498
|
+
* @param uniqueConfig 唯一标识配置
|
|
499
|
+
*/
|
|
500
|
+
const handleGetSearchDefVal = (defFalg: boolean, rowData: any[], itemData: any, uniqueConfig: any = {}) => {
|
|
501
|
+
const { is_plugin_set, keyword } = uniqueConfig;
|
|
502
|
+
const { wordbook, html_type, val_key, default_val, name } = itemData;
|
|
503
|
+
let defVal = props.defaultValue[name] || handleSysParams(default_val || "", paramsObj);
|
|
504
|
+
if (is_plugin_set) {
|
|
505
|
+
defVal = keyword;
|
|
506
|
+
}
|
|
507
|
+
if (defFalg && rowData.length) {
|
|
508
|
+
let defItem = rowData[0];
|
|
509
|
+
let itemKkey = `${defItem[wordbook.value_key]}>>>${defItem["myUniqueKey"]}`;
|
|
510
|
+
if (html_type == "SEARCH") {
|
|
511
|
+
const f = rowData.find(r => r[wordbook.value_key] == defVal);
|
|
512
|
+
if (f) {
|
|
513
|
+
defItem = f;
|
|
514
|
+
itemKkey = `${f[wordbook.value_key]}>>>${f["myUniqueKey"]}`;
|
|
515
|
+
handleSearchSelect(itemKkey, itemData, "", {
|
|
516
|
+
eventType: defFalg ? "init" : "trigger"
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
if (defVal != defItem[wordbook.value_key]) {
|
|
520
|
+
if (f) {
|
|
521
|
+
itemKkey = `${f[wordbook.value_key]}>>>${f["myUniqueKey"]}`;
|
|
522
|
+
} else {
|
|
523
|
+
itemKkey = defVal;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
if (itemKkey) {
|
|
527
|
+
hanldeSetFieldsValue(
|
|
528
|
+
{
|
|
529
|
+
[itemData.val_key]: itemKkey
|
|
530
|
+
},
|
|
531
|
+
itemData,
|
|
532
|
+
props
|
|
533
|
+
);
|
|
534
|
+
} else {
|
|
535
|
+
itemData['useFormValue'] = undefined
|
|
536
|
+
}
|
|
537
|
+
} else if (html_type == "SEARCH_MORE") {
|
|
538
|
+
itemKkey.replace(">>>", "-");
|
|
539
|
+
hanldeSetFieldsValue(
|
|
540
|
+
{
|
|
541
|
+
[itemData.val_key]: [
|
|
542
|
+
{
|
|
543
|
+
key: itemKkey,
|
|
544
|
+
label: defItem["showLabel"] || defItem[wordbook.value_key]
|
|
545
|
+
}
|
|
546
|
+
]
|
|
547
|
+
},
|
|
548
|
+
itemData,
|
|
549
|
+
props
|
|
550
|
+
);
|
|
551
|
+
multipleSelect(
|
|
552
|
+
{
|
|
553
|
+
key: itemKkey,
|
|
554
|
+
label: defItem["showLabel"] || defItem[wordbook.value_key]
|
|
555
|
+
},
|
|
556
|
+
itemData
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
} else if (defFalg) {
|
|
560
|
+
if (html_type == "SEARCH") {
|
|
561
|
+
// bugfix:14178
|
|
562
|
+
hanldeSetFieldsValue(
|
|
563
|
+
{
|
|
564
|
+
[itemData.val_key]: undefined
|
|
565
|
+
},
|
|
566
|
+
itemData,
|
|
567
|
+
props
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const handleFreeEntry = (option: Option = {}) => {
|
|
573
|
+
const { rowData, keyword, wordbook, fieldList, myUniqueKey } = option;
|
|
574
|
+
if (!keyword) return;
|
|
575
|
+
const curKey = +new Date();
|
|
576
|
+
const data = {
|
|
577
|
+
[myUniqueKey]: curKey,
|
|
578
|
+
myUniqueKey: curKey,
|
|
579
|
+
myUniqueLabel: myUniqueKey,
|
|
580
|
+
[wordbook.value_key]: keyword,
|
|
581
|
+
is_free_entry_input__add: true // 标识是自由输入
|
|
582
|
+
};
|
|
583
|
+
const hasRenderKey = wordbook.render_key && wordbook.render_key.length > 1;
|
|
584
|
+
if (rowData.length === 0) {
|
|
585
|
+
state.curOptions = [];
|
|
586
|
+
if (hasRenderKey) {
|
|
587
|
+
rowData.unshift({
|
|
588
|
+
showLabel: getTitleHeader(fieldList, wordbook.render_key),
|
|
589
|
+
myUniqueKey: Math.random()
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
hasRenderKey ? rowData.splice(1, 0, data) : rowData.unshift(data);
|
|
594
|
+
state.curOptions = setCurOptions(rowData);
|
|
595
|
+
}
|
|
596
|
+
// 请求下拉框的数据
|
|
597
|
+
const handleRequestedOptions = async (
|
|
598
|
+
itemData: any = {},
|
|
599
|
+
keyword: string = '',
|
|
600
|
+
defFalg = false,
|
|
601
|
+
otherConfig: any = {}
|
|
602
|
+
) => {
|
|
603
|
+
const closeLoading = () => {
|
|
604
|
+
state.fetching = false;
|
|
605
|
+
state.searchPageConfig.isFetching = false;
|
|
606
|
+
};
|
|
607
|
+
try {
|
|
608
|
+
const { wordbook = {}, val_key, html_type, free_entry } = itemData;
|
|
609
|
+
let { queryParamsType, queryParams = [] } = wordbook;
|
|
610
|
+
if (Object.keys(wordbook || {}).length === 0) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (keyword && typeof keyword === "string") keyword = keyword.replace(/^\s+|\s+$/, "");
|
|
614
|
+
// LEVEL_SEARCH_CASCADE SEARCH_CASCADE
|
|
615
|
+
const isCascade = html_type.includes("SEARCH_CASCADE");
|
|
616
|
+
const NOWORDBOOK = wordbook.type != "WORDBOOK";
|
|
617
|
+
const ISDICTIONARY = wordbook.type === "DICTIONARY";
|
|
618
|
+
// 请求参数
|
|
619
|
+
let params = getSearchDefParams(keyword, itemData, otherConfig);
|
|
620
|
+
|
|
621
|
+
let formData = editFormState.editForm;
|
|
622
|
+
|
|
623
|
+
let queryArr = [
|
|
624
|
+
"SEARCH",
|
|
625
|
+
"SEARCH_MORE",
|
|
626
|
+
"SEARCH_CASCADE",
|
|
627
|
+
"LEVEL_SEARCH_CASCADE",
|
|
628
|
+
"LEVEL_SEARCH_CASCADE2"
|
|
629
|
+
];
|
|
630
|
+
if (queryArr.includes(html_type) && queryParamsType == 1) {
|
|
631
|
+
let tempFormData = handleQueryParams(formData, queryParams);
|
|
632
|
+
Object.assign(params, tempFormData);
|
|
633
|
+
} else {
|
|
634
|
+
Object.assign(params, formData);
|
|
635
|
+
}
|
|
636
|
+
// 257 云his需求新增通用字典 后端欧阳 产品晶晶
|
|
637
|
+
const arr = ["SEARCH", "SEARCH_MORE"];
|
|
638
|
+
if (arr.includes(html_type) && ISDICTIONARY) {
|
|
639
|
+
Object.assign(params, {
|
|
640
|
+
dictType: JSON.stringify(wordbook.dictType)
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
state.cacheReqOptionsParams = JSON.stringify(params);
|
|
644
|
+
let reqUniqueKey: any;
|
|
645
|
+
let myUniqueKey: string | undefined = "theUniqueKey";
|
|
646
|
+
if (NOWORDBOOK) {
|
|
647
|
+
reqUniqueKey = await handleRequestedUniqueKey(wordbook.id);
|
|
648
|
+
myUniqueKey = reqUniqueKey || undefined;
|
|
649
|
+
}
|
|
650
|
+
// 多选检索框避免重复选中 "theUniqueKey" 这个值,每次请求返回来都不一样。
|
|
651
|
+
if (html_type == "SEARCH_MORE" && myUniqueKey == "theUniqueKey") {
|
|
652
|
+
myUniqueKey = undefined;
|
|
653
|
+
}
|
|
654
|
+
editFormState.formType[val_key].wordbook &&
|
|
655
|
+
(editFormState.formType[val_key].wordbook.myUniqueLabel = myUniqueKey);
|
|
656
|
+
state.fetching = true;
|
|
657
|
+
if (!html_type.includes("SEARCH_CASCADE")) {
|
|
658
|
+
cancelOptionsRequest();
|
|
659
|
+
}
|
|
660
|
+
state.optionsRequestSource = axios.CancelToken.source();
|
|
661
|
+
if (keyword && !defFalg) {
|
|
662
|
+
let key = typeof keyword === "string" ? keyword.trim() : keyword;
|
|
663
|
+
// key && this.handleSearchTracher(itemData, { keyword: key });
|
|
664
|
+
}
|
|
665
|
+
Object.assign(params, { asyncCount: 1 });
|
|
666
|
+
return axios
|
|
667
|
+
.post(`/tableReader/getWordbookData`, qs.stringify(params), {
|
|
668
|
+
cancelToken: state.optionsRequestSource.token
|
|
669
|
+
})
|
|
670
|
+
.then(({ data }) => {
|
|
671
|
+
if (otherConfig.page) {
|
|
672
|
+
handleSearchScrollTop(itemData);
|
|
673
|
+
}
|
|
674
|
+
state.optionsRequestSource = null;
|
|
675
|
+
state.fetching = false;
|
|
676
|
+
if (data.result === "SUCCESS") {
|
|
677
|
+
state.searchAddObj[`${itemData.val_key}_${itemData.name}`] = true;
|
|
678
|
+
let { rows, fieldList, page, total } = data.map;
|
|
679
|
+
state.searchPageConfig = Object.assign(state.searchPageConfig, {
|
|
680
|
+
page,
|
|
681
|
+
total,
|
|
682
|
+
isRequest: true,
|
|
683
|
+
keyword
|
|
684
|
+
});
|
|
685
|
+
let rowData = [];
|
|
686
|
+
if (isCascade) {
|
|
687
|
+
wordbook.myUniqueLabel = myUniqueKey;
|
|
688
|
+
wordbook.myUniqueKey = myUniqueKey;
|
|
689
|
+
wordbook.isLoadData = html_type == "LEVEL_SEARCH_CASCADE";
|
|
690
|
+
if (wordbook.isLoadData) {
|
|
691
|
+
state.levelNum = defFalg ? 1 : state.levelNum;
|
|
692
|
+
}
|
|
693
|
+
rows = hanldeRemoveDuplicates(rows, {
|
|
694
|
+
key: wordbook.value_key
|
|
695
|
+
});
|
|
696
|
+
handleFormCascade(rows, wordbook);
|
|
697
|
+
rowData = rows;
|
|
698
|
+
} else {
|
|
699
|
+
// 去重
|
|
700
|
+
rowData = handleRowUnique(rows, itemData, {
|
|
701
|
+
myUniqueKey: myUniqueKey,
|
|
702
|
+
reqUniqueKey: reqUniqueKey
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
// 获取显示字段title
|
|
706
|
+
if (rowData.length > 0 && wordbook.render_key && wordbook.render_key.length > 1) {
|
|
707
|
+
rowData.unshift(
|
|
708
|
+
Object.assign(
|
|
709
|
+
{},
|
|
710
|
+
{
|
|
711
|
+
showLabel: getTitleHeader(fieldList, wordbook.render_key),
|
|
712
|
+
myUniqueKey: Math.random()
|
|
713
|
+
}
|
|
714
|
+
)
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
const searchList = [
|
|
719
|
+
"SEARCH",
|
|
720
|
+
"SEARCH_CASCADE",
|
|
721
|
+
"SEARCH_MORE",
|
|
722
|
+
"LEVEL_SEARCH_CASCADE"
|
|
723
|
+
];
|
|
724
|
+
if (searchList.includes(html_type)) {
|
|
725
|
+
if (html_type != "LEVEL_SEARCH_CASCADE") {
|
|
726
|
+
state.curOptions = setCurOptions(rowData);
|
|
727
|
+
} else {
|
|
728
|
+
(defFalg || !state.loadDataPrimary_key) && (state.curOptions = setCurOptions(rowData));
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
// 默认值处理
|
|
732
|
+
handleGetSearchDefVal(defFalg, rowData, itemData, {
|
|
733
|
+
myUniqueKey: myUniqueKey,
|
|
734
|
+
reqUniqueKey: reqUniqueKey,
|
|
735
|
+
keyword: keyword,
|
|
736
|
+
...otherConfig
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
// 自由输入
|
|
740
|
+
if (!defFalg && html_type == "SEARCH" && keyword && free_entry == "1") {
|
|
741
|
+
handleFreeEntry({
|
|
742
|
+
rowData,
|
|
743
|
+
keyword,
|
|
744
|
+
wordbook,
|
|
745
|
+
fieldList,
|
|
746
|
+
myUniqueKey
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
return rowData;
|
|
751
|
+
}
|
|
752
|
+
return [];
|
|
753
|
+
})
|
|
754
|
+
.catch(err => {
|
|
755
|
+
console.log(err);
|
|
756
|
+
})
|
|
757
|
+
.finally(() => {
|
|
758
|
+
closeLoading();
|
|
759
|
+
});
|
|
760
|
+
} catch (error) {
|
|
761
|
+
closeLoading();
|
|
762
|
+
console.log(error);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
const hanlderGetSearchLabel = (config: any, v: any) => {
|
|
766
|
+
const { wordbook } = config;
|
|
767
|
+
let showLabel = "";
|
|
768
|
+
// "自由输入"的直接 return v[wordbook.value_key]
|
|
769
|
+
if (!v.is_free_entry_input__add && wordbook.show_key && wordbook.show_key.length) {
|
|
770
|
+
wordbook.show_key.forEach((s: string) => {
|
|
771
|
+
showLabel += ` ${formatField(v[s])}`;
|
|
772
|
+
});
|
|
773
|
+
return showLabel;
|
|
774
|
+
}
|
|
775
|
+
return v[wordbook.value_key];
|
|
776
|
+
}
|
|
777
|
+
const dealDictionatySearch = (val: string) => {
|
|
778
|
+
state.curOptions = state.curOptions.filter(i => {
|
|
779
|
+
return i.showLabel.includes(val);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
// 下拉框搜索输入关键字后
|
|
783
|
+
const handleMultipleSearch = (val: string, itemData: any) => {
|
|
784
|
+
clearTimeout(state.timeout);
|
|
785
|
+
const { wordbook = {}, html_type } = itemData;
|
|
786
|
+
const ISDICTIONARY = wordbook.type === "DICTIONARY";
|
|
787
|
+
// 257 云his需求新增通用字典 后端欧阳 产品晶晶
|
|
788
|
+
const arr = ["SEARCH", "SEARCH_MORE"];
|
|
789
|
+
if (arr.includes(html_type) && ISDICTIONARY && val) {
|
|
790
|
+
dealDictionatySearch(val);
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
state.searchPageConfig.keyword = val || undefined;
|
|
794
|
+
if (state.dropdownHide && !val) return;
|
|
795
|
+
state.timeout = setTimeout(() => {
|
|
796
|
+
handleRequestedOptions(itemData, val);
|
|
797
|
+
}, 200);
|
|
798
|
+
}
|
|
799
|
+
const hanldeInitSearchMoreVal = async (i: any, v?: any) => {
|
|
800
|
+
try {
|
|
801
|
+
const item = i;
|
|
802
|
+
let n;
|
|
803
|
+
if (v) {
|
|
804
|
+
n = v;
|
|
805
|
+
} else {
|
|
806
|
+
n = props.defaultValue[item.name] || item.default_val;
|
|
807
|
+
}
|
|
808
|
+
if (n) {
|
|
809
|
+
if (typeof n === "string") {
|
|
810
|
+
n = handleSysParams(n, paramsObj);
|
|
811
|
+
}
|
|
812
|
+
n = handleGetJsonStr(n) || {};
|
|
813
|
+
let NOWORDBOOK = item.wordbook.type != "WORDBOOK";
|
|
814
|
+
if (n && n.objs && n.objs.length) {
|
|
815
|
+
let curUniqueLabel: any;
|
|
816
|
+
if (NOWORDBOOK) {
|
|
817
|
+
curUniqueLabel = await handleRequestedUniqueKey(item.wordbook.id);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
curUniqueLabel = curUniqueLabel || undefined;
|
|
821
|
+
let defList: any[] = [];
|
|
822
|
+
const defOptions: any[] = [];
|
|
823
|
+
// `${v[item.wordbook.value_key]}-${v['myUniqueKey']}`
|
|
824
|
+
let l: string[] = [],
|
|
825
|
+
objs: any[] = [];
|
|
826
|
+
let objStr =
|
|
827
|
+
typeof n.objStr === "string" ? [...new Set(n.objStr.split(","))].join(",") : n.objStr;
|
|
828
|
+
n.objs.forEach((f: any) => {
|
|
829
|
+
let v = typeof f === "object" ? JSON.parse(JSON.stringify(f)) : f;
|
|
830
|
+
v.myUniqueKey = v[curUniqueLabel] || "";
|
|
831
|
+
v.myUniqueLabel = curUniqueLabel || "";
|
|
832
|
+
defList.push({
|
|
833
|
+
key: `${v[item.wordbook.value_key]}-${v[curUniqueLabel] || ""}`,
|
|
834
|
+
label: hanlderGetSearchLabel(item, v)
|
|
835
|
+
});
|
|
836
|
+
let k = `${v[item.wordbook.value_key]}-${v["myUniqueKey"]}`;
|
|
837
|
+
if (!l.includes(k)) {
|
|
838
|
+
defOptions.push({
|
|
839
|
+
...v
|
|
840
|
+
});
|
|
841
|
+
l.push(k);
|
|
842
|
+
objs.push({ ...f });
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
// 如果默认值有重复数据,过滤重复数据再提交
|
|
846
|
+
if (l.length !== (n?.objs?.length || undefined)) {
|
|
847
|
+
editFormState.formType[item.val_key].filtration_val = JSON.stringify({
|
|
848
|
+
objStr,
|
|
849
|
+
objs
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
item.defOptions = defOptions;
|
|
853
|
+
// console.log(defOptions, "--defOptions");
|
|
854
|
+
if (defOptions && defOptions.length) {
|
|
855
|
+
state.curOptions = setCurOptions([...defOptions]);
|
|
856
|
+
state.selectedOptions = [...(defOptions || [])];
|
|
857
|
+
}
|
|
858
|
+
defList = vexutils.uniqArrObj(defList, "key");
|
|
859
|
+
state.defList = defList;
|
|
860
|
+
item['useFormValue'] = defList
|
|
861
|
+
emit("valueOnChange", [...defOptions], props.item);
|
|
862
|
+
// console.log(this.defList, "---defList");
|
|
863
|
+
} else {
|
|
864
|
+
props.defaultValue[item.name] = [];
|
|
865
|
+
}
|
|
866
|
+
} else {
|
|
867
|
+
props.defaultValue[item.name] = [];
|
|
868
|
+
}
|
|
869
|
+
} catch (e) {
|
|
870
|
+
console.log(e);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
const init = () => {
|
|
874
|
+
const {
|
|
875
|
+
validate = {},
|
|
876
|
+
html_type = undefined,
|
|
877
|
+
name,
|
|
878
|
+
default_val,
|
|
879
|
+
show_type = undefined,
|
|
880
|
+
guage_num = undefined
|
|
881
|
+
} = props.item;
|
|
882
|
+
let targetStr = props.defaultValue[name] || default_val;
|
|
883
|
+
targetStr = handleSysParams(targetStr, paramsObj);
|
|
884
|
+
if (html_type == "SEARCH") {
|
|
885
|
+
if (targetStr) {
|
|
886
|
+
nextTick(() => {
|
|
887
|
+
handleRequestedOptions(props.item, targetStr, true);
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
} else if (html_type == "SEARCH_MORE") {
|
|
891
|
+
hanldeInitSearchMoreVal(props.item);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
state.cacheReqOptionsParams = "";
|
|
895
|
+
// this.getHotSearchConfig();
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
onMounted(() => {
|
|
899
|
+
init()
|
|
900
|
+
})
|
|
901
|
+
|
|
902
|
+
return {
|
|
903
|
+
state,
|
|
904
|
+
selectIsOpen,
|
|
905
|
+
handleMultipleSearch,
|
|
906
|
+
handlerDropdownVisibleChange,
|
|
907
|
+
handleSearchSelect,
|
|
908
|
+
searchMoreOnChange
|
|
909
|
+
}
|
|
910
|
+
}
|