wyg
2024-06-18 1308d4d7a162d3cabd0fe4f639b6d7f5dd376584
提交 | 用户 | 时间
bdd09a 1 <template>
1308d4 2   <el-main class="contbox" ref="contBox">
W 3     <div class="head" ref="headBox">
4       <BaseSearch
5         @getList="getList"
6         :formItemList="searchFormSchema"
7         @search="getList"
8         @showSearchChange="getElHeight(28)"
9       >
10         <template #actionButton>
11           <el-col :span="1.5">
12             <el-button
13               type="primary"
14               plain
15               icon="el-icon-plus"
16               size="mini"
17               @click="handleAdd"
18               v-hasPermi="['iqc_checkItem_create']"
19               >新增</el-button
20             >
21           </el-col>
22           <el-col :span="1.5">
23             <el-button
24               type="success"
25               plain
26               icon="el-icon-edit"
27               size="mini"
28               @click="handleUpdate"
29               v-hasPermi="['iqc_checkItem_edit']"
30               >修改</el-button
31             >
32           </el-col>
33           <el-col :span="1.5">
34             <el-button
35               type="danger"
36               plain
37               icon="el-icon-delete"
38               size="mini"
39               @click="handleDelete"
40               v-hasPermi="['iqc_checkItem_delete']"
41               >删除</el-button
42             >
43           </el-col>
44f5fa 44         </template>
1308d4 45       </BaseSearch>
W 46     </div>
47     <TableCom
48       :column="tabiInfo.columns"
49       :table-data="tabiInfo.tableData"
50       :table-loading="tabiInfo.tableLoading"
51       :isSelection="tabiInfo.isSelection"
52       :height="elementHeight"
53       rowKey="warehouseId"
54       ref="tabel"
55       @checkData="checkData"
56       @checkLook="checkInfo"
57     >
58       <template slot="checkType" slot-scope="scope">
59         <dict-tag
60           :options="dict.type.check_type"
61           :value="scope.row.checkType"
62         />
63       </template>
64       <template slot="isAutoCheck" slot-scope="scope">
65         <dict-tag
66           :options="dict.type.is_auto_check"
67           :value="scope.row.isAutoCheck"
68         />
69       </template>
70       <template slot="isRequired" slot-scope="scope">
71         <dict-tag
72           :options="dict.type.is_required"
73           :value="scope.row.isRequired"
74         />
75       </template>
76       <template slot="isToSpc" slot-scope="scope">
77         <dict-tag :options="dict.type.is_to_spc" :value="scope.row.isToSpc" />
78       </template>
79       <template slot="status" slot-scope="scope">
80         <dict-tag :options="dict.type.status" :value="scope.row.status" />
81       </template>
82     </TableCom>
83     <div class="pagination" ref="pagination">
84       <pagination
85         v-show="pageInfo.pageTotal > 0"
86         :total="pageInfo.pageTotal"
87         :page.sync="pageInfo.currentPage"
88         :limit.sync="pageInfo.pageSize"
89         @pagination="getList"
90       />
91     </div>
92     <AddaddModal ref="addaddModal" @getList="getList" />
93   </el-main>
bdd09a 94 </template>
W 95
96 <script>
1308d4 97 import TableCom from "@/components/Table/index";
W 98 import BaseSearch from "@/components/Table/BaseSearch";
99
100 import { columns, searchFormSchema } from "./info.data";
101 import mixin from "@/components/Table/mixins/resize";
102 import { listWarehouse, delWarehouse } from "@/api/basicData/warehouse";
103 import AddaddModal from "./addModal";
bdd09a 104
W 105 export default {
106   name: "Warehouse",
1308d4 107   components: { TableCom, BaseSearch, AddaddModal },
W 108   mixins: [mixin],
109   dicts: ["check_type", "is_auto_check", "is_required", "is_to_spc", "status"],
bdd09a 110   data() {
W 111     return {
1308d4 112       searchFormSchema: searchFormSchema,
W 113       tabiInfo: {
114         columns: columns,
115         tableData: [],
116         tableLoading: false,
117         isSelection: true,
118         rowClassName: "rowClassName",
bdd09a 119       },
1308d4 120       pageInfo: {
W 121         pageSize: 10,
122         pageTotal: 0,
123         currentPage: 1,
124       },
125       visible: false,
126       ids: [],
127       open: false,
bdd09a 128     };
W 129   },
1308d4 130   mounted() {
bdd09a 131     this.getList();
W 132   },
133   methods: {
1308d4 134     getList(info = {}) {
W 135       this.ids = [];
136       this.tabiInfo.tableLoading = true;
137       let params = {
138         pageSize: this.pageInfo.pageSize,
139         pageNum: this.pageInfo.currentPage,
140         bizType: 10,
141         ...info,
bdd09a 142       };
1308d4 143       listWarehouse(params).then((res) => {
W 144         if (res.code == 200) {
145           this.pageInfo.pageTotal = res.total;
146           this.tabiInfo.tableData = res.rows;
147           this.tabiInfo.tableLoading = false;
bdd09a 148         }
W 149       });
150     },
1308d4 151     checkData(data) {
W 152       if (data.length) {
153         this.ids = data.map((item) => {
154           return item.warehouseId;
155         });
156       } else {
157         this.ids = [];
158       }
bdd09a 159     },
1308d4 160     handleAdd() {
W 161       this.$refs.addaddModal.elDialogShow(1);
162     },
163     checkInfo(info) {
164       this.$refs.addaddModal.elDialogShow(3, info.warehouseId);
165     },
166     /** 修改按钮操作 */
167     handleUpdate() {
168       if (this.ids.length > 1) {
169         this.$message({
170           message: "只能操作单条数据!",
171           type: "warning",
172         });
173         return;
174       } else if (this.ids.length < 1) {
175         this.$message({
176           message: "请选择数据",
177           type: "warning",
178         });
179         return;
180       }
181       this.$refs.addaddModal.elDialogShow(2, this.ids[0]);
182     },
183     handleDelete() {
184       const warehouseIds = this.ids;
185
186       if (warehouseIds.length) {
187         this.$modal
188           .confirm(
189             '是否确认删除已选中的数据项?'
190           )
191           .then(() => {
192             this.tabiInfo.tableLoading = true;
193             return delWarehouse(warehouseIds);
194           })
195           .then(() => {
196             this.tabiInfo.tableLoading = false;
197             this.ids = [];
198             this.getList();
199             this.$message({
200               message: "删除成功",
201               type: "success",
202             });
203           })
204           .catch(() => {})
205           .finally(() => {
206             this.tabiInfo.tableLoading = false;
207           });
208       } else {
209         this.$message({
210           message: "请选择数据",
211           type: "warning",
212         });
213       }
214     },
215   },
bdd09a 216 };
W 217 </script>
1308d4 218
W 219 <style lang="less" scoped>
220 .rowClassName {
221   height: 50px;
222 }
223 .contbox {
224   width: 100;
225   height: 100%;
226 }
227 </style>