| <template> | 
|   <div class="app-container"> | 
|   | 
|     <el-row :gutter="10" class="mb8"> | 
|       <el-col :span="1.5"> | 
|         <el-button | 
|           type="primary" | 
|           plain | 
|           icon="Plus" | 
|           @click="handleAdd" | 
|           v-hasPermi="['shop:add']" | 
|         >新增</el-button> | 
|       </el-col> | 
|       <el-col :span="1.5"> | 
|         <el-button | 
|           type="success" | 
|           plain | 
|           icon="Edit" | 
|           :disabled="single" | 
|           @click="handleUpdate" | 
|           v-hasPermi="['shop:edit']" | 
|         >修改</el-button> | 
|       </el-col> | 
|   | 
|       <el-col :span="1.5"> | 
|         <el-button | 
|           type="warning" | 
|           plain | 
|           icon="Download" | 
|           @click="handleExport" | 
|           v-hasPermi="['shop:export']" | 
|         >导出</el-button> | 
|       </el-col> | 
|       <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | 
|     </el-row> | 
|   | 
|     <el-table v-loading="loading" :data="aps_shopList" @selection-change="handleSelectionChange"> | 
|       <el-table-column type="selection" width="55" align="center" /> | 
|       <el-table-column label="车间名称" align="center" prop="shopName" /> | 
|       <el-table-column label="车间代码" align="center" prop="shopCode" /> | 
|       <el-table-column label="工厂代码" align="center" prop="plantCode" /> | 
|       <el-table-column label="启用状态" align="center" prop="status"> | 
|         <template #default="scope"> | 
|           <dict-tag :options="aps_plant_status" :value="scope.row.status"/> | 
|         </template> | 
|       </el-table-column> | 
|       <el-table-column label="创建者" align="center" prop="createBy" /> | 
|       <el-table-column label="创建时间" align="center" prop="createTime" /> | 
|       <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 
|         <template #default="scope"> | 
|           <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['shop:edit']">修改</el-button> | 
|         </template> | 
|       </el-table-column> | 
|     </el-table> | 
|      | 
|     <pagination | 
|       v-show="total>0" | 
|       :total="total" | 
|       v-model:page="queryParams.pageNum" | 
|       v-model:limit="queryParams.pageSize" | 
|       @pagination="getList" | 
|     /> | 
|   | 
|     <!-- 添加或修改车间对话框 --> | 
|     <el-dialog :title="title" v-model="open" width="500px" append-to-body> | 
|       <el-form ref="aps_shopRef" :model="form" :rules="rules" label-width="80px"> | 
|         <el-form-item label="车间名称" prop="shopName"> | 
|           <el-input v-model="form.shopName" placeholder="请输入车间名称" /> | 
|         </el-form-item> | 
|         <el-form-item label="车间代码" prop="shopCode"> | 
|           <el-input v-model="form.shopCode" placeholder="请输入车间代码" :disabled=shopCodeDisabled  /> | 
|   | 
|         </el-form-item> | 
|         <el-form-item label="工厂编码" prop="plantCode"> | 
|           <el-select v-model="form.plantCode" | 
|                      placeholder="请选择工厂编码" | 
|                      value-key="plantCode" | 
|           > | 
|             <el-option | 
|                 v-for="plant in plantList" | 
|                 :key="plant.plantCode" | 
|                 :label="plant.plantName" | 
|                 :value="plant.plantCode" | 
|             > {{plant.plantName}} </el-option> | 
|           </el-select> | 
|         </el-form-item> | 
|         <el-form-item label="启用状态" prop="status"> | 
|           <el-radio-group v-model="form.status"> | 
|             <el-radio | 
|                 v-for="dict in aps_plant_status" | 
|                 :key="dict.value" | 
|                 :label="dict.value" | 
|             >{{dict.label}}</el-radio> | 
|           </el-radio-group> | 
|         </el-form-item> | 
|       </el-form> | 
|       <template #footer> | 
|         <div class="dialog-footer"> | 
|           <el-button type="primary" @click="submitForm">确 定</el-button> | 
|           <el-button @click="cancel">取 消</el-button> | 
|         </div> | 
|       </template> | 
|     </el-dialog> | 
|   </div> | 
| </template> | 
|   | 
| <script setup name="Aps_shop"> | 
| import { listAps_shop, getAps_shop, delAps_shop, addAps_shop, updateAps_shop } from "@/api/basicData/shop"; | 
| import { listAps_plant } from "@/api/basicData/plant"; | 
|   | 
| const { proxy } = getCurrentInstance(); | 
| const { aps_plant_status } = proxy.useDict('aps_plant_status'); | 
|   | 
| const aps_shopList = ref([]); | 
| const open = ref(false); | 
| const loading = ref(true); | 
| const showSearch = ref(false); | 
| const ids = ref([]); | 
| const single = ref(true); | 
| const multiple = ref(true); | 
| const total = ref(0); | 
| const title = ref(""); | 
| const plantList = ref([]); | 
| const shopCodeDisabled = ref(false); | 
| const data = reactive({ | 
|   form: {}, | 
|   queryParams: { | 
|     pageNum: 1, | 
|     pageSize: 10, | 
|     shopName: null, | 
|     shopCode: null, | 
|     plantCode: null, | 
|     status: null, | 
|   }, | 
|   rules: { | 
|     shopName: [ | 
|       { required: true, message: "车间名称不能为空", trigger: "blur" }, | 
|     ], | 
|     shopCode: [ | 
|       { required: true, message: "车间编码不能为空", trigger: "blur" }, | 
|     ], | 
|     plantCode: [ | 
|       { required: true, message: "工厂编码不能为空", trigger: "blur" }, | 
|     ], | 
|     status: [ | 
|       { required: true, message: "启用状态不能为空", trigger: "blur" }, | 
|     ], | 
|   } | 
| }); | 
|   | 
| const { queryParams, form, rules } = toRefs(data); | 
|   | 
| /** 查询车间列表 */ | 
| function getList() { | 
|   loading.value = true; | 
|   listAps_shop(queryParams.value).then(response => { | 
|     aps_shopList.value = response.rows; | 
|     total.value = response.total; | 
|     loading.value = false; | 
|   }); | 
| } | 
|   | 
| // 取消按钮 | 
| function cancel() { | 
|   open.value = false; | 
|   reset(); | 
| } | 
|   | 
| // 表单重置 | 
| function reset() { | 
|   form.value = { | 
|     id: null, | 
|     shopName: null, | 
|     shopCode: null, | 
|     plantCode: null, | 
|     status: null, | 
|     createBy: null, | 
|     createTime: null, | 
|     updateBy: null, | 
|     updateTime: null | 
|   }; | 
|   proxy.resetForm("aps_shopRef"); | 
| } | 
|   | 
| /** 搜索按钮操作 */ | 
| function handleQuery() { | 
|   queryParams.value.pageNum = 1; | 
|   getList(); | 
| } | 
|   | 
| /** 重置按钮操作 */ | 
| function resetQuery() { | 
|   proxy.resetForm("queryRef"); | 
|   handleQuery(); | 
| } | 
|   | 
| // 多选框选中数据 | 
| function handleSelectionChange(selection) { | 
|   ids.value = selection.map(item => item.id); | 
|   single.value = selection.length != 1; | 
|   multiple.value = !selection.length; | 
| } | 
|   | 
| /** 新增按钮操作 */ | 
| function handleAdd() { | 
|   reset(); | 
|   open.value = true; | 
|   shopCodeDisabled.value = false; | 
|   title.value = "添加车间"; | 
| } | 
|   | 
| /** 修改按钮操作 */ | 
| function handleUpdate(row) { | 
|   reset(); | 
|   const _id = row.id || ids.value | 
|   shopCodeDisabled.value = true; | 
|   getAps_shop(_id).then(response => { | 
|     form.value = response.data; | 
|     open.value = true; | 
|     title.value = "修改车间"; | 
|   }); | 
| } | 
|   | 
| /** 提交按钮 */ | 
| function submitForm() { | 
|   proxy.$refs["aps_shopRef"].validate(valid => { | 
|     if (valid) { | 
|       if (form.value.id != null) { | 
|         updateAps_shop(form.value).then(response => { | 
|           proxy.$modal.msgSuccess("修改成功"); | 
|           open.value = false; | 
|           getList(); | 
|         }); | 
|       } else { | 
|         addAps_shop(form.value).then(response => { | 
|           proxy.$modal.msgSuccess("新增成功"); | 
|           open.value = false; | 
|           getList(); | 
|         }); | 
|       } | 
|     } | 
|   }); | 
| } | 
|   | 
| /** 删除按钮操作 */ | 
| function handleDelete(row) { | 
|   const _ids = row.id || ids.value; | 
|   proxy.$modal.confirm('是否确认删除车间编号为"' + _ids + '"的数据项?').then(function() { | 
|     return delAps_shop(_ids); | 
|   }).then(() => { | 
|     getList(); | 
|     proxy.$modal.msgSuccess("删除成功"); | 
|   }).catch(() => {}); | 
| } | 
|   | 
| /** 导出按钮操作 */ | 
| function handleExport() { | 
|   proxy.download('aps_shop/aps_shop/export', { | 
|     ...queryParams.value | 
|   }, `aps_shop_${new Date().getTime()}.xlsx`) | 
| } | 
| /** 查询车间列表 */ | 
| function getPlantList() { | 
|   loading.value = true; | 
|   listAps_plant({}).then(response => { | 
|     plantList.value = response.rows; | 
|   | 
|     loading.value = false; | 
|   }); | 
| } | 
| getPlantList(); | 
| getList(); | 
| </script> |