        <a-form-item label="持有人类型">
          <a-select v-model:value="form.owner_type" placeholder="请选择持有人类型" allow-clear>
            <a-select-option value="user">用户</a-select-option>
            <a-select-option value="location">位置</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="持有人类型">
          <a-select v-model:value="form.owner_type" placeholder="请选择持有人类型" :options="ownerTypeOptions" allow-clear />
        </a-form-item>


Edit

          <a-col :span="12"><a-form-item label="关联类型">
            <a-select v-model:value="form.target_type" placeholder="请选择关联类型">
              <a-select-option value="device">设备</a-select-option>
              <a-select-option value="license">许可证</a-select-option>
              <a-select-option value="accessory">配件</a-select-option>
            </a-select>
          </a-form-item></a-col>

          <a-col :span="12"><a-form-item label="关联类型">
            <a-select v-model:value="form.target_type" placeholder="请选择关联类型" :options="targetTypeOptions" />
          </a-form-item></a-col>


          <a-col :span="12"><a-form-item label="状态">
            <a-select v-model:value="form.status">
              <a-select-option value="open">待处理</a-select-option>
              <a-select-option value="in_progress">处理中</a-select-option>
              <a-select-option value="resolved">已修复</a-select-option>
              <a-select-option value="closed">已关闭</a-select-option>
            </a-select>
          </a-form-item></a-col>

          <a-col :span="12"><a-form-item label="状态">
            <a-select v-model:value="form.status" :options="failureStatusOptions" />
          </a-form-item></a-col>


        <a-form-item label="状态">
          <a-select v-model:value="form.status">
            <a-select-option value="pending">待审批</a-select-option>
            <a-select-option value="approved">已批准</a-select-option>
            <a-select-option value="rejected">已拒绝</a-select-option>
            <a-select-option value="cancelled">已取消</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="状态">
          <a-select v-model:value="form.status" :options="requestStatusOptions" />
        </a-form-item>


        <a-form-item label="状态">
          <a-select v-model:value="form.status">
            <a-select-option value="planning">计划中</a-select-option>
            <a-select-option value="in_progress">执行中</a-select-option>
            <a-select-option value="completed">已完成</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="状态">
          <a-select v-model:value="form.status" :options="stocktakeStatusOptions" />
        </a-form-item>


        <a-form-item label="状态">
          <a-select v-model:value="form.status">
            <a-select-option :value="1">启用</a-select-option>
            <a-select-option :value="0">停用</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="状态">
          <a-select v-model:value="form.status" :options="depreciationStatusOptions" />
        </a-form-item>


        <a-form-item label="残值类型">
          <a-select v-model:value="form.floor_type">
            <a-select-option value="amount">固定金额</a-select-option>
            <a-select-option value="percent">百分比(%)</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="残值类型">
          <a-select v-model:value="form.floor_type" :options="floorTypeOptions" />
        </a-form-item>


        <a-form-item label="分类大类" required>
          <a-select v-model:value="form.category_type">
            <a-select-option value="device">设备</a-select-option>
            <a-select-option value="license">许可证</a-select-option>
            <a-select-option value="accessory">配件</a-select-option>
            <a-select-option value="consumable">耗材</a-select-option>
            <a-select-option value="service">服务</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="分类大类" required>
          <a-select v-model:value="form.category_type" :options="categoryTypeOptions" />
        </a-form-item>


The file c:\Workspace\Project\tansci\antdv-next-admin\src\views\asset\offering\index.vue has been updated successfully. (file state is current in your context — no need to Read it back)

          <a-col :span="12"><a-form-item label="状态">
            <a-select v-model:value="form.offering_status">
              <a-select-option value="active">生效中</a-select-option>
              <a-select-option value="expired">已过期</a-select-option>
              <a-select-option value="cancelled">已取消</a-select-option>
            </a-select>
          </a-form-item></a-col>

          <a-col :span="12"><a-form-item label="状态">
            <a-select v-model:value="form.offering_status" :options="offeringStatusOptions" />
          </a-form-item></a-col>

<template>

    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '服务管理' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <PlusOutlined /> 新增服务
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'assigned_user_name'">
          {{ record.assigned_user_name }}
          未分配
        </template>
        <template v-if="column.key === 'offering_status'">
          {{ record.offering_status === 'active' ? '生效中' : record.offering_status }}
        </template>
        <template v-if="column.key === 'operations'">

            <EditOutlined /> 编辑

              <DeleteOutlined /> 删除

        </template>
      </template>
    </ProTable>

              生效中
              已过期
              已取消

        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            {{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}
          </template>
        </template>

</template>

<a-col :span="12"><a-form-item label="结束日期"><a-input v-model:value="form.end_date" type="date" /></a-form-item></a-col>

<a-col :span="12"><a-form-item label="费用"><a-input-number v-model:value="form.cost" style="width:100%" /></a-form-item></a-col>

-            <a-select v-model:value="form.offering_status">

-              <a-select-option value="active">生效中</a-select-option>

-              <a-select-option value="expired">已过期</a-select-option>

-              <a-select-option value="cancelled">已取消</a-select-option>

+            <a-select v-model:value="form.offering_status" :options="offeringStatusOptions" />

<a-col :span="24"><a-form-item label="备注" :label-col="{ span: 3 }"><a-textarea v-model:value="form.notes" :rows="2" /></a-form-item></a-col>


The file c:\Workspace\Project\tansci\antdv-next-admin\src\views\asset\biz\allocation\index.vue has been updated successfully. (file state is current in your context — no need to Read it back)

        <a-form-item label="资产类型" required>
          <a-select v-model:value="form.item_type" placeholder="请选择资产类型" :options="itemTypeOptions" />
        </a-form-item>

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '资产分配' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:allocation:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增分配</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'active' ? 'green' : record.status === 'returned' ? 'blue' : 'default'">{{ record.status === 'active' ? '使用中' : record.status === 'returned' ? '已归还' : record.status }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:allocation:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:allocation:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑分配' : '新增分配'" @ok="handleSubmit" width="600px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-form-item label="资产类型" required>
          <a-select v-model:value="form.item_type" placeholder="请选择资产类型">
            <a-select-option value="device">设备</a-select-option>
            <a-select-option value="license">许可证</a-select-option>
            <a-select-option value="accessory">配件</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="资产ID" required><a-input v-model:value="form.item_id" /></a-form-item>
        <a-form-item label="持有人类型">
          <a-select v-model:value="form.owner_type" placeholder="请选择持有人类型" allow-clear>
            <a-select-option value="user">用户</a-select-option>
            <a-select-option value="location">位置</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="持有人ID"><a-input v-model:value="form.owner_id" /></a-form-item>
        <a-form-item label="数量"><a-input-number v-model:value="form.quantity" :min="1" style="width:100%" /></a-form-item>
        <a-form-item label="分配日期" required><a-input v-model:value="form.assign_date" type="date" /></a-form-item>
        <a-form-item label="预计归还"><a-input v-model:value="form.expected_return_date" type="date" /></a-form-item>
        <a-form-item label="备注"><a-textarea v-model:value="form.note" :rows="2" /></a-form-item>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { allocationApi, changeRecordApi } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "资产类型", dataIndex: "item_type", key: "item_type" },
  { title: "持有人", dataIndex: "assignee_name", key: "assignee_name" },
  { title: "位置", dataIndex: "location_name", key: "location_name" },
  { title: "数量", dataIndex: "quantity", key: "quantity" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "分配日期", dataIndex: "assign_date", key: "assign_date" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await allocationApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "allocation", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = () => { isEdit.value = false; form.value = { quantity: 1, status: 'active' }; visible.value = true; };
const handleEdit = (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; visible.value = true; };
const handleDelete = async (id: string) => {
  await allocationApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await allocationApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

-          <a-select v-model:value="form.item_type" placeholder="请选择资产类型">

-            <a-select-option value="device">设备</a-select-option>

-            <a-select-option value="license">许可证</a-select-option>

-            <a-select-option value="accessory">配件</a-select-option>

+          <a-select v-model:value="form.item_type" placeholder="请选择资产类型" :options="itemTypeOptions" />


资产状态 这个编辑框是下拉选项，但是里面没内容


        <a-form-item label="持有人类型">
          <a-select v-model:value="form.owner_type" placeholder="请选择持有人类型" :options="ownerTypeOptions" allow-clear />
        </a-form-item>

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '资产分配' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:allocation:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增分配</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'active' ? 'green' : record.status === 'returned' ? 'blue' : 'default'">{{ record.status === 'active' ? '使用中' : record.status === 'returned' ? '已归还' : record.status }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:allocation:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:allocation:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑分配' : '新增分配'" @ok="handleSubmit" width="600px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-form-item label="资产类型" required>
          <a-select v-model:value="form.item_type" placeholder="请选择资产类型" :options="itemTypeOptions" />
        </a-form-item>
        <a-form-item label="资产ID" required><a-input v-model:value="form.item_id" /></a-form-item>
        <a-form-item label="持有人类型">
          <a-select v-model:value="form.owner_type" placeholder="请选择持有人类型" allow-clear>
            <a-select-option value="user">用户</a-select-option>
            <a-select-option value="location">位置</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="持有人ID"><a-input v-model:value="form.owner_id" /></a-form-item>
        <a-form-item label="数量"><a-input-number v-model:value="form.quantity" :min="1" style="width:100%" /></a-form-item>
        <a-form-item label="分配日期" required><a-input v-model:value="form.assign_date" type="date" /></a-form-item>
        <a-form-item label="预计归还"><a-input v-model:value="form.expected_return_date" type="date" /></a-form-item>
        <a-form-item label="备注"><a-textarea v-model:value="form.note" :rows="2" /></a-form-item>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { allocationApi, changeRecordApi } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "资产类型", dataIndex: "item_type", key: "item_type" },
  { title: "持有人", dataIndex: "assignee_name", key: "assignee_name" },
  { title: "位置", dataIndex: "location_name", key: "location_name" },
  { title: "数量", dataIndex: "quantity", key: "quantity" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "分配日期", dataIndex: "assign_date", key: "assign_date" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await allocationApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "allocation", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = () => { isEdit.value = false; form.value = { quantity: 1, status: 'active' }; visible.value = true; };
const handleEdit = (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; visible.value = true; };
const handleDelete = async (id: string) => {
  await allocationApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await allocationApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

-          <a-select v-model:value="form.owner_type" placeholder="请选择持有人类型" allow-clear>

-            <a-select-option value="user">用户</a-select-option>

-            <a-select-option value="location">位置</a-select-option>

+          <a-select v-model:value="form.owner_type" placeholder="请选择持有人类型" :options="ownerTypeOptions" allow-clear />


The file c:\Workspace\Project\tansci\antdv-next-admin\src\views\asset\biz\failure\index.vue has been updated successfully. (file state is current in your context — no need to Read it back)

          <a-col :span="12"><a-form-item label="关联类型">
            <a-select v-model:value="form.target_type" placeholder="请选择关联类型" :options="targetTypeOptions" />
          </a-form-item></a-col>

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '故障报修' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:failure:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增故障</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'open' ? 'red' : record.status === 'in_progress' ? 'orange' : record.status === 'resolved' ? 'blue' : 'green'">{{ record.status === 'open' ? '待处理' : record.status === 'in_progress' ? '处理中' : record.status === 'resolved' ? '已修复' : '已关闭' }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:failure:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:failure:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑故障' : '新增故障'" @ok="handleSubmit" width="700px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-row :gutter="16">
          <a-col :span="12"><a-form-item label="故障名称" required><a-input v-model:value="form.failure_name" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="关联类型">
            <a-select v-model:value="form.target_type" placeholder="请选择关联类型">
              <a-select-option value="device">设备</a-select-option>
              <a-select-option value="license">许可证</a-select-option>
              <a-select-option value="accessory">配件</a-select-option>
            </a-select>
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="关联资产ID"><a-input v-model:value="form.target_id" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="故障日期" required><a-input v-model:value="form.failure_date" type="date" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="状态">
            <a-select v-model:value="form.status">
              <a-select-option value="open">待处理</a-select-option>
              <a-select-option value="in_progress">处理中</a-select-option>
              <a-select-option value="resolved">已修复</a-select-option>
              <a-select-option value="closed">已关闭</a-select-option>
            </a-select>
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="报告人">
            <a-select v-model:value="form.reported_by" show-search placeholder="请选择报告人" option-filter-prop="label" :options="userOptions" allow-clear />
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="解决人">
            <a-select v-model:value="form.resolved_by" show-search placeholder="请选择解决人" option-filter-prop="label" :options="userOptions" allow-clear />
          </a-form-item></a-col>
          <a-col :span="24"><a-form-item label="故障描述" :label-col="{ span: 3 }"><a-textarea v-model:value="form.failure_description" :rows="3" /></a-form-item></a-col>
          <a-col :span="24"><a-form-item label="备注" :label-col="{ span: 3 }"><a-textarea v-model:value="form.notes" :rows="2" /></a-form-item></a-col>
        </a-row>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { failureApi, changeRecordApi, getUserList } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const userOptions = ref<{ label: string; value: string }[]>([]);

const loadOptions = async () => {
  try {
    const userRes: any = await getUserList();
    userOptions.value = ((userRes.data || userRes)?.list || []).map((u: any) => ({ label: u.nick_name || u.user_name, value: u.id }));
  } catch { /* ignore */ }
};

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "故障名称", dataIndex: "failure_name", key: "failure_name", search: true, searchType: "input" },
  { title: "关联类型", dataIndex: "target_type", key: "target_type" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "报告人", dataIndex: "reported_user_name", key: "reported_user_name" },
  { title: "解决人", dataIndex: "resolved_user_name", key: "resolved_user_name" },
  { title: "故障日期", dataIndex: "failure_date", key: "failure_date" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await failureApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "failure", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = async () => { isEdit.value = false; form.value = { status: 'open' }; await loadOptions(); visible.value = true; };
const handleEdit = async (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; await loadOptions(); visible.value = true; };
const handleDelete = async (id: string) => {
  await failureApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await failureApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

-            <a-select v-model:value="form.target_type" placeholder="请选择关联类型">

-              <a-select-option value="device">设备</a-select-option>

-              <a-select-option value="license">许可证</a-select-option>

-              <a-select-option value="accessory">配件</a-select-option>

+            <a-select v-model:value="form.target_type" placeholder="请选择关联类型" :options="targetTypeOptions" />


          <a-col :span="12"><a-form-item label="状态">
            <a-select v-model:value="form.status" :options="failureStatusOptions" />
          </a-form-item></a-col>

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '故障报修' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:failure:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增故障</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'open' ? 'red' : record.status === 'in_progress' ? 'orange' : record.status === 'resolved' ? 'blue' : 'green'">{{ record.status === 'open' ? '待处理' : record.status === 'in_progress' ? '处理中' : record.status === 'resolved' ? '已修复' : '已关闭' }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:failure:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:failure:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑故障' : '新增故障'" @ok="handleSubmit" width="700px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-row :gutter="16">
          <a-col :span="12"><a-form-item label="故障名称" required><a-input v-model:value="form.failure_name" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="关联类型">
            <a-select v-model:value="form.target_type" placeholder="请选择关联类型" :options="targetTypeOptions" />
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="关联资产ID"><a-input v-model:value="form.target_id" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="故障日期" required><a-input v-model:value="form.failure_date" type="date" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="状态">
            <a-select v-model:value="form.status">
              <a-select-option value="open">待处理</a-select-option>
              <a-select-option value="in_progress">处理中</a-select-option>
              <a-select-option value="resolved">已修复</a-select-option>
              <a-select-option value="closed">已关闭</a-select-option>
            </a-select>
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="报告人">
            <a-select v-model:value="form.reported_by" show-search placeholder="请选择报告人" option-filter-prop="label" :options="userOptions" allow-clear />
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="解决人">
            <a-select v-model:value="form.resolved_by" show-search placeholder="请选择解决人" option-filter-prop="label" :options="userOptions" allow-clear />
          </a-form-item></a-col>
          <a-col :span="24"><a-form-item label="故障描述" :label-col="{ span: 3 }"><a-textarea v-model:value="form.failure_description" :rows="3" /></a-form-item></a-col>
          <a-col :span="24"><a-form-item label="备注" :label-col="{ span: 3 }"><a-textarea v-model:value="form.notes" :rows="2" /></a-form-item></a-col>
        </a-row>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { failureApi, changeRecordApi, getUserList } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const userOptions = ref<{ label: string; value: string }[]>([]);

const loadOptions = async () => {
  try {
    const userRes: any = await getUserList();
    userOptions.value = ((userRes.data || userRes)?.list || []).map((u: any) => ({ label: u.nick_name || u.user_name, value: u.id }));
  } catch { /* ignore */ }
};

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "故障名称", dataIndex: "failure_name", key: "failure_name", search: true, searchType: "input" },
  { title: "关联类型", dataIndex: "target_type", key: "target_type" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "报告人", dataIndex: "reported_user_name", key: "reported_user_name" },
  { title: "解决人", dataIndex: "resolved_user_name", key: "resolved_user_name" },
  { title: "故障日期", dataIndex: "failure_date", key: "failure_date" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await failureApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "failure", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = async () => { isEdit.value = false; form.value = { status: 'open' }; await loadOptions(); visible.value = true; };
const handleEdit = async (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; await loadOptions(); visible.value = true; };
const handleDelete = async (id: string) => {
  await failureApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await failureApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

-            <a-select v-model:value="form.status">

-              <a-select-option value="open">待处理</a-select-option>

-              <a-select-option value="in_progress">处理中</a-select-option>

-              <a-select-option value="resolved">已修复</a-select-option>

-              <a-select-option value="closed">已关闭</a-select-option>

+            <a-select v-model:value="form.status" :options="failureStatusOptions" />


The file c:\Workspace\Project\tansci\antdv-next-admin\src\views\asset\biz\request\index.vue has been updated successfully. (file state is current in your context — no need to Read it back)

        <a-form-item label="状态">
          <a-select v-model:value="form.status" :options="requestStatusOptions" />
        </a-form-item>

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '资产申请' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:request:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增申请</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'pending' ? 'orange' : record.status === 'approved' ? 'green' : record.status === 'rejected' ? 'red' : 'default'">{{ record.status === 'pending' ? '待审批' : record.status === 'approved' ? '已批准' : record.status === 'rejected' ? '已拒绝' : '已取消' }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:request:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:request:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑申请' : '新增申请'" @ok="handleSubmit" width="600px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-form-item label="申请单号"><a-input v-model:value="form.request_no" disabled /></a-form-item>
        <a-form-item label="申请人">
          <a-select v-model:value="form.user_id" show-search placeholder="请选择申请人" option-filter-prop="label" :options="userOptions" allow-clear />
        </a-form-item>
        <a-form-item label="资产类型"><a-input v-model:value="form.item_type" /></a-form-item>
        <a-form-item label="分类">
          <a-select v-model:value="form.category_id" show-search placeholder="请选择分类" option-filter-prop="label" :options="categoryOptions" allow-clear />
        </a-form-item>
        <a-form-item label="数量"><a-input-number v-model:value="form.quantity" :min="1" style="width:100%" /></a-form-item>
        <a-form-item label="申请原因"><a-textarea v-model:value="form.reason" :rows="2" /></a-form-item>
        <a-form-item label="状态">
          <a-select v-model:value="form.status">
            <a-select-option value="pending">待审批</a-select-option>
            <a-select-option value="approved">已批准</a-select-option>
            <a-select-option value="rejected">已拒绝</a-select-option>
            <a-select-option value="cancelled">已取消</a-select-option>
          </a-select>
        </a-form-item>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { requestApi, changeRecordApi, getCategoryList, getUserList } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const userOptions = ref<{ label: string; value: string }[]>([]);
const categoryOptions = ref<{ label: string; value: string }[]>([]);

const loadOptions = async () => {
  try {
    const [catRes, userRes]: any[] = await Promise.all([
      getCategoryList(),
      getUserList(),
    ]);
    const extractData = (res: any) => (res.data || res) as any[];
    categoryOptions.value = (extractData(catRes) || []).map((c: any) => ({ label: c.name + ' [' + c.code + ']', value: c.id }));
    userOptions.value = ((userRes.data || userRes)?.list || []).map((u: any) => ({ label: u.nick_name || u.user_name, value: u.id }));
  } catch { /* ignore */ }
};

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "申请单号", dataIndex: "request_no", key: "request_no", search: true, searchType: "input" },
  { title: "申请人", dataIndex: "user_name", key: "user_name" },
  { title: "资产类型", dataIndex: "item_type", key: "item_type" },
  { title: "分类", dataIndex: "category_name", key: "category_name" },
  { title: "数量", dataIndex: "quantity", key: "quantity" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "审批人", dataIndex: "approver_name", key: "approver_name" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await requestApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "asset_request", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = async () => { isEdit.value = false; form.value = { quantity: 1, status: 'pending' }; await loadOptions(); visible.value = true; };
const handleEdit = async (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; await loadOptions(); visible.value = true; };
const handleDelete = async (id: string) => {
  await requestApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await requestApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

-          <a-select v-model:value="form.status">

-            <a-select-option value="pending">待审批</a-select-option>

-            <a-select-option value="approved">已批准</a-select-option>

-            <a-select-option value="rejected">已拒绝</a-select-option>

-            <a-select-option value="cancelled">已取消</a-select-option>

+          <a-select v-model:value="form.status" :options="requestStatusOptions" />


The file c:\Workspace\Project\tansci\antdv-next-admin\src\views\asset\biz\stocktake\index.vue has been updated successfully. (file state is current in your context — no need to Read it back)

        <a-form-item label="状态">
          <a-select v-model:value="form.status" :options="stocktakeStatusOptions" />
        </a-form-item>

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '盘点管理' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:stocktake:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增盘点</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'planning' ? 'blue' : record.status === 'in_progress' ? 'orange' : 'green'">{{ record.status === 'planning' ? '计划中' : record.status === 'in_progress' ? '执行中' : '已完成' }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:stocktake:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:stocktake:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑盘点' : '新增盘点'" @ok="handleSubmit" width="600px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-form-item label="盘点名称" required><a-input v-model:value="form.name" /></a-form-item>
        <a-form-item label="状态">
          <a-select v-model:value="form.status">
            <a-select-option value="planning">计划中</a-select-option>
            <a-select-option value="in_progress">执行中</a-select-option>
            <a-select-option value="completed">已完成</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="负责人">
          <a-select v-model:value="form.manager_id" show-search placeholder="请选择负责人" option-filter-prop="label" :options="userOptions" allow-clear />
        </a-form-item>
        <a-form-item label="位置">
          <a-select v-model:value="form.location_id" show-search placeholder="请选择位置" option-filter-prop="label" :options="locationOptions" allow-clear />
        </a-form-item>
        <a-form-item label="分类">
          <a-select v-model:value="form.category_id" show-search placeholder="请选择分类" option-filter-prop="label" :options="categoryOptions" allow-clear />
        </a-form-item>
        <a-form-item label="开始日期"><a-input v-model:value="form.start_date" type="date" /></a-form-item>
        <a-form-item label="结束日期"><a-input v-model:value="form.end_date" type="date" /></a-form-item>
        <a-form-item label="备注"><a-textarea v-model:value="form.note" :rows="2" /></a-form-item>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { stocktakeApi, changeRecordApi, getCategoryList, getLocationList, getUserList } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const userOptions = ref<{ label: string; value: string }[]>([]);
const locationOptions = ref<{ label: string; value: string }[]>([]);
const categoryOptions = ref<{ label: string; value: string }[]>([]);

const loadOptions = async () => {
  try {
    const [locRes, catRes, userRes]: any[] = await Promise.all([
      getLocationList(),
      getCategoryList(),
      getUserList(),
    ]);
    const extractData = (res: any) => (res.data || res) as any[];
    locationOptions.value = (extractData(locRes) || []).map((l: any) => ({ label: (l.building ? l.building + ' / ' : '') + l.name, value: l.id }));
    categoryOptions.value = (extractData(catRes) || []).map((c: any) => ({ label: c.name + ' [' + c.code + ']', value: c.id }));
    userOptions.value = ((userRes.data || userRes)?.list || []).map((u: any) => ({ label: u.nick_name || u.user_name, value: u.id }));
  } catch { /* ignore */ }
};

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "盘点名称", dataIndex: "name", key: "name", search: true, searchType: "input" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "负责人", dataIndex: "manager_name", key: "manager_name" },
  { title: "开始日期", dataIndex: "start_date", key: "start_date" },
  { title: "结束日期", dataIndex: "end_date", key: "end_date" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await stocktakeApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "stocktake", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = async () => { isEdit.value = false; form.value = { status: 'planning' }; await loadOptions(); visible.value = true; };
const handleEdit = async (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; await loadOptions(); visible.value = true; };
const handleDelete = async (id: string) => {
  await stocktakeApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await stocktakeApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

-            <a-select-option value="planning">计划中</a-select-option>

-            <a-select-option value="in_progress">执行中</a-select-option>

-            <a-select-option value="completed">已完成</a-select-option>

+          <a-select v-model:value="form.status" :options="stocktakeStatusOptions" />


The file c:\Workspace\Project\tansci\antdv-next-admin\src\views\asset\depreciation\index.vue has been updated successfully. (file state is current in your context — no need to Read it back)

        <a-form-item label="状态">
          <a-select v-model:value="form.status">
            <a-select-option :value="1">启用</a-select-option>
            <a-select-option :value="0">停用</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="状态">
          <a-select v-model:value="form.status" :options="depreciationStatusOptions" />
        </a-form-item>

<template>

    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '折旧规则管理' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <PlusOutlined /> 新增规则
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          {{ record.status === 1 ? '启用' : '停用' }}
        </template>
        <template v-if="column.key === 'floor_type'">
          {{ record.floor_type === 'amount' ? '固定金额' : '百分比' }}
        </template>
        <template v-if="column.key === 'operations'">

            <EditOutlined /> 编辑

              <DeleteOutlined /> 删除

        </template>
      </template>
    </ProTable>

            启用
            停用

            固定金额
            百分比(%)

        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            {{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}
          </template>
        </template>

</template>

<a-form-item label="规则名称" required><a-input v-model:value="form.name" /></a-form-item>

-            <a-select-option :value="1">启用</a-select-option>

-            <a-select-option :value="0">停用</a-select-option>

+          <a-select v-model:value="form.status" :options="depreciationStatusOptions" />

<a-form-item label="折旧月数" required><a-input-number v-model:value="form.months" :min="1" style="width:100%" /></a-form-item>


        <a-form-item label="残值类型">
          <a-select v-model:value="form.floor_type">
            <a-select-option value="amount">固定金额</a-select-option>
            <a-select-option value="percent">百分比(%)</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="残值类型">
          <a-select v-model:value="form.floor_type" :options="floorTypeOptions" />
        </a-form-item>

<template>

    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '折旧规则管理' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <PlusOutlined /> 新增规则
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          {{ record.status === 1 ? '启用' : '停用' }}
        </template>
        <template v-if="column.key === 'floor_type'">
          {{ record.floor_type === 'amount' ? '固定金额' : '百分比' }}
        </template>
        <template v-if="column.key === 'operations'">

            <EditOutlined /> 编辑

              <DeleteOutlined /> 删除

        </template>
      </template>
    </ProTable>

            固定金额
            百分比(%)

        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            {{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}
          </template>
        </template>

</template>

-          <a-select v-model:value="form.floor_type">

-            <a-select-option value="amount">固定金额</a-select-option>

-            <a-select-option value="percent">百分比(%)</a-select-option>

+          <a-select v-model:value="form.floor_type" :options="floorTypeOptions" />

<a-form-item label="残值"><a-input-number v-model:value="form.floor_val" style="width:100%" /></a-form-item>

<a-form-item label="备注"><a-textarea v-model:value="form.remark" :rows="2" /></a-form-item>


The file c:\Workspace\Project\tansci\antdv-next-admin\src\views\asset\base\category\index.vue has been updated successfully. (file state is current in your context — no need to Read it back)

        <a-form-item label="分类大类" required>
          <a-select v-model:value="form.category_type" :options="categoryTypeOptions" />
        </a-form-item>

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '资产分类' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'base:category:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增分类</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'category_type'">
          <a-tag>{{ record.category_type }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'base:category:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'base:category:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑分类' : '新增分类'" @ok="handleSubmit" width="600px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-form-item label="分类名称" required><a-input v-model:value="form.name" /></a-form-item>
        <a-form-item label="分类编码" required><a-input v-model:value="form.code" /></a-form-item>
        <a-form-item label="分类大类" required>
          <a-select v-model:value="form.category_type">
            <a-select-option value="device">设备</a-select-option>
            <a-select-option value="license">许可证</a-select-option>
            <a-select-option value="accessory">配件</a-select-option>
            <a-select-option value="consumable">耗材</a-select-option>
            <a-select-option value="service">服务</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="父级分类">
          <a-select v-model:value="form.parent_id" show-search placeholder="留空为顶级分类" option-filter-prop="label" :options="parentOptions" allow-clear />
        </a-form-item>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { categoryApi, changeRecordApi, getCategoryList } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const parentOptions = ref<{ label: string; value: string }[]>([]);

const loadOptions = async () => {
  try {
    const res: any = await getCategoryList();
    const data = (res.data || res) as any[];
    parentOptions.value = (data || []).map((c: any) => ({ label: c.name + ' [' + c.code + ']', value: c.id }));
  } catch { /* ignore */ }
};

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "分类名称", dataIndex: "name", key: "name", search: true, searchType: "input" },
  { title: "分类编码", dataIndex: "code", key: "code" },
  { title: "分类大类", dataIndex: "category_type", key: "category_type" },
  { title: "父级ID", dataIndex: "parent_id", key: "parent_id", ellipsis: true },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await categoryApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "category", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = async () => { isEdit.value = false; form.value = {}; await loadOptions(); visible.value = true; };
const handleEdit = async (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; await loadOptions(); visible.value = true; };
const handleDelete = async (id: string) => {
  await categoryApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await categoryApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

-          <a-select v-model:value="form.category_type">

-            <a-select-option value="device">设备</a-select-option>

-            <a-select-option value="license">许可证</a-select-option>

-            <a-select-option value="accessory">配件</a-select-option>

-            <a-select-option value="consumable">耗材</a-select-option>

-            <a-select-option value="service">服务</a-select-option>

+          <a-select v-model:value="form.category_type" :options="categoryTypeOptions" />


Good, all template edits are done. Now I need to add the options arrays to the script sections of each file. Let me do them in parallel.

1. **offering/index.vue**: add `offeringStatusOptions`
2. **allocation/index.vue**: add `itemTypeOptions`, `ownerTypeOptions`
3. **failure/index.vue**: add `targetTypeOptions`, `failureStatusOptions`
4. **request/index.vue**: add `requestStatusOptions`
5. **stocktake/index.vue**: add `stocktakeStatusOptions`
6. **depreciation/index.vue**: add `depreciationStatusOptions`, `floorTypeOptions`
7. **category/index.vue**: add `categoryTypeOptions`


现在给每个文件的 script 添加对应的选项数组。


const supplierOptions = ref<{ label: string; value: string }[]>([]);
const userOptions = ref<{ label: string; value: string }[]>([]);

const supplierOptions = ref<{ label: string; value: string }[]>([]);
const userOptions = ref<{ label: string; value: string }[]>([]);
const offeringStatusOptions = [
  { label: '生效中', value: 'active' },
  { label: '已过期', value: 'expired' },
  { label: '已取消', value: 'cancelled' },
];


const form = ref<Record<string, unknown>>({});

const logVisible = ref(false);

const form = ref<Record<string, unknown>>({});

const itemTypeOptions = [
  { label: '设备', value: 'device' },
  { label: '许可证', value: 'license' },
  { label: '配件', value: 'accessory' },
];
const ownerTypeOptions = [
  { label: '用户', value: 'user' },
  { label: '位置', value: 'location' },
];

const logVisible = ref(false);


const userOptions = ref<{ label: string; value: string }[]>([]);

const userOptions = ref<{ label: string; value: string }[]>([]);
const targetTypeOptions = [
  { label: '设备', value: 'device' },
  { label: '许可证', value: 'license' },
  { label: '配件', value: 'accessory' },
];
const failureStatusOptions = [
  { label: '待处理', value: 'open' },
  { label: '处理中', value: 'in_progress' },
  { label: '已修复', value: 'resolved' },
  { label: '已关闭', value: 'closed' },
];


const categoryOptions = ref<{ label: string; value: string }[]>([]);

const categoryOptions = ref<{ label: string; value: string }[]>([]);
const requestStatusOptions = [
  { label: '待审批', value: 'pending' },
  { label: '已批准', value: 'approved' },
  { label: '已拒绝', value: 'rejected' },
  { label: '已取消', value: 'cancelled' },
];


const categoryOptions = ref<{ label: string; value: string }[]>([]);

const categoryOptions = ref<{ label: string; value: string }[]>([]);
const stocktakeStatusOptions = [
  { label: '计划中', value: 'planning' },
  { label: '执行中', value: 'in_progress' },
  { label: '已完成', value: 'completed' },
];


const form = ref<Record<string, unknown>>({});

const logVisible = ref(false);

const form = ref<Record<string, unknown>>({});

const depreciationStatusOptions = [
  { label: '启用', value: 1 },
  { label: '停用', value: 0 },
];
const floorTypeOptions = [
  { label: '固定金额', value: 'amount' },
  { label: '百分比(%)', value: 'percent' },
];

const logVisible = ref(false);


const parentOptions = ref<{ label: string; value: string }[]>([]);

const parentOptions = ref<{ label: string; value: string }[]>([]);
const categoryTypeOptions = [
  { label: '设备', value: 'device' },
  { label: '许可证', value: 'license' },
  { label: '配件', value: 'accessory' },
  { label: '耗材', value: 'consumable' },
  { label: '服务', value: 'service' },
];


const supplierOptions = ref<{ label: string; value: string }[]>([]);
const userOptions = ref<{ label: string; value: string }[]>([]);
const offeringStatusOptions = [
  { label: '生效中', value: 'active' },
  { label: '已过期', value: 'expired' },
  { label: '已取消', value: 'cancelled' },
];

<template>

    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '服务管理' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <PlusOutlined /> 新增服务
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'assigned_user_name'">
          {{ record.assigned_user_name }}
          未分配
        </template>
        <template v-if="column.key === 'offering_status'">
          {{ record.offering_status === 'active' ? '生效中' : record.offering_status }}
        </template>
        <template v-if="column.key === 'operations'">

            <EditOutlined /> 编辑

              <DeleteOutlined /> 删除

        </template>
      </template>
    </ProTable>

        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            {{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}
          </template>
        </template>

</template>

+  { label: '已取消', value: 'cancelled' },


const form = ref<Record<string, unknown>>({});

const itemTypeOptions = [
  { label: '设备', value: 'device' },
  { label: '许可证', value: 'license' },
  { label: '配件', value: 'accessory' },
];
const ownerTypeOptions = [
  { label: '用户', value: 'user' },
  { label: '位置', value: 'location' },
];

const logVisible = ref(false);

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '资产分配' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:allocation:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增分配</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'active' ? 'green' : record.status === 'returned' ? 'blue' : 'default'">{{ record.status === 'active' ? '使用中' : record.status === 'returned' ? '已归还' : record.status }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:allocation:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:allocation:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑分配' : '新增分配'" @ok="handleSubmit" width="600px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-form-item label="资产类型" required>
          <a-select v-model:value="form.item_type" placeholder="请选择资产类型" :options="itemTypeOptions" />
        </a-form-item>
        <a-form-item label="资产ID" required><a-input v-model:value="form.item_id" /></a-form-item>
        <a-form-item label="持有人类型">
          <a-select v-model:value="form.owner_type" placeholder="请选择持有人类型" :options="ownerTypeOptions" allow-clear />
        </a-form-item>
        <a-form-item label="持有人ID"><a-input v-model:value="form.owner_id" /></a-form-item>
        <a-form-item label="数量"><a-input-number v-model:value="form.quantity" :min="1" style="width:100%" /></a-form-item>
        <a-form-item label="分配日期" required><a-input v-model:value="form.assign_date" type="date" /></a-form-item>
        <a-form-item label="预计归还"><a-input v-model:value="form.expected_return_date" type="date" /></a-form-item>
        <a-form-item label="备注"><a-textarea v-model:value="form.note" :rows="2" /></a-form-item>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { allocationApi, changeRecordApi } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "资产类型", dataIndex: "item_type", key: "item_type" },
  { title: "持有人", dataIndex: "assignee_name", key: "assignee_name" },
  { title: "位置", dataIndex: "location_name", key: "location_name" },
  { title: "数量", dataIndex: "quantity", key: "quantity" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "分配日期", dataIndex: "assign_date", key: "assign_date" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await allocationApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "allocation", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = () => { isEdit.value = false; form.value = { quantity: 1, status: 'active' }; visible.value = true; };
const handleEdit = (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; visible.value = true; };
const handleDelete = async (id: string) => {
  await allocationApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await allocationApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>


const userOptions = ref<{ label: string; value: string }[]>([]);
const targetTypeOptions = [
  { label: '设备', value: 'device' },
  { label: '许可证', value: 'license' },
  { label: '配件', value: 'accessory' },
];
const failureStatusOptions = [
  { label: '待处理', value: 'open' },
  { label: '处理中', value: 'in_progress' },
  { label: '已修复', value: 'resolved' },
  { label: '已关闭', value: 'closed' },
];

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '故障报修' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:failure:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增故障</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'open' ? 'red' : record.status === 'in_progress' ? 'orange' : record.status === 'resolved' ? 'blue' : 'green'">{{ record.status === 'open' ? '待处理' : record.status === 'in_progress' ? '处理中' : record.status === 'resolved' ? '已修复' : '已关闭' }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:failure:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:failure:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑故障' : '新增故障'" @ok="handleSubmit" width="700px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-row :gutter="16">
          <a-col :span="12"><a-form-item label="故障名称" required><a-input v-model:value="form.failure_name" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="关联类型">
            <a-select v-model:value="form.target_type" placeholder="请选择关联类型" :options="targetTypeOptions" />
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="关联资产ID"><a-input v-model:value="form.target_id" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="故障日期" required><a-input v-model:value="form.failure_date" type="date" /></a-form-item></a-col>
          <a-col :span="12"><a-form-item label="状态">
            <a-select v-model:value="form.status" :options="failureStatusOptions" />
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="报告人">
            <a-select v-model:value="form.reported_by" show-search placeholder="请选择报告人" option-filter-prop="label" :options="userOptions" allow-clear />
          </a-form-item></a-col>
          <a-col :span="12"><a-form-item label="解决人">
            <a-select v-model:value="form.resolved_by" show-search placeholder="请选择解决人" option-filter-prop="label" :options="userOptions" allow-clear />
          </a-form-item></a-col>
          <a-col :span="24"><a-form-item label="故障描述" :label-col="{ span: 3 }"><a-textarea v-model:value="form.failure_description" :rows="3" /></a-form-item></a-col>
          <a-col :span="24"><a-form-item label="备注" :label-col="{ span: 3 }"><a-textarea v-model:value="form.notes" :rows="2" /></a-form-item></a-col>
        </a-row>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { failureApi, changeRecordApi, getUserList } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const userOptions = ref<{ label: string; value: string }[]>([]);

const loadOptions = async () => {
  try {
    const userRes: any = await getUserList();
    userOptions.value = ((userRes.data || userRes)?.list || []).map((u: any) => ({ label: u.nick_name || u.user_name, value: u.id }));
  } catch { /* ignore */ }
};

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "故障名称", dataIndex: "failure_name", key: "failure_name", search: true, searchType: "input" },
  { title: "关联类型", dataIndex: "target_type", key: "target_type" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "报告人", dataIndex: "reported_user_name", key: "reported_user_name" },
  { title: "解决人", dataIndex: "resolved_user_name", key: "resolved_user_name" },
  { title: "故障日期", dataIndex: "failure_date", key: "failure_date" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await failureApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "failure", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = async () => { isEdit.value = false; form.value = { status: 'open' }; await loadOptions(); visible.value = true; };
const handleEdit = async (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; await loadOptions(); visible.value = true; };
const handleDelete = async (id: string) => {
  await failureApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await failureApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

+  { label: '处理中', value: 'in_progress' },


const categoryOptions = ref<{ label: string; value: string }[]>([]);
const requestStatusOptions = [
  { label: '待审批', value: 'pending' },
  { label: '已批准', value: 'approved' },
  { label: '已拒绝', value: 'rejected' },
  { label: '已取消', value: 'cancelled' },
];

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '资产申请' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:request:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增申请</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'pending' ? 'orange' : record.status === 'approved' ? 'green' : record.status === 'rejected' ? 'red' : 'default'">{{ record.status === 'pending' ? '待审批' : record.status === 'approved' ? '已批准' : record.status === 'rejected' ? '已拒绝' : '已取消' }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:request:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:request:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑申请' : '新增申请'" @ok="handleSubmit" width="600px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-form-item label="申请单号"><a-input v-model:value="form.request_no" disabled /></a-form-item>
        <a-form-item label="申请人">
          <a-select v-model:value="form.user_id" show-search placeholder="请选择申请人" option-filter-prop="label" :options="userOptions" allow-clear />
        </a-form-item>
        <a-form-item label="资产类型"><a-input v-model:value="form.item_type" /></a-form-item>
        <a-form-item label="分类">
          <a-select v-model:value="form.category_id" show-search placeholder="请选择分类" option-filter-prop="label" :options="categoryOptions" allow-clear />
        </a-form-item>
        <a-form-item label="数量"><a-input-number v-model:value="form.quantity" :min="1" style="width:100%" /></a-form-item>
        <a-form-item label="申请原因"><a-textarea v-model:value="form.reason" :rows="2" /></a-form-item>
        <a-form-item label="状态">
          <a-select v-model:value="form.status" :options="requestStatusOptions" />
        </a-form-item>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { requestApi, changeRecordApi, getCategoryList, getUserList } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const userOptions = ref<{ label: string; value: string }[]>([]);
const categoryOptions = ref<{ label: string; value: string }[]>([]);

const loadOptions = async () => {
  try {
    const [catRes, userRes]: any[] = await Promise.all([
      getCategoryList(),
      getUserList(),
    ]);
    const extractData = (res: any) => (res.data || res) as any[];
    categoryOptions.value = (extractData(catRes) || []).map((c: any) => ({ label: c.name + ' [' + c.code + ']', value: c.id }));
    userOptions.value = ((userRes.data || userRes)?.list || []).map((u: any) => ({ label: u.nick_name || u.user_name, value: u.id }));
  } catch { /* ignore */ }
};

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "申请单号", dataIndex: "request_no", key: "request_no", search: true, searchType: "input" },
  { title: "申请人", dataIndex: "user_name", key: "user_name" },
  { title: "资产类型", dataIndex: "item_type", key: "item_type" },
  { title: "分类", dataIndex: "category_name", key: "category_name" },
  { title: "数量", dataIndex: "quantity", key: "quantity" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "审批人", dataIndex: "approver_name", key: "approver_name" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await requestApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "asset_request", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = async () => { isEdit.value = false; form.value = { quantity: 1, status: 'pending' }; await loadOptions(); visible.value = true; };
const handleEdit = async (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; await loadOptions(); visible.value = true; };
const handleDelete = async (id: string) => {
  await requestApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await requestApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>


const categoryOptions = ref<{ label: string; value: string }[]>([]);
const stocktakeStatusOptions = [
  { label: '计划中', value: 'planning' },
  { label: '执行中', value: 'in_progress' },
  { label: '已完成', value: 'completed' },
];

<template>
  <div class="page-container">
    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '盘点管理' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <a-button v-permission="'biz:stocktake:add'" type="primary" @click="handleAdd"><PlusOutlined /> 新增盘点</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          <a-tag :color="record.status === 'planning' ? 'blue' : record.status === 'in_progress' ? 'orange' : 'green'">{{ record.status === 'planning' ? '计划中' : record.status === 'in_progress' ? '执行中' : '已完成' }}</a-tag>
        </template>
        <template v-if="column.key === 'operations'">
          <a-space :size="4" @click.stop>
            <a-button v-permission="'biz:stocktake:edit'" type="link" size="small" @click.stop="handleEdit(record)"><EditOutlined /> 编辑</a-button>
            <a-popconfirm v-permission="'biz:stocktake:delete'" title="确认删除？" @confirm="handleDelete(record.id)">
              <a-button type="link" size="small" danger @click.stop><DeleteOutlined /> 删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </template>
    </ProTable>

    <a-modal v-model:open="visible" :title="isEdit ? '编辑盘点' : '新增盘点'" @ok="handleSubmit" width="600px">
      <a-form :model="form" :label-col="{ span: 6 }">
        <a-form-item label="盘点名称" required><a-input v-model:value="form.name" /></a-form-item>
        <a-form-item label="状态">
          <a-select v-model:value="form.status" :options="stocktakeStatusOptions" />
        </a-form-item>
        <a-form-item label="负责人">
          <a-select v-model:value="form.manager_id" show-search placeholder="请选择负责人" option-filter-prop="label" :options="userOptions" allow-clear />
        </a-form-item>
        <a-form-item label="位置">
          <a-select v-model:value="form.location_id" show-search placeholder="请选择位置" option-filter-prop="label" :options="locationOptions" allow-clear />
        </a-form-item>
        <a-form-item label="分类">
          <a-select v-model:value="form.category_id" show-search placeholder="请选择分类" option-filter-prop="label" :options="categoryOptions" allow-clear />
        </a-form-item>
        <a-form-item label="开始日期"><a-input v-model:value="form.start_date" type="date" /></a-form-item>
        <a-form-item label="结束日期"><a-input v-model:value="form.end_date" type="date" /></a-form-item>
        <a-form-item label="备注"><a-textarea v-model:value="form.note" :rows="2" /></a-form-item>
      </a-form>
    </a-modal>

    <a-modal v-model:open="logVisible" title="变更记录" width="800px" :footer="null">
      <a-table :columns="logColumns" :data-source="logData" :pagination="false" size="small" row-key="id">
        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            <a-tag :color="row.change_type === 'create' ? 'green' : row.change_type === 'delete' ? 'red' : 'blue'">{{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}</a-tag>
          </template>
        </template>
      </a-table>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { PlusOutlined, EditOutlined, DeleteOutlined } from "@antdv-next/icons";
import { message } from "antdv-next";
import { ref } from "vue";
import { stocktakeApi, changeRecordApi, getCategoryList, getLocationList, getUserList } from "@/api/asset";
import ProTable from "@/components/Pro/ProTable/index.vue";
import type { ProTableColumn } from "@/types/pro";

const tableRef = ref();
const visible = ref(false); const isEdit = ref(false);
const form = ref<Record<string, unknown>>({});

const userOptions = ref<{ label: string; value: string }[]>([]);
const locationOptions = ref<{ label: string; value: string }[]>([]);
const categoryOptions = ref<{ label: string; value: string }[]>([]);

const loadOptions = async () => {
  try {
    const [locRes, catRes, userRes]: any[] = await Promise.all([
      getLocationList(),
      getCategoryList(),
      getUserList(),
    ]);
    const extractData = (res: any) => (res.data || res) as any[];
    locationOptions.value = (extractData(locRes) || []).map((l: any) => ({ label: (l.building ? l.building + ' / ' : '') + l.name, value: l.id }));
    categoryOptions.value = (extractData(catRes) || []).map((c: any) => ({ label: c.name + ' [' + c.code + ']', value: c.id }));
    userOptions.value = ((userRes.data || userRes)?.list || []).map((u: any) => ({ label: u.nick_name || u.user_name, value: u.id }));
  } catch { /* ignore */ }
};

const logVisible = ref(false);
const logData = ref<Record<string, unknown>[]>([]);
const logColumns = [
  { title: "时间", dataIndex: "create_time", key: "create_time", width: 170 },
  { title: "变更类型", dataIndex: "change_type", key: "change_type", width: 80 },
  { title: "变更字段", dataIndex: "field_name", key: "field_name", width: 120 },
  { title: "旧值", dataIndex: "old_value", key: "old_value", ellipsis: true },
  { title: "新值", dataIndex: "new_value", key: "new_value", ellipsis: true },
  { title: "操作人", dataIndex: "operator_name", key: "operator_name", width: 100 },
];

const columns: ProTableColumn[] = [
  { title: "盘点名称", dataIndex: "name", key: "name", search: true, searchType: "input" },
  { title: "状态", dataIndex: "status", key: "status" },
  { title: "负责人", dataIndex: "manager_name", key: "manager_name" },
  { title: "开始日期", dataIndex: "start_date", key: "start_date" },
  { title: "结束日期", dataIndex: "end_date", key: "end_date" },
  { title: "操作", dataIndex: "operations", key: "operations", width: 200, fixed: "right" as const },
];

const loadData = async (params: Record<string, unknown>) => {
  try {
    const res: any = await stocktakeApi.page({ page: params.current, pageSize: params.pageSize, keyword: params.keyword });
    const pageData = res.data || res;
    return { data: pageData.list || [], total: pageData.total || 0, success: true };
  } catch { return { data: [], total: 0, success: false }; }
};

const showChangeLog = async (record: Record<string, unknown>) => {
  try {
    const res: any = await changeRecordApi.page({ asset_type: "stocktake", asset_id: record.id, page: 1, pageSize: 200 });
    logData.value = (res.data || res).list || [];
    logVisible.value = true;
  } catch { message.error("获取变更记录失败"); }
};

const handleAdd = async () => { isEdit.value = false; form.value = { status: 'planning' }; await loadOptions(); visible.value = true; };
const handleEdit = async (r: Record<string, unknown>) => { isEdit.value = true; form.value = { ...r }; await loadOptions(); visible.value = true; };
const handleDelete = async (id: string) => {
  await stocktakeApi.del(id);
  message.success("删除成功");
  tableRef.value?.reload();
};
const handleSubmit = async () => {
  await stocktakeApi.save(form.value);
  message.success(isEdit.value ? "更新成功" : "创建成功");
  visible.value = false;
  tableRef.value?.reload();
};
</script>

+  { label: '执行中', value: 'in_progress' },

+  { label: '已完成', value: 'completed' },


const form = ref<Record<string, unknown>>({});

const depreciationStatusOptions = [
  { label: '启用', value: 1 },
  { label: '停用', value: 0 },
];
const floorTypeOptions = [
  { label: '固定金额', value: 'amount' },
  { label: '百分比(%)', value: 'percent' },
];

const logVisible = ref(false);

<template>

    <ProTable ref="tableRef" :columns="columns" :request="loadData" :toolbar="{ title: '折旧规则管理' }" :custom-row="(record: any) => ({ onClick: () => showChangeLog(record), style: { cursor: 'pointer' } })">
      <template #toolbar-actions>
        <PlusOutlined /> 新增规则
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'status'">
          {{ record.status === 1 ? '启用' : '停用' }}
        </template>
        <template v-if="column.key === 'floor_type'">
          {{ record.floor_type === 'amount' ? '固定金额' : '百分比' }}
        </template>
        <template v-if="column.key === 'operations'">

            <EditOutlined /> 编辑

              <DeleteOutlined /> 删除

        </template>
      </template>
    </ProTable>

        <template #bodyCell="{ column, record: row }">
          <template v-if="column.key === 'change_type'">
            {{ row.change_type === 'create' ? '新增' : row.change_type === 'delete' ? '删除' : '修改' }}
          </template>
        </template>

</template>

+  { label: '百分比(%)', value: 'percent' },


资产状态 这个编辑框是下拉选项，但是里面没内容