|
|
|
@ -5,37 +5,45 @@
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
|
|
|
|
<div class="ds-bus-table">
|
|
|
|
|
<BasicTable
|
|
|
|
|
:canRowSelect="true"
|
|
|
|
|
:scroll="{ x: '100%', y: 188 }"
|
|
|
|
|
:row-selection="{ selectedRowKeys: state.historyRowKeys, onChange: historyChange }"
|
|
|
|
|
rowKey="id"
|
|
|
|
|
@register="registerTable"
|
|
|
|
|
@row-click="onRowClick"
|
|
|
|
|
>
|
|
|
|
|
<template #toolbar>
|
|
|
|
|
<a-button type="link" @click="addInfos">增加结算明细</a-button>
|
|
|
|
|
</template>
|
|
|
|
|
</BasicTable>
|
|
|
|
|
<div class="info">
|
|
|
|
|
<div>
|
|
|
|
|
<a-button @click="save" type="link">添加申请费用明细</a-button>
|
|
|
|
|
<a-spin :spinning="loading">
|
|
|
|
|
<BasicTable
|
|
|
|
|
:canRowSelect="true"
|
|
|
|
|
:scroll="{ x: '100%', y: 188 }"
|
|
|
|
|
:row-selection="{ selectedRowKeys: state.historyRowKeys, onChange: historyChange }"
|
|
|
|
|
rowKey="id"
|
|
|
|
|
@register="registerTable"
|
|
|
|
|
@row-click="onRowClick"
|
|
|
|
|
>
|
|
|
|
|
<template #toolbar>
|
|
|
|
|
<a-button type="link" @click="addInfos">增加结算明细</a-button>
|
|
|
|
|
</template>
|
|
|
|
|
</BasicTable>
|
|
|
|
|
<div class="info">
|
|
|
|
|
<div>
|
|
|
|
|
<a-button @click="save" type="link">增加申请费用明细</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
<feeTable
|
|
|
|
|
ref="feeTabel"
|
|
|
|
|
></feeTable>
|
|
|
|
|
</div>
|
|
|
|
|
<feeTable
|
|
|
|
|
ref="feeTabel"
|
|
|
|
|
></feeTable>
|
|
|
|
|
</div>
|
|
|
|
|
</a-spin>
|
|
|
|
|
<!-- 汇率换算组件 -->
|
|
|
|
|
<ExchangeRate
|
|
|
|
|
ref="exchangeRate"
|
|
|
|
|
@submit="saveExchangeRate"
|
|
|
|
|
></ExchangeRate>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { onMounted, ref, reactive, watch, defineExpose, defineProps, defineEmits } from 'vue'
|
|
|
|
|
import { onMounted, ref, reactive, watch, defineExpose, defineProps, defineEmits, h } from 'vue'
|
|
|
|
|
import { BasicTable, useTable } from '/@/components/Table'
|
|
|
|
|
import { GetBizList } from '../../api'
|
|
|
|
|
import { GetBizList, BizSave } from '../../api'
|
|
|
|
|
import { businessColumns, searchFormSchema } from '../columns'
|
|
|
|
|
import feeTable from '/@/components/CostEntry/components/feeTable.vue'
|
|
|
|
|
import ExchangeRate from './exchangeRate.vue'
|
|
|
|
|
// 引入提示信息
|
|
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'
|
|
|
|
|
const emit = defineEmits(['save'])
|
|
|
|
|
const emit = defineEmits(['save', 'refresh'])
|
|
|
|
|
const { createMessage } = useMessage()
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
// 表单数据
|
|
|
|
@ -47,7 +55,8 @@
|
|
|
|
|
type: Function
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const [registerTable, { reload, getForm, getPaginationRef, getSelectRows, setSelectedRows }] = useTable({
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const [registerTable, { reload, getForm, getPaginationRef, getSelectRows, setSelectedRows, getDataSource }] = useTable({
|
|
|
|
|
api: async (p) => {
|
|
|
|
|
const res = await GetBizList(p)
|
|
|
|
|
if (res?.data?.length) state.historyRowKeys = [res.data[0].id]
|
|
|
|
@ -59,6 +68,7 @@
|
|
|
|
|
beforeFetch: () => {
|
|
|
|
|
var currentPageInfo: any = getPaginationRef()
|
|
|
|
|
var data = getForm().getFieldsValue()
|
|
|
|
|
console.log(data)
|
|
|
|
|
const postParam = {
|
|
|
|
|
queryCondition: '',
|
|
|
|
|
pageCondition: {
|
|
|
|
@ -68,10 +78,10 @@
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
let condition: API.ConditionItem[] = []
|
|
|
|
|
if (!!data.customerNo) {
|
|
|
|
|
if (!!data.customerId) {
|
|
|
|
|
condition.push({
|
|
|
|
|
FieldName: 'customerNo',
|
|
|
|
|
FieldValue: data.customerNo,
|
|
|
|
|
FieldName: 'customerId',
|
|
|
|
|
FieldValue: data.customerId,
|
|
|
|
|
ConditionalType: 1
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -134,6 +144,17 @@
|
|
|
|
|
const allFeeData = {}
|
|
|
|
|
const feeTabel = ref(null)
|
|
|
|
|
const historyChange = async (v) => {
|
|
|
|
|
if (v.length > 1) {
|
|
|
|
|
const a = getDataSource().filter(item => {
|
|
|
|
|
return item.id == v[0]
|
|
|
|
|
})[0]
|
|
|
|
|
const b = getDataSource().filter(item => {
|
|
|
|
|
return item.id == v[v.length - 1]
|
|
|
|
|
})[0]
|
|
|
|
|
if (a.customerId != b.customerId) {
|
|
|
|
|
return createMessage.warning('请选择结算对象一致的数据!')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
state.historyRowKeys = v
|
|
|
|
|
}
|
|
|
|
|
// 行点击事件
|
|
|
|
@ -144,16 +165,75 @@
|
|
|
|
|
const feeData = () => {
|
|
|
|
|
return feeTabel.value.selectfeeData
|
|
|
|
|
}
|
|
|
|
|
// 保存费用表格数据
|
|
|
|
|
const feeTableData = ref([])
|
|
|
|
|
// 币别换算弹窗
|
|
|
|
|
const exchangeRate = ref(null)
|
|
|
|
|
// 添加申请费用明细
|
|
|
|
|
const save = () => {
|
|
|
|
|
const data = feeTabel.value.selectfeeData
|
|
|
|
|
emit('save', data)
|
|
|
|
|
// 费用表数据
|
|
|
|
|
feeTableData.value = feeTabel.value.selectfeeData
|
|
|
|
|
if (feeTableData.value.length == 0) {
|
|
|
|
|
return createMessage.warning('请选择要申请的费用明细!')
|
|
|
|
|
}
|
|
|
|
|
// 主单是否有结算单位
|
|
|
|
|
const customer = props.formData?.customerId
|
|
|
|
|
console.log(customer)
|
|
|
|
|
let cflag = true
|
|
|
|
|
// 主单是否有币别
|
|
|
|
|
const currency = props.formData?.currency
|
|
|
|
|
// 业务主表数据
|
|
|
|
|
const mData = getSelectRows()
|
|
|
|
|
mData.forEach(item => {
|
|
|
|
|
if (item.customerId == customer) {
|
|
|
|
|
cflag = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (customer && cflag) {
|
|
|
|
|
// 主单有结算单位
|
|
|
|
|
return createMessage.warning('结算对象与付费申请客户不一致,不能添加此费用明细!')
|
|
|
|
|
}
|
|
|
|
|
if (currency) {
|
|
|
|
|
// 汇率换算申请
|
|
|
|
|
let currencyList = []
|
|
|
|
|
// 过滤出所有跟业务币别不一致的币别
|
|
|
|
|
feeTableData.value.forEach((item, index) => {
|
|
|
|
|
if (item.currency != currency) {
|
|
|
|
|
currencyList.push({
|
|
|
|
|
currency: item.currency,
|
|
|
|
|
feeType: item.feeType,
|
|
|
|
|
// 正向汇率
|
|
|
|
|
value: null,
|
|
|
|
|
// 逆向汇率
|
|
|
|
|
value1: null
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
currencyList = Array.from(new Set(currencyList.map(item => item.currency))).map(currency => {
|
|
|
|
|
return currencyList.find(item => item.currency === currency)
|
|
|
|
|
})
|
|
|
|
|
console.log(currencyList)
|
|
|
|
|
// 币别不同触发换算
|
|
|
|
|
exchangeRate.value.init(currency, currencyList)
|
|
|
|
|
} else {
|
|
|
|
|
// 原币申请
|
|
|
|
|
emit('save', feeTableData.value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 保存填写汇率并提交
|
|
|
|
|
const saveExchangeRate = (list) => {
|
|
|
|
|
feeTableData.value.forEach(row => {
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
if (row.currency == item.currency) {
|
|
|
|
|
row.exchangeRate = item.value
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
emit('save', feeTableData.value)
|
|
|
|
|
}
|
|
|
|
|
// 按业务添加费用申请
|
|
|
|
|
const addInfos = () => {
|
|
|
|
|
const selectRows = getSelectRows()
|
|
|
|
|
console.log(selectRows)
|
|
|
|
|
// console.log(props.formData.currency)
|
|
|
|
|
return
|
|
|
|
|
if (props.formData.customerId) {
|
|
|
|
|
let flag = false
|
|
|
|
|
selectRows.forEach(item => {
|
|
|
|
@ -164,25 +244,61 @@
|
|
|
|
|
if (!flag) {
|
|
|
|
|
return createMessage.warning('没有选择要添加的业务!')
|
|
|
|
|
}
|
|
|
|
|
selectRows
|
|
|
|
|
} else {
|
|
|
|
|
if (state.historyRowKeys.length == 0 ) {
|
|
|
|
|
return createMessage.warning('没有选择要添加的业务!')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(allFeeData)
|
|
|
|
|
// 合并所有选择过的费用明细
|
|
|
|
|
let feeList = []
|
|
|
|
|
for(var key in allFeeData) {
|
|
|
|
|
feeList = [...feeList, ...allFeeData[key]]
|
|
|
|
|
}
|
|
|
|
|
console.log(props.formData)
|
|
|
|
|
|
|
|
|
|
feeList.forEach(item => {
|
|
|
|
|
if (props.formData.currency && props.formData.currency != item.currency) {
|
|
|
|
|
|
|
|
|
|
if (!props.formData.currency) {
|
|
|
|
|
// 原币申请
|
|
|
|
|
const postData = {
|
|
|
|
|
description: '按业务增加添加费用明细',
|
|
|
|
|
application: {
|
|
|
|
|
id: 0,
|
|
|
|
|
customerId: selectRows[0]?.customerId
|
|
|
|
|
},
|
|
|
|
|
items: [{
|
|
|
|
|
id: selectRows[0]?.id,
|
|
|
|
|
businessType: selectRows[0]?.businessType
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
loading.value = true
|
|
|
|
|
BizSave(postData).then(res => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
if (res.succeeded) {
|
|
|
|
|
createMessage.success('增加成功!')
|
|
|
|
|
emit('refresh')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 转换汇率申请
|
|
|
|
|
// 合并所有选择过的费用明细
|
|
|
|
|
let feeList = []
|
|
|
|
|
for(var key in allFeeData) {
|
|
|
|
|
feeList = [...feeList, ...allFeeData[key]]
|
|
|
|
|
}
|
|
|
|
|
// 汇率换算申请
|
|
|
|
|
let currencyList = []
|
|
|
|
|
// 过滤出所有跟业务币别不一致的币别
|
|
|
|
|
feeList.forEach((item, index) => {
|
|
|
|
|
if (item.currency != props.formData.currency) {
|
|
|
|
|
currencyList.push({
|
|
|
|
|
currency: item.currency,
|
|
|
|
|
feeType: item.feeType,
|
|
|
|
|
// 正向汇率
|
|
|
|
|
value: null,
|
|
|
|
|
// 逆向汇率
|
|
|
|
|
value1: null
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
currencyList = Array.from(new Set(currencyList.map(item => item.currency))).map(currency => {
|
|
|
|
|
return currencyList.find(item => item.currency === currency)
|
|
|
|
|
})
|
|
|
|
|
// 币别不同触发换算
|
|
|
|
|
feeTableData.value = feeList
|
|
|
|
|
exchangeRate.value.init(props.formData.currency, currencyList)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
watch(
|
|
|
|
|
() => state.historyRowKeys, (v, old) => {
|
|
|
|
@ -218,9 +334,17 @@
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
//初始化
|
|
|
|
|
reload()
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
// 如果存在结算对象,则业务数据根据结算对象进行过滤
|
|
|
|
|
if (props.formData?.customerId) {
|
|
|
|
|
console.log(props.formData.customerId)
|
|
|
|
|
await getForm().setFieldsValue({ 'customerId': props.formData.customerId })
|
|
|
|
|
//初始化
|
|
|
|
|
reload()
|
|
|
|
|
} else {
|
|
|
|
|
//初始化
|
|
|
|
|
reload()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
defineExpose({
|
|
|
|
|
feeData
|
|
|
|
|