whyczyk
2021-11-05 d291d4b450aab57b6c98cd0637f8b43f55bc370b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
    <div class="main">
        <div class="contain">
            <div class="title">{{title}}</div>
            <el-form ref="form" :model="form" label-width="10em">
                <el-form-item label="节点名称:">
                    <el-input v-model="form.linkName" placeholder="请输入节点名称"></el-input>
                </el-form-item>
                <el-form-item label="节点层级:">
                    <el-select v-model="form.linkType" placeholder="请选择节点层级">
                        <el-option :label="value" :value="key" v-for="(value,key,index) in linkLevel" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="节点所含角色:">
                    <el-button type="primary" size="mini" @click="addRole">添加角色</el-button>
                </el-form-item>
                <el-form-item label="角色" v-for="(item,i) in form.roleList" :key="i">
                    <el-input v-model="item.name" style="margin-right:8px" placeholder="请输入角色名称"></el-input>
                    <el-input v-model="item.type" style="margin-right:8px" type="number" placeholder="请输入角色编码"></el-input>
                    <i class="el-icon-delete delIcon" @click="removeList(i)"></i>
                </el-form-item>
                <el-form-item label="所属工单类型:">
                    <el-select v-model="form.type" placeholder="请选择所属工单类型">
                        <el-option :label="value" :value="key" v-for="(value,key,index) in workType" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit" v-if="pageType==1">确认提交</el-button>
                    <el-button type="primary" @click="onSubmit" v-else>确认修改</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>
 
<script>
import {
    addWorkflowProperty,
    editWorkflowProperty
} from '../js/api';
import {
    workType,
    linkLevel
} from '@/assets/js/constants';
export default {
    name: "",
 
    data() {
        return {
            workType,
            linkLevel,
            title: '新建流程节点',
            form: {
                linkName: "",
                linkType: '',
                roleList: [],
                type: '',
            },
            pageType: 1
        };
    },
    components: {},
    methods: {
        addRole() {
            this.form.roleList.push({
                name: "",
                type: ""
            })
        },
        removeList(index) {
            this.form.roleList.splice(index, 1)
        },
        onSubmit() {
            if (this.pageType == 1) {
                this.addFrom()
            } else {
                this.editFrom()
            }
        },
        editFrom() {
            editWorkflowProperty(this.form).then((res) => {
                if (res.data.code == 1) {
                    this.$message({
                        message: '修改成功!',
                        type: 'success'
                    });
                    setTimeout(() => {
                        this.$router.go(-1)
                    }, 1000)
                }
            }).catch((err) => {
                console.log(err)
            });
        },
        addFrom() {
            addWorkflowProperty(this.form).then((res) => {
                if (res.data.code == 1) {
                    this.$message({
                        message: '添加成功!',
                        type: 'success'
                    });
                    setTimeout(() => {
                        this.$router.go(-1)
                    }, 1000)
                }
            }).catch((err) => {
                console.log(err)
            });
        },
    },
 
    mounted() {
        let postData = JSON.parse(this.$route.query.data);
        console.log(postData)
        if (postData.linkName) {
            this.title = '编辑流程节点'
            this.pageType = 2;
            this.form.linkName = postData.linkName;
            this.form.linkType = postData.linkType + '';
            this.form.roleList = postData.roleList;
            this.form.type = postData.type + '';
        } else {
            this.title = '新建流程节点'
            this.pageType = 1
        }
    },
};
</script>
 
<style scoped>
.main {
    height: 100%;
    padding-top: 10px;
    padding-left: 10px;
    display: flex;
}
.contain {
    background: #fff;
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.title {
    color: #04409a;
    font-size: 24px;
    margin-bottom: 15px;
}
>>> .el-input {
    width: 30em;
}
>>> .el-textarea {
    width: 40em;
}
 
.delIcon {
    color: #e10000;
    font-size: 20px;
    margin-left: 16px;
    cursor: pointer;
}
</style>