ソースを参照

Merge branch 'sit' of http://120.46.155.214:3000/xiaodai2022/accout-vue3-ui into sit

xiaodai2017 2 年 前
コミット
af3fb3d8ee

+ 1 - 1
src/components/ApprovalNode/src/default.vue

@@ -43,7 +43,7 @@ watch(
       <ElFormItem label="审核状态" prop="status">
         <el-select placeholder="请选择审核状态" v-model="formData.status">
           <el-option :value="approveValue" label="通过" />
-          <el-option :value="rejectValue" label="不通过" />
+          <el-option :value="rejectValue" label="驳回" />
         </el-select>
       </ElFormItem>
 

+ 3 - 1
src/components/Invoice/src/index.vue

@@ -6,6 +6,7 @@ import { httpSaleInvoice, httpPurchaseInvoice } from "/@/api/invoice";
 import { invoiceTypeList } from "/@/utils/status";
 
 type InvoiceType = "sale" | "purchase";
+const emit = defineEmits(["getInvoiceData"]);
 
 const prop = ref<Partial<InvoiceDetail>>({});
 
@@ -22,7 +23,8 @@ const {
   loading: invoiceLoading,
   setData: setnvoiceDetail
 } = useAsync<InvoiceDetail>({
-  initalData: {}
+  initalData: {},
+  success: () => emit("getInvoiceData", unref(invoiceDetail))
 });
 
 const title = computed(() => {

+ 5 - 1
src/router/index.ts

@@ -106,8 +106,12 @@ router.beforeEach((to: toRouteType, _from, next) => {
         });
       }, 500);
     }
+
     // 刷新
-    if (usePermissionStoreHook().wholeMenus.length === 0)
+    if (
+      usePermissionStoreHook().wholeMenus.length === 0 &&
+      to.path !== "/login"
+    )
       initRouter()
         .then((router: Router) => {
           if (!useMultiTagsStoreHook().getMultiTagsCache) {

+ 8 - 3
src/store/modules/user.ts

@@ -6,8 +6,6 @@ import { routerArrays } from "/@/layout/types";
 import { storageSession } from "@pureadmin/utils";
 import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
 import { getRelaComNo } from "/@/utils/auth";
-import { ElMessageBox } from "element-plus";
-import { h } from "vue";
 
 import {
   getLogin,
@@ -134,11 +132,18 @@ export const useUserStore = defineStore({
         this.currentCompany = this.isSuperUser
           ? ""
           : this.companyList[index >= 0 ? index : 0];
+      } else {
+        throw new Error();
       }
     },
     // 获取当前账号菜单数据
     async postMenuList(form) {
-      await this.requesetUserInfo();
+      try {
+        await this.requesetUserInfo();
+      } catch (err) {
+        window.location.hash = "login";
+      }
+
       return new Promise((resolve, reject) => {
         getAsyncRoutes(form)
           .then((res: resType) => {

+ 1 - 0
src/views/InvoiceSales/invoiceApply/components/add-edit-form/add-edit-form.vue

@@ -127,6 +127,7 @@ function handleSave() {
     }
 
     const { code, message } = await httpAdd({
+      relaComNo: ruleForm.value.companyNo,
       ...ruleForm.value,
       ...generatorOrderArr()
     });

+ 16 - 15
src/views/InvoiceSales/invoiceApply/components/execl-files-upload/index.vue

@@ -18,7 +18,7 @@ const All_INV_TYPE = xs_inv_type_list.map(({ label }) => label);
 
 const row = ref(1);
 
-const createInvErrorMessage = (row: number) =>
+const createInvErrorMessage = (row: string) =>
   `导入数据第 ${row} 行 发票类型格式不正确,发票类型必须为${All_INV_TYPE.join(
     ","
   )}`;
@@ -57,18 +57,7 @@ const Uploadsuccess = ({ results, header }) => {
     b.forEach((si, sii) => {
       model["value" + sii] = si + "";
     });
-
-    const type = model["value1"].trim();
-
-    if (!All_INV_TYPE.includes(type)) {
-      ElMessage.error(createInvErrorMessage(row.value));
-      row.value = 1;
-      tableData.value = [];
-      break;
-    }
-
     tableData.value.push(model);
-    row.value += 1;
   }
 
   loading.value = false;
@@ -79,6 +68,7 @@ const handleSubmit = async () => {
   loading.value = true;
 
   const data = [];
+  const invErrors: any[] = [];
 
   tableData.value.forEach(key => {
     const obj: Record<string, string> = {};
@@ -92,14 +82,18 @@ const handleSubmit = async () => {
 
   let checked = true;
 
-  data.forEach(item => {
+  data.forEach((item, index) => {
     const { inv_type } = item;
 
     const invType = xs_inv_type_list.find(
       ({ label }) => label === inv_type.trim()
     );
 
-    item.inv_type = invType.value;
+    if (invType) {
+      item.inv_type = invType.value;
+    } else {
+      invErrors.push(index + 1);
+    }
 
     if (item.inv_type.indexOf("电子") >= 0 && !item.check_code) checked = false;
   });
@@ -110,6 +104,12 @@ const handleSubmit = async () => {
     return;
   }
 
+  if (invErrors.length > 0) {
+    ElMessage.error(createInvErrorMessage(invErrors.join(",")));
+    loading.value = false;
+    return;
+  }
+
   const { code, message } = await httpUpload({ data });
   loading.value = false;
   responseHandle({
@@ -128,6 +128,7 @@ const cancel = () => {
   tableData.value = [];
   row.value = 1;
 };
+
 defineExpose({
   onDisplay: () => ((visible.value = true), (tableData.value = []))
 });
@@ -136,7 +137,7 @@ defineExpose({
 <template>
   <el-dialog
     v-model="visible"
-    title="导入表格数据"
+    title="批量导入财务开票结果(发票申请)"
     width="1040px"
     top="8vh"
     center

+ 3 - 1
src/views/InvoiceSales/invoiceApply/index.vue

@@ -10,7 +10,6 @@ import { useRouter } from "vue-router";
 import { httpSetPost, httpStatus } from "/@/api/InvoiceSales/invoiceApply";
 import { useAsync } from "/@/hooks/core/useAsync";
 import ExeclUpload from "./components/execl-files-upload/index.vue";
-import { ElMessage } from "element-plus";
 import { httpRequsetExport } from "/@/utils/export";
 import { template } from "./config/xls-template";
 import { writeFile, utils } from "xlsx";
@@ -97,18 +96,21 @@ function onDownloadTemplate() {
         <ElButton
           v-if="hasPermissionWithCode('026')"
           :icon="useRenderIcon('arrow-up-line')"
+          size="small"
           @click="() => onDownloadOpenInv()"
           >开票信息导出</ElButton
         >
         <ElButton
           v-if="hasPermissionWithCode('027')"
           :icon="useRenderIcon('arrow-down-line')"
+          size="small"
           @click="() => onDownloadTemplate()"
           >下载发票信息导入模板</ElButton
         >
         <ElButton
           v-if="!isSuperUser && hasPermissionWithCode('028')"
           @click="() => execlUploadRef.onDisplay()"
+          size="small"
           >批量导入财务开票结果(发票申请)</ElButton
         >
       </template>

+ 6 - 6
src/views/InvoiceSales/returnTicket/components/approval-pending.vue

@@ -49,7 +49,7 @@ const rules = reactive({
   ],
   remark: [
     {
-      required: false,
+      required: true,
       trigger: "change",
       message: "请输入备注"
     }
@@ -121,10 +121,10 @@ watchEffect(() => (formData.return_type = props.isJs ? "1" : "2"));
 
 watchEffect(() => {
   const { invType, isOutMonth } = props;
-  //类型是否跨月
+
+  //类型和跨月
   outMonthAndPaper.value =
-    String(isOutMonth) === "1" &&
-    (invType === "normal" || invType === "special");
+    (isOutMonth && invType === "normal") || invType === "special";
 
   //校验码是否必填
   rules.checkCode[0].required =
@@ -147,7 +147,7 @@ watchEffect(() => {
       </el-select>
     </el-form-item>
 
-    <template v-if="formData.status !== '3' || outMonthAndPaper">
+    <template v-if="formData.status !== '3' && !outMonthAndPaper">
       <el-form-item label="退票方式" prop="return_type">
         <el-select
           w-300px
@@ -214,7 +214,7 @@ watchEffect(() => {
           prop="subtotal_fee"
           placeholder="请输入税前金额"
         >
-          <el-input-number v-model="formData.subtotal_fee" />
+          <el-input-number v-model="formData.subtotal_fee" :max="0" />
         </el-form-item>
       </div>
     </template>

+ 26 - 19
src/views/InvoiceSales/returnTicket/detail.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { computed } from "vue";
+import { computed, ref } from "vue";
 import { useDetail } from "/@/hooks/core/useDetail";
 import CreateReturnForm from "./components/return-form.vue";
 import BasicDescriptions from "/@/components/BasicDescriptions";
@@ -20,6 +20,8 @@ import {
 const { push } = useRouter();
 
 const pageName = "returnTicketDetail";
+const orginInvData = ref<any>({});
+
 const { hasPermissionWithCode } = usePermission(pageName);
 
 const { id, isDetail, collapses, title } = useDetail({
@@ -69,30 +71,31 @@ const inv_type = computed(() => {
   return inv_type;
 });
 
-function handleApproval(_data) {
+function handleApproval(_data, isOutMonthAndPapar = false) {
+  console.log(orginInvData.value);
+
+  const { inv_code, inv_number, open_date, inv_subtotal } = orginInvData.value;
+
+  const _orginInvData = {
+    invCode: inv_code,
+    invNum: inv_number,
+    open_date,
+    subtotal_fee: inv_subtotal
+  };
+
   const params = {
+    returnCode: id.value,
     ..._data,
-    returnCode: id.value
+    ...(isOutMonthAndPapar ? _orginInvData : {})
   };
 
+  console.log(params);
+
   approval(httpStatus(params));
 }
 
-const handleCreate = (_data, isOutMonthOrPapar = false) => {
-  const { inv_number, inv_code, open_time } = data.value;
-
-  const params = {
-    inv_number,
-    inv_code,
-    open_time
-  };
-
-  create(
-    httpAdd({
-      ..._data,
-      ...(isOutMonthOrPapar ? params : {})
-    })
-  );
+const handleCreate = _data => {
+  create(httpAdd(_data));
 };
 
 if (isDetail.value) detail(httpDetail({ returnCode: id.value }));
@@ -115,7 +118,11 @@ if (isDetail.value) detail(httpDetail({ returnCode: id.value }));
 
           <template v-if="isDetail">
             <ElCollapseItem name="2" title="发票详情" v-if="data.inv_number">
-              <Invoice type="sale" :inv-number="data.inv_number" />
+              <Invoice
+                type="sale"
+                :inv-number="data.inv_number"
+                @get-invoice-data="data => (orginInvData = data)"
+              />
             </ElCollapseItem>
             <!-- -->
 

+ 2 - 2
src/views/purchase/ticketReturn/components/execl-files-upload/columns-config.ts

@@ -7,14 +7,14 @@ const initheaders = [
 ];
 
 export const mapProp = {
-  value0: "supplierNo",
+  value0: "companyNo",
   value1: "hpNo",
   value2: "payNo",
   value3: "status",
   value4: "remark"
 };
 
-export const requireHeaders = ["dzNo", "supplierNo", "hpNo", "status"];
+export const requireHeaders = ["payNo", "companyNo", "hpNo", "status"];
 
 const columns = () => {
   const list: any[] = [

+ 37 - 10
src/views/purchase/ticketReturn/components/execl-files-upload/index.vue

@@ -4,7 +4,7 @@ import { ElMessage } from "element-plus";
 import { execlUpload } from "/@/components/execlUpload";
 import { httpBatchimport } from "/@/api/purchase/ticketReturn";
 import { useResponseHandle } from "/@/hooks";
-import { result } from "lodash-unified";
+import { useCompany } from "/@/hooks/core/useCompany";
 
 import {
   initheaders,
@@ -19,6 +19,8 @@ const tableData = ref([]);
 const columnsConfig = columns();
 const emit = defineEmits(["onSuccess"]);
 
+const { currentCompany } = useCompany();
+
 const responseHandle = useResponseHandle();
 
 const Uploadsuccess = ({ results, header }) => {
@@ -49,16 +51,15 @@ const Uploadsuccess = ({ results, header }) => {
   tableData.value = [];
 
   try {
-    results.forEach(v1 => {
+    for (const v1 of results) {
       const b = Object.values(v1);
       let model = {};
       b.forEach((si, sii) => {
         model["value" + sii] = si + "";
       });
       tableData.value.push(model);
-    });
+    }
     loading.value = false;
-    console.log(result);
   } catch (err) {
     return err;
   }
@@ -71,6 +72,7 @@ const handleSubmit = async () => {
   const data = [];
   const errorStatus = [];
   const errorHp = [];
+  const errorDz = [];
 
   tableData.value.forEach((key, index) => {
     const obj: Record<string, string> = {};
@@ -88,23 +90,25 @@ const handleSubmit = async () => {
       } else if (prop === "hpNo") {
         if (!value) errorHp.push(index + 1);
         obj[prop] = value;
+      } else if (prop === "payNo") {
+        if (!value) errorDz.push(index + 1);
+        obj[prop] = value;
       } else {
         obj[prop] = value;
       }
-
-      delete obj["supplierNo"];
-      delete obj["payNo"];
     }
     data.push(obj);
   });
 
-  console.log(errorStatus);
+  const buyers = data.map(({ companyNo }) => companyNo);
+  const setBuyers = [...new Set(buyers)];
 
   if (errorStatus.length > 0) {
     ElMessage.error(
       `第 ${errorStatus.join(",")} 行审核状态格式不正确,应该为'通过',或'驳回'`
     );
     loading.value = false;
+    return;
   }
 
   if (errorHp.length > 0) {
@@ -112,15 +116,38 @@ const handleSubmit = async () => {
       `第 ${errorHp.join(",")} 行格式不正确,回票申请编号为必填项`
     );
     loading.value = false;
+    return;
   }
 
-  console.log(data);
+  if (errorDz.length > 0) {
+    ElMessage.error(`第 ${errorDz.join(",")} 行格式不正确,对账编号为必填项`);
+    loading.value = false;
+    return;
+  }
+
+  if (setBuyers.length > 1) {
+    ElMessage.error("买方公司编码不一致");
+    loading.value = false;
+    return;
+  }
+
+  if (setBuyers[0] !== currentCompany.value.companyNo) {
+    ElMessage.error("买方公司编码与当前选择的公司不一致");
+    loading.value = false;
+    return;
+  }
+
+  data.forEach(item => {
+    delete item["payNo"];
+    delete item["companyNo"];
+  });
 
   const { code, message } = await httpBatchimport({
     list: data
   });
 
   loading.value = false;
+
   responseHandle({
     code,
     message,
@@ -142,7 +169,7 @@ defineExpose({
 <template>
   <el-dialog
     v-model="visible"
-    title="导入表格数据"
+    title="批量导入认证结果"
     width="1040px"
     top="8vh"
     center

+ 6 - 3
src/views/purchase/ticketReturn/index.vue

@@ -74,19 +74,22 @@ function onDownloadTemplate() {
     >
       <template #content_header>
         <ElButton
-          :icon="useRenderIcon('arrow-up-line')"
+          size="small"
+          :icon="useRenderIcon('arrow-down-line')"
           @click="() => handleDownload()"
           >导出回票数据</ElButton
         >
 
         <ElButton
+          size="small"
           :icon="useRenderIcon('arrow-up-line')"
           @click="() => execelUploadRef.onDisplay()"
-          >批量导入审核结果</ElButton
+          >批量导入认证结果</ElButton
         >
 
         <ElButton
-          :icon="useRenderIcon('arrow-up-line')"
+          size="small"
+          :icon="useRenderIcon('arrow-down-line')"
           @click="() => onDownloadTemplate()"
           >下载回票批量申请模板</ElButton
         >

+ 1 - 3
src/views/supply/orderRecord/config/content.config.ts

@@ -8,9 +8,7 @@ import { renderProp } from "/@/utils/columnRenderHelper";
 const columns = [
   {
     type: "selection",
-    minWidth: 55,
-    align: "left",
-    hide: ({ checkList }) => !checkList.includes("勾选列")
+    align: "left"
   },
   {
     label: "序号",

+ 10 - 0
src/views/supply/orderRecord/config/xls-template.ts

@@ -0,0 +1,10 @@
+export const template = {
+  卖方公司编码: "",
+  对账编号: "",
+  发票类型: "",
+  发票代码: "",
+  发票号码: "",
+  发票税前金额: "",
+  开票日期: "",
+  "校验码(电子票必填,全电票不需要)": ""
+};

+ 49 - 1
src/views/supply/orderRecord/index.vue

@@ -1,13 +1,19 @@
 <script setup lang="ts">
+import { ref } from "vue";
 import { useRouter } from "vue-router";
+import { utils, writeFile } from "xlsx";
+import { template } from "./config/xls-template";
 import contentConfig from "./config/content.config";
 import searchConfig from "./config/search.config";
+import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
 import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
+import { ElMessage } from "element-plus";
 
 const PageName = "supplyOrderRecord";
 const baseUrl = "/supply/supplyOrderRecordDetail";
 
 const { push } = useRouter();
+const selectlist = ref<any[]>([]);
 
 const hooks: PageHooks = {
   pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
@@ -19,6 +25,38 @@ const events: PageEvents = {
     create: () => push(baseUrl)
   }
 };
+
+//导出模板
+function onDownloadTemplate() {
+  if (selectlist.value.length === 0) {
+    ElMessage.error("至少勾选一条对账单");
+    return;
+  }
+
+  const _data: any = [];
+  for (const { status, payNo, supplierNo } of selectlist.value) {
+    if (String(status) !== "2") {
+      ElMessage.error(`对账单 ${payNo},未通过审核`);
+      return;
+    } else {
+      _data.push({
+        ...template,
+        ["卖方公司编码"]: supplierNo,
+        ["对账编号"]: payNo
+      });
+    }
+  }
+
+  //创建数据表
+  const workBook = utils.book_new();
+  const workSheet = utils.json_to_sheet(_data);
+  utils.book_append_sheet(workBook, workSheet, "sheet");
+
+  //导出模板
+  writeFile(workBook, "批量开票申请模板.xlsx", {
+    bookType: "xlsx"
+  });
+}
 </script>
 
 <template>
@@ -28,6 +66,16 @@ const events: PageEvents = {
       :events="events"
       :contentConfig="contentConfig"
       :search-config="searchConfig"
-    />
+      @content-select-change="items => (selectlist = items)"
+    >
+      <template #content_header>
+        <ElButton
+          size="small"
+          :icon="useRenderIcon('arrow-down-line')"
+          @click="() => onDownloadTemplate()"
+          >下载批量开票模板</ElButton
+        >
+      </template>
+    </PageContainer>
   </PageAuth>
 </template>

+ 41 - 18
src/views/supply/ticketReturn/components/execl-files-upload/index.vue

@@ -24,7 +24,7 @@ const allTypes = cg_inv_type_list.map(({ label }) => label);
 
 const row = ref(1);
 
-const createInvErrorMessage = (row: number) =>
+const createInvErrorMessage = (row: string) =>
   `导入数据第 ${row} 行 发票类型格式不正确,发票类型必须为${allTypes.join(",")}`;
 
 const { currentCompany } = useCompany();
@@ -64,19 +64,6 @@ const Uploadsuccess = ({ results, header }) => {
     b.forEach((si, sii) => {
       model["value" + sii] = si + "";
     });
-
-    const type = model["value2"];
-
-    if (!allTypes.includes(type.trim())) {
-      ElMessage({
-        type: "error",
-        message: createInvErrorMessage(row.value)
-      });
-
-      tableData.value = [];
-      return;
-    }
-
     tableData.value.push(model);
 
     row.value = row.value + 1;
@@ -102,18 +89,54 @@ const handleSubmit = async () => {
     data.push(obj);
   });
 
-  data.forEach(row => {
+  const typeErrors: string[] = [];
+
+  data.forEach((row, index) => {
     const source = row.invoiceType.trim();
     const target = cg_inv_type_list.find(({ label }) => label === source);
-    row.invoiceType = target.value;
+    if (!target) {
+      typeErrors.push(String(index + 1));
+    } else {
+      row.invoiceType = target.value;
+    }
+  });
+
+  if (typeErrors.length > 0) {
+    ElMessage({
+      type: "error",
+      message: createInvErrorMessage(typeErrors.join(","))
+    });
+    loading.value = false;
+    return;
+  }
+
+  const buyers = data.map(({ supplierNo }) => supplierNo);
+  const setBuyers = [...new Set(buyers)];
+
+  if (setBuyers.length > 1) {
+    ElMessage.error("卖方公司编码不一致");
+    loading.value = false;
+    return;
+  }
+
+  if (setBuyers[0] !== currentCompany.value.companyNo) {
+    ElMessage.error("卖方公司编码与当前选择的公司不一致");
+    loading.value = false;
+    return;
+  }
+
+  data.forEach(item => {
+    delete item["supplierNo"];
   });
 
   const { code, message } = await httpBatchAdd({
     list: data,
-    companyNo: currentCompany.value.companyNo
+    companyNo: currentCompany.value.companyNo,
+    relaComNo: currentCompany.value.companyNo
   });
 
   loading.value = false;
+
   responseHandle({
     code,
     message,
@@ -135,7 +158,7 @@ defineExpose({
 <template>
   <el-dialog
     v-model="visible"
-    title="导入表格数据"
+    title="导入批量开票数据"
     width="1040px"
     top="8vh"
     center

+ 5 - 25
src/views/supply/ticketReturn/index.vue

@@ -10,15 +10,12 @@ import { httpRequsetExport } from "/@/utils/export";
 import { useCompany } from "/@/hooks/core/useCompany";
 import { PageContent } from "/@/components/PageContent";
 import ExeclUpoad from "./components/execl-files-upload/index.vue";
-import { utils, writeFile } from "xlsx";
-import { template } from "./config/xls-template";
 
 const PageName = "supplyTicketReturn";
 const baseUrl = "/supply/supplyTicketReturnDetail";
 const invStatus = ["3", "4", "5", "6", "9", "10", "12"];
 
 const { push } = useRouter();
-
 const invoiceModalRef = ref<InstanceType<typeof InvoiceModal>>(null);
 const execelUploadRef = ref<InstanceType<typeof ExeclUpoad>>(null);
 const pageContentRef = ref<InstanceType<typeof PageContent>>(null);
@@ -46,19 +43,6 @@ async function handleDownload() {
     }
   });
 }
-
-//导出模板
-function onDownloadTemplate() {
-  //创建数据表
-  const workBook = utils.book_new();
-  const workSheet = utils.json_to_sheet([template]);
-  utils.book_append_sheet(workBook, workSheet, "sheet");
-
-  //导出模板
-  writeFile(workBook, "批量开票申请模板.xlsx", {
-    bookType: "xlsx"
-  });
-}
 </script>
 
 <template>
@@ -72,21 +56,17 @@ function onDownloadTemplate() {
     >
       <template #content_header>
         <ElButton
-          :icon="useRenderIcon('arrow-up-line')"
+          size="small"
+          :icon="useRenderIcon('arrow-down-line')"
           @click="() => handleDownload()"
-          >导出开票数据</ElButton
+          >导出对账开票数据</ElButton
         >
 
         <ElButton
+          size="small"
           :icon="useRenderIcon('arrow-up-line')"
           @click="() => execelUploadRef.onDisplay()"
-          >导入批量开票数据</ElButton
-        >
-
-        <ElButton
-          :icon="useRenderIcon('arrow-down-line')"
-          @click="() => onDownloadTemplate()"
-          >下载批量开票模板</ElButton
+          >批量创建开票数据</ElButton
         >
       </template>