<template>
|
<div class="app-container">
|
<!--工具栏-->
|
<div class="head-container">
|
<div v-if="crud.props.searchToggle">
|
<!-- 搜索 -->
|
<el-select v-model="query.contractId" filterable clearable placeholder="所属合同" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
|
<el-option
|
v-for="item in contractList"
|
:key="item.contractId"
|
:label="item.contractNumber + ' - ' + item.contractName"
|
:value="item.contractId"
|
/>
|
</el-select>
|
<el-select v-model="query.fundType" filterable clearable placeholder="款项类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
|
<el-option
|
v-for="item in dict[fundType]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
<rrOperation :crud="crud" />
|
</div>
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
<crudOperation :permission="permission" />
|
<!--表单组件-->
|
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="630px">
|
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="80px">
|
<el-form-item label="所属合同" prop="contractId">
|
<el-select v-model="form.contractId" filterable clearable placeholder="请选择" style="width: 495px;" @change="contractIdChange">
|
<el-option
|
v-for="item in contractList"
|
:key="item.contractId"
|
:label="item.contractNumber + ' - ' + item.contractName"
|
:value="item.contractId"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="付款时间" prop="paymentTime">
|
<el-date-picker v-model="form.paymentTime" type="datetime" style="width: 200px;" />
|
</el-form-item>
|
<el-form-item label="款项类型" prop="fundType">
|
<el-select v-model="form.fundType" filterable placeholder="请选择" style="width: 200px;">
|
<el-option
|
v-for="item in dict[fundType]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="付款金额" prop="paymentAmount">
|
<money-input :key="random" v-model="form.paymentAmount" show-ch :width="495" />
|
</el-form-item>
|
<!--魏传栋 - 始-->
|
<el-form-item label="所属公司" prop="companyId">
|
<el-select v-model="form.companyId" filterable clearable placeholder="请选择" style="width: 200px;">
|
<el-option
|
v-for="item in companyList"
|
:key="item.id"
|
:label="item.label"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="收支类型" prop="paymentType">
|
<el-select v-model="form.paymentType" filterable clearable placeholder="请选择" style="width: 200px;">
|
<el-option
|
v-for="item in dict[paymentType]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<!--魏传栋 - 终-->
|
<span v-if="form.fundType == fundContract">
|
<el-divider>合同费款项所属</el-divider>
|
<el-form-item label="所属内容" prop="fundBelong">
|
<el-input v-model="form.fundBelong" style="width: 495px;" />
|
</el-form-item>
|
</span>
|
<span v-if="form.fundType == fundService">
|
<el-divider>服务费款项所属</el-divider>
|
<el-form-item label="所属年度" prop="fundBelongYear">
|
<el-input v-model="form.fundBelongYear" style="width: 200px;" @change="changeFundBelongYear" />
|
</el-form-item>
|
<el-form-item label="">
|
<span style="width: 200px;" />
|
</el-form-item>
|
<el-form-item label="开始日期" prop="fundBelongStart">
|
<el-date-picker v-model="form.fundBelongStart" type="date" style="width: 200px;" />
|
</el-form-item>
|
<el-form-item label="结束日期" prop="fundBelongEnd">
|
<el-date-picker v-model="form.fundBelongEnd" type="date" style="width: 200px;" />
|
</el-form-item>
|
</span>
|
<el-form-item label="相关发票">
|
<el-select v-model="form.contractInvoiceIds" filterable multiple placeholder="请选择" style="width: 495px;">
|
<el-option
|
v-for="item in contractInvoiceList"
|
:key="item.invoiceId"
|
:label="item.afterTaxAmount"
|
:value="item.invoiceId"
|
>
|
<span style="float: left">开票金额:{{ item.afterTaxAmount }}</span>
|
<span style="float: right; color: #8492a6; font-size: 13px">开票时间:{{ item.billingTime }}</span>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="备注信息" prop="remarks">
|
<el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 495px;" />
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
<el-button :loading="crud.status.cu === 2" type="primary" @click="submitCU">确认</el-button>
|
</div>
|
</el-dialog>
|
<!--表格渲染-->
|
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
<el-table-column type="selection" width="55" />
|
<el-table-column :show-overflow-tooltip="true" prop="contractName" label="所属合同" />
|
<el-table-column :show-overflow-tooltip="true" prop="paymentTime" label="付款时间" />
|
<el-table-column :show-overflow-tooltip="true" prop="fundType" label="款项类型">
|
<template slot-scope="scope">
|
{{ dict.label[fundType][scope.row.fundType] }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="paymentAmount" label="付款金额">
|
<template slot-scope="scope">
|
{{ crud.toMoney(scope.row.paymentAmount) }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="companyName" label="所属公司" />
|
<el-table-column :show-overflow-tooltip="true" prop="paymentType" label="收支类型">
|
<template slot-scope="scope">
|
{{ dict.label[paymentType][scope.row.paymentType] }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="fundBelong" label="款项所属">
|
<template slot-scope="scope">
|
<span v-if="scope.row.fundBelong != null">
|
{{ scope.row.fundBelong }}
|
</span>
|
<span v-if="scope.row.fundBelongStart != null && scope.row.fundBelongEnd != null">
|
{{ scope.row.fundBelongStart.substring(0,10) }} 至 {{ scope.row.fundBelongEnd.substring(0,10) }} 服务费
|
</span>
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注信息" />
|
<el-table-column v-if="checkPer(['admin','contractPayment:edit','contractPayment:del'])" label="操作" width="150px" align="center">
|
<template slot-scope="scope">
|
<udOperation
|
:data="scope.row"
|
:permission="permission"
|
/>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!--分页组件-->
|
<pagination />
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import crudContractPayment from '@/api/contract/contractPayment'
|
import crudSysCompany from '@/api/system/sysCompany'
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
import rrOperation from '@crud/RR.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
import udOperation from '@crud/UD.operation'
|
import pagination from '@crud/Pagination'
|
import moneyInput from '@/views/assembly/moneyInput/index.vue'
|
import constant from '@/utils/constant'
|
import crudContract from '@/api/contract/contract'
|
import crudContractInvoice from '@/api/contract/contractInvoice'
|
|
const defaultForm = { paymentId: null, contractId: null, paymentTime: null, fundType: null, paymentAmount: null, fundBelong: null, fundBelongYear: null, fundBelongStart: null, fundBelongEnd: null, remarks: null, contractInvoiceIds: [], createBy: null, updateBy: null, createTime: null, updateTime: null, companyId: null, paymentType: null }
|
export default {
|
name: 'ContractPayment',
|
components: { pagination, crudOperation, rrOperation, udOperation, moneyInput },
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
dicts: [constant.FUND_TYPE, constant.CONTRACR_TYPE_COST],
|
cruds() {
|
return CRUD({ title: '合同付款', url: 'api/contractPayment', idField: 'paymentId', sort: 'paymentId,desc', crudMethod: { ...crudContractPayment }})
|
},
|
data() {
|
// 付款金额校验规则
|
var validatePaymentAmount = (rule, value, callback) => {
|
if (value !== null) {
|
if (isNaN(Number(value))) {
|
callback(new Error('请输入数字值'))
|
} else {
|
if (value < 0 || value > 1000000000) {
|
callback(new Error('付款金额不能超过10亿'))
|
} else {
|
callback()
|
}
|
}
|
} else {
|
callback(new Error('付款金额不能为空'))
|
}
|
}
|
return {
|
permission: {
|
add: ['admin', 'contractPayment:add'],
|
edit: ['admin', 'contractPayment:edit'],
|
del: ['admin', 'contractPayment:del'],
|
download: ['admin', 'contractPayment:download']
|
},
|
rules: {
|
contractId: [
|
{ required: true, message: '请选择所属合同', trigger: 'change' }
|
],
|
paymentTime: [
|
{ required: true, message: '请选择付款时间', trigger: 'change' }
|
],
|
fundType: [
|
{ required: true, message: '请选择款项类型', trigger: 'change' }
|
],
|
paymentAmount: [
|
{ required: true, validator: validatePaymentAmount, trigger: 'blur' }
|
],
|
fundBelong: [
|
{ min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur' }
|
],
|
fundBelongYear: [
|
{ required: true, message: '请输入所属年度', trigger: 'blur' }
|
],
|
fundBelongStart: [
|
{ required: true, message: '请选择款项开始日期', trigger: 'change' }
|
],
|
fundBelongEnd: [
|
{ required: true, message: '请选择款项结束日期', trigger: 'change' }
|
],
|
companyId: [
|
{ required: true, message: '请选择所属公司', trigger: 'change' }
|
],
|
paymentType: [
|
{ required: true, message: '请选择收支类型', trigger: 'change' }
|
]
|
},
|
queryTypeOptions: [
|
{ key: 'contractId', display_name: '所属合同' },
|
{ key: 'fundType', display_name: '款项类型' }
|
],
|
// 字典:款项类型
|
fundType: constant.FUND_TYPE,
|
// 字典:款项类型-合同费
|
fundContract: constant.FUND_CONTRACT,
|
// 字典:款项类型-服务费
|
fundService: constant.FUND_SERVICE,
|
// 随机数
|
random: 0,
|
// 合同数据
|
contractList: [],
|
// 发票数据
|
contractInvoiceList: [],
|
// 当前合同信息
|
currentContract: {},
|
// 公司
|
companyList: [],
|
// 字典:收支类型
|
paymentType: constant.CONTRACR_TYPE_COST
|
}
|
},
|
methods: {
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
[CRUD.HOOK.beforeRefresh]() {
|
// 获取合同数据
|
this.getContractList()
|
// 检索条件赋值
|
if (this.$route.query.contractId != null && this.crud.query.contractId === undefined) {
|
this.$set(this.crud.query, 'contractId', Number(this.$route.query.contractId))
|
}
|
// 获取公司数据
|
crudSysCompany.getAll().then(res => {
|
this.companyList = res
|
})
|
return true
|
},
|
// 获取合同数据
|
getContractList() {
|
const that = this
|
// 获取合同数据
|
crudContract.getAll().then(res => {
|
// 获取合同数据
|
that.contractList = res
|
// 判断是否传参进入
|
if (that.$route.query.contractId != null) {
|
// 循环合同数据
|
for (let i = 0; i < res.length; i++) {
|
if (res[i].contractId === Number(that.$route.query.contractId)) {
|
// 当前合同信息
|
that.currentContract = res[i]
|
}
|
}
|
}
|
})
|
},
|
// 钩子:开始 "新建/编辑" - 之前
|
[CRUD.HOOK.beforeToCU]() {
|
const that = this
|
// 随机数
|
that.random = Math.random()
|
// 表单合同所属年份
|
if (that.crud.form.fundBelongStart != null) {
|
that.crud.form.fundBelongYear = that.crud.form.fundBelongStart.substring(0, 4)
|
}
|
},
|
// 钩子:新建 - 之前
|
[CRUD.HOOK.beforeToAdd]() {
|
const that = this
|
// 判断检索条件
|
if (that.crud.query.contractId !== undefined) {
|
// 表单赋值
|
that.$set(that.crud.form, 'contractId', Number(that.crud.query.contractId))
|
// 所属合同变更
|
that.contractIdChange()
|
}
|
},
|
// 钩子:编辑 - 之前
|
[CRUD.HOOK.beforeToEdit]() {
|
const that = this
|
// 获取发票数据
|
that.getContractInvoice()
|
},
|
// 所属合同变更
|
contractIdChange() {
|
const that = this
|
// 相关发票
|
that.crud.form.contractInvoiceIds = []
|
// 获取发票数据
|
that.contractInvoiceList = []
|
// 判断所属合同是否为空
|
if (that.crud.form.contractId != null && that.crud.form.contractId !== '') {
|
that.currentContract = that.contractList.filter(item => item.contractId === that.crud.form.contractId)[0] || {}
|
// 获取发票数据
|
that.getContractInvoice()
|
} else {
|
that.currentContract = {}
|
}
|
},
|
// 获取发票数据
|
getContractInvoice() {
|
const that = this
|
// 获取发票数据
|
crudContractInvoice.getAll({ contractId: that.crud.form.contractId }).then(res => {
|
// 获取发票数据
|
that.contractInvoiceList = res
|
})
|
},
|
// 表单提交
|
submitCU() {
|
const that = this
|
// 判断款项类型
|
if (that.crud.form.fundType === that.fundContract) {
|
// 款项所属年度
|
that.crud.form.fundBelongYear = null
|
// 款项开始日期
|
that.crud.form.fundBelongStart = null
|
// 款项结束日期
|
that.crud.form.fundBelongEnd = null
|
} else if (that.crud.form.fundType === that.fundService) {
|
// 款项所属
|
that.crud.form.fundBelong = null
|
} else {
|
// 暂无
|
}
|
// 表单提交
|
that.crud.submitCU()
|
},
|
// 所属年度变更
|
changeFundBelongYear() {
|
const that = this
|
if (!that.crud.form.id) {
|
// 款项开始日期
|
that.crud.form.fundBelongStart = that.crud.form.fundBelongYear + that.crud.toDate(that.currentContract.serviceStartsDate).substring(4, 10)
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|