| 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
 | | <template> |  |     <GlobalWindow |  |         :title="title" |  |         :visible.sync="visible" |  |         :confirm-working="isWorking" |  |         @confirm="confirm" |  |     > |  |         <el-form :model="form" ref="form" :rules="rules"> |  |             <el-form-item label="显示内容" prop="title"> |  |                 <el-input v-model="form.title" placeholder="请输入LED屏显示内容" v-trim/> |  |             </el-form-item> |  |             <el-form-item label="播放速度" prop="speed"> |  |                 <el-input type="number" v-model="form.speed" placeholder="请输入播放速度(大于0数字)" v-trim/> |  |             </el-form-item> |  |         </el-form> |  |     </GlobalWindow> |  | </template> |  |   |  | <script> |  | import BaseOpera from '@/components/base/BaseOpera' |  | import GlobalWindow from '@/components/common/GlobalWindow' |  | export default { |  |   name: 'OperaDeviceWindow', |  |   extends: BaseOpera, |  |   components: { GlobalWindow }, |  |   data () { |  |     return { |  |       // 表单数据 |  |       form: { |  |         id: null, |  |         title: '', |  |         speed: 13 |  |       }, |  |       // 验证规则 |  |       rules: { |  |         title: [ |  |           { required: true, message: '请输入LED屏显示内容' } |  |         ] |  |       } |  |     } |  |   }, |  |   created () { |  |     this.config({ |  |       api: '/business/device', |  |       'field.id': 'id' |  |     }) |  |   }, |  |   methods: { |  |     confirm () { |  |       this.$refs.form.validate((valid) => { |  |         if (!valid) { |  |           return |  |         } |  |         this.confirmDo() |  |       }) |  |     }, |  |     confirmDo () { |  |       // 调用新建接口 |  |       this.isWorking = true |  |       this.api.setLedContent({ |  |         deviceId: this.form.id, |  |         speed: this.form.speed, |  |         content: this.form.title |  |       }) |  |         .then(() => { |  |           this.visible = false |  |           this.$tip.apiSuccess('发送成功') |  |           this.$emit('success') |  |         }) |  |         .catch(e => { |  |           // this.$tip.apiFailed(e) |  |         }) |  |         .finally(() => { |  |           this.isWorking = false |  |         }) |  |     } |  |   } |  | } |  | </script> | 
 |