add
This commit is contained in:
parent
9270206010
commit
8b9752234b
@ -5,3 +5,9 @@ export function apiQuotationDetailLists(params: any) {
|
||||
return request.get({ url: '/quotation.quotation_detail/lists', params })
|
||||
}
|
||||
|
||||
|
||||
// 删除报价明细列表
|
||||
export function apiQuotationDetailDelete(params: any) {
|
||||
return request.post({ url: '/quotation.quotation_detail/delete', params })
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="省" property="province_name" />
|
||||
<el-table-column label="市" property="city_name" />
|
||||
<el-table-column label="区" property="area_name" />
|
||||
<!-- <el-table-column label="市" property="city_name" />
|
||||
<el-table-column label="区" property="area_name" /> -->
|
||||
<el-table-column label="职务" prop="master_position" show-overflow-tooltip />
|
||||
<el-table-column label="电话" prop="master_phone" show-overflow-tooltip />
|
||||
<el-table-column label="手机" prop="master_telephone" show-overflow-tooltip />
|
||||
@ -43,7 +43,7 @@
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { usePaging } from "@/hooks/usePaging"
|
||||
import { useDictData } from "@/hooks/useDictOptions"
|
||||
|
@ -54,7 +54,7 @@
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" label-align="left" align="left" label-class-name="my-label"> {{
|
||||
formData.remark
|
||||
}}</el-descriptions-item>
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="附件" label-align="left" align="left" label-class-name="my-label">
|
||||
<div v-if="formData.annex.length > 0">
|
||||
<div v-for="(item, index) in formData.annex" style="margin-left: 5px;display: block;">
|
||||
@ -78,7 +78,7 @@
|
||||
<el-table-column label="参数说明" prop="product_parameter_description" show-overflow-tooltip />
|
||||
<el-table-column label="单位" prop="product_unit" show-overflow-tooltip />
|
||||
<el-table-column label="数量" prop="num" show-overflow-tooltip />
|
||||
<el-table-column label="税率" prop="tax_rate" show-overflow-tooltip />
|
||||
<el-table-column label="税率" prop="tax_rate_text" show-overflow-tooltip />
|
||||
<el-table-column label="含税单价" prop="tax_inclusive_price" show-overflow-tooltip />
|
||||
<el-table-column label="不含税金额" prop="tax_exclusive_amount" show-overflow-tooltip />
|
||||
<el-table-column label="含税金额" prop="tax_inclusive_amount" show-overflow-tooltip />
|
||||
@ -202,7 +202,7 @@ defineExpose({
|
||||
<style lang="scss" scoped>
|
||||
.tit {
|
||||
font-size: 1.2em;
|
||||
margin-bottom: 10px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
:deep(.my-label) {
|
||||
|
@ -48,8 +48,8 @@
|
||||
<el-col :span="8">
|
||||
<el-form-item label="含税金额" prop="amount_including_tax"
|
||||
:rules="[{ required: true, message: '不可为空', trigger: 'change' }]">
|
||||
<el-input v-model="formData.amount_including_tax" disabled clearable placeholder="请输入含税金额"
|
||||
@input="amountinput" />
|
||||
<el-input v-model="formData.amount_including_tax" disabled clearable
|
||||
placeholder="请输入含税金额" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@ -61,18 +61,18 @@
|
||||
<el-col :span="8">
|
||||
<el-form-item label="运费" prop="freight"
|
||||
:rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||||
<el-input v-model="formData.freight" clearable placeholder="请输入运费" type="number" />
|
||||
<el-input v-model="formData.freight" clearable placeholder="请输入运费" type="number"
|
||||
@change="calcAmount()" />
|
||||
</el-form-item></el-col><el-col :span="8">
|
||||
<el-form-item label="其他费用" prop="other_fee"
|
||||
:rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||||
<el-input v-model="formData.other_fee" clearable type="number" placeholder="请输入其他费用" />
|
||||
<el-input v-model="formData.other_fee" clearable type="number" @change="calcAmount()"
|
||||
placeholder="请输入其他费用" />
|
||||
</el-form-item></el-col>
|
||||
|
||||
<el-col :span="8">
|
||||
<el-form-item label="合计金额" prop="total_amount">
|
||||
<el-input v-model="formData.total_amount" disabled clearable placeholder="请输入合计金额"
|
||||
@input="amountinput1" />
|
||||
<div v-show="false">{{ totalPrice }}</div>
|
||||
<el-input v-model="formData.total_amount" disabled clearable placeholder="请输入合计金额" />
|
||||
</el-form-item></el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="合计金额大写" prop="total_amount">
|
||||
@ -90,23 +90,7 @@
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="附件">
|
||||
<el-upload
|
||||
accept="doc, docx, xls, xlsx, ppt, pptx, pdf, txt, zip, rar, tar, jpg, png, gif, jpeg, webp, wmv, avi, mpg, mpeg, 3gp, mov, mp4, flv, f4v, rmvb, mkv"
|
||||
class="upload-demo" :show-file-list="false" aria-hidden="true"
|
||||
:headers="{ Token: userStore.token }" :action="base_url + '/upload/file'"
|
||||
:on-success="handleAvatarSuccess_four" ref="upload">
|
||||
<el-button type="primary">
|
||||
上传
|
||||
</el-button>
|
||||
</el-upload>
|
||||
|
||||
<div>
|
||||
<div v-for="(item, index) in formDataannex" style="margin-left: 5px;display: block;">
|
||||
<a style="margin-left: 10px; color: #4a5dff; align-self: flex-start"
|
||||
:href="item.uri" target="_blank">{{ item.name }}</a>
|
||||
<span style="cursor: pointer;margin-left: 5px;" @click="delFileFn(index)">x</span>
|
||||
</div>
|
||||
</div>
|
||||
<uploadAnnex :formData="formData" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -114,74 +98,74 @@
|
||||
@click="showDialog1 = true">选择产品</el-button></div>
|
||||
|
||||
<div style="margin-bottom: 30px;">
|
||||
<el-table :data="tableData">
|
||||
<el-table :data="formData.quotation_detail">
|
||||
<el-table-column label="序号">
|
||||
<template #default="{ row }">
|
||||
<el-button @click="handleDelete(row)" size="small">-</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品名称" prop="name">
|
||||
<el-table-column label="产品名称">
|
||||
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.name" disabled placeholder="系统自动填写" />
|
||||
<el-input v-model="row.product_name" disabled placeholder="系统自动填写" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品编码" prop="code">
|
||||
<el-table-column label="产品编码">
|
||||
|
||||
<template #default="{ row }"> <el-input v-model="row.code" disabled placeholder="系统自动填写" />
|
||||
<template #default="{ row }"> <el-input v-model="row.product_code" disabled
|
||||
placeholder="系统自动填写" />
|
||||
</template></el-table-column>
|
||||
<el-table-column label="规格型号" prop="specs">
|
||||
<el-table-column label="规格型号">
|
||||
|
||||
<template #default="{ row }"> <el-input v-model="row.specs" disabled placeholder="系统自动填写" />
|
||||
<template #default="{ row }"> <el-input v-model="row.product_specs" disabled
|
||||
placeholder="系统自动填写" />
|
||||
</template></el-table-column>
|
||||
|
||||
<el-table-column label="品牌" prop="brand">
|
||||
<el-table-column label="品牌">
|
||||
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.brand" disabled placeholder="系统自动填写" />
|
||||
<el-input v-model="row.product_brand" disabled placeholder="系统自动填写" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="参数说明" prop="parameter_description">
|
||||
<el-table-column label="参数说明">
|
||||
|
||||
<template #default="{ row }"> <el-input v-model="row.parameter_description" disabled />
|
||||
<template #default="{ row }"> <el-input v-model="row.product_parameter_description"
|
||||
disabled />
|
||||
</template></el-table-column>
|
||||
<el-table-column label="单位" prop="unit">
|
||||
<el-table-column label="单位">
|
||||
|
||||
<template #default="{ row }"> <el-input v-model="row.unit" disabled />
|
||||
<template #default="{ row, index }"> <el-input v-model="row.product_unit" disabled />
|
||||
</template></el-table-column>
|
||||
<el-table-column label="数量" prop="product_num">
|
||||
<el-table-column label="数量">
|
||||
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.product_num" />
|
||||
<template #default="{ row, $index }">
|
||||
<el-input v-model="row.num" @change="calcAmount($index)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税率(%)" prop="tax_rate">
|
||||
|
||||
<template #default="{ row }">
|
||||
|
||||
<el-select class="flex-1" v-model="row.tax_rate" clearable placeholder="请选择税率">
|
||||
<template #default="scope">
|
||||
<el-select class="flex-1" v-model="scope.row.tax_rate" clearable placeholder="请选择税率"
|
||||
@change="getTaxText(scope.$index)">
|
||||
<el-option v-for="(item, index) in dictData.tax_rate" :key="index"
|
||||
:label="item.name" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="含税单价" prop="price">
|
||||
|
||||
<el-table-column label="含税单价">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.price" />
|
||||
<el-input v-model="row.tax_inclusive_price" disabled />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="含税金额" prop="amount">
|
||||
|
||||
<el-table-column label="含税金额">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.amount" disabled />
|
||||
<el-input v-model="row.tax_inclusive_amount" disabled />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="不含税金额" prop="amount_including">
|
||||
<el-table-column label="不含税金额">
|
||||
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.amount_including" disabled />
|
||||
<el-input v-model="row.tax_exclusive_amount" disabled />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" prop="remark">
|
||||
@ -210,8 +194,8 @@
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import { apiQuotationAdd, apiQuotationEdit, apiQuotationDetail } from '@/api/quotation'
|
||||
import { apiQuotationDetailLists, apiQuotationDetailDelete } from '@/api/quotation_detail'
|
||||
import { convertToChinese } from '@/utils/util'
|
||||
import { toChinesNum } from "@/utils/util";
|
||||
import customDialog1 from '@/components/product/index.vue'
|
||||
import type { PropType } from 'vue'
|
||||
import { computed, watch } from "vue"
|
||||
@ -230,49 +214,13 @@ const mode = ref('add')
|
||||
const showDialog = ref(false)
|
||||
const showDialog1 = ref(false)
|
||||
const customer_name = ref('')
|
||||
const amount_including_daxie = ref('')
|
||||
const total_amount_daxie = ref('')
|
||||
const tableData = ref([])
|
||||
const formDataannex = reactive([])
|
||||
import feedback from '@/utils/feedback'
|
||||
import configs from "@/config"
|
||||
const base_url = configs.baseUrl + configs.urlPrefix
|
||||
import useUserStore from "@/stores/modules/user";
|
||||
const userStore = useUserStore();
|
||||
// 上传文件
|
||||
const handleAvatarSuccess_four = (
|
||||
response,
|
||||
uploadFile
|
||||
) => {
|
||||
if (response.code == 0) {
|
||||
feedback.msgError(response.msg);
|
||||
return;
|
||||
}
|
||||
formDataannex.push(
|
||||
{ uri: response.data.uri, name: response.data.name }
|
||||
|
||||
);
|
||||
};
|
||||
// 删除上传的文件
|
||||
const delFileFn = (index: number) => {
|
||||
formDataannex.splice(index, 1)
|
||||
}
|
||||
|
||||
// 弹窗标题
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑报价单' : '新增报价单'
|
||||
})
|
||||
|
||||
//监听金额大写输入
|
||||
const amountinput = (e) => {
|
||||
if (e && e > 0) {
|
||||
amount_including_daxie.value = toChinesNum(e)
|
||||
}
|
||||
}
|
||||
const amountinput1 = (e) => {
|
||||
if (e && e > 0) {
|
||||
total_amount_daxie.value = toChinesNum(e)
|
||||
}
|
||||
}
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
@ -284,7 +232,7 @@ const formData = reactive({
|
||||
custom_master_phone: '',
|
||||
create_user: '',
|
||||
invoice_type: '',
|
||||
amount_including_tax: '',
|
||||
amount_including_tax: 0,
|
||||
freight: '',
|
||||
other_fee: '',
|
||||
total_amount: '',
|
||||
@ -304,20 +252,19 @@ const customEvent = (e: any) => {
|
||||
|
||||
};
|
||||
const customEvent1 = (e: any) => {
|
||||
tableData.value.push({
|
||||
|
||||
formData.quotation_detail.push({
|
||||
product_id: e.id,
|
||||
name: e.name,
|
||||
code: e.code,
|
||||
unit: e.unit,
|
||||
specs: e.specs,
|
||||
brand: e.brand,
|
||||
parameter_description: e.parameter_description,
|
||||
product_num: 1,
|
||||
product_name: e.name,
|
||||
product_code: e.code,
|
||||
product_unit: e.unit,
|
||||
product_specs: e.specs,
|
||||
product_brand: e.brand,
|
||||
product_parameter_description: e.parameter_description,
|
||||
tax_rate: '',
|
||||
price: e.sales_price,
|
||||
tax_rate_text: "",
|
||||
remark: '',
|
||||
amount: e.sales_price,
|
||||
amount_including: e.sales_price
|
||||
tax_inclusive_price: e.sales_price
|
||||
})
|
||||
showDialog1.value = false;
|
||||
|
||||
@ -326,53 +273,28 @@ const customEvent1 = (e: any) => {
|
||||
const formRules = reactive<any>({
|
||||
})
|
||||
|
||||
const handleAdd = (row: any) => {
|
||||
// 在 row 后面插入一行数据
|
||||
const index = tableData.value.indexOf(row);
|
||||
tableData.value.splice(index + 1, 0, {});
|
||||
};
|
||||
|
||||
const handleDelete = (row: any) => {
|
||||
|
||||
const handleDelete = async (row: any) => {
|
||||
if (row.id) await apiQuotationDetailDelete({ id: row.id });
|
||||
// 删除 row
|
||||
const index = tableData.value.indexOf(row);
|
||||
tableData.value.splice(index, 1);
|
||||
const index = formData.quotation_detail.indexOf(row);
|
||||
formData.quotation_detail.splice(index, 1);
|
||||
};
|
||||
|
||||
// 获取详情
|
||||
const setFormData = async (data: Record<any, any>) => {
|
||||
if (data.annex && data.annex.length > 0) {
|
||||
const arry1 = data.annex.map((item: any, index: any) => {
|
||||
return {
|
||||
name: `文件${index + 1}`,
|
||||
uri: item
|
||||
};
|
||||
});
|
||||
Object.assign(formDataannex, arry1)
|
||||
}
|
||||
if (data.total_amount && data.total_amount > 0) {
|
||||
amountinput1(data.total_amount)
|
||||
}
|
||||
if (data.amount_including_tax && data.amount_including_tax > 0) {
|
||||
amountinput(data.amount_including_tax)
|
||||
}
|
||||
customer_name.value = data.custom_name
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let res = await apiQuotationDetailLists({ quotation_id: data.id })
|
||||
formData.quotation_detail = res.lists
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
|
||||
const data = await apiQuotationDetail({
|
||||
id: row.id
|
||||
})
|
||||
setFormData(data)
|
||||
}
|
||||
const isMobileNumber = (rule: any, value: string | number | any[], callback: (arg0: Error | undefined) => void) => {
|
||||
|
||||
if (value && !/^1[3|4|5|7|8][0-9]{9}$/.test(value)) {
|
||||
@ -384,21 +306,6 @@ const isMobileNumber = (rule: any, value: string | number | any[], callback: (ar
|
||||
|
||||
// 提交按钮
|
||||
const handleSubmit = async () => {
|
||||
if (formDataannex.length > 0) {
|
||||
formData.annex = formDataannex.map((item) => item.uri)
|
||||
}
|
||||
if (tableData.value.length > 0) {
|
||||
formData.quotation_detail = tableData.value.map(item => ({
|
||||
|
||||
tax_inclusive_price: item.price,
|
||||
product_id: item.product_id,
|
||||
num: item.product_num,
|
||||
tax_rate: item.tax_rate,
|
||||
remark: item.remark
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
await formRef.value?.validate()
|
||||
const data = { ...formData, }
|
||||
mode.value == 'edit'
|
||||
@ -420,33 +327,47 @@ const handleClose = () => {
|
||||
}
|
||||
|
||||
// 计算价格
|
||||
const totalPrice = computed(() => {
|
||||
formData.total_amount = Number(formData.amount_including_tax) + Number(formData.freight || 0) + Number(formData.other_fee || 0)
|
||||
total_amount_daxie.value = convertToChinese(formData.total_amount)
|
||||
return Number(formData.amount_including_tax) + Number(formData.freight || 0) + Number(formData.other_fee || 0)
|
||||
})
|
||||
|
||||
watch(tableData.value, (newVal, oldVal) => {
|
||||
let num = 0;
|
||||
tableData.value.forEach(item => {
|
||||
item.amount = item.price * item.product_num
|
||||
let name;
|
||||
props.dictData.tax_rate.forEach(items => {
|
||||
if (items.value == item.tax_rate) {
|
||||
name = items.name
|
||||
}
|
||||
})
|
||||
item.amount_including = item.amount * (1 - (Number(name) / 100)) || 0
|
||||
num += item.amount
|
||||
// 获取列表每行的税率text
|
||||
const getTaxText = (index: number) => {
|
||||
let table = formData.quotation_detail
|
||||
let taxRate = props.dictData.tax_rate[props.dictData.tax_rate.findIndex(item => item.value == table[index]?.tax_rate)].name
|
||||
table[index].tax_rate_text = (1 - taxRate / 100)
|
||||
calcAmount(index)
|
||||
}
|
||||
|
||||
// 计算价格
|
||||
const calcAmount = (index: number) => {
|
||||
let table = formData.quotation_detail
|
||||
// 通过含税单价tax_inclusive_price和税率tax_rate_text计算列表每行的含税金额tax_inclusive_amount,不含税金额tax_exclusive_amount,遍历列表累加含税金额得出总的含税金额
|
||||
formData.amount_including_tax = 0
|
||||
table.forEach(item => {
|
||||
item.tax_inclusive_amount = (Number((item)?.num || 0) * Number(item.tax_inclusive_price)).toFixed(2)
|
||||
item.tax_exclusive_amount = (Number(item.tax_inclusive_amount || 0) * Number(item.tax_rate_text)).toFixed(2)
|
||||
formData.amount_including_tax += Number(item.tax_inclusive_amount)
|
||||
})
|
||||
formData.amount_including_tax = num
|
||||
amount_including_daxie.value = convertToChinese(num)
|
||||
// 合计金额=总含税金额+运费+其他费用
|
||||
formData.total_amount = (+formData.amount_including_tax || 0) + (+formData.freight || 0) + (+formData.other_fee || 0)
|
||||
}
|
||||
|
||||
|
||||
// 金额大写
|
||||
const amount_including_daxie = computed(() => {
|
||||
return convertToChinese(formData.amount_including_tax) || ''
|
||||
})
|
||||
|
||||
const total_amount_daxie = computed(() => {
|
||||
return convertToChinese(formData.total_amount) || ''
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData,
|
||||
getDetail
|
||||
|
||||
})
|
||||
</script>
|
||||
|
@ -50,14 +50,16 @@
|
||||
<el-table-column label="运费" prop="freight" show-overflow-tooltip />
|
||||
<el-table-column label="其他费用" prop="other_fee" show-overflow-tooltip />
|
||||
<el-table-column label="合计金额" prop="total_amount" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<!-- <el-button v-perms="['quotation.quotation/edit']" type="primary" link @click="handleEdit(row)">
|
||||
<el-button v-perms="['quotation.quotation/edit']" type="primary" link
|
||||
@click="handleEdit(row)">
|
||||
编辑
|
||||
</el-button> -->
|
||||
<!-- <el-button v-perms="['quotation.quotation/delete']" type="danger" link @click="handleDelete(row.id)">
|
||||
</el-button>
|
||||
<el-button v-perms="['quotation.quotation/delete']" type="danger" link
|
||||
@click="handleDelete(row.id)">
|
||||
删除
|
||||
</el-button> -->
|
||||
</el-button>
|
||||
<el-button v-perms="['quotation.quotation/detail']" link @click="handleDetail(row)">
|
||||
详情
|
||||
</el-button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user