<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
	<div>
		<el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="status === 'audit' || status === 'taskFormDetail'"
				 label-width="160px" @submit.native.prevent>
			<el-row  :gutter="15">
				<el-col :span="24">
					<vxe-table
						border
						:footer-method="footerMethod2"
						show-overflow
						show-footer
						ref="baseTable"
						:key="baseKey"
						class="vxe-table-element"
						:data="dataList"
						style="margin-left: 5em"
						keep-source
						highlight-current-row
					>
						<vxe-table-column field="no" align="center" title="付款编号" :edit-render="{}" show-overflow="title">
							<template #default="scope">
								<el-link  type="primary" :underline="false" @click="view(scope.row.id)">{{scope.row.no}}</el-link>
							</template>
						</vxe-table-column>
						<vxe-table-column field="paymentLower" align="center" title="付款金额" :edit-render="{}"></vxe-table-column>
						<vxe-table-column field="refund" align="center" title="冲抵金额" :edit-render="{}"></vxe-table-column>
						<vxe-table-column   field="finalMoney" align="center"   title="剩余付款金额" :edit-render="{}"></vxe-table-column>
						<vxe-table-column   field="paymentUser" align="center"   title="付款人" :edit-render="{}"></vxe-table-column>
						<vxe-table-column   field="paymentOffice" align="center"   title="付款部门" :edit-render="{}"></vxe-table-column>
						<vxe-table-column   field="paymentTime" align="center"   title="付款时间" :edit-render="{}"></vxe-table-column>
					</vxe-table>
				</el-col>
			</el-row>

		</el-form>
		<PaymentDia ref="paymentDia"></PaymentDia>
	</div>
</template>

<script>
	import PaymentService from '@/api/jy/PaymentService'
	import PaymentDia from '@/views/jy/payment/PaymentDia'
	import XEUtils from "xe-utils";
	export default {
		props: {
			businessId: {
				type: String,
				default: ''
			},
			formReadOnly: {
				type: Boolean,
				default: false
			},
			status: {
				type: String,
				default: ''
			}
		},
		data () {
			return {
				title: '',
				method: '',
				loading: false,
				baseKey: '',
				keyWatch: '',
				dataList:[]
			}
		},
		PaymentService:null,
		created () {
			console.log('jld ')
			this.paymentService=new PaymentService()
		},
		mounted () {
		},
		activated () {
		},
		components: {
			PaymentDia
		},
		computed: {
			bus: {
				get () {
					return this.businessId
				},
				set (val) {
					this.businessId = val
				}
			}
		},
		watch: {
			'keyWatch': {
				handler (newVal) {
					if (this.bus) {
						if (this.bus !== 'false') {
							this.init('', this.bus)
						}
					} else {
						this.$nextTick(() => {
							this.$refs.inputForm.resetFields()
						})
					}
				}
			},
			'loading': {
				handler (newVal) {
					this.$emit('changeLoading', newVal)
				}
			}
		},
		methods: {
			getKeyWatch(keyWatch) {
				this.keyWatch = keyWatch
			},
			init(method, id) {
				this.method = method
				this.inputForm={
					id: '',
				}
				this.inputForm.id = id
				this.loading = false
				this.$nextTick(() => {
					this.$refs.inputForm.resetFields()
					this.loading = true
					this.paymentService.queryByProjectId(this.inputForm.id).then((data)=>{
						console.log('data',data)
						this.dataList = data
						this.loading = false
					})
				})
			},
			close() {
				this.inputForm = {
					id: '',

				}
				this.visible = false
			},
			footerMethod2({columns, data}) {
				const footerData = [
					columns.map((column, columnIndex) => {
						if (columnIndex === 0) {
							return '金额汇总(元)'
						}
						if (['paymentLower'].includes(column.property)) {
							// eslint-disable-next-line no-undef
							this.dataList = XEUtils.sum(data, column.property)
							return XEUtils.sum(data, column.property)
						}
						if (['refund'].includes(column.property)) {
							// eslint-disable-next-line no-undef
							this.dataList = XEUtils.sum(data, column.property)
							return XEUtils.sum(data, column.property)
						}
						if (['finalMoney'].includes(column.property)) {
							// eslint-disable-next-line no-undef
							this.dataList = XEUtils.sum(data, column.property)
							return XEUtils.sum(data, column.property)
						}
						return null
					})
				]
				return footerData
			},
			// 查看
			view (id) {
				this.$refs.paymentDia.init('view',id);
			},


		}

	}
</script>
<style scoped>
	/deep/ .el-input-number .el-input__inner {
		text-align: left;
	}
	/deep/ .vxe-footer--row .vxe-footer--column:nth-child(1) .vxe-cell--item {
		font-weight:700;
	}
</style>
