diff --git a/src/components/MobileMultipleSelect/index.vue b/src/components/MobileMultipleSelect/index.vue index e0eb8c3..9a06144 100644 --- a/src/components/MobileMultipleSelect/index.vue +++ b/src/components/MobileMultipleSelect/index.vue @@ -76,6 +76,10 @@ export default { multipleLimit: { type: Number, default: 50 + }, + outputType: { + type: String, + default: 'array' } // showSelectMultiple: { // type: Boolean, @@ -114,7 +118,7 @@ export default { }, submitSelect() { this.showSelectMultiple = false - this.$emit('confirm', this.checked) + this.$emit('confirm', this.outputType === 'array' ? this.checked : this.checked.toString()) // this.selectNameData() }, cancelSelect() { diff --git a/src/utils/formBuilder.js b/src/utils/formBuilder.js index eae94ce..34cb0c7 100644 --- a/src/utils/formBuilder.js +++ b/src/utils/formBuilder.js @@ -510,6 +510,16 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab ); break; case "relation-flow": + if (!this.flows[info.name]) { + flowList('all', { + page: 1, + page_size: 9999, + custom_model_id: info.stub + }).then(res => { + this.$set(this.flows, info.name, res.data.data) + console.log(this.flows) + }) + } formItem = h( formBuilderMap(device).get(info.type), { @@ -533,27 +543,10 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab row ? this.$set(row, info.name, e.toString()) : this.$set(this.form, info.name, e.toString()); - }, - ['visible-change']:e => { - if (e) { - if (this.nowSelectId === info.stub && this.flows.length > 0) return - this.flowSelectLoading = true - flowList('all', { - page: 1, - page_size: 9999, - custom_model_id: info.stub - }).then(res => { - this.nowSelectId = info.stub - this.flows = res.data.data - this.flowSelectLoading = false - }).catch(err => { - this.flowSelectLoading = false - }) - } } }, }, - this.flows.map((option) => + this.flows[info.name]?.map((option) => h("el-option", { props: { label: option.title, @@ -787,6 +780,16 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab ); break; case "relation-flow": + if (!this.flows[info.name]) { + flowList('all', { + page: 1, + page_size: 9999, + custom_model_id: info.stub + }).then(res => { + this.$set(this.flows, info.name, res.data.data) + console.log(this.flows) + }) + } formItem = h( "span", { @@ -795,7 +798,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, }, this.form[info.name]?.toString()?.split(',').map(j => { - return this.flows.find((i) => + return this.flows[info.name]?.find((i) => i.id == j )?.title; })?.toString() @@ -895,9 +898,34 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab } if (formItem) { - this.logs.forEach(log => { - if(!log.is_jointly_sign) return - + let jointlySignContent = [] + 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)) { + 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 + } + }) : '', + h('br'), + h('span', log.updated_at ? this.$moment(log.updated_at).format('YYYY年MM月DD') : '') + ])) + } + }) }) return row ? formItem @@ -916,29 +944,30 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab "grid-row-end": info.gs_y + 1 + (info.name === 'flow_title' ? 0 : 1) + info.gs_height, }, }, - [formItem,(() => { - if (info.is_sign) { + [(/\/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('div',[ h('el-image',{ style: { - 'max-height': '80px' + 'max-height': '80px', + 'max-width': '120px' }, props: { src: log.user?.sign_file?.url, fit: 'contain', - alt: log.user?.sign_id + alt: log.user?.name }, attrs: { src: log.user?.sign_file?.url, - alt: log.user?.sign_id + alt: log.user?.name } }) ]) } } - })()] + })(),jointlySignContent] ); } } @@ -953,7 +982,8 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab value: row ? row[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text, - rules: this.rules[info.name] + rules: this.rules[info.name], + required: !!this.rules[info.name]?.find(j => j.required) }, attrs: { placeholder: info.help_text, @@ -976,7 +1006,8 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab value: row ? row[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text, - rules: this.rules[info.name] + rules: this.rules[info.name], + required: !!this.rules[info.name]?.find(j => j.required) }, attrs: { placeholder: info.help_text, @@ -1000,7 +1031,8 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab value: row ? row[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text, - rules: this.rules[info.name] + rules: this.rules[info.name], + required: !!this.rules[info.name]?.find(j => j.required) }, attrs: { placeholder: info.help_text, @@ -1015,7 +1047,6 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }); break; case "datetime": - console.log(3345, this.rules[info.name]) formItem = h("van-field", { props: { readonly: true, @@ -1052,7 +1083,8 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab value: typeof findSelect === "object" ? findSelect.name : findSelect, clearable: true, placeholder: info.help_text, - rules: this.rules[info.name] + rules: this.rules[info.name], + required: !!this.rules[info.name]?.find(j => j.required) }, on: { click: (_) => { @@ -1083,12 +1115,14 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab value: (findChoice instanceof Array) ? (findChoice.map(i => typeof i === "object" ? i.name : i).toString()) : (typeof findChoice === "object" ? findChoice.name : findChoice), clearable: true, placeholder: info.help_text, - rules: this.rules[info.name] + rules: this.rules[info.name], + required: !!this.rules[info.name]?.find(j => j.required) }, on: { click: (_) => { this.multipleSelectOption.forFormName = info.name; this.multipleSelectOption.originalObj = row; + this.multipleSelectOption.outputType = 'array'; this.$set(this.multipleSelectOption, "columns", options); this.$set(this.multipleSelectOption, "options", { label: 'name', @@ -1104,7 +1138,8 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab formItem = h('van-cell',{ props: { title: info.label, - rules: this.rules[info.name] + rules: this.rules[info.name], + required: !!this.rules[info.name]?.find(j => j.required) } },[ h( @@ -1235,27 +1270,42 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab ]) break; case 'relation-flow': - let findFlow = options?.find((i) => - typeof i === "object" - ? i.id === (row ? row[info.name] : this.form[info.name]) - : i === (row ? row[info.name] : this.form[info.name]) - ); + if (!this.flows[info.name]) { + flowList('all', { + page: 1, + page_size: 9999, + custom_model_id: info.stub + }).then(res => { + this.$set(this.flows, info.name, res.data.data) + console.log(this.flows) + }) + } formItem = h("van-field", { props: { readonly: true, clickable: true, name: info.name, label: info.label, - value: typeof findFlow === "object" ? (findFlow.name || findFlow.title) : findFlow, + value: row ? row[info.name]?.toString()?.split(',').map(j => { + return this.flows[info.name]?.find((i) => + i.id == j + )?.title; + })?.toString() : this.form[info.name]?.toString()?.split(',').map(j => { + return this.flows[info.name]?.find((i) => + i.id == j + )?.title; + })?.toString(), clearable: true, placeholder: info.help_text, - rules: this.rules[info.name] + rules: this.rules[info.name], + required: !!this.rules[info.name]?.find(j => j.required) }, on: { click: (_) => { this.multipleSelectOption.forFormName = info.name; this.multipleSelectOption.originalObj = row; - this.$set(this.multipleSelectOption, "columns", this.flows); + this.multipleSelectOption.outputType = 'string'; + this.$set(this.multipleSelectOption, "columns", this.flows[info.name]); this.$set(this.multipleSelectOption, "options", { label: 'title', value: 'id' diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 0733af0..c0880ec 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -345,6 +345,7 @@ export default { flows: [], usualFlows: [], + noticeTimer: null, noticeLoading: false, notice: [], noticeTable: [ @@ -473,9 +474,11 @@ export default { } }, - async getNotices() { + async getNotices(loading = false) { try { - this.noticeLoading = true; + if (loading) { + this.noticeLoading = true; + } const res = await axios.get( `${process.env.VUE_APP_BASE_API}/api/notification/todo`, { @@ -552,11 +555,15 @@ export default { }, created() { this.getWeather(); - this.getNotices(); + this.getNotices(true); + this.noticeTimer = setInterval(this.getNotices, 5000) this.getTotal(); this.getUsualFlows(); this.getAttendance(); }, + beforeDestroy() { + clearInterval(this.noticeTimer) + } }; diff --git a/src/views/flow/DesktopForm.vue b/src/views/flow/DesktopForm.vue index fec86be..134a061 100644 --- a/src/views/flow/DesktopForm.vue +++ b/src/views/flow/DesktopForm.vue @@ -66,6 +66,7 @@ export default { action: process.env.VUE_APP_BASE_API, form: {}, + jointlySignLog: [], // 所有会签log记录 datetimeFormat: 'yyyy-MM-dd HH:mm', copyShortcuts: [ { @@ -173,9 +174,7 @@ export default { }, }, ], - flows: [], - flowSelectLoading: false, - nowSelectId: '' + flows: {}, }; }, methods: { @@ -222,6 +221,23 @@ export default { this.zIndex = PopupManager.nextZIndex(); } }, + logs: { + handler: function (newVal) { + if (newVal && newVal instanceof Array && newVal.length > 0) { + this.jointlySignLog = newVal.filter(log => { + try { + JSON.parse(log.data) + return log.is_jointly_sign && /custom_field_id/g.test(log.data) + } catch (e) { + return false + } + }) + } else { + this.jointlySignLog = [] + } + }, + immediate: true + } }, render(h) { const authFields = this.fields.map((field) => ({ diff --git a/src/views/flow/MobileForm.vue b/src/views/flow/MobileForm.vue index 0f99357..95ab65a 100644 --- a/src/views/flow/MobileForm.vue +++ b/src/views/flow/MobileForm.vue @@ -10,10 +10,6 @@ export default { MobileMultipleSelect }, props: { - flows: { - type: Array, - default: () => [], - }, isFirstNode: { type: Boolean, default: true @@ -67,10 +63,12 @@ export default { modalRender: () => {}, zIndex: PopupManager.nextZIndex(), + jointlySignLog: [], // 所有会签log记录 form: {}, file: { ggg: [] }, + flows: {}, showControl: {}, vanCalendarOption: { isShow: false, @@ -134,6 +132,23 @@ export default { if(newVal) { this.zIndex = PopupManager.nextZIndex() } + }, + logs: { + handler: function (newVal) { + if (newVal && newVal instanceof Array && newVal.length > 0) { + this.jointlySignLog = newVal.filter(log => { + try { + JSON.parse(log.data) + return log.is_jointly_sign && /custom_field_id/g.test(log.data) + } catch (e) { + return false + } + }) + } else { + this.jointlySignLog = [] + } + }, + immediate: true } }, render(h) { @@ -260,6 +275,7 @@ export default { selectDataOpts: this.multipleSelectOption.columns, multipleLimit: this.multipleSelectOption.multipleLimit, options: this.multipleSelectOption.options, + outputType: this.multipleSelectOption.outputType, }, on: { confirm: value => {