From 64dd75628c1221433fb46fbc18875ac8c8b43354 Mon Sep 17 00:00:00 2001 From: sunzehua Date: Thu, 5 Sep 2024 15:28:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8F=91=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/operation/invoiceApply/api.js | 17 ++ src/views/operation/invoiceApply/columns.tsx | 4 +- .../invoiceApply/detail/InvoiceDetails.vue | 107 +++++++---- .../invoiceApply/detail/feeTable.vue | 179 ++++++++---------- .../operation/invoiceApply/detail/index.vue | 87 ++++++--- src/views/operation/invoiceApply/index.vue | 75 +++++--- 6 files changed, 287 insertions(+), 182 deletions(-) diff --git a/src/views/operation/invoiceApply/api.js b/src/views/operation/invoiceApply/api.js index 0b73ddcb..73d2a10a 100644 --- a/src/views/operation/invoiceApply/api.js +++ b/src/views/operation/invoiceApply/api.js @@ -148,6 +148,23 @@ export function InvoiceApplicationBizSave(parameter) { }) } +export function InvoiceApplicationDeleteDetail(parameter) { + return request({ + url: '/feeApi/InvoiceApplication/DeleteDetail', + method: 'post', + data: parameter, + }) +} + + +export function BatchDelFiles(parameter) { + return request({ + url: '/mainApi/OpFile/BatchDelFiles', + method: 'post', + data: parameter, + }) +} + export function GetOpFileList(parameter) { return request({ url: '/mainApi/OpFile/GetOpFileList', diff --git a/src/views/operation/invoiceApply/columns.tsx b/src/views/operation/invoiceApply/columns.tsx index a39935b5..163ad1d6 100644 --- a/src/views/operation/invoiceApply/columns.tsx +++ b/src/views/operation/invoiceApply/columns.tsx @@ -449,11 +449,11 @@ export const detailSearchFormSchema: FormSchema[] = [ options: [ { label: '收', - value: '收', + value: '1', }, { label: '付', - value: '付', + value: '2', } ], }, diff --git a/src/views/operation/invoiceApply/detail/InvoiceDetails.vue b/src/views/operation/invoiceApply/detail/InvoiceDetails.vue index 1786faf6..e8aafcf8 100644 --- a/src/views/operation/invoiceApply/detail/InvoiceDetails.vue +++ b/src/views/operation/invoiceApply/detail/InvoiceDetails.vue @@ -43,7 +43,7 @@
原币申请 - {{ item.applyAmount }} {{ item.currency }} @@ -52,7 +52,7 @@
折算人民币申请 - {{ totalRmb }} RMB + {{ totalRmb }} RMB
@@ -181,6 +181,7 @@ const columns = [ ] +const queryData = ref({}) as any const dataSource = ref([]) as any const [registerTable, { getForm, setSelectedRowKeys, getSelectRows, setProps, getRawDataSource }] = useTable({ api: async (p) => { @@ -191,8 +192,8 @@ const [registerTable, { getForm, setSelectedRowKeys, getSelectRows, setProps, ge }, beforeFetch: (p) => { const data = formatParams(p) - // data.otherQueryCondition = '' data.otherQueryCondition = getForm().getFieldsValue().FeeRange + queryData.value = JSON.parse(JSON.stringify(p)) return data }, columns: detailColumns, @@ -245,39 +246,58 @@ const exchangeData = ref({}) as any function handleChangeApply1(e) { form.value.isYB = !e.target.checked const arr = getSelectRowsFee() + const arrRight = getSelectRows() const exchangeArr = [] as any - exchangeData.value = [] - arr.forEach(item => { - if (item.currency != 'CNY') { - exchangeArr.push(item) - } - }) - if (exchangeArr.length > 0) { - const promises = exchangeArr.map(item => { - return new Promise((resolve) => { - const data = { - currencyFrom: 'CNY', - currencyTo: item.currency, - feeType: item.feeType - } - GetExchangeRate(data).then(res => { - exchangeData.value.push(res.data) - resolve(true); - }) + if (arr.length > 0) { + exchangeData.value = [] + arr.forEach(item => { + if (item.currency != 'RMB') { + exchangeArr.push(item) + } + }) + if (exchangeArr.length > 0) { + const promises = exchangeArr.map(item => { + return new Promise((resolve) => { + const data = { + currencyFrom: 'RMB', + currencyTo: item.currency, + feeType: item.feeType + } + GetExchangeRate(data).then(res => { + exchangeData.value.push(res.data) + resolve(true); + }) + }); + }); + return Promise.all(promises).then(() => { + exchangeFlag.value = true }); - }); - return Promise.all(promises).then(() => { - exchangeFlag.value = true - }); + } + if (exchangeArr.length == 0) { + const arr = getSelectRowsFee() + let total = 0 + arr.forEach(item => { + total += Number(item.applyAmount) + }) + totalRmb.value = total + } } - if (exchangeArr.length == 0) { - const arr = getSelectRowsFee() - let total = 0 - arr.forEach(item => { - total += Number(item.applyAmount) + if (arrRight.length > 0) { + const data = [] as any + arrRight.forEach(item => { + data.push({ + id: item.id, + businessType: item.businessType + }) + }) + InvoiceApplicationGetFees([data]).then(res => { + if (res.succeeded) { + + } }) - totalRmb.value = total } + + } const totalRmb = ref(0) @@ -286,7 +306,7 @@ function handleSureExhange() { const arr = getSelectRowsFee() let total = 0 arr.forEach(item => { - if (item.currency != 'CNY') { + if (item.currency != 'RMB') { exchangeData.value.forEach(ite => { if (item.currency == ite.currencyTo) { total += Number((Number(item.applyAmount) * Number(ite.reverseRate)).toFixed(2)) @@ -358,11 +378,12 @@ function onSelectChange(selectedRowKeys) { }) }) } -const emits = defineEmits(['updateList']) +const emits = defineEmits(['updateList', 'addLeft']) // 添加费用明细 // 1.如果选的是原币结算 那么表头信息中的币别是空 费用明细里币别就等于原始币别 originalCurrency原始币别 // 2.如果选的是人民币结算 表头信息的币别就是人民币 费用明细里币别是rmb 原始币别就是原本的费用币别 汇率就是汇率弹框的汇率 // originalAmount原始申请金额 是没有汇率转换的金额 applyAmount 申请金额 是转换后的 +// 3.如果选的是右边 添加业务的话 原币还是表头信息里的币别是空 选rmb就是cny 并且需要调汇率接口将汇率传过去 function handleAddDetial() { let arr = getSelectRowsFee() ? getSelectRowsFee() : [] if (arr.length == 0) { @@ -379,7 +400,7 @@ function handleAddDetial() { if (form.value.isRMB) { arr.forEach(item => { item.originalCurrency = item.currency - item.currency = 'CNY' + item.currency = 'RMB' item.originalAmount = item.applyAmount item.applyAmount = Number((Number(item.applyAmount) * Number(item.exchangeRate)).toFixed(2)) }) @@ -417,6 +438,7 @@ function mergeByCurrency(arr) { }); return Object.values(result); } +// 添加右边整体业务 需要将费用的查询参数传过去 function addDetailed() { const arr = getSelectRows() ? getSelectRows() : [] const arr1 = [] @@ -425,10 +447,25 @@ function addDetailed() { arr1.push(1) } }) - if (arr1.length > 0) { + if (arr1.length > 0 && customerIdP.value) { createMessage.error('请选择同一客户') return false } + const data = {} as any + if (queryData.value.feeType) { + data.feeType = queryData.value.feeType + } + if (queryData.value.currency) { + data.currency = queryData.value.currency + } + if (queryData.value.feeName) { + data.feeName = queryData.value.feeName + } + if (queryData.value.FeeRange) { + data.FeeRange = queryData.value.FeeRange + } + emits('addLeft', arr, data) + open.value = false } const customerIdP = ref('') function changeCustIn(id) { diff --git a/src/views/operation/invoiceApply/detail/feeTable.vue b/src/views/operation/invoiceApply/detail/feeTable.vue index 37886120..6eee45e3 100644 --- a/src/views/operation/invoiceApply/detail/feeTable.vue +++ b/src/views/operation/invoiceApply/detail/feeTable.vue @@ -2,47 +2,6 @@
- 发票明细 @@ -55,39 +14,19 @@ - + 费用名称 - + + + 附件上传 +
-
合计 @@ -104,16 +43,45 @@
- + + +
+
+ + + + 附件上传 + + + + + 删除文件 + +
+ + + +
+
@@ -137,7 +105,11 @@ import { HotTable } from '@handsontable/vue3' import { registerAllModules } from 'handsontable/registry' import { BasicTable, useTable, TableAction } from '/@/components/Table' import 'handsontable/dist/handsontable.full.min.css' -import { GetInvoiceCodeList, GeneralInvoiceDeleteDetail, DeleteInvoiceDetail, GetOpFileList, DownloadOpFile } from '../api' +import { + GetInvoiceCodeList, GeneralInvoiceDeleteDetail, InvoiceApplicationGet, + DeleteInvoiceDetail, GetOpFileList, DownloadOpFile, BatchDelFiles, + InvoiceApplicationDeleteDetail +} from '../api' import InvoiceDetails from './InvoiceDetails.vue' import { useMessage } from '/@/hooks/web/useMessage' import { useRoute } from 'vue-router' @@ -148,7 +120,7 @@ defineComponent({ HotTable, }) registerAllModules() -const [registerTable, { setTableData,setProps }] = useTable({ +const [registerTable, { setTableData, setProps, getSelectRows, setLoading }] = useTable({ columns: feeColumns, formConfig: { labelWidth: 120, @@ -200,19 +172,24 @@ function openFee() { setTimeout(() => { setTableData(dataSource.value) setProps({ - rowSelection: { - onChange: onSelectChange - }, - }) + rowSelection: { + onChange: onSelectChange + }, + }) }, 200) } -function onSelectChange(){ +const openFileFlag = ref(false) +function onSelectChange() { } -const emits = defineEmits(['updateAmount', 'updateListSave', 'handleSuccess']) +const emits = defineEmits(['updateAmount', 'updateListSave', 'handleSuccess', 'addLeftSave']) import { feeUnitDict } from '/@/hooks/dict/index' -function updateList(val,type) { - emits('updateListSave', val,type) +import { emit } from 'process' +function updateList(val, type) { + emits('updateListSave', val, type) +} +function addLeft(val,data) { + emits('addLeftSave', val,data) } const dsFile = ref('') const route = useRoute() @@ -508,6 +485,9 @@ const getfileList = () => { item['type'] = item?.filePath?.split('.')[1] fileData.value = res.data }) + if (res.data.length == 0) { + fileData.value = [] + } }).catch(() => { fileloading.value = false }) @@ -523,7 +503,10 @@ function download(item) { link.click() }) } - +function openFile() { + getfileList() + openFileFlag.value = true +} const selectedRowKeysFile = ref([]) as any function onSelectChangeFile(selectedRowKeys) { selectedRowKeysFile.value = selectedRowKeys @@ -538,21 +521,6 @@ const add = () => { }) } onMounted(() => { - const hot = hotTb.value.hotInstance - hot.addHook('afterOnCellMouseDown', function (event, coords, TD) { }) - // 定义表格按键处理逻辑 - hot.addHook('beforeKeyDown', function (event) { - // 检查按下的是否是特定的键(例如 'Enter') - if (event.key === 'ArrowDown') { - if (hot.getSelected()[0][0] == list.value.length - 1 && !hot.getActiveEditor()?._opened) { - list.value.push(JSON.parse(JSON.stringify(row))) - nextTick(() => { - hot.selectCell(list.value.length - 1, 4) - }) - return false - } - } - }) }) watchEffect(() => { // 全选 @@ -571,7 +539,6 @@ function init(data) { list.value = data.invoiceDetails ? data.invoiceDetails : [] hotTb.value.hotInstance.loadData(data.invoiceDetails ? data.invoiceDetails : []) dataSource.value = data.details ? data.details : [] - // getfileList() } const taxUnitPriceTotal = ref(0) as any @@ -632,11 +599,27 @@ function onSelectChangeDetail(selectedRowKeys) { } function delFee() { + setLoading(true) + let ids = [] + ids = getSelectRows().map((item) => { + return item.id + }) + InvoiceApplicationDeleteDetail({ ids: ids }).then(res => { + if (res.succeeded) { + InvoiceApplicationGet({ id: route.query.id }).then(res => { + setTableData(res.data.details) + setLoading(false) + createMessage.success('删除成功') + }) + } + }) +} +function delFile() { loading.value = true - GeneralInvoiceDeleteDetail({ ids: selectedRowKeysDetial.value }).then(res => { + BatchDelFiles({ ids: selectedRowKeysFile.value }).then(res => { if (res.succeeded) { - emits('handleSuccess') createMessage.success('删除成功') + getfileList() } loading.value = false }) diff --git a/src/views/operation/invoiceApply/detail/index.vue b/src/views/operation/invoiceApply/detail/index.vue index 22997db0..e9757482 100644 --- a/src/views/operation/invoiceApply/detail/index.vue +++ b/src/views/operation/invoiceApply/detail/index.vue @@ -31,7 +31,7 @@ - + @@ -78,10 +78,6 @@
申请单号:{{ form.applicationNO }}
-
@@ -94,14 +90,14 @@
原币申请 - {{ item.applyAmount }} {{ item.currency }}
折算人民币申请 - {{ totalRmb }} RMB + {{ totalRmb }} RMB
@@ -136,8 +132,8 @@
- +
@@ -163,7 +159,7 @@ {{ item.name - }} + }}
@@ -184,6 +180,7 @@ import { RenderTemplate, GetClientBankList, GetOrgList, + InvoiceApplicationBizSave, GetClientInfo } from '../api' import { useMessage } from '/@/hooks/web/useMessage' @@ -801,17 +798,20 @@ function getDetail() { form.value.applicationNO = res.data.applicationNO details.value = res.data.details feeTableRef.value.init(res.data) - if (res.data.currency == 'CNY') { + if (res.data.currency == 'RMB') { form.value.isRMB = true + res.data.summaryItems.forEach(item => { + totalRmb.value += Number(item.amount) + }) } else { form.value.isYB = true - } - res.data.summaryItems.forEach(item=>{ - amountArr.value.push({ - currency:item.currency, - applyAmount:item.amount + res.data.summaryItems.forEach(item => { + amountArr.value.push({ + currency: item.currency, + applyAmount: item.amount + }) }) - }) + } } }) } @@ -912,21 +912,20 @@ function changeCust(id, name) { }) }); } -// 从弹框选添加费用 调各种接口把发票信息补全 details是右侧费用勾选添加的数据 +// 从弹框选添加费用右侧的费用 调各种接口把发票信息补全 details是右侧费用勾选添加的数据 function updateListSave(arr, type) { loading.value = true - changeCust(arr[0].customerId, arr[0].customerName).then(res => { const data = { ...getFieldsValue(), ...getFieldsValueM(), ...getFieldsValueB(), ...form.value, - details: arr.concat(details.value), + details: arr, invoiceDetails: feeTableRef.value.list, } if (type == 'isRMB') { - data.currency = 'CNY' + data.currency = 'RMB' } else { data.currency = '' } @@ -946,6 +945,43 @@ function updateListSave(arr, type) { }) +} +// 左侧的添加过来 整个业务 +function addLeftSave(arr,query) { + loading.value = true + changeCust(arr[0].customerId, arr[0].customerName).then(res => { + const itemList = [] as any + arr.forEach(item => { + itemList.push({ + id: item.id, + businessType: item.businessType + }) + }) + const data = { + application: { + ...getFieldsValue(), + ...getFieldsValueM(), + ...getFieldsValueB(), + ...form.value, + invoiceDetails: feeTableRef.value.list, + }, + items: itemList, + queryString: JSON.stringify(query) + } + InvoiceApplicationBizSave(data) + .then((res) => { + if (res.succeeded) { + createMessage.success('保存成功') + go(`/invoiceapplyDetail?id=${res.data.id}`) + } else { + createMessage.error(res.message) + } + loading.value = false + }) + .catch((err) => { + loading.value = false + }) + }) } const tempNameId = ref('') function handleRender() { @@ -1100,14 +1136,17 @@ function handleSelect(value) { .box { padding: 0 20px; } -/deep/ .ant-checkbox-wrapper-checked .ant-checkbox-inner{ + +/deep/ .ant-checkbox-wrapper-checked .ant-checkbox-inner { background-color: #257afa; border-color: #257afa; } -/deep/ .ant-checkbox-disabled.ant-checkbox-checked .ant-checkbox-inner::after{ + +/deep/ .ant-checkbox-disabled.ant-checkbox-checked .ant-checkbox-inner::after { border-color: #f5f5f5; } -/deep/ .ant-checkbox-wrapper-checked .ant-checkbox-disabled + span{ + +/deep/ .ant-checkbox-wrapper-checked .ant-checkbox-disabled+span { color: #257afa; } diff --git a/src/views/operation/invoiceApply/index.vue b/src/views/operation/invoiceApply/index.vue index bc16515a..fbce08eb 100644 --- a/src/views/operation/invoiceApply/index.vue +++ b/src/views/operation/invoiceApply/index.vue @@ -2,45 +2,55 @@
-