Переглянути джерело

feat: indent转单. 增加客户选择. sku调整为必填.

peter 2 днів тому
батько
коміт
cad01f0f65

+ 91 - 0
src/pages/indent-manage/indent/components/quoteRecord.vue

@@ -24,6 +24,10 @@
             >
               <div class="flex justify-between flex-wrap">
                 <el-form-item
+                  :rules="{
+                    required: true,
+                  }"
+                  prop="product_sku"
                   label="SKU"
                   style="height: 40px"
                 >
@@ -31,6 +35,11 @@
                     class="el-input el-input__wrapper el-input__inner fake-sku-input"
                     @click="openSkuSelect(props.$index)"
                   >
+                    <el-input
+                      style="display: none"
+                      v-model="formList[props.$index].product_sku"
+                    ></el-input>
+
                     <span class="cursor-pointer">
                       {{ formList[props.$index].product_sku }}
                     </span>
@@ -203,6 +212,32 @@
                     ></el-option>
                   </el-select>
                 </el-form-item>
+                <el-form-item
+                  label="客户名称"
+                  prop="custom_name"
+                  :rules="{
+                    required: true,
+                  }"
+                >
+                  <el-select
+                    v-model="formList[props.$index].custom_name"
+                    style="width: 100%"
+                    :placeholder="$t('text_please_select')"
+                    :remote-method="debounce(getCustomListFun, 500)"
+                    :loading="customLoading"
+                    remote
+                    filterable
+                    @change="selectCustomer"
+                    :disabled="!!indentData.enquiry_id"
+                  >
+                    <el-option
+                      v-for="(option, index) in customList"
+                      :key="option.id || index"
+                      :label="option.name"
+                      :value="option.name"
+                    ></el-option>
+                  </el-select>
+                </el-form-item>
               </div>
               <div class="flex justify-end">
                 <el-button
@@ -362,6 +397,9 @@ import {
 import { Notebook } from '@element-plus/icons-vue'
 import Cookie from 'js-cookie'
 import { getCalcPriceRecord, generateOrder } from '@/api/indent'
+import debounce from 'lodash.debounce'
+import { $t } from '@/i18n/index'
+import { getCustomList } from '@/api/indent'
 import userAPI from '@/api/user'
 import skuSelect from './skuSelect.vue'
 
@@ -438,6 +476,9 @@ const getCalcPriceRecordFunc = () => {
         const v = list.value[i].Accounts || ({} as any)
         // remoteOption.value.push([])
         formList.value.push({
+          // custom_id 不存在说明是旧系统的数据, 需要置空让用户重新选客户
+          custom_name: indentData.custom_id ? indentData.custom_name : '',
+          custom_id: indentData.custom_id || '', // 联动custom_name
           item_id: indentData.item_id || '',
           product_name: indentData.product_name || '',
           product_sku: indentData.product_sku || '',
@@ -524,6 +565,22 @@ const submitChangeOrder = (index: number) => {
       })
       return
     }
+    if (!data.product_sku || !data.product_name) {
+      ElNotification({
+        title: 'SKU/产品名称不能为空',
+        message: '请选择正确的SKU进行转单',
+        duration: 5000,
+      })
+      return
+    }
+    if (!data.custom_id || !data.custom_name) {
+      ElNotification({
+        title: '客户名称 数据出错',
+        message: '如果界面上的客户名称有值, 请联系管理员',
+        duration: 5000,
+      })
+      return
+    }
     console.log(data, 'data')
     onChangeOrderClick(data)
   })
@@ -600,6 +657,40 @@ const selectSku = (data: any) => {
     }
   })
 }
+
+// 客户下拉框候选列表
+const customList = ref([] as any[])
+let customLoading = ref(false)
+const selectCustomer = (data: any) => {
+  const temp = customList.value.filter((i: any) => i.name === data)
+  if (temp.length === 0) {
+    ElMessage.error('客户名称不存在, 请重新选择')
+    return
+  }
+  formList.value = formList.value.map((i: any) => {
+    return {
+      ...i,
+      custom_name: temp[0].name || '',
+      custom_id: temp[0].id || '',
+    }
+  })
+}
+
+const getCustomListFun = (keyword: string) => {
+  let keywords = keyword.trim()
+  if (!keywords.length) return
+  customLoading.value = true
+  customList.value = []
+  getCustomList({ keywords })
+    .then((response: any) => {
+      if (Array.isArray(response.result)) {
+        customList.value = response.result.length ? response.result : []
+      }
+    })
+    .finally(() => {
+      customLoading.value = false
+    })
+}
 </script>
 <style lang="scss">
 .dialog-change-order {