<template>
	<div class="diaClass">
		<!--		工作流引用  显示表单-->
		<!--		{{workflow.workId}}-->

		<el-form ref="formRef" :model="insertForm" :rules="rules" label-width="110" label-position="right"
			:inline="true">
			<el-row>
        <el-col :span="2">
        </el-col>
				<el-col :span="10">
					<el-form-item label="收款编号" prop="prepaymentNo" style="width: 100%">
						<el-input v-model="insertForm.prepaymentNo" disabled></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="10" >
					<el-form-item label="客户名称" prop="tradePartnerName" style="width: 100%">
						<el-input v-model="insertForm.tradePartnerName" readonly>
						</el-input>
					</el-form-item>
				</el-col>
        <el-col :span="2">
        </el-col>
			</el-row>
			<el-row>
        <el-col :span="2">
        </el-col>
				<el-col :span="10">
					<el-form-item label="收款金额" prop="prepaymentAmt" style="width: 100%">
						<el-input-number style="width: 100%" min="0" :precision="2" :step="0.1" disabled
							controls-position="right" v-model="insertForm.prepaymentAmt"></el-input-number>
					</el-form-item>
				</el-col>
				<el-col :span="10">
					<el-form-item label="收款日期" style="width: 100%">
						<el-date-picker style="width: 100%" v-model="insertForm.prepaymentDt" type="date" placeholder="" disabled
                            value-format="YYYY-MM-DD"	size="default" />
					</el-form-item>
				</el-col>
        <el-col :span="2">
        </el-col>
			</el-row>
			<el-row>
        <el-col :span="2">
        </el-col>
				<el-col :span="10">
					<el-form-item label="收款类型" prop="payMth" style="width: 100%">
            <el-select   v-model="insertForm.payMth" clearable style="" disabled>
              <el-option v-for="(option,i) in dictList.COM_PAY_MTH" :key="i" :value="option.dicCode" :disabled="option.disabled"
                         :label="option.dicName"/>
            </el-select>
					</el-form-item>
				</el-col>

				<el-col :span="10">
					<el-form-item label="承兑编号" style="width: 100%">
						<el-input v-model="insertForm.billNoteNo" readonly></el-input>
					</el-form-item>
				</el-col>
        <el-col :span="2">
        </el-col>
			</el-row>
			<el-row>
        <el-col :span="2">
        </el-col>
				<el-col :span="10">
					<el-form-item label="票据张数" style="width: 100%">
						<el-input-number style="width: 100%" min="0" :step="1" controls-position="right" disabled
							v-model="insertForm.billNoteNum"></el-input-number>

					</el-form-item>
				</el-col>
			</el-row>

			<el-row>
        <el-col :span="2">
        </el-col>
				<el-col :span="20" class="aaa">
					<el-form-item label="收款备注信息" style="width: 100%" >
						<el-input v-model="insertForm.remarks" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea" readonly
							placeholder="" />
					</el-form-item>
				</el-col>
        <el-col :span="2">
        </el-col>
			</el-row>

		</el-form>
    <Attachment ref="AttachmentRefManual" :fId="insertForm.id" :uploadButton="uploadButton"></Attachment>
	</div>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted,
		getCurrentInstance,
		nextTick
	} from 'vue'
	const {
		proxy
	} = getCurrentInstance()
	import style from '@/tools/style'
  import Attachment from "@/components/Attachment.vue";
	const cardBodyStyle = ref(style.card)
	/**
	 * 新增表单form
	 */
	const insertForm = ref({
		id: '',
		prepaymentNo: '',
		supplierNm: '',
		prepaymentAmt: '',
		prepaymentDt: proxy.$dayjs(),
    payMth: '',
		billNoteNo: '',
		billNoteNum: '',
		prepDistributeSign: '',
		remarks: '',
		prepaymentDtStart: '',
		prepaymentDtEnd: '',
	})

	import {
		useWorkflowStore
	} from "@/stores/workflow"
	const workflow = useWorkflowStore()
  const dictList = ref({})
  const dictData = () => {
    var url = 'framework/Common/querySelectorList'
    var param = {
      type: JSON.stringify(['COM_PAY_MTH', 'IF'])
    }
    proxy.$axios.get(url, param).then(response => {
      if (response.data.code == '0') {
        dictList.value = response.data.data
      } else {
        ElMessage.error('操作失败！' + response.data.msg)
      }
    })

  }
  const uploadButton = ref(false)
	//
	onMounted(() => {
    dictData()
		console.log(workflow.workId)
		var url = 'sal/PrepayErp/queryByWorkId'
		var param = {
			workId: workflow.workId
		}
		proxy.$axios.get(url, param).then(response => {
			if (response.data.code == '0') {
				console.log(response.data.data)
				insertForm.value = response.data.data

        if (insertForm.value.processInstanceStatus == '110'){
          uploadButton.value = true
        }

			} else {
				ElMessage.error('操作失败！' + response.data.msg)
			}
		})
	})
</script>

<style scoped>
::v-deep .diaClass .el-form-item {
  width: 100%
}

::v-deep .el-dialog__body {
  background-color: #F2F6FC;
}

.el-date-editor--date {
  width: 100%;
}

::v-deep .diaClass .el-form-item__label {
  width: 140px !important;
}
</style>
