<template>
  <BasicPopup
    v-bind="$attrs"
    @register="registerPopup"
    destroyOnClose
    :showOkBtn="false"
    :showCancelBtn="false"
    :cancelText="t('common.cancelText', '取消')"
    :okText="t('common.okText', '确定')"
    @ok="handleSubmit"
    :closeFunc="onClose">
    <!-- <template #title>
      <a-space :size="10">
        <div class="text-16px font-medium">{{ title }}</div>
        <a-space-compact size="small" block v-if="dataForm.id">
          <a-tooltip :title="t('common.prevRecord')">
            <a-button size="small" :disabled="getPrevDisabled" @click="handlePrev">
              <i class="icon-ym icon-ym-caret-left text-10px"></i>
            </a-button>
          </a-tooltip>
          <a-tooltip :title="t('common.nextRecord')">
            <a-button size="small" :disabled="getNextDisabled" @click="handleNext">
              <i class="icon-ym icon-ym-caret-right text-10px"></i>
            </a-button>
          </a-tooltip>
        </a-space-compact>
      </a-space>
    </template>
    <template #insertToolbar>
      <yunzhupaasCheckboxSingle v-model:value="submitType" :label="continueText" v-if="showContinueBtn" />
    </template> -->
    <a-row class="p-10px dynamic-form" :style="{ margin: '0 auto', width: '100%' }">
      <a-form
        :colon="false"
        size="middle"
        layout="horizontal"
        labelAlign="right"
        :labelCol="{ style: { width: '100px' } }"
        :model="dataForm"
        :rules="dataRule"
        ref="formRef">
        <a-row :gutter="15">
          <!-- 具体表单 -->
          <a-col :span="24" class="ant-col-item">
            <a-steps type="default" status="process" :current="state.activestepsformItem0864d8" class="mb-10px" @change="changeStage">
              <a-step title="基本信息" key="1"> </a-step>
              <a-step title="合同清单" key="2"> </a-step>
              <a-step title="付款计划" key="3"> </a-step>
              <a-step title="确认提交" key="4"> </a-step>
            </a-steps>
            <a-row key="1" class="!pt-12px w-full" v-show="0 == state.activestepsformItem0864d8" :gutter="15">
              <a-col :span="24" class="ant-col-item">
                <a-form-item>
                  <YunzhupaasButton align="right" buttonText="下一步" type="primary" @click="nextBut()"> </YunzhupaasButton>
                </a-form-item>
              </a-col>
              <a-col :span="24" class="ant-col-item">
                <a-card class="mb-20">
                  <a-row :gutter="15">
                    <a-col :span="16" class="ant-col-item">
                      <a-form-item name="contract_name">
                        <template #label>合同名称 </template>
                        <YunzhupaasInput
                          v-model:value="dataForm.contract_name"
                          @change="changeData('contract_name', -1)"
                          placeholder="请输入合同名称"
                          :maxlength="30"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :maskConfig="maskConfig.contract_name"
                          :showCount="false">
                        </YunzhupaasInput>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8" class="ant-col-item">
                      <a-form-item name="contract_code">
                        <template #label>合同编号 </template>
                        <YunzhupaasInput
                          v-model:value="dataForm.contract_code"
                          @change="changeData('contract_code', -1)"
                          placeholder="请输入合同编号"
                          :disabled="true"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :maskConfig="maskConfig.contract_code"
                          :showCount="false">
                        </YunzhupaasInput>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="project_id">
                        <template #label>归属项目 </template>
                        <YunzhupaasSelect
                          v-model:value="dataForm.project_id"
                          @change="changeData('project_id', -1)"
                          placeholder="请选择归属项目"
                          :templateJson="state.interfaceRes.project_id"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :showSearch="false"
                          :options="optionsObj.project_idOptions"
                          :fieldNames="optionsObj.project_idProps">
                        </YunzhupaasSelect>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="contract_type_code">
                        <template #label>合同类型 </template>
                        <YunzhupaasSelect
                          v-model:value="dataForm.contract_type_code"
                          @change="changeData('contract_type_code', -1)"
                          placeholder="请选择合同类型"
                          :templateJson="state.interfaceRes.contract_type_code"
                          :allowClear="true"
                           @update:modelLabel="getcontract_type_codeOptions"
                          :style="{ width: '100%' }"
                          :showSearch="false"
                          :options="optionsObj.contract_type_codeOptions"
                          :fieldNames="optionsObj.contract_type_codeProps">
                        </YunzhupaasSelect>
                      </a-form-item>
                    </a-col>

                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="contract_date">
                        <template #label>签约日期 </template>
                        <YunzhupaasDatePicker
                          v-model:value="dataForm.contract_date"
                          @change="changeData('contract_date', -1)"
                          placeholder="请选择签约日期"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          format="yyyy-MM-dd"
                          :startTime="getRelationDate(false, 1, 1, '', '')"
                          :endTime="getRelationDate(false, 1, 1, '', '')">
                        </YunzhupaasDatePicker>
                      </a-form-item>
                    </a-col>

                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="valid_to">
                        <template #label>合同有效期 </template>
                        <YunzhupaasDatePicker
                          v-model:value="dataForm.valid_to"
                          @change="changeData('valid_to', -1)"
                          placeholder="请选择合同有效期"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          format="yyyy-MM-dd"
                          :startTime="getRelationDate(false, 1, 1, '', '')"
                          :endTime="getRelationDate(false, 1, 1, '', '')">
                        </YunzhupaasDatePicker>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8" class="ant-col-item">
                      <a-form-item name="second_party">
                        <template #label>对方单位 </template>
                        <YunzhupaasRelationFormByUrl
                          ref="relationRef"
                          v-model:value="dataForm.second_party"
                          v-model:modelLabel="dataForm.dfdwxx"
                          @change="changeData('second_party', -1)"
                          placeholder="请选择对方单位"
                          :templateJson="state.interfaceRes.second_party"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :showSearch="false"
                          :field="'second_party'"
                          modelId="/api/bcm/MdmCompany/getList"
                          :columnOptions="optionsObj.second_partycolumnOptions"
                          relationField="company_name"
                          popupWidth="1000px"
                          propsValue="company_id"
                          :valueMap="{ company_scope_yunzhupaasId: 'EXT' }"
                          :queryType="0">
                        </YunzhupaasRelationFormByUrl>
                      </a-form-item>
                    </a-col>
                    <a-col :span="4" class="ant-col-item">
                      <a-form-item :labelCol="{ style: { width: '0px' } }" name="second_party_type">
                        <YunzhupaasSelect
                          v-model:value="dataForm.second_party_type"
                          @change="changeData('second_party_type', -1)"
                          :templateJson="state.interfaceRes.second_party_type"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :showSearch="false"
                          :options="optionsObj.second_party_typeOptions"
                          :fieldNames="optionsObj.second_party_typeProps">
                        </YunzhupaasSelect>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8" class="ant-col-item">
                      <a-form-item name="first_party">
                        <template #label>我方单位 </template>
                        <YunzhupaasRelationFormByUrl
                          v-model:value="dataForm.first_party"
                          @change="changeData('first_party', -1)"
                          placeholder="请选择我方单位"
                          :templateJson="state.interfaceRes.first_party"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :showSearch="false"
                          :field="'first_party'"
                          modelId="/api/bcm/MdmCompany/getList"
                          :columnOptions="optionsObj.first_partycolumnOptions"
                          relationField="company_name"
                          popupWidth="1000px"
                          propsValue="company_id"
                          :valueMap="{ company_scope_yunzhupaasId: 'INT' }"
                          :queryType="0">
                        </YunzhupaasRelationFormByUrl>
                      </a-form-item>
                    </a-col>
                    <a-col :span="4" class="ant-col-item">
                      <a-form-item :labelCol="{ style: { width: '0px' } }" name="first_party_type">
                        <YunzhupaasSelect
                          v-model:value="dataForm.first_party_type"
                          @change="changeData('first_party_type', -1)"
                          :templateJson="state.interfaceRes.first_party_type"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :showSearch="false"
                          :options="optionsObj.first_party_typeOptions"
                          :fieldNames="optionsObj.first_party_typeProps">
                        </YunzhupaasSelect>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="second_party_address">
                        <template #label>通讯地址 </template>
                        <YunzhupaasInput
                          v-model:value="dataForm.second_party_address"
                          @change="changeData('second_party_address', -1)"
                          placeholder="请输入对方单位地址"
                          :maxlength="100"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :maskConfig="maskConfig.second_party_address"
                          :showCount="false">
                        </YunzhupaasInput>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="first_party_address">
                        <template #label>通讯地址 </template>
                        <YunzhupaasInput
                          v-model:value="dataForm.first_party_address"
                          @change="changeData('first_party_address', -1)"
                          placeholder="请输入我方单位地址"
                          :maxlength="100"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :maskConfig="maskConfig.first_party_address"
                          :showCount="false">
                        </YunzhupaasInput>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="second_party_person">
                        <template #label>负责人 </template>
                        <YunzhupaasInput
                          v-model:value="dataForm.second_party_person"
                          @change="changeData('second_party_person', -1)"
                          placeholder="请输入对方负责人"
                          :maxlength="100"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :maskConfig="maskConfig.second_party_person"
                          :showCount="false">
                        </YunzhupaasInput>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="first_party_person">
                        <template #label>负责人 </template>
                        <YunzhupaasInput
                          v-model:value="dataForm.first_party_person"
                          @change="changeData('first_party_person', -1)"
                          placeholder="请输入我方负责人"
                          :maxlength="100"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :maskConfig="maskConfig.first_party_person"
                          :showCount="false">
                        </YunzhupaasInput>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="second_party_tel">
                        <template #label>联系方式 </template>
                        <YunzhupaasInput
                          v-model:value="dataForm.second_party_tel"
                          @change="changeData('second_party_tel', -1)"
                          placeholder="请输入对方联系方式"
                          :maxlength="100"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :maskConfig="maskConfig.second_party_tel"
                          :showCount="false">
                        </YunzhupaasInput>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="first_party_tel">
                        <template #label>联系方式 </template>
                        <YunzhupaasInput
                          v-model:value="dataForm.first_party_tel"
                          @change="changeData('first_party_tel', -1)"
                          placeholder="请输入我方联系方式"
                          :maxlength="100"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :maskConfig="maskConfig.first_party_tel"
                          :showCount="false">
                        </YunzhupaasInput>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24" class="ant-col-item">
                      <a-form-item name="contract_terms">
                        <template #label>合同条款 </template>
                        <YunzhupaasTextarea
                          v-model:value="dataForm.contract_terms"
                          @change="changeData('contract_terms', -1)"
                          placeholder="请输入"
                          :maxlength="255"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :autoSize="{ minRows: 4, maxRows: 4 }"
                          :showCount="false">
                        </YunzhupaasTextarea>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24" class="ant-col-item">
                      <a-form-item name="remark">
                        <template #label>说明 </template>
                        <YunzhupaasTextarea
                          v-model:value="dataForm.remark"
                          @change="changeData('remark', -1)"
                          placeholder="请输入"
                          :maxlength="200"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          :autoSize="{ minRows: 2, maxRows: 2 }"
                          :showCount="false">
                        </YunzhupaasTextarea>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="operator_id">
                        <template #label>经办人 </template>
                        <YunzhupaasUserSelect
                          v-model:value="dataForm.operator_id"
                          @change="changeData('operator_id', -1)"
                          placeholder="请选择经办人"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          selectType="all">
                        </YunzhupaasUserSelect>
                      </a-form-item>
                    </a-col>

                    <a-col :span="12" class="ant-col-item">
                      <a-form-item name="operator_date">
                        <template #label>经办日期 </template>
                        <YunzhupaasDatePicker
                          v-model:value="dataForm.operator_date"
                          @change="changeData('operator_date', -1)"
                          placeholder="请选择合同有效期"
                          :allowClear="true"
                          :style="{ width: '100%' }"
                          format="yyyy-MM-dd"
                          :startTime="getRelationDate(false, 1, 1, '', '')"
                          :endTime="getRelationDate(false, 1, 1, '', '')">
                        </YunzhupaasDatePicker>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24" class="ant-col-item">
                      <a-form-item name="pcmDocument">
                        <template #label>附件 <BasicHelp text="默认选择完文件自动提交" /></template>
                        <YunzhupaasUploadFile
                          v-model:value="dataForm.pcmDocument"
                          @change="changeData('pcmDocument', -1)"
                          :fileSize="10"
                          sizeUnit="MB"
                          :limit="9"
                          pathType="defaultPath"
                          timeFormat="YYYY"
                          buttonText="选取文件">
                        </YunzhupaasUploadFile>
                      </a-form-item>
                    </a-col>
                  </a-row>
                </a-card>
              </a-col>
            </a-row>
            <a-row key="2" class="!pt-12px w-full" v-show="1 == state.activestepsformItem0864d8" :gutter="15">
              <a-col :span="24" class="ant-col-item">
                <a-form-item>
                  <YunzhupaasButton align="right" buttonText="下一步" type="primary" @click="nextBut()"> </YunzhupaasButton>
                </a-form-item>
              </a-col>
              <a-col :span="24" class="ant-col-item">
                <a-card class="mb-20">
                  <a-row :gutter="15">
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item>
                        <YunzhupaasText
                          :textStyle="{
                            color: '#000000',
                            'font-weight': 'normal',
                            'text-decoration': 'none',
                            'font-size': 15,
                            'line-height': 15,
                            'font-style': 'normal',
                            'text-align': 'left',
                          }"
                          :content="`合同名称：${dataForm.contract_name || ''}`">
                        </YunzhupaasText>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item>
                        <YunzhupaasText
                          :textStyle="{
                            color: '#000000',
                            'font-weight': 'normal',
                            'text-decoration': 'none',
                            'font-size': 15,
                            'line-height': 15,
                            'font-style': 'normal',
                            'text-align': 'left',
                          }"
                          :content="`合同编码：${dataForm.contract_code || ''}`">
                        </YunzhupaasText>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item>
                        <YunzhupaasText
                          :textStyle="{
                            color: '#000000',
                            'font-weight': 'normal',
                            'text-decoration': 'none',
                            'font-size': 15,
                            'line-height': 15,
                            'font-style': 'normal',
                            'text-align': 'left',
                          }"
                          :content="`对方单位：${dataForm.dfdwxx?.company_name || ''}`">
                        </YunzhupaasText>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item>
                        <YunzhupaasText
                          :textStyle="{
                            color: '#000000',
                            'font-weight': 'normal',
                            'text-decoration': 'none',
                            'font-size': 15,
                            'line-height': 15,
                            'font-style': 'normal',
                            'text-align': 'left',
                          }"
                          :content="`签约金额：${dataForm.contract_money || '0'}`">
                        </YunzhupaasText>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24" class="ant-col-item mb-20px" v-if="dataForm.htlxxx?.rg_list_enabled == '1'">
                      <a-form-item>
                        <yunzhupaasGroupTitle content="劳务清单" :bordered="false" helpMessage="" />
                        <a-table
                          :data-source="dataForm.pcm_contract_itemList"
                          :columns="pcm_contract_itemColumns"
                          size="small"
                          :pagination="false"
                          :scroll="{ x: 'max-content' }"
                          :rowSelection="getpcm_contract_itemRowSelection"
                          rowKey="yunzhupaasId">
                          <template #headerCell="{ column }">
                            <span class="required-sign" v-if="column.required">*</span>
                            {{ column.title }}
                            <BasicHelp :text="column.tipLabel" v-if="column.tipLabel && column.title" />
                          </template>
                          <template #bodyCell="{ column, index, record }">
                            <template v-if="column.key === 'index'">{{ index + 1 }}</template>
                            <template v-if="column.key === 'resources_name'">
                              <YunzhupaasSelect
                                v-model:value="record.resources_name"
                                @change="changeData('pcm_contract_itemresources_name', index)"
                                placeholder="请选择"
                                :templateJson="state.interfaceRes.pcm_contract_itemresources_name"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :showSearch="false"
                                :options="optionsObj.pcm_contract_itemresources_nameOptions"
                                :fieldNames="optionsObj.pcm_contract_itemresources_nameProps">
                              </YunzhupaasSelect>
                            </template>
                            <template v-if="column.key === 'resources_unit'">
                              <YunzhupaasInput
                                v-model:value="record.resources_unit"
                                @change="changeData('pcm_contract_itemresources_unit', index)"
                                placeholder="请输入单位"
                                :maxlength="10"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :maskConfig="maskConfig.pcm_contract_itemresources_unit"
                                :showCount="false">
                              </YunzhupaasInput>
                            </template>
                            <template v-if="column.key === 'resources_price'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_price"
                                @change="changeData('pcm_contract_itemresources_price', index)"
                                placeholder="请输入单价"
                                :style="{ width: '100%' }"
                                :step="1"
                                :precision="2"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'resources_quantity'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_quantity"
                                @change="changeData('pcm_contract_itemresources_quantity', index)"
                                placeholder="请输入工时"
                                :style="{ width: '100%' }"
                                :step="1"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'resources_money'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_money"
                                @change="changeData('pcm_contract_itemresources_money', index)"
                                placeholder="小计"
                                :style="{ width: '100%' }"
                                :disabled="true"
                                :step="1"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'action'">
                              <a-space>
                                <a-button class="action-btn" type="link" @click="copyPcm_contract_itemRow(index)" size="small">
                                  {{ t('common.copyText', '复制') }}
                                </a-button>
                                <a-button class="action-btn" type="link" color="error" @click="removePcm_contract_itemRow(index, true)" size="small">
                                  {{ t('common.delText', '删除') }}
                                </a-button>
                              </a-space>
                            </template>
                          </template>
                        </a-table>
                        <a-space class="input-table-footer-btn">
                          <a-button type="primary" preIcon="icon-ym icon-ym-btn-add" @click="addPcm_contract_itemRow">
                            {{ t('common.add1Text', '添加') }}
                          </a-button>
                          <!-- <a-button type="danger" preIcon="icon-ym icon-ym-btn-clearn" @click="batchRemovePcm_contract_itemRow(true)">
                            {{ t('common.batchDelText', '批量删除') }}
                          </a-button> -->
                        </a-space>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24" class="ant-col-item mb-20px" v-if="dataForm.htlxxx?.cl_list_enabled == '1'">
                      <a-form-item>
                        <yunzhupaasGroupTitle content="采购清单" :bordered="false" helpMessage=""  />
                        <a-table
                          :data-source="dataForm.cg_pcm_contract_itemList"
                          :columns="cg_pcm_contract_itemColumns"
                          size="small"
                          :pagination="false"
                          :scroll="{ x: 'max-content' }"
                          :rowSelection="getpcm_contract_itemRowSelection"
                          rowKey="yunzhupaasId">
                          <template #headerCell="{ column }">
                            <span class="required-sign" v-if="column.required">*</span>
                            {{ column.title }}
                            <BasicHelp :text="column.tipLabel" v-if="column.tipLabel && column.title" />
                          </template>
                          <template #bodyCell="{ column, index, record }">
                            <template v-if="column.key === 'index'">{{ index + 1 }}</template>
                            <template v-if="column.key === 'resources_name'">
                              <YunzhupaasTreeSelect
                                v-model:value="record.resources_name"
                                @change="changeData('pcm_contract_itemresources_name', index)"
                                placeholder="请选择"
                                :templateJson="state.interfaceRes.pcm_contract_itemresources_name"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :showSearch="false"
                                :options="optionsObj.cl_pcm_contract_itemresources_nameOptions"
                                :fieldNames="optionsObj.pcm_contract_itemresources_nameProps">
                              </YunzhupaasTreeSelect>
                              <!-- <YunzhupaasSelect
                                v-model:value="record.resources_name"
                                @change="changeData('pcm_contract_itemresources_name', index)"
                                placeholder="请选择"
                                :templateJson="state.interfaceRes.pcm_contract_itemresources_name"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :showSearch="false"
                                :options="optionsObj.cl_pcm_contract_itemresources_nameOptions"
                                :fieldNames="optionsObj.pcm_contract_itemresources_nameProps">
                              </YunzhupaasSelect> -->
                            </template>
                            <template v-if="column.key === 'resources_unit'">
                              <YunzhupaasInput
                                v-model:value="record.resources_unit"
                                @change="changeData('pcm_contract_itemresources_unit', index)"
                                placeholder="请输入单位"
                                :maxlength="10"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :maskConfig="maskConfig.pcm_contract_itemresources_unit"
                                :showCount="false">
                              </YunzhupaasInput>
                            </template>
                            <template v-if="column.key === 'resources_price'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_price"
                                @change="changeData('cg_pcm_contract_itemresources_price', index)"
                                placeholder="请输入单价"
                                :style="{ width: '100%' }"
                                :step="1"
                                :precision="2"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'resources_quantity'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_quantity"
                                @change="changeData('cg_pcm_contract_itemresources_quantity', index)"
                                placeholder="请输入工时"
                                :style="{ width: '100%' }"
                                :step="1"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'resources_money'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_money"
                                @change="changeData('pcm_contract_itemresources_money', index)"
                                placeholder="小计"
                                :style="{ width: '100%' }"
                                :disabled="true"
                                :step="1"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'action'">
                              <a-space>
                                <a-button class="action-btn" type="link" @click="copyCgPcm_contract_itemRow(index)" size="small">
                                  {{ t('common.copyText', '复制') }}
                                </a-button>
                                <a-button class="action-btn" type="link" color="error" @click="removeCgPcm_contract_itemRow(index, true)" size="small">
                                  {{ t('common.delText', '删除') }}
                                </a-button>
                              </a-space>
                            </template>
                          </template>
                        </a-table>
                        <a-space class="input-table-footer-btn">
                          <a-button type="primary" preIcon="icon-ym icon-ym-btn-add" @click="cg_addPcm_contract_itemRow">
                            {{ t('common.add1Text', '添加') }}
                          </a-button>
                          <!-- <a-button type="danger" preIcon="icon-ym icon-ym-btn-clearn" @click="batchRemovePcm_contract_itemRow(true)">
                            {{ t('common.batchDelText', '批量删除') }}
                          </a-button> -->
                        </a-space>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24" class="ant-col-item mb-20px"  v-if="dataForm.htlxxx?.zl_list_enabled == '1'" >
                      <a-form-item>
                        <yunzhupaasGroupTitle content="租赁清单" :bordered="false" helpMessage=""/>
                        <a-table
                          :data-source="dataForm.zd_pcm_contract_itemList"
                          :columns="zd_pcm_contract_itemColumns"
                          size="small"
                          :pagination="false"
                          :scroll="{ x: 'max-content' }"
                          :rowSelection="getpcm_contract_itemRowSelection"
                          rowKey="yunzhupaasId">
                          <template #headerCell="{ column }">
                            <span class="required-sign" v-if="column.required">*</span>
                            {{ column.title }}
                            <BasicHelp :text="column.tipLabel" v-if="column.tipLabel && column.title" />
                          </template>
                          <template #bodyCell="{ column, index, record }">
                            <template v-if="column.key === 'index'">{{ index + 1 }}</template>
                            <template v-if="column.key === 'resources_name'">
                              <!-- <YunzhupaasSelect
                                v-model:value="record.resources_name"
                                @change="changeData('pcm_contract_itemresources_name', index)"
                                placeholder="请选择"
                                :templateJson="state.interfaceRes.pcm_contract_itemresources_name"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :showSearch="false"
                                :options="optionsObj.cl_pcm_contract_itemresources_nameOptions"
                                :fieldNames="optionsObj.pcm_contract_itemresources_nameProps">
                              </YunzhupaasSelect> -->
                              <YunzhupaasTreeSelect
                                v-model:value="record.resources_name"
                                @change="changeData('pcm_contract_itemresources_name', index)"
                                placeholder="请选择"
                                :templateJson="state.interfaceRes.pcm_contract_itemresources_name"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :showSearch="false"
                                :options="optionsObj.cl_pcm_contract_itemresources_nameOptions"
                                :fieldNames="optionsObj.pcm_contract_itemresources_nameProps">
                              </YunzhupaasTreeSelect>
                            </template>
                            <template v-if="column.key === 'resources_unit'">
                              <YunzhupaasInput
                                v-model:value="record.resources_unit"
                                @change="changeData('pcm_contract_itemresources_unit', index)"
                                placeholder="请输入单位"
                                :maxlength="10"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :maskConfig="maskConfig.pcm_contract_itemresources_unit"
                                :showCount="false">
                              </YunzhupaasInput>
                            </template>
                            <template v-if="column.key === 'resources_price'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_price"
                                @change="changeData('zd_pcm_contract_itemresources_price', index)"
                                placeholder="请输入单价"
                                :style="{ width: '100%' }"
                                :step="1"
                                :precision="2"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'resources_quantity'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_quantity"
                                @change="changeData('zd_pcm_contract_itemresources_quantity', index)"
                                placeholder="请输入工时"
                                :style="{ width: '100%' }"
                                :step="1"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'resources_money'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_money"
                                @change="changeData('pcm_contract_itemresources_money', index)"
                                placeholder="小计"
                                :style="{ width: '100%' }"
                                :disabled="true"
                                :step="1"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'action'">
                              <a-space>
                                <a-button class="action-btn" type="link" @click="copyZdPcm_contract_itemRow(index)" size="small">
                                  {{ t('common.copyText', '复制') }}
                                </a-button>
                                <a-button class="action-btn" type="link" color="error" @click="removeZdPcm_contract_itemRow(index, true)" size="small">
                                  {{ t('common.delText', '删除') }}
                                </a-button>
                              </a-space>
                            </template>
                          </template>
                        </a-table>
                        <a-space class="input-table-footer-btn">
                          <a-button type="primary" preIcon="icon-ym icon-ym-btn-add" @click="zd_addPcm_contract_itemRow">
                            {{ t('common.add1Text', '添加') }}
                          </a-button>
                          <!-- <a-button type="danger" preIcon="icon-ym icon-ym-btn-clearn" @click="batchRemovePcm_contract_itemRow(true)">
                            {{ t('common.batchDelText', '批量删除') }}
                          </a-button> -->
                        </a-space>
                      </a-form-item>
                    </a-col>
                    <a-col :span="24" class="ant-col-item mb-20px" v-if="dataForm.htlxxx?.gcl_list_enabled == '1'">
                      <a-form-item>
                        <yunzhupaasGroupTitle content="工程量清单" :bordered="false" helpMessage=""  />
                        <a-table
                          :data-source="dataForm.gcl_pcm_contract_itemList"
                          :columns="gcl_pcm_contract_itemColumns"
                          size="small"
                          :pagination="false"
                          :scroll="{ x: 'max-content' }"
                          :rowSelection="getpcm_contract_itemRowSelection"
                          rowKey="yunzhupaasId">
                          <template #headerCell="{ column }">
                            <span class="required-sign" v-if="column.required">*</span>
                            {{ column.title }}
                            <BasicHelp :text="column.tipLabel" v-if="column.tipLabel && column.title" />
                          </template>
                          <template #bodyCell="{ column, index, record }">
                            <template v-if="column.key === 'index'">{{ index + 1 }}</template>
                            <template v-if="column.key === 'resources_name'">
                              <YunzhupaasInput
                                v-model:value="record.resources_name"
                                @change="changeData('pcm_contract_itemresources_name', index)"
                                placeholder="请输入施工内容"
                                :maxlength="10"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :maskConfig="maskConfig.pcm_contract_itemresources_unit"
                                :showCount="false">
                              </YunzhupaasInput>
                              <!-- <YunzhupaasSelect
                                v-model:value="record.resources_name"
                                @change="changeData('pcm_contract_itemresources_name', index)"
                                placeholder="请选择"
                                :templateJson="state.interfaceRes.pcm_contract_itemresources_name"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :showSearch="false"
                                :options="optionsObj.pcm_contract_itemresources_nameOptions"
                                :fieldNames="optionsObj.pcm_contract_itemresources_nameProps">
                              </YunzhupaasSelect> -->
                            </template>
                            <template v-if="column.key === 'resources_unit'">
                              <YunzhupaasInput
                                v-model:value="record.resources_unit"
                                @change="changeData('pcm_contract_itemresources_unit', index)"
                                placeholder="请输入单位"
                                :maxlength="10"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :maskConfig="maskConfig.pcm_contract_itemresources_unit"
                                :showCount="false">
                              </YunzhupaasInput>
                            </template>
                            <template v-if="column.key === 'resources_price'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_price"
                                @change="changeData('gcl_pcm_contract_itemresources_price', index)"
                                placeholder="请输入单价"
                                :style="{ width: '100%' }"
                                :step="1"
                                :precision="2"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'resources_quantity'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_quantity"
                                @change="changeData('gcl_pcm_contract_itemresources_quantity', index)"
                                placeholder="请输入工时"
                                :style="{ width: '100%' }"
                                :step="1"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'resources_money'">
                              <YunzhupaasInputNumber
                                v-model:value="record.resources_money"
                                @change="changeData('pcm_contract_itemresources_money', index)"
                                placeholder="小计"
                                :style="{ width: '100%' }"
                                :disabled="true"
                                :step="1"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'action'">
                              <a-space>
                                <a-button class="action-btn" type="link" @click="copyGclPcm_contract_itemRow(index)" size="small">
                                  {{ t('common.copyText', '复制') }}
                                </a-button>
                                <a-button class="action-btn" type="link" color="error" @click="removeGclPcm_contract_itemRow(index, true)" size="small">
                                  {{ t('common.delText', '删除') }}
                                </a-button>
                              </a-space>
                            </template>
                          </template>
                        </a-table>
                        <a-space class="input-table-footer-btn">
                          <a-button type="primary" preIcon="icon-ym icon-ym-btn-add" @click="gcl_addPcm_contract_itemRow">
                            {{ t('common.add1Text', '添加') }}
                          </a-button>
                          <!-- <a-button type="danger" preIcon="icon-ym icon-ym-btn-clearn" @click="batchRemovePcm_contract_itemRow(true)">
                            {{ t('common.batchDelText', '批量删除') }}
                          </a-button> -->
                        </a-space>
                      </a-form-item>
                    </a-col>
                  </a-row>
                </a-card>
              </a-col>
            </a-row>
            <a-row key="165e3f" class="!pt-12px w-full" v-show="2 == state.activestepsformItem0864d8" :gutter="15">
              <a-col :span="24" class="ant-col-item">
                <a-form-item>
                  <YunzhupaasButton align="right" buttonText="下一步" type="primary" @click="nextBut()"> </YunzhupaasButton>
                </a-form-item>
              </a-col>
              <a-col :span="24" class="ant-col-item">
                <a-card class="mb-20">
                  <a-row :gutter="15">
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item>
                        <YunzhupaasText
                          :textStyle="{
                            color: '#000000',
                            'font-weight': 'normal',
                            'text-decoration': 'none',
                            'font-size': 15,
                            'line-height': 15,
                            'font-style': 'normal',
                            'text-align': 'left',
                          }"
                          :content="`合同名称：${dataForm.contract_name || ''}`">
                        </YunzhupaasText>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item>
                        <YunzhupaasText
                          :textStyle="{
                            color: '#000000',
                            'font-weight': 'normal',
                            'text-decoration': 'none',
                            'font-size': 15,
                            'line-height': 15,
                            'font-style': 'normal',
                            'text-align': 'left',
                          }"
                          :content="`合同编码：${dataForm.contract_code || ''}`">
                        </YunzhupaasText>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item>
                        <YunzhupaasText
                          :textStyle="{
                            color: '#000000',
                            'font-weight': 'normal',
                            'text-decoration': 'none',
                            'font-size': 15,
                            'line-height': 15,
                            'font-style': 'normal',
                            'text-align': 'left',
                          }"
                          :content="`对方单位：${dataForm.dfdwxx?.company_name || ''}`">
                        </YunzhupaasText>
                      </a-form-item>
                    </a-col>
                    <a-col :span="12" class="ant-col-item">
                      <a-form-item>
                        <YunzhupaasText
                          :textStyle="{
                            color: '#000000',
                            'font-weight': 'normal',
                            'text-decoration': 'none',
                            'font-size': 15,
                            'line-height': 15,
                            'font-style': 'normal',
                            'text-align': 'left',
                          }"
                          :content="`签约金额：${dataForm.contract_money || '0'}`">
                        </YunzhupaasText>
                      </a-form-item>
                    </a-col>

                    <a-col :span="24" class="ant-col-item mb-20px">
                      <a-form-item>
                        <yunzhupaasGroupTitle content="" :bordered="false" helpMessage="" />
                        <a-table
                          :data-source="dataForm.pcm_payment_planList"
                          :columns="pcm_payment_planColumns"
                          size="small"
                          :pagination="false"
                          :scroll="{ x: 'max-content' }"
                          :rowSelection="getpcm_payment_planRowSelection"
                          rowKey="yunzhupaasId">
                          <template #headerCell="{ column }">
                            <span class="required-sign" v-if="column.required">*</span>
                            {{ column.title }}
                            <BasicHelp :text="column.tipLabel" v-if="column.tipLabel && column.title" />
                          </template>
                          <template #bodyCell="{ column, index, record }">
                            <template v-if="column.key === 'index'">{{ index + 1 }}</template>
                            <template v-if="column.key === 'payment_type'">
                              <YunzhupaasSelect
                                v-model:value="record.payment_type"
                                @change="changeData('pcm_payment_planpayment_type', index)"
                                placeholder="请选择款项名称"
                                :templateJson="state.interfaceRes.pcm_payment_planpayment_type"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :showSearch="false"
                                :options="optionsObj.pcm_payment_planpayment_typeOptions"
                                :fieldNames="optionsObj.pcm_payment_planpayment_typeProps">
                              </YunzhupaasSelect>
                            </template>
                            <template v-if="column.key === 'payment_terms'">
                              <YunzhupaasInput
                                v-model:value="record.payment_terms"
                                @change="changeData('pcm_payment_planpayment_terms', index)"
                                placeholder="请输入"
                                :maxlength="50"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                :maskConfig="maskConfig.pcm_payment_planpayment_terms"
                                :showCount="false">
                              </YunzhupaasInput>
                            </template>

                            <template v-if="column.key === 'payment_date'">
                              <YunzhupaasDatePicker
                                v-model:value="record.payment_date"
                                @change="changeData('pcm_payment_planpayment_date', index)"
                                placeholder="请选择预计付款日期"
                                :allowClear="true"
                                :style="{ width: '100%' }"
                                format="yyyy-MM-dd"
                                :startTime="getRelationDate(false, 1, 1, '', '')"
                                :endTime="getRelationDate(false, 1, 1, '', '')">
                              </YunzhupaasDatePicker>
                            </template>
                            <template v-if="column.key === 'payment_redio'">
                              <YunzhupaasInputNumber
                                v-model:value="record.payment_redio"
                                @change="changeData('pcm_payment_planpayment_redio', index)"
                                placeholder="请输入"
                                :style="{ width: '100%' }"
                                :max="100"
                                :step="1"
                                :precision="2"
                                addonAfter="%"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'payment_money'">
                              <YunzhupaasInputNumber
                                v-model:value="record.payment_money"
                                @change="changeData('pcm_payment_planpayment_money', index)"
                                placeholder="请输入付款金额"
                                :style="{ width: '100%' }"
                                :max="999999"
                                :step="1"
                                :precision="4"
                                :controls="false">
                              </YunzhupaasInputNumber>
                            </template>
                            <template v-if="column.key === 'action'">
                              <a-space>
                                <a-button class="action-btn" type="link" @click="copyPcm_payment_planRow(index)" size="small">
                                  {{ t('common.copyText', '复制') }}
                                </a-button>
                                <a-button class="action-btn" type="link" color="error" @click="removePcm_payment_planRow(index, true)" size="small">
                                  {{ t('common.delText', '删除') }}
                                </a-button>
                              </a-space>
                            </template>
                          </template>
                        </a-table>
                        <a-space class="input-table-footer-btn">
                          <a-button type="primary" preIcon="icon-ym icon-ym-btn-add" @click="addPcm_payment_planRow">
                            {{ t('common.add1Text', '添加') }}
                          </a-button>
                          <!-- <a-button type="danger" preIcon="icon-ym icon-ym-btn-clearn" @click="batchRemovePcm_payment_planRow(true)">
                            {{ t('common.batchDelText', '批量删除') }}
                          </a-button> -->
                        </a-space>
                      </a-form-item>
                    </a-col>
                  </a-row>
                </a-card>
              </a-col>
            </a-row>
            <a-row key="c35cdb" class="!pt-12px w-full" v-show="3 == state.activestepsformItem0864d8" :gutter="15">
              <a-col :span="24" class="ant-col-item">
                <a-form-item>
                  <YunzhupaasButton align="right" buttonText="提交" type="primary" @click="nextBut()"> </YunzhupaasButton>
                </a-form-item>
              </a-col>
              <a-col :span="24" class="ant-col-item">
                <!-- <a-form-item>
                  <YunzhupaasText
                    :textStyle="{
                      color: '#000000',
                      'font-weight': 'normal',
                      'text-decoration': 'none',
                      'font-size': 12,
                      'line-height': 32,
                      'font-style': 'normal',
                      'text-align': 'left',
                    }"
                    content="这是一段文字">
                  </YunzhupaasText>
                </a-form-item> -->
                <a-row class="detail-view">
                  <a-col :span="24" class="detail-title">
                    {{ dataForm.contract_name || '合同名称' }}
                    <span>【{{ dataForm.contract_code || '' }}】</span>
                  </a-col>

                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">归属项目</div>
                    <div class="detail-value">
                      <YunzhupaasSelect
                        v-model:value="dataForm.project_id"
                        :disabled="true"
                        @change="changeData('project_id', -1)"
                        placeholder="请选择归属项目"
                        :templateJson="state.interfaceRes.project_id"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :showSearch="false"
                        :options="optionsObj.project_idOptions"
                        :fieldNames="optionsObj.project_idProps">
                      </YunzhupaasSelect
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">合同类型</div>
                    <div class="detail-value"
                      ><YunzhupaasSelect
                        v-model:value="dataForm.contract_type_code"
                        @change="changeData('contract_type_code', -1)"
                        placeholder="请选择合同类型"
                        :disabled="true"
                        :templateJson="state.interfaceRes.contract_type_code"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :showSearch="false"
                        :options="optionsObj.contract_type_codeOptions"
                        :fieldNames="optionsObj.contract_type_codeProps">
                      </YunzhupaasSelect
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">签约日期</div>
                    <div class="detail-value">
                      <YunzhupaasDatePicker
                        v-model:value="dataForm.contract_date"
                        @change="changeData('contract_date', -1)"
                        placeholder="请选择签约日期"
                        :disabled="true"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        format="yyyy-MM-dd"
                        :startTime="getRelationDate(false, 1, 1, '', '')"
                        :endTime="getRelationDate(false, 1, 1, '', '')">
                      </YunzhupaasDatePicker
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">合同有效期</div>
                    <div class="detail-value">
                      <YunzhupaasDatePicker
                        v-model:value="dataForm.valid_to"
                        :disabled="true"
                        @change="changeData('valid_to', -1)"
                        placeholder="请选择合同有效期"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        format="yyyy-MM-dd"
                        :startTime="getRelationDate(false, 1, 1, '', '')"
                        :endTime="getRelationDate(false, 1, 1, '', '')">
                      </YunzhupaasDatePicker
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">对方单位</div>
                    <div class="detail-value"
                      ><YunzhupaasRelationFormByUrl
                        style="width: 97%"
                        v-model:value="dataForm.second_party"
                        :disabled="true"
                        @change="changeData('second_party', -1)"
                        placeholder="请选择对方单位"
                        :templateJson="state.interfaceRes.second_party"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :showSearch="false"
                        :field="'second_party'"
                        modelId="/api/bcm/MdmCompany/getList"
                        :columnOptions="optionsObj.second_partycolumnOptions"
                        relationField="company_name"
                        popupWidth="1000px"
                        propsValue="company_id"
                        :valueMap="{ company_scope_yunzhupaasId: 'EXT' }"
                           detailComponentPath="@/views/mdm/mdmcompany/Detail.vue"
                        detailOpenType="component"
                        :queryType="0">
                      </YunzhupaasRelationFormByUrl
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">我方单位</div>
                    <!-- <div class="detail-value">
                      <YunzhupaasRelationFormByUrl
                        v-model:value="dataForm.first_party"
                        :disabled="true"
                        @change="changeData('first_party', -1)"
                        placeholder="请选择我方单位"
                        :templateJson="state.interfaceRes.first_party"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :showSearch="false"
                        :field="'first_party'"
                        modelId="/api/bcm/MdmCompany/getList"
                        :columnOptions="optionsObj.first_partycolumnOptions"
                        relationField="company_name"
                        popupWidth="1000px"
                        propsValue="company_id"
                        :valueMap="{ company_scope_yunzhupaasId: 'INT' }"
                        :queryType="0">
                      </YunzhupaasRelationFormByUrl
                    ></div> -->
                    <div class="detail-value">
                      <YunzhupaasRelationFormByUrl
                        v-model:value="dataForm.first_party"
                        :disabled="true"
                        @change="changeData('first_party', -1)"
                        placeholder="请选择我方单位"
                        :templateJson="state.interfaceRes.first_party"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :showSearch="false"
                        :field="'first_party'"
                        modelId="/api/bcm/MdmCompany/getList"
                        :columnOptions="optionsObj.first_partycolumnOptions"
                        relationField="company_name"
                        popupWidth="1000px"
                        propsValue="company_id"
                        :valueMap="{ company_scope_yunzhupaasId: 'INT' }"
                         detailComponentPath="@/views/mdm/mdmcompany/Detail.vue"
                        detailOpenType="component"
                        :queryType="0">
                      </YunzhupaasRelationFormByUrl
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">通讯地址（对方）</div>
                    <div class="detail-value"
                      ><YunzhupaasInput
                        v-model:value="dataForm.second_party_address"
                        @change="changeData('second_party_address', -1)"
                        placeholder="请输入对方单位地址"
                        :disabled="true"
                        :maxlength="100"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :maskConfig="maskConfig.second_party_address"
                        :showCount="false">
                      </YunzhupaasInput
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">通讯地址（我方）</div>
                    <div class="detail-value">
                      <YunzhupaasInput
                        v-model:value="dataForm.first_party_address"
                        @change="changeData('first_party_address', -1)"
                        placeholder="请输入我方单位地址"
                        :disabled="true"
                        :maxlength="100"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :maskConfig="maskConfig.first_party_address"
                        :showCount="false">
                      </YunzhupaasInput
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">负责人（对方）</div>
                    <div class="detail-value">
                      <YunzhupaasInput
                        v-model:value="dataForm.second_party_person"
                        @change="changeData('second_party_person', -1)"
                        placeholder="请输入对方负责人"
                        :disabled="true"
                        :maxlength="100"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :maskConfig="maskConfig.second_party_person"
                        :showCount="false">
                      </YunzhupaasInput
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">负责人（我方）</div>
                    <div class="detail-value"
                      ><YunzhupaasInput
                        v-model:value="dataForm.first_party_person"
                        @change="changeData('first_party_person', -1)"
                        placeholder="请输入我方负责人"
                        :disabled="true"
                        :maxlength="100"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :maskConfig="maskConfig.first_party_person"
                        :showCount="false">
                      </YunzhupaasInput
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">联系方式（对方）</div>
                    <div class="detail-value">
                      <YunzhupaasInput
                        v-model:value="dataForm.second_party_tel"
                        @change="changeData('second_party_tel', -1)"
                        placeholder="请输入对方联系方式"
                        :disabled="true"
                        :maxlength="100"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :maskConfig="maskConfig.second_party_tel"
                        :showCount="false">
                      </YunzhupaasInput
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">联系方式（我方）</div>
                    <div class="detail-value">
                      <YunzhupaasInput
                        v-model:value="dataForm.first_party_tel"
                        @change="changeData('first_party_tel', -1)"
                        placeholder="请输入我方联系方式"
                        :maxlength="100"
                        :disabled="true"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :maskConfig="maskConfig.first_party_tel"
                        :showCount="false">
                      </YunzhupaasInput
                    ></div>
                  </a-col>
                  <a-col :span="24" class="detail-row">
                    <div class="detail-label">合同条款</div>
                    <div class="detail-value">
                      <YunzhupaasTextarea
                        v-model:value="dataForm.contract_terms"
                        @change="changeData('contract_terms', -1)"
                        placeholder="请输入"
                        :disabled="true"
                        :maxlength="255"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :autoSize="{ minRows: 4, maxRows: 4 }"
                        :showCount="false">
                      </YunzhupaasTextarea
                    ></div>
                  </a-col>
                  <a-col :span="24" class="detail-row">
                    <div class="detail-label">说明</div>
                    <div class="detail-value">
                      <YunzhupaasTextarea
                        v-model:value="dataForm.remark"
                        @change="changeData('remark', -1)"
                        placeholder="请输入"
                        :maxlength="200"
                        :allowClear="true"
                        :disabled="true"
                        :style="{ width: '100%' }"
                        :autoSize="{ minRows: 2, maxRows: 2 }"
                        :showCount="false">
                      </YunzhupaasTextarea
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">经办人</div>
                    <div class="detail-value"
                      ><YunzhupaasUserSelect
                        v-model:value="dataForm.operator_id"
                        @change="changeData('operator_id', -1)"
                        placeholder="请选择经办人"
                        :disabled="true"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        selectType="all">
                      </YunzhupaasUserSelect
                    ></div>
                  </a-col>
                  <a-col :span="12" class="detail-row">
                    <div class="detail-label">经办日期</div>
                    <div class="detail-value">
                      <YunzhupaasDatePicker
                        v-model:value="dataForm.operator_date"
                        @change="changeData('operator_date', -1)"
                        :disabled="true"
                        placeholder="请选择合同有效期"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        format="yyyy-MM-dd"
                        :startTime="getRelationDate(false, 1, 1, '', '')"
                        :endTime="getRelationDate(false, 1, 1, '', '')">
                      </YunzhupaasDatePicker
                    ></div>
                  </a-col>
                </a-row>
                <yunzhupaasGroupTitle content="收/付款计划" :bordered="false" helpMessage="" />
                <a-table
                  :data-source="dataForm.pcm_payment_planList"
                  :columns="fk_pcm_payment_planColumns"
                  size="small"
                  :pagination="false"
                  :scroll="{ x: 'max-content' }">
                  <template #headerCell="{ column }">
                    <span class="required-sign" v-if="column.required">*</span>
                    {{ column.title }}
                    <BasicHelp :text="column.tipLabel" v-if="column.tipLabel && column.title" />
                  </template>
                  <template #bodyCell="{ column, index, record }">
                    <template v-if="column.key === 'index'">{{ index + 1 }}</template>
                    <template v-if="column.key === 'payment_type'">
                      <YunzhupaasSelect
                        v-model:value="record.payment_type"
                        @change="changeData('pcm_payment_planpayment_type', index)"
                        placeholder="请选择款项名称"
                        :templateJson="state.interfaceRes.pcm_payment_planpayment_type"
                        :allowClear="true"
                        :disabled="true"
                        :style="{ width: '100%' }"
                        :showSearch="false"
                        :options="optionsObj.pcm_payment_planpayment_typeOptions"
                        :fieldNames="optionsObj.pcm_payment_planpayment_typeProps">
                      </YunzhupaasSelect>
                    </template>
                    <template v-if="column.key === 'payment_terms'">
                      <YunzhupaasInput
                        v-model:value="record.payment_terms"
                        @change="changeData('pcm_payment_planpayment_terms', index)"
                        placeholder="请输入"
                        :maxlength="50"
                        :disabled="true"
                        :allowClear="true"
                        :style="{ width: '100%' }"
                        :maskConfig="maskConfig.pcm_payment_planpayment_terms"
                        :showCount="false">
                      </YunzhupaasInput>
                    </template>

                    <template v-if="column.key === 'payment_date'">
                      <YunzhupaasDatePicker
                        v-model:value="record.payment_date"
                        @change="changeData('pcm_payment_planpayment_date', index)"
                        placeholder="请选择预计付款日期"
                        :allowClear="true"
                        :disabled="true"
                        :style="{ width: '100%' }"
                        format="yyyy-MM-dd"
                        :startTime="getRelationDate(false, 1, 1, '', '')"
                        :endTime="getRelationDate(false, 1, 1, '', '')">
                      </YunzhupaasDatePicker>
                    </template>
                    <template v-if="column.key === 'payment_redio'">
                      <YunzhupaasInputNumber
                        v-model:value="record.payment_redio"
                        @change="changeData('pcm_payment_planpayment_redio', index)"
                        placeholder="请输入"
                        :style="{ width: '100%' }"
                        :max="100"
                        :step="1"
                        :disabled="true"
                        :precision="2"
                        addonAfter="%"
                        :controls="false">
                      </YunzhupaasInputNumber>
                    </template>
                    <template v-if="column.key === 'payment_money'">
                      <YunzhupaasInputNumber
                        v-model:value="record.payment_money"
                        @change="changeData('pcm_payment_planpayment_money', index)"
                        placeholder="请输入付款金额"
                        :style="{ width: '100%' }"
                        :max="999999"
                        :disabled="true"
                        :step="1"
                        :precision="4"
                        :controls="false">
                      </YunzhupaasInputNumber>
                    </template>
                  </template>
                </a-table>
              </a-col>
            </a-row>
          </a-col>
          <!-- 表单结束 -->
        </a-row>
      </a-form>
    </a-row>
  </BasicPopup>
</template>
<script lang="ts" setup>
  import { create, update, getInfo } from './helper/api';
  import { reactive, toRefs, nextTick, ref, unref, computed, toRaw, inject } from 'vue';
  import { BasicPopup, usePopup } from '@/components/Popup';
  import { YunzhupaasRelationFormByUrl } from '@/components/Yunzhupaas/RelationFormByUrl';
  import { useMessage } from '@/hooks/web/useMessage';
  import { useI18n } from '@/hooks/web/useI18n';
  import { useUserStore } from '@/store/modules/user';
  import type { FormInstance } from 'ant-design-vue';
  import { thousandsFormat, getDateTimeUnit, getTimeUnit } from '@/utils/yunzhupaas';
  import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
  import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
  import dayjs from 'dayjs';
  // import { YunzhupaasRelationForm } from '@/components/Yunzhupaas';
  // 表单权限
  import { usePermission } from '@/hooks/web/usePermission';
  import { cloneDeep } from 'lodash-es';
  import { buildUUID } from '@/utils/uuid';
  import { CaretRightOutlined } from '@ant-design/icons-vue';

  interface State {
    dataForm: any;
    tableRows: any;
    dataRule: any;
    optionsObj: any;
    childIndex: any;
    isEdit: any;
    interfaceRes: any;
    //可选范围默认值
    ableAll: any;
    //掩码配置
    maskConfig: any;
    //定位属性
    locationScope: any;
    activestepsformItem0864d8: any;
    selectedpcm_contract_itemRowKeys: any;
    selectedpcm_payment_planRowKeys: any;
    extraOptions: any;
    title: string;
    continueText: string;
    allList: any[];
    currIndex: number;
    isContinue: boolean;
    submitType: number;
    showContinueBtn: boolean;
  }

  const emit = defineEmits(['reload']);
  const getLeftTreeActiveInfo: (() => any) | null = inject('getLeftTreeActiveInfo', null);
  const userStore = useUserStore();
  const userInfo = userStore.getUserInfo;
  const { createMessage, createConfirm } = useMessage();
  const { t } = useI18n();
  const [registerPopup, { openPopup, setPopupProps }] = usePopup();
  const formRef = ref<FormInstance>();
  const pcm_contract_itemColumns: any[] = computed(() => {
    let list = [
      {
        title: '工种',
        dataIndex: 'resources_name',
        key: 'resources_name',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_name',
      },
      {
        title: '单位',
        dataIndex: 'resources_unit',
        key: 'resources_unit',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_unit',
      },
      {
        title: '单价',
        dataIndex: 'resources_price',
        key: 'resources_price',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_price',
      },
      {
        title: '工时',
        dataIndex: 'resources_quantity',
        key: 'resources_quantity',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_quantity',
      },
      {
        title: '小计',
        dataIndex: 'resources_money',
        key: 'resources_money',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_money',
      },
    ];
    list.push({ title: t('component.table.action'), showLabel: true, dataIndex: 'action', key: 'action', align: 'center', fixed: 'right', width: 100 });
    const indexColumn = { title: t('component.table.index'), showLabel: true, dataIndex: 'index', key: 'index', align: 'center', fixed: 'left', width: 50 };
    //子表复杂表头-处理
    let columnList = list;
    let complexHeaderList: any[] = [];
    if (complexHeaderList.length) {
      let childColumns: any[] = [];
      let firstChildColumns: string[] = [];
      for (let i = 0; i < complexHeaderList.length; i++) {
        const e = complexHeaderList[i];
        e.title = e.fullNameI18nCode ? t(e.fullNameI18nCode, e.fullName) : e.fullName;
        e.align = e.align;
        e.children = [];
        e.yunzhupaasKey = 'complexHeader';
        if (e.childColumns?.length) {
          childColumns.push(...e.childColumns);
          for (let k = 0; k < e.childColumns.length; k++) {
            const item = e.childColumns[k];
            for (let j = 0; j < list.length; j++) {
              const o = list[j];
              if (o.key == item && o.fixed !== 'left' && o.fixed !== 'right') e.children.push({ ...o });
            }
          }
        }
        if (e.children.length) firstChildColumns.push(e.children[0].key);
      }
      complexHeaderList = complexHeaderList.filter(o => o.children.length);
      let newList: any[] = [];
      for (let i = 0; i < list.length; i++) {
        const e = list[i];
        if (!childColumns.includes(e.key) || e.fixed === 'left' || e.fixed === 'right') {
          newList.push(e);
        } else {
          if (firstChildColumns.includes(e.key)) {
            const item = complexHeaderList.find(o => o.childColumns.includes(e.key));
            newList.push(item);
          }
        }
      }
      columnList = newList;
    }
    let columns = [indexColumn, ...columnList];
    const leftFixedList = columns.filter(o => o.fixed === 'left');
    const rightFixedList = columns.filter(o => o.fixed === 'right');
    const noFixedList = columns.filter(o => o.fixed !== 'left' && o.fixed !== 'right');
    return [...leftFixedList, ...noFixedList, ...rightFixedList];
  });
  const cg_pcm_contract_itemColumns: any[] = computed(() => {
    let list = [
      {
        title: '材料名称',
        dataIndex: 'resources_name',
        key: 'resources_name',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_name',
      },
      {
        title: '单位',
        dataIndex: 'resources_unit',
        key: 'resources_unit',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_unit',
      },
      {
        title: '单价',
        dataIndex: 'resources_price',
        key: 'resources_price',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_price',
      },
      {
        title: '数量',
        dataIndex: 'resources_quantity',
        key: 'resources_quantity',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_quantity',
      },
      {
        title: '小计',
        dataIndex: 'resources_money',
        key: 'resources_money',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_money',
      },
    ];
    list.push({ title: t('component.table.action'), showLabel: true, dataIndex: 'action', key: 'action', align: 'center', fixed: 'right', width: 100 });
    const indexColumn = { title: t('component.table.index'), showLabel: true, dataIndex: 'index', key: 'index', align: 'center', fixed: 'left', width: 50 };
    //子表复杂表头-处理
    let columnList = list;
    let complexHeaderList: any[] = [];
    if (complexHeaderList.length) {
      let childColumns: any[] = [];
      let firstChildColumns: string[] = [];
      for (let i = 0; i < complexHeaderList.length; i++) {
        const e = complexHeaderList[i];
        e.title = e.fullNameI18nCode ? t(e.fullNameI18nCode, e.fullName) : e.fullName;
        e.align = e.align;
        e.children = [];
        e.yunzhupaasKey = 'complexHeader';
        if (e.childColumns?.length) {
          childColumns.push(...e.childColumns);
          for (let k = 0; k < e.childColumns.length; k++) {
            const item = e.childColumns[k];
            for (let j = 0; j < list.length; j++) {
              const o = list[j];
              if (o.key == item && o.fixed !== 'left' && o.fixed !== 'right') e.children.push({ ...o });
            }
          }
        }
        if (e.children.length) firstChildColumns.push(e.children[0].key);
      }
      complexHeaderList = complexHeaderList.filter(o => o.children.length);
      let newList: any[] = [];
      for (let i = 0; i < list.length; i++) {
        const e = list[i];
        if (!childColumns.includes(e.key) || e.fixed === 'left' || e.fixed === 'right') {
          newList.push(e);
        } else {
          if (firstChildColumns.includes(e.key)) {
            const item = complexHeaderList.find(o => o.childColumns.includes(e.key));
            newList.push(item);
          }
        }
      }
      columnList = newList;
    }
    let columns = [indexColumn, ...columnList];
    const leftFixedList = columns.filter(o => o.fixed === 'left');
    const rightFixedList = columns.filter(o => o.fixed === 'right');
    const noFixedList = columns.filter(o => o.fixed !== 'left' && o.fixed !== 'right');
    return [...leftFixedList, ...noFixedList, ...rightFixedList];
  });

  const zd_pcm_contract_itemColumns: any[] = computed(() => {
    let list = [
      {
        title: '资源名称',
        dataIndex: 'resources_name',
        key: 'resources_name',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_name',
      },
      {
        title: '单位',
        dataIndex: 'resources_unit',
        key: 'resources_unit',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_unit',
      },
      {
        title: '单价',
        dataIndex: 'resources_price',
        key: 'resources_price',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_price',
      },
      {
        title: '周期',
        dataIndex: 'resources_quantity',
        key: 'resources_quantity',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_quantity',
      },
      {
        title: '小计',
        dataIndex: 'resources_money',
        key: 'resources_money',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_money',
      },
    ];
    list.push({ title: t('component.table.action'), showLabel: true, dataIndex: 'action', key: 'action', align: 'center', fixed: 'right', width: 100 });
    const indexColumn = { title: t('component.table.index'), showLabel: true, dataIndex: 'index', key: 'index', align: 'center', fixed: 'left', width: 50 };
    //子表复杂表头-处理
    let columnList = list;
    let complexHeaderList: any[] = [];
    if (complexHeaderList.length) {
      let childColumns: any[] = [];
      let firstChildColumns: string[] = [];
      for (let i = 0; i < complexHeaderList.length; i++) {
        const e = complexHeaderList[i];
        e.title = e.fullNameI18nCode ? t(e.fullNameI18nCode, e.fullName) : e.fullName;
        e.align = e.align;
        e.children = [];
        e.yunzhupaasKey = 'complexHeader';
        if (e.childColumns?.length) {
          childColumns.push(...e.childColumns);
          for (let k = 0; k < e.childColumns.length; k++) {
            const item = e.childColumns[k];
            for (let j = 0; j < list.length; j++) {
              const o = list[j];
              if (o.key == item && o.fixed !== 'left' && o.fixed !== 'right') e.children.push({ ...o });
            }
          }
        }
        if (e.children.length) firstChildColumns.push(e.children[0].key);
      }
      complexHeaderList = complexHeaderList.filter(o => o.children.length);
      let newList: any[] = [];
      for (let i = 0; i < list.length; i++) {
        const e = list[i];
        if (!childColumns.includes(e.key) || e.fixed === 'left' || e.fixed === 'right') {
          newList.push(e);
        } else {
          if (firstChildColumns.includes(e.key)) {
            const item = complexHeaderList.find(o => o.childColumns.includes(e.key));
            newList.push(item);
          }
        }
      }
      columnList = newList;
    }
    let columns = [indexColumn, ...columnList];
    const leftFixedList = columns.filter(o => o.fixed === 'left');
    const rightFixedList = columns.filter(o => o.fixed === 'right');
    const noFixedList = columns.filter(o => o.fixed !== 'left' && o.fixed !== 'right');
    return [...leftFixedList, ...noFixedList, ...rightFixedList];
  });

  const gcl_pcm_contract_itemColumns: any[] = computed(() => {
    let list = [
      {
        title: '施工内容',
        dataIndex: 'resources_name',
        key: 'resources_name',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_name',
      },
      {
        title: '单位',
        dataIndex: 'resources_unit',
        key: 'resources_unit',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_unit',
      },
      {
        title: '单价',
        dataIndex: 'resources_price',
        key: 'resources_price',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_price',
      },
      {
        title: '工程量',
        dataIndex: 'resources_quantity',
        key: 'resources_quantity',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_quantity',
      },
      {
        title: '小计',
        dataIndex: 'resources_money',
        key: 'resources_money',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'resources_money',
      },
    ];
    list.push({ title: t('component.table.action'), showLabel: true, dataIndex: 'action', key: 'action', align: 'center', fixed: 'right', width: 100 });
    const indexColumn = { title: t('component.table.index'), showLabel: true, dataIndex: 'index', key: 'index', align: 'center', fixed: 'left', width: 50 };
    //子表复杂表头-处理
    let columnList = list;
    let complexHeaderList: any[] = [];
    if (complexHeaderList.length) {
      let childColumns: any[] = [];
      let firstChildColumns: string[] = [];
      for (let i = 0; i < complexHeaderList.length; i++) {
        const e = complexHeaderList[i];
        e.title = e.fullNameI18nCode ? t(e.fullNameI18nCode, e.fullName) : e.fullName;
        e.align = e.align;
        e.children = [];
        e.yunzhupaasKey = 'complexHeader';
        if (e.childColumns?.length) {
          childColumns.push(...e.childColumns);
          for (let k = 0; k < e.childColumns.length; k++) {
            const item = e.childColumns[k];
            for (let j = 0; j < list.length; j++) {
              const o = list[j];
              if (o.key == item && o.fixed !== 'left' && o.fixed !== 'right') e.children.push({ ...o });
            }
          }
        }
        if (e.children.length) firstChildColumns.push(e.children[0].key);
      }
      complexHeaderList = complexHeaderList.filter(o => o.children.length);
      let newList: any[] = [];
      for (let i = 0; i < list.length; i++) {
        const e = list[i];
        if (!childColumns.includes(e.key) || e.fixed === 'left' || e.fixed === 'right') {
          newList.push(e);
        } else {
          if (firstChildColumns.includes(e.key)) {
            const item = complexHeaderList.find(o => o.childColumns.includes(e.key));
            newList.push(item);
          }
        }
      }
      columnList = newList;
    }
    let columns = [indexColumn, ...columnList];
    const leftFixedList = columns.filter(o => o.fixed === 'left');
    const rightFixedList = columns.filter(o => o.fixed === 'right');
    const noFixedList = columns.filter(o => o.fixed !== 'left' && o.fixed !== 'right');
    return [...leftFixedList, ...noFixedList, ...rightFixedList];
  });

  const nextBut = async () => {
    const values = await getForm()?.validate();
    if (!values) return;
    console.log(state.activestepsformItem0864d8 + 1);

    if (state.activestepsformItem0864d8 + 1 < 4) {
      state.activestepsformItem0864d8 = state.activestepsformItem0864d8 + 1;
      return;
    }
    createConfirm({
      iconType: 'warning',
      title: '提示',
      content: '确认提交吗?',
      onOk: () => {
        handleSubmit(undefined);
      },
    });

    // 下面写你下一步逻辑
  };
  const changeStage = current => {
    // 规则：只能后退，不能前进、不能点当前
    if (current >= state.activestepsformItem0864d8) {
      // 禁止：点击当前 + 下一步
      return;
    }
    state.activestepsformItem0864d8 = current;
  };
  const getpcm_contract_itemHasBatchBtn = computed(() => {
    let flist: any[] = [
      { btnIcon: 'icon-ym icon-ym-btn-add', show: true, label: '添加', btnType: 'primary', value: 'add', labelI18nCode: 'common.add1Text' },
      {
        btnIcon: 'icon-ym icon-ym-btn-clearn',
        showConfirm: 'true',
        show: true,
        label: '批量删除',
        btnType: 'danger',
        value: 'batchRemove',
        labelI18nCode: 'common.batchDelText',
      },
    ];
    return flist?.length && flist.some(o => o.value == 'batchRemove' && !!o.show);
  });

  const getpcm_contract_itemRowSelection = computed(() => {
    if (!unref(getpcm_contract_itemHasBatchBtn)) return undefined;
    const rowSelection = {
      selectedRowKeys: state.selectedpcm_contract_itemRowKeys,
      onChange: (selectedRowKeys: string[]) => {
        state.selectedpcm_contract_itemRowKeys = selectedRowKeys;
      },
    };
    return rowSelection;
  });

  const pcm_payment_planColumns: any[] = computed(() => {
    let list = [
      {
        title: '款项名称',
        dataIndex: 'payment_type',
        key: 'payment_type',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_type',
      },
      {
        title: '付款条件',
        dataIndex: 'payment_terms',
        key: 'payment_terms',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_terms',
      },
      {
        title: '预计付款日期',
        dataIndex: 'payment_date',
        key: 'payment_date',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_date',
      },
      {
        title: '付款比例 (%)',
        dataIndex: 'payment_redio',
        key: 'payment_redio',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_redio',
      },
      {
        title: '付款金额',
        dataIndex: 'payment_money',
        key: 'payment_money',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_money',
      },
    ];
    list.push({ title: t('component.table.action'), showLabel: true, dataIndex: 'action', key: 'action', align: 'center', fixed: 'right', width: 100 });
    const indexColumn = { title: t('component.table.index'), showLabel: true, dataIndex: 'index', key: 'index', align: 'center', fixed: 'left', width: 50 };
    //子表复杂表头-处理
    let columnList = list;
    let complexHeaderList: any[] = [];
    if (complexHeaderList.length) {
      let childColumns: any[] = [];
      let firstChildColumns: string[] = [];
      for (let i = 0; i < complexHeaderList.length; i++) {
        const e = complexHeaderList[i];
        e.title = e.fullNameI18nCode ? t(e.fullNameI18nCode, e.fullName) : e.fullName;
        e.align = e.align;
        e.children = [];
        e.yunzhupaasKey = 'complexHeader';
        if (e.childColumns?.length) {
          childColumns.push(...e.childColumns);
          for (let k = 0; k < e.childColumns.length; k++) {
            const item = e.childColumns[k];
            for (let j = 0; j < list.length; j++) {
              const o = list[j];
              if (o.key == item && o.fixed !== 'left' && o.fixed !== 'right') e.children.push({ ...o });
            }
          }
        }
        if (e.children.length) firstChildColumns.push(e.children[0].key);
      }
      complexHeaderList = complexHeaderList.filter(o => o.children.length);
      let newList: any[] = [];
      for (let i = 0; i < list.length; i++) {
        const e = list[i];
        if (!childColumns.includes(e.key) || e.fixed === 'left' || e.fixed === 'right') {
          newList.push(e);
        } else {
          if (firstChildColumns.includes(e.key)) {
            const item = complexHeaderList.find(o => o.childColumns.includes(e.key));
            newList.push(item);
          }
        }
      }
      columnList = newList;
    }
    let columns = [indexColumn, ...columnList];
    const leftFixedList = columns.filter(o => o.fixed === 'left');
    const rightFixedList = columns.filter(o => o.fixed === 'right');
    const noFixedList = columns.filter(o => o.fixed !== 'left' && o.fixed !== 'right');
    return [...leftFixedList, ...noFixedList, ...rightFixedList];
  });

  const fk_pcm_payment_planColumns: any[] = computed(() => {
    let list = [
      {
        title: '款项名称',
        dataIndex: 'payment_type',
        key: 'payment_type',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_type',
      },
      {
        title: '付款条件',
        dataIndex: 'payment_terms',
        key: 'payment_terms',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_terms',
      },
      {
        title: '预计付款日期',
        dataIndex: 'payment_date',
        key: 'payment_date',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_date',
      },
      {
        title: '付款比例 (%)',
        dataIndex: 'payment_redio',
        key: 'payment_redio',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_redio',
      },
      {
        title: '付款金额',
        dataIndex: 'payment_money',
        key: 'payment_money',
        labelWidth: '',
        span: '24',
        tipLabel: '',
        required: false,
        style: { width: '100%' },
        align: 'left',
        fixed: false,
        formP: 'payment_money',
      },
    ];
    // list.push({ title: t('component.table.action'), showLabel: true, dataIndex: 'action', key: 'action', align: 'center', fixed: 'right', width: 100 });
    const indexColumn = { title: t('component.table.index'), showLabel: true, dataIndex: 'index', key: 'index', align: 'center', fixed: 'left', width: 50 };
    //子表复杂表头-处理
    let columnList = list;
    let complexHeaderList: any[] = [];
    if (complexHeaderList.length) {
      let childColumns: any[] = [];
      let firstChildColumns: string[] = [];
      for (let i = 0; i < complexHeaderList.length; i++) {
        const e = complexHeaderList[i];
        e.title = e.fullNameI18nCode ? t(e.fullNameI18nCode, e.fullName) : e.fullName;
        e.align = e.align;
        e.children = [];
        e.yunzhupaasKey = 'complexHeader';
        if (e.childColumns?.length) {
          childColumns.push(...e.childColumns);
          for (let k = 0; k < e.childColumns.length; k++) {
            const item = e.childColumns[k];
            for (let j = 0; j < list.length; j++) {
              const o = list[j];
              if (o.key == item && o.fixed !== 'left' && o.fixed !== 'right') e.children.push({ ...o });
            }
          }
        }
        if (e.children.length) firstChildColumns.push(e.children[0].key);
      }
      complexHeaderList = complexHeaderList.filter(o => o.children.length);
      let newList: any[] = [];
      for (let i = 0; i < list.length; i++) {
        const e = list[i];
        if (!childColumns.includes(e.key) || e.fixed === 'left' || e.fixed === 'right') {
          newList.push(e);
        } else {
          if (firstChildColumns.includes(e.key)) {
            const item = complexHeaderList.find(o => o.childColumns.includes(e.key));
            newList.push(item);
          }
        }
      }
      columnList = newList;
    }
    let columns = [indexColumn, ...columnList];
    const leftFixedList = columns.filter(o => o.fixed === 'left');
    const rightFixedList = columns.filter(o => o.fixed === 'right');
    const noFixedList = columns.filter(o => o.fixed !== 'left' && o.fixed !== 'right');
    return [...leftFixedList, ...noFixedList, ...rightFixedList];
  });

  const getpcm_payment_planHasBatchBtn = computed(() => {
    let flist: any[] = [
      { btnIcon: 'icon-ym icon-ym-btn-add', show: true, label: '添加', btnType: 'primary', value: 'add', labelI18nCode: 'common.add1Text' },
      {
        btnIcon: 'icon-ym icon-ym-btn-clearn',
        showConfirm: 'true',
        show: true,
        label: '批量删除',
        btnType: 'danger',
        value: 'batchRemove',
        labelI18nCode: 'common.batchDelText',
      },
    ];
    return flist?.length && flist.some(o => o.value == 'batchRemove' && !!o.show);
  });

  const getpcm_payment_planRowSelection = computed(() => {
    if (!unref(getpcm_payment_planHasBatchBtn)) return undefined;
    const rowSelection = {
      selectedRowKeys: state.selectedpcm_payment_planRowKeys,
      onChange: (selectedRowKeys: string[]) => {
        state.selectedpcm_payment_planRowKeys = selectedRowKeys;
      },
    };
    return rowSelection;
  });

  const state = reactive<State>({
    dataForm: {
      dfdwxx: {},
      htlxxx: {
        cl_list_enabled: '0',
        rg_list_enabled: '0',
        zl_list_enabled: '0',
        gcl_list_enabled: '0',
      },
      contract_name: undefined,
      contract_code: undefined,
      contract_money: 0,
      contract_mode: 'revenue',
      project_id: '',
      contract_type_code: '测试数据',
      contract_date: dayjs().startOf(getDateTimeUnit('yyyy-MM-dd')).valueOf(),
      valid_to: dayjs().startOf(getDateTimeUnit('yyyy-MM-dd')).valueOf(),
      second_party: '',
      second_party_type: 'JF',
      first_party: '',
      first_party_type: 'YF',
      second_party_address: undefined,
      first_party_address: undefined,
      second_party_person: undefined,
      first_party_person: undefined,
      second_party_tel: undefined,
      first_party_tel: undefined,
      contract_terms: undefined,
      remark: undefined,
      operator_id: userInfo.userId ? userInfo.userId : '',
      operator_date: dayjs().startOf(getDateTimeUnit('yyyy-MM-dd')).valueOf(),
      pcmDocument: [],
      pcm_contract_itemList: [],
      cg_pcm_contract_itemList: [],
      zd_pcm_contract_itemList: [],
      gcl_pcm_contract_itemList: [],
      pcm_payment_planList: [],
    },

    tableRows: {
      pcm_contract_itemList: {
        resources_name: '',
        resources_unit: '',
        contract_item_type: 'RG',
        resources_type: 'RG',
        resources_price: undefined,
        resources_quantity: undefined,
        resources_money: undefined,
        enabledmark: undefined,
      },
      cg_pcm_contract_itemList: {
        resources_name: '',
        resources_unit: '',
        contract_item_type: 'CL',
        resources_type: 'CL',
        resources_price: undefined,
        resources_quantity: undefined,
        resources_money: undefined,
        enabledmark: undefined,
      },
      zd_pcm_contract_itemList: {
        resources_name: '',
        resources_unit: '',
        contract_item_type: 'ZL',
        resources_type: 'ZL',
        resources_price: undefined,
        resources_quantity: undefined,
        resources_money: undefined,
        enabledmark: undefined,
      },
      gcl_pcm_contract_itemList: {
        resources_name: '',
        resources_unit: '',
        contract_item_type: 'GCL',
        resources_type: 'GCL',
        resources_price: undefined,
        resources_quantity: undefined,
        resources_money: undefined,
        enabledmark: undefined,
      },
      pcm_payment_planList: {
        payment_type: '',
        payment_terms: '',
        payment_date: '',
        contract_item_type: 'RG',
        resources_type: 'RG',
        payment_redio: undefined,
        payment_money: undefined,
        enabledmark: undefined,
      },
    },

    dataRule: {
      contract_name: [
        {
          required: true,
          message: t('sys.validate.textRequiredSuffix', '不能为空'),
          trigger: 'blur',
        },
      ],
      contract_code: [
        {
          required: true,
          message: t('sys.validate.textRequiredSuffix', '不能为空'),
          trigger: 'blur',
        },
      ],
      project_id: [
        {
          required: true,
          message: t('sys.validate.arrayRequiredPrefix	', '请至少选择一个'),
          trigger: 'change',
        },
      ],
      contract_type_code: [
        {
          required: true,
          message: t('sys.validate.arrayRequiredPrefix	', '请至少选择一个'),
          trigger: 'change',
        },
      ],
      contract_date: [
        {
          required: true,
          message: t('sys.validate.textRequiredSuffix', '不能为空'),
          trigger: 'change',
        },
      ],
      valid_to: [
        {
          required: true,
          message: t('sys.validate.textRequiredSuffix', '不能为空'),
          trigger: 'change',
        },
      ],
      second_party: [
        {
          required: true,
          message: t('sys.validate.textRequiredSuffix', '不能为空'),
          trigger: 'change',
        },
      ],
      first_party: [
        {
          required: true,
          message: t('sys.validate.textRequiredSuffix', '不能为空'),
          trigger: 'change',
        },
      ],
    },

    optionsObj: {
      project_idOptions: [],
      project_idProps: { label: 'project_name', value: 'project_id' },
      contract_type_codeOptions: [],
      contract_type_codeProps: { label: 'contract_type_name', value: 'contract_type_code' },
      second_partycolumnOptions: [
        { label: '企业编码', value: 'company_code' },
        { label: '企业名称', value: 'company_name' },
        { label: '简称/昵称', value: 'short_name' },
        { label: '类型', value: 'entity_type' },
      ],
      second_party_typeOptions: [
        { fullName: '甲方', id: 'JF' },
        { fullName: '乙方', id: 'YF' },
      ],
      second_party_typeProps: { label: 'fullName', value: 'id' },
      first_partycolumnOptions: [
        { label: '企业编码', value: 'company_code' },
        { label: '企业名称', value: 'company_name' },
        { label: '简称/昵称', value: 'short_name' },
        { label: '类型', value: 'entity_type' },
      ],
      first_party_typeOptions: [
        { fullName: '甲方', id: 'JF' },
        { fullName: '乙方', id: 'YF' },
      ],
      first_party_typeProps: { label: 'fullName', value: 'id' },
      pcm_contract_itemresources_nameOptions: [],
      cl_pcm_contract_itemresources_nameOptions: [],
      pcm_contract_itemresources_nameProps: { label: 'fullName', value: 'enCode' },
      pcm_payment_planpayment_typeOptions: [
        { fullName: '预付款', id: 'YFK' },
        { fullName: '进度款', id: 'JDK' },
        { fullName: '质保金', id: 'ZBJ' },
        { fullName: '其他款', id: 'QTK' },
      ],
      pcm_payment_planpayment_typeProps: { label: 'fullName', value: 'id' },
    },

    childIndex: -1,
    isEdit: false,
    interfaceRes: {
      operator_id: [],
      pcm_payment_planpayment_type: [],
      remark: [],
      first_party_type: [],
      pcm_contract_itemresources_quantity: [],
      first_party_tel: [],
      pcm_contract_itemresources_price: [],
      first_party_address: [],
      second_party_person: [],
      pcm_contract_itemresources_money: [],
      contract_code: [],
      project_id: [],
      contract_date: [],
      pcm_contract_itemresources_unit: [],
      valid_to: [],
      pcm_payment_planpayment_money: [],
      pcm_payment_planpayment_date: [],
      contract_terms: [],
      operator_date: [],
      second_party_type: [],
      second_party_tel: [],
      second_party: [],
      pcm_contract_itemresources_name: [],
      contract_name: [],
      pcm_payment_planpayment_redio: [],
      first_party: [],
      pcm_payment_planpayment_terms: [],
      contract_type_code: [
        {
          dataType: 'varchar',
          defaultValue: 'SOFT',
          field: 'projectType',
          fieldName: '',
          id: '87bd31',
          isSubTable: false,
          relationField: 'SOFT',
          required: '1',
          sourceType: 2,
        },
      ],
      first_party_person: [],
      pcmDocument: [],
      second_party_address: [],
    },
    //可选范围默认值
    ableAll: {},

    //掩码配置
    maskConfig: {
      contract_name: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      contract_code: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      second_party_address: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      first_party_address: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      second_party_person: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      first_party_person: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      second_party_tel: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      first_party_tel: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      pcm_contract_itemresources_unit: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
      pcm_payment_planpayment_terms: {
        prefixType: 1,
        useUnrealMask: false,
        maskType: 1,
        unrealMaskLength: 1,
        prefixLimit: 0,
        suffixLimit: 0,
        filler: '*',
        prefixSpecifyChar: '',
        suffixType: 1,
        ignoreChar: '',
        suffixSpecifyChar: '',
      },
    },

    //定位属性
    locationScope: {},

    activestepsformItem0864d8: 0,
    selectedpcm_contract_itemRowKeys: [],
    selectedpcm_payment_planRowKeys: [],
    extraOptions: {
      second_party: [{ label: '企业名称', value: 'company_name' }],
      first_party: [{ label: '企业名称', value: 'company_name' }],
    },

    title: '',
    continueText: '',
    allList: [],
    currIndex: 0,
    isContinue: false,
    submitType: 0,
    showContinueBtn: true,
  });
  const { title, continueText, showContinueBtn, dataRule, dataForm, optionsObj, ableAll, maskConfig, submitType } = toRefs(state);

  const getPrevDisabled = computed(() => state.currIndex === 0);
  const getNextDisabled = computed(() => state.currIndex === state.allList.length - 1);
  // 表单权限
  const { hasFormP } = usePermission();

  defineExpose({ init });

  function init(data) {
    state.submitType = 0;
    state.isContinue = false;
    state.title = !data.id ? t('common.add2Text', '新增') : t('common.editText', '编辑');
    state.continueText = !data.id ? t('common.continueAndAddText', '确定并新增') : t('common.continueText', '确定并继续');
    setFormProps({ continueLoading: false });
    state.dataForm.id = data.id;
    openPopup();
    state.allList = data.allList;
    state.currIndex = state.allList.length && data.id ? state.allList.findIndex(item => item.id === data.id) : 0;
    nextTick(() => {
      getForm().resetFields();
      state.dataForm.pcm_contract_itemList = [];
      state.dataForm.cg_pcm_contract_itemList = [];
      state.dataForm.zd_pcm_contract_itemList = [];
      state.dataForm.gcl_pcm_contract_itemList = [];
      state.dataForm.pcm_payment_planList = [];
      setTimeout(initData, 0);
    });
  }
  function initData() {
    changeLoading(true);
    state.activestepsformItem0864d8 = 0;
    if (state.dataForm.id) {
      getData(state.dataForm.id);
    } else {
      //初始化options
      getproject_idOptions();
      getcontract_type_codeOptions();

      getpcm_contract_itemresources_nameOptions();
      getClpcm_contract_itemresources_nameOptions();
      if (state.dataForm.pcm_contract_itemList) {
        for (let i = 0; i < state.dataForm.pcm_contract_itemList.length; i++) {
          state.childIndex = i;
          state.dataForm.pcm_contract_itemList[i].yunzhupaasId = buildUUID();
        }
      }
      if (state.dataForm.cg_pcm_contract_itemList) {
        for (let i = 0; i < state.dataForm.cg_pcm_contract_itemList.length; i++) {
          state.childIndex = i;
          state.dataForm.cg_pcm_contract_itemList[i].yunzhupaasId = buildUUID();
        }
      }

      if (state.dataForm.zd_pcm_contract_itemList) {
        for (let i = 0; i < state.dataForm.zd_pcm_contract_itemList.length; i++) {
          state.childIndex = i;
          state.dataForm.zd_pcm_contract_itemList[i].yunzhupaasId = buildUUID();
        }
      }
      if (state.dataForm.gcl_pcm_contract_itemList) {
        for (let i = 0; i < state.dataForm.gcl_pcm_contract_itemList.length; i++) {
          state.childIndex = i;
          state.dataForm.gcl_pcm_contract_itemList[i].yunzhupaasId = buildUUID();
        }
      }
      if (state.dataForm.pcm_payment_planList) {
        for (let i = 0; i < state.dataForm.pcm_payment_planList.length; i++) {
          state.childIndex = i;
          state.dataForm.pcm_payment_planList[i].yunzhupaasId = buildUUID();
        }
      }
      // 设置默认值
      state.dataForm = {
        dfdwxx: {},
        htlxxx: {
          cl_list_enabled: '0',
          rg_list_enabled: '0',
          zl_list_enabled: '0',
          gcl_list_enabled: '0',
        },
        contract_name: undefined,
        contract_mode: 'revenue',
        contract_code: generateContractName(),
        contract_money: 0,
        project_id: '',
        contract_type_code: '测试数据',
        contract_date: dayjs().startOf(getDateTimeUnit('yyyy-MM-dd')).valueOf(),
        valid_to: dayjs().startOf(getDateTimeUnit('yyyy-MM-dd')).valueOf(),
        second_party: '',
        second_party_type: 'JF',
        first_party: '',
        first_party_type: 'YF',
        second_party_address: undefined,
        first_party_address: undefined,
        second_party_person: undefined,
        first_party_person: undefined,
        second_party_tel: undefined,
        first_party_tel: undefined,
        contract_terms: undefined,
        remark: undefined,
        operator_id: userInfo.userId ? userInfo.userId : '',
        operator_date: dayjs().startOf(getDateTimeUnit('yyyy-MM-dd')).valueOf(),
        pcmDocument: [],
        pcm_contract_itemList: [],
        cg_pcm_contract_itemList: [],
        zd_pcm_contract_itemList: [],
        gcl_pcm_contract_itemList: [],
        pcm_payment_planList: [],
      };
      if (getLeftTreeActiveInfo) state.dataForm = { ...state.dataForm, ...(getLeftTreeActiveInfo() || {}) };
      state.childIndex = -1;
      changeLoading(false);
    }
  }
  function getForm() {
    const form = unref(formRef);
    if (!form) {
      throw new Error('form is null!');
    }
    return form;
  }
  function getData(id) {
    getInfo(id).then(res => {
      state.dataForm = res.data || {};
      state.dataForm.htlxxx={
         cl_list_enabled: '0',
          rg_list_enabled: '0',
          zl_list_enabled: '0',
          gcl_list_enabled: '0',
      }
      getproject_idOptions();
      getcontract_type_codeOptions();
      getpcm_contract_itemresources_nameOptions();
      getClpcm_contract_itemresources_nameOptions();
      if (state.dataForm.pcm_contract_itemList) {
        for (let i = 0; i < state.dataForm.pcm_contract_itemList.length; i++) {
          state.childIndex = i;
          state.dataForm.pcm_contract_itemList[i].yunzhupaasId = buildUUID();
        }
      }
      if (state.dataForm.cg_pcm_contract_itemList) {
        for (let i = 0; i < state.dataForm.cg_pcm_contract_itemList.length; i++) {
          state.childIndex = i;
          state.dataForm.cg_pcm_contract_itemList[i].yunzhupaasId = buildUUID();
        }
      }
      if (state.dataForm.zd_pcm_contract_itemList) {
        for (let i = 0; i < state.dataForm.zd_pcm_contract_itemList.length; i++) {
          state.childIndex = i;
          state.dataForm.zd_pcm_contract_itemList[i].yunzhupaasId = buildUUID();
        }
      }
      if (state.dataForm.gcl_pcm_contract_itemList) {
        for (let i = 0; i < state.dataForm.gcl_pcm_contract_itemList.length; i++) {
          state.childIndex = i;
          state.dataForm.gcl_pcm_contract_itemList[i].yunzhupaasId = buildUUID();
        }
      }
      if (state.dataForm.pcm_payment_planList) {
        for (let i = 0; i < state.dataForm.pcm_payment_planList.length; i++) {
          state.childIndex = i;
          state.dataForm.pcm_payment_planList[i].yunzhupaasId = buildUUID();
        }
      }
      state.childIndex = -1;
      changeLoading(false);
    });
  }
  async function handleSubmit(type) {
    try {
      const values = await getForm()?.validate();
      if (!values) return;
      if (!pcm_contract_itemExist()) return;
      if (!pcm_payment_planExist()) return;

      setFormProps({ confirmLoading: true });
      const formMethod = state.dataForm.id ? update : create;
      formMethod(state.dataForm)
        .then(res => {
          createMessage.success(res.msg);
          setFormProps({ confirmLoading: false });
          if (state.submitType == 1) {
            initData();
            state.isContinue = true;
          } else {
            setFormProps({ open: false });
            emit('reload');
          }
        })
        .catch(() => {
          setFormProps({ confirmLoading: false });
        });
    } catch (_) {}
  }
  // 生成合同编号：HT.年月日.时分秒
  const generateContractName = () => {
    const now = new Date();
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, '0');
    const day = String(now.getDate()).padStart(2, '0');
    const hour = String(now.getHours()).padStart(2, '0');
    const minute = String(now.getMinutes()).padStart(2, '0');
    const second = String(now.getSeconds()).padStart(2, '0');

    // 拼接格式：HT.20260331.152835
    return `HT.${year}${month}${day}.${hour}${minute}${second}`;
  };
  function handleSecondPartyChange(id, row) {
    dataForm.company_name = row.company_name;
    changeData('second_party', -1);
  }
  function handlePrev() {
    state.currIndex--;
    handleGetNewInfo();
  }
  function handleNext() {
    state.currIndex++;
    handleGetNewInfo();
  }
  function handleGetNewInfo() {
    changeLoading(true);
    getForm().resetFields();
    const id = state.allList[state.currIndex].id;
    getData(id);
  }
  function setFormProps(data) {
    setPopupProps(data);
  }
  function changeLoading(loading) {
    setPopupProps({ loading });
  }
  async function onClose() {
    if (state.isContinue) emit('reload');
    return true;
  }

  function changeData(model, index) {
    state.isEdit = false;
    state.childIndex = index;
    // ==============================================
    // ✅ 安全计算小计（加了多层防错，绝对不报错）
    // ==============================================
    if (model === 'pcm_contract_itemresources_price' || model === 'pcm_contract_itemresources_quantity') {
      const row = dataForm.value.pcm_contract_itemList[index];
      const price = Number(row.resources_price) || 0;
      const quantity = Number(row.resources_quantity) || 0;
      row.resources_money = parseFloat((price * quantity).toFixed(2));
    }
    if (model === 'cg_pcm_contract_itemresources_price' || model === 'cg_pcm_contract_itemresources_quantity') {
      const row = dataForm.value.cg_pcm_contract_itemList[index];
      const price = Number(row.resources_price) || 0;
      const quantity = Number(row.resources_quantity) || 0;
      row.resources_money = parseFloat((price * quantity).toFixed(2));
    }

    if (model === 'zd_pcm_contract_itemresources_price' || model === 'zd_pcm_contract_itemresources_quantity') {
      const row = dataForm.value.zd_pcm_contract_itemList[index];
      const price = Number(row.resources_price) || 0;
      const quantity = Number(row.resources_quantity) || 0;
      row.resources_money = parseFloat((price * quantity).toFixed(2));
    }

    if (model === 'gcl_pcm_contract_itemresources_price' || model === 'gcl_pcm_contract_itemresources_quantity') {
      const row = dataForm.value.gcl_pcm_contract_itemList[index];
      const price = Number(row.resources_price) || 0;
      const quantity = Number(row.resources_quantity) || 0;
      row.resources_money = parseFloat((price * quantity).toFixed(2));
    }

    if (model === 'pcm_payment_planpayment_redio') {
      const row = dataForm.value.pcm_payment_planList[index];
      // 计算总和（包含当前即将选中的值）
      let total = 0;
      dataForm.value.pcm_payment_planList.forEach(item => {
        total += Number(item.payment_redio) || 0;
      });

      // 如果总和 > 100，清空当前项
      if (total > 100) {
        createConfirm({
          iconType: 'warning',
          title: '提示',
          content: '支付比例总和不能大于100%',
          onOk: () => {
            row.payment_redio = '';
          },
        });
      }
    }
    // ==============================================
    //  4 个数组的 resources_money
    // ==============================================
    const allItems = [
      ...(dataForm.value.pcm_contract_itemList || []),
      ...(dataForm.value.cg_pcm_contract_itemList || []),
      ...(dataForm.value.zd_pcm_contract_itemList || []),
      ...(dataForm.value.gcl_pcm_contract_itemList || []),
    ];

    const totalMoney = allItems.reduce((sum, item) => {
      return sum + (Number(item.resources_money) || 0);
    }, 0);

    // 赋值给合同总金额（保留2位小数）
    dataForm.value.contract_money = parseFloat(totalMoney.toFixed(2));
    // ==============================================
    // 原来的代码，完全不动
    // ==============================================
    for (let key in state.interfaceRes) {
      if (key != model) {
        let faceReList = state.interfaceRes[key];
        for (let i = 0; i < faceReList.length; i++) {
          let relationField = faceReList[i].relationField;
          if (relationField) {
            let modelAll = relationField.split('-');
            let faceMode = '';
            let faceMode2 = modelAll.length == 2 ? modelAll[0].substring(0, modelAll[0].length - 4) + modelAll[1] : '';
            for (let i = 0; i < modelAll.length; i++) {
              faceMode += modelAll[i];
            }
            if (faceMode == model || faceMode2 == model) {
              let options = 'get' + key + 'Options';
              eval(options)(true);
              changeData(key, index);
            }
          }
        }
      }
    }
  }
  function changeDataFormData(type, data, model, index, defaultValue) {
    if (!state.isEdit) {
      if (type == 2) {
        for (let i = 0; i < state.dataForm[data].length; i++) {
          if (index == -1) {
            state.dataForm[data][i][model] = defaultValue;
          } else if (index == i) {
            state.dataForm[data][i][model] = defaultValue;
          }
        }
      } else {
        state.dataForm[data] = defaultValue;
      }
    }
  }
  function addPcm_contract_itemRow() {
    let item = {
      resources_name: '',
      pcm_contract_itemresources_nameOptions: state.optionsObj.pcm_contract_itemresources_nameOptions,
      resources_unit: undefined,
      resources_price: undefined,
      contract_item_type: 'RG',
      resources_type: 'RG',
      resources_quantity: undefined,
      resources_money: undefined,
      yunzhupaasId: buildUUID(),
    };
    state.dataForm.pcm_contract_itemList.push(item);
    state.childIndex = state.dataForm.pcm_contract_itemList.length - 1;
    state.childIndex = -1;
  }
  function cg_addPcm_contract_itemRow() {
    let item = {
      resources_name: '',
      pcm_contract_itemresources_nameOptions: state.optionsObj.cl_pcm_contract_itemresources_nameOptions,
      resources_unit: undefined,
      resources_price: undefined,
      contract_item_type: 'CL',
      resources_type: 'CL',
      resources_quantity: undefined,
      resources_money: undefined,
      yunzhupaasId: buildUUID(),
    };
    state.dataForm.cg_pcm_contract_itemList.push(item);
    state.childIndex = state.dataForm.cg_pcm_contract_itemList.length - 1;
    state.childIndex = -1;
  }

  function zd_addPcm_contract_itemRow() {
    let item = {
      resources_name: '',
      pcm_contract_itemresources_nameOptions: state.optionsObj.cl_pcm_contract_itemresources_nameOptions,
      resources_unit: undefined,
      resources_price: undefined,
      contract_item_type: 'ZL',
      resources_type: 'ZL',
      resources_quantity: undefined,
      resources_money: undefined,
      yunzhupaasId: buildUUID(),
    };
    state.dataForm.zd_pcm_contract_itemList.push(item);
    state.childIndex = state.dataForm.zd_pcm_contract_itemList.length - 1;
    state.childIndex = -1;
  }

  function gcl_addPcm_contract_itemRow() {
    let item = {
      resources_name: '',
      pcm_contract_itemresources_nameOptions: state.optionsObj.pcm_contract_itemresources_nameOptions,
      resources_unit: undefined,
      resources_price: undefined,
      contract_item_type: 'GCL',
      resources_type: 'GCL',
      resources_quantity: undefined,
      resources_money: undefined,
      yunzhupaasId: buildUUID(),
    };
    state.dataForm.gcl_pcm_contract_itemList.push(item);
    state.childIndex = state.dataForm.gcl_pcm_contract_itemList.length - 1;
    state.childIndex = -1;
  }

  function removePcm_contract_itemRow(index, showConfirm = false) {
    if (showConfirm) {
      createConfirm({
        iconType: 'warning',
        title: '提示',
        content: '此操作将永久删除该数据, 是否继续?',
        onOk: () => {
          state.dataForm.pcm_contract_itemList.splice(index, 1);
        },
      });
    } else {
      state.dataForm.pcm_contract_itemList.splice(index, 1);
    }
  }
  function removeCgPcm_contract_itemRow(index, showConfirm = false) {
    if (showConfirm) {
      createConfirm({
        iconType: 'warning',
        title: '提示',
        content: '此操作将永久删除该数据, 是否继续?',
        onOk: () => {
          state.dataForm.cg_pcm_contract_itemList.splice(index, 1);
        },
      });
    } else {
      state.dataForm.cg_pcm_contract_itemList.splice(index, 1);
    }
  }
  function removeZdPcm_contract_itemRow(index, showConfirm = false) {
    if (showConfirm) {
      createConfirm({
        iconType: 'warning',
        title: '提示',
        content: '此操作将永久删除该数据, 是否继续?',
        onOk: () => {
          state.dataForm.zd_pcm_contract_itemList.splice(index, 1);
        },
      });
    } else {
      state.dataForm.zd_pcm_contract_itemList.splice(index, 1);
    }
  }
  function removeGclPcm_contract_itemRow(index, showConfirm = false) {
    if (showConfirm) {
      createConfirm({
        iconType: 'warning',
        title: '提示',
        content: '此操作将永久删除该数据, 是否继续?',
        onOk: () => {
          state.dataForm.gcl_pcm_contract_itemList.splice(index, 1);
        },
      });
    } else {
      state.dataForm.gcl_pcm_contract_itemList.splice(index, 1);
    }
  }

  function copyPcm_contract_itemRow(index) {
    let item = cloneDeep(state.dataForm.pcm_contract_itemList[index]);
    let copyData = {};
    for (let i = 0; i < unref(pcm_contract_itemColumns).length; i++) {
      const cur = unref(pcm_contract_itemColumns)[i];
      if (cur.key != 'index' && cur.key != 'action') {
        if (cur.children?.length && cur.yunzhupaasKey == 'complexHeader') {
          for (let j = 0; j < cur.children.length; j++) {
            copyData[cur.children[j].key] = item[cur.children[j].key];
          }
        } else {
          copyData[cur.key] = item[cur.key];
        }
      }
    }
    const copyItem = { ...copyData, yunzhupaasId: buildUUID() };
    state.dataForm.pcm_contract_itemList.push(copyItem);
    state.childIndex = state.dataForm.pcm_contract_itemList.length - 1;
    state.childIndex = -1;
  }
  function copyCgPcm_contract_itemRow(index) {
    let item = cloneDeep(state.dataForm.cg_pcm_contract_itemList[index]);
    let copyData = {};
    for (let i = 0; i < unref(cg_pcm_contract_itemColumns).length; i++) {
      const cur = unref(cg_pcm_contract_itemColumns)[i];
      if (cur.key != 'index' && cur.key != 'action') {
        if (cur.children?.length && cur.yunzhupaasKey == 'complexHeader') {
          for (let j = 0; j < cur.children.length; j++) {
            copyData[cur.children[j].key] = item[cur.children[j].key];
          }
        } else {
          copyData[cur.key] = item[cur.key];
        }
      }
    }
    const copyItem = { ...copyData, yunzhupaasId: buildUUID() };
    state.dataForm.cg_pcm_contract_itemList.push(copyItem);
    state.childIndex = state.dataForm.cg_pcm_contract_itemList.length - 1;
    state.childIndex = -1;
  }
  function copyZdPcm_contract_itemRow(index) {
    let item = cloneDeep(state.dataForm.zd_pcm_contract_itemList[index]);
    let copyData = {};
    for (let i = 0; i < unref(zd_pcm_contract_itemColumns).length; i++) {
      const cur = unref(zd_pcm_contract_itemColumns)[i];
      if (cur.key != 'index' && cur.key != 'action') {
        if (cur.children?.length && cur.yunzhupaasKey == 'complexHeader') {
          for (let j = 0; j < cur.children.length; j++) {
            copyData[cur.children[j].key] = item[cur.children[j].key];
          }
        } else {
          copyData[cur.key] = item[cur.key];
        }
      }
    }
    const copyItem = { ...copyData, yunzhupaasId: buildUUID() };
    state.dataForm.zd_pcm_contract_itemList.push(copyItem);
    state.childIndex = state.dataForm.zd_pcm_contract_itemList.length - 1;
    state.childIndex = -1;
  }
  function copyGclPcm_contract_itemRow(index) {
    let item = cloneDeep(state.dataForm.gcl_pcm_contract_itemList[index]);
    let copyData = {};
    for (let i = 0; i < unref(gcl_pcm_contract_itemColumns).length; i++) {
      const cur = unref(gcl_pcm_contract_itemColumns)[i];
      if (cur.key != 'index' && cur.key != 'action') {
        if (cur.children?.length && cur.yunzhupaasKey == 'complexHeader') {
          for (let j = 0; j < cur.children.length; j++) {
            copyData[cur.children[j].key] = item[cur.children[j].key];
          }
        } else {
          copyData[cur.key] = item[cur.key];
        }
      }
    }
    const copyItem = { ...copyData, yunzhupaasId: buildUUID() };
    state.dataForm.gcl_pcm_contract_itemList.push(copyItem);
    state.childIndex = state.dataForm.gcl_pcm_contract_itemList.length - 1;
    state.childIndex = -1;
  }

  function batchRemovePcm_contract_itemRow(showConfirm = false) {
    if (!state.selectedpcm_contract_itemRowKeys.length) return createMessage.error('请选择一条数据');
    const handleRemove = () => {
      state.dataForm.pcm_contract_itemList = state.dataForm.pcm_contract_itemList.filter(o => !state.selectedpcm_contract_itemRowKeys.includes(o.yunzhupaasId));
      nextTick(() => {
        state.selectedpcm_contract_itemRowKeys = [];
      });
    };
    if (showConfirm) {
      createConfirm({
        iconType: 'warning',
        title: '提示',
        content: '此操作将永久删除该数据, 是否继续?',
        onOk: () => {
          handleRemove();
        },
      });
    } else {
      handleRemove();
    }
  }

  function pcm_contract_itemExist() {
    let isOk = true;
    for (let i = 0; i < state.dataForm.pcm_contract_itemList.length; i++) {
      const e = state.dataForm.pcm_contract_itemList[i];
    }
    return isOk;
  }

  function addPcm_payment_planRow() {
    let item = {
      payment_type: '',
      pcm_payment_planpayment_typeOptions: state.optionsObj.pcm_payment_planpayment_typeOptions,
      payment_terms: undefined,
      payment_date: undefined,
      payment_redio: undefined,
      payment_money: undefined,
      yunzhupaasId: buildUUID(),
    };
    state.dataForm.pcm_payment_planList.push(item);
    state.childIndex = state.dataForm.pcm_payment_planList.length - 1;
    state.childIndex = -1;
  }

  function removePcm_payment_planRow(index, showConfirm = false) {
    if (showConfirm) {
      createConfirm({
        iconType: 'warning',
        title: '提示',
        content: '此操作将永久删除该数据, 是否继续?',
        onOk: () => {
          state.dataForm.pcm_payment_planList.splice(index, 1);
        },
      });
    } else {
      state.dataForm.pcm_payment_planList.splice(index, 1);
    }
  }

  function copyPcm_payment_planRow(index) {
    let item = cloneDeep(state.dataForm.pcm_payment_planList[index]);
    let copyData = {};
    for (let i = 0; i < unref(pcm_payment_planColumns).length; i++) {
      const cur = unref(pcm_payment_planColumns)[i];
      if (cur.key != 'index' && cur.key != 'action') {
        if (cur.children?.length && cur.yunzhupaasKey == 'complexHeader') {
          for (let j = 0; j < cur.children.length; j++) {
            copyData[cur.children[j].key] = item[cur.children[j].key];
          }
        } else {
          copyData[cur.key] = item[cur.key];
        }
      }
    }
    const copyItem = { ...copyData, yunzhupaasId: buildUUID() };
    state.dataForm.pcm_payment_planList.push(copyItem);
    state.childIndex = state.dataForm.pcm_payment_planList.length - 1;
    state.childIndex = -1;
  }

  function batchRemovePcm_payment_planRow(showConfirm = false) {
    if (!state.selectedpcm_payment_planRowKeys.length) return createMessage.error('请选择一条数据');
    const handleRemove = () => {
      state.dataForm.pcm_payment_planList = state.dataForm.pcm_payment_planList.filter(o => !state.selectedpcm_payment_planRowKeys.includes(o.yunzhupaasId));
      nextTick(() => {
        state.selectedpcm_payment_planRowKeys = [];
      });
    };
    if (showConfirm) {
      createConfirm({
        iconType: 'warning',
        title: '提示',
        content: '此操作将永久删除该数据, 是否继续?',
        onOk: () => {
          handleRemove();
        },
      });
    } else {
      handleRemove();
    }
  }

  function pcm_payment_planExist() {
    let isOk = true;
    for (let i = 0; i < state.dataForm.pcm_payment_planList.length; i++) {
      const e = state.dataForm.pcm_payment_planList[i];
    }
    return isOk;
  }

  //数据选项--远端数据初始化方法
  function getproject_idOptions(isClear = false) {
    const index = state.childIndex;
    let templateJsonList = JSON.parse(JSON.stringify(state.interfaceRes.project_id));
    for (let i = 0; i < templateJsonList.length; i++) {
      let json = templateJsonList[i];
      if (json.relationField && json.sourceType == 1) {
        let relationFieldAll = json.relationField.split('-');
        let val = json.defaultValue;
        if (relationFieldAll.length > 1 && index > -1) {
          if (relationFieldAll[0].endsWith('List')) {
            val =
              state.dataForm[relationFieldAll[0]] && state.dataForm[relationFieldAll[0]].length
                ? state.dataForm[relationFieldAll[0]][index][relationFieldAll[1]]
                : '';
          } else {
            val =
              state.dataForm[relationFieldAll[0] + 'List'] && state.dataForm[relationFieldAll[0] + 'List'].length
                ? state.dataForm[relationFieldAll[0] + 'List'][index][relationFieldAll[1]]
                : '';
          }
        } else {
          val = state.dataForm[relationFieldAll];
        }
        json.defaultValue = val ? val : '';
      }
    }
    let template = {
      paramList: templateJsonList,
    };
    getDataInterfaceRes('797177453981204485', template).then(res => {
      let data = res.data;
      state.optionsObj.project_idOptions = data;
      if (index == -1) return;
      if (isClear) {
        changeDataFormData(1, 'List', 'project_id', index, '');
      }
    });
  }
  //数据选项--远端数据初始化方法
  function getcontract_type_codeOptions(isClear = false) {
    const index = state.childIndex;
    let templateJsonList = JSON.parse(JSON.stringify(state.interfaceRes.contract_type_code));
    for (let i = 0; i < templateJsonList.length; i++) {
      let json = templateJsonList[i];
      if (json.relationField && json.sourceType == 1) {
        let relationFieldAll = json.relationField.split('-');
        let val = json.defaultValue;
        if (relationFieldAll.length > 1 && index > -1) {
          if (relationFieldAll[0].endsWith('List')) {
            val =
              state.dataForm[relationFieldAll[0]] && state.dataForm[relationFieldAll[0]].length
                ? state.dataForm[relationFieldAll[0]][index][relationFieldAll[1]]
                : '';
          } else {
            val =
              state.dataForm[relationFieldAll[0] + 'List'] && state.dataForm[relationFieldAll[0] + 'List'].length
                ? state.dataForm[relationFieldAll[0] + 'List'][index][relationFieldAll[1]]
                : '';
          }
        } else {
          val = state.dataForm[relationFieldAll];
        }
        json.defaultValue = val ? val : '';
      }
    }
    let template = {
      paramList: templateJsonList,
    };
    
    getDataInterfaceRes('808356583347064133', template).then(res => {
      let data = res.data;
      state.optionsObj.contract_type_codeOptions = data;
      // ✅ 核心：判断不为空时，从 data 中找到匹配的一行数据
      if (state.dataForm && state.dataForm.contract_type_code) {
        // 根据 contract_type_code 查找对应行
        const targetRow = data.find(item => item.contract_type_code === state.dataForm.contract_type_code);

        // 找到了就可以使用 targetRow（整行数据）
        if (targetRow) {
          state.dataForm.htlxxx.cl_list_enabled = targetRow.cl_list_enabled;
          state.dataForm.htlxxx.rg_list_enabled = targetRow.rg_list_enabled;
          state.dataForm.htlxxx.zl_list_enabled = targetRow.zl_list_enabled;
          state.dataForm.htlxxx.gcl_list_enabled = targetRow.gcl_list_enabled;
        }
      }
      if (index == -1) return;
      if (isClear) {
        changeDataFormData(1, 'List', 'contract_type_code', index, '');
      }
    });
  }
  //数据选项--数据字典初始化方法
  function getpcm_contract_itemresources_nameOptions() {
    getDictionaryDataSelector('808608079544323461').then(res => {
      state.optionsObj.pcm_contract_itemresources_nameOptions = res.data.list;
    });
  }
  //数据选项--数据字典初始化方法
  function getClpcm_contract_itemresources_nameOptions() {
    getDictionaryDataSelector('808608974935952773').then(res => {
      state.optionsObj.cl_pcm_contract_itemresources_nameOptions = res.data.list;
    });
  }
  function getRelationDate(timeRule, timeType, timeTarget, timeValueData, dataValue) {
    let timeDataValue: any = null;
    let timeValue = Number(timeValueData);
    if (timeRule) {
      if (timeType == 1) {
        timeDataValue = timeValue;
      } else if (timeType == 2) {
        timeDataValue = dataValue;
      } else if (timeType == 3) {
        timeDataValue = new Date().getTime();
      } else if (timeType == 4 || timeType == 5) {
        const type = getTimeUnit(timeTarget);
        const method = timeType == 4 ? 'subtract' : 'add';
        timeDataValue = dayjs()[method](timeValue, type).valueOf();
      }
    }
    return timeDataValue;
  }
  function getRelationTime(timeRule, timeType, timeTarget, timeValue, formatType, dataValue) {
    let format = formatType == 'HH:mm' ? 'HH:mm:00' : formatType;
    let timeDataValue: any = null;
    if (timeRule) {
      if (timeType == 1) {
        timeDataValue = timeValue || '00:00:00';
        if (timeDataValue.split(':').length == 3) {
          timeDataValue = timeDataValue;
        } else {
          timeDataValue = timeDataValue + ':00';
        }
      } else if (timeType == 2) {
        timeDataValue = dataValue;
      } else if (timeType == 3) {
        timeDataValue = dayjs().format(format);
      } else if (timeType == 4 || timeType == 5) {
        const type = getTimeUnit(timeTarget + 3);
        const method = timeType == 4 ? 'subtract' : 'add';
        timeDataValue = dayjs()[method](timeValue, type).format(format);
      }
    }
    return timeDataValue;
  }
</script>
<style scoped>
  .mb-10px {
    margin-bottom: 10px;
    padding: 0 10%;
  }

  /* 整体容器 */
  .detail-view {
    width: 100%;
    /* border: 1px solid #e5e6eb; */
    border-radius: 6px;
    overflow: hidden;
  }

  /* 标题 */
  .detail-title {
    /* background: #fafbfc; */
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    border-bottom: 1px solid #e5e6eb;
  }

  /* 每行：占满整行 */
  .detail-row {
    display: flex;
    width: 100%;
    border-bottom: 1px solid #e5e6eb;
  }

  /* 标签：占满左侧 + 背景色 #f5f7fa */
  .detail-label {
    width: 160px;
    background: #f5f7fa;
    padding: 10px 16px;
    color: #333;
    font-weight: 400;
    display: flex;
    align-items: center;
  }

  /* 值：占满右侧 + 背景色 #fff */
  .detail-value {
    /* width: 100%;
      box-sizing: border-box; */

    flex: 1;
    background: #ffffff;
    padding: 10px 16px;
    color: #333;
    display: flex;
    align-items: center;
  }

  /* 最后一行无边框 */
  .detail-row:last-child {
    border-bottom: none;
  }
</style>
