|
@@ -0,0 +1,312 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import { reactive, ref, watch, nextTick, onMounted } from "vue";
|
|
|
+import { FormRules, ElForm, ElMessage } from "element-plus";
|
|
|
+import { httpAdd , httpCreate} from "/@/api/InvoiceSales/invoiceApply";
|
|
|
+import RemoteSelect from "/@/components/RemoteSelect";
|
|
|
+import { httpInvoiceList } from "/@/api/InvoiceSales/invoiceApply";
|
|
|
+import { httpList as httpCompanylist } from "/@/api/parameter/finance";
|
|
|
+import OrderDialog from "./order-dialog.vue";
|
|
|
+import EditOrder from "./edit-order.vue";
|
|
|
+import { useResponseHandle } from "/@/hooks";
|
|
|
+import { useRouter } from "vue-router";
|
|
|
+import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
|
|
+import InvoiceTitle from "./invoice-title.vue";
|
|
|
+import { convertInvoiceTitle, convertInvoiceTitleData } from "./columns";
|
|
|
+import { useCompany } from "/@/hooks/core/useCompany";
|
|
|
+import ChooseForm from "./chooseForm/choose-form.vue";
|
|
|
+
|
|
|
+import { ADD_EDIT_FORM_RULES } from "./../../config/configs";
|
|
|
+import { xs_inv_type_list, useTypeOptions } from "/@/utils/status";
|
|
|
+
|
|
|
+const formRef = ref<InstanceType<typeof ElForm> | null>(null)
|
|
|
+enum FROM_TYPE {
|
|
|
+ order = "order",
|
|
|
+ invoice = "invoice"
|
|
|
+}
|
|
|
+
|
|
|
+const TYPE = ref<FROM_TYPE>(FROM_TYPE.order);
|
|
|
+
|
|
|
+const { companyList } = useCompany();
|
|
|
+const { push } = useRouter();
|
|
|
+
|
|
|
+
|
|
|
+const modelRef = ref<InstanceType<typeof OrderDialog>>(null);
|
|
|
+const editOrderRef = ref<InstanceType<typeof EditOrder>>(null);
|
|
|
+const responseHandle = useResponseHandle();
|
|
|
+const loading = ref(false);
|
|
|
+
|
|
|
+const { currentCompany } = useCompany();
|
|
|
+
|
|
|
+//最大开票金额
|
|
|
+const denomination = ref(0);
|
|
|
+
|
|
|
+const max = 150;
|
|
|
+
|
|
|
+const initform = {
|
|
|
+ companyNo: "", //销售方公司抬头
|
|
|
+ invtype: "", //开票类型
|
|
|
+ email: "", //邮箱
|
|
|
+ remark: "", //发票备注
|
|
|
+ exam_remark: "", //申请备注
|
|
|
+ orderArr: [], //开票销售订单明细 obj:sequenceNo//销售订单编码 inv_fee//销售订单开票金额,
|
|
|
+ companyType: "01",
|
|
|
+ platform_type: "",
|
|
|
+ buyer:""
|
|
|
+};
|
|
|
+
|
|
|
+const ruleForm = ref({ ...initform });
|
|
|
+const invoiceTypes = ref([]);
|
|
|
+const rules = reactive<FormRules>({ ...ADD_EDIT_FORM_RULES });
|
|
|
+
|
|
|
+function handleShowEditModal(_, row: any) {
|
|
|
+ editOrderRef.value.onDisplay({
|
|
|
+ row
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function menu_type_change() {
|
|
|
+ const { invtype } = ruleForm.value;
|
|
|
+ rules.email[0].required =
|
|
|
+ invtype === "special_electronic" || invtype === "electronic";
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//设置发票抬头详情
|
|
|
+const sellerInvoiceTitle = ref<Record<string, string>>({});
|
|
|
+const purchaserInvoiceTitle = ref<Record<string, string>>({});
|
|
|
+
|
|
|
+function handleInvoiceTitle(
|
|
|
+ _isSeller: boolean,
|
|
|
+ invoiceTitle: Record<string, string>
|
|
|
+) {
|
|
|
+
|
|
|
+ if (!invoiceTitle) {
|
|
|
+ if (_isSeller) {
|
|
|
+ return (sellerInvoiceTitle.value = {});
|
|
|
+ }
|
|
|
+
|
|
|
+ return (purchaserInvoiceTitle.value = {});
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_isSeller) {
|
|
|
+ //支持的开票方式
|
|
|
+ const { invoiceType, denomination: _denomination } = invoiceTitle;
|
|
|
+ denomination.value = Number(_denomination) * 10000;
|
|
|
+ const chunks = invoiceType.split(",");
|
|
|
+ ruleForm.value.invtype = "";
|
|
|
+
|
|
|
+ invoiceTypes.value = xs_inv_type_list.filter(({ value }) =>
|
|
|
+ chunks.includes(value)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ _isSeller
|
|
|
+ ? (sellerInvoiceTitle.value = convertInvoiceTitleData(
|
|
|
+ convertInvoiceTitle(invoiceTitle)
|
|
|
+ ))
|
|
|
+ : (purchaserInvoiceTitle.value = convertInvoiceTitleData( convertInvoiceTitle(invoiceTitle)));
|
|
|
+}
|
|
|
+
|
|
|
+const setSellerInvoiceTitle = handleInvoiceTitle.bind(null, true);
|
|
|
+const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
+
|
|
|
+async function handleCompanyChange(companyNo,isSeller = true) {
|
|
|
+ ruleForm.value[isSeller ? 'companyNo' : 'buyer'] = companyNo;
|
|
|
+ const { code, data, message } = await httpCompanylist({
|
|
|
+ companyNo
|
|
|
+ });
|
|
|
+
|
|
|
+ nextTick(() => {
|
|
|
+ if (formRef.value) { formRef.value.validateField("companyNo"); }
|
|
|
+ });
|
|
|
+
|
|
|
+ responseHandle({
|
|
|
+ code,
|
|
|
+ message,
|
|
|
+ handler: () => setSellerInvoiceTitle(data.list[0])
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+async function handleSupplierChange(name) {
|
|
|
+ ruleForm.value.buyer = name;
|
|
|
+
|
|
|
+ const { code, data, message } = await httpCompanylist({noRela:true});
|
|
|
+
|
|
|
+ responseHandle({
|
|
|
+ code,
|
|
|
+ message,
|
|
|
+ handler: () => {
|
|
|
+ const item = data.list.find(({ company_name }) => company_name === name);
|
|
|
+
|
|
|
+ console.log(data.list,name)
|
|
|
+ setPurchaserInvoiceTitle(item || {})
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+async function handleOpenInv({ orderArr,payNo}) {
|
|
|
+ try {
|
|
|
+ await formRef.value.validate();
|
|
|
+ const { invtype, email, remark, exam_remark } = ruleForm.value
|
|
|
+
|
|
|
+ loading.value = true;
|
|
|
+ const { code, message } = await httpCreate({ invtype, email, remark, exam_remark, orderArr, payNo });
|
|
|
+
|
|
|
+ loading.value = false;
|
|
|
+
|
|
|
+ responseHandle({
|
|
|
+ code,
|
|
|
+ message,
|
|
|
+ handler: () => push("/InvoiceSales/invoiceApply")
|
|
|
+ });
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => handleCompanyChange(currentCompany.value.companyNo));
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="addEditForm">
|
|
|
+ <el-form
|
|
|
+ ref="formRef"
|
|
|
+ v-loading="loading"
|
|
|
+ :model="ruleForm"
|
|
|
+ :rules="rules"
|
|
|
+ status-icon
|
|
|
+ size="small"
|
|
|
+ >
|
|
|
+ <el-row gutter="10">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item
|
|
|
+ label="销售方公司抬头"
|
|
|
+ prop="companyNo"
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ style="width: 100%"
|
|
|
+ placeholder="销售方公司抬头"
|
|
|
+ disabled
|
|
|
+ v-model="ruleForm.companyNo"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="c in companyList"
|
|
|
+ :key="c.companyCode"
|
|
|
+ :value="c.companyCode"
|
|
|
+ :label="c.companyName"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <InvoiceTitle :detail="sellerInvoiceTitle" />
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item
|
|
|
+ label="购买方公司抬头"
|
|
|
+ prop="companyNo"
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ style="width: 100%"
|
|
|
+ placeholder="购买方公司抬头"
|
|
|
+ disabled
|
|
|
+ v-model="ruleForm.buyer"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="c in companyList"
|
|
|
+ :key="c.companyCode"
|
|
|
+ :value="c.companyCode"
|
|
|
+ :label="c.companyName"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <InvoiceTitle v-if="ruleForm.buyer" :detail="purchaserInvoiceTitle" />
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="发票类型" prop="invtype">
|
|
|
+ <el-select
|
|
|
+ v-model="ruleForm.invtype"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="menu_type_change"
|
|
|
+ placeholder="发票类型"
|
|
|
+ no-data-text="请选择其他销售方公司"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="si in invoiceTypes"
|
|
|
+ :key="si.value"
|
|
|
+ :label="si.label"
|
|
|
+ :value="si.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="电子邮箱" prop="email">
|
|
|
+ <el-input v-model="ruleForm.email" placeholder="电子邮箱" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <!-- <el-form-item
|
|
|
+ label="平台类型"
|
|
|
+ prop="platform_type"
|
|
|
+ >
|
|
|
+ <el-switch
|
|
|
+ v-model="ruleForm.platform_type"
|
|
|
+ size="small"
|
|
|
+ active-text="toC"
|
|
|
+ inactive-text="toB"
|
|
|
+ active-value="2"
|
|
|
+ inactive-value="1"
|
|
|
+ />
|
|
|
+ </el-form-item>-->
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="18">
|
|
|
+ <el-form-item label="申请备注" prop="exam_remark">
|
|
|
+ <el-input
|
|
|
+ w-full
|
|
|
+ v-model="ruleForm.exam_remark"
|
|
|
+ :rows="5"
|
|
|
+ type="textarea"
|
|
|
+ maxlength="2000"
|
|
|
+ placeholder="申请备注"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="发票备注" prop="remark">
|
|
|
+ <div w-full>
|
|
|
+ <el-input
|
|
|
+ w-full
|
|
|
+ v-model="ruleForm.remark"
|
|
|
+ :rows="3"
|
|
|
+ type="textarea"
|
|
|
+ maxlength="2000"
|
|
|
+ show-word-limit
|
|
|
+ placeholder="发票备注"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="订单对账">
|
|
|
+ <ChooseForm @openInv="handleOpenInv" @get-buyer="buyer => {
|
|
|
+ handleSupplierChange(buyer);
|
|
|
+ }" :platformType="ruleForm.platform_type" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+:deep(.el-descriptions) {
|
|
|
+ padding: 0px !important;
|
|
|
+ padding-left: 30px !important;
|
|
|
+ padding-bottom: 10px !important;
|
|
|
+}
|
|
|
+</style>
|