| | |
| | | <el-form-item label="描述" prop="description"> |
| | | <el-input v-model="form.description"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="库存预警数量" prop="warnNum"> |
| | | <el-input-number |
| | | v-model="form.warnNum" |
| | | placeholder="请输入库存预警数量" |
| | | :min="0" |
| | | :step="0.1" |
| | | :precision="2" |
| | | style="width: 100%" |
| | | ></el-input-number> |
| | | </el-form-item> |
| | | <el-form-item label="预警通知人" prop="notifyPersonId"> |
| | | <el-select |
| | | v-model="form.notifyPersonId" |
| | | placeholder="请选择预警通知人" |
| | | filterable |
| | | clearable |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="user in userOptions" |
| | | :key="user.userId" |
| | | :label="user.nickName || user.userName" |
| | | :value="user.userId" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="价格" prop="price"> |
| | | <el-input-number |
| | | v-model="form.price" |
| | |
| | | </el-form> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="dialogVisible = false" :disabled="formLoading">取消</el-button> |
| | | <el-button type="primary" @click="submitForm" :loading="formLoading">确定</el-button> |
| | | <el-button @click="dialogVisible = false" :disabled="formLoading">取消</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | import { ElMessage, ElMessageBox } from 'element-plus'; |
| | | import { getSparePartsList, addSparePart, editSparePart, delSparePart } from "@/api/equipmentManagement/spareParts"; |
| | | import { getDeviceLedger } from "@/api/equipmentManagement/ledger"; |
| | | import { userListNoPage } from "@/api/system/user.js"; |
| | | import PIMTable from "@/components/PIMTable/PIMTable.vue"; |
| | | import { getSparePartsUsagePage } from "@/api/equipmentManagement/sparePartsUsage"; |
| | | |
| | |
| | | const operationType = ref('add') |
| | | // 设备选项 |
| | | const deviceOptions = ref([]); |
| | | const userOptions = ref([]); |
| | | // 表单引用 |
| | | const formRef = ref(null); |
| | | // 查询参数 |
| | |
| | | prop: "quantity", |
| | | }, |
| | | { |
| | | label: "库存预警数量", |
| | | prop: "warnNum", |
| | | }, |
| | | { |
| | | label: "预警通知人", |
| | | prop: "notifyPersonName", |
| | | }, |
| | | { |
| | | label: "描述", |
| | | prop: "description", |
| | | }, |
| | |
| | | status: '', |
| | | description: '', |
| | | deviceLedgerIds: [], |
| | | price: null |
| | | price: null, |
| | | warnNum: null, |
| | | notifyPersonId: null |
| | | }); |
| | | |
| | | // 表单验证规则 |
| | |
| | | } |
| | | }; |
| | | |
| | | // 加载用户列表 |
| | | const loadUserOptions = async () => { |
| | | try { |
| | | const res = await userListNoPage(); |
| | | userOptions.value = res.data || []; |
| | | } catch (error) { |
| | | ElMessage.error('获取用户列表失败'); |
| | | } |
| | | }; |
| | | |
| | | // 新增分类 |
| | | const addCategory = async () => { |
| | | await loadDeviceName(); |
| | | await loadUserOptions(); |
| | | form.id = ''; |
| | | form.name = ''; |
| | | form.sparePartsNo = ''; |
| | |
| | | form.deviceLedgerIds = []; |
| | | form.quantity = undefined; |
| | | form.price = null; |
| | | form.warnNum = null; |
| | | form.notifyPersonId = null; |
| | | operationType.value = 'add' |
| | | dialogVisible.value = true; |
| | | }; |
| | |
| | | // 编辑分类 |
| | | const editCategory = async (row) => { |
| | | await loadDeviceName(); |
| | | await loadUserOptions(); |
| | | Object.assign(form, row); |
| | | // 如果后端返回的是 deviceIds 字符串,需要转换为数组 |
| | | if (row.deviceIds && typeof row.deviceIds === 'string') { |