Преглед на файлове

change: 创建PO模块. 若干功能调整.

peter преди 1 година
родител
ревизия
3abd6d1110
променени са 5 файла, в които са добавени 50 реда и са изтрити 31 реда
  1. 2 0
      .env.development
  2. 2 0
      .env.production
  3. 2 0
      .env.test
  4. 1 0
      src/interface.ts
  5. 43 31
      src/pages/purchase-order/edit.vue

+ 2 - 0
.env.development

@@ -0,0 +1,2 @@
+VITE_PO_PATH=https://crm.zoho.com/crm/org810841123/tab/PurchaseOrders/
+VITE_PO_APPEND=''

+ 2 - 0
.env.production

@@ -0,0 +1,2 @@
+VITE_PO_PATH=https://crm.zoho.com/crm/org742735154/tab/PurchaseOrders/
+VITE_PO_APPEND=/canvas/4791186000049921685

+ 2 - 0
.env.test

@@ -0,0 +1,2 @@
+VITE_PO_PATH=https://crm.zoho.com/crm/org810841123/tab/PurchaseOrders/
+VITE_PO_APPEND=''

+ 1 - 0
src/interface.ts

@@ -65,6 +65,7 @@ export interface IForm {
   Created_By?: any
   Vendor_Name?: any
   currentVendor?: string // 仅前端界面用到, API接口的字段是Vendor_Name
+  Reference?: string // 用在 表单项:订单号 显示
 }
 
 export interface IVendorItem {

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

@@ -175,12 +175,9 @@
                 <el-form-item label="采购订单 #:">
                   Generate once PO submitted
                 </el-form-item>
-                <el-form-item
-                  label="订单号 # :"
-                  prop="saleOrderId"
-                >
+                <el-form-item label="订单号 # :">
                   <el-input
-                    v-model="form.saleOrderId"
+                    v-model="form.Reference"
                     disabled
                   ></el-input>
                 </el-form-item>
@@ -406,8 +403,6 @@
                       v-model="adjustment"
                       style="width: 100%"
                       type="number"
-                      @change="(e) => formatAdjustment(e)"
-                      @input="(e) => formatAdjustment(e)"
                     ></el-input>
                   </div>
                 </div>
@@ -575,7 +570,7 @@
               <div class="flex">
                 <div class="column-form-label">订单号 # :</div>
                 <div class="column-form-value">
-                  {{ form.saleOrderId }}
+                  {{ form.Reference }}
                 </div>
               </div>
               <div class="flex">
@@ -1031,7 +1026,7 @@ computed(() => {
 })
 const formVisible = ref(true)
 const loading = ref(false)
-// 订单ID. 例如5757019000000428205, 不是串号.
+// 订单ID. 例如 5757019000000683001, 不是串号.
 const POID = ref('')
 // po 串号. 例如 PO2025
 const PONumber = ref('')
@@ -1061,12 +1056,17 @@ const submit = () => {
           generatePDF()
             .then(() => {
               ElNotification({
+                duration: 0,
                 type: 'success',
                 title: '任务已成功处理',
-                message: '本页面将在数秒后自动关闭',
+                message: '本页面将在数秒后自动跳转',
               })
+              const url =
+                import.meta.env.VITE_PO_PATH +
+                POID.value +
+                import.meta.env.VITE_PO_APPEND
               setTimeout(() => {
-                window.close()
+                window.location.replace(url)
               }, 5000)
             })
             .finally(() => {
@@ -1176,7 +1176,11 @@ const generatePDF = (ele = pdfElement, isFirstTime = true) => {
         renderedHeight += imgHeight
         if (renderedHeight < canvas.height) pdf.addPage() //如果后面还有内容,添加一个空页
       }
-      const fileName = isFirstTime ? 'attachment_file' : 'attachment_file_2'
+
+      const prefix =
+        `${PONumber.value}-${computedVendor.value.label}` +
+        (form.value.Title?.length ? `-${form.value.Title}` : '')
+      const fileName = isFirstTime ? prefix : prefix + '_2'
 
       sendPDF(pdf.output('datauristring'), fileName)
         .then(() => {
@@ -1198,9 +1202,7 @@ const generatePDF = (ele = pdfElement, isFirstTime = true) => {
           reject(e)
         })
       // 本地备份一下
-      pdf.save(
-        `backup_${fileName}` + `_${dayjs().format('YYYYMMDD_HHmm')}` + '.pdf',
-      )
+      pdf.save(fileName + '.pdf')
     })
   })
 }
@@ -1269,7 +1271,7 @@ const createPurchaseOrders = function () {
   data.Sub_Total = subTotal.value
   data.Total_Taxes = 0
   data.Total_Discount = totalDiscount.value
-  data.Adjustment = adjustment.value
+  data.Adjustment = Number(adjustment.value)
   data.Grand_Total = grandTotal.value
   data.Subject = '这里不用填'
   data.Created_By = {
@@ -1424,6 +1426,7 @@ const form = ref<IForm>({
   Currency: 'CNY',
   // 订单号
   saleOrderId: '',
+  Reference: '',
   // 日期
   PO_Date: '',
   // 付款方式
@@ -1481,13 +1484,13 @@ const formRule = ref<FormRules>({
       trigger: 'blur',
     },
   ],
-  saleOrderId: [
-    {
-      required: true,
-      message: '必填项',
-      trigger: 'blur',
-    },
-  ],
+  // saleOrderId: [
+  //   {
+  //     required: true,
+  //     message: '必填项',
+  //     trigger: 'blur',
+  //   },
+  // ],
   field7: [
     {
       required: true,
@@ -1538,7 +1541,7 @@ const addRow = function () {
 }
 const keyNeedCompute = ['quantity', 'rate']
 const onInputChange = function (e: any, obj: IProductItem, key: string) {
-  console.log(e, 'input value before enfore change')
+  // console.log(e, 'input value before enfore change')
   if (typeof e === 'string') {
     if (e.length) {
       // 强制转换为数字类型
@@ -1580,13 +1583,11 @@ const totalDiscount = computed(() => {
   }, 0)
 })
 // 价格统计修正值
-const adjustment = ref(0)
-const formatAdjustment = function (string: string) {
-  adjustment.value = Number(string)
-}
+const adjustment = ref<number | string>('')
+
 // 总计
 const grandTotal = computed(() => {
-  return subTotal.value - totalDiscount.value + adjustment.value
+  return subTotal.value - totalDiscount.value + Number(adjustment.value)
 })
 const productLoading = ref(false)
 const getProductList = utils.debounce(
@@ -1874,6 +1875,7 @@ const p2 = axios
     form.value.Title = res.Sales_Order_Title_Job_Name || ''
     form.value.saleOrderId = res.sales_orders_id || res.id || ''
     form.value.PO_Date = dayjs(new Date()).format('YYYY-MM-DD')
+    form.value.Reference = res.Reference || ''
     let temp = []
     if (res.details) {
       temp = res.details.filter(
@@ -1916,7 +1918,16 @@ const p3 = axios
   .then((response) => {
     const res = response.data
     if (res.code !== 1) return
-    userInfo.value = res.result || {}
+
+    if (res.result.users && res.result.users.length) {
+      userInfo.value = res.result.users[0]
+    } else if (res.result.id) {
+      userInfo.value = res.result || {}
+    } else if (Array.isArray(res.result) && res.result.length) {
+      userInfo.value = res.result[0] || {}
+    } else {
+      ElMessage.error('获取当前用户身份异常, 请联系管理员')
+    }
   })
 
 Promise.all([p1, p2, p3]).finally(() => {
@@ -2010,7 +2021,8 @@ input[type='number'] {
 }
 .screen {
   background-color: rgba(#fff, 1);
-  box-shadow: 0 0 0 1px rgba(255, 255, 255, .4) inset, 0 .5em 1em rgba(0, 0, 0, 0.6);
+  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4) inset,
+    0 0.5em 1em rgba(0, 0, 0, 0.6);
   max-width: 1600px;
   margin: 0 auto;