张保健 4 yıl önce
ebeveyn
işleme
3f056695b1
1 değiştirilmiş dosya ile 137 ekleme ve 139 silme
  1. 137 139
      src/xt_pages/data/components/tableson.vue

+ 137 - 139
src/xt_pages/data/components/tableson.vue Dosyayı Görüntüle

@@ -77,8 +77,8 @@
77 77
           <el-col :span="12">
78 78
             <el-form-item label="排序" prop="order">
79 79
               <el-input
80
-                type="age"
81
-                v-model="temp.order"
80
+                type="number" 
81
+                v-model.number="temp.order"
82 82
                 placeholder="请输入排序值,数值越大,排序越靠前"
83 83
               ></el-input>
84 84
             </el-form-item>
@@ -136,40 +136,40 @@ import {
136 136
   fetchPv,
137 137
   createArticle,
138 138
   updateArticle
139
-} from "@/api/article";
140
-import waves from "@/directive/waves"; // 水波纹指令
141
-import { parseTime } from "@/utils";
142
-import store from "@/store";
143
-import bus from "@/assets/eventBus";
139
+} from '@/api/article'
140
+import waves from '@/directive/waves' // 水波纹指令
141
+import { parseTime } from '@/utils'
142
+import store from '@/store'
143
+import bus from '@/assets/eventBus'
144 144
 import {
145 145
   createConfig,
146 146
   createChildConfig,
147 147
   updateChildConfig,
148 148
   deleteChildConfig
149
-} from "@/api/data";
149
+} from '@/api/data'
150 150
 
151 151
 const calendarTypeOptions = [
152
-  { key: "CN", display_name: "China" },
153
-  { key: "US", display_name: "USA" },
154
-  { key: "JP", display_name: "Japan" },
155
-  { key: "EU", display_name: "Eurozone" }
156
-];
152
+  { key: 'CN', display_name: 'China' },
153
+  { key: 'US', display_name: 'USA' },
154
+  { key: 'JP', display_name: 'Japan' },
155
+  { key: 'EU', display_name: 'Eurozone' }
156
+]
157 157
 
158 158
 // arr to obj ,such as { CN : "China", US : "USA" }
159 159
 const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
160
-  acc[cur.key] = cur.display_name;
161
-  return acc;
162
-}, {});
160
+  acc[cur.key] = cur.display_name
161
+  return acc
162
+}, {})
163 163
 
164 164
 export default {
165
-  name: "tableson",
165
+  name: 'tableson',
166 166
   directives: {
167 167
     waves
168 168
   },
169 169
   props: {
170 170
     type: {
171 171
       type: String,
172
-      default: "patient"
172
+      default: 'patient'
173 173
     }
174 174
   },
175 175
   data() {
@@ -184,56 +184,54 @@ export default {
184 184
         importance: undefined,
185 185
         title: undefined,
186 186
         type: this.type,
187
-        sort: "+id"
187
+        sort: '+id'
188 188
       },
189 189
       importanceOptions: [1, 2, 3],
190 190
       calendarTypeOptions,
191 191
       sortOptions: [
192
-        { label: "ID Ascending", key: "+id" },
193
-        { label: "ID Descending", key: "-id" }
192
+        { label: 'ID Ascending', key: '+id' },
193
+        { label: 'ID Descending', key: '-id' }
194 194
       ],
195
-      statusOptions: ["published", "draft", "deleted"],
195
+      statusOptions: ['published', 'draft', 'deleted'],
196 196
       showReviewer: false,
197 197
       temp: {
198 198
         id: undefined,
199 199
         parent_id: 0,
200 200
         module: this.type,
201 201
         org_id: 0,
202
-        name: "",
202
+        name: '',
203 203
         field_name: undefined,
204
-        value: "",
205
-        remark: ""
204
+        value: '',
205
+        remark: ''
206 206
       },
207 207
       dialogFormVisible: false,
208
-      dialogStatus: "",
208
+      dialogStatus: '',
209 209
       textMap: {
210
-        update: "编辑",
211
-        create: "新增"
210
+        update: '编辑',
211
+        create: '新增'
212 212
       },
213 213
       dialogPvVisible: false,
214 214
       pvData: [],
215 215
       rules: {
216
-        name: [{ required: true, message: "请输入名称", trigger: "blur" }],
217
-        order: [
218
-          { type: "number", message: "排序必须为数字值", trigger: "blur" }
219
-        ]
216
+        name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
217
+        order: [{ type: 'number', message: '排序必须为数字11', trigger: 'blur' }]
220 218
         // timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
221 219
         // title: [{ required: true, message: 'title is required', trigger: 'blur' }]
222 220
       },
223 221
       downloadLoading: false,
224 222
       parentConfig: undefined,
225 223
       addState: true
226
-    };
224
+    }
227 225
   },
228 226
   computed: {
229 227
     list: function() {
230 228
       if (this.parentConfig != undefined) {
231
-        this.addState = false;
232
-        const list = store.getters.configlist[this.parentConfig.module];
229
+        this.addState = false
230
+        const list = store.getters.configlist[this.parentConfig.module]
233 231
         for (var i = 0; i < list.length; i++) {
234 232
           if (list[i].id === this.parentConfig.id) {
235
-            return list[i]["childs"];
236
-            break;
233
+            return list[i]['childs']
234
+            break
237 235
           }
238 236
         }
239 237
         // return store.getters.configlist[this.parentConfig.module][this.parentConfig.index ]["childs"];
@@ -243,90 +241,90 @@ export default {
243 241
   filters: {
244 242
     statusFilter(status) {
245 243
       const statusMap = {
246
-        published: "success",
247
-        draft: "info",
248
-        deleted: "danger"
249
-      };
250
-      return statusMap[status];
244
+        published: 'success',
245
+        draft: 'info',
246
+        deleted: 'danger'
247
+      }
248
+      return statusMap[status]
251 249
     },
252 250
     typeFilter(type) {
253
-      return calendarTypeKeyValue[type];
251
+      return calendarTypeKeyValue[type]
254 252
     }
255 253
   },
256 254
   created() {
257 255
     // this.getList()
258 256
   },
259 257
   mounted() {
260
-    var _this = this;
261
-    bus.$on("parentChangeId", function(parentData) {
262
-      _this.parentConfig = parentData;
258
+    var _this = this
259
+    bus.$on('parentChangeId', function(parentData) {
260
+      _this.parentConfig = parentData
263 261
       // _this.list = parentData.childs
264 262
       _this.temp = {
265 263
         id: undefined,
266 264
         parent_id: parentData.id,
267 265
         module: parentData.module,
268 266
         org_id: parentData.org_id,
269
-        name: "",
267
+        name: '',
270 268
         field_name: undefined,
271
-        value: "",
272
-        remark: ""
273
-      };
274
-    });
269
+        value: '',
270
+        remark: ''
271
+      }
272
+    })
275 273
   },
276 274
   methods: {
277 275
     handleRowChange(currentRow, oldCurrentRow) {
278
-      this.currentId = currentRow.id;
276
+      this.currentId = currentRow.id
279 277
     },
280 278
 
281 279
     handleFilter() {
282
-      this.listQuery.page = 1;
283
-      this.getList();
280
+      this.listQuery.page = 1
281
+      this.getList()
284 282
     },
285 283
     handleSizeChange(val) {
286
-      this.listQuery.limit = val;
287
-      this.getList();
284
+      this.listQuery.limit = val
285
+      this.getList()
288 286
     },
289 287
     handleCurrentChange(val) {
290
-      this.listQuery.page = val;
291
-      this.getList();
288
+      this.listQuery.page = val
289
+      this.getList()
292 290
     },
293 291
     handleModifyStatus(row, status) {
294
-      this.temp = Object.assign({}, row); // copy obj
295
-      this.$confirm("此操作将永久删除该配置项, 是否继续?", "提示", {
296
-        confirmButtonText: "确 定",
297
-        cancelButtonText: "取 消",
298
-        type: "warning"
292
+      this.temp = Object.assign({}, row) // copy obj
293
+      this.$confirm('此操作将永久删除该配置项, 是否继续?', '提示', {
294
+        confirmButtonText: '确 定',
295
+        cancelButtonText: '取 消',
296
+        type: 'warning'
299 297
       })
300 298
         .then(() => {
301
-          const tempData = Object.assign({}, this.temp);
299
+          const tempData = Object.assign({}, this.temp)
302 300
           deleteChildConfig(tempData).then(response => {
303 301
             if (!response.data) {
304 302
               // 由于mockjs 不支持自定义状态码只能这样hack
305
-              reject("error");
303
+              reject('error')
306 304
             }
307 305
             if (response.data.state === 0) {
308
-              this.$message.error(response.data.msg);
306
+              this.$message.error(response.data.msg)
309 307
             }
310 308
 
311
-            const result = response.data.data.dataconfig;
309
+            const result = response.data.data.dataconfig
312 310
             store
313
-              .dispatch("updateChildConfigList", [tempData, "delete"])
311
+              .dispatch('updateChildConfigList', [tempData, 'delete'])
314 312
               .then(() => {
315
-                next();
316
-              });
317
-          });
313
+                next()
314
+              })
315
+          })
318 316
 
319 317
           this.$message({
320
-            type: "success",
321
-            message: "删除成功!"
322
-          });
318
+            type: 'success',
319
+            message: '删除成功!'
320
+          })
323 321
         })
324 322
         .catch(() => {
325 323
           this.$message({
326
-            type: "info",
327
-            message: "已取消删除"
328
-          });
329
-        });
324
+            type: 'info',
325
+            message: '已取消删除'
326
+          })
327
+        })
330 328
     },
331 329
     resetTemp() {
332 330
       this.temp = {
@@ -334,123 +332,123 @@ export default {
334 332
         parent_id: this.parentConfig.id,
335 333
         module: this.parentConfig.module,
336 334
         org_id: this.parentConfig.org_id,
337
-        name: "",
335
+        name: '',
338 336
         field_name: undefined,
339
-        value: "",
340
-        remark: ""
341
-      };
337
+        value: '',
338
+        remark: ''
339
+      }
342 340
     },
343 341
     handleCreate() {
344
-      this.resetTemp();
345
-      this.dialogStatus = "create";
346
-      this.dialogFormVisible = true;
342
+      this.resetTemp()
343
+      this.dialogStatus = 'create'
344
+      this.dialogFormVisible = true
347 345
       this.$nextTick(() => {
348
-        this.$refs["dataForm"].clearValidate();
349
-      });
346
+        this.$refs['dataForm'].clearValidate()
347
+      })
350 348
     },
351 349
     createData() {
352
-      this.$refs["dataForm"].validate(valid => {
350
+      this.$refs['dataForm'].validate(valid => {
353 351
         if (valid) {
354 352
           createChildConfig(this.temp).then(response => {
355 353
             if (!response.data) {
356 354
               // 由于mockjs 不支持自定义状态码只能这样hack
357
-              reject("error");
355
+              reject('error')
358 356
             }
359 357
             if (response.data.state === 0) {
360
-              this.$message.error(response.data.msg);
358
+              this.$message.error(response.data.msg)
361 359
             }
362
-            const result = response.data.data.dataconfig;
360
+            const result = response.data.data.dataconfig
363 361
 
364 362
             // this.list.unshift(tempval)
365 363
             // 更新store
366 364
             store
367
-              .dispatch("updateChildConfigList", [result, "create"])
368
-              .then(() => {});
365
+              .dispatch('updateChildConfigList', [result, 'create'])
366
+              .then(() => {})
369 367
 
370
-            this.dialogFormVisible = false;
371
-            this.$message.success("创建成功");
372
-          });
368
+            this.dialogFormVisible = false
369
+            this.$message.success('创建成功')
370
+          })
373 371
         }
374
-      });
372
+      })
375 373
     },
376 374
     handleUpdate(row) {
377
-      this.temp = Object.assign({}, row); // copy obj
378
-      this.dialogStatus = "update";
379
-      this.dialogFormVisible = true;
375
+      this.temp = Object.assign({}, row) // copy obj
376
+      this.dialogStatus = 'update'
377
+      this.dialogFormVisible = true
380 378
       this.$nextTick(() => {
381
-        this.$refs["dataForm"].clearValidate();
382
-      });
379
+        this.$refs['dataForm'].clearValidate()
380
+      })
383 381
     },
384 382
     updateData() {
385
-      this.$refs["dataForm"].validate(valid => {
383
+      this.$refs['dataForm'].validate(valid => {
386 384
         if (valid) {
387
-          const tempData = Object.assign({}, this.temp);
388
-          console.log("tempData", tempData);
385
+          const tempData = Object.assign({}, this.temp)
386
+          console.log('tempData', tempData)
389 387
           updateChildConfig(tempData).then(response => {
390 388
             if (!response.data) {
391 389
               // 由于mockjs 不支持自定义状态码只能这样hack
392
-              reject("error");
390
+              reject('error')
393 391
             }
394 392
             if (response.data.state === 0) {
395
-              this.$message.error(response.data.msg);
393
+              this.$message.error(response.data.msg)
396 394
             }
397 395
 
398
-            const result = response.data.data.dataconfig;
396
+            const result = response.data.data.dataconfig
399 397
             store
400
-              .dispatch("updateChildConfigList", [result, "update"])
401
-              .then(() => {});
398
+              .dispatch('updateChildConfigList', [result, 'update'])
399
+              .then(() => {})
402 400
 
403
-            this.dialogFormVisible = false;
401
+            this.dialogFormVisible = false
404 402
 
405
-            this.$message.success("更新成功");
406
-          });
403
+            this.$message.success('更新成功')
404
+          })
407 405
         }
408
-      });
406
+      })
409 407
     },
410 408
     handleDelete(row) {
411
-      this.$message.success("删除成功");
412
-      const index = this.list.indexOf(row);
413
-      this.list.splice(index, 1);
409
+      this.$message.success('删除成功')
410
+      const index = this.list.indexOf(row)
411
+      this.list.splice(index, 1)
414 412
     },
415 413
     handleFetchPv(pv) {
416 414
       fetchPv(pv).then(response => {
417
-        this.pvData = response.data.pvData;
418
-        this.dialogPvVisible = true;
419
-      });
415
+        this.pvData = response.data.pvData
416
+        this.dialogPvVisible = true
417
+      })
420 418
     },
421 419
     handleDownload() {
422
-      this.downloadLoading = true;
423
-      import("@/vendor/Export2Excel").then(excel => {
424
-        const tHeader = ["timestamp", "title", "type", "importance", "status"];
420
+      this.downloadLoading = true
421
+      import('@/vendor/Export2Excel').then(excel => {
422
+        const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
425 423
         const filterVal = [
426
-          "timestamp",
427
-          "title",
428
-          "type",
429
-          "importance",
430
-          "status"
431
-        ];
432
-        const data = this.formatJson(filterVal, this.list);
424
+          'timestamp',
425
+          'title',
426
+          'type',
427
+          'importance',
428
+          'status'
429
+        ]
430
+        const data = this.formatJson(filterVal, this.list)
433 431
         excel.export_json_to_excel({
434 432
           header: tHeader,
435 433
           data,
436
-          filename: "table-list"
437
-        });
438
-        this.downloadLoading = false;
439
-      });
434
+          filename: 'table-list'
435
+        })
436
+        this.downloadLoading = false
437
+      })
440 438
     },
441 439
     formatJson(filterVal, jsonData) {
442 440
       return jsonData.map(v =>
443 441
         filterVal.map(j => {
444
-          if (j === "timestamp") {
445
-            return parseTime(v[j]);
442
+          if (j === 'timestamp') {
443
+            return parseTime(v[j])
446 444
           } else {
447
-            return v[j];
445
+            return v[j]
448 446
           }
449 447
         })
450
-      );
448
+      )
451 449
     }
452 450
   }
453
-};
451
+}
454 452
 </script>
455 453
 
456 454
 <style rel="stylesheet/css" lang="scss" scoped></style>