|
@@ -1,15 +1,164 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
-
|
|
|
- </div>
|
|
|
+ <m-dialog :title="`${item.workFlowTmplate?.name} 审批配置`" ref="dialog" @sure="onSure">
|
|
|
+ <el-form ref="form" inline :model="formValues" label-width="80px" >
|
|
|
+ <m-card
|
|
|
+ v-for="(item, index) in formValues.items"
|
|
|
+ :key="item.key"
|
|
|
+ shadow="never"
|
|
|
+ class="mb-3 cardBox"
|
|
|
+ >
|
|
|
+ <el-form-item label="处理对象">
|
|
|
+ <el-select v-model="item.handleType" placeholder="请选择处理对象" @change="onChange(item)">
|
|
|
+ <el-option label="指定人" :value="0"></el-option>
|
|
|
+ <el-option label="指定部室岗位" :value="1"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="处理方">
|
|
|
+ <el-select v-if="item.handleType === 0" v-model="item.handleValue" placeholder="请选择处理方">
|
|
|
+ <el-option
|
|
|
+ v-for="item in personOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-cascader
|
|
|
+ v-if="item.handleType === 1"
|
|
|
+ v-model="item.handleValue"
|
|
|
+ placeholder="请选择处理方"
|
|
|
+ :props="organizationProp"
|
|
|
+ :options="organizationTree"
|
|
|
+ ></el-cascader>
|
|
|
+ </el-form-item>
|
|
|
+ <div class="button-group">
|
|
|
+ <m-button :disabled="index === 0" icon="el-icon-top" circle size="mini" @click="onUp(index)"></m-button>
|
|
|
+ <m-button :disabled="index === formValues.items.length - 1" icon="el-icon-bottom" circle size="mini" @click="onDown(index)"></m-button>
|
|
|
+ <m-button type="danger" icon="el-icon-delete" circle size="mini" @click="onDelete(index)"></m-button>
|
|
|
+ </div>
|
|
|
+ </m-card>
|
|
|
+ </el-form>
|
|
|
+ <div class="text-center">
|
|
|
+ <el-button @click="onAdd" icon="el-icon-plus">新增一条记录</el-button>
|
|
|
+ </div>
|
|
|
+ </m-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import {
|
|
|
+ saveWorkflow
|
|
|
+} from '@/api/workflow'
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
export default {
|
|
|
- name: 'workflowApproved'
|
|
|
+ name: 'workflowApproved',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ key: 0,
|
|
|
+ formValues: {
|
|
|
+ items: [
|
|
|
+ {
|
|
|
+ key: 0,
|
|
|
+ handleType: 0,
|
|
|
+ handleValue: null,
|
|
|
+ handleValueData: {}
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ item: {},
|
|
|
+ personOptions: [],
|
|
|
+ organizationProp: {
|
|
|
+ lazy: true,
|
|
|
+ value: 'organizationNo',
|
|
|
+ label: 'organizationName',
|
|
|
+ children: 'child',
|
|
|
+ checkStrictly: true,
|
|
|
+ lazyLoad (node, resolve) {
|
|
|
+ console.log(node)
|
|
|
+ // const { level } = node
|
|
|
+ if (node.children) {
|
|
|
+ resolve(node.children)
|
|
|
+ }
|
|
|
+ console.log(11)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(['organizationTree'])
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ open (item) {
|
|
|
+ this.item = item
|
|
|
+ if (item.workFlowTmplateItems.length > 0) {
|
|
|
+ this.formValues.items = item.workFlowTmplateItems.map((e, index) => {
|
|
|
+ return {
|
|
|
+ handleType: e.handleType,
|
|
|
+ handleValue: e.handleValue,
|
|
|
+ handleValueData: {}, // 回显
|
|
|
+ key: index
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.key = item.workFlowTmplateItems.length + 1
|
|
|
+ this.$refs.dialog.open()
|
|
|
+ },
|
|
|
+ onAdd () {
|
|
|
+ this.key++
|
|
|
+ this.formValues.items.push({
|
|
|
+ key: this.key,
|
|
|
+ handleType: 0,
|
|
|
+ handleValue: null,
|
|
|
+ handleValueData: {}
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 向上移动一位
|
|
|
+ onUp (index) {
|
|
|
+ if (index === 0) return
|
|
|
+ const temp = this.formValues.items[index]
|
|
|
+ this.formValues.items.splice(index, 1)
|
|
|
+ this.formValues.items.splice(index - 1, 0, temp)
|
|
|
+ },
|
|
|
+ // 向下移动一位
|
|
|
+ onDown (index) {
|
|
|
+ if (index === this.formValues.items.length - 1) return
|
|
|
+ const temp = this.formValues.items[index]
|
|
|
+ this.formValues.items.splice(index, 1)
|
|
|
+ this.formValues.items.splice(index + 1, 0, temp)
|
|
|
+ },
|
|
|
+ // 删除
|
|
|
+ onDelete (index) {
|
|
|
+ this.formValues.items.splice(index, 1)
|
|
|
+ },
|
|
|
+ onChange (item) {
|
|
|
+ item.handleValue = null
|
|
|
+ },
|
|
|
+ async onSure () {
|
|
|
+ try {
|
|
|
+ await saveWorkflow({
|
|
|
+ workFlowTmplateItems: this.formValues.items.map((e, index) => {
|
|
|
+ return {
|
|
|
+ handleType: e.handleType,
|
|
|
+ handleValue: e.handleValueData,
|
|
|
+ sort: index
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ workFlowTmplate: this.item.workFlowTmplate
|
|
|
+ })
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-
|
|
|
+.cardBox {
|
|
|
+ position: relative;
|
|
|
+ .button-group {
|
|
|
+ position: absolute;
|
|
|
+ right: 10px;
|
|
|
+ bottom: 10px;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|