perf: 外置表单模版

master
ssc 3 years ago
parent d42de6f1c5
commit 51d66cce1e
  1. 8
      src/api/plugin/workflow/demo/leave.js
  2. 2
      src/views/plugin/workflow/demo/leave/index.vue
  3. 27
      src/views/plugin/workflow/process/external/Leave/detail.vue
  4. 57
      src/views/plugin/workflow/process/external/Leave/start.vue
  5. 12
      src/views/plugin/workflow/process/external/template/detail.vue
  6. 4
      src/views/plugin/workflow/util/status.js

@ -22,4 +22,12 @@ export const remove = (ids) => {
ids,
}
})
}
export const submit = (data) => {
return request({
url: `${prefix}/submit`,
method: 'post',
data
})
}

@ -215,7 +215,7 @@ export default {
},
methods: {
handleDetail(row) {
this.dynamicRoute({ processInstanceId: row.processInsId }, 'detail', true).then(() => {
this.dynamicRoute({ ...row, processInstanceId: row.processInsId }, 'detail', true).then(() => {
this.form = { ...row }
this.detailVisible = true
})

@ -28,6 +28,13 @@
:option="option"
:upload-preview="handleUploadPreview">
</avue-form>
<el-card shadow="never"
style="margin-top: 10px;"
header="流转信息"
:body-style="{padding: '20px 0'}"
v-if="isPrintShow">
<wf-flow :flow="flow"></wf-flow>
</el-card>
</div>
</el-card>
<el-card shadow="never"
@ -97,7 +104,7 @@ export default {
if (val) {
const param = JSON.parse(Buffer.from(val, 'base64').toString())
const { taskId, processInsId } = param
if (taskId && processInsId) this.getDetail(taskId, processInsId)
if ((taskId && processInsId) || processInsId) this.getDetail(taskId, processInsId)
}
},
immediate: true
@ -124,7 +131,7 @@ export default {
label: '创建部门',
span: 12,
display: true,
prop: 'createDept',
prop: 'creatorDept',
value: '${this.$store.getters.userInfo.dept_name}',
readonly: true
},
@ -136,6 +143,7 @@ export default {
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
prop: 'datetime',
dataType: 'string',
required: true,
rules: [
{
@ -147,8 +155,8 @@ export default {
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 d1 = Date.parse(value.split(',')[0])
const d2 = Date.parse(value.split(',')[1])
const day = (d2 - d1) / (1 * 24 * 60 * 60 * 1000)
this.$set(this.form, 'days', Number(day.toFixed(2)))
}
@ -170,7 +178,8 @@ export default {
controls: true,
controlsPosition: 'right',
change: ({ value }) => {
this.$set(this.form, 'reason', '请假' + value + '天')
if (value) this.$set(this.form, 'reason', '请假' + value + '天')
else this.$set(this.form, 'reason', '')
}
},
{
@ -201,7 +210,8 @@ export default {
showFileList: true,
multiple: true,
limit: 10,
prop: 'attachment'
prop: 'attachment',
dataType: 'string'
},
]
},
@ -286,7 +296,10 @@ export default {
if (valid) {
const variables = {}
this.vars.forEach(v => {
if (v != 'comment' && this.form[v]) variables[v] = this.form[v]
if (!this.validatenull(this.form[v])) {
variables[v] = this.form[v]
if (this.form[`$${v}`]) variables[`$${v}`] = this.form[`$${v}`]
}
})
this.handleCompleteTask(pass, variables).then(() => {

@ -53,6 +53,9 @@
</template>
<script>
//
// import { submit } from '@/api/plugin/workflow/demo/leave.js'
import WfExamineForm from '@/views/plugin/workflow/process/components/examForm.vue'
import WfUserSelect from '@/views/plugin/workflow/process/components/user-select'
@ -69,8 +72,8 @@ export default {
handler(val) {
if (val) {
const param = JSON.parse(Buffer.from(val, 'base64').toString())
const { processId } = param
if (processId) this.getForm(processId)
const { processId, processDefKey } = param
if (processId || processDefKey) this.getForm(processId, processDefKey)
}
},
immediate: true
@ -103,7 +106,7 @@ export default {
label: '创建部门',
span: 12,
display: true,
prop: 'createDept',
prop: 'creatorDept',
value: '${this.$store.getters.userInfo.dept_name}',
readonly: true
},
@ -115,6 +118,7 @@ export default {
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
prop: 'datetime',
dataType: 'string',
required: true,
rules: [
{
@ -126,8 +130,8 @@ export default {
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 d1 = Date.parse(value.split(',')[0])
const d2 = Date.parse(value.split(',')[1])
const day = (d2 - d1) / (1 * 24 * 60 * 60 * 1000)
this.$set(this.form, 'days', Number(day.toFixed(2)))
}
@ -149,7 +153,8 @@ export default {
controls: true,
controlsPosition: 'right',
change: ({ value }) => {
this.$set(this.form, 'reason', '请假' + value + '天')
if (value) this.$set(this.form, 'reason', '请假' + value + '天')
else this.$set(this.form, 'reason', '')
}
},
{
@ -180,7 +185,8 @@ export default {
showFileList: true,
multiple: true,
limit: 10,
prop: 'attachment'
prop: 'attachment',
dataType: 'string'
},
]
},
@ -189,8 +195,17 @@ export default {
}
},
methods: {
getForm(processId) {
this.getStartForm(processId).then(res => {
getForm(processId, processDefKey) {
let param
let method
if (processId) {
param = processId
method = 'getStartForm'
} else if (processDefKey) {
param = processDefKey
method = 'getStartFormByProcessDefKey'
}
this[method](param).then(res => {
let { process, startForm } = res
this.form.processId = process.id
const option = this.option
@ -230,6 +245,30 @@ export default {
}).catch(() => {
this.loading = false
})
//
// let form = this.deepClone(this.form)
// form = {
// ...form,
// processDefId: form.processId,
// exFormKey: this.process.formKey,
// exFormUrl: this.process.formUrl,
// }
// submit(form).then(res => {
// const data = res.data.data
// this.form.processDefKey = this.process.key
// this.form.businessKey = data.id
// this.handleStartProcessByKey(true).then((res, done) => {
// const processInsId = res.data.data
// submit({ id: data.id, processInsId }).then(() => {
// this.$message.success("")
// this.handleCloseTag('/plugin/workflow/process/send')
// done()
// })
// }).catch(() => {
// this.loading = false
// })
// })
},
}
}

@ -24,6 +24,13 @@
<!-- 自定义表单区域 -->
<!-- 自定义表单区域 -->
<el-card shadow="never"
style="margin-top: 10px;"
header="流转信息"
:body-style="{padding: '20px 0'}"
v-if="isPrintShow">
<wf-flow :flow="flow"></wf-flow>
</el-card>
</div>
</el-card>
<!-- 审批意见表单 -->
@ -137,7 +144,10 @@ export default {
if (valid) {
const variables = {}
this.vars.forEach(v => {
if (v != 'comment' && this.form[v]) variables[v] = this.form[v]
if (!this.validatenull(this.form[v])) {
variables[v] = this.form[v]
if (this.form[`$${v}`]) variables[`$${v}`] = this.form[`$${v}`]
}
})
this.handleCompleteTask(pass, variables).then(() => {

@ -23,6 +23,10 @@ export default [
label: '审核中', // 到候选人/候选组
value: 8
},
{
label: '审核中', // 到候选人/候选组
value: 10
},
{
label: '审核中', // 节点被调度
value: 14

Loading…
Cancel
Save