wui-components-v2 1.1.69 → 1.1.71
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/api/core/index.ts +74 -74
- package/api/feishu.ts +20 -20
- package/api/index.ts +4 -4
- package/api/login.ts +51 -51
- package/api/menu.ts +45 -45
- package/api/page.ts +114 -114
- package/api/sys.ts +12 -12
- package/api/tree.ts +28 -28
- package/components/action-popup/action-popup.vue +116 -116
- package/components/add-address-list/add-address-list.vue +187 -187
- package/components/add-address-page/add-address-page.vue +77 -77
- package/components/add-address-page/config.ts +297 -297
- package/components/audio-play/audio-play.vue +220 -220
- package/components/batch-upload-file/batch-upload-file.vue +75 -75
- package/components/card-botom-buttons/card-botom-buttons.vue +279 -279
- package/components/custom-date-picker/custom-date-picker.vue +106 -106
- package/components/custom-select-picker/custom-select-picker.vue +95 -95
- package/components/demo-block/demo-block.vue +63 -63
- package/components/demo-card/demo-card.vue +44 -44
- package/components/detail-popup/detail-popup.vue +99 -99
- package/components/evaluation-page/evaluation-page.vue +196 -196
- package/components/fold-card/fold-card.vue +171 -171
- package/components/form-control/form-control.vue +661 -661
- package/components/global-loading/GlobalLoading.md +366 -366
- package/components/global-loading/global-loading.vue +55 -55
- package/components/global-message/GlobalMessage.md +570 -570
- package/components/global-message/global-message.vue +68 -68
- package/components/global-toast/GlobalToast.md +261 -261
- package/components/global-toast/global-toast.vue +56 -56
- package/components/label-value/label-value.vue +144 -144
- package/components/label-value/open-value-more.vue +56 -56
- package/components/list-top-buttons/list-top-buttons.vue +19 -19
- package/components/loading/loading.vue +5 -5
- package/components/login-form/login-form.vue +126 -126
- package/components/login-form-box/login-form-box.vue +65 -65
- package/components/mulselect-picker/mulselect-picker.vue +86 -86
- package/components/phone-login-form/phone-login-form.vue +204 -204
- package/components/privacy-popup/privacy-popup.vue +191 -191
- package/components/product-card/product-card.vue +201 -201
- package/components/scan-input/scan-input.vue +406 -406
- package/components/search/search.vue +128 -128
- package/components/select-col-picker/select-col-picker.vue +168 -168
- package/components/tab-search/tab-search.vue +73 -73
- package/components/tree-select/components/TreeNode.vue +200 -200
- package/components/tree-select/components/index.vue +471 -471
- package/components/tree-select/components/tree-select.vue +56 -56
- package/components/tree-select/index.vue +93 -93
- package/components/user-choose/user-choose.vue +169 -151
- package/components/video-play/video-play.vue +56 -56
- package/components/wui-auto-update-component/wui-auto-update-component.vue +132 -132
- package/components/wui-default/wui-default.vue +49 -49
- package/components/wui-details-page/wui-details-page.vue +147 -147
- package/components/wui-edit-page/wui-edit-page-copy.vue +757 -757
- package/components/wui-edit-page/wui-edit-page.vue +793 -793
- package/components/wui-enume-select-control/wui-enume-select-control.vue +92 -92
- package/components/wui-list/wui-list.vue +235 -235
- package/components/wui-login/wui-login.vue +43 -43
- package/components/wui-login1/wui-login.vue +41 -41
- package/components/wui-menus/wui-menus-top.vue +137 -137
- package/components/wui-menus/wui-menus-top1.vue +8 -8
- package/components/wui-menus/wui-menus.vue +247 -247
- package/components/wui-menus1/components/banner-carousel.vue +320 -320
- package/components/wui-menus1/components/navbar.vue +43 -43
- package/components/wui-menus1/components/quick-panel.vue +55 -55
- package/components/wui-menus1/components/search-bar.vue +49 -49
- package/components/wui-menus1/components/section-menus.vue +208 -208
- package/components/wui-menus1/wui-menus-top.vue +718 -718
- package/components/wui-menus1/wui-menus-top1.vue +398 -398
- package/components/wui-menus1/wui-menus.vue +564 -564
- package/components/wui-notify-info/notify-handle.vue +53 -53
- package/components/wui-notify-info/wui-notify-info.vue +280 -280
- package/components/wui-scan-binding-sensor/wui-scan-binding-sensor.vue +75 -75
- package/components/wui-search-history-babbar/components/SearchBar.vue +70 -70
- package/components/wui-search-history-babbar/wui-search-history-babbar.vue +204 -204
- package/components/wui-select-list/wui-select-list.vue +310 -310
- package/components/wui-select-popup/wui-select-popup.vue +613 -612
- package/components/wui-system-settings/wui-system-settings.vue +144 -144
- package/components/wui-tabbar/wui-tabbar.vue +106 -106
- package/components/wui-tree-page/components/tree-item.vue +238 -238
- package/components/wui-tree-page/wui-tree-page.vue +297 -297
- package/components/wui-update-component/wui-update-component.vue +221 -221
- package/components/wui-user/wui-user.vue +202 -202
- package/composables/types/theme.ts +65 -65
- package/composables/types/user.ts +5 -5
- package/composables/useColorGenerator.ts +221 -221
- package/composables/useCompanyFieldFilter.ts +91 -91
- package/composables/useEnumes.ts +43 -43
- package/composables/useEventBus.ts +37 -37
- package/composables/useGlobalLoading.ts +47 -47
- package/composables/useGlobalMessage.ts +53 -53
- package/composables/useGlobalToast.ts +63 -63
- package/composables/useLocale.ts +54 -54
- package/composables/useManualTheme.ts +179 -179
- package/composables/useMenus.ts +193 -193
- package/composables/useSectionMenus.ts +120 -120
- package/composables/useTabbar.ts +50 -50
- package/composables/useTheme.ts +74 -74
- package/composables/useUser.ts +24 -24
- package/index.d.ts +90 -90
- package/index.ts +83 -83
- package/package.json +24 -24
- package/static/iconfont/iconfont.css +63 -63
- package/store/language.ts +151 -151
- package/store/manualThemeStore.ts +143 -143
- package/store/persist.ts +41 -41
- package/store/themeStore.ts +74 -74
- package/store/userStore.ts +22 -22
- package/styles/dark-mode.css +523 -523
- package/styles/dark-mode.min.css +1 -1
- package/styles/dark-mode.scss +498 -498
- package/type.ts +154 -154
- package/utils/control-tree.ts +353 -353
- package/utils/control-type-supportor.ts +148 -148
- package/utils/eventBus.ts +36 -36
- package/utils/idata-scan.ts +99 -99
- package/utils/index.ts +979 -979
- package/utils/rsaEncrypt.ts +10 -10
|
@@ -1,793 +1,793 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { computed, defineOptions, onBeforeMount, onUnmounted, ref, toRaw } from 'vue'
|
|
3
|
-
import { onLoad } from '@dcloudio/uni-app'
|
|
4
|
-
import { useRouter } from 'uni-mini-router'
|
|
5
|
-
import FormControl from '../form-control/form-control.vue'
|
|
6
|
-
import { addPageConfig, editPageConfig, editPageDataSave, enums, selectDatas } from '../../api/page'
|
|
7
|
-
import type { Entities, Enums, Groups, dtmplConfig } from '../../type'
|
|
8
|
-
import { useGlobalToast } from '../../composables/useGlobalToast'
|
|
9
|
-
import foldCard from '../fold-card/fold-card.vue'
|
|
10
|
-
import { generateHighResolutionID } from '../../utils/index'
|
|
11
|
-
import TreeSelectControl from '../tree-select/index.vue'
|
|
12
|
-
import batchUploadFile from '../batch-upload-file/batch-upload-file.vue'
|
|
13
|
-
|
|
14
|
-
defineOptions({
|
|
15
|
-
name: 'WuiEditPage',
|
|
16
|
-
})
|
|
17
|
-
const props = defineProps<{
|
|
18
|
-
companyFilter?: boolean
|
|
19
|
-
companyFieldSourceId?: string
|
|
20
|
-
}>()
|
|
21
|
-
const pageConfig = ref<dtmplConfig>({
|
|
22
|
-
id: '',
|
|
23
|
-
title: '',
|
|
24
|
-
groups: [],
|
|
25
|
-
entity: {
|
|
26
|
-
arrayMap: {},
|
|
27
|
-
code: '',
|
|
28
|
-
fieldMap: {},
|
|
29
|
-
},
|
|
30
|
-
buttons: [],
|
|
31
|
-
smartPaste: false,
|
|
32
|
-
})
|
|
33
|
-
const tree = ref({ value: '', sourceId: '' })
|
|
34
|
-
const loading = ref(false)
|
|
35
|
-
const globalToast = useGlobalToast()
|
|
36
|
-
const router = useRouter()
|
|
37
|
-
const mainCode = ref('')
|
|
38
|
-
const id = ref('')
|
|
39
|
-
const sourceId = ref('')
|
|
40
|
-
const formControlRef = ref()
|
|
41
|
-
const subLoading = ref(false)
|
|
42
|
-
const Enumcolumn = ref<Enums | undefined>()
|
|
43
|
-
const pageTitle = ref('')
|
|
44
|
-
const pageType = ref('')
|
|
45
|
-
const selectData = ref<{ [key: string]: { loading: boolean, data: string[] } }>({})
|
|
46
|
-
const rowData = ref<{ [key: string]: { [key: string]: any } }>({})
|
|
47
|
-
const action = ref('')
|
|
48
|
-
const hydrocarbonProgramToken = ref('')
|
|
49
|
-
const token = ref('')
|
|
50
|
-
// 全局事件名称
|
|
51
|
-
const SELECTEVENT = generateHighResolutionID()
|
|
52
|
-
const SENDSELECTEVENT = generateHighResolutionID()
|
|
53
|
-
const addEvent = ref('')
|
|
54
|
-
const editEvent = ref('')
|
|
55
|
-
const rowAddEvent = ref('')
|
|
56
|
-
const sendRowAddEvent = ref('')
|
|
57
|
-
const smartPaste=ref(false)
|
|
58
|
-
// 折叠面板
|
|
59
|
-
const collapses = ref('')
|
|
60
|
-
const groupsformat = computed(() => {
|
|
61
|
-
return pageConfig.value.groups.filter((item: Groups) => {
|
|
62
|
-
return item.displayConfig.includes('displayed')
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
const canSmartPaste=computed(()=>{
|
|
66
|
-
return pageConfig.value?.smartPaste??false
|
|
67
|
-
})
|
|
68
|
-
onLoad((option: any) => {
|
|
69
|
-
sourceId.value = option.sourceId
|
|
70
|
-
mainCode.value = option.mainCode || ''
|
|
71
|
-
id.value = option.id || ''
|
|
72
|
-
pageTitle.value = option.title
|
|
73
|
-
addEvent.value = option.addEvent
|
|
74
|
-
editEvent.value = option.editEvent
|
|
75
|
-
pageType.value = option.pageType || ''
|
|
76
|
-
rowAddEvent.value = option.rowAddEvent
|
|
77
|
-
sendRowAddEvent.value = option.sendRowAddEvent
|
|
78
|
-
getEditPageConfig()
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
onUnmounted(() => {
|
|
82
|
-
console.log('页面卸载')
|
|
83
|
-
// 勿在卸载时 $off 勾选事件:跳转勾选页会触发 onUnmounted,导致 $once(SELECTEVENT) 被提前移除
|
|
84
|
-
uni.$off(rowAddEvent.value)
|
|
85
|
-
// uni.$off(addEvent.value)
|
|
86
|
-
uni.$off(editEvent.value)
|
|
87
|
-
uni.$off(sendRowAddEvent.value)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
onBeforeMount(() => {
|
|
91
|
-
action.value = uni.getStorageSync('BASE_URL')
|
|
92
|
-
hydrocarbonProgramToken.value = uni.getStorageSync('HYDROCARBON_PROGRAM_TOKEN')
|
|
93
|
-
token.value = uni.getStorageSync('TOKEN')
|
|
94
|
-
})
|
|
95
|
-
// 获取编辑页面配置
|
|
96
|
-
async function getEditPageConfig() {
|
|
97
|
-
// 判断是否为行新增事件
|
|
98
|
-
if (sendRowAddEvent.value) {
|
|
99
|
-
uni.$once(sendRowAddEvent.value, (conf: any) => {
|
|
100
|
-
console.log('sendRowAddEvent.value', conf)
|
|
101
|
-
pageConfig.value = {
|
|
102
|
-
id: '',
|
|
103
|
-
title: '行添加',
|
|
104
|
-
groups: conf.groups,
|
|
105
|
-
entity: conf.entity || {
|
|
106
|
-
arrayMap: {},
|
|
107
|
-
code: '',
|
|
108
|
-
fieldMap: {},
|
|
109
|
-
},
|
|
110
|
-
buttons: [],
|
|
111
|
-
}
|
|
112
|
-
getEnums()
|
|
113
|
-
uni.$off(sendRowAddEvent.value)
|
|
114
|
-
})
|
|
115
|
-
setTimeout(() => {
|
|
116
|
-
const visibleGroups = pageConfig.value.groups.filter((item: Groups) => item.displayConfig.includes('displayed'))
|
|
117
|
-
collapses.value = visibleGroups.length > 0 ? visibleGroups[0].id : ''
|
|
118
|
-
}, 100)
|
|
119
|
-
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
let res = null
|
|
125
|
-
loading.value = true
|
|
126
|
-
if (id.value) {
|
|
127
|
-
res = await editPageConfig(sourceId.value, id.value)
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
res = await addPageConfig(sourceId.value)
|
|
131
|
-
}
|
|
132
|
-
loading.value = false
|
|
133
|
-
// 初始化折叠面板
|
|
134
|
-
if (res.dtmplConfig) {
|
|
135
|
-
uni.setNavigationBarTitle({
|
|
136
|
-
title: `${res.dtmplConfig.title}`,
|
|
137
|
-
})
|
|
138
|
-
pageConfig.value = res.dtmplConfig
|
|
139
|
-
const visibleGroups = pageConfig.value.groups.filter((item: Groups) => item.displayConfig.includes('displayed'))
|
|
140
|
-
collapses.value = visibleGroups.length > 0 ? visibleGroups[0].id : ''
|
|
141
|
-
|
|
142
|
-
pageConfig.value.groups.forEach((item: Groups) => {
|
|
143
|
-
// 初始化勾选数据
|
|
144
|
-
if (item.type === 'relation' && (item.buttons.includes('dtmplAdd') || item.buttons.includes('selectAdd'))) {
|
|
145
|
-
selectData.value[item.id] = {
|
|
146
|
-
data: (pageConfig.value.entity && pageConfig.value.entity.arrayMap[item.id]?.map((sebitem: any) => {
|
|
147
|
-
return `${sebitem.code}`
|
|
148
|
-
})) || [],
|
|
149
|
-
loading: false,
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// 初始化行数据
|
|
153
|
-
if (item.type === 'relation' && item.buttons.includes('rowAdd')) {
|
|
154
|
-
rowData.value[item.id] = (pageConfig.value.entity && pageConfig.value.entity.arrayMap[item.id]?.map((sebitem: any) => {
|
|
155
|
-
return {
|
|
156
|
-
id: sebitem.code,
|
|
157
|
-
...sebitem.fieldMap,
|
|
158
|
-
}
|
|
159
|
-
})) || []
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
getEnums()
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
loading.value = false
|
|
167
|
-
console.log('error:', error)
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
// 获取枚举
|
|
171
|
-
async function getEnums() {
|
|
172
|
-
try {
|
|
173
|
-
const params: string[] = []
|
|
174
|
-
pageConfig.value.groups?.forEach((item: any) => {
|
|
175
|
-
item.fields?.forEach((subItem: any) => {
|
|
176
|
-
if (subItem.extControlType === 'select' || subItem.extControlType === 'multiselect') {
|
|
177
|
-
params.push(`mstrucIds=${subItem.mstrucId}`)
|
|
178
|
-
}
|
|
179
|
-
})
|
|
180
|
-
})
|
|
181
|
-
if (!params.length)
|
|
182
|
-
return
|
|
183
|
-
const res = await enums(params.join('&'))
|
|
184
|
-
Enumcolumn.value = res.enumMap || {}
|
|
185
|
-
}
|
|
186
|
-
catch (error) {
|
|
187
|
-
console.log('error:', error)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// 行添加保存
|
|
192
|
-
async function rowAddSave(all: any) {
|
|
193
|
-
console.log('行数据', all)
|
|
194
|
-
router.back()
|
|
195
|
-
uni.$emit(rowAddEvent.value, all)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// 保存
|
|
199
|
-
async function save() {
|
|
200
|
-
// 判断是否为树添加
|
|
201
|
-
if (pageType.value === '树' && !tree.value.value) {
|
|
202
|
-
return globalToast.warning('请选择分组')
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
try {
|
|
206
|
-
const formArray: any[] = []
|
|
207
|
-
formControlRef.value.forEach((element: any) => {
|
|
208
|
-
formArray.push(element.submit())
|
|
209
|
-
})
|
|
210
|
-
const res = await Promise.all(formArray)
|
|
211
|
-
const beasData = res.reduce((acc, cur) => {
|
|
212
|
-
return { ...acc, ...cur }
|
|
213
|
-
}, {})
|
|
214
|
-
subLoading.value = true
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
*
|
|
218
|
-
* 421639572264099847.$$flag$$:true
|
|
219
|
-
421639572264099847[0].$$relation$$:拥有角色
|
|
220
|
-
421639572264099847[0].唯一编码:448591711817211909
|
|
221
|
-
*/
|
|
222
|
-
let all: Record<string, any> = {}
|
|
223
|
-
for (const key in selectData.value) {
|
|
224
|
-
if (Object.prototype.hasOwnProperty.call(selectData.value, key)) {
|
|
225
|
-
const element = selectData.value[key].data
|
|
226
|
-
if (element) {
|
|
227
|
-
all[`${key}.$$flag$$`] = true
|
|
228
|
-
element.forEach((item, index) => {
|
|
229
|
-
all[`${key}[${index}].$$relation$$`] = pageConfig.value.groups.find(item => item.id === key)?.relationNames[0]
|
|
230
|
-
if (typeof item === 'string') {
|
|
231
|
-
all[`${key}[${index}].唯一编码`] = item.split('@R@')[0]
|
|
232
|
-
}
|
|
233
|
-
})
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
console.log('rowData.value', rowData.value)
|
|
238
|
-
for (const key in rowData.value) {
|
|
239
|
-
if (Object.prototype.hasOwnProperty.call(rowData.value, key)) {
|
|
240
|
-
const element1 = rowData.value[key]
|
|
241
|
-
if (element1) {
|
|
242
|
-
all[`${key}.$$flag$$`] = true
|
|
243
|
-
element1.forEach((item: any, index: any) => {
|
|
244
|
-
all[`${key}[${index}].$$relation$$`] = pageConfig.value.groups.find(item => item.id === key)?.relationNames[0]
|
|
245
|
-
all[`${key}[${index}].唯一编码`] = item.id
|
|
246
|
-
|
|
247
|
-
for (const key1 in item) {
|
|
248
|
-
if (Object.prototype.hasOwnProperty.call(item, key1)) {
|
|
249
|
-
console.log('item[key1]', item[key1])
|
|
250
|
-
if (item[key1] && item[key1].response) {
|
|
251
|
-
all[`${key}[${index}].${key1}`] = JSON.stringify({
|
|
252
|
-
valid: item[key1].disabled ? 'old' : 'new',
|
|
253
|
-
fileKey: JSON.parse(item[key1].response).fileKey,
|
|
254
|
-
fileName: item[key1].name,
|
|
255
|
-
})
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (typeof item[key1] === 'string') {
|
|
259
|
-
// all[`${key}[${index}].${key1}`] = item[key1].split('@R@')[0]
|
|
260
|
-
all[`${key}[${index}].${key1}`] = item[key1]
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
})
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
console.log('all', all, beasData)
|
|
269
|
-
all = {
|
|
270
|
-
...all,
|
|
271
|
-
...beasData,
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// 判断是否为行添加
|
|
275
|
-
if (rowAddEvent.value) {
|
|
276
|
-
subLoading.value = false
|
|
277
|
-
return rowAddSave({ ...all, id: pageConfig.value.entity.code })
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const newAll: Record<string, any> = {}
|
|
281
|
-
|
|
282
|
-
for (const key1 in all) {
|
|
283
|
-
if (Object.prototype.hasOwnProperty.call(all, key1)) {
|
|
284
|
-
if (all[key1] && all[key1].response) {
|
|
285
|
-
newAll[`${key1}`] = JSON.stringify({
|
|
286
|
-
valid: all[key1].disabled ? 'old' : 'new',
|
|
287
|
-
fileKey: JSON.parse(all[key1].response).fileKey,
|
|
288
|
-
fileName: all[key1].name,
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
newAll[key1] = all[key1]
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
editPageDataSave(tree.value.sourceId || sourceId.value, id.value, newAll, tree.value.value || mainCode.value).then((res: any) => {
|
|
298
|
-
// 发送事件
|
|
299
|
-
if (addEvent.value)
|
|
300
|
-
uni.$emit(addEvent.value, { entityCode: res.entityCode, data: newAll })
|
|
301
|
-
if (editEvent.value)
|
|
302
|
-
uni.$emit(editEvent.value, res.entityCode)
|
|
303
|
-
|
|
304
|
-
// ★ 通知 wui-select-popup 刷新列表数据
|
|
305
|
-
uni.$emit('selectPopup:refresh', sourceId.value)
|
|
306
|
-
|
|
307
|
-
subLoading.value = false
|
|
308
|
-
router.back()
|
|
309
|
-
}).catch((error: any) => {
|
|
310
|
-
subLoading.value = false
|
|
311
|
-
globalToast.error(error.message)
|
|
312
|
-
})
|
|
313
|
-
}
|
|
314
|
-
catch (error) {
|
|
315
|
-
console.log('error:', error)
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// 跳转勾选页面
|
|
320
|
-
function gotoSlect(group: Groups) {
|
|
321
|
-
router.push(`/pages/select-list/index?sourceId=${group.id}&title=${pageTitle.value}&selectEvent=${SELECTEVENT}&sendSelectEvent=${SENDSELECTEVENT}&extControlType=${''}&cardModel=complex`)
|
|
322
|
-
// 发送数据给选择页面,延迟发送防止页面不刷新
|
|
323
|
-
setTimeout(() => {
|
|
324
|
-
console.log('selectData:', selectData.value)
|
|
325
|
-
uni.$emit(SENDSELECTEVENT, toRaw(selectData.value[group.id].data))
|
|
326
|
-
}, 100)
|
|
327
|
-
|
|
328
|
-
// 接收勾选页面发送过来的数据
|
|
329
|
-
uni.$once(SELECTEVENT, (data: any) => {
|
|
330
|
-
selectData.value[group.id].data = data
|
|
331
|
-
getSelectData(data, group.id)
|
|
332
|
-
uni.$off(SELECTEVENT)
|
|
333
|
-
})
|
|
334
|
-
}
|
|
335
|
-
// 获取勾选数据
|
|
336
|
-
async function getSelectData(data: any, relationID: string) {
|
|
337
|
-
try {
|
|
338
|
-
// 获取勾选数据
|
|
339
|
-
let codes = ''
|
|
340
|
-
data.forEach((item: any) => {
|
|
341
|
-
codes += `codes=${item.split('@R@')[0]}&`
|
|
342
|
-
})
|
|
343
|
-
selectData.value[relationID].loading = true
|
|
344
|
-
const res = await selectDatas(relationID, codes)
|
|
345
|
-
if (pageConfig.value.entity) {
|
|
346
|
-
pageConfig.value.entity.arrayMap[relationID] = res.entities
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
pageConfig.value.entity = { arrayMap: { [relationID]: res.entities }, code: '', fieldMap: {} }
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
selectData.value[relationID].loading = false
|
|
353
|
-
}
|
|
354
|
-
catch (error) {
|
|
355
|
-
console.log('error:', error)
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// 获取添加的行数据
|
|
360
|
-
async function getAddData(data: any, relationID: string) {
|
|
361
|
-
addEvent.value = ''
|
|
362
|
-
try {
|
|
363
|
-
let codes = ''
|
|
364
|
-
selectData.value[relationID].data = [
|
|
365
|
-
...data,
|
|
366
|
-
...selectData.value[relationID].data,
|
|
367
|
-
]
|
|
368
|
-
selectData.value[relationID].data.forEach((item: any) => {
|
|
369
|
-
codes += `codes=${item}&`
|
|
370
|
-
})
|
|
371
|
-
selectData.value[relationID].loading = true
|
|
372
|
-
const res = await selectDatas(relationID, codes)
|
|
373
|
-
if (pageConfig.value.entity) {
|
|
374
|
-
if (pageConfig.value.entity.arrayMap) {
|
|
375
|
-
pageConfig.value.entity.arrayMap[relationID] = res.entities
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
pageConfig.value.entity.arrayMap = { [relationID]: res.entities }
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
pageConfig.value.entity = { arrayMap: { [relationID]: res.entities }, code: '', fieldMap: {} }
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
selectData.value[relationID].loading = false
|
|
386
|
-
}
|
|
387
|
-
catch (error) {
|
|
388
|
-
console.log('error:', error)
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// 获取编辑数据
|
|
393
|
-
async function getEditData(data: any, relationID: string) {
|
|
394
|
-
editEvent.value = ''
|
|
395
|
-
try {
|
|
396
|
-
let codes = ''
|
|
397
|
-
selectData.value[relationID].data.forEach((item: any) => {
|
|
398
|
-
codes += `codes=${item}&`
|
|
399
|
-
})
|
|
400
|
-
selectData.value[relationID].loading = true
|
|
401
|
-
const res = await selectDatas(relationID, codes)
|
|
402
|
-
pageConfig.value.entity.arrayMap[relationID] = res.entities
|
|
403
|
-
selectData.value[relationID].loading = false
|
|
404
|
-
}
|
|
405
|
-
catch (error) {
|
|
406
|
-
console.log('error:', error)
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
// 跳转添加页面
|
|
410
|
-
function gotoAdd(group: Groups) {
|
|
411
|
-
const addEvent = generateHighResolutionID()
|
|
412
|
-
router.push(`/pages/edit-page/index?sourceId=${group.id}&id=&title=${group.title}&addEvent=${addEvent}`)
|
|
413
|
-
// 接收添加页面发送过来的数据
|
|
414
|
-
uni.$once(addEvent, (data: any) => {
|
|
415
|
-
uni.$off(addEvent)
|
|
416
|
-
getAddData([data.entityCode], group.id)
|
|
417
|
-
})
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// 跳转编辑页面
|
|
421
|
-
function edit(group: Groups, field: Entities) {
|
|
422
|
-
const editEvent = generateHighResolutionID()
|
|
423
|
-
router.push(`/pages/edit-page/index?sourceId=${group.id}&id=${field.code}&title=${group.title}&editEvent=${editEvent}`)
|
|
424
|
-
// 接收编辑页面发送过来的数据
|
|
425
|
-
uni.$once(editEvent, (data: any) => {
|
|
426
|
-
uni.$off(editEvent)
|
|
427
|
-
getEditData([data], group.id)
|
|
428
|
-
})
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// 跳转行添加页面
|
|
432
|
-
function gotoRowAdd(group: Groups) {
|
|
433
|
-
const rowAddEvent = generateHighResolutionID()
|
|
434
|
-
const sendRowAddEvent = generateHighResolutionID()
|
|
435
|
-
router.push(`/pages/edit-page/index?sourceId=${group.id}&id=&title=${group.title}&rowAddEvent=${rowAddEvent}&sendRowAddEvent=${sendRowAddEvent}`)
|
|
436
|
-
// 发送数据给行添加页面
|
|
437
|
-
setTimeout(() => {
|
|
438
|
-
// groups: conf.groups,
|
|
439
|
-
// entity: conf.entity,
|
|
440
|
-
const groupf = {
|
|
441
|
-
...group,
|
|
442
|
-
type: 'fieldGroup',
|
|
443
|
-
}
|
|
444
|
-
uni.$emit(sendRowAddEvent, { groups: [groupf], entity: pageConfig.value?.entity?.arrayMap[group.id] })
|
|
445
|
-
}, 100)
|
|
446
|
-
|
|
447
|
-
// 接收添加页面发送过来的数据
|
|
448
|
-
uni.$once(rowAddEvent, (data: any) => {
|
|
449
|
-
const newData: { [key: string]: any } = {}
|
|
450
|
-
const id = generateHighResolutionID()
|
|
451
|
-
for (const key in data) {
|
|
452
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
453
|
-
newData[key] = data[key]
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (rowData.value[group.id]) {
|
|
458
|
-
rowData.value[group.id].push({
|
|
459
|
-
...newData,
|
|
460
|
-
id,
|
|
461
|
-
})
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
rowData.value[group.id] = [{
|
|
465
|
-
...newData,
|
|
466
|
-
id,
|
|
467
|
-
}]
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
console.log(pageConfig.value.entity)
|
|
471
|
-
// 显示数据
|
|
472
|
-
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap[group.id]) {
|
|
473
|
-
pageConfig.value.entity.arrayMap[group.id].push({
|
|
474
|
-
arrayMap: {},
|
|
475
|
-
code: id,
|
|
476
|
-
fieldMap: {
|
|
477
|
-
...data,
|
|
478
|
-
},
|
|
479
|
-
})
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap) {
|
|
483
|
-
pageConfig.value.entity = {
|
|
484
|
-
arrayMap: {
|
|
485
|
-
...pageConfig.value.entity.arrayMap,
|
|
486
|
-
[group.id]: [{
|
|
487
|
-
arrayMap: {},
|
|
488
|
-
code: id,
|
|
489
|
-
fieldMap: {
|
|
490
|
-
...data,
|
|
491
|
-
},
|
|
492
|
-
}],
|
|
493
|
-
},
|
|
494
|
-
code: id,
|
|
495
|
-
fieldMap: {},
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
pageConfig.value.entity = {
|
|
500
|
-
arrayMap: {
|
|
501
|
-
[group.id]: [{
|
|
502
|
-
arrayMap: {},
|
|
503
|
-
code: id,
|
|
504
|
-
fieldMap: {
|
|
505
|
-
...data,
|
|
506
|
-
},
|
|
507
|
-
}],
|
|
508
|
-
},
|
|
509
|
-
code: id,
|
|
510
|
-
fieldMap: {},
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
console.log(rowData.value, 'rowData.value')
|
|
516
|
-
uni.$off(rowAddEvent)
|
|
517
|
-
})
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// 跳转编辑行页面
|
|
521
|
-
function rowEdit(group: Groups, field: Entities) {
|
|
522
|
-
const rowAddEvent = generateHighResolutionID()
|
|
523
|
-
const sendRowAddEvent = generateHighResolutionID()
|
|
524
|
-
router.push(`/pages/edit-page/index?sourceId=${group.id}&id=&title=${group.title}&rowAddEvent=${rowAddEvent}&sendRowAddEvent=${sendRowAddEvent}`)
|
|
525
|
-
// 发送数据给行编辑页面
|
|
526
|
-
setTimeout(() => {
|
|
527
|
-
// groups: conf.groups,
|
|
528
|
-
// entity: conf.entity,
|
|
529
|
-
const groupf = {
|
|
530
|
-
...group,
|
|
531
|
-
type: 'fieldGroup',
|
|
532
|
-
}
|
|
533
|
-
uni.$emit(sendRowAddEvent, { groups: [groupf], entity: field })
|
|
534
|
-
}, 100)
|
|
535
|
-
|
|
536
|
-
// 接收行编辑页面发送过来的数据
|
|
537
|
-
uni.$once(rowAddEvent, (data: any) => {
|
|
538
|
-
console.log('rowAddEvent', data)
|
|
539
|
-
const newData: { [key: string]: any } = {}
|
|
540
|
-
for (const key in data) {
|
|
541
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
542
|
-
newData[key] = data[key]
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
if (rowData.value[group.id]) {
|
|
547
|
-
rowData.value[group.id] = rowData.value[group.id].filter((item: any) => item.id !== newData.id)
|
|
548
|
-
rowData.value[group.id].push({
|
|
549
|
-
...newData,
|
|
550
|
-
})
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
// 显示数据
|
|
554
|
-
if (pageConfig.value.entity.arrayMap[group.id]) {
|
|
555
|
-
const index = pageConfig.value.entity.arrayMap[group.id].findIndex((item: any) => item.code === newData.id)
|
|
556
|
-
console.log('index', index)
|
|
557
|
-
pageConfig.value.entity.arrayMap[group.id][index] = {
|
|
558
|
-
arrayMap: {},
|
|
559
|
-
code: '',
|
|
560
|
-
fieldMap: {
|
|
561
|
-
...newData,
|
|
562
|
-
},
|
|
563
|
-
}
|
|
564
|
-
// pageConfig.value.entity.arrayMap[group.id] = pageConfig.value.entity.arrayMap[group.id].filter((item: any) => item.code !== newData.id)
|
|
565
|
-
// pageConfig.value.entity.arrayMap[group.id].push({
|
|
566
|
-
// arrayMap: {},
|
|
567
|
-
// code: '',
|
|
568
|
-
// fieldMap: {
|
|
569
|
-
// ...newData,
|
|
570
|
-
// },
|
|
571
|
-
// })
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
console.log(rowData.value, group.id, 'rowData.value')
|
|
575
|
-
uni.$off(rowAddEvent)
|
|
576
|
-
})
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* 判断编辑按钮是否可以点击
|
|
581
|
-
*/
|
|
582
|
-
function canClick(group: Groups) {
|
|
583
|
-
if (group.max) {
|
|
584
|
-
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap[group.id] && pageConfig.value.entity.arrayMap[group.id].length >= group.max) {
|
|
585
|
-
return true
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
return false
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
else {
|
|
592
|
-
return false
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* 删除行数据
|
|
598
|
-
*/
|
|
599
|
-
function remove(group: Groups, field: Entities) {
|
|
600
|
-
// 行编辑数据
|
|
601
|
-
if (rowData.value[group.id]) {
|
|
602
|
-
rowData.value[group.id] = rowData.value[group.id].filter((item: any) => item.id !== (field.code || field.fieldMap.id))
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
// 显示数据
|
|
606
|
-
if (pageConfig.value.entity.arrayMap[group.id]) {
|
|
607
|
-
pageConfig.value.entity.arrayMap[group.id] = pageConfig.value.entity.arrayMap[group.id].filter((item: any) => (item.code || item.fieldMap.id) !== (field.code || field.fieldMap.id))
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// 行选择数据
|
|
611
|
-
if (selectData.value[group.id]) {
|
|
612
|
-
selectData.value[group.id].data = selectData.value[group.id].data.filter((item: any) => item.split('@R@')[0] !== field.code)
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
console.log(rowData.value[group.id], field, '删除行数据')
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* 批量上传文件
|
|
619
|
-
*/
|
|
620
|
-
function handleFileChange(e: any, group: Groups) {
|
|
621
|
-
console.log(e, group)
|
|
622
|
-
const newData: { [key: string]: any } = {
|
|
623
|
-
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
group.fields.forEach((item) => {
|
|
627
|
-
newData[item.sourceId] = ''
|
|
628
|
-
})
|
|
629
|
-
const id = generateHighResolutionID()
|
|
630
|
-
if (group.batchAddFileField)
|
|
631
|
-
newData[group.batchAddFileField?.sourceId] = e.file
|
|
632
|
-
|
|
633
|
-
if (rowData.value[group.id]) {
|
|
634
|
-
rowData.value[group.id].push({
|
|
635
|
-
...newData,
|
|
636
|
-
id,
|
|
637
|
-
})
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
rowData.value[group.id] = [{
|
|
641
|
-
...newData,
|
|
642
|
-
id,
|
|
643
|
-
}]
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
// 显示数据
|
|
647
|
-
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap[group.id]) {
|
|
648
|
-
pageConfig.value.entity.arrayMap[group.id].push({
|
|
649
|
-
arrayMap: {},
|
|
650
|
-
code: id,
|
|
651
|
-
fieldMap: {
|
|
652
|
-
...newData,
|
|
653
|
-
},
|
|
654
|
-
})
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap) {
|
|
658
|
-
pageConfig.value.entity = {
|
|
659
|
-
arrayMap: {
|
|
660
|
-
...pageConfig.value.entity.arrayMap,
|
|
661
|
-
[group.id]: [{
|
|
662
|
-
arrayMap: {},
|
|
663
|
-
code: id,
|
|
664
|
-
fieldMap: {
|
|
665
|
-
...newData,
|
|
666
|
-
},
|
|
667
|
-
}],
|
|
668
|
-
},
|
|
669
|
-
code: id,
|
|
670
|
-
fieldMap: {},
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
else {
|
|
674
|
-
pageConfig.value.entity = {
|
|
675
|
-
arrayMap: {
|
|
676
|
-
[group.id]: [{
|
|
677
|
-
arrayMap: {},
|
|
678
|
-
code: id,
|
|
679
|
-
fieldMap: {
|
|
680
|
-
...newData,
|
|
681
|
-
},
|
|
682
|
-
}],
|
|
683
|
-
},
|
|
684
|
-
code: id,
|
|
685
|
-
fieldMap: {},
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
</script>
|
|
691
|
-
|
|
692
|
-
<template>
|
|
693
|
-
<view class="relative h-[calc(100vh-44px)] w-100vw overflow-auto bg-[#f8f9fb] dark:bg-[var(--wot-dark-background)]">
|
|
694
|
-
<view v-if="loading" class="flex justify-center p-3">
|
|
695
|
-
<wd-loading />
|
|
696
|
-
</view>
|
|
697
|
-
<view v-else>
|
|
698
|
-
<wd-cell v-if="pageType === '树'" title="分组" title-width="100px">
|
|
699
|
-
<TreeSelectControl
|
|
700
|
-
v-model="tree" select-mode="single" :source-id="sourceId" title="分组"
|
|
701
|
-
ext-control-type="relselect " :readonly="false" :clearable="false"
|
|
702
|
-
/>
|
|
703
|
-
</wd-cell>
|
|
704
|
-
<wd-collapse v-model="collapses" accordion>
|
|
705
|
-
<wd-collapse-item v-for="group in groupsformat" :key="group.id" :name="group.id">
|
|
706
|
-
<template #title>
|
|
707
|
-
<view class="flex items-center justify-between">
|
|
708
|
-
<view class="flex-1 flex items-center justify-between pr-2">
|
|
709
|
-
<view>{{ group.title }}</view>
|
|
710
|
-
<view v-if="group.type === 'relation'">
|
|
711
|
-
<view v-if="selectData[group.id]?.loading" class="flex justify-center p-3">
|
|
712
|
-
<wd-loading />
|
|
713
|
-
</view>
|
|
714
|
-
<view v-else>
|
|
715
|
-
<view v-if="!group.readOnly" class="w-upload flex justify-center gap-2">
|
|
716
|
-
<batchUploadFile
|
|
717
|
-
v-if="group.batchAddFileField && group.batchAddFileField.extControlType === 'file'"
|
|
718
|
-
@handle-file-change="(e) => { handleFileChange(e, group) }"
|
|
719
|
-
/>
|
|
720
|
-
<wd-button
|
|
721
|
-
v-if="group.buttons.includes('selectAdd')" :disabled="canClick(group)" type="info"
|
|
722
|
-
size="small" @click.stop="gotoSlect(group)"
|
|
723
|
-
>
|
|
724
|
-
选择
|
|
725
|
-
</wd-button>
|
|
726
|
-
<wd-button
|
|
727
|
-
v-if="group.buttons.includes('dtmplAdd')" :disabled="canClick(group)" type="primary"
|
|
728
|
-
size="small" @click.stop="gotoAdd(group)"
|
|
729
|
-
>
|
|
730
|
-
新增
|
|
731
|
-
</wd-button>
|
|
732
|
-
<wd-button
|
|
733
|
-
v-if="group.buttons.includes('rowAdd')" :disabled="canClick(group)" type="primary" size="small"
|
|
734
|
-
@click.stop="gotoRowAdd(group)"
|
|
735
|
-
>
|
|
736
|
-
新增
|
|
737
|
-
</wd-button>
|
|
738
|
-
</view>
|
|
739
|
-
</view>
|
|
740
|
-
</view>
|
|
741
|
-
</view>
|
|
742
|
-
<wd-icon :name="collapses === group.id ? 'up' : 'down'" size="24px"></wd-icon>
|
|
743
|
-
</view>
|
|
744
|
-
</template>
|
|
745
|
-
|
|
746
|
-
<FormControl
|
|
747
|
-
v-if="group.type === 'fieldGroup'" ref="formControlRef" :field-group="group"
|
|
748
|
-
:entity="pageConfig?.entity?.fieldMap" :enum-column="Enumcolumn"
|
|
749
|
-
:company-filter="props.companyFilter"
|
|
750
|
-
:company-field-source-id="props.companyFieldSourceId"
|
|
751
|
-
:smart-paste="canSmartPaste"
|
|
752
|
-
/>
|
|
753
|
-
<view v-if="group.type === 'relation'">
|
|
754
|
-
<view v-if="selectData[group.id]?.loading" class="flex justify-center p-3">
|
|
755
|
-
<wd-loading />
|
|
756
|
-
</view>
|
|
757
|
-
<view v-else>
|
|
758
|
-
<view v-for="(field, index) in pageConfig?.entity?.arrayMap[group.id]" :key="field.code">
|
|
759
|
-
<foldCard
|
|
760
|
-
:index="index" :enum-column="{}" :groups="group" :source-id="sourceId" :columns="group.fields"
|
|
761
|
-
model="complex" :data="field"
|
|
762
|
-
>
|
|
763
|
-
<template v-if="!group.readOnly" #buttons>
|
|
764
|
-
<wd-button v-if="group.buttons.includes('dtmplEdit')" size="small" @click="edit(group, field)">
|
|
765
|
-
编辑
|
|
766
|
-
</wd-button>
|
|
767
|
-
<wd-button v-if="group.buttons.includes('rowEdit')" size="small" @click="rowEdit(group, field)">
|
|
768
|
-
编辑
|
|
769
|
-
</wd-button>
|
|
770
|
-
<wd-button
|
|
771
|
-
v-if="group.buttons.includes('singleDelete')" type="danger" size="small"
|
|
772
|
-
@click="remove(group, field)"
|
|
773
|
-
>
|
|
774
|
-
删除
|
|
775
|
-
</wd-button>
|
|
776
|
-
</template>
|
|
777
|
-
</foldCard>
|
|
778
|
-
</view>
|
|
779
|
-
</view>
|
|
780
|
-
</view>
|
|
781
|
-
</wd-collapse-item>
|
|
782
|
-
</wd-collapse>
|
|
783
|
-
<view class="h-12" />
|
|
784
|
-
<view class="fixed bottom-0 left-0 right-0 box-border w-100% flex p-2 bg-white dark:bg-[var(--wot-dark-background)]">
|
|
785
|
-
<wd-button class="flex-1" :loading="subLoading" @click="save">
|
|
786
|
-
保存
|
|
787
|
-
</wd-button>
|
|
788
|
-
</view>
|
|
789
|
-
</view>
|
|
790
|
-
</view>
|
|
791
|
-
</template>
|
|
792
|
-
|
|
793
|
-
<style scoped></style>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, defineOptions, onBeforeMount, onUnmounted, ref, toRaw } from 'vue'
|
|
3
|
+
import { onLoad } from '@dcloudio/uni-app'
|
|
4
|
+
import { useRouter } from 'uni-mini-router'
|
|
5
|
+
import FormControl from '../form-control/form-control.vue'
|
|
6
|
+
import { addPageConfig, editPageConfig, editPageDataSave, enums, selectDatas } from '../../api/page'
|
|
7
|
+
import type { Entities, Enums, Groups, dtmplConfig } from '../../type'
|
|
8
|
+
import { useGlobalToast } from '../../composables/useGlobalToast'
|
|
9
|
+
import foldCard from '../fold-card/fold-card.vue'
|
|
10
|
+
import { generateHighResolutionID } from '../../utils/index'
|
|
11
|
+
import TreeSelectControl from '../tree-select/index.vue'
|
|
12
|
+
import batchUploadFile from '../batch-upload-file/batch-upload-file.vue'
|
|
13
|
+
|
|
14
|
+
defineOptions({
|
|
15
|
+
name: 'WuiEditPage',
|
|
16
|
+
})
|
|
17
|
+
const props = defineProps<{
|
|
18
|
+
companyFilter?: boolean
|
|
19
|
+
companyFieldSourceId?: string
|
|
20
|
+
}>()
|
|
21
|
+
const pageConfig = ref<dtmplConfig>({
|
|
22
|
+
id: '',
|
|
23
|
+
title: '',
|
|
24
|
+
groups: [],
|
|
25
|
+
entity: {
|
|
26
|
+
arrayMap: {},
|
|
27
|
+
code: '',
|
|
28
|
+
fieldMap: {},
|
|
29
|
+
},
|
|
30
|
+
buttons: [],
|
|
31
|
+
smartPaste: false,
|
|
32
|
+
})
|
|
33
|
+
const tree = ref({ value: '', sourceId: '' })
|
|
34
|
+
const loading = ref(false)
|
|
35
|
+
const globalToast = useGlobalToast()
|
|
36
|
+
const router = useRouter()
|
|
37
|
+
const mainCode = ref('')
|
|
38
|
+
const id = ref('')
|
|
39
|
+
const sourceId = ref('')
|
|
40
|
+
const formControlRef = ref()
|
|
41
|
+
const subLoading = ref(false)
|
|
42
|
+
const Enumcolumn = ref<Enums | undefined>()
|
|
43
|
+
const pageTitle = ref('')
|
|
44
|
+
const pageType = ref('')
|
|
45
|
+
const selectData = ref<{ [key: string]: { loading: boolean, data: string[] } }>({})
|
|
46
|
+
const rowData = ref<{ [key: string]: { [key: string]: any } }>({})
|
|
47
|
+
const action = ref('')
|
|
48
|
+
const hydrocarbonProgramToken = ref('')
|
|
49
|
+
const token = ref('')
|
|
50
|
+
// 全局事件名称
|
|
51
|
+
const SELECTEVENT = generateHighResolutionID()
|
|
52
|
+
const SENDSELECTEVENT = generateHighResolutionID()
|
|
53
|
+
const addEvent = ref('')
|
|
54
|
+
const editEvent = ref('')
|
|
55
|
+
const rowAddEvent = ref('')
|
|
56
|
+
const sendRowAddEvent = ref('')
|
|
57
|
+
const smartPaste=ref(false)
|
|
58
|
+
// 折叠面板
|
|
59
|
+
const collapses = ref('')
|
|
60
|
+
const groupsformat = computed(() => {
|
|
61
|
+
return pageConfig.value.groups.filter((item: Groups) => {
|
|
62
|
+
return item.displayConfig.includes('displayed')
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
const canSmartPaste=computed(()=>{
|
|
66
|
+
return pageConfig.value?.smartPaste??false
|
|
67
|
+
})
|
|
68
|
+
onLoad((option: any) => {
|
|
69
|
+
sourceId.value = option.sourceId
|
|
70
|
+
mainCode.value = option.mainCode || ''
|
|
71
|
+
id.value = option.id || ''
|
|
72
|
+
pageTitle.value = option.title
|
|
73
|
+
addEvent.value = option.addEvent
|
|
74
|
+
editEvent.value = option.editEvent
|
|
75
|
+
pageType.value = option.pageType || ''
|
|
76
|
+
rowAddEvent.value = option.rowAddEvent
|
|
77
|
+
sendRowAddEvent.value = option.sendRowAddEvent
|
|
78
|
+
getEditPageConfig()
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
onUnmounted(() => {
|
|
82
|
+
console.log('页面卸载')
|
|
83
|
+
// 勿在卸载时 $off 勾选事件:跳转勾选页会触发 onUnmounted,导致 $once(SELECTEVENT) 被提前移除
|
|
84
|
+
uni.$off(rowAddEvent.value)
|
|
85
|
+
// uni.$off(addEvent.value)
|
|
86
|
+
uni.$off(editEvent.value)
|
|
87
|
+
uni.$off(sendRowAddEvent.value)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
onBeforeMount(() => {
|
|
91
|
+
action.value = uni.getStorageSync('BASE_URL')
|
|
92
|
+
hydrocarbonProgramToken.value = uni.getStorageSync('HYDROCARBON_PROGRAM_TOKEN')
|
|
93
|
+
token.value = uni.getStorageSync('TOKEN')
|
|
94
|
+
})
|
|
95
|
+
// 获取编辑页面配置
|
|
96
|
+
async function getEditPageConfig() {
|
|
97
|
+
// 判断是否为行新增事件
|
|
98
|
+
if (sendRowAddEvent.value) {
|
|
99
|
+
uni.$once(sendRowAddEvent.value, (conf: any) => {
|
|
100
|
+
console.log('sendRowAddEvent.value', conf)
|
|
101
|
+
pageConfig.value = {
|
|
102
|
+
id: '',
|
|
103
|
+
title: '行添加',
|
|
104
|
+
groups: conf.groups,
|
|
105
|
+
entity: conf.entity || {
|
|
106
|
+
arrayMap: {},
|
|
107
|
+
code: '',
|
|
108
|
+
fieldMap: {},
|
|
109
|
+
},
|
|
110
|
+
buttons: [],
|
|
111
|
+
}
|
|
112
|
+
getEnums()
|
|
113
|
+
uni.$off(sendRowAddEvent.value)
|
|
114
|
+
})
|
|
115
|
+
setTimeout(() => {
|
|
116
|
+
const visibleGroups = pageConfig.value.groups.filter((item: Groups) => item.displayConfig.includes('displayed'))
|
|
117
|
+
collapses.value = visibleGroups.length > 0 ? visibleGroups[0].id : ''
|
|
118
|
+
}, 100)
|
|
119
|
+
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
let res = null
|
|
125
|
+
loading.value = true
|
|
126
|
+
if (id.value) {
|
|
127
|
+
res = await editPageConfig(sourceId.value, id.value)
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
res = await addPageConfig(sourceId.value)
|
|
131
|
+
}
|
|
132
|
+
loading.value = false
|
|
133
|
+
// 初始化折叠面板
|
|
134
|
+
if (res.dtmplConfig) {
|
|
135
|
+
uni.setNavigationBarTitle({
|
|
136
|
+
title: `${res.dtmplConfig.title}`,
|
|
137
|
+
})
|
|
138
|
+
pageConfig.value = res.dtmplConfig
|
|
139
|
+
const visibleGroups = pageConfig.value.groups.filter((item: Groups) => item.displayConfig.includes('displayed'))
|
|
140
|
+
collapses.value = visibleGroups.length > 0 ? visibleGroups[0].id : ''
|
|
141
|
+
|
|
142
|
+
pageConfig.value.groups.forEach((item: Groups) => {
|
|
143
|
+
// 初始化勾选数据
|
|
144
|
+
if (item.type === 'relation' && (item.buttons.includes('dtmplAdd') || item.buttons.includes('selectAdd'))) {
|
|
145
|
+
selectData.value[item.id] = {
|
|
146
|
+
data: (pageConfig.value.entity && pageConfig.value.entity.arrayMap[item.id]?.map((sebitem: any) => {
|
|
147
|
+
return `${sebitem.code}`
|
|
148
|
+
})) || [],
|
|
149
|
+
loading: false,
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// 初始化行数据
|
|
153
|
+
if (item.type === 'relation' && item.buttons.includes('rowAdd')) {
|
|
154
|
+
rowData.value[item.id] = (pageConfig.value.entity && pageConfig.value.entity.arrayMap[item.id]?.map((sebitem: any) => {
|
|
155
|
+
return {
|
|
156
|
+
id: sebitem.code,
|
|
157
|
+
...sebitem.fieldMap,
|
|
158
|
+
}
|
|
159
|
+
})) || []
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
getEnums()
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
loading.value = false
|
|
167
|
+
console.log('error:', error)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// 获取枚举
|
|
171
|
+
async function getEnums() {
|
|
172
|
+
try {
|
|
173
|
+
const params: string[] = []
|
|
174
|
+
pageConfig.value.groups?.forEach((item: any) => {
|
|
175
|
+
item.fields?.forEach((subItem: any) => {
|
|
176
|
+
if (subItem.extControlType === 'select' || subItem.extControlType === 'multiselect') {
|
|
177
|
+
params.push(`mstrucIds=${subItem.mstrucId}`)
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
if (!params.length)
|
|
182
|
+
return
|
|
183
|
+
const res = await enums(params.join('&'))
|
|
184
|
+
Enumcolumn.value = res.enumMap || {}
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
console.log('error:', error)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 行添加保存
|
|
192
|
+
async function rowAddSave(all: any) {
|
|
193
|
+
console.log('行数据', all)
|
|
194
|
+
router.back()
|
|
195
|
+
uni.$emit(rowAddEvent.value, all)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// 保存
|
|
199
|
+
async function save() {
|
|
200
|
+
// 判断是否为树添加
|
|
201
|
+
if (pageType.value === '树' && !tree.value.value) {
|
|
202
|
+
return globalToast.warning('请选择分组')
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
const formArray: any[] = []
|
|
207
|
+
formControlRef.value.forEach((element: any) => {
|
|
208
|
+
formArray.push(element.submit())
|
|
209
|
+
})
|
|
210
|
+
const res = await Promise.all(formArray)
|
|
211
|
+
const beasData = res.reduce((acc, cur) => {
|
|
212
|
+
return { ...acc, ...cur }
|
|
213
|
+
}, {})
|
|
214
|
+
subLoading.value = true
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
* 421639572264099847.$$flag$$:true
|
|
219
|
+
421639572264099847[0].$$relation$$:拥有角色
|
|
220
|
+
421639572264099847[0].唯一编码:448591711817211909
|
|
221
|
+
*/
|
|
222
|
+
let all: Record<string, any> = {}
|
|
223
|
+
for (const key in selectData.value) {
|
|
224
|
+
if (Object.prototype.hasOwnProperty.call(selectData.value, key)) {
|
|
225
|
+
const element = selectData.value[key].data
|
|
226
|
+
if (element) {
|
|
227
|
+
all[`${key}.$$flag$$`] = true
|
|
228
|
+
element.forEach((item, index) => {
|
|
229
|
+
all[`${key}[${index}].$$relation$$`] = pageConfig.value.groups.find(item => item.id === key)?.relationNames[0]
|
|
230
|
+
if (typeof item === 'string') {
|
|
231
|
+
all[`${key}[${index}].唯一编码`] = item.split('@R@')[0]
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
console.log('rowData.value', rowData.value)
|
|
238
|
+
for (const key in rowData.value) {
|
|
239
|
+
if (Object.prototype.hasOwnProperty.call(rowData.value, key)) {
|
|
240
|
+
const element1 = rowData.value[key]
|
|
241
|
+
if (element1) {
|
|
242
|
+
all[`${key}.$$flag$$`] = true
|
|
243
|
+
element1.forEach((item: any, index: any) => {
|
|
244
|
+
all[`${key}[${index}].$$relation$$`] = pageConfig.value.groups.find(item => item.id === key)?.relationNames[0]
|
|
245
|
+
all[`${key}[${index}].唯一编码`] = item.id
|
|
246
|
+
|
|
247
|
+
for (const key1 in item) {
|
|
248
|
+
if (Object.prototype.hasOwnProperty.call(item, key1)) {
|
|
249
|
+
console.log('item[key1]', item[key1])
|
|
250
|
+
if (item[key1] && item[key1].response) {
|
|
251
|
+
all[`${key}[${index}].${key1}`] = JSON.stringify({
|
|
252
|
+
valid: item[key1].disabled ? 'old' : 'new',
|
|
253
|
+
fileKey: JSON.parse(item[key1].response).fileKey,
|
|
254
|
+
fileName: item[key1].name,
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (typeof item[key1] === 'string') {
|
|
259
|
+
// all[`${key}[${index}].${key1}`] = item[key1].split('@R@')[0]
|
|
260
|
+
all[`${key}[${index}].${key1}`] = item[key1]
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
console.log('all', all, beasData)
|
|
269
|
+
all = {
|
|
270
|
+
...all,
|
|
271
|
+
...beasData,
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// 判断是否为行添加
|
|
275
|
+
if (rowAddEvent.value) {
|
|
276
|
+
subLoading.value = false
|
|
277
|
+
return rowAddSave({ ...all, id: pageConfig.value.entity.code })
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const newAll: Record<string, any> = {}
|
|
281
|
+
|
|
282
|
+
for (const key1 in all) {
|
|
283
|
+
if (Object.prototype.hasOwnProperty.call(all, key1)) {
|
|
284
|
+
if (all[key1] && all[key1].response) {
|
|
285
|
+
newAll[`${key1}`] = JSON.stringify({
|
|
286
|
+
valid: all[key1].disabled ? 'old' : 'new',
|
|
287
|
+
fileKey: JSON.parse(all[key1].response).fileKey,
|
|
288
|
+
fileName: all[key1].name,
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
newAll[key1] = all[key1]
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
editPageDataSave(tree.value.sourceId || sourceId.value, id.value, newAll, tree.value.value || mainCode.value).then((res: any) => {
|
|
298
|
+
// 发送事件
|
|
299
|
+
if (addEvent.value)
|
|
300
|
+
uni.$emit(addEvent.value, { entityCode: res.entityCode, data: newAll })
|
|
301
|
+
if (editEvent.value)
|
|
302
|
+
uni.$emit(editEvent.value, res.entityCode)
|
|
303
|
+
|
|
304
|
+
// ★ 通知 wui-select-popup 刷新列表数据
|
|
305
|
+
uni.$emit('selectPopup:refresh', sourceId.value)
|
|
306
|
+
|
|
307
|
+
subLoading.value = false
|
|
308
|
+
router.back()
|
|
309
|
+
}).catch((error: any) => {
|
|
310
|
+
subLoading.value = false
|
|
311
|
+
globalToast.error(error.message)
|
|
312
|
+
})
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
console.log('error:', error)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// 跳转勾选页面
|
|
320
|
+
function gotoSlect(group: Groups) {
|
|
321
|
+
router.push(`/pages/select-list/index?sourceId=${group.id}&title=${pageTitle.value}&selectEvent=${SELECTEVENT}&sendSelectEvent=${SENDSELECTEVENT}&extControlType=${''}&cardModel=complex`)
|
|
322
|
+
// 发送数据给选择页面,延迟发送防止页面不刷新
|
|
323
|
+
setTimeout(() => {
|
|
324
|
+
console.log('selectData:', selectData.value)
|
|
325
|
+
uni.$emit(SENDSELECTEVENT, toRaw(selectData.value[group.id].data))
|
|
326
|
+
}, 100)
|
|
327
|
+
|
|
328
|
+
// 接收勾选页面发送过来的数据
|
|
329
|
+
uni.$once(SELECTEVENT, (data: any) => {
|
|
330
|
+
selectData.value[group.id].data = data
|
|
331
|
+
getSelectData(data, group.id)
|
|
332
|
+
uni.$off(SELECTEVENT)
|
|
333
|
+
})
|
|
334
|
+
}
|
|
335
|
+
// 获取勾选数据
|
|
336
|
+
async function getSelectData(data: any, relationID: string) {
|
|
337
|
+
try {
|
|
338
|
+
// 获取勾选数据
|
|
339
|
+
let codes = ''
|
|
340
|
+
data.forEach((item: any) => {
|
|
341
|
+
codes += `codes=${item.split('@R@')[0]}&`
|
|
342
|
+
})
|
|
343
|
+
selectData.value[relationID].loading = true
|
|
344
|
+
const res = await selectDatas(relationID, codes)
|
|
345
|
+
if (pageConfig.value.entity) {
|
|
346
|
+
pageConfig.value.entity.arrayMap[relationID] = res.entities
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
pageConfig.value.entity = { arrayMap: { [relationID]: res.entities }, code: '', fieldMap: {} }
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
selectData.value[relationID].loading = false
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
console.log('error:', error)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// 获取添加的行数据
|
|
360
|
+
async function getAddData(data: any, relationID: string) {
|
|
361
|
+
addEvent.value = ''
|
|
362
|
+
try {
|
|
363
|
+
let codes = ''
|
|
364
|
+
selectData.value[relationID].data = [
|
|
365
|
+
...data,
|
|
366
|
+
...selectData.value[relationID].data,
|
|
367
|
+
]
|
|
368
|
+
selectData.value[relationID].data.forEach((item: any) => {
|
|
369
|
+
codes += `codes=${item}&`
|
|
370
|
+
})
|
|
371
|
+
selectData.value[relationID].loading = true
|
|
372
|
+
const res = await selectDatas(relationID, codes)
|
|
373
|
+
if (pageConfig.value.entity) {
|
|
374
|
+
if (pageConfig.value.entity.arrayMap) {
|
|
375
|
+
pageConfig.value.entity.arrayMap[relationID] = res.entities
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
pageConfig.value.entity.arrayMap = { [relationID]: res.entities }
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
pageConfig.value.entity = { arrayMap: { [relationID]: res.entities }, code: '', fieldMap: {} }
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
selectData.value[relationID].loading = false
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
console.log('error:', error)
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// 获取编辑数据
|
|
393
|
+
async function getEditData(data: any, relationID: string) {
|
|
394
|
+
editEvent.value = ''
|
|
395
|
+
try {
|
|
396
|
+
let codes = ''
|
|
397
|
+
selectData.value[relationID].data.forEach((item: any) => {
|
|
398
|
+
codes += `codes=${item}&`
|
|
399
|
+
})
|
|
400
|
+
selectData.value[relationID].loading = true
|
|
401
|
+
const res = await selectDatas(relationID, codes)
|
|
402
|
+
pageConfig.value.entity.arrayMap[relationID] = res.entities
|
|
403
|
+
selectData.value[relationID].loading = false
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
console.log('error:', error)
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
// 跳转添加页面
|
|
410
|
+
function gotoAdd(group: Groups) {
|
|
411
|
+
const addEvent = generateHighResolutionID()
|
|
412
|
+
router.push(`/pages/edit-page/index?sourceId=${group.id}&id=&title=${group.title}&addEvent=${addEvent}`)
|
|
413
|
+
// 接收添加页面发送过来的数据
|
|
414
|
+
uni.$once(addEvent, (data: any) => {
|
|
415
|
+
uni.$off(addEvent)
|
|
416
|
+
getAddData([data.entityCode], group.id)
|
|
417
|
+
})
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// 跳转编辑页面
|
|
421
|
+
function edit(group: Groups, field: Entities) {
|
|
422
|
+
const editEvent = generateHighResolutionID()
|
|
423
|
+
router.push(`/pages/edit-page/index?sourceId=${group.id}&id=${field.code}&title=${group.title}&editEvent=${editEvent}`)
|
|
424
|
+
// 接收编辑页面发送过来的数据
|
|
425
|
+
uni.$once(editEvent, (data: any) => {
|
|
426
|
+
uni.$off(editEvent)
|
|
427
|
+
getEditData([data], group.id)
|
|
428
|
+
})
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// 跳转行添加页面
|
|
432
|
+
function gotoRowAdd(group: Groups) {
|
|
433
|
+
const rowAddEvent = generateHighResolutionID()
|
|
434
|
+
const sendRowAddEvent = generateHighResolutionID()
|
|
435
|
+
router.push(`/pages/edit-page/index?sourceId=${group.id}&id=&title=${group.title}&rowAddEvent=${rowAddEvent}&sendRowAddEvent=${sendRowAddEvent}`)
|
|
436
|
+
// 发送数据给行添加页面
|
|
437
|
+
setTimeout(() => {
|
|
438
|
+
// groups: conf.groups,
|
|
439
|
+
// entity: conf.entity,
|
|
440
|
+
const groupf = {
|
|
441
|
+
...group,
|
|
442
|
+
type: 'fieldGroup',
|
|
443
|
+
}
|
|
444
|
+
uni.$emit(sendRowAddEvent, { groups: [groupf], entity: pageConfig.value?.entity?.arrayMap[group.id] })
|
|
445
|
+
}, 100)
|
|
446
|
+
|
|
447
|
+
// 接收添加页面发送过来的数据
|
|
448
|
+
uni.$once(rowAddEvent, (data: any) => {
|
|
449
|
+
const newData: { [key: string]: any } = {}
|
|
450
|
+
const id = generateHighResolutionID()
|
|
451
|
+
for (const key in data) {
|
|
452
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
453
|
+
newData[key] = data[key]
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (rowData.value[group.id]) {
|
|
458
|
+
rowData.value[group.id].push({
|
|
459
|
+
...newData,
|
|
460
|
+
id,
|
|
461
|
+
})
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
rowData.value[group.id] = [{
|
|
465
|
+
...newData,
|
|
466
|
+
id,
|
|
467
|
+
}]
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
console.log(pageConfig.value.entity)
|
|
471
|
+
// 显示数据
|
|
472
|
+
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap[group.id]) {
|
|
473
|
+
pageConfig.value.entity.arrayMap[group.id].push({
|
|
474
|
+
arrayMap: {},
|
|
475
|
+
code: id,
|
|
476
|
+
fieldMap: {
|
|
477
|
+
...data,
|
|
478
|
+
},
|
|
479
|
+
})
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap) {
|
|
483
|
+
pageConfig.value.entity = {
|
|
484
|
+
arrayMap: {
|
|
485
|
+
...pageConfig.value.entity.arrayMap,
|
|
486
|
+
[group.id]: [{
|
|
487
|
+
arrayMap: {},
|
|
488
|
+
code: id,
|
|
489
|
+
fieldMap: {
|
|
490
|
+
...data,
|
|
491
|
+
},
|
|
492
|
+
}],
|
|
493
|
+
},
|
|
494
|
+
code: id,
|
|
495
|
+
fieldMap: {},
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
pageConfig.value.entity = {
|
|
500
|
+
arrayMap: {
|
|
501
|
+
[group.id]: [{
|
|
502
|
+
arrayMap: {},
|
|
503
|
+
code: id,
|
|
504
|
+
fieldMap: {
|
|
505
|
+
...data,
|
|
506
|
+
},
|
|
507
|
+
}],
|
|
508
|
+
},
|
|
509
|
+
code: id,
|
|
510
|
+
fieldMap: {},
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
console.log(rowData.value, 'rowData.value')
|
|
516
|
+
uni.$off(rowAddEvent)
|
|
517
|
+
})
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// 跳转编辑行页面
|
|
521
|
+
function rowEdit(group: Groups, field: Entities) {
|
|
522
|
+
const rowAddEvent = generateHighResolutionID()
|
|
523
|
+
const sendRowAddEvent = generateHighResolutionID()
|
|
524
|
+
router.push(`/pages/edit-page/index?sourceId=${group.id}&id=&title=${group.title}&rowAddEvent=${rowAddEvent}&sendRowAddEvent=${sendRowAddEvent}`)
|
|
525
|
+
// 发送数据给行编辑页面
|
|
526
|
+
setTimeout(() => {
|
|
527
|
+
// groups: conf.groups,
|
|
528
|
+
// entity: conf.entity,
|
|
529
|
+
const groupf = {
|
|
530
|
+
...group,
|
|
531
|
+
type: 'fieldGroup',
|
|
532
|
+
}
|
|
533
|
+
uni.$emit(sendRowAddEvent, { groups: [groupf], entity: field })
|
|
534
|
+
}, 100)
|
|
535
|
+
|
|
536
|
+
// 接收行编辑页面发送过来的数据
|
|
537
|
+
uni.$once(rowAddEvent, (data: any) => {
|
|
538
|
+
console.log('rowAddEvent', data)
|
|
539
|
+
const newData: { [key: string]: any } = {}
|
|
540
|
+
for (const key in data) {
|
|
541
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
542
|
+
newData[key] = data[key]
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (rowData.value[group.id]) {
|
|
547
|
+
rowData.value[group.id] = rowData.value[group.id].filter((item: any) => item.id !== newData.id)
|
|
548
|
+
rowData.value[group.id].push({
|
|
549
|
+
...newData,
|
|
550
|
+
})
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// 显示数据
|
|
554
|
+
if (pageConfig.value.entity.arrayMap[group.id]) {
|
|
555
|
+
const index = pageConfig.value.entity.arrayMap[group.id].findIndex((item: any) => item.code === newData.id)
|
|
556
|
+
console.log('index', index)
|
|
557
|
+
pageConfig.value.entity.arrayMap[group.id][index] = {
|
|
558
|
+
arrayMap: {},
|
|
559
|
+
code: '',
|
|
560
|
+
fieldMap: {
|
|
561
|
+
...newData,
|
|
562
|
+
},
|
|
563
|
+
}
|
|
564
|
+
// pageConfig.value.entity.arrayMap[group.id] = pageConfig.value.entity.arrayMap[group.id].filter((item: any) => item.code !== newData.id)
|
|
565
|
+
// pageConfig.value.entity.arrayMap[group.id].push({
|
|
566
|
+
// arrayMap: {},
|
|
567
|
+
// code: '',
|
|
568
|
+
// fieldMap: {
|
|
569
|
+
// ...newData,
|
|
570
|
+
// },
|
|
571
|
+
// })
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
console.log(rowData.value, group.id, 'rowData.value')
|
|
575
|
+
uni.$off(rowAddEvent)
|
|
576
|
+
})
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* 判断编辑按钮是否可以点击
|
|
581
|
+
*/
|
|
582
|
+
function canClick(group: Groups) {
|
|
583
|
+
if (group.max) {
|
|
584
|
+
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap[group.id] && pageConfig.value.entity.arrayMap[group.id].length >= group.max) {
|
|
585
|
+
return true
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
return false
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
return false
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* 删除行数据
|
|
598
|
+
*/
|
|
599
|
+
function remove(group: Groups, field: Entities) {
|
|
600
|
+
// 行编辑数据
|
|
601
|
+
if (rowData.value[group.id]) {
|
|
602
|
+
rowData.value[group.id] = rowData.value[group.id].filter((item: any) => item.id !== (field.code || field.fieldMap.id))
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// 显示数据
|
|
606
|
+
if (pageConfig.value.entity.arrayMap[group.id]) {
|
|
607
|
+
pageConfig.value.entity.arrayMap[group.id] = pageConfig.value.entity.arrayMap[group.id].filter((item: any) => (item.code || item.fieldMap.id) !== (field.code || field.fieldMap.id))
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// 行选择数据
|
|
611
|
+
if (selectData.value[group.id]) {
|
|
612
|
+
selectData.value[group.id].data = selectData.value[group.id].data.filter((item: any) => item.split('@R@')[0] !== field.code)
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
console.log(rowData.value[group.id], field, '删除行数据')
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* 批量上传文件
|
|
619
|
+
*/
|
|
620
|
+
function handleFileChange(e: any, group: Groups) {
|
|
621
|
+
console.log(e, group)
|
|
622
|
+
const newData: { [key: string]: any } = {
|
|
623
|
+
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
group.fields.forEach((item) => {
|
|
627
|
+
newData[item.sourceId] = ''
|
|
628
|
+
})
|
|
629
|
+
const id = generateHighResolutionID()
|
|
630
|
+
if (group.batchAddFileField)
|
|
631
|
+
newData[group.batchAddFileField?.sourceId] = e.file
|
|
632
|
+
|
|
633
|
+
if (rowData.value[group.id]) {
|
|
634
|
+
rowData.value[group.id].push({
|
|
635
|
+
...newData,
|
|
636
|
+
id,
|
|
637
|
+
})
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
rowData.value[group.id] = [{
|
|
641
|
+
...newData,
|
|
642
|
+
id,
|
|
643
|
+
}]
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// 显示数据
|
|
647
|
+
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap[group.id]) {
|
|
648
|
+
pageConfig.value.entity.arrayMap[group.id].push({
|
|
649
|
+
arrayMap: {},
|
|
650
|
+
code: id,
|
|
651
|
+
fieldMap: {
|
|
652
|
+
...newData,
|
|
653
|
+
},
|
|
654
|
+
})
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
if (pageConfig.value.entity && pageConfig.value.entity.arrayMap) {
|
|
658
|
+
pageConfig.value.entity = {
|
|
659
|
+
arrayMap: {
|
|
660
|
+
...pageConfig.value.entity.arrayMap,
|
|
661
|
+
[group.id]: [{
|
|
662
|
+
arrayMap: {},
|
|
663
|
+
code: id,
|
|
664
|
+
fieldMap: {
|
|
665
|
+
...newData,
|
|
666
|
+
},
|
|
667
|
+
}],
|
|
668
|
+
},
|
|
669
|
+
code: id,
|
|
670
|
+
fieldMap: {},
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
pageConfig.value.entity = {
|
|
675
|
+
arrayMap: {
|
|
676
|
+
[group.id]: [{
|
|
677
|
+
arrayMap: {},
|
|
678
|
+
code: id,
|
|
679
|
+
fieldMap: {
|
|
680
|
+
...newData,
|
|
681
|
+
},
|
|
682
|
+
}],
|
|
683
|
+
},
|
|
684
|
+
code: id,
|
|
685
|
+
fieldMap: {},
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
</script>
|
|
691
|
+
|
|
692
|
+
<template>
|
|
693
|
+
<view class="relative h-[calc(100vh-44px)] w-100vw overflow-auto bg-[#f8f9fb] dark:bg-[var(--wot-dark-background)]">
|
|
694
|
+
<view v-if="loading" class="flex justify-center p-3">
|
|
695
|
+
<wd-loading />
|
|
696
|
+
</view>
|
|
697
|
+
<view v-else>
|
|
698
|
+
<wd-cell v-if="pageType === '树'" title="分组" title-width="100px">
|
|
699
|
+
<TreeSelectControl
|
|
700
|
+
v-model="tree" select-mode="single" :source-id="sourceId" title="分组"
|
|
701
|
+
ext-control-type="relselect " :readonly="false" :clearable="false"
|
|
702
|
+
/>
|
|
703
|
+
</wd-cell>
|
|
704
|
+
<wd-collapse v-model="collapses" accordion>
|
|
705
|
+
<wd-collapse-item v-for="group in groupsformat" :key="group.id" :name="group.id">
|
|
706
|
+
<template #title>
|
|
707
|
+
<view class="flex items-center justify-between">
|
|
708
|
+
<view class="flex-1 flex items-center justify-between pr-2">
|
|
709
|
+
<view>{{ group.title }}</view>
|
|
710
|
+
<view v-if="group.type === 'relation'">
|
|
711
|
+
<view v-if="selectData[group.id]?.loading" class="flex justify-center p-3">
|
|
712
|
+
<wd-loading />
|
|
713
|
+
</view>
|
|
714
|
+
<view v-else>
|
|
715
|
+
<view v-if="!group.readOnly" class="w-upload flex justify-center gap-2">
|
|
716
|
+
<batchUploadFile
|
|
717
|
+
v-if="group.batchAddFileField && group.batchAddFileField.extControlType === 'file'"
|
|
718
|
+
@handle-file-change="(e) => { handleFileChange(e, group) }"
|
|
719
|
+
/>
|
|
720
|
+
<wd-button
|
|
721
|
+
v-if="group.buttons.includes('selectAdd')" :disabled="canClick(group)" type="info"
|
|
722
|
+
size="small" @click.stop="gotoSlect(group)"
|
|
723
|
+
>
|
|
724
|
+
选择
|
|
725
|
+
</wd-button>
|
|
726
|
+
<wd-button
|
|
727
|
+
v-if="group.buttons.includes('dtmplAdd')" :disabled="canClick(group)" type="primary"
|
|
728
|
+
size="small" @click.stop="gotoAdd(group)"
|
|
729
|
+
>
|
|
730
|
+
新增
|
|
731
|
+
</wd-button>
|
|
732
|
+
<wd-button
|
|
733
|
+
v-if="group.buttons.includes('rowAdd')" :disabled="canClick(group)" type="primary" size="small"
|
|
734
|
+
@click.stop="gotoRowAdd(group)"
|
|
735
|
+
>
|
|
736
|
+
新增
|
|
737
|
+
</wd-button>
|
|
738
|
+
</view>
|
|
739
|
+
</view>
|
|
740
|
+
</view>
|
|
741
|
+
</view>
|
|
742
|
+
<wd-icon :name="collapses === group.id ? 'up' : 'down'" size="24px"></wd-icon>
|
|
743
|
+
</view>
|
|
744
|
+
</template>
|
|
745
|
+
|
|
746
|
+
<FormControl
|
|
747
|
+
v-if="group.type === 'fieldGroup'" ref="formControlRef" :field-group="group"
|
|
748
|
+
:entity="pageConfig?.entity?.fieldMap" :enum-column="Enumcolumn"
|
|
749
|
+
:company-filter="props.companyFilter"
|
|
750
|
+
:company-field-source-id="props.companyFieldSourceId"
|
|
751
|
+
:smart-paste="canSmartPaste"
|
|
752
|
+
/>
|
|
753
|
+
<view v-if="group.type === 'relation'">
|
|
754
|
+
<view v-if="selectData[group.id]?.loading" class="flex justify-center p-3">
|
|
755
|
+
<wd-loading />
|
|
756
|
+
</view>
|
|
757
|
+
<view v-else>
|
|
758
|
+
<view v-for="(field, index) in pageConfig?.entity?.arrayMap[group.id]" :key="field.code">
|
|
759
|
+
<foldCard
|
|
760
|
+
:index="index" :enum-column="{}" :groups="group" :source-id="sourceId" :columns="group.fields"
|
|
761
|
+
model="complex" :data="field"
|
|
762
|
+
>
|
|
763
|
+
<template v-if="!group.readOnly" #buttons>
|
|
764
|
+
<wd-button v-if="group.buttons.includes('dtmplEdit')" size="small" @click="edit(group, field)">
|
|
765
|
+
编辑
|
|
766
|
+
</wd-button>
|
|
767
|
+
<wd-button v-if="group.buttons.includes('rowEdit')" size="small" @click="rowEdit(group, field)">
|
|
768
|
+
编辑
|
|
769
|
+
</wd-button>
|
|
770
|
+
<wd-button
|
|
771
|
+
v-if="group.buttons.includes('singleDelete')" type="danger" size="small"
|
|
772
|
+
@click="remove(group, field)"
|
|
773
|
+
>
|
|
774
|
+
删除
|
|
775
|
+
</wd-button>
|
|
776
|
+
</template>
|
|
777
|
+
</foldCard>
|
|
778
|
+
</view>
|
|
779
|
+
</view>
|
|
780
|
+
</view>
|
|
781
|
+
</wd-collapse-item>
|
|
782
|
+
</wd-collapse>
|
|
783
|
+
<view class="h-12" />
|
|
784
|
+
<view class="fixed bottom-0 left-0 right-0 box-border w-100% flex p-2 bg-white dark:bg-[var(--wot-dark-background)]">
|
|
785
|
+
<wd-button class="flex-1" :loading="subLoading" @click="save">
|
|
786
|
+
保存
|
|
787
|
+
</wd-button>
|
|
788
|
+
</view>
|
|
789
|
+
</view>
|
|
790
|
+
</view>
|
|
791
|
+
</template>
|
|
792
|
+
|
|
793
|
+
<style scoped></style>
|