<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
	  draggable
      width="1200px"
      height="500px"
      @close="close"
      append-to-body
      v-model="visible">
    <el-row>
      <el-col :span="24">
        <el-tabs v-model="activeNameTop" type="border-card" @tab-click="tabHandleClickTop">
          <el-tab-pane label="项目信息" name="project" style="width: 100%;">
            <el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method === 'view'"
                     label-width="135px" @submit.native.prevent>
              <el-divider v-if="commonJS.isNotEmpty(inputForm.contractId) && method === 'view'" content-position="left">
                <el-link  type="primary" :underline="false" icon="el-icon-document" @click="viewContract(inputForm.contractId)"><b>查看合同详情</b></el-link>
              </el-divider>
              <el-divider v-else content-position="left"><i class="el-icon-document"></i> 选择合同</el-divider>
              <el-row  :gutter="15">
                <el-col :span="24">
                  <el-form-item label="合同名称" prop="contractName"
                                :rules="[
                 ]">
                    <el-input :readonly="true" @focus="openContract()" v-model="inputForm.contractName" placeholder="请选择合同">
                      <el-button slot="append" icon="el-icon-search" @click="openContract()"></el-button>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="合同金额(元)" prop="contractAmount"
                                :rules="[
                 ]">
                    <el-input :disabled="true" v-model="inputForm.contractAmount" placeholder="请填写合同金额"></el-input>
                  </el-form-item>
                </el-col>
                <!--            <el-col :span="12">-->
                <!--              <el-form-item label="合同份数" prop="contractNum"-->
                <!--                            :rules="[-->
                <!--                 ]">-->
                <!--                <el-input :disabled="true" v-model="inputForm.contractNum" placeholder="请填写合同份数"></el-input>-->
                <!--              </el-form-item>-->
                <!--            </el-col>-->
                <el-col :span="12">
                  <el-form-item label="委托人" prop="clientContactsName"
                                :rules="[
                 ]">
                    <el-input :disabled="true" v-model="inputForm.clientContactsName" placeholder="请填写委托人"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="付款主体" prop="payerSubject"
                                :rules="[
                 ]">
                    <el-select :disabled="true" v-model="inputForm.payerSubject" placeholder="请选择付款主体" style="width:100%;">
                      <el-option
                        v-for="item in $dictUtils.getDictList('cw_payment_subject')"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="付款方式" prop="paymentMethod"
                                :rules="[
                 ]">
                    <el-select :disabled="true" v-model="inputForm.paymentMethod" placeholder="请选择付款方式" style="width:100%;">
                      <el-option
                        v-for="item in $dictUtils.getDictList('cw_payment_method')"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-divider content-position="left"><i class="el-icon-document"></i> 项目信息</el-divider>
              <el-row  :gutter="15">
                <el-col :span="12">
                  <el-form-item label="项目名称" prop="projectName"
                                :rules="[
                                {required: true, message:'项目名称不能为空', trigger:'blur'}
                   ]">
                    <el-input v-model="inputForm.projectName" placeholder="请填写项目名称" clearable></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="项目编号" prop="projectNumber"
                                :rules="[
                   ]">
                    <el-input :disabled="true" v-model="inputForm.projectNumber" placeholder="请填写项目编号" ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="项目所属部门" prop="officeId"
                                :rules="[
                                {required: true, message:'项目所属部门不能为空', trigger:'blur'}
                   ]">
                    <SelectTree
                      ref="officeTree"
                      :props="{
                          value: 'id',             // ID字段名
                          label: 'name',         // 显示名称
                          children: 'children'    // 子级字段名
                        }"
                      :url="`/system-server/sys/office/treeData?type=2`"
                      :value="inputForm.officeId"
                      :accordion="true"
                      size="default"
                      @getValue="(value) => {inputForm.officeId=value}"/>
                  </el-form-item>
                </el-col>
<!--                <el-col :span="12">-->
<!--                  <el-form-item label="业务类型" prop="businessTypeName"-->
<!--                                :rules="[-->
<!--                   ]">-->
<!--                    <el-input :readonly="true" @focus="openBusinessTypeForm" v-model="inputForm.businessTypeName" placeholder="请填写业务类型" clearable></el-input>-->
<!--                  </el-form-item>-->
<!--                </el-col>-->
                <el-col :span="12">
                  <el-form-item label="风险等级" prop="riskLevel"
                                :rules="[
                   ]">
                    <el-select v-model="inputForm.riskLevel" placeholder="请选择风险等级" style="width:100%;">
                      <el-option
                        v-for="item in $dictUtils.getDictList('cw_project_risk_level')"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
				  <el-col :span="12">
					  <el-form-item label="项目等级" prop="projectLevel"
									:rules="[
                  {required: true, message:'请选择项目等级(500万及500万以上为A级，500万以下为B级)', trigger:'blur'}
               ]">
						  <el-radio-group v-model="inputForm.projectLevel">
							  <el-radio v-for="item in $dictUtils.getDictList('cw_project_level')" :label="item.value" >{{item.label}}</el-radio>
						  </el-radio-group>
					  </el-form-item>
					  <div style="color: red; display: block; margin-left: 140px;">500万及500万以上为A级，500万以下为B级</div>
				  </el-col>
                <el-col :span="12">
                  <el-form-item label="送审规模(万元)" prop="projectMoney"
                                :rules="[
                                	{required: true, message:'送审规模不能为空', trigger:'blur'}
                   ]">
                    <el-input-number
                      v-model="inputForm.projectMoney"
                      controls-position="right"
                      style="width:100%"
                      :precision="2"
                      :max="9999999999"
                      :step="0.01"
                      :min="0"
                      placeholder="请填写送审规模"
                      :controls="false"
                    >
                    </el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="项目类别" prop="reportType"
                                :rules="[
                                 {required: true, message:'项目类别不能为空', trigger:'blur'}
                  ]">
                    <el-select v-model="inputForm.reportType" placeholder="请选择项目类别" clearable style="width: 100%;">
                      <el-option
                        v-for="item in $dictUtils.getDictList('program_cost_audit_type')"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
					  <div style="color: red; display: block; ">与归档资料关联，请仔细选择</div>
                  </el-form-item>
                </el-col>
                <!--<el-col :span="12">
                  <el-form-item label="审计期间" prop="auditYear"
                                :rules="[
                   ]">
                    <el-date-picker
                      v-model="inputForm.auditYear"
                      type="year"
                      value-format="YYYY"
                      placeholder="选择评审计期间"
                      style="width:100%"
                      placement="bottom-start"
                    >
                    </el-date-picker>
                  </el-form-item>
                </el-col>-->
                <el-col :span="12">
                  <el-form-item label="项目预计时间" prop="planDate"
                                :rules="[
                   ]">
                    <el-date-picker
                      style="width: 100%"
                      placement="bottom-start"
					  format="YYYY-MM-DD h:m:s"
					  value-format="YYYY-MM-DD h:m:s"
                      v-model="inputForm.planDate"
                      type="datetimerange"
                      range-separator="至"
                      start-placeholder="开始日期"
                      @change="forUpdate"
                      end-placeholder="结束日期">
                    </el-date-picker>
                  </el-form-item>
                </el-col>

                <el-col :span="12">
                  <el-form-item label="现场负责人" prop="projectLeaderId"
                                :rules="[
                   ]">
					  <UserSelectForQualification :readonly="true" :disabled="method === 'view'" :limit='1' :modelValue="inputForm.projectLeaderId" @update:modelValue='(value) => {inputForm.projectLeaderId = value}'></UserSelectForQualification>
<!--                    <UserSelect :readonly="true" :disabled="method === 'view'" :limit='1' :modleValue="inputForm.projectLeaderId" @update:modelValue='(value) => {inputForm.projectLeaderId = value}'></UserSelect>-->
					  <span style="color: red">必须拥有一级造价师证书</span>
                  </el-form-item>
                </el-col>
				  <el-col :span="12">
					  <el-form-item label="工程类型" prop="engineeringType"
									:rules="[
                                 {required: true, message:'工程类型不能为空', trigger:'blur'}
                  ]">
						  <el-tree-select
							  v-model="inputForm.engineeringType"
							  :data="engineeringTypeList"
							  :render-after-expand="false"
							  style="width: 100%"
						  />
					  </el-form-item>
				  </el-col>
                <el-col :span="12">
                  <el-form-item label="项目经理1" prop="projectMasterId"
                                :rules="[
                                {required: true, message:'项目经理1不能为空', trigger:'blur'}
                   ]">
                    <!--                    <el-input v-model="inputForm.projectMasterId" placeholder="请填写项目经理" clearable></el-input>-->
<!--                    <UserSelectForQualification :readonly="true" :disabled="method === 'view'" :limit='1' :modelValue="inputForm.projectMasterId" @update:modelValue='(value) => {inputForm.projectMasterId = value}'></UserSelectForQualification>-->
					  <UserSelectSignatory :readonly="true" :disabled="status === 'audit' || status === 'taskFormDetail'"
										   :limit='1' :modelValue="inputForm.projectMasterId"
										   @update:modelValue='(value) => {inputForm.projectMasterId = value}'></UserSelectSignatory>
				  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="项目经理2" prop="realHeader"
                                :rules="[
                   ]">
<!--                    <UserSelectForQualification :readonly="true" :disabled="method === 'view'" :limit='1' :modelValue="inputForm.realHeader" @update:modelValue='(value) => {inputForm.realHeader = value}'></UserSelectForQualification>-->
					  <UserSelectSignatory :readonly="true" :disabled="status === 'audit' || status === 'taskFormDetail'"
										   :limit='1' :modelValue="inputForm.realHeader"
										   @update:modelValue='(value) => {inputForm.realHeader = value}'></UserSelectSignatory>
				  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="创建人" prop="createBy.name"
                                :rules="[
                   ]">
                    <el-input :disabled="true" v-model="inputForm.createBy.name" placeholder="请填写创建人" clearable></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="创建时间" prop="createDate"
                                :rules="[
                   ]">
                    <el-input :disabled="true" v-model="inputForm.createDate" placeholder="请填写创建时间" clearable></el-input>
                  </el-form-item>
                </el-col>
				  <el-col :span="12">
					  <el-form-item label="项目开始时间" prop="projectStartTime"
									:rules="[
                   ]">
						  <el-date-picker
							  v-model="inputForm.projectStartTime"
							  type="date"
							  value-format="YYYY-MM-DD"
							  placeholder="选择项目开始时间"
							  style="width:100%"
							  placement="bottom-start"
							  clearable>
						  </el-date-picker>
					  </el-form-item>
				  </el-col>
				  <el-col :span="12">
					  <el-form-item label="项目结束时间" prop="projectEndTime"
									:rules="[
                   ]">
						  <el-date-picker
							  v-model="inputForm.projectEndTime"
							  type="date"
							  value-format="YYYY-MM-DD"
							  placeholder="选择项目结束时间"
							  style="width:100%"
							  placement="bottom-start"
							  clearable>
						  </el-date-picker>
					  </el-form-item>
				  </el-col>
              </el-row>
            </el-form>
            <el-tabs v-model="activeName" style="width: 100%;" type="border-card" @tab-click="tabHandleClick">
              <el-tab-pane name="client">
				  <template v-slot:label>
					  <span><span style="color: red;border-top: 20px">*</span> 被服务单位</span>
				  </template>
                <el-row :gutter="15">
                  <el-button type="primary" style="margin-bottom: 15px" :disabled="method === 'view'" @click="openWorkClient">
                    新增被服务单位
                  </el-button>
                </el-row>
				  <el-row  :gutter="15">
					  <el-form :disabled="method === 'view'" style="width: 100%;">
						  <vxe-table
							  border
							  show-overflow
							  show-footer
							  :column-config="{resizable: true}"
							  ref="clientTable"
							  :key="tableKeyClient"
							  class="vxe-table-element"
							  :data="inputForm.cwProjectClientInfoDTOList"
							  style=""
							  keep-source
							  highlight-current-row
						  >
							  <vxe-table-column align="center" field="name" title="客户名称" :edit-render="{}" show-overflow="title"></vxe-table-column>
							  <vxe-table-column align="center" field="no" title="客户编号" :edit-render="{}" show-overflow="title"></vxe-table-column>
							  <vxe-table-column align="center" title="操作" width="100">
								  <template #default="scope">
									  <el-button type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'client')">删除</el-button>
								  </template>
							  </vxe-table-column>
						  </vxe-table>
					  </el-form>
				  </el-row>
              </el-tab-pane>
              <el-tab-pane name="contact">
				  <template v-slot:label>
					  <span><span style="color: red;border-top: 20px">*</span> 客户联系人</span>
				  </template>
                <el-row :gutter="15">
                  <el-button type="primary" style="margin-bottom: 15px" :disabled="method === 'view'" @click="insertEvent('contact')">
                    新增客户联系人
                  </el-button>
                </el-row>
				  <el-row  :gutter="15">
					  <el-form :disabled="method === 'view'" style="width: 100%;">
						  <vxe-table
							  border
							  show-overflow
							  show-footer
							  :column-config="{resizable: true}"
							  ref="contactTable"
							  :key="tableKeyContact"
							  class="vxe-table-element"
							  :data="inputForm.cwProjectClientContactDTOList"
							  style=""
							  highlight-current-row
							  :edit-rules="validContactRules"
							  :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: true, icon: '-'}"
						  >
							  <vxe-table-column min-width="110" align="center" field="name" title="姓名" :edit-render="{}" show-overflow="title">
								  <template #default="scope">
									  <el-input v-model="scope.row.name" placeholder="姓名" clearable></el-input>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column min-width="110" align="center" field="sex" title="性别" :edit-render="{name: '$select', options: $dictUtils.getDictList('sex')}">
								  <template #default="scope">
									  <vxe-select :disabled="method === 'view'" v-model="scope.row.sex" placeholder="性别" clearable style="width: 100%;" transfer>
										  <vxe-option
											  v-for="item in $dictUtils.getDictList('sex')"
											  :key="item.value"
											  :label="item.label"
											  :value="item.value">
										  </vxe-option>
									  </vxe-select>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column min-width="110" align="center" field="officeId" title="部门" :edit-render="{}" show-overflow="title">
								  <template #default="scope">
									  <el-input v-model="scope.row.officeId" placeholder="部门" clearable></el-input>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column min-width="111" align="center" field="position" title="职务" :edit-render="{}" show-overflow="title">
								  <template #default="scope">
									  <el-input v-model="scope.row.position" placeholder="职务" clearable></el-input>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column min-width="111" align="center" field="contactFirst" title="联系方式1" :edit-render="{}" show-overflow="title">
								  <template #default="scope">
									  <el-input v-model="scope.row.contactFirst" oninput="value=value.replace(/[^\d]/g,'')" placeholder="联系方式1" clearable></el-input>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column min-width="111" align="center" field="contactSecond" title="联系方式2" :edit-render="{}" show-overflow="title">
								  <template #default="scope">
									  <el-input v-model="scope.row.contactSecond" oninput="value=value.replace(/[^\d]/g,'')" placeholder="联系方式2" clearable></el-input>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column min-width="111" align="center" field="fax" title="传真" :edit-render="{}" show-overflow="title">
								  <template #default="scope">
									  <el-input v-model="scope.row.fax" placeholder="传真" clearable></el-input>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column min-width="111" align="center" field="email" title="邮箱" :edit-render="{}" show-overflow="title">
								  <template #default="scope">
									  <el-input v-model="scope.row.email" @change="$forceUpdate()" @blur="blurEmail(scope.$rowIndex)" placeholder="邮箱" clearable></el-input>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column min-width="111" align="center" field="remarks" title="备注" :edit-render="{}" show-overflow="title">
								  <template #default="scope">
									  <el-input maxlength="500" v-model="scope.row.remarks" placeholder="备注" clearable></el-input>
								  </template>
							  </vxe-table-column>
							  <vxe-table-column align="center" title="操作" width="100">
								  <template #default="scope">
									  <el-button type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'contact')">删除</el-button>
								  </template>
							  </vxe-table-column>
						  </vxe-table>
					  </el-form>
				  </el-row>
              </el-tab-pane>
              <el-tab-pane label="项目组成员" name="members">
                <el-row  :gutter="15">
                  <vxe-table
                    border
                    show-overflow
                    show-footer
                    :column-config="{resizable: true}"
                    ref="memberTable"
                    :key="tableKeyMembers"
                    class="vxe-table-element"
                    :data="inputForm.cwProjectMembersDTOList"
                    style=""
                    highlight-current-row
                  >
                    <vxe-table-column min-width="218" align="center" field="name" title="姓名" show-overflow="title"></vxe-table-column>
                    <vxe-table-column min-width="218" align="center" field="officeName" title="部门" show-overflow="title"></vxe-table-column>
                    <vxe-table-column min-width="218" align="center" field="roleName" title="角色" show-overflow="title"></vxe-table-column>
                    <vxe-table-column min-width="218" align="center" field="mobile" title="手机号" show-overflow="title"></vxe-table-column>
                    <vxe-table-column min-width="218" align="center" field="status" title="状态">
                      <template #default="scope">
                        <span v-if="scope.row.status === '0'" style="color: #67C23A">正常</span>
                        <span v-else>移除</span>
                      </template>
                    </vxe-table-column>
                  </vxe-table>
                </el-row>
              </el-tab-pane>
				<el-tab-pane name="construction">
					<template v-slot:label>
						<span> 施工方信息</span>
					</template>
					<el-row :gutter="15">
						<el-button style="margin-bottom: 15px" type="primary" :disabled="true" @click="openConstructionForm()"  plain>
							添加施工方信息联系人
						</el-button>
					</el-row>
					<el-row  :gutter="15">
						<el-form :disabled="true" style="width: 100%;">
							<vxe-table
								border
								show-overflow
								show-footer
								:column-config="{resizable: true}"
								ref="construction"
								:key="tableKeyConstruction"
								class="vxe-table-element"
								:data="inputForm.cwProjectConstructionList"
								keep-source
								style=""
								highlight-current-row
								:edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: true, icon: '-'}"
							>
								<vxe-table-column min-width="250" align="center"  field="name" title="施工方单位名称" :edit-render="{}">
									<template v-slot:edit="scope">
										<el-input v-model="scope.row.name" placeholder="施工方单位名称" clearable></el-input>
									</template>
								</vxe-table-column>
								<vxe-table-column min-width="250" align="center" field="clientName" title="联系人姓名" :edit-render="{}">
									<template v-slot:edit="scope">
										<el-input v-model="scope.row.clientName" placeholder="联系人姓名" clearable></el-input>
									</template>
								</vxe-table-column>
								<vxe-table-column min-width="250" align="center" field="contactFirst" title="联系方式1" :edit-render="{}">
									<template v-slot:edit="scope">
										<el-input v-model="scope.row.contactFirst" oninput="value=value.replace(/[^\d]/g,'')" placeholder="联系方式1" clearable></el-input>
									</template>
								</vxe-table-column>
								<vxe-table-column min-width="240" align="center" field="contactSecond" title="联系方式2" :edit-render="{}">
									<template v-slot:edit="scope">
										<el-input v-model="scope.row.contactSecond" oninput="value=value.replace(/[^\d]/g,'')" placeholder="联系方式2" clearable></el-input>
									</template>
								</vxe-table-column>
								<vxe-table-column align="center" title="操作" width="100">
									<template v-slot="scope">
										<el-button type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'construction')">删除</el-button>
									</template>
								</vxe-table-column>
							</vxe-table>
						</el-form>
					</el-row>
				</el-tab-pane>
              <el-tab-pane label="附件" name="files">
                <!--        附件-->
                <UpLoadComponent ref="uploadComponent"></UpLoadComponent>
              </el-tab-pane>

            </el-tabs>
          </el-tab-pane>
          <el-tab-pane label="关联报告" name="report">
            <el-form :inline="true" class="query-form" style="margin-bottom: 0;padding-top: 2px;padding-left: 0" ref="reportForm" :model="reportForm" @keyup.enter.native="searchReport()" @submit.native.prevent>
              <!-- 搜索框-->
              <el-form-item label="报告文号" prop="reportNo">
                <el-input v-model="reportForm.reportNo" placeholder="请输入报告文号" clearable></el-input>
              </el-form-item>
              <el-form-item label="项目名称" prop="projectName">
                <el-input v-model="reportForm.projectName" placeholder="请输入项目名称" clearable></el-input>
              </el-form-item>
              <el-form-item label="项目编号" prop="projectNumber">
                <el-input v-model="reportForm.projectNumber" placeholder="请输入项目编号" clearable></el-input>
              </el-form-item>

              <el-form-item>
                <el-button type="primary" @click="searchReport()" icon="el-icon-search">查询</el-button>
                <el-button @click="refreshReportForm()" icon="el-icon-refresh-right">重置</el-button>
              </el-form-item>
            </el-form>
            <vxe-table
              max-height="500"
              border="inner"
              auto-resize
              resizable
              height="auto"
              :loading="loading"
              ref="reportTable"
              show-header-overflow
              show-overflow
              highlight-hover-row
              :menu-config="{}"
              :sort-config="{remote:true}"
              :data="reportList"
              :checkbox-config="{}">
              <vxe-column type="seq" width="60" title="序号"></vxe-column>
              <vxe-column min-width="200" title="报告文号" align="center" field="reportNo" show-overflow="title">
                <template #default="scope">
                  <el-link  type="primary" :underline="false" @click="viewReport(scope.row.id)">{{scope.row.reportNo}}</el-link>
                </template>
              </vxe-column>
              <vxe-column min-width="200" title="项目名称" align="center" field="projectName" show-overflow="title">
                <template #default="scope">
                  <el-link  type="primary" :underline="false" @click="viewProject(scope.row.projectId)">{{scope.row.projectName}}</el-link>
                </template>
              </vxe-column>
              <vxe-column min-width="200" title="项目编号" align="center" field="projectNumber" show-overflow="title"></vxe-column>
              <vxe-column min-width="150" title="所属部门" align="center" field="officeName" show-overflow="title"></vxe-column>
              <vxe-column min-width="150" title="项目经理" align="center" field="projectMasterName" show-overflow="title"></vxe-column>
              <vxe-column min-width="120" title="报告创建人" align="center" field="createName" show-overflow="title"></vxe-column>
              <vxe-column min-width="180" title="报告创建时间" align="center" field="createDate" show-overflow="title"></vxe-column>
            </vxe-table>
          </el-tab-pane>
          <el-tab-pane label="关联发票" name="invoice">
            <el-form :inline="true" class="query-form" style="margin-bottom: 0;padding-top: 2px;padding-left: 0" ref="invoiceForm" :model="invoiceForm" @keyup.enter.native="searchInvoice()" @submit.native.prevent>
              <!-- 搜索框-->
              <el-form-item label="发票申请编号" prop="no">
                <el-input v-model="invoiceForm.no" placeholder="请输入发票申请编号" clearable></el-input>
              </el-form-item>

              <el-form-item>
                <el-button type="primary" @click="searchInvoice()"  icon="el-icon-search">查询</el-button>
                <el-button @click="refreshInvoiceForm()"  icon="el-icon-refresh-right">重置</el-button>
              </el-form-item>
            </el-form>
            <vxe-table
              max-height="500"
              border="inner"
              auto-resize
              resizable
              height="auto"
              :loading="loading"
              ref="invoiceTable"
              show-header-overflow
              show-overflow
              highlight-hover-row
              :menu-config="{}"
              :sort-config="{remote:true}"
              :data="invoiceList"
              :checkbox-config="{}">
              <vxe-column type="seq" width="60" title="序号"></vxe-column>
              <vxe-column min-width="150" title="发票申请编号" align="center" field="no" show-overflow="title">
                <template #default="scope">
                  <el-link  type="primary" :underline="false" @click="viewInvoice(false, scope.row.id)">{{scope.row.no}}</el-link>
                </template>
              </vxe-column>
              <vxe-column min-width="150" title="发票号" align="center" field="number" show-overflow="title"></vxe-column>
              <vxe-column min-width="150" title="实际开票单位" align="center" field="billingWorkplaceReal" show-overflow="title"></vxe-column>
              <vxe-column min-width="150" title="开票金额（元）" align="center" field="accountDetail" show-overflow="title"></vxe-column>
              <vxe-column min-width="120" title="开票内容" align="center" field="billingContent" show-overflow="title">
                <template #default="scope">
                  {{$dictUtils.getDictLabel('invoice_billing_content', scope.row.billingContent, '-')}}
                </template>
              </vxe-column>
              <vxe-column min-width="110" fixed="right" align="center" title="是否收款" field="receivablesStatus" show-overflow="title">
                <template #default="scope">
                  {{scope.row.receivablesStatus === '1'?'已收款':'未收款'}}
                </template>
              </vxe-column>
            </vxe-table>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
		<template #footer>
			<span class="dialog-footer">
			  <el-button  @click="close()" icon="el-icon-circle-close">关闭</el-button>
			  <el-button  v-if="method === 'edit'" type="primary" icon="el-icon-circle-check" @click="doSubmit('save')">确定</el-button>
			</span>
		</template>
      <WorkContractChooseCom ref="workContractChooseCom" @getContract="getContract"></WorkContractChooseCom>
      <WorkClientChooseForm ref="workClientChooseForm" @getWorkClientChoose="getWorkClientChoose"></WorkClientChooseForm>
      <CwProjectBusinessTypeListForm ref="cwProjectBusinessTypeListForm" @getBusinessType="getBusinessType"></CwProjectBusinessTypeListForm>
      <ContractNameForm ref="contractNameForm"></ContractNameForm>
      <InvoiceForm ref="invoiceFormDialog"></InvoiceForm>
      <ReportManagementForm ref="reportManagementForm"></ReportManagementForm>
      <ProjectRecordsForm ref="projectRecordsForm"></ProjectRecordsForm>
		<CwConstructionForm ref="cwConstructionForm" @getProgram2="getProgram2"></CwConstructionForm>
    </el-dialog>
  </div>
</template>

<script>
	import CwConstructionForm from './CwConstructionForm'
	import UserSelectSignatory from '@/components/userSelect'
  import UpLoadComponent from '@/views/common/UpLoadComponent'
  import SelectTree from '@/components/treeSelect/treeSelect.vue'
  import UserSelect from '@/components/userSelect'
  import UserSelectForQualification from '@/components/userSelectForQualification'
  import projectRecordsService from '@/api/cw/projectRecords/ProjectRecordsService'
  import projectReportService from '@/api/cw/reportManagement/ProjectReportService'
  import WorkClientChooseForm from '../workClientInfo/WorkClientChooseForm'
  import WorkContractChooseCom from './WorkContractChooseCom'
  import CwProjectBusinessTypeListForm from '@/views/cw/projectBusinessType/CwProjectBusinessTypeListForm'
  import ContractNameForm from '../workContract/ContractNameForm'
  import workClientService from '@/api/cw/workClientInfo/WorkClientService'
  import contractInfoService from '@/api/cw/workContract/contractInfoService'
  import cwFinanceInvoiceService from '@/api/cw/invoice/CwFinanceInvoiceService'
  import userService from '@/api/sys/UserService'
  export default {
    name: 'ProjectRecordsForm',
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      },
      status: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
		  engineeringTypeList: [],
        title: '',
        method: '',
        loading: false,
        inputForm: {
			engineeringType: '',
          id: '',
          createDate: '',
			projectStartTime: '',
			projectEndTime: '',
          createBy: {
            id: '',
            name: ''
          },
          remarks: '',
          projectNumber: '',
          projectName: '',
          officeId: '',
          projectMoney: '',
          auditYear: '',
          planStartDate: '',
          planEndDate: '',
          projectMasterId: '',
          projectLeaderId: '',
          procInsId: '',
          processDefinitionId: '',
          status: '',
          workAttachmentDtoList: [],
          cwProjectClientInfoDTOList: [],
			cwProjectConstructionList: [],
          contractName: '',
          contractAmount: '',
          contractNum: '',
          payerSubject: '',
          paymentMethod: '',
          contractId: '',
          businessType: '',
          riskLevel: '',
			projectLevel: '',
          businessTypeName: '',
          planDate: [],
          realHeader: '',
          clientContactsName: '',
          reportType: '',
          cwProjectClientContactDTOList: [],
          cwProjectMembersDTOList: []
        },
		  programRow: '',
		  programRow2: '',
        keyWatch: '',
        activeName: 'client',
        activeNameTop: 'project',
        tableKey: '',
        tableKeyClient: '1',
        tableKeyMembers: '3',
        visible: false,
        invoiceList: [],
        invoiceForm: {
          no: ''
        },
        reportForm: {
          reportNo: '',
          projectName: '',
          projectNumber: ''
        },
        reportList: [],
        tableKeyContact: '2',
		  tableKeyConstruction: '3',
        validContactRules: {
          name: [
            {required: true, message: '姓名不可以为空'}
          ],
          sex: [
            {required: true, message: '性别不可以为空'}
          ],
          officeId: [
            {required: true, message: '部门不可以为空'}
          ],
          position: [
            {required: true, message: '职务不可以为空'}
          ],
          contactFirst: [
            {required: true, message: '联系方式1不可以为空'}
          ]
        }
      }
    },
    created () {
    },
    computed: {
      bus: {
        get () {
          this.$refs.uploadComponent.setDividerName('附件', false)
          return this.businessId
        },
        set (val) {
          this.businessId = val
        }
      }
    },
    watch: {
      'keyWatch': {
        handler (newVal) {
          if (this.commonJS.isNotEmpty(this.bus)) {
            this.init('', this.bus)
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields()
            })
          }
        }
      }
    },
    components: {
		CwConstructionForm,
		UserSelectSignatory,
      UpLoadComponent,
      SelectTree,
      UserSelect,
		UserSelectForQualification,
      WorkClientChooseForm,
      WorkContractChooseCom,
      CwProjectBusinessTypeListForm,
      ContractNameForm,
      InvoiceForm: () => import('../invoice/InvoiceForm'),
      ReportManagementForm: () => import('../reportManagement/ReportManagementForm')
    },
    methods: {
      getKeyWatch (keyWatch) {
        this.keyWatch = keyWatch
      },
      forUpdate () {
        this.$forceUpdate()
      },
      init (method, id) {
        this.visible = true
        if (method === 'edit') {
          this.title = '项目信息修改'
          this.method = method
        } else {
          this.title = '项目详情'
          this.method = 'view'
        }
        this.activeName = 'client'
        this.activeNameTop = 'project'
        this.inputForm = {
			engineeringType: '',
          id: '',
          createDate: '',
			projectStartTime: '',
			projectEndTime: '',
          createBy: {
            id: '',
            name: this.$store.state.user.name
          },
          remarks: '',
          projectNumber: '',
          projectName: '',
          officeId: '',
          projectMoney: '',
          auditYear: '',
          planStartDate: '',
          planEndDate: '',
          projectMasterId: '',
          projectLeaderId: '',
          procInsId: '',
          processDefinitionId: '',
          status: '',
          workAttachmentDtoList: [],
          cwProjectClientInfoDTOList: [],
			cwProjectConstructionList: [],
          contractName: '',
          contractAmount: '',
          contractNum: '',
          payerSubject: '',
          paymentMethod: '',
          contractId: '',
          businessType: '',
          riskLevel: '',
			projectLevel: '',
          businessTypeName: '',
          planDate: [],
          realHeader: '',
          clientContactsName: '',
          cwProjectClientContactDTOList: [],
          cwProjectMembersDTOList: []
        }
		  this.engineeringTypeList = []
        this.inputForm.id = id
        this.loading = false
        this.$nextTick(() => {
          this.$refs.inputForm.resetFields()
          this.loading = true
          projectRecordsService.queryById(this.inputForm.id).then((data) => {
			  this.engineeringTypeList = data.engineeringTypeList
            this.$refs.uploadComponent.clearUpload()
            this.inputForm = this.recover(this.inputForm, data)
            this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
            if (this.commonJS.isEmpty(this.inputForm.workAttachmentDtoList)) {
              this.inputForm.workAttachmentDtoList = []
            }
            if (this.commonJS.isEmpty(this.inputForm.createDate)) {
              this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
            }
            if (this.commonJS.isEmpty(this.inputForm.createBy.name)) {
              this.inputForm.createBy.name = this.$store.state.user.name
            }
            if (this.commonJS.isEmpty(this.inputForm.cwProjectClientContactDTOList)) {
              this.inputForm.cwProjectClientContactDTOList = []
            }
            if (this.commonJS.isEmpty(this.inputForm.officeId)) {
              this.inputForm.officeId = this.$store.state.user.office.id
            }
            if (this.commonJS.isEmpty(this.inputForm.cwProjectMembersDTOList)) {
              this.inputForm.cwProjectMembersDTOList = []
            } else {
              this.inputForm.cwProjectMembersDTOList.forEach((member, index) => {
                userService.queryDetailById(member.userId).then((data) => {
                  member.name = this.commonJS.isEmpty(data.name) ? '' : data.name
                  member.mobile = this.commonJS.isEmpty(data.mobile) ? '' : data.mobile
                  member.officeName = this.commonJS.isEmpty(data.officeDTO) ? '' : this.commonJS.isEmpty(data.officeDTO.name) ? '' : data.officeDTO.name
                  member.roleName = this.commonJS.isEmpty(data.roleList) ? '' : data.roleList.map(role => { return this.commonJS.isEmpty(role.name) ? '' : role.name }).join(',')
                  this.tableKeyMembers = Math.random()
                })
              })
            }
            // if (this.formReadOnly) {
            //   this.method = 'view'
            // }
            this.$refs.uploadComponent.newUpload(this.method, this.inputForm.workAttachmentDtoList, 'cw_project_records', null, null, null, null, false)
            if (this.commonJS.isEmpty(this.inputForm.cwProjectClientInfoDTOList)) {
              this.inputForm.cwProjectClientInfoDTOList = []
            }
			  if (this.commonJS.isEmpty(this.inputForm.cwProjectConstructionList)) {
				  this.inputForm.cwProjectConstructionList = []
			  }
            if (this.commonJS.isEmpty(this.inputForm.projectMasterId) && this.method !== 'view') {
              this.inputForm.projectMasterId = this.$store.state.user.id
            }
            if (this.commonJS.isEmpty(this.inputForm.projectLeaderId) && this.method !== 'view') {
              this.inputForm.projectLeaderId = this.$store.state.user.id
            }
            if (this.commonJS.isEmpty(this.inputForm.projectMoney)) {
              this.inputForm.projectMoney = 0
            }
            // 获取关联发票信息
            cwFinanceInvoiceService.getByIds(this.inputForm.id, this.invoiceForm).then((data) => {
              let _this = this
              let _data = data
              const wait = function () {
                return new Promise((resolve, reject) => {
                  _this.invoiceList = _data
                  resolve()
                })
              }
              wait().then(() => {
                this.invoiceList.forEach(item => {
                  item.account = parseFloat(item.account).toFixed(2)
                  if (!this.commonJS.isEmpty(item.financeInvoiceDetailDTOList)) {
                    item.accountDetail = 0
                    let num = ''
                    item.financeInvoiceDetailDTOList.forEach((detail, index) => {
                      if (!this.commonJS.isEmpty(detail.account)) {
                        item.accountDetail = parseFloat(parseFloat(item.accountDetail) + parseFloat(detail.account)).toFixed(2)
                      }
                      if ((index + 1) !== item.financeInvoiceDetailDTOList.length) {
                        num = num + detail.number + ','
                      } else {
                        num = num + detail.number
                      }
                    })
                    item.number = num
                  } else {
                    item.number = ''
                    item.accountDetail = ''
                  }
                })
              })
            })
            // 获取关联报告信息
            projectReportService.getIdByProjectId(this.inputForm.id, this.reportForm).then((data) => {
              this.reportList = data
            })
            this.loading = false
          })
        })
      },
      saveForm (callback) {
        this.doSubmit('save', callback)
      },
      startForm (callback) {
        this.doSubmit('start', callback)
      },
      async agreeForm (callback) {
        await projectRecordsService.queryById(this.inputForm.id).then((data) => {
          if (data.status !== '2') { // 审核状态不是“待审核”，就弹出提示
            this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            throw new Error()
          } else {
            this.doSubmit('agree', callback)
          }
        })
      },
      // 表单提交
      doSubmit (status, callback) {
        if (status === 'save') {
          this.$refs['inputForm'].validate((valid) => {
            if (valid) {
              // 暂存
              // this.inputForm.status = '1'
              this.loading = true
              if (this.commonJS.isEmpty(this.inputForm.cwProjectClientContactDTOList)) {
                this.loading = false
                this.$message.error('“客户联系人”中至少填写一条信息')
                throw new Error('“客户联系人”中至少填写一条信息')
              }
              this.contactSubmit()
				if (this.commonJS.isNotEmpty(this.inputForm.planDate)) {
					this.inputForm.planStartDate = this.inputForm.planDate[0]
					this.inputForm.planEndDate = this.inputForm.planDate[1]
				}
              if (this.$refs.uploadComponent.checkProgress()) {
                this.loading = false
                return
              }
              this.inputForm.workAttachmentDtoList = this.$refs.uploadComponent.getDataList()
              // this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
              projectRecordsService.saveForm(this.inputForm).then((data) => {
                // callback(data.businessTable, data.businessId, this.inputForm)
                this.$emit('refreshList')
                this.close()
                this.loading = false
              }).catch(() => {
                this.loading = false
              })
            }
          })
        } else if (status === 'start') {
          // 送审  待审核
          this.inputForm.status = '2'
        } else if (status === 'agree') {
          // 审核同意
          this.inputForm.agreeDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
          this.inputForm.agreeUserId = this.$store.state.user.id
          this.inputForm.status = '5'
        }
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            if (this.$refs.uploadComponent.checkProgress()) {
              this.loading = false
              return
            }
            this.inputForm.workAttachmentDtoList = this.$refs.uploadComponent.getDataList()
            if (this.commonJS.isEmpty(this.inputForm.createDate)) {
              this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
            }
            projectRecordsService.saveForm(this.inputForm).then((data) => {
              callback(data.businessTable, data.businessId, this.inputForm)
              this.loading = false
            }).catch(() => {
              this.loading = false
            })
          }
        })
      },
      async updateStatusById (type) {
        if (type === 'reject' || type === 'reback') {
          if (await this.$refs.uploadComponent.checkProgress()) {
            this.loading = false
            throw new Error()
          }
          await projectRecordsService.queryById(this.inputForm.id).then((data) => {
            if (data.status !== '2') { // status的值不等于“审核中”就弹出提示
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error()
            } else {
              if (type === 'reject') {
                // 驳回
                this.inputForm.status = '4'
                let param = {status: '4', id: this.inputForm.id}
                projectRecordsService.updateStatusById(param)
              }
              if (type === 'reback') {
                // 撤回
                let param = {status: '3', id: this.inputForm.id}
                projectRecordsService.updateStatusById(param)
              }
            }
          })
        }
      },
      close () {
        this.inputForm = {
			engineeringType: '',
          id: '',
          createDate: '',
			projectStartTime: '',
			projectEndTime: '',
          createBy: {
            id: '',
            name: ''
          },
          remarks: '',
          projectNumber: '',
          projectName: '',
          officeId: '',
          projectMoney: '',
          auditYear: '',
          planStartDate: '',
          planEndDate: '',
          projectMasterId: '',
          projectLeaderId: '',
          procInsId: '',
          processDefinitionId: '',
          status: '',
          workAttachmentDtoList: [],
          cwProjectClientInfoDTOList: [],
			cwProjectConstructionList: [],
          contractName: '',
          contractAmount: '',
          contractNum: '',
          payerSubject: '',
          paymentMethod: '',
          contractId: '',
          businessType: '',
          riskLevel: '',
			projectLevel: '',
          businessTypeName: '',
          planDate: [],
          realHeader: '',
          clientContactsName: '',
          cwProjectClientContactDTOList: [],
          cwProjectMembersDTOList: []
        }
		  this.engineeringTypeList = []
        this.$refs.uploadComponent.clearUpload()
        this.$refs.inputForm.resetFields()
        this.$emit('refreshList')
        this.visible = false
      },
      tabHandleClick (event) {
        // console.log(event)
      },
      tabHandleClickTop (event) {
        // console.log(event)
      },
      // 新增
      // eslint-disable-next-line no-dupe-keys
      insertEvent (type) {
        if (type === 'client') {
          let d = {
            no: '',
            name: '',
            companyLevel: ''
          }
          if (this.commonJS.isEmpty(this.inputForm.cwProjectClientInfoDTOList)) {
            this.inputForm.cwProjectClientInfoDTOList = []
          }
          this.$refs.clientTable.insertAt(d)
          this.inputForm.cwProjectClientInfoDTOList.push(d)
          this.tableKeyClient = Math.random()
        }
        if (type === 'contact') {
          let d = {
            contactFirst: '',
            contactSecond: '',
            email: '',
            fax: '',
            name: '',
            officeId: '',
            position: '',
            remarks: '',
            sex: ''
          }
          if (this.commonJS.isEmpty(this.inputForm.cwProjectClientContactDTOList)) {
            this.inputForm.cwProjectClientContactDTOList = []
          }
          this.$refs.contactTable.insertAt(d)
          this.inputForm.cwProjectClientContactDTOList.push(d)
          this.tableKeyContact = Math.random()
        }
      },
      // 删除
      removeEvent (row, rowIndex, type) {
        if (type === 'client') {
          this.$refs.clientTable.remove(row)
          this.inputForm.cwProjectClientInfoDTOList.splice(rowIndex, 1)
        }
        if (type === 'contact') {
          this.$refs.contactTable.remove(row)
          this.inputForm.cwProjectClientContactDTOList.splice(rowIndex, 1)
        }
		  if (type === 'construction') {
			  this.$refs.construction.remove(row)
			  this.inputForm.cwProjectConstructionList.splice(rowIndex, 1)
		  }
      },
      openWorkClient () {
        this.$refs.workClientChooseForm.init()
      },
      getWorkClientChoose (list) {
        if (this.commonJS.isEmpty(this.inputForm.cwProjectClientInfoDTOList)) {
          this.inputForm.cwProjectClientInfoDTOList = []
        }
        let _this = this
        let _list = list
        const waitForEach = function () {
          return new Promise(function (resolve, reject) {
            _list.forEach((item) => {
              _this.inputForm.cwProjectClientInfoDTOList.forEach(client => {
                if (item.no === client.no) {
                  _this.$message.error('已存在客户 “' + client.name + '”，请重新选择')
                  throw new Error('已存在客户 “' + client.name + '”，请重新选择')
                }
              })
            })
            resolve()
          })
        }
        waitForEach().then(() => {
          list.forEach(item => {
            this.$refs.clientTable.insertAt(item)
            this.inputForm.cwProjectClientInfoDTOList.push(item)
            this.tableKeyClient = Math.random()
          })
        })
      },
      getContract (row) {
        // 首先删除之前合同与被服务单位的关联（委托方联系人）
        let _this = this
        const waitDelClient = function () {
          return new Promise((resolve, reject) => {
            if (_this.commonJS.isNotEmpty(_this.inputForm.contractId)) {
              // 根据合同id查询合同信息
              contractInfoService.findById(_this.inputForm.contractId).then((data) => {
                if (_this.commonJS.isNotEmpty(data.customerId)) {
                  // 根据合同的委托人联系人id查询客户信息
                  workClientService.queryById(data.customerId).then((client) => {
                    if (_this.commonJS.isNotEmpty(client.no)) {
                      // 将被服务单位中与合同委托人联系人相同删除
                      _this.inputForm.cwProjectClientInfoDTOList.forEach((item, index) => {
                        if (item.no === client.no) {
                          _this.$refs.clientTable.remove(item)
                          _this.inputForm.cwProjectClientInfoDTOList.splice(index, 1)
                        }
                      })
                    }
                  })
                }
              })
            }
            resolve()
          })
        }
        waitDelClient().then(() => {
          this.inputForm.contractName = row.contractName
          this.inputForm.contractAmount = row.contractAmount
          this.inputForm.contractNum = row.contractNum
          this.inputForm.payerSubject = row.payerSubject
          this.inputForm.paymentMethod = row.paymentMethod
          this.inputForm.contractId = row.id
          this.inputForm.clientContactsName = row.clientContactsName
          if (this.commonJS.isNotEmpty(row.clientContacts)) {
            if (this.commonJS.isEmpty(this.inputForm.cwProjectClientInfoDTOList)) {
              this.inputForm.cwProjectClientInfoDTOList = []
            }
            workClientService.queryById(row.clientContacts).then((data) => {
              if (this.commonJS.isNotEmpty(data.id)) {
                let _data = data
                const waitForEach = function () {
                  return new Promise(function (resolve, reject) {
                    _this.inputForm.cwProjectClientInfoDTOList.forEach(client => {
                      if (_data.no === client.no) {
                        // _this.$message.error('已存在客户 “' + client.name + '”')
                        throw new Error('已存在客户 “' + client.name + '”')
                      }
                    })
                    resolve()
                  })
                }
                waitForEach().then(() => {
                  this.$refs.clientTable.insertAt(data)
                  this.inputForm.cwProjectClientInfoDTOList.push(data)
                  this.tableKeyClient = Math.random()
                })
              }
            })
          }
        })
      },
      openContract () {
        this.$refs.workContractChooseCom.init()
      },
      getBusinessType (row) {
        this.inputForm.businessType = row.id
        this.inputForm.businessTypeName = row.name
      },
      openBusinessTypeForm () {
        this.$refs.cwProjectBusinessTypeListForm.init()
      },
      // 查看合同详情
      viewContract (id) {
        this.$refs.contractNameForm.init('view', id)
      },
      searchInvoice () {
        this.loading = true
        cwFinanceInvoiceService.getByIds(this.inputForm.id, this.invoiceForm).then((data) => {
          let _this = this
          let _data = data
          const wait = function () {
            return new Promise((resolve, reject) => {
              _this.invoiceList = _data
              resolve()
            })
          }
          wait().then(() => {
            this.invoiceList.forEach(item => {
              item.account = parseFloat(item.account).toFixed(2)
              if (!this.commonJS.isEmpty(item.financeInvoiceDetailDTOList)) {
                item.accountDetail = 0
                let num = ''
                item.financeInvoiceDetailDTOList.forEach((detail, index) => {
                  if (!this.commonJS.isEmpty(detail.account)) {
                    item.accountDetail = parseFloat(parseFloat(item.accountDetail) + parseFloat(detail.account)).toFixed(2)
                  }
                  if ((index + 1) !== item.financeInvoiceDetailDTOList.length) {
                    num = num + detail.number + ','
                  } else {
                    num = num + detail.number
                  }
                })
                item.number = num
              } else {
                item.number = ''
                item.accountDetail = ''
              }
            })
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      },
      refreshInvoiceForm () {
        this.$refs.invoiceForm.resetFields()
        this.searchInvoice()
      },
      viewInvoice (flag, id) {
        this.$refs.invoiceFormDialog.init(flag, id)
      },
      searchReport () {
        this.loading = true
        projectReportService.getIdByProjectId(this.inputForm.id, this.reportForm).then((data) => {
          this.reportList = data
          this.loading = false
        })
      },
      refreshReportForm () {
        this.$refs.reportForm.resetFields()
        this.searchReport()
      },
      viewReport (id) {
        this.$refs.reportManagementForm.init('view', id)
      },
      viewProject (id) {
        this.$refs.projectRecordsForm.init('view', id)
      },
      blurEmail (index) {
        if (this.commonJS.isNotEmpty(this.inputForm.cwProjectClientContactDTOList[index].email)) {
          if (!this.validateXG.isEmail(this.inputForm.cwProjectClientContactDTOList[index].email)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“邮箱”填写错误，请重新填写')
            this.inputForm.cwProjectClientContactDTOList[index].email = ''
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“邮箱”填写错误，请重新填写')
          }
        }
      },
      contactSubmit () {
        this.inputForm.cwProjectClientContactDTOList.forEach((item, index) => {
          if (this.commonJS.isNotEmpty(item.email)) {
            if (!this.validateXG.isEmail(item.email)) {
              this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“邮箱”填写错误')
              this.loading = false
              throw new Error('客户联系人中，第' + (index + 1) + '条数据的“邮箱”填写错误')
            }
          }
          if (this.commonJS.isEmpty(item.name)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“姓名”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“姓名”未填写')
          }
          if (this.commonJS.isEmpty(item.sex)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“性别”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“性别”未填写')
          }
          if (this.commonJS.isEmpty(item.officeId)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“部门”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“部门”未填写')
          }
          if (this.commonJS.isEmpty(item.position)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“职务”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“职务”未填写')
          }
          if (this.commonJS.isEmpty(item.contactFirst)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“联系方式1”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“联系方式1”未填写')
          }
        })
      },
		openConstructionForm () {
			this.$refs.cwConstructionForm.init()
			if (this.inputForm.cwProjectConstructionList.length > 0) {
				this.programRow2 = this.inputForm.cwProjectConstructionList.length
			} else {
				this.programRow2 = this.inputForm.cwProjectConstructionList.length
			}
		},
		getProgram2 (rows) {
			console.log('rows', rows)
			rows.forEach((item, index) => {
				if (index === 0) {
					let d = {
						name: '',
						clientName: '',
						contactFirst: '',
						contactSecond: '',
						clientId: ''
					}
					this.$refs.construction.insertAt(d)
					this.inputForm.cwProjectConstructionList.push(d)
					this.tableKeyConstruction = Math.random()

					let r = this.inputForm.cwProjectConstructionList[this.programRow2]
					r.name = item.name
					r.clientName = item.clientName
					r.contactFirst = item.contactFirst
					r.contactSecond = item.contactSecond
					r.clientId = item.clientId
					this.inputForm.cwProjectConstructionList[this.programRow2] = r
				} else {
					let r = {
						name: item.name,
						clientName: item.clientName,
						contactFirst: item.contactFirst,
						contactSecond: item.contactSecond,
						clientId: item.clientId
					}
					this.inputForm.cwProjectConstructionList.push(r)
					this.tableKeyConstruction = Math.random()
				}
			})
			this.$forceUpdate()
			this.programRow2 = ''
		},
    }
  }
</script>
<style scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
