<template>
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
	  draggable
      width="1200px"
      @close="close"
      @keyup.enter.native="doSubmit"
	  v-model="visible">
      <el-form size="large" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method==='view'"
               label-width="100px" @submit.native.prevent>

        <el-divider content-position="left"><i class="el-icon-document"></i> 基础信息</el-divider>
		  <el-row >
			  <el-col :span="12">
				  <el-form-item label="报销项" prop="reimbursementType" :disabled="status === 'audit' || status === 'taskFormDetail'"
								:rules="[
                        {required: true, message:'报销项不能为空', trigger:'blur'}
               ]">
					  <el-radio v-model="inputForm.reimbursementType" v-for="item in $dictUtils.getDictList('reimbursement_type')" :label="item.value" style="margin-right: 20px">
						  {{item.label}}</el-radio>
				  </el-form-item>
			  </el-col>
		  </el-row>
        <el-row :gutter="26">
          <el-col :span="12">
            <el-form-item label="经办人" prop="userName">
              <el-input v-model="inputForm.userName" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报销编号" prop="no">
              <el-input v-model="inputForm.no" :disabled="true" placeholder="自动生成"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属部门" prop="departmentName">
              <el-input v-model="inputForm.departmentName" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报销日期" prop="reimDate" :rules="[{required: true, message:'请选择报销日期', trigger:'blur'}]">
              <el-date-picker
                placement="bottom-start"
                v-model="inputForm.reimDate"
                type="date"
                value-format="YYYY-MM-DD"
                style="width: 100%"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报销类型" prop="sourceType"
                          :rules="[
                        {required: true, message:'请选择报销类型', trigger:'change'}
                 ]">
              <el-select v-model="inputForm.sourceType" @change="changeSourceType" placeholder="请选择报销类型" style="width:100%;">
                <el-option
                  v-for="item in $dictUtils.getDictList('pg_reimbursement_source_type')"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="inputForm.sourceType === '5'">
            <el-form-item label="采购编号" prop="purchaseNo"
                          :rules="[{required: true, message:'采购编号不能为空', trigger:'blur'},
                              {required: true, message:'采购编号不能为空', trigger:'change'}]">
              <el-input size="large" :readonly="true" @focus="openPurForm()" v-model="inputForm.purchaseNo" placeholder="请选择采购编号">
                <el-button slot="append" icon="el-icon-search" @click="openPurForm()"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remarks">
              <el-input v-model="inputForm.remarks"
                        type="textarea"
                        :rows="5"
                        maxlength="500"
                        placeholder="请输入简介"
                        show-word-limit>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <div v-if="inputForm.sourceType === '5'">
          <el-divider content-position="left"><i class="el-icon-document"></i>
            采购详情
          </el-divider>
          <el-row  :gutter="15" >
			  <el-col :span="24">
				  <vxe-table
					  border
					  show-footer
					  show-overflow
					  :footer-method="footerMethod555"
					  ref="preTable"
					  class="vxe-table-element"
					  :data="inputForm.preList"
					  style="margin-left: 5em"
					  @cell-click=""
					  @edit-closed=""
					  highlight-current-row
				  >
					  <vxe-table-column field="purchaserAgent" title="采购人" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择采购人', trigger:'blur'}]"></vxe-table-column>
					  <vxe-table-column field="procurementOffice" title="采购部门" :edit-render="{}" show-overflow="title"></vxe-table-column>
					  <vxe-table-column field="procurementType" title="采购类型" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择采购类型', trigger:'blur'}]"></vxe-table-column>
					  <vxe-table-column field="tradeName" title="商品名称" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请填写商品名称', trigger:'blur'}]"></vxe-table-column>
					  <vxe-table-column field="tradePrice" title="商品单价(元)" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请输入商品单价', trigger:'blur'}]"></vxe-table-column>
					  <vxe-table-column field="tradeNumber" title="商品数量" :edit-render="{}" show-overflow="title"></vxe-table-column>
					  <vxe-table-column field="priceSum" title="商品总价" :edit-render="{}" show-overflow="title"></vxe-table-column>
					  <vxe-table-column field="company" title="单位" :edit-render="{}" show-overflow="title"></vxe-table-column>
					  <vxe-table-column field="remarks" title="备注" :edit-render="{}" show-overflow="title"></vxe-table-column>
					  <vxe-table-column title="操作">
						  <template #default="scope">
							  <el-button size="default" type="primary" :disabled="false" @click="seeFileInfo(scope.$rowIndex)">文件详情</el-button>
						  </template>
					  </vxe-table-column>
				  </vxe-table>
			  </el-col>

          </el-row>
        </div>
        <div v-if="inputForm.sourceType === '1'">
          <el-divider content-position="left"><i class="el-icon-document"></i>
            项目报销详情
            <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="default" @click="insertEvent('detail')" plain>
              新增
            </el-button>
          </el-divider>
          <el-row  :gutter="15" >
			  <el-col :span="24">
				  <vxe-table
					  border
					  show-footer
					  show-overflow
					  :footer-method="footerMethod"
					  ref="detailTable"
					  :key="detailKey"
					  class="vxe-table-element"
					  :data="inputForm.detailInfos"
					  style="margin-left: 5em"
					  @cell-click=""
					  @edit-closed=""
					  highlight-current-row
					  :edit-config="{trigger: 'click', mode: 'row', showStatus: true, autoClear: true, icon:'_'}"
					  :edit-rules="validRules"
				  >
					  <vxe-table-column field="userName" title="报销人" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销人', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.userName" @focus="userPullListForm(scope.$rowIndex)"></el-input>
							  <!--              <UserSelectV2 :limit='1' :userName="scope.row.userName" @getValue='(value, label) => {scope.row.userName = label}'></UserSelectV2>-->
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="deptName" title="报销部门" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input :disabled='true' v-model="scope.row.deptName" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="typeName" title="报销类别" :edit-render="{}" :rules="[{required: true, message:'请选择报销类别', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.typeName" @focus="typePullForm(scope.$rowIndex, scope.row.deptId)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="projectName" title="报销项目" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销项目', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.projectName" @focus="openProgramPageForm(scope.$rowIndex, scope.row)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="reportNumber" title="报告号" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <!--                <el-input :readonly="true" v-model="scope.row.reportNumber" @focus="openReportNoPageForm(scope.$rowIndex, scope.row)"></el-input>-->
							  <el-input :readonly="true" v-model="scope.row.reportNumber"></el-input>

						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="number" title="费用(元)" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请输入费用', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input maxlength="15" v-model="scope.row.number" @input="scope.row.number = twoDecimalPlaces(scope.row.number)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="receiptNumber" title="收据张数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.receiptNumber" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="days" title="出差天数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.days" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="content" title="内容" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.content" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column title="操作" width="100">
						  <template #default="scope">
							  <el-button size="default" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'detail')">删除</el-button>
						  </template>
					  </vxe-table-column>
				  </vxe-table>
			  </el-col>

          </el-row>
        </div>
        <div v-if="inputForm.sourceType === '2'">
          <el-divider content-position="left"><i class="el-icon-document"></i>
            合同报销详情
            <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="default" @click="insertEvent('contract_detail')" plain>
              新增
            </el-button>
          </el-divider>
          <el-row  :gutter="15" >
			  <el-col :span="24">
				  <vxe-table
					  border
					  show-footer
					  show-overflow
					  :footer-method="footerMethod"
					  ref="detailTableContract"
					  :key="detailKeyContract"
					  class="vxe-table-element"
					  :data="inputForm.detailInfoContracts"
					  style="margin-left: 5em"
					  @cell-click=""
					  @edit-closed=""
					  highlight-current-row
					  :edit-config="{trigger: 'click', mode: 'row', showStatus: true, autoClear: true, icon:'_'}"
					  :edit-rules="validRules"
				  >
					  <vxe-table-column field="userName" title="报销人" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销人', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.userName" @focus="userPullListForm2(scope.$rowIndex)"></el-input>
							  <!--              <UserSelectV2 :limit='1' :userName="scope.row.userName" @getValue='(value, label) => {scope.row.userName = label}'></UserSelectV2>-->
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="deptName" title="报销部门" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input :disabled='true' v-model="scope.row.deptName" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="typeName" title="报销类别" :edit-render="{}" :rules="[{required: true, message:'请选择报销类别', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.typeName" @focus="typePullForm2(scope.$rowIndex, scope.row.deptId)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="contractName" title="报销合同" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销合同', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.contractName" @focus="openContractForm(scope.$rowIndex, scope.row)"></el-input>
						  </template>
					  </vxe-table-column>
					  <!--            <vxe-table-column field="reportNumber" title="报告号" :edit-render="{}">-->
					  <!--              <template v-slot:edit="scope">-->
					  <!--                <el-input :readonly="true" v-model="scope.row.reportNumber" @focus="openReportNoPageForm(scope.$rowIndex, scope.row)"></el-input>-->
					  <!--              </template>-->
					  <!--            </vxe-table-column>-->
					  <vxe-table-column field="number" title="费用(元)" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请输入费用', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input maxlength="15" v-model="scope.row.number" @input="scope.row.number = twoDecimalPlaces(scope.row.number)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="receiptNumber" title="收据张数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.receiptNumber" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="days" title="出差天数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.days" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="content" title="内容" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.content" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column title="操作" width="100">
						  <template #default="scope">
							  <el-button size="default" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'contract_detail')">删除</el-button>
						  </template>
					  </vxe-table-column>
				  </vxe-table>
			  </el-col>

          </el-row>
        </div>
        <div v-if="inputForm.sourceType === '3'">
          <el-divider content-position="left"><i class="el-icon-document"></i>
            报告报销详情
            <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="default" @click="insertEvent('report_detail')" plain>
              新增
            </el-button>
          </el-divider>
          <el-row  :gutter="15" >
			  <el-col :span="24">
				  <vxe-table
					  border
					  show-footer
					  show-overflow
					  :footer-method="footerMethod"
					  ref="detailTableReport"
					  :key="detailKeyReport"
					  class="vxe-table-element"
					  :data="inputForm.detailInfoReports"
					  style="margin-left: 5em"
					  @cell-click=""
					  @edit-closed=""
					  highlight-current-row
					  :edit-config="{trigger: 'click', mode: 'row', showStatus: true, autoClear: true, icon:'_'}"
					  :edit-rules="validRules"
				  >
					  <vxe-table-column field="userName" title="报销人" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销人', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.userName" @focus="userPullListForm3(scope.$rowIndex)"></el-input>
							  <!--              <UserSelectV2 :limit='1' :userName="scope.row.userName" @getValue='(value, label) => {scope.row.userName = label}'></UserSelectV2>-->
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="deptName" title="报销部门" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input :disabled='true' v-model="scope.row.deptName" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="typeName" title="报销类别" :edit-render="{}" :rules="[{required: true, message:'请选择报销类别', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.typeName" @focus="typePullForm3(scope.$rowIndex, scope.row.deptId)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="projectName" title="报销项目" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销项目', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.projectName" @focus="openProgramPageForm3(scope.$rowIndex, scope.row)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="reportNumber" title="报告号" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input :readonly="true" v-model="scope.row.reportNumber" @focus="openReportNoPageForm(scope.$rowIndex, scope.row)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="number" title="费用(元)" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请输入费用', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input maxlength="15" v-model="scope.row.number" @input="scope.row.number = twoDecimalPlaces(scope.row.number)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="receiptNumber" title="收据张数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.receiptNumber" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="days" title="出差天数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.days" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="content" title="内容" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.content" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column title="操作" width="100">
						  <template #default="scope">
							  <el-button size="default" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'report_detail')">删除</el-button>
						  </template>
					  </vxe-table-column>
				  </vxe-table>
			  </el-col>

          </el-row>
        </div>
        <div v-if="inputForm.sourceType === '4'">
          <el-divider content-position="left"><i class="el-icon-document"></i>
            其他报销详情
            <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="default" @click="insertEvent('others')" plain>
              新增
            </el-button>
          </el-divider>
          <el-row  :gutter="15" >
			  <el-col :span="24">
				  <vxe-table
					  border
					  show-footer
					  show-overflow
					  :footer-method="footerMethod"
					  ref="detailTableOthers"
					  class="vxe-table-element"
					  :data="inputForm.detailInfoOthers"
					  style="margin-left: 5em"
					  :key="detailKeyOthers"
					  @cell-click=""
					  @edit-closed=""
					  highlight-current-row
					  :edit-config="{trigger: 'click', mode: 'row', showStatus: true, autoClear: true, icon:'_'}"
					  :edit-rules="validRules"
				  >
					  <vxe-table-column field="userName" title="报销人" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销人', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.userName" @focus="userPullListForm4(scope.$rowIndex)"></el-input>
							  <!--              <UserSelectV2 :limit='1' :userName="scope.row.userName" @getValue='(value, label) => {scope.row.userName = label}'></UserSelectV2>-->
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="deptName" title="报销部门" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input :disabled='true' v-model="scope.row.deptName" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="typeName" title="报销类别" :edit-render="{}" :rules="[{required: true, message:'请选择报销类别', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.typeName" @focus="typePullForm4(scope.$rowIndex, scope.row.deptId)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="projectName" title="报销详情" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请填写报销详情', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.projectName" @focus="openProgramPageForm4(scope.$rowIndex, scope.row)"></el-input>
						  </template>
					  </vxe-table-column>
					  <!--            <vxe-table-column field="reportNumber" title="报告号" :edit-render="{}">-->
					  <!--              <template v-slot:edit="scope">-->
					  <!--                <el-input :readonly="true" v-model="scope.row.reportNumber" @focus="openReportNoPageForm(scope.$rowIndex, scope.row)"></el-input>-->
					  <!--              </template>-->
					  <!--            </vxe-table-column>-->
					  <vxe-table-column field="number" title="费用(元)" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请输入费用', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input maxlength="15" v-model="scope.row.number" @input="scope.row.number = twoDecimalPlaces(scope.row.number)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="receiptNumber" title="收据张数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.receiptNumber" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="days" title="出差天数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.days" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="content" title="内容" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.content" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column title="操作" width="100">
						  <template #default="scope">
							  <el-button size="default" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'others')">删除</el-button>
						  </template>
					  </vxe-table-column>
				  </vxe-table>
			  </el-col>

          </el-row>
        </div>
        <div v-if="inputForm.sourceType === '5'">
          <el-divider content-position="left"><i class="el-icon-document"></i>
            采购报销详情
            <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="default" @click="insertEvent('procured')" plain>
              新增
            </el-button>
          </el-divider>
          <el-row  :gutter="15" >
			  <el-col :span="24">
				  <vxe-table
					  border
					  show-footer
					  show-overflow
					  :footer-method="footerMethod"
					  ref="detailTableProcured"
					  class="vxe-table-element"
					  :data="inputForm.detailInfoProcured"
					  style="margin-left: 5em"
					  :key="detailKeyProcured"
					  @cell-click=""
					  @edit-closed=""
					  highlight-current-row
					  :edit-config="{trigger: 'click', mode: 'row', showStatus: true, autoClear: true, icon:'_'}"
					  :edit-rules="validRules"
				  >
					  <vxe-table-column field="userName" title="报销人" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销人', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.userName" @focus="userPullListForm5(scope.$rowIndex)"></el-input>
							  <!--              <UserSelectV2 :limit='1' :userName="scope.row.userName" @getValue='(value, label) => {scope.row.userName = label}'></UserSelectV2>-->
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="deptName" title="报销部门" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input :disabled='true' v-model="scope.row.deptName" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="typeName" title="报销类别" :edit-render="{}" :rules="[{required: true, message:'请选择报销类别', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.typeName" @focus="typePullForm5(scope.$rowIndex, scope.row.deptId)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="projectName" title="报销项目" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请选择报销项目', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input v-model="scope.row.projectName" @focus="openProgramPageForm5(scope.$rowIndex, scope.row)"></el-input>
						  </template>
					  </vxe-table-column>
					  <!--            <vxe-table-column field="reportNumber" title="报告号" :edit-render="{}">-->
					  <!--              <template v-slot:edit="scope">-->
					  <!--                <el-input :readonly="true" v-model="scope.row.reportNumber" @focus="openReportNoPageForm(scope.$rowIndex, scope.row)"></el-input>-->
					  <!--              </template>-->
					  <!--            </vxe-table-column>-->
					  <vxe-table-column field="number" title="费用(元)" :edit-render="{}" show-overflow="title" :rules="[{required: true, message:'请输入费用', trigger:'blur'}]">
						  <template #edit="scope">
							  <el-input maxlength="15" v-model="scope.row.number" @input="scope.row.number = twoDecimalPlaces(scope.row.number)"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="receiptNumber" title="收据张数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.receiptNumber" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="days" title="出差天数" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.days" oninput ="value=value.replace(/\D|^0/g,'')" maxlength="10"></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column field="content" title="内容" :edit-render="{}" show-overflow="title">
						  <template #edit="scope">
							  <el-input v-model="scope.row.content" ></el-input>
						  </template>
					  </vxe-table-column>
					  <vxe-table-column title="操作" width="100">
						  <template #default="scope">
							  <el-button size="default" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'procured')">删除</el-button>
						  </template>
					  </vxe-table-column>
				  </vxe-table>
			  </el-col>

          </el-row>
        </div>

		  <div v-if="inputForm.reimbursementType === '0'">
        <el-divider content-position="left"><i class="el-icon-document"></i>
          专用发票信息
          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail' " size="default" @click="insertEvent('amount')" plain>
            新增
          </el-button>
        </el-divider>
        <el-row  :gutter="15" >
			<el-col :span="24">
				<vxe-table
					border
					show-overflow
					ref="amountTable"
					class="vxe-table-element"
					:data="inputForm.amountInfos"
					style="margin-left: 5em"
					@cell-click=""
					:key="amountKey"
					@edit-closed=""
					highlight-current-row
					:edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true}"
				>
					<vxe-table-column field="code" title="发票代码" :edit-render="{}" show-overflow="title">
						<template #edit="scope">
							<el-input oninput ="value=value.replace(/\D|^/g,'')" maxlength="20" v-model="scope.row.code" ></el-input>
						</template>
					</vxe-table-column>
					<vxe-table-column field="number" title="发票号" :edit-render="{}" show-overflow="title">
						<template #edit="scope">
							<el-input oninput ="value=value.replace(/\D|^/g,'')" maxlength="8" @change="isExict(scope.row)" v-model="scope.row.number" ></el-input>
						</template>
					</vxe-table-column>
					<vxe-table-column field="amount" title="金额" :edit-render="{}" show-overflow="title">
						<template #edit="scope">
							<el-input maxlength="15" v-model="scope.row.amount" @input="scope.row.amount = twoDecimalPlaces(scope.row.amount)" @change="countAmount(scope.row)"></el-input>
						</template>
					</vxe-table-column>
					<vxe-table-column field="taxAmount" title="税额" :edit-render="{}" show-overflow="title">
						<template #edit="scope">
							<el-input maxlength="15" v-model="scope.row.taxAmount" @input="scope.row.taxAmount = twoDecimalPlaces(scope.row.taxAmount)" @change="countAmount(scope.row)"></el-input>
						</template>
					</vxe-table-column>
					<vxe-table-column field="count" title="价税合计" :edit-render="{}" show-overflow="title">
						<template #edit="scope">
							<el-input disabled="true" v-model="scope.row.count" ></el-input>
						</template>
					</vxe-table-column>
					<vxe-table-column title="操作" width="100">
						<template #default="scope">
							<el-button size="default" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'amount')">删除</el-button>
						</template>
					</vxe-table-column>
				</vxe-table>
			</el-col>

        </el-row>
		  </div>
		  <div v-if="inputForm.reimbursementType === '1'">
			  <el-divider content-position="left"><i class="el-icon-document"></i>
				  <span style="color: red;border-top: 20px">* </span>电子发票信息
				  <!--<el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail' " size="default" @click="insertEvent('invoiceReimbursement')" plain>
					  新增
				  </el-button>-->
			  </el-divider>
			  <el-row  :gutter="15" >
				  <el-col :span="24">
					  <vxe-table
						  border
						  show-footer
						  show-overflow
						  ref="invoiceReimbursementTable"
						  class="vxe-table-element"
						  :data="inputForm.invoiceReimbursements"
						  style="margin-left: 5em"
						  @cell-click=""
						  :key="invoiceReimbursementKey"
						  @edit-closed=""
						  highlight-current-row
						  :edit-config="{trigger: 'click', mode: 'row', showStatus: true, autoClear: true, icon:'_'}"
						  :edit-rules="invoiceReimbursementRules"
					  >
						  <vxe-table-column  field="invoiceType" title="发票类型" show-overflow="title" :edit-render="{name: '$select', options: $dictUtils.getDictList('invoice_reimbursement_type')}">
							  <template v-slot:edit="scope">
								  <vxe-select :disabled="true" v-model="scope.row.invoiceType" placeholder="请选择发票类型" clearable style="width: 100%;" transfer>
									  <vxe-option
										  v-for="item in $dictUtils.getDictList('invoice_reimbursement_type')"
										  :key="item.value"
										  :label="item.label"
										  :value="item.value">
									  </vxe-option>
								  </vxe-select>
							  </template>
						  </vxe-table-column>
						  <vxe-table-column field="invoiceProjectName" title="发票项目名" :edit-render="{}" show-overflow="title">
							  <template #edit="scope">
								  <el-input maxlength="50" readonly="true" v-model="scope.row.invoiceProjectName" ></el-input>
							  </template>
						  </vxe-table-column>
						  <vxe-table-column field="number" title="发票号" :edit-render="{}" show-overflow="title">
							  <template #edit="scope">
								  <el-input oninput ="value=value.replace(/\D|^/g,'')" readonly="true" maxlength="30" @change="isExict(scope.row)" v-model="scope.row.number" ></el-input>
							  </template>
						  </vxe-table-column>
						  <vxe-table-column field="invoiceDate" title="开票日期" :edit-render="{}" show-overflow="title">
							  <template v-slot:edit="scope">
								  <vxe-input v-model="scope.row.invoiceDate" readonly="true" type="datetime" transfer placeholder="请选择日期"></vxe-input>
							  </template>
						  </vxe-table-column>
						  <vxe-table-column field="invoiceUnit" title="开票单位" :edit-render="{}" show-overflow="title">
							  <template #edit="scope">
								  <el-input maxlength="50" readonly="true" v-model="scope.row.invoiceUnit" ></el-input>
							  </template>
						  </vxe-table-column>
						  <vxe-table-column field="amount" title="金额" :edit-render="{}" show-overflow="title">
							  <template #edit="scope">
								  <el-input maxlength="15" readonly="true" v-model="scope.row.amount" @input="scope.row.amount = twoDecimalPlaces(scope.row.amount)" @change="countAmount(scope.row)"></el-input>
							  </template>
						  </vxe-table-column>
						  <vxe-table-column field="taxAmount" title="税额" :edit-render="{}" show-overflow="title">
							  <template #edit="scope">
								  <el-input maxlength="15" readonly="true" v-model="scope.row.taxAmount" @input="scope.row.taxAmount = twoDecimalPlaces(scope.row.taxAmount)" @change="countAmount(scope.row)"></el-input>
							  </template>
						  </vxe-table-column>
						  <vxe-table-column field="count" title="价税合计" :edit-render="{}" show-overflow="title">
							  <template #edit="scope">
								  <el-input disabled="true" v-model="scope.row.count" ></el-input>
							  </template>
						  </vxe-table-column>
						  <vxe-table-column field="remarks" title="备注" :edit-render="{}" show-overflow="title">
							  <template #edit="scope">
								  <el-input maxlength="250" v-model="scope.row.remarks" ></el-input>
							  </template>
						  </vxe-table-column>
						  <!--<vxe-table-column title="操作" width="100">
							  <template #default="scope">
								  <el-button size="default" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'invoiceReimbursement')">删除</el-button>
							  </template>
						  </vxe-table-column>-->
					  </vxe-table>
				  </el-col>
			  </el-row>
		  </div>

      </el-form>
		<!-- 附件 -->
		<InvoiceReimbursementUpLoadComponent ref="invoiceReimbursementUpLoadComponent" v-show="'1' === this.inputForm.reimbursementType"></InvoiceReimbursementUpLoadComponent>
		<UpLoadComponent ref="uploadComponent"></UpLoadComponent>
		<template #footer>
			<span class="dialog-footer">
			  <el-button size="default" @click="close()" icon="el-icon-circle-close">关闭</el-button>
			  <el-button size="default" type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
			</span>
		</template>
    </el-dialog>
  </div>
</template>

<script>
  import ReimbursementService from '@/api/sys/ReimbursementService'
  import UpLoadComponent from '@/views/common/UpLoadComponent'
  import InvoiceReimbursementUpLoadComponent from '@/views/common/InvoiceReimbursementUpLoadComponent'
  import MaterialManagementService from '@/api/materialManagement/MaterialManagementService'
  import XEUtils from 'xe-utils'
  export default {
    data () {
      return {
        validRules: {
          userName: [
            {required: true, message: '报销人不能为空'}
          ],
          deptName: [
            {required: true, message: '报销部门不能为空'}
          ],
          typeName: [
            {required: true, message: '报销类型不能为空'}
          ],
          projectName: [
            {required: true, message: '报销项目不能为空'}
          ],
          contractName: [
            {required: true, message: '报销合同不能为空'}
          ],
          reportNumber: [
            {required: true, message: '报告号不能为空'}
          ],
          number: [
            {required: true, message: '费用(元)不能为空'}
          ]
        },
        title: '',
        method: '',
        visible: false,
        loading: false,
        inputForm: {
			reimbursementType: '0',
          userId: '',
          userName: '',
          no: '',
          department: '',
          reimDate: '',
          remarks: '',
          detailInfos: [],
          detailInfoContracts: [],
          detailInfoReports: [],
          detailInfoOthers: [],
          detailInfoProcured: [],
          amountInfos: [],
			invoiceReimbursements: [],
			invoiceReimbursementFiles: [], // 电子发票附件信息
          files: [], // 附件信息
          procInsId: '',
          sourceType: '',
          preList: [],
          purchaseNo: '',
          tradeTotalPrice: '',
          purchaseId: '',
			procDefId: '',
			procDefKey: '',
			formTitle: '',
			departmentName: ''
        },
        indexRow: '',
        detailKey: '',
        detailKeyContract: '',
        detailKeyReport: '',
        detailKeyOthers: '',
        detailKeyProcured: '',
        keyWatch: '',
		  amountKey: '',
		  invoiceReimbursementKey: ''
      }
    },
	  provide() {
		  return {
			  getParentReimbursementType: this.getParentReimbursementType
		  }
	  },
    reimbursementService: null,
    materialManagementService: null,
    created () {
      this.reimbursementService = new ReimbursementService()
      this.materialManagementService = new MaterialManagementService()
    },
    components: {
		InvoiceReimbursementUpLoadComponent,
      UpLoadComponent
    },
    methods: {
		getParentReimbursementType() {
			return this.inputForm.reimbursementType
		},
      init (method, id) {
        this.method = method
        this.inputForm = {
			reimbursementType: '0',
          userId: '',
          userName: '',
          no: '',
          department: '',
          reimDate: '',
          remarks: '',
          detailInfos: [],
          detailInfoContracts: [],
          detailInfoReports: [],
          detailInfoOthers: [],
          detailInfoProcured: [],
          amountInfos: [],
			invoiceReimbursements: [],
			invoiceReimbursementFiles: [], // 电子发票附件信息
          files: [], // 附件信息
          procInsId: '',
          sourceType: '',
          preList: [],
          purchaseNo: '',
          tradeTotalPrice: '',
          purchaseId: '',
          departmentName: ''
        }
        if (method === 'add') {
          this.title = `新建报销类型`
        } else if (method === 'edit') {
          this.inputForm.id = id
          this.title = '修改报销类型'
        } else if (method === 'view') {
          this.inputForm.id = id
          this.title = '查看报销详情'
        } else if (method === 'addChild') {
          this.title = '添加下级结构'
          this.inputForm.parentId = id
        }
        this.visible = true
        this.loading = false
        this.$nextTick(() => {
          if (method === 'edit' || method === 'view') { // 修改或者查看
            this.loading = true
            this.$refs.inputForm.resetFields()
            this.reimbursementService.findById(this.inputForm.id).then((data) => {
              this.inputForm = this.recover(this.inputForm, data)
              this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
              this.$refs.uploadComponent.clearUpload()
				this.$refs.invoiceReimbursementUpLoadComponent.clearUpload()
              if (this.status === 'audit' || this.status === 'taskFormDetail') {
                method = 'view'
              }
              if (this.commonJS.isEmpty(this.inputForm.department)) {
                this.inputForm.department = this.$store.state.user.office.id
                this.inputForm.departmentName = this.$store.state.user.office.name
              }
              if (this.commonJS.isEmpty(this.inputForm.userId)) {
                this.inputForm.userId = this.$store.state.user.id
              }
              if (this.commonJS.isEmpty(this.inputForm.userName)) {
                this.inputForm.userName = this.$store.state.user.name
              }
              if (this.commonJS.isEmpty(this.inputForm.reimDate)) {
                this.inputForm.reimDate = new Date()
              }
				if (this.commonJS.isEmpty(this.inputForm.invoiceReimbursementFiles)) {
					this.inputForm.invoiceReimbursementFiles = []
				}
				if (this.commonJS.isEmpty(this.inputForm.files)) {
					this.inputForm.files = []
				}
				if (this.commonJS.isEmpty(this.inputForm.reimbursementType)) {
					this.inputForm.reimbursementType = '0'
				}
				this.$refs.invoiceReimbursementUpLoadComponent.newUpload(method, this.inputForm.invoiceReimbursementFiles, 'reimbursement_ping_gu',300,'电子发票附件')
				this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'reimbursement_ping_gu')
              if (this.commonJS.isNotEmpty(this.inputForm.purchaseId)) {
                this.startPur(this.inputForm.purchaseId)
              }
              this.loading = false
            })
          }
        })
      },
      // 表单提交
      doSubmit () {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            if (this.$refs.uploadComponent.checkProgress()) {
              this.loading = false
              return
            }
            if (this.commonJS.isEmpty(this.inputForm.files)) {
              this.inputForm.files = []
            }
            this.inputForm.files = this.$refs.uploadComponent.getDataList()
            this.reimbursementTypeService.save(this.inputForm).then((data) => {
              this.close()
              this.$message.success(data)
              this.$emit('refreshDataList')
              this.loading = false
            }).catch(() => {
              this.loading = false
            })
          }
        })
      },
      close () {
        this.$refs.inputForm.resetFields()
        this.inputForm.detailInfos = []
        this.inputForm.amountInfos = []
        this.inputForm.invoiceReimbursements = []
        this.$refs.uploadComponent.clearUpload()
        this.visible = false
      },
      // 删除
      removeEvent (row, rowIndex, type) {
        if (type === 'detail') {
          this.$refs.detailTable.remove(row)
          this.inputForm.detailInfos.splice(rowIndex, 1)
        }
        if (type === 'amount') {
          this.$refs.amountTable.remove(row)
          this.inputForm.amountInfos.splice(rowIndex, 1)
        }
      },
      // 新增
      async insertEvent (type) {
        if (type === 'detail') {
          await this.$refs.detailTable.insert().then((data) => {
            this.inputForm.detailInfos.push(data)
          })
        }
        if (type === 'amount') {
          await this.$refs.amountTable.insert().then((data) => {
            this.inputForm.amountInfos.push(data)
          })
        }
      },
      footerMethod ({ columns, data }) {
        const footerData = [
          columns.map((column, columnIndex) => {
            if (columnIndex === 0) {
              return '总报销费用'
            }
            if (['number'].includes(column.property)) {
              // eslint-disable-next-line no-undef
              return XEUtils.sum(data, column.property)
            }
            return null
          })
        ]
        return footerData
      },
      twoDecimalPlaces (num) {
        let str = num.toString()
		  str=str.replace(/\s+/g,"");
        var len1 = str.substr(0, 1)
        var len2 = str.substr(1, 1)
        // eslint-disable-next-line eqeqeq
        if (str.length > 1 && len1 == 0 && len2 != '.') {
          str = str.substr(1, 1)
        }
        // eslint-disable-next-line eqeqeq
        if (len1 == '.') {
          str = ''
        }
        // eslint-disable-next-line eqeqeq
        if (str.indexOf('.') != -1) {
          var str_ = str.substr(str.indexOf('.') + 1)
          // eslint-disable-next-line eqeqeq
          if (str_.indexOf('.') != -1) {
            str = str.substr(0, str.indexOf('.') + str_.indexOf('.') + 1)
          }
          if (str_.length > 2) {
            this.$message.warning(`金额小数点后只能输入两位，请正确输入！`)
            return (str = '')
          }
        }
        // eslint-disable-next-line no-useless-escape
        str = str.replace(/[^\d^\.]+/g, '') // 保留数字和小数点
        return str
      },
      isExict (row) {
        this.reimbursementService.checkNumber(row.number).then((data) => {
          if (data) {
            this.$message.error('该发票号已存在')
            row.number = ''
          }
        })
      },
      countAmount (row) {
        let amount
        let taxAmount
        let count = 0
        if (!this.commonJS.isEmpty(row.amount)) {
          amount = parseFloat(row.amount)
          count = count + amount
        }
        if (!this.commonJS.isEmpty(row.taxAmount)) {
          taxAmount = parseFloat(row.taxAmount)
          count = count + taxAmount
        }
        row.count = parseFloat(count).toFixed(2)
      },
      openProgramPageForm (rowIndex, row) {
        if (this.commonJS.isEmpty(row.typeName)) {
          this.$message.error('请选择报销类型')
          return
        }
        this.indexRow = rowIndex
        this.reimbursementApprovalTypeService.findById(row.typeId).then((data) => {
          let i = data.sort.toString()
          i = i.substring(0, 1)
          // 非业务报销
          if (i !== '1') {
            this.$refs.programPageForm.init('2', false)
          } else {
            // 打开单选组件
            this.$refs.programPageForm.init('1', false)
          }
        })
      },
      openProgramPageForm3 (rowIndex, row) {
        if (this.commonJS.isEmpty(row.typeName)) {
          this.$message.error('请选择报销类型')
          return
        }
        this.indexRow = rowIndex
        this.reimbursementApprovalTypeService.findById(row.typeId).then((data) => {
          let i = data.sort.toString()
          i = i.substring(0, 1)
          // 非业务报销
          if (i !== '1') {
            this.$refs.programPageForm3.init('2', false)
          } else {
            // 打开单选组件
            this.$refs.programPageForm3.init('1', false)
          }
        })
      },
      openProgramPageForm4 (rowIndex, row) {
        if (this.commonJS.isEmpty(row.typeName)) {
          this.$message.error('请选择报销类型')
          return
        }
        this.indexRow = rowIndex
        this.$refs.programPageForm4.init('2', false)
      },
      openProgramPageForm5 (rowIndex, row) {
        if (this.commonJS.isEmpty(row.typeName)) {
          this.$message.error('请选择报销类型')
          return
        }
        this.indexRow = rowIndex
        this.$refs.programPageForm5.init('2', false)
      },
      // getProgram (rows) {
      //   this.inputForm.detailInfos[this.indexRow].projectId = rows[0].id
      //   this.inputForm.detailInfos[this.indexRow].projectName = rows[0].name
      //   this.inputForm.detailInfos[this.indexRow].reportNumber = rows[0].reportNo
      //   this.indexRow = ''
      //   this.$forceUpdate()
      // },
      getProgram (rows) {
        this.inputForm.detailInfos[this.indexRow].projectId = rows[0].id
        this.inputForm.detailInfos[this.indexRow].projectName = rows[0].name
        this.inputForm.detailInfos[this.indexRow].reportNumber = rows[0].reportNo
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgram3 (rows) {
        this.inputForm.detailInfoReports[this.indexRow].projectId = rows[0].id
        this.inputForm.detailInfoReports[this.indexRow].projectName = rows[0].name
        this.inputForm.detailInfoReports[this.indexRow].reportNumber = rows[0].reportNo
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgram4 (rows) {
        this.inputForm.detailInfoOthers[this.indexRow].projectId = rows[0].id
        this.inputForm.detailInfoOthers[this.indexRow].projectName = rows[0].name
        this.inputForm.detailInfoOthers[this.indexRow].reportNumber = rows[0].reportNo
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgram5 (rows) {
        this.inputForm.detailInfoProcured[this.indexRow].projectId = rows[0].id
        this.inputForm.detailInfoProcured[this.indexRow].projectName = rows[0].name
        this.inputForm.detailInfoProcured[this.indexRow].reportNumber = rows[0].reportNo
        this.indexRow = ''
        this.$forceUpdate()
      },
      // 报销类型下拉弹窗
      typePullForm (rowIndex, deptName) {
        console.log(this.$refs.cwReimbursementTypePullForm)
        this.indexRow = rowIndex
        // this.$refs.reimbursementTypePullForm.init()
        this.$refs.cwReimbursementTypePullForm.init('1', deptName)
      },
      typePullForm2 (rowIndex, deptName) {
        this.indexRow = rowIndex
        this.$refs.cwReimbursementTypePullForm2.init('2', deptName)
      },
      typePullForm3 (rowIndex, deptName) {
        this.indexRow = rowIndex
        this.$refs.cwReimbursementTypePullForm3.init('1', deptName)
      },
      typePullForm4 (rowIndex, deptName) {
        this.indexRow = rowIndex
        this.$refs.cwReimbursementTypePullForm4.init('2', deptName)
      },
      typePullForm5 (rowIndex, deptName) {
        this.indexRow = rowIndex
        this.$refs.cwReimbursementTypePullForm5.init('2', deptName)
      },
      // 报销内容详情
      getProgramForType (rows) {
        this.inputForm.detailInfos[this.indexRow].typeId = rows.id
        this.inputForm.detailInfos[this.indexRow].typeName = rows.name
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgramForType2 (rows) {
        this.inputForm.detailInfoContracts[this.indexRow].typeId = rows.id
        this.inputForm.detailInfoContracts[this.indexRow].typeName = rows.name
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgramForType3 (rows) {
        this.inputForm.detailInfoReports[this.indexRow].typeId = rows.id
        this.inputForm.detailInfoReports[this.indexRow].typeName = rows.name
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgramForType4 (rows) {
        this.inputForm.detailInfoOthers[this.indexRow].typeId = rows.id
        this.inputForm.detailInfoOthers[this.indexRow].typeName = rows.name
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgramForType5 (rows) {
        this.inputForm.detailInfoProcured[this.indexRow].typeId = rows.id
        this.inputForm.detailInfoProcured[this.indexRow].typeName = rows.name
        this.indexRow = ''
        this.$forceUpdate()
      },
      // 报销人下拉弹窗
      userPullListForm (rowIndex) {
        this.indexRow = rowIndex
        this.$refs.userPullForm.init()
      },
      userPullListForm2 (rowIndex) {
        this.indexRow = rowIndex
        this.$refs.userPullForm2.init()
      },
      userPullListForm3 (rowIndex) {
        this.indexRow = rowIndex
        this.$refs.userPullForm3.init()
      },
      userPullListForm4 (rowIndex) {
        this.indexRow = rowIndex
        this.$refs.userPullForm4.init()
      },
      userPullListForm5 (rowIndex) {
        this.indexRow = rowIndex
        this.$refs.userPullForm5.init()
      },
      getProgramForUser (rows) {
        this.inputForm.detailInfos[this.indexRow].userId = rows[0].id
        this.inputForm.detailInfos[this.indexRow].userName = rows[0].name
        this.inputForm.detailInfos[this.indexRow].deptId = rows[0].parentId
        this.inputForm.detailInfos[this.indexRow].deptName = rows[0].officeName
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgramForUser2 (rows) {
        this.inputForm.detailInfoContracts[this.indexRow].userId = rows[0].id
        this.inputForm.detailInfoContracts[this.indexRow].userName = rows[0].name
        this.inputForm.detailInfoContracts[this.indexRow].deptId = rows[0].parentId
        this.inputForm.detailInfoContracts[this.indexRow].deptName = rows[0].officeName
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgramForUser3 (rows) {
        this.inputForm.detailInfoReports[this.indexRow].userId = rows[0].id
        this.inputForm.detailInfoReports[this.indexRow].userName = rows[0].name
        this.inputForm.detailInfoReports[this.indexRow].deptId = rows[0].parentId
        this.inputForm.detailInfoReports[this.indexRow].deptName = rows[0].officeName
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgramForUser4 (rows) {
        this.inputForm.detailInfoOthers[this.indexRow].userId = rows[0].id
        this.inputForm.detailInfoOthers[this.indexRow].userName = rows[0].name
        this.inputForm.detailInfoOthers[this.indexRow].deptId = rows[0].parentId
        this.inputForm.detailInfoOthers[this.indexRow].deptName = rows[0].officeName
        this.indexRow = ''
        this.$forceUpdate()
      },
      getProgramForUser5 (rows) {
        this.inputForm.detailInfoProcured[this.indexRow].userId = rows[0].id
        this.inputForm.detailInfoProcured[this.indexRow].userName = rows[0].name
        this.inputForm.detailInfoProcured[this.indexRow].deptId = rows[0].parentId
        this.inputForm.detailInfoProcured[this.indexRow].deptName = rows[0].officeName
        this.indexRow = ''
        this.$forceUpdate()
      },
      // 报销类型change事件
      changeSourceType () {
        this.inputForm.detailInfos = []
        this.inputForm.detailInfoContracts = []
        this.inputForm.detailInfoReports = []
        this.inputForm.detailInfoOthers = []
        this.inputForm.detailInfoProcured = []
        this.inputForm.purchaseNo = ''
        this.inputForm.preList = ''
        this.inputForm.purchaseId = ''
        this.detailKey = Math.random()
        this.detailKeyContract = Math.random()
        this.detailKeyReport = Math.random()
        this.detailKeyOthers = Math.random()
        this.detailKeyProcured = Math.random()
      },
      openContractForm (rowIndex, row) {
        this.$refs.workContractChooseCom.init(rowIndex)
      },
      getContract (row, rowIndex) {
        console.log(row)
        this.inputForm.detailInfoContracts[rowIndex].contractId = row.id
        this.inputForm.detailInfoContracts[rowIndex].contractName = row.name
        this.$forceUpdate()
      },
      startPur (id) {
        this.materialManagementService.findById(id).then((data) => {
          this.inputForm.preList = data.detailInfos
          this.inputForm.purchaseNo = data.purchaseNo
          let i = this.inputForm.preList.length
          for (let j = 0; j < i; j++) {
            if (this.commonJS.isNotEmpty(this.inputForm.preList[j].tradePrice)) {
              if (this.commonJS.isNotEmpty(this.inputForm.preList[j].tradeNumber)) {
                this.inputForm.preList[j].priceSum = this.inputForm.preList[j].tradePrice * this.inputForm.preList[j].tradeNumber
              }
            }
          }
        })
        this.$forceUpdate()
      },
      openPurForm () {
        this.$refs.purchaseChooseForm.init()
      },
      getPurChoose (row) {
        this.inputForm.purchaseId = row.id
        this.startPur(row.id)
      },
      getUpload () {
      },
      footerMethod555 ({ columns, data }) {
        const footerData = [
          columns.map((column, columnIndex) => {
            if (columnIndex === 0) {
              return '商品总价'
            }
            if (['priceSum'].includes(column.property)) {
              // eslint-disable-next-line no-undef
              this.inputForm.tradeTotalPrice = XEUtils.sum(data, column.property)
              return XEUtils.sum(data, column.property)
            }
            return null
          })
        ]
        return footerData
      },
      seeFileInfo (index) {
        if (this.commonJS.isEmpty(this.inputForm.preList[index].fileInfoLost)) {
          this.inputForm.preList[index].fileInfoLost = []
        }
        this.$refs.materialManagementDialog.newUpload('view', this.inputForm.preList[index].fileInfoLost, null, null, null, null, null, false, index)
      }
    }
  }
</script>
