diff --git a/src/utils/formBuilder.js b/src/utils/formBuilder.js index e0200de..7c8776b 100644 --- a/src/utils/formBuilder.js +++ b/src/utils/formBuilder.js @@ -904,7 +904,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab let isJointly = false this.jointlySignLog.forEach(log => { const data = JSON.parse(log.data) - Object.entries(data).forEach(([key, value]) => { + Object.entries(data)?.forEach(([key, value]) => { if (value.hasOwnProperty('custom_field_id') && (value['custom_field_id'] === info.id)) { isJointly = log.is_jointly_sign jointlySignContent.push(h('div',[ @@ -1016,6 +1016,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, attrs: { placeholder: info.help_text, + for: info.name }, on: { input: (e) => { @@ -1040,6 +1041,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, attrs: { placeholder: info.help_text, + for: info.name }, on: { input: (e) => { @@ -1065,6 +1067,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, attrs: { placeholder: info.help_text, + for: info.name }, on: { click: (_) => { @@ -1088,6 +1091,9 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab rules: this.rules[info.name], required: !!this.rules[info.name]?.find(j => j.required) }, + attrs: { + for: info.name + }, on: { click: (_) => { this.vanTimePickerOption.forFormName = info.name; @@ -1115,6 +1121,9 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab rules: this.rules[info.name], required: !!this.rules[info.name]?.find(j => j.required) }, + attrs: { + for: info.name + }, on: { click: (_) => { this.vanPopupOption.forFormName = info.name; @@ -1147,6 +1156,9 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab rules: this.rules[info.name], required: !!this.rules[info.name]?.find(j => j.required) }, + attrs: { + for: info.name + }, on: { click: (_) => { this.multipleSelectOption.forFormName = info.name; @@ -1169,7 +1181,10 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab title: info.label, rules: this.rules[info.name], required: !!this.rules[info.name]?.find(j => j.required) - } + }, + attrs: { + for: info.name + }, },[ h( formBuilderMap(device).get(info.type), @@ -1329,6 +1344,9 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab rules: this.rules[info.name], required: !!this.rules[info.name]?.find(j => j.required) }, + attrs: { + for: info.name + }, on: { click: (_) => { this.multipleSelectOption.forFormName = info.name; @@ -1353,6 +1371,9 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab "arrow-direction": "down", title: info.label, }, + attrs: { + for: info.name + } },[ h('van-button',{ props: { @@ -1626,6 +1647,86 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }) } } - return formItem; + + let jointlySignContent = [] + let isJointly = false + this.jointlySignLog.forEach(log => { + const data = JSON.parse(log.data) + Object.entries(data)?.forEach(([key, value]) => { + if (value.hasOwnProperty('custom_field_id') && (value['custom_field_id'] === info.id)) { + isJointly = log.is_jointly_sign + jointlySignContent.push(h('div',[ + h('span', value.value), + h('br'), + info.is_sign ? h('el-image',{ + style: { + 'max-height': '80px', + 'max-width': '120px' + }, + props: { + src: log.user?.sign_file?.url, + fit: 'contain', + alt: log.user?.name + }, + attrs: { + src: log.user?.sign_file?.url, + alt: log.user?.name + } + }) : '', + info.is_sign ? h('br') : '', + h('span', log.updated_at ? this.$moment(log.updated_at).format('YYYY年MM月DD') : '') + ])) + } + }) + }) + return isJointly ? [(/\/detail/.test(this.$route.path) && this.$route.query.flow_id && jointlySignContent.length > 0) ? '' : formItem,(() => { + if (info.is_sign && !(/\/detail/.test(this.$route.path && this.$route.query.flow_id && jointlySignContent.length > 0))) { + let log = this.logs.find(log => log.node?.fields?.findIndex(field => field?.field?.name === info.name) !== -1) && (row ? row[info.name] : this.form[info.name]) + if (log && log.user) { + return h('van-cell',[ + h('el-image',{ + style: { + 'max-height': '80px', + 'max-width': '120px' + }, + props: { + src: log.user?.sign_file?.url, + fit: 'contain', + alt: log.user?.name + }, + attrs: { + src: log.user?.sign_file?.url, + alt: log.user?.name + } + }), + h('div', this.$moment(log.updated_at).format('YYYY年MM月DD日 HH时mm分')) + ]) + } + } + })(),jointlySignContent] : [formItem,(() => { + if (info.is_sign) { + let log = this.logs.find(log => log.node?.fields?.findIndex(field => field?.field?.name === info.name) !== -1 && (row ? row[info.name] : this.form[info.name])) + if (log && log.user) { + return h('van-cell',[ + h('el-image',{ + style: { + 'max-height': '80px', + 'max-width': '120px' + }, + props: { + src: log.user?.sign_file?.url, + fit: 'contain', + alt: log.user?.name + }, + attrs: { + src: log.user?.sign_file?.url, + alt: log.user?.name + } + }), + h('div', this.$moment(log.updated_at).format('YYYY年MM月DD日 HH时mm分')) + ]) + } + } + })()] } } diff --git a/src/views/flow/MobileForm.vue b/src/views/flow/MobileForm.vue index 29dcb5d..9b10921 100644 --- a/src/views/flow/MobileForm.vue +++ b/src/views/flow/MobileForm.vue @@ -108,8 +108,9 @@ export default { getToken, async validate() { const $vanForm = this.$refs['vanForm'] + console.log($vanForm) if ($vanForm) { - await $vanForm.validate() + const res = await $vanForm.validate() } }, }, @@ -165,6 +166,7 @@ export default { const subFields = Array.from(this.subForm).map(i => i[1]?.customModel?.fields).filter(i => i).flat() return h('div',[ h('van-form',{ + ref: 'vanForm', props: { 'validate-first': true, 'scroll-to-error': true diff --git a/src/views/flow/create.vue b/src/views/flow/create.vue index 046ca45..12ca0de 100644 --- a/src/views/flow/create.vue +++ b/src/views/flow/create.vue @@ -852,7 +852,7 @@ export default { scriptContent() { if (this.config?.customModel?.view_js && this.$route.query.flow_id && /\/detail/.test(this.$route.path)) { return this.config?.customModel?.view_js; - } else if (this.config?.customModel?.js) { + } else if (this.config?.customModel?.js && !/\/detail/.test(this.$route.path)) { return this.config?.customModel?.js; } },