src/views/equipmentManagement/spareParts/index.vue
@@ -75,6 +75,32 @@
            <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"
@@ -88,8 +114,8 @@
          </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>
@@ -134,6 +160,7 @@
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";
@@ -153,6 +180,7 @@
const operationType = ref('add')
// 设备选项
const deviceOptions = ref([]);
const userOptions = ref([]);
// 表单引用
const formRef = ref(null);
// 查询参数
@@ -222,6 +250,14 @@
    prop: "quantity",
  },
  {
    label: "库存预警数量",
    prop: "warnNum",
  },
  {
    label: "预警通知人",
    prop: "notifyPersonName",
  },
  {
    label: "描述",
    prop: "description",
  },
@@ -256,7 +292,9 @@
  status: '',
  description: '',
  deviceLedgerIds: [],
  price: null
  price: null,
  warnNum: null,
  notifyPersonId: null
});
// 表单验证规则
@@ -414,9 +452,20 @@
  }
};
// 加载用户列表
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 = '';
@@ -425,6 +474,8 @@
  form.deviceLedgerIds = [];
  form.quantity = undefined;
  form.price = null;
  form.warnNum = null;
  form.notifyPersonId = null;
  operationType.value = 'add'
  dialogVisible.value = true;
};
@@ -432,6 +483,7 @@
// 编辑分类
const editCategory = async (row) => {
  await loadDeviceName();
  await loadUserOptions();
  Object.assign(form, row);
  // 如果后端返回的是 deviceIds 字符串,需要转换为数组
  if (row.deviceIds && typeof row.deviceIds === 'string') {