houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-card shadow="never" class="aui-card--fill">
3     <div>
4       <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
5         <el-form-item>
6           <el-input v-model="dataForm.predictitemid" placeholder="预测项" clearable></el-input>
7         </el-form-item>
8         <el-form-item>
9           <el-button @click="searchDataList()">查询</el-button>
10           <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
11           <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
12         </el-form-item>
13       </el-form>
14       <el-table
15               :data="dataList"
16               border
17               v-loading="dataListLoading"
18               @selection-change="selectionChangeHandle"
19               style="width: 100%;">
20         <el-table-column
21                 type="selection"
22                 header-align="center"
23                 align="center"
24                 width="50">
25         </el-table-column>
26         <el-table-column
27                 type="index"
28                 align="center"
29                 width="50"
30                 label="序号"
31         >
32         </el-table-column>
33         <el-table-column
34                 prop="itemname"
35                 header-align="center"
36                 align="center"
37                 label="预测项">
38         </el-table-column>
39         <el-table-column
40                 prop="modelname"
41                 header-align="center"
42                 align="center"
43                 label="调度模型">
44         </el-table-column>
45         <el-table-column
46                 prop="maxValue"
47                 header-align="center"
48                 align="center"
49                 label="最大值">
50         </el-table-column>
51         <el-table-column
52                 prop="minValue"
53                 header-align="center"
54                 align="center"
55                 label="最小值">
56         </el-table-column>
57         <el-table-column
58                 fixed="right"
59                 header-align="center"
60                 align="center"
61                 width="150"
62                 label="操作">
63           <template slot-scope="scope">
64             <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
65           </template>
66         </el-table-column>
67       </el-table>
68       <el-pagination
69               @size-change="sizeChangeHandle"
70               @current-change="currentChangeHandle"
71               :current-page="pageIndex"
72               :page-sizes="[10, 20, 50, 100]"
73               :page-size="pageSize"
74               :total="totalPage"
75               layout="total, sizes, prev, pager, next, jumper">
76       </el-pagination>
77       <!-- 弹窗, 新增 / 修改 -->
78       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
79     </div>
80   </el-card>
81 </template>
82
83 <script>
84   import AddOrUpdate from './st-schedule-predict-item-add-or-update'
85
86   export default {
87     data () {
88       return {
89         dataForm: {
90           predictitemid: ''
91         },
92         dataList: [],
93         pageIndex: 1,
94         pageSize: 10,
95         totalPage: 0,
96         dataListLoading: false,
97         dataListSelections: [],
98         addOrUpdateVisible: false
99       }
100     },
101     components: {
102       AddOrUpdate
103     },
104     activated () {
105       this.getDataList()
106     },
107     methods: {
108       searchDataList () {
109         this.pageIndex = 1
110         this.getDataList()
111       },
112       // 获取数据列表
113       getDataList () {
114         this.dataListLoading = true
115         this.$http({
116           url: '/iailab-ntt-model/mcs/schedule-predict-item/list',
117           method: 'get',
118           params: this.$http.adornParams({
119             'page': this.pageIndex,
120             'limit': this.pageSize,
121             'pointtypename': this.dataForm.pointtypename,
122             'pointtypeno': this.dataForm.pointtypeno
123           })
124         }).then(({data}) => {
125           if (data && data.code === 0) {
126             this.dataList = data.page.list
127             this.totalPage = data.page.totalCount
128           } else {
129             this.dataList = []
130             this.totalPage = 0
131           }
132           this.dataListLoading = false
133         })
134       },
135       // 每页数
136       sizeChangeHandle (val) {
137         this.pageSize = val
138         this.pageIndex = 1
139         this.getDataList()
140       },
141       // 当前页
142       currentChangeHandle (val) {
143         this.pageIndex = val
144         this.getDataList()
145       },
146       // 多选
147       selectionChangeHandle (val) {
148         this.dataListSelections = val
149       },
150       // 新增 / 修改
151       addOrUpdateHandle (id) {
152         this.addOrUpdateVisible = true
153         this.$nextTick(() => {
154           this.$refs.addOrUpdate.init(id)
155         })
156       },
157       // 删除
158       deleteHandle (id) {
159         var ids = id ? [id] : this.dataListSelections.map(item => {
160           return item.id
161         })
162         this.$confirm(`确定删除选中的${ids.length}项数据?`, '提示', {
163           confirmButtonText: '确定',
164           cancelButtonText: '取消',
165           type: 'warning'
166         }).then(() => {
167           this.$http({
168             url: '/iailab-ntt-model/mcs/schedule-predict-item/delete',
169             method: 'post',
170             data: this.$http.adornData(ids, false)
171           }).then(({data}) => {
172             if (data && data.code === 0) {
173               this.$message({
174                 message: '操作成功',
175                 type: 'success',
176                 duration: 1500,
177                 onClose: () => {
178                   this.getDataList()
179                 }
180               })
181             } else {
182               this.$message.error(data.msg)
183             }
184           })
185         }).catch(() => {})
186       }
187     }
188   }
189 </script>