|
1
2
3
4
5
6
|
<template>
<a-spin :spinning="confirmLoading">
<j-form-container :disabled="formDisabled">
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
<a-row>
<a-col :span="24">
|
|
7
8
|
<a-form-model-item :label="$t('parameter.name')" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
<a-input v-model="model.name" :placeholder="$t('parameter.inputName')"></a-input>
|
|
9
10
11
|
</a-form-model-item>
</a-col>
<a-col :span="24">
|
|
12
13
|
<a-form-model-item :label="$t('parameter.code')" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="code">
<a-input v-model="model.code" :placeholder="$t('parameter.inputCode')"></a-input>
|
|
14
15
16
|
</a-form-model-item>
</a-col>
<a-col :span="24">
|
|
17
|
<a-form-model-item :label="$t('task.zone')" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zoneCode">
|
|
18
19
|
<a-select
show-search
|
|
20
|
:placeholder="$t('system.selectZone')"
|
|
21
22
23
24
25
26
27
28
29
30
|
option-filter-prop="children"
v-model="model.zoneCode">
<a-select-option v-for="item in zoneList" :key="item.name" :value="item.code">{{
item.name
}}
</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="24">
|
|
31
32
|
<a-form-model-item :label="$t('parameter.value')" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="value">
<a-input v-model="model.value" :placeholder="$t('parameter.inputValue')"></a-input>
|
|
33
34
35
|
</a-form-model-item>
</a-col>
<a-col :span="24">
|
|
36
37
|
<a-form-model-item :label="$t('system.remark')" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
<a-input v-model="model.remark" :placeholder="$t('config.inputRemark')"></a-input>
|
|
38
39
40
41
42
43
44
45
46
47
|
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</j-form-container>
</a-spin>
</template>
<script>
|
|
48
49
|
import {httpAction, getAction} from '@/api/manage'
import {validateDuplicateValue} from '@/utils/util'
|
|
50
|
import {getZoneList} from "@api/api";
|
|
51
|
import { translateResultMessage } from '@/api/api'
|
|
52
|
|
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
export default {
name: 'ParameterConfigurationForm',
components: {},
props: {
//表单禁用
disabled: {
type: Boolean,
default: false,
required: false
}
},
data() {
return {
model: {},
|
|
67
|
zoneList: [],
|
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
labelCol: {
xs: {span: 24},
sm: {span: 5},
},
wrapperCol: {
xs: {span: 24},
sm: {span: 16},
},
confirmLoading: false,
validatorRules: {},
url: {
add: "/config/parameterConfiguration/add",
edit: "/config/parameterConfiguration/edit",
queryById: "/config/parameterConfiguration/queryById"
|
|
82
|
}
|
|
83
84
85
86
87
|
}
},
computed: {
formDisabled() {
return this.disabled
|
|
88
|
},
|
|
89
90
91
92
|
},
created() {
//备份model原始值
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
|
93
|
this.loadFrom();
|
|
94
95
96
97
|
},
methods: {
add() {
this.edit(this.modelDefault);
|
|
98
|
},
|
|
99
100
101
|
edit(record) {
this.model = Object.assign({}, record);
this.visible = true;
|
|
102
|
},
|
|
103
104
105
|
loadFrom() {
getZoneList().then((res) => {
if (res.success) {
|
|
106
107
|
this.zoneList = res.result;
this.zoneList.push({value:"",text:""});
|
|
108
109
110
|
}
});
},
|
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
submitForm() {
const that = this;
// 触发表单验证
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true;
let httpurl = '';
let method = '';
if (!this.model.id) {
httpurl += this.url.add;
method = 'post';
} else {
httpurl += this.url.edit;
method = 'put';
|
|
125
|
}
|
|
126
127
|
httpAction(httpurl, this.model, method).then((res) => {
if (res.success) {
|
|
128
|
that.$message.success(translateResultMessage(res, res.message))
|
|
129
130
|
that.$emit('ok');
} else {
|
|
131
|
that.$message.warning(translateResultMessage(res, res.message))
|
|
132
133
134
135
136
137
138
139
|
}
}).finally(() => {
that.confirmLoading = false;
})
}
})
},
|
|
140
|
}
|
|
141
|
}
|
|
142
|
</script>
|