<template>
	<view class="jnpf-wrap jnpf-wrap-form" v-if="!loading">
		<u-form :model="dataForm" :rules="rules" ref="dataForm" :errorType="['toast']" label-position="left"
			label-align="left" :label-width="labelwidth" class="jnpf-form">
			<view class="u-p-l-20 u-p-r-20 ">
				<u-form-item>
				
					<view style="float: left; width:8px; height: 16px;background-color: cadetblue;margin-right: 8px;">
					</view>单据类型
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item>
					<jnpf-text
						:textStyle='{"color":"#000000","font-weight":"normal","text-decoration":"none","font-size":12,"line-height":32,"font-style":"normal","text-align":"left"}'
						value="       不同的单据类型，需要选择不同的收货信息" content="       不同的单据类型，需要选择不同的收货信息">
					</jnpf-text>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('type')" :required="requiredList.type" label="类型" prop="type">
					<jnpf-radio v-model="dataForm.type" :disabled="judgeWrite('type')" @change="changeData('type',-1)"
						optionType="button" direction="horizontal" :props="typeProps" :options="typeOptions">
					</jnpf-radio>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 ">
				<u-form-item>
					<view style="float: left; width:8px; height: 16px;background-color: cadetblue;margin-right: 8px;">
					</view>基础配置
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('code')" :required="requiredList.code" label="单据编号" prop="code">
					<u-input v-model="dataForm.code" disabled @change="changeData('code',-1)" 
						placeholder="系统自动生成" :style='{"width":"100%"}' readonly>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('settlementId')" :required="requiredList.settlementId" label="结算单号"
					prop="settlementId">
					<jnpf-popup-select v-model="dataForm.settlementId" :disabled="judgeWrite('settlementId')"
						@change="changeData('settlementId',-1)" :rowIndex="null" :formData="dataForm"
						:templateJson="interfaceRes.settlementId" clearable propsValue="id" popupWidth="800px"
						popupTitle="选择数据" popupType="dialog" relationField='code' vModel='settlementId'
						:columnOptions="settlementIdColumnOptions" interfaceId="547745774990039365" :pageSize="20"
						placeholder="请选择" type="popup" :style='{"width":"100%"}'>
					</jnpf-popup-select>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('payee')" :required="requiredList.payee" label="收款方" prop="payee">
					<u-input v-model="dataForm.payee" :disabled="judgeWrite('payee')" @change="changeData('payee',-1)"
						  clearable placeholder="请输入" :style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('payer')" :required="requiredList.payer" label="付款方" prop="payer">
					<u-input v-model="dataForm.payer" :disabled="judgeWrite('payer')" @change="changeData('payer',-1)"
						  clearable placeholder="请输入" :style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>

			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('settlableAmount')" :required="requiredList.settlableAmount" label="可结金额"
					prop="settlableAmount">
					<u-input v-model="dataForm.settlableAmount" :disabled="judgeWrite('settlableAmount')"
						@change="changeData('settlableAmount',-1)"  addonAfter="元" clearable
						placeholder="请输入" :style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('paymentAmount')" :required="requiredList.paymentAmount" label="申请金额"
					prop="paymentAmount">
					<u-input v-model="dataForm.paymentAmount" :disabled="judgeWrite('paymentAmount')"
						@change="changeData('paymentAmount',-1)"  addonAfter="元" clearable
						placeholder="请输入" :style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('applyAmount')" :required="requiredList.applyAmount" label="实际付款金额"
					prop="applyAmount">
					<u-input v-model="dataForm.applyAmount" :disabled="judgeWrite('applyAmount')"
						@change="changeData('applyAmount',-1)"  addonAfter="元" clearable
						placeholder="请输入" :style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>
			<view class="u-p-l-20 u-p-r-20 form-item-box">
				<u-form-item v-if="judgeShow('remark')" :required="requiredList.remark" label="备注" prop="remark">
					<u-input v-model="dataForm.remark" :disabled="judgeWrite('remark')"
						@change="changeData('remark',-1)"  placeholder="请输入" type="textarea"
						:style='{"width":"100%"}'>
					</u-input>
				</u-form-item>
			</view>
			<view class="jnpf-table" v-if="judgeShow('cwpaymentsummaryList')">
				<view class="jnpf-table-item" v-for="(item,i) in dataForm.cwpaymentsummaryList" :key="i">
					<view class="jnpf-table-item-title u-flex u-row-between">
						<text class="jnpf-table-item-title-num">结算汇总({{i+1}})</text>
						<view class="jnpf-table-item-title-action"
							v-if=" !judgeWrite('cwpaymentsummaryList') && dataForm.cwpaymentsummaryList.length>0"
							@click="delcwpaymentsummaryList(i)">删除</view>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-productId')"
							:required="requiredList['cwpaymentsummaryList-productId']" label="商品名称">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].productId"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-productId')"
								@change="changeData('cwpaymentsummary-productId',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-spec')"
							:required="requiredList['cwpaymentsummaryList-spec']" label="规格">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].spec"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-spec')"
								@change="changeData('cwpaymentsummary-spec',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-settlementUnit')"
							:required="requiredList['cwpaymentsummaryList-settlementUnit']" label="结算单位">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].settlementUnit"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-settlementUnit')"
								@change="changeData('cwpaymentsummary-settlementUnit',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-settlementSum')"
							:required="requiredList['cwpaymentsummaryList-settlementSum']" label="结算数量">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].settlementSum"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-settlementSum')"
								@change="changeData('cwpaymentsummary-settlementSum',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-settlementPrice')"
							:required="requiredList['cwpaymentsummaryList-settlementPrice']" label="结算单价（含税）">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].settlementPrice"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-settlementPrice')"
								@change="changeData('cwpaymentsummary-settlementPrice',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-settlementSubtotal')"
							:required="requiredList['cwpaymentsummaryList-settlementSubtotal']" label="结算小计（含税）">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].settlementSubtotal"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-settlementSubtotal')"
								@change="changeData('cwpaymentsummary-settlementSubtotal',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-settlementPriceNo')"
							:required="requiredList['cwpaymentsummaryList-settlementPriceNo']" label="结算单价（不含税）">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].settlementPriceNo"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-settlementPriceNo')"
								@change="changeData('cwpaymentsummary-settlementPriceNo',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-settlementSubtotalNo')"
							:required="requiredList['cwpaymentsummaryList-settlementSubtotalNo']" label="结算小计（不含税）">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].settlementSubtotalNo"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-settlementSubtotalNo')"
								@change="changeData('cwpaymentsummary-settlementSubtotalNo',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-otherType')"
							:required="requiredList['cwpaymentsummaryList-otherType']" label="其他费用类型">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].otherType"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-otherType')"
								@change="changeData('cwpaymentsummary-otherType',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-otherExpenses')"
							:required="requiredList['cwpaymentsummaryList-otherExpenses']" label="其他费用">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].otherExpenses"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-otherExpenses')"
								@change="changeData('cwpaymentsummary-otherExpenses',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-settlementTotal')"
							:required="requiredList['cwpaymentsummaryList-settlementTotal']" label="结算合计（含税）">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].settlementTotal"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-settlementTotal')"
								@change="changeData('cwpaymentsummary-settlementTotal',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-settlementTotalNo')"
							:required="requiredList['cwpaymentsummaryList-settlementTotalNo']" label="结算合计（不含税）">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].settlementTotalNo"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-settlementTotalNo')"
								@change="changeData('cwpaymentsummary-settlementTotalNo',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentsummaryList-remark')"
							:required="requiredList['cwpaymentsummaryList-remark']" label="备注">
							<u-input v-model="dataForm.cwpaymentsummaryList[i].remark"
								:disabled="judgeWrite('cwpaymentsummaryList')||judgeWrite('cwpaymentsummaryList-remark')"
								@change="changeData('cwpaymentsummary-remark',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
				</view>
				<view class="jnpf-table-addBtn" @click="addcwpaymentsummaryList"
					v-if="!judgeWrite('cwpaymentsummaryList')">
					<u-icon name="plus" color="#2979ff"></u-icon>
					<span>{{dataForm.cwpaymentsummaryList.length==0?"添加结算汇总":"添加"}}</span>
				</view>
			</view>
			<view class="jnpf-table" v-if="judgeShow('cwpaymentlastsummaryList')">
				<view class="jnpf-table-item" v-for="(item,i) in dataForm.cwpaymentlastsummaryList" :key="i">
					<view class="jnpf-table-item-title u-flex u-row-between">
						<text class="jnpf-table-item-title-num">票据打印汇总({{i+1}})</text>
						<view class="jnpf-table-item-title-action"
							v-if=" !judgeWrite('cwpaymentlastsummaryList') && dataForm.cwpaymentlastsummaryList.length>0"
							@click="delcwpaymentlastsummaryList(i)">删除</view>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-productId')"
							:required="requiredList['cwpaymentlastsummaryList-productId']" label="商品名称">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].productId"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-productId')"
								@change="changeData('cwpaymentlastsummary-productId',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-spec')"
							:required="requiredList['cwpaymentlastsummaryList-spec']" label="规格">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].spec"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-spec')"
								@change="changeData('cwpaymentlastsummary-spec',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-settlementUnit')"
							:required="requiredList['cwpaymentlastsummaryList-settlementUnit']" label="结算单位">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].settlementUnit"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-settlementUnit')"
								@change="changeData('cwpaymentlastsummary-settlementUnit',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-settlementSum')"
							:required="requiredList['cwpaymentlastsummaryList-settlementSum']" label="结算数量">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].settlementSum"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-settlementSum')"
								@change="changeData('cwpaymentlastsummary-settlementSum',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-settlementPrice')"
							:required="requiredList['cwpaymentlastsummaryList-settlementPrice']" label="结算单价（含税）">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].settlementPrice"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-settlementPrice')"
								@change="changeData('cwpaymentlastsummary-settlementPrice',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-settlementSubtotal')"
							:required="requiredList['cwpaymentlastsummaryList-settlementSubtotal']" label="结算小计（含税）">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].settlementSubtotal"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-settlementSubtotal')"
								@change="changeData('cwpaymentlastsummary-settlementSubtotal',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-rate')"
							:required="requiredList['cwpaymentlastsummaryList-rate']" label="税率">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].rate"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-rate')"
								@change="changeData('cwpaymentlastsummary-rate',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-settlementPriceNo')"
							:required="requiredList['cwpaymentlastsummaryList-settlementPriceNo']" label="结算单价（不含税）">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].settlementPriceNo"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-settlementPriceNo')"
								@change="changeData('cwpaymentlastsummary-settlementPriceNo',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-settlementSubtotalNo')"
							:required="requiredList['cwpaymentlastsummaryList-settlementSubtotalNo']" label="结算小计（不含税）">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].settlementSubtotalNo"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-settlementSubtotalNo')"
								@change="changeData('cwpaymentlastsummary-settlementSubtotalNo',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-otherType')"
							:required="requiredList['cwpaymentlastsummaryList-otherType']" label="其他费用类型">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].otherType"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-otherType')"
								@change="changeData('cwpaymentlastsummary-otherType',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-otherExpenses')"
							:required="requiredList['cwpaymentlastsummaryList-otherExpenses']" label="其他费用">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].otherExpenses"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-otherExpenses')"
								@change="changeData('cwpaymentlastsummary-otherExpenses',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-settlementTotal')"
							:required="requiredList['cwpaymentlastsummaryList-settlementTotal']" label="结算合计（含税）">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].settlementTotal"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-settlementTotal')"
								@change="changeData('cwpaymentlastsummary-settlementTotal',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-settlementTotalNo')"
							:required="requiredList['cwpaymentlastsummaryList-settlementTotalNo']" label="结算合计（不含税）">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].settlementTotalNo"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-settlementTotalNo')"
								@change="changeData('cwpaymentlastsummary-settlementTotalNo',i)" 
								clearable placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
					<view class="u-p-l-20 u-p-r-20 form-item-box">
						<u-form-item v-if="judgeShow('cwpaymentlastsummaryList-remark')"
							:required="requiredList['cwpaymentlastsummaryList-remark']" label="备注">
							<u-input v-model="dataForm.cwpaymentlastsummaryList[i].remark"
								:disabled="judgeWrite('cwpaymentlastsummaryList')||judgeWrite('cwpaymentlastsummaryList-remark')"
								@change="changeData('cwpaymentlastsummary-remark',i)"  clearable
								placeholder="请输入" :style='{"width":"100%"}'>
							</u-input>
						</u-form-item>
					</view>
				</view>
				<view class="jnpf-table-addBtn" @click="addcwpaymentlastsummaryList"
					v-if="!judgeWrite('cwpaymentlastsummaryList')">
					<u-icon name="plus" color="#2979ff"></u-icon>
					<span>{{dataForm.cwpaymentlastsummaryList.length==0?"添加票据打印汇总":"添加"}}</span>
				</view>
			</view>
		</u-form>
		<u-modal v-model="show" :content="content" width='70%' border-radius="16"
			:content-style="{fontSize: '28rpx',padding: '20rpx',lineHeight: '44rpx',textAlign: 'left'}"
			:titleStyle="{padding: '20rpx'}" :confirm-style="{height: '80rpx',lineHeight: '80rpx'}" :title="title"
			confirm-text="确定">
		</u-modal>
	</view>
</template>

<script>
	import {
		getDictionaryDataSelector,
		getDataInterfaceRes,
		getDefaultCurrentValueUserId,
		getDefaultCurrentValueDepartmentId
	} from '@/api/common'
	import comMixin from '../../../workFlow/workFlowForm/mixin'
	import {
		getDateDay,
		getLaterData,
		getBeforeData,
		getBeforeTime,
		getLaterTime
	} from '@/components/index.js'
	import request from '@/utils/request'
	export default {
		mixins: [comMixin],
		data() {
			return {
				idList: [],
				index: 0,
				actionList: [],
				actionListLength: false,
				showAction: false,
				btnLoading: false,
				loading: false,
				text: '提示：测试文本',
				tableKey: '',
				dataForm: {
					id: "",
					type: "1",
					creatorUserId: "",
					creatorTime: "",
					lastModifyTime: "",
					lastModifyUserId: "",
					code: '',
					settlementId: "",
					payee: '',
					payer: "",
					payDate: '',
					settlableAmount: '',
					applyAmount: '',
					paymentAmount: '',
					remark: '',
					cwpaymentsummaryList: [],
					cwpaymentlastsummaryList: [],
				},
				rules: {
					type: [{
						required: true,
						message: '类型请至少选择一个',
					}, ],
					settlableAmount: [{
						pattern: /^([1-9][\d]*|0)(\.[\d]+)?$/,
						message: '可结金额请输入正确的金额',
					}, ],
					applyAmount: [{
						pattern: /^([1-9][\d]*|0)(\.[\d]+)?$/,
						message: '申请金额请输入正确的金额',
					}, ],
					paymentAmount: [{
						pattern: /^([1-9][\d]*|0)(\.[\d]+)?$/,
						message: '付款金额请输入正确的金额',
					}, ],
				},
				typeOptions: [{
					"fullName": "采购付款",
					"id": "1"
				}, {
					"fullName": "销售付款",
					"id": "2"
				}, {
					"fullName": "其他付款",
					"id": "3"
				}],
				typeProps: {
					"label": "fullName",
					"value": "id",
					"multiple": false,
					"children": ""
				},
				settlementIdColumnOptions: [{
						"label": "结算单号",
						"value": "code"
					},
					{
						"label": "类型",
						"value": "type"
					},
					{
						"label": "应结金额",
						"value": "payable_amount"
					},
					{
						"label": "已结金额",
						"value": "settled_amount"
					},
					{
						"label": "可结金额",
						"value": "settlable_amount"
					},
				],
				labelwidth: 100 * 1.5,
				menuId: '',
				jurisdictionType: '',
				ruleList: {
					cwpaymentsummaryList: {},
					cwpaymentlastsummaryList: {},
				},
				interfaceRes: {
					type: [],
					creatorUserId: [],
					creatorTime: [],
					lastModifyTime: [],
					lastModifyUserId: [],
					code: [],
					settlementId: [],
					payee: [],
					payer: [],
					payDate: [],
					settlableAmount: [],
					applyAmount: [],
					paymentAmount: [],
					remark: [],
					cwpaymentsummaryproductId: [],
					cwpaymentsummaryspec: [],
					cwpaymentsummarysettlementUnit: [],
					cwpaymentsummarysettlementSum: [],
					cwpaymentsummarysettlementPrice: [],
					cwpaymentsummarysettlementSubtotal: [],
					cwpaymentsummarysettlementPriceNo: [],
					cwpaymentsummarysettlementSubtotalNo: [],
					cwpaymentsummaryotherType: [],
					cwpaymentsummaryotherExpenses: [],
					cwpaymentsummarysettlementTotal: [],
					cwpaymentsummarysettlementTotalNo: [],
					cwpaymentsummaryremark: [],
					cwpaymentlastsummaryproductId: [],
					cwpaymentlastsummaryspec: [],
					cwpaymentlastsummarysettlementUnit: [],
					cwpaymentlastsummarysettlementSum: [],
					cwpaymentlastsummarysettlementPrice: [],
					cwpaymentlastsummarysettlementSubtotal: [],
					cwpaymentlastsummaryrate: [],
					cwpaymentlastsummarysettlementPriceNo: [],
					cwpaymentlastsummarysettlementSubtotalNo: [],
					cwpaymentlastsummaryotherType: [],
					cwpaymentlastsummaryotherExpenses: [],
					cwpaymentlastsummarysettlementTotal: [],
					cwpaymentlastsummarysettlementTotalNo: [],
					cwpaymentlastsummaryremark: [],
				},
				regList: {
					cwpaymentsummaryList: {
						productId: [],
						spec: [],
						settlementUnit: [],
						settlementSum: [],
						settlementPrice: [],
						settlementSubtotal: [],
						settlementPriceNo: [],
						settlementSubtotalNo: [],
						otherType: [],
						otherExpenses: [],
						settlementTotal: [],
						settlementTotalNo: [],
						remark: [],
					},
					cwpaymentlastsummaryList: {
						productId: [],
						spec: [],
						settlementUnit: [],
						settlementSum: [],
						settlementPrice: [],
						settlementSubtotal: [],
						rate: [],
						settlementPriceNo: [],
						settlementSubtotalNo: [],
						otherType: [],
						otherExpenses: [],
						settlementTotal: [],
						settlementTotalNo: [],
						remark: [],
					},
				},
				ableAll: {},
				childIndex: -1,
				dataValue: {},
				isEdit: false,
				userInfo: {},
				formatType: {
					"yyyy": "yyyy",
					"yyyy-MM": "yyyy-mm",
					"yyyy-MM-dd": "yyyy-mm-dd",
					"yyyy-MM-dd HH:mm": "yyyy-mm-dd hh:MM",
					"yyyy-MM-dd HH:mm:ss": "yyyy-mm-dd hh:MM:ss",
					"HH:mm:ss": "hh:MM:ss",
					"HH:mm": "hh:MM"
				},
				content: '',
				title: '',
				show: false,
			}
		},
		onLoad(option) {
			uni.$on('linkPageConfirm', (subVal) => {
				if (this.tableKey) {
					for (let i = 0; i < subVal.length; i++) {
						let t = subVal[i]
						if (this['get' + this.tableKey]) {
							this['get' + this.tableKey](t)
						}
					}
					this.childIndex = -1
					this.collapse()
				}
			})
			this.jurisdictionType = option.jurisdictionType
			this.menuId = option.menuId
			this.userInfo = uni.getStorageSync('userInfo') || {}
			this.dataForm.id = option.id || 0
			let _title = ""
			if (option.jurisdictionType == 'btn_edit') {
				_title = "编辑"
			}
			if (option.jurisdictionType == 'btn_detail') {
				_title = "详情"
			}
			if (option.jurisdictionType == 'btn_add') {
				_title = "新增"
			}
			if (_title) {
				uni.setNavigationBarTitle({
					title: _title
				})
			}
			this.selfInit()
			this.initDefaultData()
			this.dataAll()
			this.initData()
			this.dataValue = JSON.parse(JSON.stringify(this.dataForm))
			this.idList = option.idList ? option.idList.split(",") : []
			for (let i = 0; i < this.idList.length; i++) {
				if (this.idList[i] == option.id) {
					this.index = i;
				}
			}
			if (!option.id) {
				this.actionList.push({
					text: '确定并新增',
					id: 'save_add'
				})
			} else {
				let upper = {
					text: '上一条',
					id: 'upper',
					disabled: this.index == 0 ? true : false
				}
				this.actionList.push(upper)
				let lower = {
					text: '下一条',
					id: 'lower',
					disabled: this.index == this.idList.length - 1 ? true : false
				}
				this.actionList.push(lower)
				this.actionList.push({
					text: '确定并继续',
					id: 'save_proceed'
				})
				this.collapse()
			}
		},
		onReady() {
			this.$nextTick(() => {
				setTimeout(() => {
					this.$refs.dataForm.setRules(this.rules);
				}, 100)
			})
		},
		watch: {
			dataForm: {
				handler(val, oldVal) {
					this.cwpaymentsummary()
					this.cwpaymentlastsummary()
				},
				deep: true
			}
		},
		methods: {
			handleAction(index) {
				if (this.actionList[index].id === 'save_add' || this.actionList[index].id === 'save_proceed') {
					this.submitForm(1)
				} else {
					this.calculation(this.actionList[index].id, index)
				}
			},
			calculation(type, index) {
				if (type === 'upper') {
					this.index--
					this.actionList[index + 1].disabled = false
					if (this.index == 0) this.actionList[index].disabled = true
				} else {
					this.index++
					this.actionList[index - 1].disabled = false
					if (this.index == this.idList.length - 1) this.actionList[index].disabled = true
				}
				this.dataForm.id = this.idList[this.index]
				this.initData()
			},
			changeData(model, index) {
				this.isEdit = false
				this.childIndex = index
				let modelAll = model.split("-");
				let faceMode = "";
				for (let i = 0; i < modelAll.length; i++) {
					faceMode += modelAll[i];
				}
				for (let key in this.interfaceRes) {
					if (key != faceMode) {
						let faceReList = this.interfaceRes[key]
						for (let i = 0; i < faceReList.length; i++) {
							if (faceReList[i].relationField == model) {
								let options = 'get' + key + 'Options';
								if (this[options]) {
									this[options]()
								}
								this.changeData(key, index)
							}
						}
					}
				}
			},
			changeDataFormData(type, data, model, index, defaultValue, edit) {
				if (!edit) {
					if (type == 2) {
						for (let i = 0; i < this.dataForm[data].length; i++) {
							if (index == -1) {
								this.dataForm[data][i][model] = defaultValue
							} else if (index == i) {
								this.dataForm[data][i][model] = defaultValue
							}
						}
					} else {
						this.dataForm[data] = defaultValue
					}
				}
			},
			clickIcon(label, tipLabel) {
				this.content = tipLabel
				this.title = label
				this.show = true
			},
			exist() {
				let title = [];
				let _ruleList = this.ruleList
				for (let k in _ruleList) {
					let childData = this.dataForm[k]
					childData.forEach((item, index) => {
						for (let model in _ruleList[k]) {
							if (item[model] instanceof Array) {
								if (item[model].length == 0) {
									title.push(_ruleList[k][model])
								}
							} else if (!item[model]) {
								title.push(_ruleList[k][model])
							}
						}
					})
				}
				let _regList = this.regList
				for (let k in _regList) {
					let childData = this.dataForm[k]
					for (let n in _regList[k]) {
						for (let i = 0; i < _regList[k][n].length; i++) {
							const element = _regList[k][n][i]
							if (element.pattern) {
								element.pattern = element.pattern.toString()
								let start = element.pattern.indexOf('/')
								let stop = element.pattern.lastIndexOf('/')
								let str = element.pattern.substring(start + 1, stop)
								let reg = new RegExp(str)
								element.pattern = reg
							}
							childData.forEach((item, index) => {
								if (item[n] && !element.pattern.test(item[n])) {
									title.push(element.message)
								}
							})
						}
					}
				}
				if (title.length > 0) {
					return title[0]
				}
			},
			resetForm() {
				uni.navigateBack()
			},
			dataAll() {
				this.collapse()
			},
			dateTime(timeRule, timeType, timeTarget, timeValueData, dataValue) {
				let timeDataValue = null;
				let timeValue = Number(timeValueData)
				if (timeRule) {
					if (timeType == 1) {
						timeDataValue = timeValueData ? timeValue : null
					} else if (timeType == 2) {
						timeDataValue = dataValue
					} else if (timeType == 3) {
						timeDataValue = new Date().getTime()
					} else if (timeType == 4) {
						let previousDate = '';
						if (timeTarget == 1 || timeTarget == 2) {
							previousDate = getDateDay(timeTarget, timeType, timeValue)
							timeDataValue = new Date(previousDate).getTime()
						} else if (timeTarget == 3) {
							previousDate = getBeforeData(timeValue)
							timeDataValue = new Date(previousDate).getTime()
						} else {
							timeDataValue = getBeforeTime(timeTarget, timeValue).getTime()
						}
					} else if (timeType == 5) {
						let previousDate = '';
						if (timeTarget == 1 || timeTarget == 2) {
							previousDate = getDateDay(timeTarget, timeType, timeValue)
							timeDataValue = new Date(previousDate).getTime()
						} else if (timeTarget == 3) {
							previousDate = getLaterData(timeValue)
							timeDataValue = new Date(previousDate).getTime()
						} else {
							timeDataValue = getLaterTime(timeTarget, timeValue).getTime()
						}
					}
				}
				return timeDataValue;
			},
			time(timeRule, timeType, timeTarget, timeValue, formatType, dataValue) {
				let format = formatType == 'HH:mm' ? 'HH:mm:00' : formatType
				let timeDataValue = null
				if (timeRule) {
					if (timeType == 1 && timeValue) {
						timeDataValue = timeValue || '00:00:00'
						if (timeDataValue.split(':').length == 3) {
							timeDataValue = timeDataValue
						} else {
							timeDataValue = timeDataValue + ':00'
						}
					} else if (timeType == 2) {
						timeDataValue = dataValue
					} else if (timeType == 3) {
						timeDataValue = this.jnpf.toDate(new Date(), format)
					} else if (timeType == 4) {
						let previousDate = '';
						previousDate = getBeforeTime(timeTarget, timeValue)
						timeDataValue = this.jnpf.toDate(previousDate, format)
					} else if (timeType == 5) {
						let previousDate = '';
						previousDate = getLaterTime(timeTarget, timeValue)
						timeDataValue = this.jnpf.toDate(previousDate, format)
					}
				}
				return timeDataValue;
			},
			cwpaymentsummary() {
				let table = this.dataForm.cwpaymentsummaryList
				let summaryField = []
				let summaryFieldName = {}
				let data = {}
				let thousandsField = []
				for (let i in summaryField) {
					let map = {}
					let val = 0
					for (let j = 0; j < table.length; j++) {
						let summary = table[j][summaryField[i]];
						if (summary) {
							let data = isNaN(summary) ? 0 : Number(summary)
							val += data
						}
					}
					map.id = summaryField[i];
					map.name = summaryFieldName[summaryField[i]];
					map.val = (thousandsField.includes(summaryField[i])) ? Number(val).toLocaleString('zh', {
						maximumFractionDigits: '2'
					}) : val;
					data[summaryField[i]] = map;
				}
				return data;
			},
			cwpaymentlastsummary() {
				let table = this.dataForm.cwpaymentlastsummaryList
				let summaryField = []
				let summaryFieldName = {}
				let data = {}
				let thousandsField = []
				for (let i in summaryField) {
					let map = {}
					let val = 0
					for (let j = 0; j < table.length; j++) {
						let summary = table[j][summaryField[i]];
						if (summary) {
							let data = isNaN(summary) ? 0 : Number(summary)
							val += data
						}
					}
					map.id = summaryField[i];
					map.name = summaryFieldName[summaryField[i]];
					map.val = (thousandsField.includes(summaryField[i])) ? Number(val).toLocaleString('zh', {
						maximumFractionDigits: '2'
					}) : val;
					data[summaryField[i]] = map;
				}
				return data;
			},
			initData() {
				this.$nextTick(function() {
					if (this.dataForm.id) {
						this.loading = true
						request({
							url: '/api/scm/Cwpaymentreceipt/' + this.dataForm.id,
							method: 'get',
						}).then(res => {
							this.dataInfo(res.data)
							this.loading = false
						})
					} else {
						this.initDefaultData()
					}
				})
			},
			beforeSubmit() {
				const _data = this.dataList()
				return _data
			},
			initDefaultData() {},
			selfInit() {
				this.$store.commit('base/UPDATE_RELATION_DATA', {})
				this.dataAll()
				this.initDefaultData()
				this.collapse()
			},
			selfGetInfo(dataForm) {
				this.dataForm.id = this.dataForm.id
				this.dataInfo(dataForm)
			},
			addcwpaymentsummaryList() {
				let value = {}
				this.tableKey = 'cwpaymentsummaryList';
				this.getcwpaymentsummaryList(value)
				this.childIndex = -1
				this.collapse()
			},
			delcwpaymentsummaryList(index) {
				var that = this
				uni.showModal({
					title: '提示',
					content: '确认删除该条信息吗？',
					success: function(res) {
						if (res.confirm) {
							that.dataForm.cwpaymentsummaryList.splice(index, 1);
							that.collapse()
						}
					}
				})
			},
			getcwpaymentsummaryList(value) {
				let item = {
					productId: '',
					spec: '',
					settlementUnit: '',
					settlementSum: '',
					settlementPrice: '',
					settlementSubtotal: '',
					settlementPriceNo: '',
					settlementSubtotalNo: '',
					otherType: '',
					otherExpenses: '',
					settlementTotal: '',
					settlementTotalNo: '',
					remark: '',
				}
				let result = {
					...item,
					...value
				}
				this.dataForm.cwpaymentsummaryList.push(result)
				this.childIndex = this.dataForm.cwpaymentsummaryList.length - 1
				this.isEdit = true
				this.isEdit = false
			},
			addcwpaymentlastsummaryList() {
				let value = {}
				this.tableKey = 'cwpaymentlastsummaryList';
				this.getcwpaymentlastsummaryList(value)
				this.childIndex = -1
				this.collapse()
			},
			delcwpaymentlastsummaryList(index) {
				var that = this
				uni.showModal({
					title: '提示',
					content: '确认删除该条信息吗？',
					success: function(res) {
						if (res.confirm) {
							that.dataForm.cwpaymentlastsummaryList.splice(index, 1);
							that.collapse()
						}
					}
				})
			},
			getcwpaymentlastsummaryList(value) {
				let item = {
					productId: '',
					spec: '',
					settlementUnit: '',
					settlementSum: '',
					settlementPrice: '',
					settlementSubtotal: '',
					rate: '',
					settlementPriceNo: '',
					settlementSubtotalNo: '',
					otherType: '',
					otherExpenses: '',
					settlementTotal: '',
					settlementTotalNo: '',
					remark: '',
				}
				let result = {
					...item,
					...value
				}
				this.dataForm.cwpaymentlastsummaryList.push(result)
				this.childIndex = this.dataForm.cwpaymentlastsummaryList.length - 1
				this.isEdit = true
				this.isEdit = false
			},
			dataList() {
				var _data = this.dataForm;
				return _data;
			},
			dataInfo(dataAll) {
				let _dataAll = dataAll
				this.dataForm = _dataAll
				this.isEdit = true
				this.dataAll()
				for (let i = 0; i < _dataAll.cwpaymentsummaryList.length; i++) {
					this.childIndex = i
				}
				for (let i = 0; i < _dataAll.cwpaymentlastsummaryList.length; i++) {
					this.childIndex = i
				}
				this.childIndex = -1
				this.collapse()
			},
			collapse() {
				setTimeout(() => {}, 1000);
			},
		},
	}
</script>
<style>
	page {
		background-color: #f0f2f6;
	}
</style>