From 50a870b23b02a0fbcf6228c263145243400663d9 Mon Sep 17 00:00:00 2001 From: ssc <273702440@qq.com> Date: Mon, 21 Mar 2022 15:02:52 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=A4=96=E7=BD=AE=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/plugin/workflow/mixins/ex-form.js | 2 +- .../process/external/Leave/detail.vue | 153 ++++++++++++------ .../workflow/process/external/Leave/start.vue | 118 +++++++++++--- 3 files changed, 206 insertions(+), 67 deletions(-) diff --git a/src/views/plugin/workflow/mixins/ex-form.js b/src/views/plugin/workflow/mixins/ex-form.js index 2c7d416..5157047 100644 --- a/src/views/plugin/workflow/mixins/ex-form.js +++ b/src/views/plugin/workflow/mixins/ex-form.js @@ -345,7 +345,7 @@ export default { } // 汇总表单打印 const summaryOption = this.deepClone(this.summaryOption) - if (this.summaryOption.group) { + if (this.summaryOption && this.summaryOption.group) { this.summaryOption.group.forEach(g => { g.collapse = false g.column.forEach(col => { diff --git a/src/views/plugin/workflow/process/external/Leave/detail.vue b/src/views/plugin/workflow/process/external/Leave/detail.vue index 5a3c796..7242012 100644 --- a/src/views/plugin/workflow/process/external/Leave/detail.vue +++ b/src/views/plugin/workflow/process/external/Leave/detail.vue @@ -108,25 +108,101 @@ export default { defaults: {}, form: {}, option: { - column: [{ - label: '请假时间', - prop: 'datetime', - type: 'datetimerange', - format: 'yyyy-MM-dd HH:mm:ss', - valueFormat: 'yyyy-MM-dd HH:mm:ss', - rules: [{ required: true, message: '请选择请假时间' }] - }, { - label: '请假天数', - prop: 'days', - type: 'number', - rules: [{ required: true, message: '请输入请假天数' }] - }, { - label: '请假理由', - prop: 'reason', - type: 'textarea', - span: 24, - rules: [{ required: true, message: '请输入请假理由' }] - }] + column: [ + { + type: 'input', + label: '创建人', + span: 12, + display: true, + prop: 'creator', + value: '${this.$store.getters.userInfo.nick_name}', + readonly: true + }, + { + type: 'input', + label: '创建部门', + span: 12, + display: true, + prop: 'createDept', + value: '${this.$store.getters.userInfo.dept_name}', + readonly: true + }, + { + type: 'datetimerange', + label: '请假时间', + span: 12, + display: true, + format: 'yyyy-MM-dd HH:mm:ss', + valueFormat: 'yyyy-MM-dd HH:mm:ss', + prop: 'datetime', + required: true, + rules: [ + { + required: true, + message: '开始时间必须填写' + } + ], + change: ({ value }) => { + if (!value || value.length == 0) { + this.$set(this.form, 'days', undefined) + } else { + const d1 = Date.parse(value[0]) + const d2 = Date.parse(value[1]) + const day = (d2 - d1) / (1 * 24 * 60 * 60 * 1000) + this.$set(this.form, 'days', Number(day.toFixed(2))) + } + } + }, + { + type: 'number', + label: '请假天数', + span: 12, + display: true, + prop: 'days', + required: true, + rules: [ + { + required: true, + message: '请假天数必须填写' + } + ], + controls: true, + controlsPosition: 'right', + change: ({ value }) => { + this.$set(this.form, 'reason', '请假' + value + '天') + } + }, + { + type: 'textarea', + label: '请假理由', + span: 24, + display: true, + prop: 'reason', + required: true, + rules: [ + { + required: true, + message: '请假理由必须填写' + } + ] + }, + { + label: '附件', + type: 'upload', + propsHttp: { + res: 'data', + url: 'link', + name: 'originalName' + }, + action: '/api/blade-resource/oss/endpoint/put-file', + display: true, + span: 24, + showFileList: true, + multiple: true, + limit: 10, + prop: 'attachment' + }, + ] }, vars: [], // 需要提交的字段 submitLoading: false, // 提交时按钮loading @@ -144,20 +220,13 @@ export default { option.menuBtn = false const { column, group } = option if (status != 'todo') { // 已办,删除字段默认值 - let event = ['change', 'blur', 'click', 'focus'] option.detail = true if (column && column.length > 0) { // 处理column column.forEach(col => { if (col.type == 'dynamic') col.children.column.forEach(cc => { delete cc.value - delete cc.event - event.forEach(e => delete cc[e]) }) - else { - delete col.value - delete col.event - event.forEach(e => delete col[e]) - } + delete col.value }) } @@ -167,41 +236,26 @@ export default { gro.column.forEach(col => { if (col.type == 'dynamic') col.children.column.forEach(cc => { delete cc.value - delete cc.event - event.forEach(e => delete cc[e]) }) - else { - delete col.value - delete col.event - event.forEach(e => delete col[e]) - } + delete col.value }) } }) } } else { - const columnFilter = this.filterAvueColumn(column, taskForm) + const columnFilter = this.filterAvueColumn(column, taskForm, true) const columnArr = columnFilter.column let vars = columnFilter.vars || [] const groupArr = [] if (group && group.length > 0) { // 处理group group.forEach(gro => { - const groupFilter = this.filterAvueColumn(gro.column, taskForm) + const groupFilter = this.filterAvueColumn(gro.column, taskForm, true) gro.column = groupFilter.column vars = vars.concat(groupFilter.vars) if (gro.column.length > 0) groupArr.push(gro) }) } - - if (process.variables && process.variables.serialNumber) { - columnArr.unshift({ - label: '流水号', - prop: 'serialNumber', - span: 24, - detail: true, - }) - } option.column = columnArr option.group = groupArr this.vars = vars @@ -210,6 +264,15 @@ export default { if (!variables[key]) delete variables[key] } + if (option.column && process.variables && process.variables.serialNumber) { + option.column.unshift({ + label: '流水号', + prop: 'serialNumber', + span: 24, + detail: true, + }) + } + this.option = option this.form = variables this.waiting = false diff --git a/src/views/plugin/workflow/process/external/Leave/start.vue b/src/views/plugin/workflow/process/external/Leave/start.vue index 7b8d5aa..bca3264 100644 --- a/src/views/plugin/workflow/process/external/Leave/start.vue +++ b/src/views/plugin/workflow/process/external/Leave/start.vue @@ -91,25 +91,101 @@ export default { form: {}, option: { menuBtn: false, - column: [{ - label: '请假时间', - prop: 'datetime', - type: 'datetimerange', - format: 'yyyy-MM-dd HH:mm:ss', - valueFormat: 'yyyy-MM-dd HH:mm:ss', - rules: [{ required: true, message: '请选择请假时间' }] - }, { - label: '请假天数', - prop: 'days', - type: 'number', - rules: [{ required: true, message: '请输入请假天数' }] - }, { - label: '请假理由', - prop: 'reason', - type: 'textarea', - span: 24, - rules: [{ required: true, message: '请输入请假理由' }] - }] + column: [ + { + type: 'input', + label: '创建人', + span: 12, + display: true, + prop: 'creator', + value: '${this.$store.getters.userInfo.nick_name}', + readonly: true + }, + { + type: 'input', + label: '创建部门', + span: 12, + display: true, + prop: 'createDept', + value: '${this.$store.getters.userInfo.dept_name}', + readonly: true + }, + { + type: 'datetimerange', + label: '请假时间', + span: 12, + display: true, + format: 'yyyy-MM-dd HH:mm:ss', + valueFormat: 'yyyy-MM-dd HH:mm:ss', + prop: 'datetime', + required: true, + rules: [ + { + required: true, + message: '开始时间必须填写' + } + ], + change: ({ value }) => { + if (!value || value.length == 0) { + this.$set(this.form, 'days', undefined) + } else { + const d1 = Date.parse(value[0]) + const d2 = Date.parse(value[1]) + const day = (d2 - d1) / (1 * 24 * 60 * 60 * 1000) + this.$set(this.form, 'days', Number(day.toFixed(2))) + } + } + }, + { + type: 'number', + label: '请假天数', + span: 12, + display: true, + prop: 'days', + required: true, + rules: [ + { + required: true, + message: '请假天数必须填写' + } + ], + controls: true, + controlsPosition: 'right', + change: ({ value }) => { + this.$set(this.form, 'reason', '请假' + value + '天') + } + }, + { + type: 'textarea', + label: '请假理由', + span: 24, + display: true, + prop: 'reason', + required: true, + rules: [ + { + required: true, + message: '请假理由必须填写' + } + ] + }, + { + label: '附件', + type: 'upload', + propsHttp: { + res: 'data', + url: 'link', + name: 'originalName' + }, + action: '/api/blade-resource/oss/endpoint/put-file', + display: true, + span: 24, + showFileList: true, + multiple: true, + limit: 10, + prop: 'attachment' + }, + ] }, process: {}, loading: false @@ -124,10 +200,10 @@ export default { const { column, group } = option const groupArr = [] - const columnArr = this.filterAvueColumn(column, startForm).column + const columnArr = this.filterAvueColumn(column, startForm, true).column if (group && group.length > 0) { // 处理group group.forEach(gro => { - gro.column = this.filterAvueColumn(gro.column, startForm).column + gro.column = this.filterAvueColumn(gro.column, startForm, true).column if (gro.column.length > 0) groupArr.push(gro) }) }