|
@@ -1,72 +1,82 @@
|
|
|
<script setup lang="ts">
|
|
|
import { reactive, ref } from "vue";
|
|
|
-import { rules } from "./rules"
|
|
|
-import { cg_order_type_options, xs_inv_type_list } from "/@/utils/status"
|
|
|
-import { convertInvoiceTitle, convertInvoiceTitleData } from "./columns"
|
|
|
+import { cg_order_type_options, xs_inv_type_list, tax_list } from "/@/utils/status"
|
|
|
+import { ElButton, ElCol, ElForm, ElFormItem, ElMessage, ElOption, ElSelect, ElTooltip } from "element-plus"
|
|
|
import { httpCompanies } from "/@/api/invoiceInOut/productManager"
|
|
|
-import { ElCol, ElForm, ElFormItem, ElOption, ElSelect } from "element-plus"
|
|
|
import RemoteSelect from "/@/components/RemoteSelect";
|
|
|
import InvoiceTitle from "./InvoiceTitle.vue";
|
|
|
+import { rules } from "./rules"
|
|
|
+
|
|
|
+import { convertInvoiceTitle, convertInvoiceTitleData, createInitalData } from "./shared"
|
|
|
+import { useTask } from "/@/hooks/core"
|
|
|
+import { useRouter } from "vue-router"
|
|
|
+
|
|
|
+import ChooseGoodModal from "./ChooseGoodModal/index.vue"
|
|
|
+import ChildGoodEditModal from "./ChildGoodEditModal.vue";
|
|
|
+
|
|
|
|
|
|
import { httpInvoiceList } from "/@/api/InvoiceSales/invoiceApply";
|
|
|
+import { httpAdd, httpCatist } from "/@/api/invoiceInOut/productManager";
|
|
|
+import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
|
|
+
|
|
|
|
|
|
+const router = useRouter()
|
|
|
const formRef = ref<InstanceType<typeof ElForm> | null>(null)
|
|
|
|
|
|
-const formData = ref({
|
|
|
- companyNo: "",
|
|
|
- supplierNo: "",
|
|
|
- goodSource: "",
|
|
|
- goodCode: '',
|
|
|
- goodType: '',
|
|
|
- is_combind: "",
|
|
|
- invGoodName: "",
|
|
|
- afterTaxPrice: '',
|
|
|
- in_cost_status: '',
|
|
|
- beforeTaxPrice: '',
|
|
|
- goodName: "",
|
|
|
- spuCode: '',
|
|
|
- in_code: '',
|
|
|
- invType: '',
|
|
|
- in_tax: '',
|
|
|
- spec: '',
|
|
|
- unit: '',
|
|
|
- weight: '',
|
|
|
- fg: ''
|
|
|
+const state = reactive({
|
|
|
+ editVisible: false,
|
|
|
+ visible: false,
|
|
|
+ companies: [],
|
|
|
+ index: -1,
|
|
|
+ data: {}
|
|
|
})
|
|
|
|
|
|
-const state = reactive({
|
|
|
- companies: []
|
|
|
-})
|
|
|
+
|
|
|
+
|
|
|
+const createTask = useTask({ success(){ router.push('/invoiceInOut/productManager') } })
|
|
|
+const formData = ref(createInitalData())
|
|
|
|
|
|
const sellerInvoiceTitle = ref<Record<string, string>>({});
|
|
|
const purchaserInvoiceTitle = ref<Record<string, string>>({});
|
|
|
|
|
|
async function submit(){
|
|
|
+ if(formData.value.is_combind === '1' && formData.value.childArr.length === 0){
|
|
|
+ ElMessage.warning('请选择至少一个子商品')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if(formData.value.is_combind === '0'){
|
|
|
+ formData.value.childArr = []
|
|
|
+ }
|
|
|
+
|
|
|
try{
|
|
|
await formRef.value?.validate()
|
|
|
- console.log('joined~~~')
|
|
|
+ createTask.run(httpAdd({
|
|
|
+ ...formData.value,
|
|
|
+ childArr: formData.value.childArr.map(({ child_id, child_num }) => ({ child_id, child_num }))
|
|
|
+ }))
|
|
|
}catch(err){
|
|
|
console.log(err)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function handleInvoiceTitle(
|
|
|
- _isSeller: boolean,
|
|
|
- invoiceTitle: Record<string, string>
|
|
|
-) {
|
|
|
- if (!invoiceTitle) {
|
|
|
- if (_isSeller) { return (sellerInvoiceTitle.value = {}); }
|
|
|
- return (purchaserInvoiceTitle.value = {});
|
|
|
- }
|
|
|
-
|
|
|
+function handleInvoiceTitle(_isSeller: boolean, invoiceTitle: Record<string, string> ) {
|
|
|
if (_isSeller) {
|
|
|
- invoiceTitle = state.companies.find(item => item.companyNo === invoiceTitle)
|
|
|
+ invoiceTitle = state.companies.find(item => item.company_license === formData.value.seller_code)
|
|
|
+ formData.value.seller_name = invoiceTitle.company_name
|
|
|
//支持的开票方式
|
|
|
- const { invoiceType, denomination: _denomination } = invoiceTitle;
|
|
|
+ // const { invoiceType, denomination: _denomination } = invoiceTitle;
|
|
|
// const chunks = invoiceType.split(",");
|
|
|
// ruleForm.value.invtype = "";
|
|
|
// invoiceTypes.value = xs_inv_type_list.filter(({ value }) => chunks.includes(value));
|
|
|
+ // formData.value.seller_name =
|
|
|
+ } else{
|
|
|
+ formData.value.buyer_name = invoiceTitle.invoice_title
|
|
|
+ }
|
|
|
|
|
|
+ if (!invoiceTitle) {
|
|
|
+ if (_isSeller) { return (sellerInvoiceTitle.value = {}); }
|
|
|
+ return (purchaserInvoiceTitle.value = {});
|
|
|
}
|
|
|
|
|
|
_isSeller
|
|
@@ -75,13 +85,31 @@ function handleInvoiceTitle(
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
const setSellerInvoiceTitle = handleInvoiceTitle.bind(null, true);
|
|
|
const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
|
|
|
+
|
|
|
+function handleSubmit(list: any[]){
|
|
|
+ const currentIds = formData.value.childArr.map(({ id }) => id)
|
|
|
+ const appends: any[] = []
|
|
|
+
|
|
|
+ for(const item of list){
|
|
|
+ if(currentIds.includes(item.id)){ continue }
|
|
|
+ appends.push(item)
|
|
|
+ }
|
|
|
+
|
|
|
+ formData.value.childArr = [ ...formData.value.childArr, ...appends ]
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function handleChildGoodEdit(index: number){
|
|
|
+ state.index = index
|
|
|
+ state.editVisible = true
|
|
|
+ state.data = { ...formData.value.childArr[index] }
|
|
|
+}
|
|
|
+
|
|
|
(async function initialData(){
|
|
|
const result = await httpCompanies({ size: 10000 })
|
|
|
-
|
|
|
if(result.code == 0){
|
|
|
state.companies = [...result.data.list]
|
|
|
console.log(state.companies)
|
|
@@ -94,20 +122,21 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
ref="formRef"
|
|
|
:rules="rules"
|
|
|
:model="formData"
|
|
|
+ v-loading="createTask.loading"
|
|
|
>
|
|
|
<ElRow :gutter="10">
|
|
|
<ElCol :span="12">
|
|
|
- <ElFormItem label="销售方公司" prop="supplierNo">
|
|
|
+ <ElFormItem label="销售方公司" prop="seller_code">
|
|
|
<ElSelect
|
|
|
style="width: 100%"
|
|
|
placeholder="销售方公司"
|
|
|
- v-model="formData.supplierNo"
|
|
|
+ v-model="formData.seller_code"
|
|
|
@change="setSellerInvoiceTitle"
|
|
|
>
|
|
|
<ElOption
|
|
|
v-for="item in state.companies"
|
|
|
:label="item.company_name"
|
|
|
- :value="item.companyNo"
|
|
|
+ :value="item.company_license"
|
|
|
/>
|
|
|
</ElSelect>
|
|
|
</ElFormItem>
|
|
@@ -115,15 +144,15 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="12">
|
|
|
- <ElFormItem label="购买方公司" prop="companyNo">
|
|
|
+ <ElFormItem label="购买方公司" prop="buyer_code">
|
|
|
<RemoteSelect
|
|
|
is-root
|
|
|
style="width: 100%"
|
|
|
request-prop="name"
|
|
|
:api="httpInvoiceList"
|
|
|
- response-val-prop="id"
|
|
|
+ response-val-prop="invoice_code"
|
|
|
placeholder="购买方公司抬头"
|
|
|
- v-model:value="formData.companyNo"
|
|
|
+ v-model:value="formData.buyer_code"
|
|
|
response-label-prop="invoice_title"
|
|
|
@item-change="setPurchaserInvoiceTitle"
|
|
|
/>
|
|
@@ -133,29 +162,29 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
|
|
|
|
|
|
<ElCol :span="8">
|
|
|
- <ElFormItem label="商品来源" prop="goodSource">
|
|
|
+ <ElFormItem label="商品来源" prop="good_source">
|
|
|
<ElSelect
|
|
|
- @change="formData.goodCode = ''"
|
|
|
- v-model="formData.goodSource"
|
|
|
+ @change="formData.good_code = ''"
|
|
|
+ v-model="formData.good_source"
|
|
|
placeholder="商品来源"
|
|
|
style="width: 100%"
|
|
|
>
|
|
|
- <ElOption label="采销商品" value="0" />
|
|
|
- <ElOption label="非采销商品" value="1" />
|
|
|
+ <ElOption label="采销商品" value="1" />
|
|
|
+ <ElOption label="非采销商品" value="2" />
|
|
|
</ElSelect>
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="8">
|
|
|
- <ElFormItem label="商品编号" prop="spuCode">
|
|
|
- <ElInput v-model="formData.spuCode" placeholder="商品编号" />
|
|
|
+ <ElFormItem label="商品编号" prop="skuCode">
|
|
|
+ <ElInput v-model="formData.skuCode" placeholder="商品编号" />
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="8">
|
|
|
- <ElFormItem label="订单商品类型" prop="goodType">
|
|
|
+ <ElFormItem label="订单商品类型" prop="good_type">
|
|
|
<ElSelect
|
|
|
- v-model="formData.goodType"
|
|
|
+ v-model="formData.good_type"
|
|
|
placeholder="订单商品类型"
|
|
|
style="width: 100%"
|
|
|
>
|
|
@@ -184,8 +213,8 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="8">
|
|
|
- <ElFormItem label="发票商品名称" prop="invGoodName">
|
|
|
- <ElInput v-model="formData.invGoodName" placeholder="发票商品名称" />
|
|
|
+ <ElFormItem label="发票商品名称" prop="inv_good_name">
|
|
|
+ <ElInput v-model="formData.inv_good_name" placeholder="发票商品名称" />
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
@@ -196,14 +225,14 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="8">
|
|
|
- <ElFormItem label="商品代码" prop="goodCode">
|
|
|
- <ElInput v-model="formData.goodCode" placeholder="商品代码" />
|
|
|
+ <ElFormItem label="商品代码" prop="good_code">
|
|
|
+ <ElInput v-model="formData.good_code" placeholder="商品代码" />
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="8">
|
|
|
- <ElFormItem label="成本税前单价" prop="beforeTaxPrice">
|
|
|
- <ElInput v-model="formData.beforeTaxPrice" placeholder="成本税前单价" />
|
|
|
+ <ElFormItem label="成本税前单价" prop="unit_price">
|
|
|
+ <ElInput v-model="formData.unit_price" placeholder="成本税前单价" />
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
@@ -214,24 +243,24 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="8">
|
|
|
- <ElFormItem label="重量" prop="weight">
|
|
|
- <ElInput v-model="formData.weight" placeholder="重量" />
|
|
|
+ <ElFormItem label="重量" prop="unit_weight">
|
|
|
+ <ElInput v-model="formData.unit_weight" placeholder="重量" />
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="8">
|
|
|
- <ElFormItem label="成本税后单价" prop="afterTaxPrice">
|
|
|
+ <ElFormItem label="成本税后单价" prop="subunit_price">
|
|
|
<ElInput
|
|
|
- v-model="formData.afterTaxPrice"
|
|
|
+ v-model="formData.subunit_price"
|
|
|
placeholder="成本税后单价"
|
|
|
/>
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="6">
|
|
|
- <ElFormItem label="分光" prop="fg">
|
|
|
+ <ElFormItem label="分光" prop="spectral">
|
|
|
<ElInput
|
|
|
- v-model="formData.fg"
|
|
|
+ v-model="formData.spectral"
|
|
|
placeholder="分光"
|
|
|
style="width: 100%"
|
|
|
/>
|
|
@@ -239,9 +268,9 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="6">
|
|
|
- <ElFormItem label="发票类型" prop="invType">
|
|
|
+ <ElFormItem label="发票类型" prop="inv_type">
|
|
|
<ElSelect
|
|
|
- v-model="formData.invType"
|
|
|
+ v-model="formData.inv_type"
|
|
|
placeholder="发票类型"
|
|
|
style="width: 100%"
|
|
|
>
|
|
@@ -255,53 +284,57 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="6">
|
|
|
- <ElFormItem label="进项税目" prop="in_code">
|
|
|
+ <ElFormItem label="进项税目" prop="cat_code">
|
|
|
<RemoteSelect
|
|
|
- is-root
|
|
|
+ :api="httpCatist"
|
|
|
style="width: 100%"
|
|
|
- request-prop="name"
|
|
|
- :api="httpInvoiceList"
|
|
|
- response-val-prop="id"
|
|
|
+ request-prop="cat_name"
|
|
|
placeholder="进项税目"
|
|
|
- v-model:value="formData.in_code"
|
|
|
- response-label-prop="invoice_title"
|
|
|
- @item-change="setPurchaserInvoiceTitle"
|
|
|
+ response-val-prop="cat_code"
|
|
|
+ response-label-prop="cat_name"
|
|
|
+ v-model:value="formData.cat_code"
|
|
|
/>
|
|
|
+ <!-- <ElInput v-model="formData.cat_code" placeholder="进项税目" /> -->
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="6">
|
|
|
- <ElFormItem label="进项税率" prop="in_tax">
|
|
|
- <ElSelect
|
|
|
- v-model="formData.in_tax"
|
|
|
- placeholder="进项税率"
|
|
|
- style="width: 100%"
|
|
|
- > </ElSelect>
|
|
|
+ <ElFormItem label="进项税率" prop="cat_tax">
|
|
|
+ <ElSelect v-model="formData.cat_tax" placeholder="进项税率">
|
|
|
+ <ElOption v-for="tax in tax_list" v-bind="tax" />
|
|
|
+ </ElSelect>
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
|
|
|
<ElCol :span="6">
|
|
|
- <ElFormItem label="进项成本状态" prop="in_cost_status">
|
|
|
+ <ElFormItem label="进项成本状态" prop="basic_status">
|
|
|
<ElSelect
|
|
|
- v-mdoel="formData.in_cost_status"
|
|
|
+ v-model="formData.basic_status"
|
|
|
placeholder="进项成本状态"
|
|
|
>
|
|
|
- <ElOption label="真实成本信息" value="0" />
|
|
|
- <ElOption label="预估成本信息" value="1" />
|
|
|
+ <ElOption label="真实成本信息" value="1" />
|
|
|
+ <ElOption label="预估成本信息" value="2" />
|
|
|
</ElSelect>
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
</ElRow>
|
|
|
|
|
|
- <!--
|
|
|
- <ElRow>
|
|
|
+ <ElRow v-if="formData.is_combind == '1'">
|
|
|
<ElCol :span="24">
|
|
|
<ElFormItem label="子商品">
|
|
|
- <ElTable border size="small">
|
|
|
- <ElTableColumn label="比例" />
|
|
|
- <ElTableColumn label="商品编号" />
|
|
|
- <ElTableColumn label="商品类型" />
|
|
|
- <ElTableColumn label="商品名称" />
|
|
|
+ <ElTable border size="small" :data="formData.childArr">
|
|
|
+ <ElTableColumn label="比例" prop="child_num" width="60px" />
|
|
|
+
|
|
|
+ <ElTableColumn label="商品编号" prop="skuCode" />
|
|
|
+ <ElTableColumn label="商品类型" prop="good_type">
|
|
|
+ <template #="{ row }">
|
|
|
+ <ElTag size="small">
|
|
|
+ {{ cg_order_type_options.find(item => item.value == row.good_type)?.label }}
|
|
|
+ </ElTag>
|
|
|
+ </template>
|
|
|
+ </ElTableColumn>
|
|
|
+
|
|
|
+ <ElTableColumn label="商品名称" prop="goodName" />
|
|
|
|
|
|
<ElTableColumn width="80px">
|
|
|
<template #header>
|
|
@@ -312,18 +345,52 @@ const setPurchaserInvoiceTitle = handleInvoiceTitle.bind(null, false);
|
|
|
size="small"
|
|
|
type="primary"
|
|
|
:icon="useRenderIcon('add')"
|
|
|
+ @click="state.visible = true"
|
|
|
/>
|
|
|
</div>
|
|
|
</template>
|
|
|
+
|
|
|
+ <template #="{ $index }">
|
|
|
+ <ElTooltip content="删除" placement="top">
|
|
|
+ <ElButton
|
|
|
+ link
|
|
|
+ size="small"
|
|
|
+ type="danger"
|
|
|
+ :icon="useRenderIcon('delete')"
|
|
|
+ @click="formData.childArr.splice($index, 1)"
|
|
|
+ />
|
|
|
+ </ElTooltip>
|
|
|
+
|
|
|
+ <ElTooltip content="编辑" placement="top">
|
|
|
+ <ElButton
|
|
|
+ link
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ :icon="useRenderIcon('edits')"
|
|
|
+ @click="handleChildGoodEdit($index)"
|
|
|
+ />
|
|
|
+ </ElTooltip>
|
|
|
+ </template>
|
|
|
</ElTableColumn>
|
|
|
</ElTable>
|
|
|
</ElFormItem>
|
|
|
</ElCol>
|
|
|
- </ElRow> -->
|
|
|
- <!-- <Modal /> -->
|
|
|
+ </ElRow>
|
|
|
|
|
|
<div class="w-full flex justify-end">
|
|
|
<ElButton type="primary" @click="submit">保存</ElButton>
|
|
|
</div>
|
|
|
+
|
|
|
+ <ChooseGoodModal
|
|
|
+ v-model:visible="state.visible"
|
|
|
+ @submit="handleSubmit"
|
|
|
+ />
|
|
|
+
|
|
|
+ <ChildGoodEditModal
|
|
|
+ v-model:visible="state.editVisible"
|
|
|
+ :index="state.index"
|
|
|
+ :data="state.data"
|
|
|
+ @submit="(index, data) => formData.childArr[index] = { ...data }"
|
|
|
+ />
|
|
|
</ElForm>
|
|
|
</template>
|