Quellcode durchsuchen

fix: 处理下拉框选择候选项时触发远程搜索的问题.

peter vor 1 Jahr
Ursprung
Commit
2c88208803
1 geänderte Dateien mit 31 neuen und 9 gelöschten Zeilen
  1. 31 9
      src/pages/purchase-order/edit.vue

+ 31 - 9
src/pages/purchase-order/edit.vue

@@ -156,7 +156,7 @@
                   label-width="0"
                   prop="currentVendor"
                 >
-                  <el-select-v2
+                  <!-- <el-select-v2
                     v-model="form.currentVendor"
                     :remote-method="getSupplierLists"
                     remote
@@ -165,7 +165,23 @@
                     :options="vendorList"
                     filterable
                     clearable
-                  ></el-select-v2>
+                  ></el-select-v2> -->
+                  <el-select
+                    v-model="form.currentVendor"
+                    :remote-method="getSupplierLists"
+                    remote
+                    style="width: 100%"
+                    :loading="vendorLoading"
+                    filterable
+                    clearable
+                  >
+                    <el-option
+                      v-for="option in vendorList"
+                      :key="option.value"
+                      :value="option.value"
+                      :label="option.label"
+                    ></el-option>
+                  </el-select>
                 </el-form-item>
                 <div
                   v-if="typeof computedCompany.taxReimbursement === 'undefined'"
@@ -1072,7 +1088,7 @@ const submit = () => {
   loading.value = true
   createPurchaseOrders()
     .then((res) => {
-      console.log(res)
+      // console.log(res)
       getPurchaseOrdersData()
         .then(() => {
           generatePDF()
@@ -1332,14 +1348,14 @@ const createPurchaseOrders = function () {
     }
   })
   if (data.productList) delete data.productList
-  console.log(data, 'create po params')
+  // console.log(data, 'create po params')
   return new Promise((resolve, reject) => {
     request
       .post('/Purchase_orders/createPurchaseOrders', data, {})
       .then((response) => {
         if (response.data.code !== 1) return
         const res = response.data.result
-        console.log(res, 'create po')
+        // console.log(res, 'create po')
         if (res.data && res.data.length && res.data[0].code === 'SUCCESS') {
           POID.value = res.data[0].details?.id || ''
           resolve(res.data[0].details?.id)
@@ -1613,9 +1629,12 @@ const grandTotal = computed(() => {
 const productLoading = ref(false)
 const getProductList = utils.debounce(
   (keyword: string, target: IProductItem) => {
+    const key = keyword.trim()
+    if (!key.length) return
+
     productLoading.value = true
     const data = {
-      value: keyword.trim(),
+      value: key,
       name: 'Products',
       api_name: 'Product_Name',
       contains: 'contains',
@@ -1676,13 +1695,16 @@ watch(computedVendor, () => {
 
 const vendorLoading = ref(false)
 const getSupplierLists = utils.debounce(function (string: string) {
+  const keyword = string.trim()
+  if (!keyword.length) return
+
   const data = {
-    value: string.trim(),
+    value: keyword,
     name: 'Vendors',
     api_name: 'Vendor_Name',
     contains: 'contains',
     page: 1,
-    limit: 200,
+    limit: 100,
   }
   vendorLoading.value = true
   getSearchData(data)
@@ -1977,7 +1999,7 @@ const getProductData = async (id: string) =>
   request.post('/common/getProductsData', { id }).then((response) => {
     const res = response.data
     if (res.code !== 1) return
-    console.log(res.result)
+    // console.log(res.result)
     return res.result?.CF3 || ''
   })