Quellcode durchsuchen

feat: 添加开发票功能,支持根据总单ID拉取拆分初始化数据

xieyong vor 3 Wochen
Ursprung
Commit
854ecb988b

+ 11 - 0
src/api/financialManage/invoiceManage/index.js

@@ -92,4 +92,15 @@ export async function  initInvoiceByStatementId(data) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
+}
+
+// 开发票-根据总单ID获取拆分初始化数据
+export async function splitInitAPI(parentInvoiceId) {
+  const res = await request.get(
+    `/eom/fininvoiceapply/splitInit/${parentInvoiceId}`
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 } 

+ 29 - 4
src/views/financialManage/invoiceManage/components/addOrEditDialogNew.vue

@@ -457,7 +457,8 @@
     invoiceApplyInfoV2API,
     invoiceApplyCreateAPI,
     invoiceApplyUpdateV2API,
-    initInvoiceByStatementId
+    initInvoiceByStatementId,
+    splitInitAPI
   } from '@/api/financialManage/invoiceManage';
   import { getpurchaseorderDetail } from '@/api/purchasingManage/purchaseOrder';
   import { getSaleOrderDetail } from '@/api/saleManage/saleorder';
@@ -756,11 +757,16 @@
     methods: {
       //从发票管理新增发票初始化
       async init(row = {}, type) {
-        this.businessId = row.id || '';
-        this.title = type == 'add' ? '新增' : '修改';
+        this.businessId = type == 'reissue' ? '' : row.id || '';
+        this.title =
+          type == 'add'
+            ? '新增'
+            : type == 'reissue'
+            ? '开发票'
+            : '修改';
         console.log('row', row, type);
         this.dialogType = type;
-        if (type == 'add') {
+        if (type == 'add' || type == 'reissue') {
           this.form.applyDeptId = this.user.info.groupId;
           this.form.applyDeptName = this.user.info.groupName;
           this.form.applyUserId = this.user.info.userId;
@@ -773,6 +779,25 @@
             this.enterprisePage.push(...res.list);
             this.enterpriseChange(this.enterprisePage[0]?.name);
           });
+          // 开发票:根据总单ID拉取拆分初始化数据,预填到表单上
+          if (type == 'reissue' && row.id) {
+            try {
+              const data = await splitInitAPI(row.id);
+              data.type = Number(data.type);
+              Object.keys(data || {}).forEach((k) => {
+                this.$set(this.form, k, data[k]);
+              });
+              this.$nextTick(() => {
+                if (this.form.sourceType == 99) {
+                  this.$refs.tableInfoNoOrderRef?.setValue(this.form);
+                } else {
+                  this.$refs.tableInfoRef?.putValue(this.form);
+                }
+              });
+            } catch (e) {
+              console.error('splitInit failed:', e);
+            }
+          }
         } else {
           await this.getInfo(row.id);
         }

+ 16 - 0
src/views/financialManage/invoiceManage/index.vue

@@ -66,6 +66,15 @@
             >
               提交
             </el-link>
+            <el-link
+              type="primary"
+              :underline="false"
+              icon="el-icon-document-add"
+              v-if="!!row.reInvoiceFlag"
+              @click="handleReissue(row)"
+            >
+              开发票
+            </el-link>
             <el-popconfirm
               class="ele-action"
               title="确定要删除此信息吗?"
@@ -381,6 +390,13 @@
           this.$refs.addOrEditDialogNewRef.init(row, type);
         });
       },
+      //开发票:以当前总单ID拉取拆分初始化数据,复用新增/修改弹框
+      handleReissue(row) {
+        this.addOrEditDialogNewFlag = true;
+        this.$nextTick(() => {
+          this.$refs.addOrEditDialogNewRef.init(row, 'reissue');
+        });
+      },
       //详情
       handleDetail(row = {}, type) {
         this.detailDialogFlag = true;