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
209
210
211
212
213
214
215
216
217
218
219
220
221
| <template>
| <div class="create">
| <main>
| <div class="mainContent">
| <el-form
| ref="formRef"
| label-width="140px"
| :rules="createCarRules"
| autoComplete="on"
| :model="form"
| label-position="right"
| >
| <!-- 音柱名称 -->
| <el-form-item class="optionItem" label="音柱名称:" prop="name">
| <el-input
| v-model="form.name"
| placeholder="请填写音柱名称"
| ></el-input>
| </el-form-item>
| <!-- 音柱编号 -->
| <el-form-item class="optionItem" label="音柱编号:" prop="code">
| <el-input
| v-model="form.code"
| placeholder="请填写音柱编号"
| ></el-input>
| </el-form-item>
| <!-- 额度功率 -->
| <el-form-item class="optionItem" label="额度功率:" prop="power">
| <el-input
| v-model="form.power"
| placeholder="请填写额度功率"
| ></el-input>
| </el-form-item>
| <!-- 频率响应 -->
| <el-form-item
| class="optionItem"
| label="频率响应:"
| prop="frequencyResponse"
| >
| <el-input
| v-model="form.frequencyResponse"
| placeholder="请填写频率响应"
| ></el-input>
| </el-form-item>
| <!-- 喇叭单元 -->
| <el-form-item
| class="optionItem"
| label="喇叭单元:"
| prop="fullRangeSpeaker"
| >
| <el-input
| v-model="form.fullRangeSpeaker"
| placeholder="请填写 喇叭单元"
| ></el-input>
| </el-form-item>
| <el-form-item>
| <div class="optionBtn">
| <el-button
| type="primary"
| class="btn submit"
| @click.native.prevent="handleSave"
| >确认
| </el-button>
| </div>
| </el-form-item>
| </el-form>
| </div>
| </main>
| </div>
| </template>
| <script>
| import { createNamespacedHelpers } from "vuex";
| const { mapActions } = createNamespacedHelpers("loudspeaker");
| export default {
| data() {
| const checkName = (rule, value, callback) => {
| if (value) {
| callback();
| } else {
| callback(new Error("音柱名称不能为空"));
| }
| };
| const checkCode = (rule, value, callback) => {
| if (value) {
| callback();
| } else {
| callback(new Error("音柱编码不能为空"));
| }
| };
| return {
| form: {
| id: 0,
| name: "",
| code: "",
| power: "",
| frequencyResponse: "",
| fullRangeSpeaker: "",
| },
| createCarRules: {
| name: [
| {
| required: true,
| trigger: "blur",
| validator: checkName,
| },
| ],
| code: [
| {
| required: true,
| trigger: "blur",
| validator: checkCode,
| },
| ],
| },
| };
| },
| created() {
| this.form = this.info;
| },
| watch: {
| info(newVal) {
| this.form = newVal; //对父组件传过来的值进行监听,如果改变也对子组件内部的值进行改变
| },
| },
| methods: {
| ...mapActions(["saveLoudspeaker", "updateLoudspeaker"]),
| // 保存
| handleSave() {
| this.$refs.formRef.validate((valid) => {
| if (valid) {
| const { form } = this;
| if (form.id > 0) {
| this.updateLoudspeaker(form).then((res) => {
| this.$message({
| type: "success",
| message: "修改音柱成功",
| });
| this.$emit("closeDialog", { flag: false, index: 1 });
| });
| } else {
| this.saveLoudspeaker(form).then((res) => {
| this.$message({
| type: "success",
| message: "保存音柱成功",
| });
| this.$emit("closeDialog", { flag: false, index: 1 });
| });
| }
| } else {
| return false;
| }
| });
| },
| },
| props: ["info", "closeDialog"],
| };
| </script>
| <style lang="scss" scoped>
| .create {
| border-radius: 1px;
| background-color: #09152f;
|
| main {
| // border: 1px solid #fff;
| text-align: left;
| padding: 0 55px;
| background-color: #09152f;
| padding-bottom: 50px;
|
| .mainContent {
| display: flex;
| justify-content: center;
| padding-top: 50px;
|
| .el-form-item__content {
| width: 400px;
|
| .el-select {
| width: 100%;
| }
| }
|
| .optionHandleSp {
| display: flex;
|
| .areaNumber,
| .moreNumber {
| flex: 1;
| }
|
| .telNumber {
| flex: 2;
| }
| }
|
| .optionBtn {
| display: flex;
| margin-top: 20px;
|
| .btn {
| padding: 12px 50px;
| }
| }
| }
| }
|
| &::v-deep .el-textarea__inner {
| background-color: #09152f;
| border: 1px solid #17324c;
| }
|
| ::v-deep .el-form-item__label {
| color: #4b9bb7;
| }
|
| ::v-deep .el-input__inner {
| background-color: #09152f;
| border: 1px solid #17324c;
| }
| }
| </style>
|
|