wui-components-v2 1.1.55 → 1.1.56
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.
|
@@ -26,9 +26,6 @@ interface SelectOption {
|
|
|
26
26
|
value: string | number
|
|
27
27
|
[key: string]: any
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
console.log(props.type, 'props.type')
|
|
31
|
-
|
|
32
29
|
const open = ref(false)
|
|
33
30
|
const currentValue = ref<any>(props.modelValue)
|
|
34
31
|
function clear() {
|
|
@@ -38,7 +35,6 @@ function clear() {
|
|
|
38
35
|
watch(
|
|
39
36
|
() => props.modelValue,
|
|
40
37
|
(val) => {
|
|
41
|
-
console.log(val, 'val1111')
|
|
42
38
|
currentValue.value = val
|
|
43
39
|
},
|
|
44
40
|
)
|
|
@@ -55,8 +51,10 @@ const labelText = computed(() => {
|
|
|
55
51
|
} = {
|
|
56
52
|
date: 'YYYY-MM-DD',
|
|
57
53
|
datetime: 'YYYY-MM-DD HH:mm',
|
|
54
|
+
year:'YYYY'
|
|
58
55
|
}
|
|
59
|
-
|
|
56
|
+
|
|
57
|
+
if (['date', 'datetime', 'year'].includes(props.type)) {
|
|
60
58
|
return currentValue.value ? dayjs(currentValue.value).format(formatMap[props.type] as string) : ''
|
|
61
59
|
}
|
|
62
60
|
else {
|
|
@@ -79,7 +77,7 @@ const labelText = computed(() => {
|
|
|
79
77
|
</div>
|
|
80
78
|
|
|
81
79
|
<wd-calendar
|
|
82
|
-
v-if="['date', 'datetime'].includes(type)"
|
|
80
|
+
v-if="['date', 'datetime',].includes(type)"
|
|
83
81
|
v-model="currentValue"
|
|
84
82
|
v-model:visible="open"
|
|
85
83
|
label-key="label"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, onBeforeMount, ref, toRaw } from 'vue'
|
|
2
|
+
import { computed, onBeforeMount, ref, toRaw, watch } from 'vue'
|
|
3
3
|
import type { FormSchema, FormSchemaIssue } from '@wot-ui/ui/components/wd-form/types'
|
|
4
4
|
import dayjs from 'dayjs/esm/index'
|
|
5
5
|
import type { Enums, Fields, Groups } from '../../type'
|
|
@@ -50,6 +50,19 @@ const { filteredFields: fields } = useCompanyFieldFilter(
|
|
|
50
50
|
props.companyFilter, // 是否自适应显示快递公司填充框
|
|
51
51
|
props.companyFieldSourceId, // 快递公司对应字段
|
|
52
52
|
)
|
|
53
|
+
const giveDefaultValue =(value:any)=>{
|
|
54
|
+
const {extInfo={}} = uni.getStorageSync('userInfo')||{}
|
|
55
|
+
const rawDefaultValue=extInfo.fieldMap||{};
|
|
56
|
+
const defaultValue: Record<string, any> = {}
|
|
57
|
+
for (const key in rawDefaultValue) {
|
|
58
|
+
if (Object.prototype.hasOwnProperty.call(rawDefaultValue, key)) {
|
|
59
|
+
const val = rawDefaultValue[key]
|
|
60
|
+
defaultValue[key] = typeof val === 'string' && val.includes('@R@') ? val.split('@R@')[0] : val
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return defaultValue[value]||{}
|
|
64
|
+
}
|
|
65
|
+
giveDefaultValue({})
|
|
53
66
|
// 初始化表单数据
|
|
54
67
|
function initFormData() {
|
|
55
68
|
const models: { [key: string]: any } = {}
|
|
@@ -81,14 +94,84 @@ function initFormData() {
|
|
|
81
94
|
return models[item.sourceId] = (props.entity && props.entity[item.sourceId]) || item.transDefaultValue || ''
|
|
82
95
|
})
|
|
83
96
|
|
|
84
|
-
|
|
97
|
+
// 遍历 models,处理 $$user. 前缀
|
|
98
|
+
const processedModels: Record<string, any> = {}
|
|
99
|
+
for (const key in models) {
|
|
100
|
+
if (Object.prototype.hasOwnProperty.call(models, key)) {
|
|
101
|
+
const val = models[key]
|
|
102
|
+
if (typeof val === 'string' && val.includes('$$user.')) {
|
|
103
|
+
processedModels[key] = giveDefaultValue(val.split('$$user.')[1])
|
|
104
|
+
} else {
|
|
105
|
+
processedModels[key] = val
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
model.value = {
|
|
111
|
+
...processedModels,
|
|
112
|
+
}
|
|
85
113
|
}
|
|
86
114
|
|
|
115
|
+
//-s
|
|
116
|
+
const shouldMonitor=computed(()=>{
|
|
117
|
+
const newList=fields.value.filter((item:any)=>item.relValueField||item.relValueField3).map((innerItem:any)=>({
|
|
118
|
+
id: innerItem.sourceId,
|
|
119
|
+
title: innerItem.title,
|
|
120
|
+
relValueField: innerItem.relValueField.id,
|
|
121
|
+
relValueField3: innerItem.relValueField3.id,
|
|
122
|
+
}))
|
|
123
|
+
console.log('shouldMonitor:', newList)
|
|
124
|
+
return newList
|
|
125
|
+
})
|
|
126
|
+
//-e
|
|
127
|
+
|
|
128
|
+
// 存储变化后的数据,{ [fieldKey]: newValue, ... }
|
|
129
|
+
const changedData = ref<Record<string, any>>({})
|
|
130
|
+
const initialModel = ref<Record<string, any>>({})
|
|
131
|
+
|
|
132
|
+
// 监听 shouldMonitor 中 relValueField / relValueField3 对应的 model 字段
|
|
133
|
+
watch(
|
|
134
|
+
() => {
|
|
135
|
+
const snapshot: Record<string, any> = {}
|
|
136
|
+
shouldMonitor.value?.forEach((item: any) => {
|
|
137
|
+
if (item.relValueField)
|
|
138
|
+
snapshot.relValueField = model.value[item.relValueField]
|
|
139
|
+
if (item.relValueField3)
|
|
140
|
+
snapshot.relValueField3 = model.value[item.relValueField3]
|
|
141
|
+
})
|
|
142
|
+
return snapshot
|
|
143
|
+
},
|
|
144
|
+
(newVal) => {
|
|
145
|
+
// 只存储与初始值不同的字段(表单变化的值)
|
|
146
|
+
const changed: Record<string, any> = {}
|
|
147
|
+
shouldMonitor.value?.forEach((item: any) => {
|
|
148
|
+
if (item.relValueField && newVal.relValueField !== initialModel.value[item.relValueField]) {
|
|
149
|
+
changed.relValueField = newVal.relValueField
|
|
150
|
+
}
|
|
151
|
+
if (item.relValueField3 && newVal.relValueField3 !== initialModel.value[item.relValueField3]) {
|
|
152
|
+
changed.relValueField3 = newVal.relValueField3
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
changedData.value = changed
|
|
156
|
+
|
|
157
|
+
// 当所有被监听的字段都有值时,存入缓存供 select-list 页面读取
|
|
158
|
+
const values = Object.values(newVal)
|
|
159
|
+
const allExist = values.length > 0 && values.every(v => v !== null && v !== undefined && v !== '')
|
|
160
|
+
if (allExist) {
|
|
161
|
+
uni.setStorageSync('paramsData', {
|
|
162
|
+
changedData: changedData.value,
|
|
163
|
+
rawData: shouldMonitor.value,
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
)
|
|
168
|
+
|
|
87
169
|
onBeforeMount(() => {
|
|
88
170
|
action.value = uni.getStorageSync('BASE_URL')
|
|
89
171
|
hydrocarbonProgramToken.value = uni.getStorageSync('HYDROCARBON_PROGRAM_TOKEN')
|
|
90
172
|
token.value = uni.getStorageSync('TOKEN')
|
|
91
173
|
initFormData()
|
|
174
|
+
initialModel.value = JSON.parse(JSON.stringify(model.value))
|
|
92
175
|
})
|
|
93
176
|
function formatSelectColumns(columns: any) {
|
|
94
177
|
return columns.map((item: any) => {
|
|
@@ -124,7 +207,6 @@ const schema = computed((): FormSchema => {
|
|
|
124
207
|
|
|
125
208
|
// 监听文件上传成功
|
|
126
209
|
function handleFileChange(e: any, item: Fields) {
|
|
127
|
-
console.log(e, item,'2222222222222')
|
|
128
210
|
model.value[item.sourceId] = e.fileList
|
|
129
211
|
}
|
|
130
212
|
|
|
@@ -155,7 +237,6 @@ function submit() {
|
|
|
155
237
|
})
|
|
156
238
|
}
|
|
157
239
|
}
|
|
158
|
-
console.log('submit', model.value)
|
|
159
240
|
resolve(data)
|
|
160
241
|
}
|
|
161
242
|
else {
|
|
@@ -169,10 +250,16 @@ function submit() {
|
|
|
169
250
|
})
|
|
170
251
|
}
|
|
171
252
|
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
172
257
|
// 暴露方法/变量给父组件
|
|
173
258
|
defineExpose({
|
|
174
259
|
submit,
|
|
175
260
|
})
|
|
261
|
+
|
|
262
|
+
|
|
176
263
|
</script>
|
|
177
264
|
|
|
178
265
|
<template>
|
|
@@ -66,7 +66,6 @@ const fetchDataById = async (id: string) => {
|
|
|
66
66
|
if (!id || !props.sourceId) return
|
|
67
67
|
const newId=Array.isArray(id)?id[0]:id
|
|
68
68
|
const requestId = newId?.split('@R@')[0] || props.sourceId
|
|
69
|
-
console.log('fetchDataById', requestId, props.sourceId,id)
|
|
70
69
|
try {
|
|
71
70
|
const config = await pageConfig(props.sourceId)
|
|
72
71
|
const newConfig=config.ltmplConfig
|
|
@@ -96,18 +95,17 @@ const emitIfNeeded = (val: string) => {
|
|
|
96
95
|
emitVal = val + '@R@' + showValue.name
|
|
97
96
|
}
|
|
98
97
|
if (emitVal !== props.modelValue) {
|
|
99
|
-
console.log('emit update:modelValue', emitVal)
|
|
100
98
|
emit('update:modelValue', emitVal)
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
onMounted(() => {
|
|
105
103
|
if (currentValue.value) {
|
|
106
|
-
|
|
104
|
+
const requestId= currentValue.value.includes('$$user.')? currentValue.value.split('$$user.')[1] : currentValue.value
|
|
105
|
+
fetchDataById(requestId)
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
uni.$on(EVENT_NAME, (id: string) => {
|
|
110
|
-
console.log('user-choose 接收到id:', id)
|
|
111
109
|
currentValue.value = id
|
|
112
110
|
fetchDataById(id)
|
|
113
111
|
})
|
|
@@ -141,6 +141,7 @@ async function getEnums() {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
|
|
144
145
|
// @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用this.$refs.paging.reload()即可
|
|
145
146
|
async function queryList(pageNo: number, pageSize: number) {
|
|
146
147
|
// 此处请求仅为演示,请替换为自己项目中的请求
|
|
@@ -155,7 +156,16 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
155
156
|
// paging.value.reload() // 手动触发加载
|
|
156
157
|
// })
|
|
157
158
|
|
|
158
|
-
|
|
159
|
+
const search=uni.getStorageSync('paramsData')?.changedData || {}
|
|
160
|
+
const newParams={
|
|
161
|
+
thirdCriteria:search.relValueField3 || '',
|
|
162
|
+
secondCriteria:search.relValueField?.toString() || '',
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
const params = Object.entries(newParams)
|
|
166
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
167
|
+
.join('&');
|
|
168
|
+
let qre = searchData.value?`${searchData.value+'&'+params}`:params
|
|
159
169
|
if (config.value.defaultCriteriaValue) {
|
|
160
170
|
for (const key in config.value.defaultCriteriaValue) {
|
|
161
171
|
if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
|
|
@@ -237,6 +247,9 @@ const formatAddress = (value:string) => {
|
|
|
237
247
|
const checkboxType:any=computed(()=>{
|
|
238
248
|
return ['relselect','relselect-extdis'].includes(extControlType.value)?'':'square'
|
|
239
249
|
})
|
|
250
|
+
onUnmounted(() => {
|
|
251
|
+
uni.removeStorageSync('paramsData')
|
|
252
|
+
})
|
|
240
253
|
</script>
|
|
241
254
|
|
|
242
255
|
<template>
|