houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-card shadow="never" class="aui-card--fill">
3     <div class="mod-znfx-opcua">
4       <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
5         <el-form-item>
6           <el-input v-model="dataForm.pointNo" :placeholder="$t('point.pointNo')" clearable></el-input>
7         </el-form-item>
8         <el-form-item>
9           <el-input v-model="dataForm.pointName" :placeholder="$t('point.pointName')" clearable></el-input>
10         </el-form-item>
11         <el-form-item>
12           <el-input v-model="dataForm.tagNo" :placeholder="$t('point.tagNo')" clearable></el-input>
13         </el-form-item>
14         <el-form-item>
15           <el-input v-model="dataForm.sourceName" :placeholder="$t('point.sourceName')" clearable></el-input>
16         </el-form-item>
17         <el-form-item>
18           <el-button @click="getDataList()">{{ $t('query') }}</el-button>
19         </el-form-item>
20         <el-form-item>
21           <el-button v-hasPermi="['data:point:save']" type="primary" @click="addOrUpdateHandle()">{{ $t('add')}}
22           </el-button>
23         </el-form-item>
24         <el-form-item>
25           <el-button v-hasPermi="['data:point:update']" type="success" @click="enableHandle()">启用</el-button>
26         </el-form-item>
27         <el-form-item>
28           <el-button v-hasPermi="['data:point:update']" type="danger" @click="disableHandle()">禁用</el-button>
29         </el-form-item>
30       </el-form>
31       <el-table
32           v-loading="dataListLoading"
33           :data="dataList"
34           border
35           @selection-change="dataListSelectionChangeHandle"
36           @sort-change="dataListSortChangeHandle"
37           style="width: 100%;">
38         <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
39         <el-table-column prop="pointNo" :label="$t('point.pointNo')" header-align="center"
40                          min-width="120"></el-table-column>
41         <el-table-column prop="pointName" :label="$t('point.pointName')" header-align="center"
42                          min-width="200"></el-table-column>
43         <el-table-column prop="pointTypeName" :label="$t('point.pointType')" header-align="center" align="center"
44                          min-width="100">
45         </el-table-column>
46         <el-table-column prop="dataTypeName" :label="$t('point.dataType')" header-align="center" align="center"
47                          min-width="100">
48         </el-table-column>
49         <el-table-column prop="defaultValue" :label="$t('point.defaultValue')" header-align="center" align="center"
50                          min-width="100"></el-table-column>
51         <el-table-column prop="unit" :label="$t('point.unit')" header-align="center" align="center"
52                          min-width="100"></el-table-column>
53         <el-table-column prop="unittransfactor" :label="$t('point.unittransfactor')" header-align="center"
54                          align="center"
55                          min-width="100">
56         </el-table-column>
57         <el-table-column prop="sourceType" :label="$t('point.sourceType')" header-align="center" align="center"
58                          min-width="100"></el-table-column>
59         <el-table-column prop="sourceName" :label="$t('point.sourceName')" align="center"
60                          header-align="center" min-width="100"></el-table-column>
61         <el-table-column prop="tagNo" :label="$t('point.tagNo')" header-align="center" align="left"
62                          min-width="200"></el-table-column>
63         <el-table-column prop="minfreqid" :label="$t('point.minfreqid')" header-align="center" align="center"
64                          min-width="80"></el-table-column>
65         <el-table-column prop="isEnable" :label="$t('user.status')" header-align="center" align="center">
66           <template slot-scope="scope">
67             <el-tag v-if="scope.row.isEnable === 0" size="small" type="danger">禁用</el-tag>
68             <el-tag v-else size="small" type="success">启用</el-tag>
69           </template>
70         </el-table-column>
71         <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
72           <template slot-scope="scope">
73             <el-button v-hasPermi="['data:point:update']" type="text" size="small"
74                        @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}
75             </el-button>
76             <el-button v-hasPermi="['data:point:delete']" type="text" size="small"
77                        @click="deleteHandle(scope.row.id)">{{ $t('delete') }}
78             </el-button>
79             <el-button type="text" size="small" @click="chartHandle(scope.row)">采集值</el-button>
80             <el-button v-hasPermi="['data:point:setValue']" type="text" size="small" @click="setValueHandle(scope.row)">设置值</el-button>
81           </template>
82         </el-table-column>
83       </el-table>
84       <el-pagination
85           :current-page="page"
86           :page-sizes="[10, 20, 50, 100]"
87           :page-size="limit"
88           :total="total"
89           layout="total, sizes, prev, pager, next, jumper"
90           @size-change="pageSizeChangeHandle"
91           @current-change="pageCurrentChangeHandle">
92       </el-pagination>
93       <!-- 弹窗, 新增 / 修改 -->
94       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
95       <!-- 弹窗, 历史数据 -->
96       <chart-view v-if="chartViewVisible" ref="chartView"></chart-view>
97       <!-- 弹窗, 设置值 -->
98       <set-value v-if="setValueVisible" ref="setValue"></set-value>
99     </div>
100   </el-card>
101 </template>
102 <script>
103   import mixinViewModule from '@/mixins/view-module'
104   import AddOrUpdate from './point-add-or-update'
105   import ChartView from './point-chart'
106   import SetValue from './point-set'
107
108   export default {
109     mixins: [mixinViewModule],
110     data() {
111       return {
112         mixinViewModuleOptions: {
113           getDataListURL: '/data/da/point/page',
114           getDataListIsPage: true,
115           deleteURL: '/data/da/point',
116           deleteIsBatch: true,
117           exportURL: '/data/da/point/export'
118         },
119         dataForm: {
120           pointNo: '',
121           pointName: '',
122           tagNo: '',
123           sourceName: ''
124         },
125         chartViewVisible: false,
126         setValueVisible: false,
127       }
128     },
129     components: {
130       AddOrUpdate,
131       ChartView,
132       SetValue
133     },
134     methods: {
135       chartHandle(row) {
136         this.chartViewVisible = true
137         this.$nextTick(() => {
138           this.$refs.chartView.init(row)
139         })
140       },
141
142       setValueHandle(row) {
143         this.setValueVisible = true
144         this.$nextTick(() => {
145           this.$refs.setValue.init(row)
146         })
147       },
148
149       // 启用
150       enableHandle(id) {
151         if (!id && this.dataListSelections.length <= 0) {
152           return this.$message({
153             message: this.$t('prompt.checkBatch'),
154             type: 'warning',
155             duration: 500
156           })
157         }
158         this.$confirm(this.$t('prompt.info', {'handle': '启用'}), this.$t('prompt.title'), {
159           confirmButtonText: this.$t('confirm'),
160           cancelButtonText: this.$t('cancel'),
161           type: 'warning'
162         }).then(() => {
163           this.$http.put('/data/da/point/enable', id ? [id] : this.dataListSelections.map(item => item.id)).then(({data: res}) => {
164             if (res.code !== 0) {
165               return this.$message.error(res.msg)
166             }
167             this.$message({
168               message: this.$t('prompt.success'),
169               type: 'success',
170               duration: 500,
171               onClose: () => {
172                 this.getDataList()
173               }
174             })
175           }).catch(() => {
176           })
177         }).catch(() => {
178         })
179       },
180
181       // 禁用
182       disableHandle(id) {
183         if (!id && this.dataListSelections.length <= 0) {
184           return this.$message({
185             message: this.$t('prompt.checkBatch'),
186             type: 'warning',
187             duration: 500
188           })
189         }
190         this.$confirm(this.$t('prompt.info', {'handle': '禁用'}), this.$t('prompt.title'), {
191           confirmButtonText: this.$t('confirm'),
192           cancelButtonText: this.$t('cancel'),
193           type: 'warning'
194         }).then(() => {
195           this.$http.put('/data/da/point/disable', id ? [id] : this.dataListSelections.map(item => item.id)).then(({data: res}) => {
196             if (res.code !== 0) {
197               return this.$message.error(res.msg)
198             }
199             this.$message({
200               message: this.$t('prompt.success'),
201               type: 'success',
202               duration: 500,
203               onClose: () => {
204                 this.getDataList()
205               }
206             })
207           }).catch(() => {
208           })
209         }).catch(() => {
210         })
211       },
212     }
213   }
214 </script>