浏览代码

设备台账

lipenghui 5 月之前
父节点
当前提交
8c977bbc5c

+ 1 - 1
src/router/modules/remaining.ts

@@ -86,7 +86,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
           noCache: false,
           hidden: true,
           canTo: true,
-          icon: 'ep:edit',
+          icon: 'ep:add',
           title: '设备台账添加',
           activeMenu: '/device/base'
         }

+ 2 - 2
src/views/pms/device/CustomerList.vue

@@ -8,10 +8,10 @@
       :inline="true"
       label-width="68px"
     >
-      <el-form-item label="客商名称" prop="name">
+      <el-form-item label-width="90px" :label="customerType==='supplier'?'供应商名称':'制造商名称'" prop="name">
         <el-input
           v-model="queryParams.name"
-          placeholder="请输入客商名称"
+          placeholder="请输入名称"
           clearable
           @keyup.enter="handleQuery"
           class="!w-240px"

+ 301 - 176
src/views/pms/device/IotDeviceForm.vue

@@ -1,23 +1,13 @@
 <template>
   <ContentWrap v-loading="formLoading">
-    <el-form
-      ref="formRef"
-      :model="formData"
-      :rules="formRules"
-      label-width="100px"
-    >
-      <div style="margin-bottom: 20px;margin-top: 10px;margin-left: 15px">
-        <el-button @click="baseInfoClick" style="font-size: 18px;border:none">
-          <Icon
-            color="black"
-            icon="ep:expand"
-            :size="18"
-            class="cursor-pointer"
-          />
+    <el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px">
+      <div style="margin-bottom: 20px; margin-top: 10px; margin-left: 15px">
+        <el-button @click="baseInfoClick" style="font-size: 18px; border: none">
+          <Icon color="black" icon="ep:expand" :size="18" class="cursor-pointer" />
           基本信息
           <Icon
             color="black"
-            :icon="baseIsExpanded?'fa-solid:angle-double-down':'fa-solid:angle-double-right'"
+            :icon="baseIsExpanded ? 'fa-solid:angle-double-down' : 'fa-solid:angle-double-right'"
             :size="18"
             class="cursor-pointer"
           />
@@ -37,7 +27,12 @@
           </el-col>
           <el-col :span="6">
             <el-form-item label="品牌" prop="brand">
-              <el-select v-model="formData.brand" placeholder="请输入品牌" @click="openForm"/>
+              <el-select
+                v-model="formData.brand"
+                :model-value="brandLabel"
+                placeholder="请输入品牌"
+                @click="openForm"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -55,11 +50,24 @@
         </el-row>
         <el-row>
           <el-col :span="6">
-            <el-form-item label="设备状态">
+            <el-form-item label="资产类别" prop="assetClass">
+              <el-tree-select
+                v-model="formData.assetClass"
+                :data="productClassifyList"
+                :props="defaultProps"
+                check-strictly
+                node-key="id"
+                placeholder="请选择资产类别"
+                @change="assetclasschange"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="设备状态" prop="deviceStatus">
               <el-select v-model="formData.deviceStatus" placeholder="请选择">
                 <el-option
-                  v-for="dict in getIntDictOptions(DICT_TYPE.PMS_DEVICE_STATUS)"
-                  :key="dict.id"
+                  v-for="dict in getStrDictOptions(DICT_TYPE.PMS_DEVICE_STATUS)"
+                  :key="dict.label"
                   :label="dict.label"
                   :value="dict.value"
                 />
@@ -67,15 +75,10 @@
             </el-form-item>
           </el-col>
           <el-col :span="6">
-            <el-form-item label="规格型号" prop="model">
-              <el-input v-model="formData.model" placeholder="请输入规格型号" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="6">
-            <el-form-item label="资产性质">
+            <el-form-item label="资产性质" prop="deviceStatus">
               <el-select v-model="formData.assetProperty" placeholder="请选择">
                 <el-option
-                  v-for="dict in getIntDictOptions(DICT_TYPE.PMS_ASSET_PROPERTY)"
+                  v-for="dict in getStrDictOptions(DICT_TYPE.PMS_ASSET_PROPERTY)"
                   :key="dict.id"
                   :label="dict.label"
                   :value="dict.value"
@@ -83,6 +86,11 @@
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="6">
+            <el-form-item label="规格型号" prop="model">
+              <el-input v-model="formData.model" placeholder="请输入规格型号" />
+            </el-form-item>
+          </el-col>
         </el-row>
         <el-row>
           <el-col :span="6">
@@ -91,24 +99,19 @@
             </el-form-item>
           </el-col>
           <el-col :span="18">
-          <el-form-item label="备注" prop="remark">
-            <el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
-          </el-form-item>
+            <el-form-item label="备注" prop="remark">
+              <el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
+            </el-form-item>
           </el-col>
         </el-row>
       </div>
-      <div style="margin-bottom: 20px;margin-top: 10px;margin-left: 15px">
-        <el-button @click="zzInfoClick" style="font-size: 18px;border: none">
-          <Icon
-            color="black"
-            icon="ep:expand"
-            :size="18"
-            class="cursor-pointer"
-          />
+      <div style="margin-bottom: 20px; margin-top: 10px; margin-left: 15px">
+        <el-button @click="zzInfoClick" style="font-size: 18px; border: none">
+          <Icon color="black" icon="ep:expand" :size="18" class="cursor-pointer" />
           制造信息
           <Icon
             color="black"
-            :icon="zzIsExpanded?'fa-solid:angle-double-down':'fa-solid:angle-double-right'"
+            :icon="zzIsExpanded ? 'fa-solid:angle-double-down' : 'fa-solid:angle-double-right'"
             :size="18"
             class="cursor-pointer"
           />
@@ -118,11 +121,16 @@
         <el-row>
           <el-col :span="6">
             <el-form-item label="制造商" prop="manufacturerId">
-              <el-select v-model="formData.manufacturerId" placeholder="请输入制造商" @click="openCustomer('manufacturer')"/>
+              <el-select
+                v-model="formData.manufacturerId"
+                :model-value="zzLabel"
+                placeholder="请输入制造商"
+                @click="openCustomer('manufacturer')"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="6">
-            <el-form-item label="生产日期" prop="manDate" >
+            <el-form-item label="生产日期" prop="manDate">
               <el-date-picker
                 style="width: 150%"
                 v-model="formData.manDate"
@@ -134,7 +142,12 @@
           </el-col>
           <el-col :span="6">
             <el-form-item label="供应商" prop="supplierId">
-              <el-select v-model="formData.supplierId" placeholder="请输入供应商" @click="openCustomer('supplier')"/>
+              <el-select
+                v-model="formData.supplierId"
+                placeholder="请输入供应商"
+                :model-value="supplierLabel"
+                @click="openCustomer('supplier')"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -157,18 +170,13 @@
           </el-col>
         </el-row>
       </div>
-      <div style="margin-bottom: 20px;margin-top: 10px;margin-left: 15px">
-        <el-button @click="cwInfoClick" style=" font-size: 18px;border: none">
-          <Icon
-            color="black"
-            icon="ep:expand"
-            :size="18"
-            class="cursor-pointer"
-          />
+      <div style="margin-bottom: 20px; margin-top: 10px; margin-left: 15px">
+        <el-button @click="cwInfoClick" style="font-size: 18px; border: none">
+          <Icon color="black" icon="ep:expand" :size="18" class="cursor-pointer" />
           财务信息
           <Icon
             color="black"
-            :icon="cwIsExpanded?'fa-solid:angle-double-down':'fa-solid:angle-double-right'"
+            :icon="cwIsExpanded ? 'fa-solid:angle-double-down' : 'fa-solid:angle-double-right'"
             :size="18"
             class="cursor-pointer"
           />
@@ -178,7 +186,11 @@
         <el-row>
           <el-col :span="6">
             <el-form-item label="采购价格" prop="plPrice">
-              <el-input v-model="formData.plPrice" @input="handleInput(formData.plPrice, 'plPrice')" placeholder="请输入采购/租赁价格" />
+              <el-input
+                v-model="formData.plPrice"
+                @input="handleInput(formData.plPrice, 'plPrice')"
+                placeholder="请输入采购/租赁价格"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -213,93 +225,147 @@
         <el-row>
           <el-col :span="6">
             <el-form-item label="已提折旧月数" prop="plMonthed">
-              <el-input v-model="formData.plMonthed" type="number" placeholder="请输入已提折旧月数" />
+              <el-input
+                v-model="formData.plMonthed"
+                type="number"
+                placeholder="请输入已提折旧月数"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="6">
             <el-form-item label="已提折旧金额" prop="plAmounted">
-              <el-input v-model="formData.plAmounted" @input="handleInput(formData.plAmounted, 'plAmounted')" placeholder="请输入已提折旧金额" />
+              <el-input
+                v-model="formData.plAmounted"
+                @input="handleInput(formData.plAmounted, 'plAmounted')"
+                placeholder="请输入已提折旧金额"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="6">
             <el-form-item label="剩余金额" prop="remainAmount">
-              <el-input v-model="formData.remainAmount" @input="handleInput(formData.remainAmount, 'remainAmount')" placeholder="请输入剩余金额" />
+              <el-input
+                v-model="formData.remainAmount"
+                @input="handleInput(formData.remainAmount, 'remainAmount')"
+                placeholder="请输入剩余金额"
+              />
             </el-form-item>
           </el-col>
         </el-row>
       </div>
-      <div style="margin-bottom: 20px;margin-top: 10px;margin-left: 15px">
-        <el-button @click="qtInfoClick" style="font-size: 18px;border: none">
-          <Icon
-            color="black"
-            icon="ep:expand"
-            :size="18"
-            class="cursor-pointer"
-          />其它信息
+      <div style="margin-bottom: 20px; margin-top: 10px; margin-left: 15px">
+        <el-button @click="qtInfoClick" style="font-size: 18px; border: none">
+          <Icon color="black" icon="ep:expand" :size="18" class="cursor-pointer" />其它信息
           <Icon
             color="black"
-            :icon="qtIsExpanded?'fa-solid:angle-double-down':'fa-solid:angle-double-right'"
+            :icon="qtIsExpanded ? 'fa-solid:angle-double-down' : 'fa-solid:angle-double-right'"
             :size="18"
             class="cursor-pointer"
           />
         </el-button>
-
       </div>
       <div class="qt-expandable-content" :class="{ 'is-expanded': qtIsExpanded }">
+        <el-row>
+          <el-col v-for="field in list" :key="field.id" :span="6">
+            <el-form-item :label="field.label" :prop="field.model" :rules="field.rules">
+              <!-- 文本输入 -->
+              <el-input
+                v-if="field.type === 'input'"
+                v-model="formData[field.prop]"
+                :placeholder="'请输入' + field.label"
+                :type="field.type || 'text'"
+                clearable
+              >
+                <!--                <template v-if="field.prepend" #prepend>-->
+                <!--                  {{ field.prepend }}-->
+                <!--                </template>-->
+              </el-input>
 
+              <!-- 下拉选择 -->
+              <!--              <el-select-->
+              <!--                v-else-if="field.type === 'select'"-->
+              <!--                v-model="formData[field.model]"-->
+              <!--                :placeholder="'请输入'+field.label"-->
+              <!--                clearable-->
+              <!--                filterable-->
+              <!--              >-->
+              <!--                <el-option-->
+              <!--                  v-for="item in field.options"-->
+              <!--                  :key="item.value"-->
+              <!--                  :label="item.label"-->
+              <!--                  :value="item.value"-->
+              <!--                />-->
+              <!--              </el-select>-->
 
-      <el-form-item label="动态模板信息" prop="templateJson">
-        <el-input v-model="formData.templateJson" placeholder="请输入动态模板信息" />
-      </el-form-item>
+              <!-- 数字输入 -->
+              <el-input-number
+                v-else-if="field.type === 'number'"
+                v-model="formData[field.prop]"
+                :min="field.min || 0"
+                :max="field.max || 100"
+                :step="field.step || 1"
+              />
+
+              <!-- 日期选择 -->
+              <el-date-picker
+                v-else-if="field.type === 'date'"
+                v-model="formData[field.prop]"
+                :type="field.type || 'date'"
+                :placeholder="'请输入' + field.label"
+                value-format="YYYY-MM-DD"
+                style="width: 150%"
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
       </div>
     </el-form>
-<!--    <template #footer>-->
-<!--      <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>-->
-<!--      <el-button @click="dialogVisible = false">取 消</el-button>-->
-<!--    </template>-->
-  <el-form>
-    <el-form-item style="float: right">
-      <el-button type="success" @click="allzhankai">一键展开</el-button>
-      <el-button type="info" @click="allshouqi">一键收起</el-button>
-      <el-button v-if="!isDetail" :loading="formLoading" type="warning"  @click="submitForm">
-        保存
-      </el-button>
-      <el-button @click="close" type="primary">返回</el-button>
-    </el-form-item>
-  </el-form>
+    <el-form>
+      <el-form-item style="float: right">
+        <el-button type="success" @click="allzhankai">一键展开</el-button>
+        <el-button type="info" @click="allshouqi">一键收起</el-button>
+        <el-button v-if="!isDetail" :loading="formLoading" type="warning" @click="submitForm">
+          保存
+        </el-button>
+        <el-button @click="close" type="primary">返回</el-button>
+      </el-form-item>
+    </el-form>
   </ContentWrap>
   <BrandList ref="brandFormRef" @choose="brandChoose" />
-  <CustomerList ref="customerFormRef" @choose="customerChoose"/>
+  <CustomerList ref="customerFormRef" @choose="customerChoose" />
 </template>
 <script setup lang="ts">
 import { IotDeviceApi, IotDeviceVO } from '@/api/pms/device'
-import BrandList from "@/views/pms/device/BrandList.vue";
-import CustomerList from "@/views/pms/device/CustomerList.vue";
-import {defaultProps, handleTree} from "@/utils/tree";
-import * as DeptApi from "@/api/system/dept";
-import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
+import BrandList from '@/views/pms/device/BrandList.vue'
+import CustomerList from '@/views/pms/device/CustomerList.vue'
+import { defaultProps, handleTree } from '@/utils/tree'
+import * as DeptApi from '@/api/system/dept'
+import * as ProductClassifyApi from '@/api/pms/productclassify'
+import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
 import { useTagsViewStore } from '@/store/modules/tagsView'
 
 /** 设备台账 表单 */
 defineOptions({ name: 'IotDeviceForm' })
-const baseIsExpanded = ref(true); // 控制表单是否展开的变量
-const zzIsExpanded = ref(false); // 控制表单是否展开的变量
-const cwIsExpanded = ref(false); // 控制表单是否展开的变量
-const qtIsExpanded = ref(false); // 控制表单是否展开的变量
+const baseIsExpanded = ref(true) // 控制表单是否展开的变量
+const zzIsExpanded = ref(false) // 控制表单是否展开的变量
+const cwIsExpanded = ref(false) // 控制表单是否展开的变量
+const qtIsExpanded = ref(false) // 控制表单是否展开的变量
 
 const deptList = ref<Tree[]>([]) // 树形结构
+const productClassifyList = ref<Tree[]>([]) // 树形结构
 const { delView } = useTagsViewStore() // 视图操作
-const { params, name} = useRoute() // 查询参数
-const {currentRoute, push} = useRouter()
-const id = params.id;
-const isDetail = params.isDetail;
+const { params, name } = useRoute() // 查询参数
+const { currentRoute, push } = useRouter()
+const id = params.id
+const isDetail = params.isDetail
 const { t } = useI18n() // 国际化
 const message = useMessage() // 消息弹窗
 const dialogVisible = ref(false) // 弹窗的是否展示
 const dialogTitle = ref('') // 弹窗的标题
 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
 const formType = ref('') // 表单的类型:create - 新增;update - 修改
-const customerType = ref('')
+const brandLabel = ref('') // 表单的类型:create - 新增;update - 修改
+const zzLabel = ref('') // 表单的类型:create - 新增;update - 修改
+const supplierLabel = ref('') // 表单的类型:create - 新增;update - 修改
 const formData = ref({
   id: undefined,
   deviceCode: undefined,
@@ -329,8 +395,10 @@ const formData = ref({
   infoRemark: undefined,
   infoUrl: undefined,
   templateJson: undefined,
+  assetClass: undefined
 })
 const formRules = reactive({
+  assetClass: [{ required: true, message: '资产类别不能为空', trigger: 'blur' }],
   deviceCode: [{ required: true, message: '资产编码不能为空', trigger: 'blur' }],
   deviceName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
   brand: [{ required: true, message: '品牌不能为空', trigger: 'blur' }],
@@ -338,16 +406,40 @@ const formRules = reactive({
   deviceStatus: [{ required: true, message: '设备状态不能为空', trigger: 'blur' }],
   assetProperty: [{ required: true, message: '资产性质不能为空', trigger: 'blur' }],
   manufacturerId: [{ required: true, message: '制造商id不能为空', trigger: 'blur' }],
-  manDate: [{ required: true, message: '生产日期不能为空', trigger: 'blur' }],
+  manDate: [{ required: true, message: '生产日期不能为空', trigger: 'blur' }]
 })
 
-const brandChoose = (row) =>{
-  console.log(JSON.stringify(row.value))
-  formData.value.brand = row.value;
+const list = [
+  {
+    id: 1,
+    label: '姓名',
+    prop: 'name',
+    type: 'input',
+    value: null,
+    rules: [{ required: true, message: '姓名不能为空', trigger: 'blur' }]
+  },
+  { id: 2, label: '邮件', prop: 'email', type: 'date' },
+  { id: 3, label: '邮件', prop: 'email', type: 'date' },
+  { id: 4, label: '邮件', prop: 'email', type: 'date' },
+  { id: 5, label: '邮件', prop: 'email', type: 'date' }
+]
+
+const assetclasschange = () => {
+  const assetClass = formData.value.assetClass
+  // todo 调用获取动态模板接口
 }
-const customerChoose = (row) =>{
-  console.log(JSON.stringify(row))
-    formData.value[row.customerNature+'Id'] = row.name;
+
+const brandChoose = (row) => {
+  formData.value.brand = row.id
+  brandLabel.value = row.value
+}
+const customerChoose = (row) => {
+  formData.value[row.customerNature + 'Id'] = row.id
+  if (row.customerNature == 'supplier') {
+    supplierLabel.value = row.name
+  } else {
+    zzLabel.value = row.name
+  }
 }
 /** 添加/修改操作 */
 const brandFormRef = ref()
@@ -358,7 +450,7 @@ const customerFormRef = ref()
 const openCustomer = (type) => {
   customerFormRef.value.open(type)
 }
-const allshouqi = () =>{
+const allshouqi = () => {
   baseIsExpanded.value = false
   zzIsExpanded.value = false
   cwIsExpanded.value = false
@@ -371,73 +463,79 @@ const allzhankai = () => {
   qtIsExpanded.value = true
 }
 /** 打开弹窗 */
-const open = async (type: string, id?: number) => {
-  dialogVisible.value = true
-  dialogTitle.value = t('action.' + type)
-  formType.value = type
-  resetForm()
-  // 修改时,设置数据
-  if (id) {
-    formLoading.value = true
-    try {
-      formData.value = await IotDeviceApi.getIotDevice(id)
-    } finally {
-      formLoading.value = false
-    }
-  }
-}
-defineExpose({ open }) // 提供 open 方法,用于打开弹窗
+// const open = async (id?: number,isDetail: boolean, type: string) => {
+//   debugger
+//   formType.value = type
+//   resetForm()
+//   // 修改时,设置数据
+//   if (id) {
+//     formLoading.value = true
+//     try {
+//       formData.value = await IotDeviceApi.getIotDevice(id)
+//     } finally {
+//       formLoading.value = false
+//     }
+//   }
+// }
+// defineExpose({ open }) // 提供 open 方法,用于打开弹窗
 
-const handleInput = (value,obj) => {
+const handleInput = (value, obj) => {
   // 1. 过滤非法字符(只允许数字和小数点)
-  let filtered = value.replace(/[^\d.]/g, '');
+  let filtered = value.replace(/[^\d.]/g, '')
 
   // 2. 处理多个小数点的情况
-  filtered = filtered.replace(/\.{2,}/g, '.');
+  filtered = filtered.replace(/\.{2,}/g, '.')
 
   // 3. 限制小数点后最多两位
-  let decimalParts = filtered.split('.');
+  let decimalParts = filtered.split('.')
   if (decimalParts.length > 1) {
-    decimalParts = decimalParts.slice(0, 2);
-    filtered = decimalParts.join('.');
+    decimalParts = decimalParts.slice(0, 2)
+    filtered = decimalParts.join('.')
   }
 
   // 4. 处理以小数点开头的情况(自动补0)
   if (filtered.startsWith('.')) {
-    filtered = '0' + filtered;
+    filtered = '0' + filtered
   }
 
   // 5. 更新绑定值(同时处理连续输入多个0的情况)
-  formData.value[obj] = filtered.replace(/^0+(?=\d)/, '');
-
-};
+  formData.value[obj] = filtered.replace(/^0+(?=\d)/, '')
+}
 
 const close = () => {
   delView(unref(currentRoute))
-  push({ name: 'IotDevicePms',query: {
-      date: new Date().getTime(),
-    } })
+  push({
+    name: 'IotDevicePms',
+    query: {
+      date: new Date().getTime()
+    }
+  })
 }
-const baseInfoClick = ()=> {
-  baseIsExpanded.value = !baseIsExpanded.value; // 切换展开状态
+const baseInfoClick = () => {
+  baseIsExpanded.value = !baseIsExpanded.value // 切换展开状态
 }
-const zzInfoClick = ()=> {
-  zzIsExpanded.value = !zzIsExpanded.value; // 切换展开状态
+const zzInfoClick = () => {
+  zzIsExpanded.value = !zzIsExpanded.value // 切换展开状态
 }
-const cwInfoClick = ()=> {
-  cwIsExpanded.value = !cwIsExpanded.value; // 切换展开状态
+const cwInfoClick = () => {
+  cwIsExpanded.value = !cwIsExpanded.value // 切换展开状态
 }
-const qtInfoClick = ()=> {
-  qtIsExpanded.value = !qtIsExpanded.value; // 切换展开状态
+const qtInfoClick = () => {
+  qtIsExpanded.value = !qtIsExpanded.value // 切换展开状态
 }
 /** 提交表单 */
 const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
+const formRef = ref()
 const submitForm = async () => {
   // 校验表单
   await formRef.value.validate()
   // 提交请求
   formLoading.value = true
   try {
+    list.forEach((item) => {
+      item.value = formData.value[item.prop]
+    })
+    formData.value.templateJson = JSON.stringify(list)
     const data = formData.value as unknown as IotDeviceVO
     if (formType.value === 'create') {
       await IotDeviceApi.createIotDevice(data)
@@ -448,14 +546,40 @@ const submitForm = async () => {
     }
     dialogVisible.value = false
     // 发送操作成功的事件
-    emit('success')
+    //emit('success')
+    delView(unref(currentRoute))
+    await push({
+      name: 'IotDevicePms', query: {
+        date: new Date().getTime(),
+      }
+    })
   } finally {
     formLoading.value = false
   }
 }
 
-onMounted(async ()=>{
+onMounted(async () => {
   deptList.value = handleTree(await DeptApi.getSimpleDeptList())
+  productClassifyList.value = handleTree(
+    await ProductClassifyApi.IotProductClassifyApi.getSimpleProductClassifyList()
+  )
+  console.log(JSON.stringify(productClassifyList.value))
+  // 修改时,设置数据
+  if (id) {
+    formType.value = 'update';
+    formLoading.value = true
+    try {
+      const iotDevice = await IotDeviceApi.getIotDevice(id);
+      formData.value = iotDevice
+      brandLabel.value = iotDevice.brandName;
+      zzLabel.value = iotDevice.zzName;
+      supplierLabel.value = iotDevice.supplierName;
+    } finally {
+      formLoading.value = false
+    }
+  } else {
+    formType.value = 'create';
+  }
 })
 /** 重置表单 */
 const resetForm = () => {
@@ -488,47 +612,48 @@ const resetForm = () => {
     infoRemark: undefined,
     infoUrl: undefined,
     templateJson: undefined,
+    assetClass: undefined,
+
   }
   formRef.value?.resetFields()
 }
 </script>
 
 <style scoped lang="scss">
-  .base-expandable-content {
-    max-height: 0; /* 初始高度为0 */
-    overflow: hidden; /* 隐藏溢出的内容 */
-    transition: max-height 0.3s ease; /* 平滑过渡效果 */
-  }
-
-  .base-expandable-content.is-expanded {
-    max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
-  }
-  .zz-expandable-content {
-    max-height: 0; /* 初始高度为0 */
-    overflow: hidden; /* 隐藏溢出的内容 */
-    transition: max-height 0.3s ease; /* 平滑过渡效果 */
-  }
+.base-expandable-content {
+  max-height: 0; /* 初始高度为0 */
+  overflow: hidden; /* 隐藏溢出的内容 */
+  transition: max-height 0.3s ease; /* 平滑过渡效果 */
+}
 
-  .zz-expandable-content.is-expanded {
-    max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
-  }
-  .cw-expandable-content {
-    max-height: 0; /* 初始高度为0 */
-    overflow: hidden; /* 隐藏溢出的内容 */
-    transition: max-height 0.3s ease; /* 平滑过渡效果 */
-  }
+.base-expandable-content.is-expanded {
+  max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
+}
+.zz-expandable-content {
+  max-height: 0; /* 初始高度为0 */
+  overflow: hidden; /* 隐藏溢出的内容 */
+  transition: max-height 0.3s ease; /* 平滑过渡效果 */
+}
 
-  .cw-expandable-content.is-expanded {
-    max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
-  }
-  .qt-expandable-content {
-    max-height: 0; /* 初始高度为0 */
-    overflow: hidden; /* 隐藏溢出的内容 */
-    transition: max-height 0.3s ease; /* 平滑过渡效果 */
-  }
+.zz-expandable-content.is-expanded {
+  max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
+}
+.cw-expandable-content {
+  max-height: 0; /* 初始高度为0 */
+  overflow: hidden; /* 隐藏溢出的内容 */
+  transition: max-height 0.3s ease; /* 平滑过渡效果 */
+}
 
-  .qt-expandable-content.is-expanded {
-    max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
-  }
+.cw-expandable-content.is-expanded {
+  max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
+}
+.qt-expandable-content {
+  max-height: 0; /* 初始高度为0 */
+  overflow: hidden; /* 隐藏溢出的内容 */
+  transition: max-height 0.3s ease; /* 平滑过渡效果 */
+}
 
+.qt-expandable-content.is-expanded {
+  max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
+}
 </style>

+ 22 - 27
src/views/pms/device/index.vue

@@ -90,11 +90,17 @@
     <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
       <el-table-column label="资产编码" align="center" prop="deviceCode" />
       <el-table-column label="设备名称" align="center" prop="deviceName" />
-<!--      <el-table-column label="品牌" align="center" prop="brand" />-->
-<!--      <el-table-column label="规格型号" align="center" prop="model" />-->
-      <el-table-column label="所在部门" align="center" prop="orgId" />
-      <el-table-column label="设备状态" align="center" prop="deviceStatus" />
-      <el-table-column label="资产性质" align="center" prop="assetProperty" />
+      <el-table-column label="所在部门" align="center" prop="deptName" />
+      <el-table-column label="设备状态" align="center" prop="deviceStatus">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.PMS_DEVICE_STATUS" :value="scope.row.deviceStatus" />
+        </template>
+      </el-table-column>
+      <el-table-column label="资产性质" align="center" prop="assetProperty">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.PMS_ASSET_PROPERTY" :value="scope.row.assetProperty" />
+        </template>
+      </el-table-column>
       <el-form-item label="创建时间" prop="createTime">
         <el-date-picker
           v-model="queryParams.createTime"
@@ -106,26 +112,13 @@
           class="!w-240px"
         />
       </el-form-item>
-<!--      <el-table-column label="图片" align="center" prop="picUrl" />-->
-<!--      <el-table-column label="备注" align="center" prop="remark" />-->
-<!--      <el-table-column label="制造商id" align="center" prop="manufacturerId" />-->
-<!--      <el-table-column label="供应商id" align="center" prop="supplierId" />-->
-<!--      <el-table-column label="生产日期" align="center" prop="manDate" />-->
-<!--      <el-table-column label="铭牌信息" align="center" prop="nameplate" />-->
-<!--      <el-table-column label="质保到期" align="center" prop="expires" />-->
-<!--      <el-table-column label="采购/租赁价格" align="center" prop="plPrice" />-->
-<!--      <el-table-column label="采购/租赁日期" align="center" prop="plDate" />-->
-<!--      <el-table-column label="折旧年限" align="center" prop="plYear" />-->
-<!--      <el-table-column label="折旧开始日期" align="center" prop="plStartDate" />-->
-<!--      <el-table-column label="已提折旧月数" align="center" prop="plMonthed" />-->
-<!--      <el-table-column label="已提折旧金额" align="center" prop="plAmounted" />-->
-<!--      <el-table-column label="剩余金额" align="center" prop="remainAmount" />-->
-<!--      <el-table-column label="资料分类id" align="center" prop="infoId" />-->
-<!--      <el-table-column label="资料类型" align="center" prop="infoType" />-->
-<!--      <el-table-column label="资料名称" align="center" prop="infoName" />-->
-<!--      <el-table-column label="资料备注" align="center" prop="infoRemark" />-->
-<!--      <el-table-column label="资料附件" align="center" prop="infoUrl" />-->
-<!--      <el-table-column label="动态模板信息" align="center" prop="templateJson" />-->
+      <el-table-column
+        label="创建时间"
+        align="center"
+        prop="createTime"
+        :formatter="dateFormatter"
+        width="180px"
+      />
       <el-table-column label="操作" align="center" min-width="120px">
         <template #default="scope">
           <el-button
@@ -164,6 +157,8 @@
 import download from '@/utils/download'
 import { IotDeviceApi, IotDeviceVO } from '@/api/pms/device'
 import IotDeviceForm from './IotDeviceForm.vue'
+import {DICT_TYPE} from "@/utils/dict";
+import {dateFormatter} from "@/utils/formatTime";
 
 /** 设备台账 列表 */
 defineOptions({ name: 'IotDevicePms' })
@@ -242,11 +237,11 @@ const formRef = ref()
 const openForm = (type: string, id?: number) => {
   //修改
   if (typeof id === 'number') {
-    push({ name: 'DeviceDetailEdit', params: { id:id, isDetail: type } })
+    push({ name: 'DeviceDetailEdit', params: {id } })
     return
   }
   // 新增
-  push({ name: 'DeviceDetailAdd', params:{isDetail: type} })
+  push({ name: 'DeviceDetailAdd', params:{} })
 }
 
 /** 删除按钮操作 */