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.nf" placeholder="年份" clearable></el-input>
7         </el-form-item>
8         <el-form-item>
9           <el-button @click="searchDataList()">查询</el-button>
10           <el-button v-if="$hasPermission('coal:prod-plan-month:add')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
11           <el-button v-if="$hasPermission('coal:prod-plan-month:delete')" 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         </el-table-column>
32         <el-table-column
33                 prop="nf"
34                 header-align="center"
35                 align="center"
36                 width="200"
37                 label="年份">
38         </el-table-column>
39         <el-table-column
40                 prop="zcxtCode"
41                 header-align="center"
42                 align="center"
43                 width="100"
44                 label="装车系统">
45         </el-table-column>
46         <el-table-column
47                 prop="myCode"
48                 header-align="center"
49                 align="center"
50                 width="100"
51                 label="煤源">
52         </el-table-column>
53         <el-table-column
54                 prop="sl"
55                 header-align="center"
56                 align="center"
57                 min-width="200"
58                 label="数量">
59         </el-table-column>
60         <el-table-column
61                 v-if="$hasPermission('coal:prod-plan-month:edit')"
62                 fixed="right"
63                 header-align="center"
64                 align="center"
65                 width="100"
66                 label="操作">
67           <template slot-scope="scope">
68             <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
69           </template>
70         </el-table-column>
71       </el-table>
72       <el-pagination
73               @size-change="sizeChangeHandle"
74               @current-change="currentChangeHandle"
75               :current-page="pageIndex"
76               :page-sizes="[10, 20, 50, 100]"
77               :page-size="pageSize"
78               :total="totalPage"
79               layout="total, sizes, prev, pager, next, jumper">
80       </el-pagination>
81       <!-- 弹窗, 新增 / 修改 -->
82       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
83     </div>
84   </el-card>
85 </template>
86
87 <script>
88   import AddOrUpdate from './prod-quality-bc-add-or-update'
89
90   export default {
91     data () {
92       return {
93         dataForm: {
94           nf: ''
95         },
96         dataList: [],
97         pageIndex: 1,
98         pageSize: 10,
99         totalPage: 0,
100         dataListLoading: false,
101         dataListSelections: [],
102         addOrUpdateVisible: false
103       }
104     },
105     components: {
106       AddOrUpdate
107     },
108     activated () {
109       this.getDataList()
110     },
111     methods: {
112       searchDataList () {
113         this.pageIndex = 1
114         this.getDataList()
115       },
116       // 获取数据列表
117       getDataList () {
118         this.dataListLoading = true
119         this.$http({
120           url: '/data/coal/zcxt-plan-year/list',
121           method: 'get',
122           params: this.$http.adornParams({
123             'page': this.pageIndex,
124             'limit': this.pageSize,
125             'nf': this.dataForm.nf
126           })
127         }).then(({data}) => {
128           if (data && data.code === 0) {
129             this.dataList = data.page.list
130             this.totalPage = data.page.totalCount
131           } else {
132             this.dataList = []
133             this.totalPage = 0
134           }
135           this.dataListLoading = false
136         })
137       },
138       // 每页数
139       sizeChangeHandle (val) {
140         this.pageSize = val
141         this.pageIndex = 1
142         this.getDataList()
143       },
144       // 当前页
145       currentChangeHandle (val) {
146         this.pageIndex = val
147         this.getDataList()
148       },
149       // 多选
150       selectionChangeHandle (val) {
151         this.dataListSelections = val
152       },
153       // 新增 / 修改
154       addOrUpdateHandle (id) {
155         this.addOrUpdateVisible = true
156         this.$nextTick(() => {
157           this.$refs.addOrUpdate.init(id)
158         })
159       },
160       // 删除
161       deleteHandle (id) {
162         var ids = id ? [id] : this.dataListSelections.map(item => {
163           return item.id
164         })
165         this.$confirm(`确定删除选中的${ids.length}项数据?`, '提示', {
166           confirmButtonText: '确定',
167           cancelButtonText: '取消',
168           type: 'warning'
169         }).then(() => {
170           this.$http({
171             url: '/data/coal/zcxt-plan-year/delete',
172             method: 'post',
173             data: this.$http.adornData(ids, false)
174           }).then(({data}) => {
175             if (data && data.code === 0) {
176               this.$message({
177                 message: '操作成功',
178                 type: 'success',
179                 duration: 1500,
180                 onClose: () => {
181                   this.getDataList()
182                 }
183               })
184             } else {
185               this.$message.error(data.msg)
186             }
187           })
188         }).catch(() => {})
189       }
190     }
191   }
192 </script>