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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<template>
<div>
<el-dialog
:title="manageObj.title"
center
append-to-body
:visible.sync="manageObj.show"
width="800px">
<div class="head clear-both">
<el-button @click="add" plain type="primary" style="float: right" v-if="!$store.state.readonly">新增来源码类别</el-button>
</div>
<el-table
:data="sourceTypeList"
style="width: 100%">
<el-table-column
prop="desc"
label="描述">
</el-table-column>
<el-table-column
prop="value"
label="类别">
</el-table-column>
<el-table-column
prop="created_at"
label="创建时间">
</el-table-column>
<el-table-column
width="250"
v-if="!$store.state.readonly"
label="操作">
<template slot-scope="scope">
<el-button size="mini" plain type="warning" @click="edit(scope.row)">
编辑
</el-button>
<el-button size="mini" plain type="danger" @click="del(scope.row)" v-if="$store.state.deletePermission">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
<el-dialog
:title="addTypeObj.title"
center
append-to-body
:visible.sync="addTypeObj.show"
width="800px">
<el-form ref="form" :model="form" :rules="rules" >
<el-row>
<el-col :span="4"><label>来源码类别</label></el-col>
<el-col :span="8">
<el-form-item prop="value">
<el-input v-model="form.value"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4"><label>描述</label></el-col>
<el-col :span="8">
<el-form-item prop="desc">
<el-input v-model="form.desc" type="textarea"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="addTypeObj.show = false">取 消</el-button>
<el-button type="primary" @click="sub">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {getConfigListApi,saveConfigApi,updateConfigApi,deleteConfigApi ,getConfigDetailApi} from "../../service/api"
export default {
name:"manageDialog",
props:[
"manageObj"
],
data(){
return{
sourceTypeList:[],
addTypeObj:{
title:"来源码类别",
show:false,
},
form:{
value:'',
desc:'',
id:''
},
rules:{
value:[
{ required: true, message: '请输入类别', trigger: 'change' }
],
desc:[
{ message: '请输入描述', trigger: 'change' }
]
}
}
},
methods:{
sub(){
let json={
value:this.form.value,
key:"code_rule_type"
}
if(this.form.desc){
json.desc=this.form.desc
}
if(this.form.id){
this.$refs['form'].validate((valid) => {
if(valid){
this.$confirm('此操作将修改来源码?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
updateConfigApi(this.form.id,json).then(res=>{
this.$message({
type: 'success',
message: '修改成功!'
});
this.addTypeObj.show = false;
this.sourceTypeOptions();
})
})
}
});
}else{
this.$refs['form'].validate((valid) => {
if(valid){
this.$confirm('此操作将新增来源码?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
saveConfigApi(json).then(res=>{
this.$message({
type: 'success',
message: '新增成功!'
});
this.addTypeObj.show = false;
this.sourceTypeOptions();
})
})
}
});
}
},
add(){
this.form.id = '';
this.form.value = '';
this.form.desc = '';
this.addTypeObj.show=true;
},
sourceTypeOptions(){
let json={
limit: 2000,
page: 1,
key:"code_rule_type",
};
getConfigListApi(json).then(res => {
this.sourceTypeList=res.list
})
},
del(data){
this.$confirm('此操作将删除该记录?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteConfigApi(data.id).then(res=>{
this.$message({
type: 'success',
message: '删除成功!'
});
this.sourceTypeOptions()
});
});
},
edit(data){
getConfigDetailApi(data.id).then((res) => {
this.addTypeObj.show = true
this.form.id = res.id;
this.form.value = res.value;
this.form.desc = res.desc;
});
},
},
mounted(){
},
watch:{
"manageObj.show"(val){
if(val){
this.sourceTypeOptions();
}else{
this.$emit("reflash");
}
}
}
}
</script>
<style scoped>
</style>