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