<template>
  <div>
    <el-descriptions :column="2" border>
      <el-descriptions-item label="部门">
        <!-- <TextTag :options="deptList" column="deptId" label="deptName" :value="form.deptId" /> -->
        {{form.deptName}}
      </el-descriptions-item>
      <el-descriptions-item label="角色">
        <!-- <TextTag :options="roleList" column="roleId" label="roleName" :value="form.roleId" /> -->
        {{form.roleName}}
      </el-descriptions-item>
      <!-- <el-descriptions-item label="创建者">{{ form.sparePartAccessId }}</el-descriptions-item> -->
      <el-descriptions-item label="创建时间">
        <span>{{ parseTime(form.createTime) }}</span>
      </el-descriptions-item>
      <el-descriptions-item label="状态" :span="2">
        <dict-tag :options="com_maintenance_record_state" :value="form.state" />
      </el-descriptions-item>
      <!-- <el-descriptions-item label="备注" :span="2">{{ form.remark }}</el-descriptions-item> -->
    </el-descriptions>
    <el-divider content-position="center">
      维保记录详情列表
    </el-divider>
    <Index :list="form.maintenanceRecordDetails" :editable="false" @update="handleUpdateMaintenanceRecord" />
  </div>
</template>

<script setup>
import Index from "@/components/MaintenanceRecordDetails/index";
import { listRole } from "@/api/system/role";
import { listDept } from "@/api/system/dept";
import { updateMaintenanceRecord } from "@/api/maintenanceRecord/maintenanceRecord";

const { proxy } = getCurrentInstance();
const { com_maintenance_record_state } = proxy.useDict(
  "com_maintenance_record_state"
);
const props = defineProps({
  form: {
    type: [Object],
    default: null,
  },
});
const { form } = toRefs(props);

const roleList = ref([]);
const deptList = ref([]);

function handleUpdateMaintenanceRecord() {
  // updateMaintenanceRecord(form.value).then(response => {
  //     proxy.$modal.msgSuccess("保存成功");
  // });
}

listDept({
  pageNum: 1,
  pageSize: 9999,
}).then((response) => {
  deptList.value = response.data;
});
listRole(
  proxy.addDateRange(
    {
      pageNum: 1,
      pageSize: 9999,
    },
    undefined
  )
).then((response) => {
  roleList.value = response.rows;
});
</script>