@@ -100,18 +100,28 @@
< / el-form-item >
< / el-col >
< el-col :span = "6" >
< el-form-item label = "结算组织 " prop = "deptId " >
< el-cascader
v-if = "!readonly"
:model-value = "deptCascaderValu e"
:options = "deptTreeOptions "
:props = "deptCascaderProps "
placeholder = "请选择结算组织(合同承办部门)"
filterable
clearable
@change ="handleDeptChange"
/ >
< el-input v-else :model-value = "form.deptName" disabled / >
< el-form-item label = "所属合同 " prop = "contractNo " >
< el-tooltip
:content = "form.contractName"
:disabled = "!form.contractNam e"
placement = "top "
:show-after = "200 "
>
< div class = "receipt-form-page__overflow-trigger" >
< el-input :model-value = "form.contractNo" readonly placeholder = "请选择承运商合同" >
< template v-if = "!readonly" # append >
< el-tooltip content = "选择承运商合同" placement = "top" >
< el-button :icon = "Search" @click ="openContractDialog" / >
< / el-tooltip >
< / template >
< / el-input >
< / div >
< / el-tooltip >
< / el-form-item >
< / el-col >
< el-col :span = "6" >
< el-form-item label = "承办部门" >
< el-input :model-value = "form.deptName" disabled placeholder = "从所属合同带出" / >
< / el-form-item >
< / el-col >
< / el-row >
@@ -214,6 +224,48 @@
:query-api = "apiQueryInvoicePool"
@confirm ="handleInvoicePicked"
/ >
< el-dialog v-model = "contractDialog.visible" title="选择承运商合同" width="920px" append -to -body >
< el-form :model = "contractDialog.query" label -position = " right " label -width = " auto " inline @submit.prevent >
< el -form -item label = "合同编号" >
< el-input
v-model = "contractDialog.query.contractNo"
clearable
placeholder = "请输入"
@keyup.enter ="searchContracts"
/ >
< / el-form-item >
< el-form-item label = "合同名称" >
< el-input
v-model = "contractDialog.query.contractName"
clearable
placeholder = "请输入"
@keyup.enter ="searchContracts"
/ >
< / el-form-item >
< el-form-item >
< el-button type = "primary" :icon = "Search" @click ="searchContracts" > 查询 < / el -button >
< el-button @click ="resetContractQuery" > 重置 < / el -button >
< / el-form-item >
< / el-form >
< el-table v-loading = "contractDialog.loading" :data="contractDialog.rows" border >
< el-table-column prop = "contractNo" label = "合同编号" min -width = " 180 " show -overflow -tooltip / >
< el-table-column prop = "contractName" label = "合同名称" min -width = " 200 " show -overflow -tooltip / >
< el-table-column prop = "organizationName" label = "承办部门" min -width = " 160 " show -overflow -tooltip / >
< el-table-column label = "操作" width = "80" align = "center" >
< template # default = "{ row }" >
< el-button type = "primary" link @click ="pickContract(row)" > 选择 < / el -button >
< / template >
< / el-table-column >
< / el-table >
< el-pagination
v -model :current-page = "contractDialog.page.current"
v -model :page-size = "contractDialog.page.size"
:total = "contractDialog.page.total"
layout = "total, prev, pager, next"
@ current -change = " loadContracts "
/ >
< / el-dialog >
< / basic-container >
< / template >
@@ -221,7 +273,7 @@
import { Search } from '@element-plus/icons-vue' ;
import { mapGetters } from 'vuex' ;
import * as api from '@/api/payment/invoiceReceipt' ;
import { getDeptTree } from '@/api/system/dept ' ;
import { getList as getContractList } from '@/api/business/contract-manage ' ;
import KingdeeInvoicePoolDialog from '@/components/kingdee-invoice-pool-dialog/main.vue' ;
import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue' ;
import { getMkPublicDetail } from '@/api/mk-process' ;
@@ -247,6 +299,8 @@ const emptyForm = () => ({
customerEmails : [ ] ,
departmentEmails : [ ] ,
projectName : '' ,
contractNo : '' ,
contractName : '' ,
deptId : null ,
deptName : '' ,
payerName : '' ,
@@ -269,16 +323,19 @@ export default {
customerEmailOptions : [ ] ,
departmentEmailOptions : [ ] ,
invoiceItems : [ ] ,
deptTreeOptions : [ ] ,
deptMap : new Map ( ) ,
// 结算组织=合同承办部门:部门树级联单选(取末级 id),后端沿部门树上溯平台公司取金蝶组织
deptCascaderProps : { checkStrictly : true , emitPath : true } ,
contractDialog : {
visible : false ,
loading : false ,
rows : [ ] ,
page : { current : 1 , size : 10 , total : 0 } ,
query : { contractNo : '' , contractName : '' } ,
} ,
invoiceDialog : {
visible : false ,
} ,
rules : {
invoiceNo : [ { required : true , validator : this . validateInvoice , trigger : 'change' } ] ,
deptId : [ { required : true , validator : this . validateDept , trigger : 'change' } ] ,
contractNo : [ { required : true , validator : this . validateContract , trigger : 'change' } ] ,
customerEmails : [ { validator : this . validateEmails , trigger : 'change' } ] ,
departmentEmails : [ { validator : this . validateEmails , trigger : 'change' } ] ,
} ,
@@ -299,12 +356,6 @@ export default {
const code = this . recordId ? 'invoice_receipt_edit' : 'invoice_receipt_add' ;
return this . hasPermission ( code ) ;
} ,
deptCascaderValue ( ) {
if ( this . form . deptId === null || this . form . deptId === undefined || this . form . deptId === '' ) {
return [ ] ;
}
return [ String ( this . form . deptId ) ] ;
} ,
} ,
created ( ) {
this . initialize ( ) ;
@@ -339,7 +390,6 @@ export default {
. filter ( Boolean ) ;
} ,
async initialize ( ) {
this . loadDepartments ( ) ;
if ( this . isPublicViewPage ) {
await this . loadPublicDetail ( ) ;
return ;
@@ -380,9 +430,9 @@ export default {
}
callback ( ) ;
} ,
validateDept ( rule , value , callback ) {
if ( this . form . deptId === null || this . form . deptId === undefined || this . form . deptId === '' ) {
callback ( new Error ( '请选择结算组织 ' ) ) ;
validateContract ( rule , value , callback ) {
if ( ! this . form . contractNo ) {
callback ( new Error ( '请选择所属合同 ' ) ) ;
return ;
}
callback ( ) ;
@@ -454,47 +504,43 @@ export default {
this . invoiceItems = [ ] ;
}
} ,
loadDepartments ( ) {
// 结算组织取租户部门树(过滤外部组织),选中取末级部门 id
getDeptTree ( this . userInfo ? . tenantId )
. then ( response => {
const rows = this . excludeExternalOrganization ( this . unwrapData ( response ) || [ ] ) ;
this . deptTreeOptions = this . toDeptCascaderOptions ( rows ) ;
this . deptMap = new Map ( ) ;
this . flattenDepartments ( rows ) . forEach ( item =>
this . deptMap . set ( String ( item . id ) , item . title || item . deptName || item . name )
) ;
} )
. catch ( ( ) => { } ) ;
// 所属合同=承运商合同:选择后带出承办部门(结算组织=承办部门对应平台公司金蝶编码,后端派生)
openContractDialog ( ) {
this . contractDialog . visible = true ;
this . searchContracts ( ) ;
} ,
excludeExternalOrganization ( list = [ ] ) {
return list . reduce ( ( result , item ) => {
const deptName = item . title || item . deptName || item . name ;
if ( String ( deptName || '' ) . trim ( ) === '外部组织' ) return result ;
result . push ( {
... item ,
children : item . children ? . length
? this . excludeExternalOrganization ( item . children )
: item . children ,
searchContracts ( ) {
this . contractDialog . page . current = 1 ;
this . loadContracts ( ) ;
} ,
resetContractQuery ( ) {
this . contractDialog . query = { contractNo : '' , contractName : '' } ;
this . searchContracts ( ) ;
} ,
async loadContracts ( ) {
this . contractDialog . loading = true ;
try {
const res = await getContractList ( this . contractDialog . page . current , this . contractDialog . page . size , {
... this . contractDialog . query ,
contractCategory : '承运商合同' ,
approvalStatuses : 'approved,change_approved' ,
} ) ;
return result ;
} , [ ] ) ;
const data = this . unwrapData ( res ) || { } ;
this . contractDialog . rows = data . records || [ ] ;
this . contractDialog . page . total = Number ( data . total || 0 ) ;
} finally {
this . contractDialog . loading = false ;
}
} ,
toDeptCascaderOptions ( list = [ ] ) {
return list . map ( item => ( {
label : item . title || item . deptName || item . name ,
value : item . id == null || item . id === '' ? '' : String ( item . id ) ,
children : item . children ? . length ? this . toDeptCascaderOptions ( item . children ) : undefined ,
} ) ) ;
} ,
flattenDepartments ( rows ) {
return ( rows || [ ] ) . flatMap ( item => [ item , ... this . flattenDepartments ( item . children || [ ] ) ] ) ;
} ,
handleDeptChange ( value ) {
const deptId = Array . isArray ( value ) ? value . at ( - 1 ) : value ;
this . form . deptId = deptId || null ;
this . form . deptName = deptId ? this . deptMap . get ( String ( deptId ) ) || '' : '' ;
this . $refs . formRef ? . validateField ( 'deptId' ) . catch ( ( ) => { } ) ;
pickContract ( row ) {
if ( ! row ) return ;
Object . assign ( this . form , {
contractNo : row . contractNo ,
contractName : row . contractName ,
deptName : row . organizationName ,
} ) ;
this . contractDialog . visible = false ;
this . $refs . formRef ? . validateField ( 'contractNo' ) . catch ( ( ) => { } ) ;
} ,
openSettlementDetail ( row ) {
const id = row . formalSettlementId || row . settlementId || row . id ;
@@ -527,9 +573,8 @@ export default {
departmentEmails : this . form . departmentEmails . join ( ';' ) ,
attachmentsJson : JSON . stringify ( this . form . attachments || [ ] ) ,
remark : this . form . remark ,
// 结算组织=页面手选部门(先票后款不挂结算单,认领关系由结算单侧维护,不再传 settlements )
deptId : this . form . deptId ,
deptName : this . form . deptName ,
// 所属合同仅传编号,合同名称/承办部门由后端按编号带出(结算组织=合同承办部门 )
contractNo : this . form . contractNo ,
} ;
} ,
async saveDraft ( ) {