commit | author | age
|
9bcb19
|
1 |
<template> |
I |
2 |
<a-modal |
|
3 |
title="参数编辑" |
|
4 |
:width="900" |
|
5 |
:visible="visible" |
|
6 |
:confirmLoading="confirmLoading" |
|
7 |
@ok="handleSubmit" |
|
8 |
@cancel="handleCancel" |
|
9 |
> |
|
10 |
<a-spin :spinning="formLoading"> |
|
11 |
<a-form :form="form"> |
|
12 |
<a-form-item |
|
13 |
style="display: none;" |
|
14 |
:labelCol="labelCol" |
|
15 |
:wrapperCol="wrapperCol" |
|
16 |
has-feedback |
|
17 |
> |
|
18 |
<a-input v-decorator="['id']" /> |
|
19 |
</a-form-item> |
|
20 |
<a-form-item |
|
21 |
label="参数名称" |
|
22 |
:labelCol="labelCol" |
|
23 |
:wrapperCol="wrapperCol" |
|
24 |
has-feedback |
|
25 |
> |
|
26 |
<a-input placeholder="请输入参数名称" v-decorator="['name', {rules: [{required: true, message: '请输入参数名称!'}]}]" /> |
|
27 |
</a-form-item> |
|
28 |
<a-form-item |
|
29 |
label="唯一编码" |
|
30 |
:labelCol="labelCol" |
|
31 |
:wrapperCol="wrapperCol" |
|
32 |
has-feedback |
|
33 |
> |
|
34 |
<a-input placeholder="请输入唯一编码" :disabled="editDisabled" v-decorator="['code', {rules: [{required: true, message: '请输入唯一编码!'}]}]" /> |
|
35 |
</a-form-item> |
|
36 |
<a-form-item |
|
37 |
label="系统参数" |
|
38 |
:labelCol="labelCol" |
|
39 |
:wrapperCol="wrapperCol" |
|
40 |
> |
|
41 |
<a-radio-group :disabled="editDisabled" v-decorator="['sysFlag',{rules: [{ required: true, message: '请选择是否为系统参数!' }]}]" > |
|
42 |
<a-radio-button value="Y" > 是 </a-radio-button> |
|
43 |
<a-radio-button value="N" > 否 </a-radio-button> |
|
44 |
</a-radio-group> |
|
45 |
</a-form-item> |
|
46 |
<a-form-item |
|
47 |
label="所属分类" |
|
48 |
:labelCol="labelCol" |
|
49 |
:wrapperCol="wrapperCol" |
|
50 |
has-feedback |
|
51 |
> |
|
52 |
<a-select :disabled="editDisabled" style="width: 100%" placeholder="请选择所属分类" v-decorator="['groupCode', {rules: [{ required: true, message: '请选择取所属分类!' }]}]" > |
|
53 |
<a-select-option v-for="(item,index) in groupCodeList" :key="index" :value="item.code" >{{ item.value }}</a-select-option> |
|
54 |
</a-select> |
|
55 |
</a-form-item> |
|
56 |
<a-form-item |
|
57 |
:labelCol="labelCol" |
|
58 |
:wrapperCol="wrapperCol" |
|
59 |
label="参数值" |
|
60 |
has-feedback |
|
61 |
> |
|
62 |
<a-input placeholder="请输入参数值" v-decorator="['value', {rules: [{required: true, message: '请输入参数值!'}]}]" /> |
|
63 |
</a-form-item> |
|
64 |
<a-form-item |
|
65 |
label="备注" |
|
66 |
:labelCol="labelCol" |
|
67 |
:wrapperCol="wrapperCol" |
|
68 |
has-feedback |
|
69 |
> |
|
70 |
<a-textarea :rows="4" placeholder="请输入备注" v-decorator="['remark']"></a-textarea> |
|
71 |
</a-form-item> |
|
72 |
</a-form> |
|
73 |
</a-spin> |
|
74 |
</a-modal> |
|
75 |
</template> |
|
76 |
<script> |
|
77 |
import { sysDictTypeDropDown, sysConfigEdit } from '@/api/modular/system/configManage' |
|
78 |
export default { |
|
79 |
data () { |
|
80 |
return { |
|
81 |
labelCol: { |
|
82 |
xs: { span: 24 }, |
|
83 |
sm: { span: 5 } |
|
84 |
}, |
|
85 |
wrapperCol: { |
|
86 |
xs: { span: 24 }, |
|
87 |
sm: { span: 15 } |
|
88 |
}, |
|
89 |
visible: false, |
|
90 |
confirmLoading: false, |
|
91 |
formLoading: true, |
|
92 |
groupCodeList: [], |
|
93 |
editDisabled: false, |
|
94 |
form: this.$form.createForm(this) |
|
95 |
} |
|
96 |
}, |
|
97 |
methods: { |
|
98 |
// 初始化方法 |
|
99 |
edit (record) { |
|
100 |
this.visible = true |
|
101 |
setTimeout(() => { |
|
102 |
this.form.setFieldsValue( |
|
103 |
{ |
|
104 |
id: record.id, |
|
105 |
name: record.name, |
|
106 |
code: record.code, |
|
107 |
groupCode: record.groupCode, |
|
108 |
sysFlag: record.sysFlag, |
|
109 |
value: record.value, |
|
110 |
remark: record.remark |
|
111 |
} |
|
112 |
) |
|
113 |
}, 100) |
|
114 |
// eslint-disable-next-line eqeqeq |
|
115 |
if (record.sysFlag == 'Y') { |
|
116 |
this.editDisabled = true |
|
117 |
} |
|
118 |
this.sysDictTypeDropDown() |
|
119 |
}, |
|
120 |
/** |
|
121 |
* 获取所属分类 |
|
122 |
*/ |
|
123 |
sysDictTypeDropDown () { |
|
124 |
sysDictTypeDropDown({ code: 'consts_type' }).then((res) => { |
|
125 |
this.groupCodeList = res.data |
|
126 |
this.formLoading = false |
|
127 |
}) |
|
128 |
}, |
|
129 |
handleSubmit () { |
|
130 |
const { form: { validateFields } } = this |
|
131 |
this.confirmLoading = true |
|
132 |
validateFields((errors, values) => { |
|
133 |
if (!errors) { |
|
134 |
sysConfigEdit(values).then((res) => { |
|
135 |
this.confirmLoading = false |
|
136 |
if (res.success) { |
|
137 |
this.$message.success('编辑成功') |
|
138 |
this.$emit('ok', values) |
|
139 |
this.handleCancel() |
|
140 |
} else { |
|
141 |
this.$message.error('编辑失败:' + res.message) |
|
142 |
} |
|
143 |
}).finally((res) => { |
|
144 |
this.confirmLoading = false |
|
145 |
}) |
|
146 |
} else { |
|
147 |
this.confirmLoading = false |
|
148 |
} |
|
149 |
}) |
|
150 |
}, |
|
151 |
handleCancel () { |
|
152 |
this.form.resetFields() |
|
153 |
this.visible = false |
|
154 |
this.editDisabled = false |
|
155 |
} |
|
156 |
} |
|
157 |
} |
|
158 |
</script> |