|
|
|
@ -0,0 +1,913 @@
|
|
|
|
|
<!--
|
|
|
|
|
* @Description: 费用录入应收组件
|
|
|
|
|
* @Author: lijj
|
|
|
|
|
* @Date: 2024-05-07 15:19:07
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
|
|
|
|
<a-spin :spinning="loading">
|
|
|
|
|
<div class="cost-entry-receive">
|
|
|
|
|
<div class="flex">
|
|
|
|
|
<h4>发票明细</h4>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<input class="ds-tb-check" type="checkbox" v-model="allCheck" :indeterminate="someCheck" />
|
|
|
|
|
<hot-table ref="hotTb" :data="list" :settings="settings">
|
|
|
|
|
</hot-table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</a-spin>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import {
|
|
|
|
|
defineProps,
|
|
|
|
|
defineEmits,
|
|
|
|
|
ref,
|
|
|
|
|
watch,
|
|
|
|
|
watchEffect,
|
|
|
|
|
computed,
|
|
|
|
|
unref,
|
|
|
|
|
defineComponent,
|
|
|
|
|
onMounted,
|
|
|
|
|
reactive,
|
|
|
|
|
nextTick,
|
|
|
|
|
provide,
|
|
|
|
|
} from 'vue'
|
|
|
|
|
// 下拉框数据接口
|
|
|
|
|
import { GetFeeCurrencySelectList, GetFeeCodeSelectList, GetClientSelectInfoByCode, GetUnitSelectInfo } from '/@/api/common'
|
|
|
|
|
import { HotTable } from '@handsontable/vue3'
|
|
|
|
|
import { registerAllModules } from 'handsontable/registry'
|
|
|
|
|
import 'handsontable/dist/handsontable.full.min.css'
|
|
|
|
|
// 操作栏
|
|
|
|
|
import { feeStatusList } from './columns'
|
|
|
|
|
// 引入计费标准字典
|
|
|
|
|
import { feeUnitDict } from '/@/hooks/dict/index'
|
|
|
|
|
import { GetList, SubmitFee, DeleteFee, ApplyAudit, Withdraw } from './api'
|
|
|
|
|
// 结算对象下拉数据
|
|
|
|
|
import { GetClientListByCode } from '/@/api/common'
|
|
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'
|
|
|
|
|
const { createMessage } = useMessage()
|
|
|
|
|
defineComponent({
|
|
|
|
|
HotTable,
|
|
|
|
|
})
|
|
|
|
|
registerAllModules()
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
// 当前组件类型(应收或应付)
|
|
|
|
|
tbType: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '',
|
|
|
|
|
},
|
|
|
|
|
// 兄弟组件传过来的复制的数据
|
|
|
|
|
broData: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => {
|
|
|
|
|
return []
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// 业务ID
|
|
|
|
|
id: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '',
|
|
|
|
|
},
|
|
|
|
|
// 业务数据
|
|
|
|
|
details: { type: [Object, Array] },
|
|
|
|
|
// 业务类型
|
|
|
|
|
type: { type: [String, Number] },
|
|
|
|
|
// 表格高度
|
|
|
|
|
height: {
|
|
|
|
|
type: [String, Number],
|
|
|
|
|
default: '300'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const emits = defineEmits(['broInsert'])
|
|
|
|
|
// 费用名称字典
|
|
|
|
|
const feeDict = ref([])
|
|
|
|
|
// 费用标准字典
|
|
|
|
|
const unitDict = ref([])
|
|
|
|
|
// 币别字典
|
|
|
|
|
const currencyDict = ref([])
|
|
|
|
|
// 费用对象字典数据
|
|
|
|
|
const companyDict = ref([])
|
|
|
|
|
// 引入字典接口
|
|
|
|
|
import { getDictOption } from '/@/utils/dictUtil'
|
|
|
|
|
// 表格插件
|
|
|
|
|
const hotTb = ref(null)
|
|
|
|
|
// loading
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
// 需要定义新增的行数据(后台需要)
|
|
|
|
|
const row = {
|
|
|
|
|
selected: false,
|
|
|
|
|
feeStatus: '1',
|
|
|
|
|
feeStatusText: '录入状态',
|
|
|
|
|
id: '',
|
|
|
|
|
businessId: '',
|
|
|
|
|
feeCode: '',
|
|
|
|
|
feeName: '',
|
|
|
|
|
feeEnName: '',
|
|
|
|
|
quantity: 1,
|
|
|
|
|
exchangeRate: 1,
|
|
|
|
|
feeType: props.tbType == 'receive' ? 1 : 2,
|
|
|
|
|
}
|
|
|
|
|
// 表格绑定数据
|
|
|
|
|
const list = ref([])
|
|
|
|
|
provide('temFieldData', list)
|
|
|
|
|
// 表格编辑前初始数据
|
|
|
|
|
let oldData = []
|
|
|
|
|
// 全部勾选
|
|
|
|
|
const allCheck = ref(false)
|
|
|
|
|
// 部分勾选
|
|
|
|
|
const someCheck = ref(false)
|
|
|
|
|
// 定义表格所有列
|
|
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
data: 'selected',
|
|
|
|
|
type: 'checkbox',
|
|
|
|
|
title: ' ',
|
|
|
|
|
width: 32,
|
|
|
|
|
className: 'htCenter',
|
|
|
|
|
readOnly: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '序号',
|
|
|
|
|
width: 130,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '业务编号',
|
|
|
|
|
width: 130,
|
|
|
|
|
data: 'businessId',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '费用状态',
|
|
|
|
|
width: 70,
|
|
|
|
|
data: 'feeStatusText',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: props.tbType == 'receive' ? '应收费用名称' : '应付费用名称',
|
|
|
|
|
width: 130,
|
|
|
|
|
data: 'feeName',
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
// 下拉框数据,可以同步或者异步返回(异步需要process返回)
|
|
|
|
|
source: async (query, process) => {
|
|
|
|
|
const res = feeDict.value.length ? feeDict.value : (await GetFeeCodeSelectList())?.data
|
|
|
|
|
if (!feeDict.value.length) feeDict.value = res
|
|
|
|
|
console.log(res)
|
|
|
|
|
const dict = res.map((res) => {
|
|
|
|
|
return res.code + '-' + res.name
|
|
|
|
|
})
|
|
|
|
|
process(dict)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '费用英文名称',
|
|
|
|
|
width: 130,
|
|
|
|
|
data: 'feeEnName',
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
source: async (query, process) => {
|
|
|
|
|
const res = feeDict.value.length ? feeDict.value : (await GetFeeCodeSelectList())?.data
|
|
|
|
|
if (!feeDict.value.length) feeDict.value = res
|
|
|
|
|
const dict = res.map((res) => {
|
|
|
|
|
return res.enName
|
|
|
|
|
})
|
|
|
|
|
process(dict)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '客户类别',
|
|
|
|
|
width: 130,
|
|
|
|
|
data: 'customerTypeText',
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
source: async (query, process) => {
|
|
|
|
|
const results = await getDictOption('djy_cust_prop')
|
|
|
|
|
console.log(results)
|
|
|
|
|
const dict = results.map((item) => {
|
|
|
|
|
return item.value + '-' + item.name
|
|
|
|
|
})
|
|
|
|
|
process(dict)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '结算对象',
|
|
|
|
|
width: 130,
|
|
|
|
|
data: 'customerName',
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
source: async (query, process) => {
|
|
|
|
|
// 获取当前选中行
|
|
|
|
|
const rowIndex = hotTb.value.hotInstance.getActiveEditor().row
|
|
|
|
|
const code = list.value[rowIndex]?.customerType || null
|
|
|
|
|
GetClientListByCode({ code }).then((res) => {
|
|
|
|
|
const { data } = res
|
|
|
|
|
data.forEach((item) => {
|
|
|
|
|
item['label'] = item.shortName
|
|
|
|
|
item['value'] = item.codeName
|
|
|
|
|
})
|
|
|
|
|
companyDict.value = data
|
|
|
|
|
const dict = data.map((item) => {
|
|
|
|
|
return item.codeName + '-' + item.shortName
|
|
|
|
|
})
|
|
|
|
|
process(dict)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '单位标准',
|
|
|
|
|
width: 130,
|
|
|
|
|
data: 'unitText',
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
source: async (query, process) => {
|
|
|
|
|
if (unitDict.value && unitDict.value.length) {
|
|
|
|
|
const dict = unitDict.value.map((item) => {
|
|
|
|
|
return item.value + '-' + item.name
|
|
|
|
|
})
|
|
|
|
|
process(dict)
|
|
|
|
|
} else {
|
|
|
|
|
const results = await feeUnitDict()
|
|
|
|
|
unitDict.value = results
|
|
|
|
|
const dict = results.map((item) => {
|
|
|
|
|
return item.value + '-' + item.name
|
|
|
|
|
})
|
|
|
|
|
process(dict)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '税率',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'taxRate',
|
|
|
|
|
type: 'numeric',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '单价',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'unitPrice',
|
|
|
|
|
type: 'numeric',
|
|
|
|
|
format: '0.00',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '数量',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'quantity',
|
|
|
|
|
type: 'numeric',
|
|
|
|
|
format: '0',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '不含税单价',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'noTaxPrice',
|
|
|
|
|
type: 'numeric',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '不含税金额',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'noTaxAmount',
|
|
|
|
|
type: 'numeric',
|
|
|
|
|
format: '0.00',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '金额',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'amount',
|
|
|
|
|
type: 'numeric',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '币别',
|
|
|
|
|
width: 80,
|
|
|
|
|
data: 'currency',
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
source: async (query, process) => {
|
|
|
|
|
if (currencyDict.value.length) {
|
|
|
|
|
process(currencyDict.value)
|
|
|
|
|
} else {
|
|
|
|
|
const results = await GetFeeCurrencySelectList()
|
|
|
|
|
const dict = results.data?.map((res) => {
|
|
|
|
|
return res.codeName
|
|
|
|
|
})
|
|
|
|
|
currencyDict.value = dict
|
|
|
|
|
process(dict)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '汇率',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'exchangeRate',
|
|
|
|
|
type: 'numeric',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '备注',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'note',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '销项税率',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'accTaxRate',
|
|
|
|
|
type: 'numeric',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '销项税额',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'accTaxAmount',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '销项金额',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'accAmount',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '是否机密',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'isOpen',
|
|
|
|
|
type: 'checkbox',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '是否垫付',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'isAdvancedPay',
|
|
|
|
|
type: 'checkbox',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '是否禁开发票',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'isInvoice',
|
|
|
|
|
type: 'checkbox',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'FRT',
|
|
|
|
|
width: 120,
|
|
|
|
|
data: 'feeFrt',
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
source: ['PP', 'CC'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '录入人',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'createByName',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '录入日期',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'createTime',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '结算金额',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'settlementAmount',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '已开票金额',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'invoiceAmount',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '对账编号',
|
|
|
|
|
width: 140,
|
|
|
|
|
data: 'debitNo',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '修改人',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'updateByName',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '修改日期',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'updateTime',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '发票申请金额',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'orderInvoiceAmount',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '未开票金额',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'invoiceAmountRest',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '审核人',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'auditOperator',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '审核日期',
|
|
|
|
|
width: 100,
|
|
|
|
|
data: 'auditDate',
|
|
|
|
|
readOnly: true,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
// 表格配置项
|
|
|
|
|
const settings = {
|
|
|
|
|
height: props.height,
|
|
|
|
|
width: '100%',
|
|
|
|
|
autoWrapRow: true,
|
|
|
|
|
autoWrapCol: true,
|
|
|
|
|
// 每行的高度
|
|
|
|
|
rowHeights: 32,
|
|
|
|
|
fixedColumnsLeft: 1,
|
|
|
|
|
// 需要隐藏的列
|
|
|
|
|
hiddenColumns: {
|
|
|
|
|
columns: [1, 2],
|
|
|
|
|
indicators: true,
|
|
|
|
|
},
|
|
|
|
|
// 控制回车移动
|
|
|
|
|
enterMoves: 'row',
|
|
|
|
|
columnSorting: true,
|
|
|
|
|
// 设置排序的列和方向
|
|
|
|
|
// columnSorting: {
|
|
|
|
|
// column: 2, // 根据第三列排序
|
|
|
|
|
// sortOrder: ['asc', 'desc'] // 允许升序和降序排序
|
|
|
|
|
// },
|
|
|
|
|
// 如果通过复制或者填写校验出现错误,清空输入框
|
|
|
|
|
afterValidate: function (isValid, value, row, prop, source) {
|
|
|
|
|
if (!isValid) {
|
|
|
|
|
hotTb.value.hotInstance.setDataAtRowProp(row, prop, '')
|
|
|
|
|
// if (/^noTaxPrice|unitPrice|noTaxAmount|taxRate|exchangeRate$/.test(prop)) {
|
|
|
|
|
// if (!isNaN(value)) {
|
|
|
|
|
// hotTb.value.hotInstance.setDataAtRowProp(row, prop, value.toFixed(2))
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
columns: columns,
|
|
|
|
|
// 此行直接复制,必须(非商用)
|
|
|
|
|
licenseKey: 'non-commercial-and-evaluation',
|
|
|
|
|
// 定义所有单元格发生变化的回调处理
|
|
|
|
|
afterChange(changes, source) {
|
|
|
|
|
// 这里定义了编辑,自动填充和拷贝数据的处理逻辑
|
|
|
|
|
if (source === 'edit' || source === 'Autofill.fill' || source === 'CopyPaste.paste') {
|
|
|
|
|
let dict = {}
|
|
|
|
|
changes.forEach((res) => {
|
|
|
|
|
// 修改费用名称
|
|
|
|
|
if (res[1] === 'feeName') {
|
|
|
|
|
// 获取当前选中的字典对象数据
|
|
|
|
|
const item = feeDict.value.filter((item) => {
|
|
|
|
|
return changes[0][3].includes(item.name)
|
|
|
|
|
})
|
|
|
|
|
if (item) dict = item[0]
|
|
|
|
|
list.value[res[0]]['feeName'] = changes[0][3].split('-')[1]
|
|
|
|
|
list.value[res[0]]['feeEnName'] = dict['enName']
|
|
|
|
|
list.value[res[0]]['currency'] = dict['defaultCurrency']
|
|
|
|
|
list.value[res[0]]['unitText'] = dict['defaultUnitName']
|
|
|
|
|
list.value[res[0]]['unit'] = dict['defaultUnit']
|
|
|
|
|
list.value[res[0]]['customerTypeText'] = dict['defaultDebitName']
|
|
|
|
|
list.value[res[0]]['customerType'] = dict['defaultDebit']
|
|
|
|
|
list.value[res[0]]['isOpen'] = dict['isOpen']
|
|
|
|
|
list.value[res[0]]['isAdvancedPay'] = dict['isAdvancedPay']
|
|
|
|
|
list.value[res[0]]['isInvoice'] = dict['isInvoice']
|
|
|
|
|
list.value[res[0]]['feeFrt'] = dict['feeFrt']
|
|
|
|
|
list.value[res[0]]['feeCode'] = dict['code']
|
|
|
|
|
list.value[res[0]]['taxRate'] = dict['taxRate']
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// 修改费用英文名称
|
|
|
|
|
if (changes[0][1] === 'feeEnName') {
|
|
|
|
|
}
|
|
|
|
|
// 修改费用对象
|
|
|
|
|
if (changes[0][1] === 'customerName') {
|
|
|
|
|
const item = companyDict.value.filter((item) => {
|
|
|
|
|
return changes[0][3].includes(item.name)
|
|
|
|
|
})
|
|
|
|
|
if (item) dict = item[0]
|
|
|
|
|
list.value[changes[0][0]]['customerCode'] = dict?.value
|
|
|
|
|
list.value[changes[0][0]]['customerName'] = changes[0][3].split('-')[1]
|
|
|
|
|
}
|
|
|
|
|
// 修改客户类别
|
|
|
|
|
if (changes[0][1] === 'customerTypeText') {
|
|
|
|
|
getDictOption('djy_cust_prop').then((res) => {
|
|
|
|
|
const item = res.filter((item) => {
|
|
|
|
|
return changes[0][3].includes(item.name)
|
|
|
|
|
})
|
|
|
|
|
if (item) dict = item[0]
|
|
|
|
|
list.value[changes[0][0]]['customerType'] = dict?.value
|
|
|
|
|
list.value[changes[0][0]]['customerTypeText'] = changes[0][3].split('-')[1]
|
|
|
|
|
// 调用接口取费用对象
|
|
|
|
|
console.log(props.details)
|
|
|
|
|
GetClientSelectInfoByCode({ code: dict?.value, businessId: props.id, businessType: props.type }).then(res => {
|
|
|
|
|
list.value[changes[0][0]]['customerCode'] = res.data.clientId
|
|
|
|
|
list.value[changes[0][0]]['customerName'] = res.data.clientName
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 修改单位
|
|
|
|
|
if (changes[0][1] === 'unitText') {
|
|
|
|
|
const item = unitDict.value.filter((item) => {
|
|
|
|
|
return changes[0][3].includes(item.name)
|
|
|
|
|
})
|
|
|
|
|
if (item) dict = item[0]
|
|
|
|
|
list.value[changes[0][0]]['unit'] = dict?.value
|
|
|
|
|
list.value[changes[0][0]]['unitText'] = changes[0][3].split('-')[1]
|
|
|
|
|
GetUnitSelectInfo({ code: dict?.value, businessId: props.id, businessType: props.type }).then(res => {
|
|
|
|
|
list.value[changes[0][0]]['quantity'] = res.data.quantity
|
|
|
|
|
})
|
|
|
|
|
// 业务数据有件数,修改单位,带出件数
|
|
|
|
|
// const text = list.value[changes[0][0]]['unitText']
|
|
|
|
|
// if (text == '单票') {
|
|
|
|
|
// list.value[changes[0][0]]['quantity'] = 1
|
|
|
|
|
// } else if (text == '件数') {
|
|
|
|
|
// list.value[changes[0][0]]['quantity'] = props.details.pkgs
|
|
|
|
|
// } else if (text == '重量') {
|
|
|
|
|
// list.value[changes[0][0]]['quantity'] = props.details.kgs
|
|
|
|
|
// } else if (text == '尺码') {
|
|
|
|
|
// list.value[changes[0][0]]['quantity'] = props.details.cbm
|
|
|
|
|
// } else if (text == '计费吨') {
|
|
|
|
|
// let r = props.details.kgs
|
|
|
|
|
// const k = (props.details.pkgs || 0) / 1000
|
|
|
|
|
// if (k > r) {
|
|
|
|
|
// r = k
|
|
|
|
|
// }
|
|
|
|
|
// list.value[changes[0][0]]['quantity'] = r
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 修改币别
|
|
|
|
|
if (changes[0][1] === 'currencyName') {
|
|
|
|
|
const item = currencyDict.value.filter((item) => {
|
|
|
|
|
return item.name === changes[0][3]
|
|
|
|
|
})
|
|
|
|
|
if (item) dict = item[0]
|
|
|
|
|
list.value[changes[0][0]]['currency'] = dict?.codeName
|
|
|
|
|
}
|
|
|
|
|
// 当前操作的行
|
|
|
|
|
const index = changes[0][0]
|
|
|
|
|
// 修改不含税单价计算
|
|
|
|
|
if (changes[0][1] === 'noTaxPrice') {
|
|
|
|
|
// 单价
|
|
|
|
|
list.value[index].unitPrice = Number(
|
|
|
|
|
(changes[0][3] || 0) * ((list.value[index].taxRate || 0) / 100 + 1),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
// 金额
|
|
|
|
|
list.value[index].amount = Number(
|
|
|
|
|
(list.value[index].unitPrice || 0) * (list.value[index].quantity || 0),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
// 不含税金额
|
|
|
|
|
list.value[index].noTaxAmount = Number(
|
|
|
|
|
(changes[0][3] || 0) * (list.value[index].quantity || 0),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
}
|
|
|
|
|
// 修改单价计算
|
|
|
|
|
if (changes[0][1] === 'unitPrice') {
|
|
|
|
|
// 不含税单价
|
|
|
|
|
list.value[index].noTaxPrice = Number(
|
|
|
|
|
(changes[0][3] || 0) / ((list.value[index].taxRate || 0) / 100 + 1),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
// 金额
|
|
|
|
|
list.value[index].amount = Number(
|
|
|
|
|
(changes[0][3] || 0) * (list.value[index].quantity || 0),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
// 不含税金额
|
|
|
|
|
list.value[index].noTaxAmount = Number(
|
|
|
|
|
(list.value[index].noTaxPrice || 0) * (list.value[index].quantity || 0),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
}
|
|
|
|
|
// 修改数量
|
|
|
|
|
if (changes[0][1] === 'quantity') {
|
|
|
|
|
// 金额
|
|
|
|
|
list.value[index].amount = Number(
|
|
|
|
|
(changes[0][3] || 0) * (list.value[index].unitPrice || 0),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
// 不含税金额
|
|
|
|
|
list.value[index].noTaxAmount = Number(
|
|
|
|
|
(changes[0][3] || 0) * (list.value[index].noTaxPrice || 0),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
}
|
|
|
|
|
// 修改税率
|
|
|
|
|
if (changes[0][1] === 'taxRate') {
|
|
|
|
|
// 不含税单价
|
|
|
|
|
list.value[index].noTaxPrice = Number(
|
|
|
|
|
(list.value[index].unitPrice || 0) / ((changes[0][3] || 0) / 100 + 1),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
// 不含税金额
|
|
|
|
|
list.value[index].noTaxAmount = Number(
|
|
|
|
|
(list.value[index].noTaxPrice || 0) * (list.value[index].quantity || 0),
|
|
|
|
|
).toFixed(6)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
// 保存
|
|
|
|
|
const save = () => {
|
|
|
|
|
const postData = {
|
|
|
|
|
BusinessId: props.id,
|
|
|
|
|
items: list.value.filter((res) => {
|
|
|
|
|
return res.feeStatus == 1
|
|
|
|
|
}),
|
|
|
|
|
businessType: 1,
|
|
|
|
|
}
|
|
|
|
|
loading.value = true
|
|
|
|
|
SubmitFee(postData)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
init()
|
|
|
|
|
createMessage.success(res.message)
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 提交审核
|
|
|
|
|
const submit = (arr) => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
const ids = []
|
|
|
|
|
arr.forEach((res) => {
|
|
|
|
|
if (res.id) ids.push(res.id)
|
|
|
|
|
})
|
|
|
|
|
if (ids.length == arr.length) {
|
|
|
|
|
ApplyAudit({ id: '', ids })
|
|
|
|
|
.then((res) => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
createMessage.success(res.message)
|
|
|
|
|
init()
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
const postData = {
|
|
|
|
|
BusinessId: props.id,
|
|
|
|
|
items: arr,
|
|
|
|
|
}
|
|
|
|
|
SubmitFee(postData).then((res) => {
|
|
|
|
|
const { data } = res
|
|
|
|
|
const ids = data.map((item) => {
|
|
|
|
|
return item.id
|
|
|
|
|
})
|
|
|
|
|
ApplyAudit({ ids })
|
|
|
|
|
.then((res) => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
createMessage.success(res.message)
|
|
|
|
|
init()
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 撤销提交
|
|
|
|
|
const revoke = (ids) => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
Withdraw({ ids })
|
|
|
|
|
.then((res) => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
createMessage.success(res.message)
|
|
|
|
|
init()
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 取消编辑
|
|
|
|
|
const cancelEdit = () => {
|
|
|
|
|
const copy = JSON.parse(JSON.stringify(oldData))
|
|
|
|
|
list.value = copy
|
|
|
|
|
hotTb.value.hotInstance.loadData(copy)
|
|
|
|
|
}
|
|
|
|
|
// 历史引入
|
|
|
|
|
const history = (v) => {
|
|
|
|
|
v.forEach((row) => {
|
|
|
|
|
list.value.push(row)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 选择插入
|
|
|
|
|
const selectInsert = (v) => {
|
|
|
|
|
const selectData = JSON.parse(JSON.stringify(list.value))
|
|
|
|
|
// 选择插入
|
|
|
|
|
if (v === 1) {
|
|
|
|
|
let flag = false
|
|
|
|
|
selectData.forEach((item) => {
|
|
|
|
|
item.id = ''
|
|
|
|
|
item.feeStatus = 1
|
|
|
|
|
item.feeStatusText = '录入状态'
|
|
|
|
|
if (props.tbType == 'receive') {
|
|
|
|
|
item.feeType = 2
|
|
|
|
|
} else {
|
|
|
|
|
item.feeType = 1
|
|
|
|
|
}
|
|
|
|
|
if (item.selected) flag = true
|
|
|
|
|
})
|
|
|
|
|
if (!flag) return createMessage.warning('请勾选要复制的数据!')
|
|
|
|
|
const res = selectData.filter((item) => {
|
|
|
|
|
return item.selected
|
|
|
|
|
})
|
|
|
|
|
emits('broInsert', res)
|
|
|
|
|
} else {
|
|
|
|
|
// 全部插入
|
|
|
|
|
selectData.forEach((item) => {
|
|
|
|
|
item.id = ''
|
|
|
|
|
item.feeStatus = 1
|
|
|
|
|
item.feeStatusText = '录入状态'
|
|
|
|
|
item.selected = false
|
|
|
|
|
if (props.tbType == 'receive') {
|
|
|
|
|
item.feeType = 2
|
|
|
|
|
} else {
|
|
|
|
|
item.feeType = 1
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
console.log(selectData)
|
|
|
|
|
emits('broInsert', selectData)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 删除行
|
|
|
|
|
const deleteRow = async () => {
|
|
|
|
|
const ids = []
|
|
|
|
|
list.value.forEach((item) => {
|
|
|
|
|
if (item.selected && item.id) ids.push(item.id)
|
|
|
|
|
})
|
|
|
|
|
if (ids.length) {
|
|
|
|
|
loading.value = true
|
|
|
|
|
const data = await DeleteFee({ ids })
|
|
|
|
|
loading.value = false
|
|
|
|
|
createMessage.success(data.message)
|
|
|
|
|
}
|
|
|
|
|
const res = list.value.filter((item) => {
|
|
|
|
|
return !item.selected
|
|
|
|
|
})
|
|
|
|
|
list.value = res
|
|
|
|
|
hotTb.value.hotInstance.loadData(res)
|
|
|
|
|
}
|
|
|
|
|
// 页面初始化
|
|
|
|
|
const init = () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
const postData = {
|
|
|
|
|
pageCondition: {
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
sortConditions: [],
|
|
|
|
|
},
|
|
|
|
|
queryCondition: JSON.stringify([
|
|
|
|
|
{ FieldName: 'BusinessId', FieldValue: props.id, ConditionalType: 1 },
|
|
|
|
|
{ FieldName: 'FeeType', FieldValue: props.tbType == 'receive' ? 1 : 2, ConditionalType: 1 },
|
|
|
|
|
]),
|
|
|
|
|
}
|
|
|
|
|
GetList(postData)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
const { data } = res
|
|
|
|
|
data.forEach((item, index) => {
|
|
|
|
|
item['feeStatusText'] = feeStatusList[item.feeStatus]
|
|
|
|
|
if (item.createTime) item.createTime = item.createTime.split(' ')[0]
|
|
|
|
|
if (item.auditDate) item.auditDate = item.auditDate.split(' ')[0]
|
|
|
|
|
if (item.updateTime) item.updateTime = item.updateTime.split(' ')[0]
|
|
|
|
|
if (item.updateTime == '1900-01-01') item.updateTime = ''
|
|
|
|
|
})
|
|
|
|
|
list.value = data
|
|
|
|
|
// 设置原始数据,取消使用
|
|
|
|
|
oldData = JSON.parse(JSON.stringify(data))
|
|
|
|
|
if (data.length != 0) {
|
|
|
|
|
hotTb.value.hotInstance.updateSettings({
|
|
|
|
|
cells: function (row, col) {
|
|
|
|
|
// 设置费用状态不是录入状态的行为只读
|
|
|
|
|
const props = { readOnly: true }
|
|
|
|
|
// 审核通过(STATUS=0)
|
|
|
|
|
// 录入状态(STATUS=1)
|
|
|
|
|
// 提交审核(STATUS=2)
|
|
|
|
|
// 申请修改 (STATUS=3)
|
|
|
|
|
// 申请删除 (STATUS=4)
|
|
|
|
|
// 撤销申请 (STATUS=5)
|
|
|
|
|
// 驳回提交(STATUS=6)
|
|
|
|
|
// 驳回申请(STATUS=7)
|
|
|
|
|
// 部分结算(STATUS=8)
|
|
|
|
|
// 结算完毕(STATUS=9)
|
|
|
|
|
if (data[row]?.feeStatus != 1 && col != 0) {
|
|
|
|
|
// 配置不同状态的行颜色
|
|
|
|
|
if (data[row]?.feeStatus == 0 && col == 3) {
|
|
|
|
|
props['className'] = 'hot-green'
|
|
|
|
|
}
|
|
|
|
|
if (data[row]?.feeStatus == 2 && col == 3) {
|
|
|
|
|
props['className'] = 'hot-yellow'
|
|
|
|
|
}
|
|
|
|
|
if (data[row]?.feeStatus == 7 && col == 3) {
|
|
|
|
|
props['className'] = 'hot-red'
|
|
|
|
|
}
|
|
|
|
|
if ((data[row]?.feeStatus == 4 || data[row]?.feeStatus == 3) && col == 3) {
|
|
|
|
|
props['className'] = 'hot-red'
|
|
|
|
|
}
|
|
|
|
|
return props
|
|
|
|
|
} else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
hotTb.value.hotInstance.loadData(list.value)
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 增加行
|
|
|
|
|
const add = () => {
|
|
|
|
|
const hot = hotTb.value.hotInstance
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
hot.selectCell(list.value.length - 1, 4)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// 数据初始化
|
|
|
|
|
init()
|
|
|
|
|
})
|
|
|
|
|
watchEffect(() => {
|
|
|
|
|
// 全选
|
|
|
|
|
if (allCheck.value) {
|
|
|
|
|
list.value.forEach((item) => {
|
|
|
|
|
item.selected = true
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 取消全选
|
|
|
|
|
list.value.forEach((item) => {
|
|
|
|
|
item.selected = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
watch(
|
|
|
|
|
() => props.broData,
|
|
|
|
|
(row) => {
|
|
|
|
|
row.forEach((item) => {
|
|
|
|
|
list.value.push(item)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
watch(
|
|
|
|
|
() => props.id,
|
|
|
|
|
() => {
|
|
|
|
|
init()
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
watch(
|
|
|
|
|
list.value,
|
|
|
|
|
(val) => {
|
|
|
|
|
let a = 0
|
|
|
|
|
let b = 0
|
|
|
|
|
val.forEach((item) => {
|
|
|
|
|
if (item.selected) {
|
|
|
|
|
a += 1
|
|
|
|
|
} else {
|
|
|
|
|
b += 1
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (a == 0) {
|
|
|
|
|
allCheck.value = false
|
|
|
|
|
}
|
|
|
|
|
if (b == 0) {
|
|
|
|
|
allCheck.value = true
|
|
|
|
|
}
|
|
|
|
|
if (a != 0 && b != 0) {
|
|
|
|
|
someCheck.value = true
|
|
|
|
|
} else {
|
|
|
|
|
someCheck.value = false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
deep: true,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.cost-entry-receive {
|
|
|
|
|
.flex {
|
|
|
|
|
h4 {
|
|
|
|
|
margin: 10px 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.line {
|
|
|
|
|
width: 3px;
|
|
|
|
|
height: 12px;
|
|
|
|
|
background: #489cef;
|
|
|
|
|
position: relative;
|
|
|
|
|
top: 10px;
|
|
|
|
|
}
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
</style>
|