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/apsShop/index.vue |  229 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 199 insertions(+), 30 deletions(-)

diff --git a/src/views/basicData/apsShop/index.vue b/src/views/basicData/apsShop/index.vue
index a5f98a7..e5844ea 100644
--- a/src/views/basicData/apsShop/index.vue
+++ b/src/views/basicData/apsShop/index.vue
@@ -31,44 +31,34 @@
           v-hasPermi="['shop: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_shopList" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="杞﹂棿鍚嶇О" align="center" prop="shopName" />
-      <el-table-column label="杞﹂棿浠g爜" align="center" prop="shopCode" />
-      <el-table-column label="宸ュ巶浠g爜" 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="['shop:edit']">淇敼</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
+    <HxlhTable
+        style="width: 100%"
+        :columns="columns"
+        :data="aps_shopList"
+        :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>
     
-    <pagination
-      v-show="total>0"
-      :total="total"
-      v-model:page="queryParams.pageNum"
-      v-model:limit="queryParams.pageSize"
-      @pagination="getList"
-    />
 
     <!-- 娣诲姞鎴栦慨鏀硅溅闂村璇濇 -->
     <el-dialog :title="title" v-model="open" width="500px" append-to-body>
       <el-form ref="aps_shopRef" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="杞﹂棿鍚嶇О" prop="shopName">
-          <el-input v-model="form.shopName" placeholder="璇疯緭鍏ヨ溅闂村悕绉�" />
+          <el-input v-model="form.shopName" placeholder="璇疯緭鍏ヨ溅闂村悕绉�" ref="shopNameInputRef"/>
         </el-form-item>
         <el-form-item label="杞﹂棿浠g爜" prop="shopCode">
-          <el-input v-model="form.shopCode" placeholder="璇疯緭鍏ヨ溅闂翠唬鐮�" :disabled=shopCodeDisabled  />
+          <el-input v-model="form.shopCode" placeholder="璇疯緭鍏ヨ溅闂翠唬鐮�" :disabled=shopCodeDisabled ref="shopCodeInputRef" />
 
         </el-form-item>
         <el-form-item label="宸ュ巶缂栫爜" prop="plantCode">
@@ -107,10 +97,15 @@
 <script setup name="Aps_shop">
 import { listAps_shop, getAps_shop, delAps_shop, addAps_shop, updateAps_shop } from "@/api/basicData/shop";
 import { listAps_plant } from "@/api/basicData/plant";
+import { ref } from "vue";
+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 shopNameRules = ref(null);
+const shopCodeRules = ref(null);
+const plantCodeRules = ref(null);
 const aps_shopList = ref([]);
 const open = ref(false);
 const loading = ref(true);
@@ -135,9 +130,53 @@
   rules: {
     shopName: [
       { required: true, message: "杞﹂棿鍚嶇О涓嶈兘涓虹┖", trigger: "blur" },
+      {
+        validator: async (rule, value, callback) => {
+          if (!value) {
+            return callback();
+          }
+          try {
+            if(value === shopNameRules.value && plantCodeRules.value === form.value.plantCode){
+              callback();
+            }else{
+              const isExists = await checkShopNameExists(value);
+              if (isExists) {
+                return callback(new Error('杞﹂棿鍚嶇О宸插瓨鍦紝璇锋洿鎹�'));
+              } else {
+                callback();
+              }
+            }
+          } catch (error) {
+            return callback(new Error('鏍¢獙鐢ㄦ埛鍚嶆椂鍙戠敓閿欒锛岃绋嶅悗閲嶈瘯'));
+          }
+        },
+        trigger: 'blur'
+      }
     ],
     shopCode: [
       { required: true, message: "杞﹂棿缂栫爜涓嶈兘涓虹┖", trigger: "blur" },
+      {
+        validator: async (rule, value, callback) => {
+          if (!value) {
+            return callback();
+          }
+          try {
+            if(form.value.shopCode){
+              callback();
+            }else{
+              const isExists = await checkShopCodeExists(value);
+              if (isExists) {
+                return callback(new Error('璇ヨ溅闂寸紪鐮佸凡瀛樺湪锛岃鏇存崲'));
+              } else {
+                callback();
+              }
+            }
+          } catch (error) {
+            return callback(new Error('鏍¢獙鐢ㄦ埛鍚嶆椂鍙戠敓閿欒锛岃绋嶅悗閲嶈瘯'));
+          }
+        },
+        trigger: 'blur'
+      }
     ],
     plantCode: [
       { required: true, message: "宸ュ巶缂栫爜涓嶈兘涓虹┖", trigger: "blur" },
@@ -150,12 +189,50 @@
 
 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: 'shopName',
+  },
+  {
+    title: '杞﹂棿浠g爜',
+    field: 'shopCode',
+  },
+  {
+    title: '宸ュ巶浠g爜',
+    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_shop(queryParams.value).then(response => {
     aps_shopList.value = response.rows;
-    total.value = response.total;
+    page.value.total = response.total;
     loading.value = false;
   });
 }
@@ -180,10 +257,14 @@
     updateTime: null
   };
   proxy.resetForm("aps_shopRef");
+  shopNameRules.value = null;
+  shopCodeRules.value = null;
+  plantCodeRules.value = null;
 }
 
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 function handleQuery() {
+  page.value.current = 1;
   queryParams.value.pageNum = 1;
   getList();
 }
@@ -218,6 +299,9 @@
     form.value = response.data;
     open.value = true;
     title.value = "淇敼杞﹂棿";
+    shopNameRules.value = form.value.shopName;
+    shopCodeRules.value = form.value.shopCode;
+    plantCodeRules.value = form.value.plantCode;
   });
 }
 
@@ -268,6 +352,91 @@
     loading.value = false;
   });
 }
+
+/** 妫�鏌ヨ溅闂村悕瀛楅噸澶� */
+const checkShopNameExists = async (value) => {
+  return new Promise((resolve) => {
+    queryParams.value = {};
+    queryParams.value.shopName = value;
+    queryParams.value.plantCode = form.value.plantCode;
+    listAps_shop(queryParams.value).then(response => {
+      console.log(response);
+      if(response.total === 0){
+        resolve(false);
+      }else{
+        resolve(true);
+      }
+    });
+    queryParams.value = {};
+  });
+};
+
+/** 妫�鏌ヨ溅闂寸紪鐮侀噸澶� */
+const checkShopCodeExists = async (value) => {
+  return new Promise((resolve) => {
+    queryParams.value = {};
+    queryParams.value.shopCode = value;
+    queryParams.value.plantCode = form.value.plantCode;
+    listAps_shop(queryParams.value).then(response => {
+      if(response.total === 0){
+        resolve(false);
+      }else{
+        resolve(true);
+      }
+    });
+    queryParams.value = {};
+  });
+};
+
 getPlantList();
 getList();
+
+const shopNameInputRef = ref(null);
+const aps_shopRef = ref(null);
+
+watch(() => form.value.shopName, (newValue, oldValue) => {
+  nextTick(() => {
+    if (newValue!== oldValue && proxy.$refs["aps_shopRef"] != null) {
+      proxy.$refs["aps_shopRef"].validateField('shopCode');
+    }
+  });
+});
+
+watch(() => form.value.shopCode, (newValue, oldValue) => {
+  nextTick(() => {
+    if (newValue!== oldValue && proxy.$refs["aps_shopRef"] != null) {
+      proxy.$refs["aps_shopRef"].validateField('shopName');
+    }
+  });
+});
+
+watch(() => form.value.plantCode, (newValue, oldValue) => {
+    nextTick(() => {
+      if (newValue!== oldValue && proxy.$refs["aps_shopRef"] != null) {
+        proxy.$refs["aps_shopRef"].validateField('shopName');
+        proxy.$refs["aps_shopRef"].validateField('shopCode');
+      }
+    });
+});
+
+function changePageNo(currentPage) {
+  page.value.current = currentPage;
+  queryParams.value.pageNum = 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;
+};
+
 </script>

--
Gitblit v1.9.3