From af1c9e588f1de0240390648f9bb56aa486870aff Mon Sep 17 00:00:00 2001
From: chengxiangling <291105840@qq.com>
Date: 星期五, 16 五月 2025 17:40:18 +0800
Subject: [PATCH] 提交高度修改;

---
 src/views/basicData/apsPlant/index.vue |  196 ++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 163 insertions(+), 33 deletions(-)

diff --git a/src/views/basicData/apsPlant/index.vue b/src/views/basicData/apsPlant/index.vue
index c9806a5..1347cab 100644
--- a/src/views/basicData/apsPlant/index.vue
+++ b/src/views/basicData/apsPlant/index.vue
@@ -40,35 +40,26 @@
           v-hasPermi="['plant:export']"
         >瀵煎嚭</el-button>
       </el-col>
-      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
+      <right-toolbar :search="false" 
+        @refreshTable="getList"
+      ></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="aps_plantList" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="宸ュ巶鍚嶇О" align="center" prop="plantName" />
-      <el-table-column label="宸ュ巶缂栫爜" align="center" prop="plantCode" />
-      <el-table-column label="鍚敤鐘舵��" align="center" prop="status">
-        <template #default="scope">
-          <dict-tag :options="aps_plant_status" :value="scope.row.status"/>
-        </template>
-      </el-table-column>
-      <el-table-column label="鍒涘缓鑰�" align="center" prop="createBy" />
-      <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" />
-      <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
-        <template #default="scope">
-          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['plant:edit']">淇敼</el-button>
-<!--          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['aps_plant:aps_plant:remove']">鍒犻櫎</el-button>-->
-        </template>
-      </el-table-column>
-    </el-table>
-    
-    <pagination
-      v-show="total>0"
-      :total="total"
-      v-model:page="queryParams.pageNum"
-      v-model:limit="queryParams.pageSize"
-      @pagination="getList"
-    />
+    <HxlhTable
+        style="width: 100%"
+        :columns="columns"
+        :data="aps_plantList"
+        :loading="loading"
+        :height="height"
+        :page="page"
+        @changePageNo="changePageNo"
+        @changePageSize="changePageSize"
+        @on-checkbox="handleCheckboxChange"
+    >
+      <template #buttons="{row}">
+        <vxe-button mode="text" @click="handleUpdate(row)" v-hasPermi="['plant:edit']" >缂栬緫</vxe-button>
+      </template>
+    </HxlhTable>
 
     <!-- 娣诲姞鎴栦慨鏀瑰伐鍘傜鐞嗗璇濇 -->
     <el-dialog :title="title" v-model="open" width="500px" append-to-body>
@@ -78,7 +69,7 @@
           <el-input v-model="form.plantName" placeholder="璇疯緭鍏ュ伐鍘傚悕绉�" />
         </el-form-item>
         <el-form-item label="宸ュ巶缂栫爜" prop="plantCode">
-          <el-input v-model="form.plantCode" placeholder="璇疯緭鍏ュ伐鍘傜紪鐮�"     :disabled=disabled />
+          <el-input v-model="form.plantCode" placeholder="璇疯緭鍏ュ伐鍘傜紪鐮�" :disabled=disabled />
         </el-form-item>
         <el-form-item label="鍚敤鐘舵��" prop="status">
           <el-radio-group v-model="form.status">
@@ -102,10 +93,14 @@
 
 <script setup name="Aps_plant">
 import { listAps_plant, getAps_plant, delAps_plant, addAps_plant, updateAps_plant } from "@/api/basicData/plant";
+import HxlhTable from '@/components/HxlhTable'
 
 const { proxy } = getCurrentInstance();
 const { aps_plant_status } = proxy.useDict('aps_plant_status');
-
+const height = ref(document.documentElement.clientHeight - 170 + "px;");
+const plantNameRules = ref(null);
+const plantCodeRules = ref(null);
+const dataForm = ref();
 const aps_plantList = ref([]);
 const open = ref(false);
 const loading = ref(true);
@@ -113,7 +108,6 @@
 const ids = ref([]);
 const single = ref(true);
 const multiple = ref(true);
-const total = ref(0);
 const title = ref("");
 const disabled = ref(false);
 const data = reactive({
@@ -128,9 +122,53 @@
   rules: {
     plantName: [
       { required: true, message: "宸ュ巶鍚嶇О涓嶈兘涓虹┖", trigger: "blur" },
+      {
+        validator: async (rule, value, callback) => {
+          if (!value) {
+            return callback();
+          }
+          try {
+            if(value === plantNameRules.value){
+              callback();
+            }else{
+              const isExists = await checkPlantNameExists(value);
+              if (isExists) {
+                return callback(new Error('璇ュ伐鍘傚悕绉板凡瀛樺湪锛岃鏇存崲'));
+              } else {
+                callback();
+              }
+            }
+          } catch (error) {
+            return callback(new Error('鏍¢獙鐢ㄦ埛鍚嶆椂鍙戠敓閿欒锛岃绋嶅悗閲嶈瘯'));
+          }
+        },
+        trigger: 'blur'
+      }
     ],
     plantCode: [
       { required: true, message: "宸ュ巶缂栫爜涓嶈兘涓虹┖", trigger: "blur" },
+      {
+        validator: async (rule, value, callback) => {
+          if (!value) {
+            return callback();
+          }
+          try {
+            if(value === plantCodeRules.value){
+              callback();
+            }else{
+              const isExists = await checkPlantCodeExists(value);
+              if (isExists) {
+                return callback(new Error('璇ュ伐鍘傜紪鐮佸凡瀛樺湪锛岃鏇存崲'));
+              } else {
+                callback();
+              }
+            }
+          } catch (error) {
+            return callback(new Error('鏍¢獙鐢ㄦ埛鍚嶆椂鍙戠敓閿欒锛岃绋嶅悗閲嶈瘯'));
+          }
+        },
+        trigger: 'blur'
+      }
     ],
     status: [
       { required: true, message: "鍚敤鐘舵�佷笉鑳戒负绌�", trigger: "blur" },
@@ -140,12 +178,46 @@
 
 const { queryParams, form, rules } = toRefs(data);
 
+// 鍒嗛〉灞炴��
+const page = ref({
+  total: 0,
+  current: 1,
+  size: 10
+});
+
+// 琛ㄦ牸閰嶇疆 
+const columns = ref([
+  { type: 'checkbox', width: 60, align:"center"},
+  { type: 'seq', title: '搴忓彿', width: 60 },
+  {
+    title: '宸ュ巶鍚嶇О',
+    field: 'plantName',
+  },
+  {
+    title: '宸ュ巶缂栫爜',
+    field: 'plantCode',
+  },
+  {
+    title: '鍚敤鐘舵��',
+    field: 'status',
+  },
+  {
+    title: '鍒涘缓鑰�',
+    field: 'createBy',
+  },
+  {
+    title: '鍒涘缓鏃堕棿',
+    field: 'createTime',
+  },
+  { title: '鎿嶄綔', width: 100, fixed:"right", slots: { default: 'buttons' } }
+]);
+
 /** 鏌ヨ宸ュ巶绠$悊鍒楄〃 */
 function getList() {
   loading.value = true;
   listAps_plant(queryParams.value).then(response => {
     aps_plantList.value = response.rows;
-    total.value = response.total;
+    page.value.total = response.total;
     loading.value = false;
   });
 }
@@ -169,10 +241,13 @@
     updateTime: null
   };
   proxy.resetForm("aps_plantRef");
+  plantNameRules.value = null;
+  plantCodeRules.value = null;
 }
 
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 function handleQuery() {
+  page.value.current = 1;
   queryParams.value.pageNum = 1;
   getList();
 }
@@ -204,15 +279,18 @@
   const _id = row.id || ids.value
   disabled.value = true;
   getAps_plant(_id).then(response => {
+    dataForm.value = response.data;
     form.value = response.data;
     open.value = true;
     title.value = "淇敼宸ュ巶绠$悊";
+    plantNameRules.value = form.value.plantName;
+    plantCodeRules.value = form.value.plantCode;
   });
 }
 
 /** 鎻愪氦鎸夐挳 */
-function submitForm() {
-  proxy.$refs["aps_plantRef"].validate(valid => {
+const submitForm = async () => {
+  await proxy.$refs["aps_plantRef"].validate(valid => {
     if (valid) {
       if (form.value.id != null) {
         updateAps_plant(form.value).then(response => {
@@ -249,5 +327,57 @@
   }, `aps_plant_${new Date().getTime()}.xlsx`)
 }
 
+/** 妫�鏌ュ伐鍘傚悕瀛楅噸澶� */
+const checkPlantNameExists = async (value) => {
+  return new Promise((resolve) => {
+    queryParams.value = {};
+    queryParams.value.plantName = value;
+    listAps_plant(queryParams.value).then(response => {
+      if(response.total === 0){
+        resolve(false);
+      }else{
+        resolve(true);
+      }
+    });
+    queryParams.value = {};
+  });
+};
+
+/** 妫�鏌ュ伐鍘傜紪鐮侀噸澶� */
+const checkPlantCodeExists = async (value) => {
+  return new Promise((resolve) => {
+    queryParams.value = {};
+    queryParams.value.plantCode = value;
+    listAps_plant(queryParams.value).then(response => {
+      if(response.total === 0){
+        resolve(false);
+      }else{
+        resolve(true);
+      }
+    });
+    queryParams.value = {};
+  });
+};
+
+function changePageNo(currentPage) {
+  queryParams.value.pageNum = currentPage;
+  page.value.current = currentPage;
+  getList();
+}
+
+function changePageSize(pageSize) {
+  page.value.current = 1;
+  queryParams.value.pageNum = 1;
+  queryParams.value.pageSize = pageSize;
+  getList();
+}
+
+// 澶氶�夋閫変腑鏁版嵁
+const handleCheckboxChange = (data) => {
+  ids.value = data.records.map(item => item.id);
+  single.value = data.records.length != 1;
+  multiple.value = !data.records.length;
+};
+
 getList();
 </script>

--
Gitblit v1.9.3