inleft
2022-03-01 88f419df77ade235ea5e5e24be204842a24b7b33
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           label="参数名称"
14           :labelCol="labelCol"
15           :wrapperCol="wrapperCol"
16           has-feedback
17         >
18           <a-input placeholder="请输入参数名称" v-decorator="['name', {rules: [{required: true, message: '请输入参数名称!'}]}]" />
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="['code', {rules: [{required: true, message: '请输入唯一编码!'}]}]" />
27         </a-form-item>
28         <a-form-item
29           label="系统参数"
30           :labelCol="labelCol"
31           :wrapperCol="wrapperCol"
32         >
33           <a-radio-group v-decorator="['sysFlag',{rules: [{ required: true, message: '请选择是否为系统参数!' }]}]" >
34             <a-radio-button value="Y" > 是 </a-radio-button>
35             <a-radio-button value="N" >  否 </a-radio-button>
36           </a-radio-group>
37         </a-form-item>
38         <a-form-item
39           label="所属分类"
40           :labelCol="labelCol"
41           :wrapperCol="wrapperCol"
42           has-feedback
43         >
44           <a-select style="width: 100%" placeholder="请选择所属分类" v-decorator="['groupCode', {rules: [{ required: true, message: '请选择取所属分类!' }]}]" >
45             <a-select-option v-for="(item,index) in groupCodeList" :key="index" :value="item.code" >{{ item.value }}</a-select-option>
46           </a-select>
47         </a-form-item>
48         <a-form-item
49           :labelCol="labelCol"
50           :wrapperCol="wrapperCol"
51           label="参数值"
52         >
53           <a-input placeholder="请输入参数值" v-decorator="['value', {rules: [{required: true, message: '请输入参数值!'}]}]" />
54         </a-form-item>
55         <a-form-item
56           label="备注"
57           :labelCol="labelCol"
58           :wrapperCol="wrapperCol"
59           has-feedback
60         >
61           <a-textarea :rows="4" placeholder="请输入备注" v-decorator="['remark']"></a-textarea>
62         </a-form-item>
63       </a-form>
64     </a-spin>
65   </a-modal>
66 </template>
67 <script>
68   import { sysDictTypeDropDown, sysConfigAdd } from '@/api/modular/system/configManage'
69   export default {
70     data () {
71       return {
72         labelCol: {
73           xs: { span: 24 },
74           sm: { span: 5 }
75         },
76         wrapperCol: {
77           xs: { span: 24 },
78           sm: { span: 15 }
79         },
80         visible: false,
81         confirmLoading: false,
82         formLoading: true,
83         groupCodeList: [],
84         form: this.$form.createForm(this)
85       }
86     },
87     methods: {
88       // 初始化方法
89       add () {
90         this.visible = true
91         this.sysDictTypeDropDown()
92       },
93       /**
94        * 获取所属分类
95        */
96       sysDictTypeDropDown () {
97         sysDictTypeDropDown({ code: 'consts_type' }).then((res) => {
98           this.groupCodeList = res.data
99           this.formLoading = false
100         })
101       },
102       handleSubmit () {
103         const { form: { validateFields } } = this
104         this.confirmLoading = true
105         validateFields((errors, values) => {
106           if (!errors) {
107             sysConfigAdd(values).then((res) => {
108               this.confirmLoading = false
109               if (res.success) {
110                 this.$message.success('新增成功')
111                 this.$emit('ok', values)
112                 this.handleCancel()
113               } else {
114                 this.$message.error('新增失败:' + res.message)
115               }
116             }).finally((res) => {
117               this.confirmLoading = false
118             })
119           } else {
120             this.confirmLoading = false
121           }
122         })
123       },
124       handleCancel () {
125         this.form.resetFields()
126         this.visible = false
127       }
128     }
129   }
130 </script>