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="ny"
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-plan-month: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     mounted () {
116       this.getDataList()
117     },
118     methods: {
119       searchDataList () {
120         this.pageIndex = 1
121         this.getDataList()
122       },
123       // 获取数据列表
124       getDataList () {
125         this.dataListLoading = true
126         this.$http({
127           url: '/data/coal/prod-plan-month/list',
128           method: 'get',
129           params: this.$http.adornParams({
130             'page': this.pageIndex,
131             'limit': this.pageSize,
132             'nf': this.dataForm.nf
133           })
134         }).then(({data}) => {
135           if (data && data.code === 0) {
136             this.dataList = data.page.list
137             this.totalPage = data.page.totalCount
138           } else {
139             this.dataList = []
140             this.totalPage = 0
141           }
142           this.dataListLoading = false
143         })
144       },
145       // 每页数
146       sizeChangeHandle (val) {
147         this.pageSize = val
148         this.pageIndex = 1
149         this.getDataList()
150       },
151       // 当前页
152       currentChangeHandle (val) {
153         this.pageIndex = val
154         this.getDataList()
155       },
156       // 多选
157       selectionChangeHandle (val) {
158         this.dataListSelections = val
159       },
160       // 新增 / 修改
161       addOrUpdateHandle (id) {
162         this.addOrUpdateVisible = true
163         this.$nextTick(() => {
164           this.$refs.addOrUpdate.init(id)
165         })
166       },
167       // 删除
168       deleteHandle (id) {
169         var ids = id ? [id] : this.dataListSelections.map(item => {
170           return item.id
171         })
172         this.$confirm(`确定删除选中的${ids.length}项数据?`, '提示', {
173           confirmButtonText: '确定',
174           cancelButtonText: '取消',
175           type: 'warning'
176         }).then(() => {
177           this.$http({
178             url: '/data/coal/prod-plan-month/delete',
179             method: 'post',
180             data: this.$http.adornData(ids, false)
181           }).then(({data}) => {
182             if (data && data.code === 0) {
183               this.$message({
184                 message: '操作成功',
185                 type: 'success',
186                 duration: 1500,
187                 onClose: () => {
188                   this.getDataList()
189                 }
190               })
191             } else {
192               this.$message.error(data.msg)
193             }
194           })
195         }).catch(() => {})
196       }
197     }
198   }
199 </script>