<template>
  <el-card class="box-card" v-loading="editloading" element-loading-text="正在处理中...">

    <el-tabs type="border-card" class="PackageInformation">
      <el-tab-pane label="包件信息">
        <div class="ResponsibilityBoxS">
          <div>
            <el-button type="primary" v-if="RouterState != 'Kfend'" @click="AddPackage">
              添加信息
            </el-button>
          </div>
          <div class="el_btbox" v-for="(item, index) in PackageInfo" :key="index">
            <div class="leftbox">
              <div class="maxBox">
                <span class="title">包条码:</span>
                <el-input
                  v-model="item.packageCode"
                  placeholder="请输入包条码"
                  clearable
                  :rows="2"
                  @change="ChangePackageInfo(item.packageCode, index)"
                  :disabled="RouterState == 'Kfend'"
                />
              </div>

              <div class="maxBox">
                <span class="title">订单自编码:</span>
                <el-input
                  :disabled="RouterState == 'Kfend'"
                  v-model="item.orderCode"
                  placeholder="请输入订单自编号"
                  clearable
                />
              </div>

              <div class="maxBox">
                <span class="title">运单号:</span>
                <el-input
                  :disabled="RouterState == 'Kfend'"
                  v-model="item.waybillNumber"
                  placeholder="请输入运单号"
                  clearable
                />
              </div>

              <div class="maxBox">
                <span class="title">品牌:</span>
                <el-input
                  :disabled="RouterState == 'Kfend'"
                  v-model="item.brandName"
                  placeholder="请输入品牌"
                  clearable
                />
              </div>
            </div>

            <div class="el-btn">
              <el-button v-if="item.state" type="primary" @click="historicalPackages(index)">
                查看历史包件
              </el-button>
              <el-button
                type="primary"
                v-if="RouterState != 'Kfend'"
                @click="PackagRemoval(index, item)"
              >
                移除
              </el-button>
            </div>
          </div>
          <div class="NumTotal">
            <span>总件数:{{ Indexform.number }}</span>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
    <el-form
      :disabled="RouterState == 'Kfend'"
      :model="Indexform"
      label-width="100px"
      class="IndexFrom"
      ref="IndexForm"
    >
      <el-form-item label="异常类型">
        <el-select
          v-model="Indexform.workOrderType"
          clearable
          placeholder="选择工单异常类型"
          @change="abnormalChange"
        >
          <el-option
            v-for="item in IndexException"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="发现节点">
        <el-select
          v-model="Indexform.discoveryNode"
          clearable
          placeholder="选择发现节点"
          @change="DiscoveringNodesChange"
        >
          <el-option
            v-for="item in DiscoveringNodes"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="异常工单号">
        <el-input v-model="Indexform.workOrderNumber" disabled placeholder="异常工单号" clearable />
      </el-form-item>

      <el-form-item label="车次号">
        <el-input
          v-model="Indexform.trainNumber"
          placeholder="请输入车次号(干线卸车环节)"
          clearable
          @change="DeliveryTrainnumber"
        />
      </el-form-item>
      <!-- 必填 -->
      <el-form-item label="一级品">
        <el-input v-model="Indexform.first" placeholder="请输入一级品类" clearable />
      </el-form-item>
      <!-- 必填 -->
      <el-form-item label="二级品">
        <el-input v-model="Indexform.secondary" placeholder="请输入二级品类" clearable />
      </el-form-item>

      <el-form-item label="车辆路线">
        <el-input
          v-model="Indexform.vehicleRoute"
          placeholder="请输入车辆路线车次号(通过车次号自动带出车辆路线)"
          clearable
        />
      </el-form-item>

      <el-form-item label="发货时间">
        <el-date-picker
          v-model="Indexform.deliverGoodsTime"
          type="datetime"
          format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DD HH:mm:ss"
          placeholder="请选择发货时间"
        />
      </el-form-item>

      <el-form-item label="发现时间">
        <el-date-picker
          v-model="Indexform.discoveryTime"
          type="datetime"
          format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DD HH:mm:ss"
          placeholder="请选择发现时间"
        />
      </el-form-item>

      <el-form-item label="配送时间">
        <el-date-picker
          v-model="Indexform.deliveryTime"
          type="datetime"
          format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DD HH:mm:ss"
          placeholder="请选择配送时间"
        />
      </el-form-item>

      <el-form-item label="入库时间">
        <el-date-picker
          v-model="Indexform.warehousingTime"
          type="datetime"
          format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DD HH:mm:ss"
          placeholder="请选择入库"
        />
      </el-form-item>
      <!-- 必填 -->
      <el-form-item label="运单商场">
        <el-input v-model="Indexform.waybillMall" placeholder="请输入运单商场" clearable />
      </el-form-item>
      <el-form-item label="钉钉流程号">
        <el-input v-model="Indexform.processNumber" placeholder="请输入钉钉流程号" />
      </el-form-item>
      <el-form-item label="配送司机">
        <el-select
          v-model="Indexform.deliveryDriver"
          filterable
          default-first-option
          :reserve-keyword="false"
          placeholder="请输入配送司机"
        >
          <el-option
            v-for="item in DeliveryDriver"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <!-- 必填 -->
      <!-- <el-form-item label="异常问题描述">
        <el-input v-model="Indexform.problemDescription" placeholder="请输入异常问题" clearable />
      </el-form-item> -->

      <el-form-item label="处理方">
        <el-select
          :disabled="RouterState == 'Kfend'"
          v-model="Indexform.processor"
          clearable
          filterable
          multiple
          placeholder="请选择处理方"
        >
          <el-option
            v-for="item in warehouseData"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="调查经过">
        <el-input
          :disabled="RouterState == 'Kfend'"
          v-model="Indexform.investigationProcess"
          placeholder="请输入调查经过"
          clearable
          :rows="2"
          type="textarea"
        />
      </el-form-item>

      <el-form-item> </el-form-item>
      <el-form-item> </el-form-item>
    </el-form>

    <el-tabs type="border-card">
      <el-tab-pane label="内部责任划分">
        <div class="ResponsibilityBox">
          <div>
            <el-button type="primary" @click="responsibleParty" v-if="RouterState != 'Kfend'">
              添加信息
            </el-button>
          </div>
          <div class="el_btbox" v-for="(item, index) in FangAddList" :key="index">
            <div class="leftbox">
              <div class="maxBox">
                <span class="title">责任方:</span>

                <!-- 提货环节  -->

                <el-select
                  v-model="item.businessName"
                  clearable
                  placeholder="请选提货择责任方"
                  v-if="groundlineType == 1"
                  :disabled="RouterState == 'Kfend'"
                >
                  <el-option
                    v-for="item in responsible"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>

                <el-select
                  v-else
                  v-model="item.businessName"
                  filterable
                  placeholder="请选择责任方"
                  :disabled="RouterState == 'Kfend'"
                  @change="ResponsiblePartychange(item.businessName, index)"
                >
                  <el-option
                    v-for="item in warehouseData"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </div>

              <div class="maxBox">
                <span class="title">责任人：</span>
                <el-select
                  :disabled="RouterState == 'Kfend'"
                  v-model="item.personResponsibleName"
                  clearable
                  filterable
                  placeholder="请选责任人"
                >
                  <el-option
                    v-for="item in personResponsibleList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </div>
              <div class="maxBox el_zb">
                <span class="title">占比:</span>
                <el-input-number
                  v-model="item.responsibilityRatio"
                  :controls="false"
                  placeholder="占比"
                  :disabled="RouterState == 'Kfend'"
                  :rows="2"
                  :max="item.ProportionMax"
                  @input="CompanyProportionInput(item)"
                />
                <span>%</span>
              </div>
              <div class="maxBox">
                <el-form-item label="三方责任人:">
                  <el-input
                    v-model="item.tripartite"
                    placeholder="请输入三方责任人"
                    :disabled="RouterState == 'Kfend'"
                  />
                </el-form-item>
              </div>

              <div class="maxBox">
                <span class="title">说明:</span>
                <el-input
                  :disabled="RouterState == 'Kfend'"
                  v-model="item.description"
                  placeholder="请输入说明 "
                  clearable
                  :rows="2"
                />
              </div>
            </div>
            <div class="el-btn">
              <el-button
                v-if="RouterState != 'Kfend'"
                type="primary"
                @click="ResponsibilityRemoval(index, item)"
              >
                移除
              </el-button>
            </div>
          </div>
          <div class="Proportion">
            <span class="title">公司占比:{{ companyProportion }}%</span>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>

    <el-form-item label="处理结果" class="el_handle">
      <el-select
        v-model="Indexform.result"
        multiple
        filterable
        default-first-option
        :reserve-keyword="false"
        placeholder="请选择处理结果"
        @change="changeProcessingResults"
        :disabled="Appealeditor == 'appeal'"
      >
        <el-option
          v-for="item in ProcessingResults"
          :key="item.dictKey"
          :label="item.dictValue"
          :value="item.dictKey"
        />
      </el-select>
    </el-form-item>

    <div class="ProcessingResults" v-if="ProcessingList.length">
      <div class="title">处理结果-理赔金额</div>
      <div class="Listadmiration">
        <div class="name" v-for="(item, index) in ProcessingList" :key="index">
          <span>{{ item.name }}:</span>
          <el-tooltip :content="item.input" placement="top">
            <el-input-number
              v-model="item.input"
              :min="item.min"
              :max="item.max"
              @change="TotalChange"
              :disabled="Appealeditor == 'appeal'"
            />
          </el-tooltip>
          <!-- 申诉的时候不展示 -->
          <div v-if="Appealeditor != 'appeal'" class="Paymentname" @click="PaymentSelection(item)">
            {{ item.payment ? item.text : '支付方式' }}
          </div>

          <div class="Paymentname" v-else>
            {{ item.payment ? item.text : '支付方式' }}
          </div>

          <div class="el_PaymentUnit">
            <span>支付单位:</span>
            <el-input
              v-model="item.paymentUnit"
              placeholder="请输入支付单位"
              :disabled="Appealeditor == 'appeal'"
            />
          </div>
          <el-date-picker
            v-model="item.compensationTime"
            type="datetime"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD HH:mm:ss"
            placeholder="理赔支付时间"
          />
        </div>
      </div>

      <div class="el_tool">
        <span>总金额:{{ TotalClaimAmount }}</span>
      </div>

    </div>
                  <!-- 处理结果说明  -->
    <el-form-item label="处理结果说明" class="el_resj">
        <el-input
                v-model="Indexform.resultDescription"
                placeholder="请输入处理结果说明"
                clearable
                :autosize="{ minRows: 3, maxRows: 4 }"
                type="textarea"
                :disabled="Appealeditor == 'appeal'"
              />
            </el-form-item>
    <el-tabs type="border-card" class="demo-tabs" v-if="!Processingresults">
      <el-tab-pane>
        <template #label>
          <span class="custom-tabs-label">
            <el-icon><calendar /></el-icon>
            <span>完结信息</span>
          </span>
        </template>
        <!-- v-if="RouterState != 'Infoedit'" -->
        <div class="el-ckbtn">
          <el-button type="primary" @click="AddCompensation">添加赔款方</el-button>
          <el-button type="primary" @click="AddPayee">添加受款方</el-button>
        </div>

        <div class="payanindemnity" v-for="(item, index) in CompensationParty" :key="index">
          <div class="el_pklab">
            <span class="title" :style="{ color: item.state != 0 ? '#000' : '#F56C6C' }"
              >{{ item.state == 0 ? '赔款方' : '受款方' }}{{ item.cld }}</span
            >
          </div>

          <div class="el_pkLi">
            <div class="sk_input">
              <el-input
                v-model="item.name"
                :placeholder="item.state == 0 ? '请填写赔款方' : '请填写受款方'"
                :disabled="Processingresults"
              />
              <!-- Processingresults表示此刻只能编辑处理结果 -->
            </div>
            <div class="sk_input">
              <el-form-item label="原因">
                <el-input
                  v-model="item.reason"
                  :disabled="Processingresults"
                  placeholder="请填写原因"
                />
              </el-form-item>
            </div>
            <div class="sk_input">
              <el-form-item label="金额">
                <el-input
                  @input="amountMoney"
                  :min="0"
                  v-model="item.num"
                  placeholder="金额"
                  :disabled="Processingresults"
                />
              </el-form-item>
            </div>
            <div class="sk_input" v-if="item.state == 0">
              <el-form-item label="仓库">
                <el-select
                  v-model="item.warehouseId"
                  filterable
                  placeholder="请选择仓库"
                  :disabled="Processingresults"
                >
                  <el-option
                    v-for="item in warehouseData"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </div>

            <div class="sk_input" v-if="item.state == 0">
              <el-form-item label="责任人">
                <el-input
                  v-model="item.personResponsibleList"
                  placeholder="请填写责任人"
                  clearable
                  :rows="2"
                  :disabled="Processingresults"
                />
              </el-form-item>
            </div>
            <div class="sk_input" v-if="item.state == 1"></div>

            <div class="sk_input" v-if="item.state == 1"></div>
            <!-- :disabled="RouterState == 'Infoedit'" -->
            <div class="sk_input" v-if="item.state == 0">
              <!-- <el-input v-model="item.explains" placeholder="请填写说明" /> -->
            </div>
            <div class="sk_input" v-if="item.state == 1">
              <!-- <el-input v-model="item.explain" placeholder="请填写说明" /> -->
            </div>
            <!-- v-if="RouterState != 'Infoedit'" -->
            <div class="el_cwBtn">
              <el-button type="primary" @click="payremove(item.state, index, item)">
                移除
              </el-button>
              <!-- <el-button type="primary" v-if="item.state == 0"> 财务处理 </el-button> -->
            </div>
          </div>
        </div>
        <div class="paySum">
          <span>
            <el-icon><Coin /></el-icon>赔款金额总和:<b>{{ TotalamountCompensation }}</b></span
          >
          <span>
            <el-icon><Coin /></el-icon>收款金额总和:<b>{{ TotalamountReceived }}</b></span
          >
        </div>
      </el-tab-pane>
    </el-tabs>

    <!-- 仲裁原因 -->
    <div class="arbitrate" v-if="!Processingresults">
      <el-tabs type="border-card" class="demo-tabs">
        <el-tab-pane>
          <template #label>
            <span class="custom-tabs-label">
              <el-icon><calendar /></el-icon>
              <span>仲裁原因</span>
            </span>
          </template>

          <el-input
            v-model="Indexform.arbitrate"
            type="textarea"
            :autosize="{ minRows: 5, maxRows: 4 }"
            placeholder="请输入仲裁原因"
            :disabled="Processingresults"
          />
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="Transport_damage_photos">
      <el-upload
        v-model:file-list="Indexform.packageImage"
        list-type="picture-card"
        :on-preview="pictureList"
        :on-remove="ImgListRemove"
        :action="doubledCount"
        :on-success="ImgSuccess"
        :before-upload="beforeAvatarUpload"
        :headers="headers"
        multiple
        drag
      >
        <el-icon><Plus /></el-icon>
      </el-upload>

      <el-dialog v-model="dialogImgList" width="30%">
        <el-image
          :src="amplifyurl"
          :zoom-rate="1.2"
          :max-scale="7"
          :min-scale="0.2"
          :preview-src-list="amplifysrcList"
          :initial-index="4"
          fit="cover"
        />
      </el-dialog>
    </div>

    <div class="dialog-footer">
      <!-- <el-button @click="Indexdialog = false">取消</el-button> -->
      <el-button type="primary" @click="ConfirmForm" v-if="RouterState == 'Infoedit'">
        提交
      </el-button>
      <!--编辑提交-->
      <el-button
        type="primary"
        @click="Arbitrationcompleted"
        v-if="
          (RouterState == 'Kfend' && !Appealeditor) || Appealeditor == 'appeal' || Processingresults
        "
      >
        提交
      </el-button>

      <!--客服仲裁完结 -->
    </div>
  </el-card>

  <!-- 少货件数大于3 -->
  <el-dialog
    :show-close="false"
    v-model="ShortageState"
    title="少货件数"
    width="40%"
    @close="ShortageStateFun"
    lock-scroll
    draggable
  >
    <div class="ShortageStatenum" v-for="item in ShortageList">
      <span class="title">件数{{ item.number }}</span
      ><el-input v-model="item.packageCode" placeholder="请输入包条码" />
    </div>

    <template #footer>
      <span class="dialog-footer">
        <el-button @click="ShortageCancellation">取消</el-button>
        <el-button type="primary" @click="ShortageState = false"> 确认信息 </el-button>
      </span>
    </template>
  </el-dialog>

  <!-- 窜货件数大于3 -->
  <el-dialog
    :show-close="false"
    v-model="fleeingState"
    title="窜货件数"
    width="40%"
    @close="fleeingFun"
    lock-scroll
    draggable
  >
    <div class="ShortageStatenum" v-for="item in fleeingList">
      <span class="title">件数{{ item.number }}</span
      ><el-input v-model="item.packageCode" placeholder="请输入包条码" />
    </div>

    <template #footer>
      <span class="dialog-footer">
        <el-button @click="fleeingCancellation">取消</el-button>
        <el-button type="primary" @click="ShortageState = false"> 确认信息 </el-button>
      </span>
    </template>
  </el-dialog>

  <el-dialog v-model="dialogHistoricalPackage" title="查看历史包件" width="30%">
    <el-form-item label="历史包件选择">
      <el-select v-model="HistoricalPackageinput" clearable filterable placeholder="请选择包件">
        <el-option
          v-for="item in HistoricalPackageList"
          :key="item.value"
          :label="item.workOrderNumber"
          :value="item.workOrderId"
        />
      </el-select>
      <el-button @click="ViewPackageDetails(HistoricalPackageinput)">查看详情</el-button>
    </el-form-item>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogHistoricalPackage = false">取消</el-button>
        <el-button type="primary" @click="HistoricalPackage(HistoricalPackageinput)">
          确定选择
        </el-button>
      </span>
    </template>
  </el-dialog>

  <!-- 支付方式选择 -->
  <el-dialog v-model="ZFdialog" title="支付方式选择" width="45%" class="ZFfsLoad">
    <el-radio-group v-model="Indexform.compensationMethod">
      <el-radio
        :label="item.dictKey"
        v-for="item in Paymentmethod"
        :key="item.dictKey"
        size="large"
        border
        >{{ item.dictValue }}</el-radio
      >
    </el-radio-group>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="ZFdialog = false">取消</el-button>
        <el-button type="primary" @click="PaymentConfirmation(Indexform.compensationMethod)">
          确定
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
import { ElMessage } from 'element-plus';
import { ElMessageBox } from 'element-plus';
import { useRouter, useRoute } from 'vue-router';
import { getDictionaryBiz } from '@/api/system/dict'; //字典
import { getDetailWarehouse, getDeptWarehouse } from '@/api/basicdata/basicdataWarehouse'; //处理方
import {
  $_getList,
  $_submit,
  $_getDetail,
  $_remove,
  $_getBusinessDepartmentUser,
  $_getAbnormalPackage,
  $_getInfo,
  $_arbitrateEnd,
  $_modifyData,
  $_shippingInformation,
  $_updateCompletionEnd,
  $_addProcessingResults,
} from '@/api/aftersales/aftersalesWorkOrder';
import { ref, reactive, toRefs, computed, onMounted, nextTick } from 'vue';
import { AddressClosed } from '@/utils/util';
import { getToken } from '@/utils/auth';
import { computeNumber, isNumer } from '@/utils/util';
import { useStore } from 'vuex';
import error from '@/error';
const $router = useRouter();
const $store = useStore();
const $route = useRoute();
const TotalamountCompensation = ref(0); //赔款金额合计
const TotalamountReceived = ref(0); //收款金额合计
const Indexform = ref({
  packList: [],
  packageImage: [], //图片列表
  decreaseImageEntityList: [], //处理好的图片数据
}); //首页新增表单
const IndexException = ref([]); //异常类型下拉选择
const editloading = ref(false); //页面加载效果
const ProcessingList = ref([]); //处理结果已经选择的列表
const DiscoveringNodes = ref([]); //发现节点下拉选择
const warehouseData = ref([]); //处理方
const SelectType = ref(); //类型
const StateType = ref(true); //类型
const HistoricalPackageinput = ref(''); //历史包件选择
const dialogImageUrl = ref(null); //图片
const dialogVisible = ref(null); //图片
const groundlineSet = ref(true); //干线条件都满足
const groundlineType = ref(null); //干线状态
const ShortageState = ref(false); //少货件数弹窗状态
const fleeingState = ref(false); //窜货件数弹窗
const ShortageList = ref([]); //少货件数
const fleeingList = ref([]); //窜货件数
const valueStrictly = ref();
const routerID = ref(null); //路由参数ID
const routerState = ref(''); //路由状态
const personResponsibleList = ref([]); //责任人列表
const companyProportion = ref(100); //公司占比
const identifying = ref(1); //订单，零担状态
const dialogHistoricalPackage = ref(false); //历史包件弹窗
const HistoricalPackageList = ref([]); //历史包件数组
const Paymentmethod = ref([]); //支付方式
const ZFdialog = ref(false); //支付弹窗
const ZFname = ref(''); //支付方式弹窗
const HistorIndex = ref(0); //历史包件索引
const ProcessingResults = ref([]); //处理结果列表选项
const TotalClaimAmount = ref(0); //理赔总金额
const TransportlossList = ref([]);
const RouterState = ref(); //编辑信息
const Appealeditor = ref(); //申诉编辑状态
const oldData = ref(); //旧数据
const unPackageInfo = ref(); //旧包件信息
const unProcessorEntityList = ref([]); //取消的责任方
const deletePackageInfo = ref([]); //被删除的包间信息
const unDecreaseImageEntityList = ref([]); //移除的货损图片
const NewImageAddress = ref([]); //旧的片地址
const InitialresponsibleParty = ref(); //初始的责任方
const ProcessingParty = ref(); //拷贝一份处理方
const CopyingInfo = ref({}); //拷贝的信息
const ProcessingpartyData = ref([]); //处理方拷贝的信息
const ResponsiblepartyData = ref([]); //责任方拷贝的信息
const completionRecipientEntityListData = ref([]); //受款方拷贝
const completionRecordEntitiesData = ref([]); //赔款方拷贝
const UncompletionRecipientEntityListData = ref([]); //收款取消的
const UncompletionRecordEntitiesDat = ref([]); //赔款取消的
const CompletionInformation = ref([]); //完结信息收赔款信息
const formData = ref({}); // 存储修改过的数据
const dialogImgList = ref(false); //图片预览弹窗
const amplifyurl = ref(''); //当前点击的图片
const amplifysrcList = ref([]); //图片循环列表
const Processingresults = ref(false); //理赔是否可以编辑
// ref 用于跟踪哪些字段被修改过
// 当字段改变时标记它为已修改

const modifiedFields = ref(new Set());
const markFieldAsModified = fieldName => {
  modifiedFields.value.add(fieldName);
};
const CompensationParty = ref([
  {
    name: '',
    state: 0,
    num: null,
    reason: '',
    cld: 1,
    explains: '',
    warehouseId: '',
    personResponsibleList: '',
  }, //赔款方
  {
    name: '',
    state: 1,
    num: null,
    reason: '',
    cld: 1,
    explains: '',
    warehouseId: '',
    personResponsibleList: '',
  }, //受款方
]); //收/赔
const PackageInfo = ref([
  //包件信息
  { packageCode: '', orderCode: '', waybillNumber: '', state: 0, brandName: '' },
]);
// 责任方列表
const FangAddList = ref([
  {
    businessName: '',
    personResponsibleName: '',
    responsibilityRatio: '',
    description: '',
    tripartite: '',
  },
]);
// 提货责任方
const responsible = ref([
  {
    value: 1,
    label: '工厂',
  },
  {
    value: 2,
    label: '外包搬运',
  },
  {
    value: 3,
    label: '物流',
  },
]);
// 司机信息
const DeliveryDriver = ref([]);
// 图片列表
const fileList = ref([]);
// 字典公共函数
function updateDictionary(targetArray, dictionaryType) {
  getDictionaryBiz(dictionaryType).then(res => {
    console.log(res, '字典');
    res.data.data.forEach(item => {
      targetArray.push({
        value: item.dictKey,
        label: item.dictValue,
      });
    });
  });
}
// 车次号自动带出时间司机
function DeliveryTrainnumber() {
  if (!Indexform.value.trainNumber && !Indexform.value.deliveryTime) {
    Indexform.value.deliveryTime = null;
    Indexform.value.deliveryDriver = '';
    DeliveryDriver.value = [];
  }
  if (!Indexform.value.trainNumber && !Indexform.value.deliveryTime) {
    return;
  }
  let data = {
    trainNumber: Indexform.value.trainNumber,
    taskTime: Indexform.value.deliveryTime,
  };
  data.current = 1; //页码
  data.size = 200; //条数
  $_shippingInformation(data).then(res => {
    console.log(res, '查询返回值');
    DeliveryDriver.value = res.data.data.records; //获取到的信息
    // 如果是精确搜索自动带入日期
    if (res.data.data.records.length == 1 && groundlineType.value != 3) {
      Indexform.value.deliveryTime = res.data.data.records[0].taskTime; //配送时间
      Indexform.value.deliveryDriver = res.data.data.records[0].id; //配送人
      // Indexform.value.trainNumber = res.data.data.records[0].trainNumber; //车次号
    }
  });
}
// 图片上传必须携带TOKEN
const headers = computed(() => {
  return { 'Blade-Auth': 'Bearer ' + getToken() };
});
// 图片上传接口
const doubledCount = computed(() => {
  return '/api/blade-resource/oss/endpoint/put-file';
});
// 图片上传接口

// 图片上传成功回调函数
const ImgSuccess = (response, uploadFile) => {
  console.log(response, '上传成功');
  if (response.code == 200) {
    amplifysrcList.value.push(response.data.link);
  }
};

// 上传图片规则
const beforeAvatarUpload = rawFile => {
  if (rawFile.type !== 'image/png') {
    ElMessage.error('图片格式只能为image/png!');
    return false;
  } else if (rawFile.size / 1024 / 1024 > 2) {
    ElMessage.error('图片大小不能大于2MB!');
    return false;
  }
  return true;
};
// 点击图片列表回调
const pictureList = val => {
  dialogImgList.value = true;
  console.log(val, '图片列表');
  amplifyurl.value = val.url;
};
// 点击图片移除
const ImgListRemove = val => {
  unDecreaseImageEntityList.value.push(val); //移除的图片
  amplifysrcList.value = amplifysrcList.value.filter(item => item !== val.url);
  console.log(val, '移除图片');
};
// 处理方和责任方获取数据
const handle = () => {
  getDeptWarehouse().then(res => {
    res.data.data.forEach(item => {
      warehouseData.value.push({
        value: item.id,
        label: item.name,
      });
    });
  });
};

// 获取当前责任方的责任人
const ResponsiblePartychange = (val, index) => {
  FangAddList.value[index].personResponsibleName = null; //清空当前选择的责任人
  $_getBusinessDepartmentUser({
    warehouseId: val,
  }).then(res => {
    console.log(res, '获取责任人列表');
    personResponsibleList.value = res.data.data;
  });
};
const onLoad = () => {
  RouterState.value = $route.query.RouterState;
  if ($route.query.Appealeditor) {
    Appealeditor.value = $route.query.Appealeditor; //申诉编辑
    console.log(Appealeditor.value, '申诉编辑状态');
  }
  // 判断是否为理赔金未出编辑
  if ($route.query.Processingresults) {
    Processingresults.value = true;
  }
  console.log(RouterState.value, '路由状态');
  getDictionaryBiz('result_handling').then(res => {
    console.log(res, '发现环节');
    ProcessingResults.value = res.data.data;
    console.log(ProcessingResults.value, '发现环节');
  });

  // 支付方式字典
  getDictionaryBiz('payment_method').then(res => {
    //处理结果字典
    console.log(res);
    Paymentmethod.value = res.data.data;
  });

  console.log($route.query.id, '页面初始化');
  routerState.value = $route.query.routerState;
  updateDictionary(IndexException.value, 'pc_work_order'); //异常类型
  updateDictionary(DiscoveringNodes.value, 'pc_discovery_node'); //发现环节
  handle(); //处理方和责任方信息

  $_getInfo({ id: $route.query.id }).then(res => {
    if(res.data.data.discoveryNode=='1'){
      groundlineType.value = '1'
    }else{
      groundlineType.value = 'null'
    }
    oldData.value = JSON.parse(JSON.stringify(res.data.data));
    console.log(oldData.value, '旧数据');
    console.log(res, '回显返回值参数');
    Indexform.value = res.data.data;
    formData.value = JSON.parse(JSON.stringify(Indexform.value));
    Indexform.value.result = [];
    Indexform.value.processor = [];
    Indexform.value.packageImage = [];
    //图片处理回显
    res.data.data.decreaseImageVOList.forEach(res => {
      amplifysrcList.value.push(res.imagePath);
      Indexform.value['packageImage'].push({
        name: res.imageName,
        url: res.imagePath,
        id: res.id,
      });
    });
    // 拷贝基础信息
    // CopyingInfo.value.deliveryDriver = res.data.data.deliveryDriver; //配送司机
    // CopyingInfo.value.deliveryTime = res.data.data.deliveryTime; //配送时间
    // CopyingInfo.value.warehousingTime = res.data.data.warehousingTime; //入库时间
    // CopyingInfo.value.waybillMall = res.data.data.waybillMall; //运单商场
    // CopyingInfo.value.trainNumber = res.data.data.trainNumber; //车次号
    // CopyingInfo.value.first = res.data.data.first; //一级品
    // CopyingInfo.value.secondary = res.data.data.secondary; //二级品
    // CopyingInfo.value.problemDescription = res.data.data.problemDescription; //异常问题描述
    NewImageAddress.value = JSON.parse(JSON.stringify(Indexform.value['packageImage'])); //拷贝一份固定数据
    // 包件回显
    PackageInfo.value = res.data.data.abnormalPackageVOList;

    unPackageInfo.value = JSON.parse(JSON.stringify(PackageInfo.value)); //拷贝一份旧的包件信息
    console.log(unPackageInfo.value, '包件信息');


    let factorydata = res.data.data.personResponsibleVOS.find(item => item.typesOf);
      // if (factorydata.typesOf) {
      //   groundlineType.value = true; //切换处理方模式
      // }
    FangAddList.value = res.data.data.personResponsibleVOS.map(res => {
      ResponsiblepartyData.value.push(res);

      return {
        businessName: res.businessId, //责任人ID
        personResponsibleName: res.personResponsibleName, //责任人名称
        responsibilityRatio: res.responsibilityRatio, //占比
        tripartite: res.tripartite, //三方责任人
        description: res.description, //说明
        ProportionMax: 100,
      };
    });

    InitialresponsibleParty.value = JSON.parse(JSON.stringify(FangAddList.value)); //拷贝一份责任方
    res.data.data.processorVOList.forEach(item => {
      if (item) {
        if (item.typesOf == 2) {
          // 处理方
          Indexform.value.processor.push(item.businessId);
        }
      }
    });

    ProcessingParty.value = JSON.parse(JSON.stringify(Indexform.value.processor)); //拷贝一份处理方
    console.log(ProcessingParty.value, '拷贝的处理方');
    console.log(Indexform.value.processor, ' Indexform.value.processor');
    getDictionaryBiz('pc_work_order').then(res => {
      //处理结果字典
      console.log(res, '环节字典');
      Indexform.value.workOrderType = res.data.data.find(
        res => res.dictKey == Indexform.value.workOrderType
      ).dictValue; //异常类型回显
    });

    //发现环节回显
    getDictionaryBiz('pc_discovery_node').then(res => {
      // ProcessingResults.value = res.data.data;
      TransportlossList.value = res.data.data;
      // Indexform.discoveryNode
    });
    getDictionaryBiz('result_handling').then(res => {
      ProcessingResults.value = res.data.data;
    });

    // 公司占比回显计算
    let sum = 0;
    FangAddList.value.forEach(item => {
      sum = Number(item.responsibilityRatio) + sum;
    });
    companyProportion.value = 100 - sum;
    // 赔付方式
    if (res.data.data.processingResultsVO.processingMoneyEntityList) {
      ProcessingList.value = res.data.data.processingResultsVO.processingMoneyEntityList.map(
        item => {
          Indexform.value.result.push(item.resultType);
          return {
            input: item.money,
            min: 0,
            state: item.resultType,
            payment: item.compensationMethod,
            name: item.resultTypeName,
            text: item.compensationMethodName,
            compensationTime: item.compensationTime,
            paymentUnit: item.paymentUnit, //支付单位
            id:item.id, //id
          };
        }
      );
    }

    // 总金额回显
    TotalClaimAmount.value = res.data.data.processingResultsVO.money;
    // 理赔支付时间
    Indexform.value.compensationTime = res.data.data.processingResultsVO.compensationTime;
    // 处理结果说明回显
    Indexform.value.resultDescription = res.data.data.processingResultsVO.resultDescription;

    if (
      res.data.data.completionRecordEntities.length ||
      res.data.data.completionRecipientEntityList.length
    ) {
      // 如果受款方和赔款方存在数据清空初始数据
      CompensationParty.value = [];
      // 赔款方
      if (res.data.data.completionRecordEntities.length) {
        completionRecordEntitiesData.value = JSON.parse(
          JSON.stringify(res.data.data.completionRecordEntities)
        ); //赔款方拷贝
        res.data.data.completionRecordEntities.forEach((item, index) => {
          CompletionInformation.value.push({
            //把赔款方信息添加到数组中
            state: 0, //状态
            num: item.money, //金额
            name: item.indemnitor, //受款方名字
            reason: item.reason, //受款方原因
            explains: item.explains, //受款方说明
            cld: index + 1,
            id: item.id, //赔款方id
            warehouseId: item.warehouseId, //仓库ID
            personResponsibleList: item.compensationPersonnel, //责任人
          });

          TotalamountCompensation.value += Number(item.money);
          CompensationParty.value.push({
            state: 0, //状态
            num: item.money, //金额
            name: item.indemnitor, //受款方名字
            reason: item.reason, //受款方原因
            explains: item.explains, //受款方说明
            cld: index + 1,
            id: item.id, //赔款方id
            warehouseId: item.warehouseId, //仓库
            personResponsibleList: item.compensationPersonnel, //责任人
          });
        });
      }

      // 受款方
      if (res.data.data.completionRecipientEntityList.length) {
        completionRecipientEntityListData.value = JSON.parse(
          JSON.stringify(res.data.data.completionRecipientEntityList)
        ); //拷贝受款方

        res.data.data.completionRecipientEntityList.forEach((item, index) => {
          CompletionInformation.value.push({
            //把受款方信息添加到数组中
            state: 1, //状态
            num: item.money, //金额
            name: item.recipient, //受款方名字
            reason: item.reasonReceivingPayment, //受款方原因
            explains: item.explains, //受款方说明
            cld: index + 1,
            id: item.id, //受款方id
            warehouseId: item.warehouseId, //仓库ID
            personResponsibleList: item.compensationPersonnel, //责任人
          });

          TotalamountReceived.value += Number(item.money);
          CompensationParty.value.push({
            state: 1, //状态
            num: item.money, //金额
            name: item.recipient, //受款方名字
            reason: item.reasonReceivingPayment, //受款方原因
            explains: item.explains, //受款方说明
            cld: index + 1,
            id: item.id, //受款方id
            warehouseId: item.warehouseId, //仓库ID
            personResponsibleList: item.compensationPersonnel, //责任人
          });
        });
      }
    }

    Indexform.value.arbitrate = res.data.data.reasonArbitration; //仲裁原因
    // 异常类型下标
    SelectType.value = IndexException.value.find(
      item => item.value == Indexform.value.workOrderType
    ).value;
    console.log(SelectType.value, '异常类型');
  });
};
onLoad(); //初始化程序

// 统计包件个数
const Statistics = () => {
  // 订单统计包件个数
  if (identifying.value == 1) {
    Indexform.value.number = 0;
    PackageInfo.value.map(res => {
      if (res.packageCode) {
        Indexform.value.number++;
      }
    });
  } else {
    // 零担统计包件个数
    Indexform.value.number = 0;
    PackageInfo.value.map(res => {
      console.log(res);
      if (res.waybillNumber) {
        Indexform.value.number++;
      }
    });
  }
};



// 异常类型事件
const abnormalChange = val => {
  console.log(val, '异常事件类型');
  console.log(StateType.value);
  StateType.value = false;
  if (val == 1 || val == 2 || val == 3) {
    SelectType.value = val;
  } else {
    StateType.value = true;
  }
  // 运损无数据默认0
  if (val == 1) {
    Indexform.value.packageCode = 0;
  } else {
    Indexform.value.packageCode = null;
  }
};
// 公司占比计算
const CompanyProportion = val => {
  console.log(val, '接受的值');
  setTimeout(() => {
    console.log(FangAddList.value, ' FangAddList.value');
    let proportion = 0; //责任比例之和
    FangAddList.value.forEach(item => {
      proportion += Number(item.responsibilityRatio);
    });
    // companyProportion公司占比
    companyProportion.value = 100 - proportion;

    let sum = 0;
    FangAddList.value.forEach(item => {
      console.log(item.responsibilityRatio, '当前比例');
      sum += Number(item.responsibilityRatio);
    });
    console.log(sum, '当前比例之和');
    let max = 100 - sum + Number(val.responsibilityRatio);
    console.log('MAX当前最大值', max);
    if (val.ProportionMax) {
      val.ProportionMax = max;
    }
  }, 0);
};

// 公司占比事件
const CompanyProportionInput = item => {
  console.log(item, '接收的值');
  CompanyProportion(item);
};

// 发现节点事件
const DiscoveringNodesChange = val => {
  groundlineSet.value = false; //干线条件都不满足
  if (val == 1 || val == 2 || val == 3 || val == 4 || val == 5 || val == 8 || val == 7) {
    groundlineType.value = val; //干线状态
    console.log(val);
  } else {
    groundlineSet.value = true; //展示所有搜索框
  }
};

// 照片
const handleRemove = (uploadFile, uploadFiles) => {
  console.log(uploadFile, uploadFiles);
};

const handlePictureCardPreview = uploadFile => {
  dialogImageUrl.value = uploadFile.url;
  dialogVisible.value = true;
};

// 添加包件
const AddPackage = () => {
  PackageInfo.value.push({
    packageCode: '',
    orderCode: '',
    waybillNumber: '',
    state: 0,
    brandName: '',
  });
};
// 包件移除
const PackagRemoval = (val, item) => {
  deletePackageInfo.value.push(item);
  console.log(deletePackageInfo.value, '移除包件');
  PackageInfo.value.splice(val, 1); //移除当前点击的按钮
};
// 责任方添加
const responsibleParty = () => {
  let sum = 0;
  FangAddList.value.forEach(item => {
    console.log(item.responsibilityRatio, '当前比例');
    sum += Number(item.responsibilityRatio);
  });
  console.log(sum, '当前总和');
  let max = 100 - sum;
  console.log('添加了责任方');
  FangAddList.value.push({
    businessName: '',
    personResponsibleName: '',
    tripartite: '',
    responsibilityRatio: '',
    description: '',
    ProportionMax: max,
  });
  console.log(max, '当前最大值');
  console.log(FangAddList.value, '最新参数');
};
// 责任移除
const ResponsibilityRemoval = (val, item) => {
  unProcessorEntityList.value.push(item);
  FangAddList.value.splice(val, 1); //移除当前点击的按钮
  CompanyProportion(val);
};
// 顶部标签切换
const TopChange = val => {
  console.log(val);
  if (val == 0) {
    identifying.value = 1;
  } else {
    identifying.value = 2;
  }
};

const changeProcessingResults = val => {
  console.log(val,'当前点击的参数');
  console.log(ProcessingList.value,'当前的列表');
    // 首先删除取消的项目
  console.log(val[val.length-1]);
  ProcessingList.value = ProcessingList.value.filter(item => val.includes(item.state - 1));
  // 然后添加或保持新的项目
console.log(val,'当前状态');
    console.log(num,'当前参数');
     newItem = {
      input: 0,
      min: 0,
      max: 9999999999999,
      state: num,
      payment: '',
      text: '',
      compensationTime: '',
      paymentUnit: '',
    };

    // 根据num为newItem的name字段赋值
    switch (num) {
      case '1':
        newItem.name = '下补单';
        break;
      case '2':
        newItem.name = '维修/补漆';
        break;
      case '3':
        newItem.name = '客户未要求理赔';
        break;
      case '4':
        newItem.name = '用库存';
        break;
      case '5':
        newItem.name = '赔商家';
        break;
      case '6':
        newItem.name = '赔付运费';
        break;
      case '7':
        newItem.name = '工厂考核';
        break;
      default:
        return;
    }

    // 如果列表中不存在则加入新项目
    if (!ProcessingList.value.some(item => item.state === newItem.state)) {
      ProcessingList.value.push(newItem);
      console.log(`添加：${newItem.name}`);
      }
 
};

// 支付方式选择
const PaymentSelection = val => {
  console.log(val, '支付');
  console.log(Paymentmethod.value);
  if (val.payment) {
    //支付方式回显
    let data = Paymentmethod.value.find(item => item.dictKey == val.payment);
    Indexform.value.compensationMethod = data.dictKey;
  } else {
    Indexform.value.compensationMethod = null; //清空上一次选择
  }
  ZFdialog.value = true; //展开支付方式选择弹窗
  ZFname.value = val.name; //存放的当前点击的名字
};

// 理赔总金额计算
const TotalChange = () => {
  TotalClaimAmount.value = 0;
  ProcessingList.value.forEach(item => {
    console.log(item);
    TotalClaimAmount.value += item.input;
  });
};

// 支付方式选择确定
const PaymentConfirmation = val => {
  console.log(val, '支付方式选择确定');
  let data = ProcessingList.value.find(item => item.name == ZFname.value);
  console.log(data, '处理好的');
  data.text = Paymentmethod.value.find(item => item.dictKey == val).dictValue;
  data.payment = val;
  ZFdialog.value = false; //关闭支付方式选择弹窗
  ElMessage({
    message: '支付方式选择成功',
    type: 'success',
  });
  console.log(ProcessingList.value, '选择好的支付列表');
};

// 添加赔款方
const AddCompensation = () => {
  if (!Processingresults.value) {
    // 表示此刻为理赔编辑状态，只能操作处理结果
    return;
  }
  console.log('添加赔款方');
  let som = 1;
  CompensationParty.value.forEach(item => {
    if (item.state == 0) {
      som++;
    }
  });
  CompensationParty.value.push({ name: '', state: 0, num: 0, reason: '', cld: som, explains: '' });
};
// 添加受款方
const AddPayee = () => {
  if (!Processingresults.value) {
    // 表示此刻为理赔编辑状态，只能操作处理结果
    return;
  }
  let som = 1;
  CompensationParty.value.forEach(item => {
    if (item.state == 1) {
      som++;
    }
  });
  CompensationParty.value.push({ name: '', state: 1, num: 0, reason: '', cld: som, explains: '' });
};
// 金额输入汇总
const amountMoney = () => {
  // 计算赔款金额总数
  TotalamountCompensation.value = 0;
  TotalamountReceived.value = 0;
  CompensationParty.value.forEach(item => {
    const _num = isNumer(item.num) ? item.num : 0;
    // 统计赔款方【0】
    if (item.state == 0) {
      TotalamountCompensation.value = computeNumber(
        TotalamountCompensation.value,
        '+',
        _num
      ).result;
    }
    // 统计受款方金额【1】
    if (item.state == 1) {
      TotalamountReceived.value = computeNumber(TotalamountReceived.value, '+', _num).result;
    }
  });
  console.log('赔款总计金额', TotalamountCompensation.value);
  console.log('收款总计金额', TotalamountReceived.value);
};
// 移除按钮
const payremove = (state, val, data) => {
  if (!Processingresults.value) {
    // 表示此刻为理赔编辑状态，只能操作处理结果
    return;
  }
  console.log(state, '当前移除按钮的状态');
  //   const completionRecipientEntityListData=ref([]);//受款方拷贝
  // const completionRecordEntitiesData=ref([]);//赔款方拷贝
  if (state == 0) {
    UncompletionRecordEntitiesDat.value.push(data); //删除的赔款方
  } else {
    UncompletionRecipientEntityListData.value.push(data); //删除的受款方
    console.log();
  }

  // 判断赔付方，至少保留一条数据
  let som = 0;
  if (state == 0) {
    CompensationParty.value.forEach(item => {
      if (item.state == 0) {
        som++;
      }
    });
    if (som == 1) {
      ElMessage({
        message: '赔款必填最少一条',
        type: 'warning',
      });
      return;
    }
  }
  CompensationParty.value.splice(val, 1);
  console.log('CompensationParty :>> ', CompensationParty);
  amountMoney();
};

// 删除空的对象和数组
function removeEmptyProperties(obj) {
  Object.keys(obj).forEach(key => {
    if (Array.isArray(obj[key]) && obj[key].length === 0) {
      // 如果是空数组，则删除
      delete obj[key];
    } else if (
      typeof obj[key] === 'object' &&
      obj[key] !== null &&
      Object.keys(obj[key]).length === 0
    ) {
      // 如果是空对象，并且不是null，则删除
      delete obj[key];
    }
  });
  return obj;
}

//表单提交
const ConfirmForm = () => {
  console.log(ProcessingpartyData.value, '处理方信息');
  // 支付方式校验
  if (ProcessingList.value.length) {
    for (let item of ProcessingList.value) {
      if (!item.payment) {
        ElMessage({
          message: `请选择${item.name}的支付方式`,
          type: 'warning',
        });
        return;
      }
    }
  }
  // console.log(oldData.value,'查看老数据');
  // ...Indexform.value
  let DataSubmit = {
    packageEntityList: [], //新增的包件信息 (完成)
    unPpackageEntityList: [], //取消的包件ID（完成）
    processorEntityList: [], //新增处理方(完成)
    unProcessorEntityList: [], //取消的处理方（完成）
    decreaseImageEntityList: [], //损货图片 （完成）
    unDecreaseImageEntityList: [], //取消的损货图片（完成）
    completionRecipientEntities: [], //异常工单完结受款方(完成暂不可修改)
    completionRecordEntities: [], //异常工单完结赔款方(完成暂不可修改)
    aftersalesProcessingResultsDTO: {}, //处理结果（完成暂不可修改）
    personResponsibleDTO: [], //添加预计责任人(完成)
    unPersonResponsibleDTO: [], //取消预计责任人（完成）
    surveyRecordDTO: {}, //调查经过
    unCompletionRecipientEntities: [], //取消异常工单完结处理结果受款方
    unCompletionRecordEntities: [], //取消异常工单完结的赔款方
  };
  DataSubmit.id = $route.query.id; //任务

  let Modified = PackageInfo.value.filter(
    objB => !unPackageInfo.value.some(objA => JSON.stringify(objA) === JSON.stringify(objB))
  ); //修改过的包件信息

  // 调查经过
  // if (Indexform.value.investigationProcess) {
  //   DataSubmit.surveyRecordDTO = {
  //     content: Indexform.value.investigationProcess, //内容'
  //     workOrderId: $route.query.id, //工单ID
  //     // pictureUrl: KFfeel.value.join(','), //附件路径
  //   };
  // }

  if (Modified.length) {
    // 如果有修改过包件信息执行
    Modified.forEach(item => {
      deletePackageInfo.value.push(item); //被修改过的放入删除里面
      console.log(item);
      DataSubmit['packageEntityList'].push({
        // id: $route.query.id,
        number: Modified.length, //数量
        packageCode: item.packageCode, //包件码
        warehouseId: $route.query.warehouseId == '/' ? '' : $route.query.warehouseId, //仓库ID
        waybillNumber: item.waybillNumber, //运单号
        brandName: item.brandName, //品牌
        orderCode: item.orderCode, //订单自编码
      });
    });
  }

  let addedImages = Indexform.value['packageImage'].filter(
    image => !NewImageAddress.value.some(existingImage => existingImage.url === image.url)
  );

  // 添加的图片图片类型:10运损,20窜货
  if (SelectType.value == '1' || SelectType.value == '3') {
    if (addedImages.length) {
      addedImages.forEach(item => {
        DataSubmit['decreaseImageEntityList'].push({
          imageType: SelectType.value == '1' ? 10 : SelectType.value == '3' ? 20 : '',
          imageName: item.name,
          imagePath: item.response.data.link,
        });
      });
    }
  }

  // 取消的图片
  if (SelectType.value == '1' || SelectType.value == '3') {
    if (unDecreaseImageEntityList.value.length) {
      unDecreaseImageEntityList.value.forEach(item => {
        DataSubmit['unDecreaseImageEntityList'].push(item.id);
      });
    }
  }

  // 移除的包件ID

  if (deletePackageInfo.value.length) {
    console.log(deletePackageInfo.value, '被删除的包件');
    // 先判断是否存在有被删除的包件
    DataSubmit['unPpackageEntityList'] = deletePackageInfo.value.map(item => item.id);
    DataSubmit['unPpackageEntityList'] = DataSubmit['unPpackageEntityList'].filter(
      item => item !== undefined
    );
  }

  // 旧的 InitialresponsibleParty

  // 新的  FangAddList

  // 添加的责任方处理
  let modifyresponsibility = FangAddList.value.filter(
    objB =>
      !InitialresponsibleParty.value.some(objA => JSON.stringify(objA) === JSON.stringify(objB))
  );
  console.log(modifyresponsibility, '发送改变的责任方');
  modifyresponsibility.forEach(item => {
    DataSubmit['personResponsibleDTO'].push({
      wordOrderId: $route.query.id, //工单异常ID
      personResponsibleId:
        personResponsibleList.value.find(obj => obj.id == item.personResponsibleName)?.id || null, //责任人ID
      personResponsibleName:
        personResponsibleList.value.find(obj => obj.id == item.personResponsibleName)?.name || null, //责任人名称
      businessId: warehouseData.value.find(obj => obj.value == item.businessName)?.value || null, //责任方ID
      businessName: warehouseData.value.find(obj => obj.value == item.businessName)?.label || null, //责任方名称//责任方名称
      responsibilityRatio: item.responsibilityRatio, //责任比例
      description: item.description, //说明
    });
  });

  // 被移除的责任方处理
  if (unProcessorEntityList.value.length) {
    console.log(ResponsiblepartyData.value, '初始值责任方');
    unProcessorEntityList.value.forEach(item => {
      console.log(item, '循环要被删除的责任方');
      DataSubmit['unPersonResponsibleDTO'].push(
        ResponsiblepartyData.value.find(obj => obj.businessId == item.businessName).id
      );
    });
  }

  // 判断是否处理方发送了改变
  let arraysAreEqual =
    ProcessingParty.value.length === Indexform.value.processor.length &&
    ProcessingParty.value.every(aElement => Indexform.value.processor.includes(aElement));
  console.log(arraysAreEqual, 'arraysAreEqual处理方');
  // 新增的
  let processornewValue = Indexform.value.processor.filter(
    item => !ProcessingParty.value.includes(item)
  );
  console.log(processornewValue, '新增的处理方');
  if (processornewValue.length) {
    processornewValue.forEach(item => {
      DataSubmit['processorEntityList'].push({
        businessName: warehouseData.value.find(obj => obj.value == item).label, //名称
        businessId: warehouseData.value.find(obj => obj.value == item).value, //ID
        workOrderId: $route.query.id == '/' ? '' : $route.query.id, //异常工单ID
        conditions: 1, //状态  1正常  2新增  3取消
        typesOf: 2, //1 责任方 2 处理方
        warehouseId: $route.query.warehouseId == '/' ? '' : $route.query.warehouseId, //仓库ID
        processingStatus: $route.query.ProcessType == '/' ? '' : $route.query.ProcessType, //处理状态 类型 1 待处理 2 已处理
      });
    });
    // 新增处理方要携带调查经过
    DataSubmit.surveyRecordDTO = {
      content: Indexform.value.investigationProcess, //内容'
      workOrderId: $route.query.id == '/' ? '' : $route.query.id, //工单ID
      // pictureUrl: KFfeel.value.join(','), //附件路径
    };
  }

  // 删除的
  let processornremove = ProcessingParty.value.filter(
    item => !Indexform.value.processor.includes(item)
  );
  console.log(processornremove, '被删除的处理方');
  if (processornremove.length) {
    console.log(ProcessingpartyData.value, '准备处理的数据');
    processornremove.forEach(item => {
      let ids = warehouseData.value.find(obj => obj.value == item).value;
      DataSubmit['unProcessorEntityList'].push(
        ProcessingpartyData.value.find(obj => obj.businessId == ids).id
      ); //ID);
    });
  }

  // ProcessingParty.value = JSON.parse(JSON.stringify(Indexform.value.processor)); //拷贝一份处理方

  //   // 完结信息修改
  console.log(CompensationParty.value);
  // 异常工单完结赔款方

  // unCompletionRecipientEntities: [], //取消异常工单完结处理结果受款方
  //  unCompletionRecordEntities:[],//取消异常工单完结的赔款方

  // completionRecordEntitiesData.value; //赔款
  // completionRecipientEntityListData.value; //收款

  if (UncompletionRecipientEntityListData.value.length) {
    // 如果有取消的完结收款执行
    console.log(completionRecipientEntityListData.value, '完结收款');
    // 完结收款取消的收款
    UncompletionRecipientEntityListData.value.forEach(item => {
      console.log(item, '完结取消的受款方');
      DataSubmit['unCompletionRecipientEntities'].push(
        completionRecipientEntityListData.value.find(obj => obj.id == item.id).id
      );
    });
  }

  if (UncompletionRecordEntitiesDat.value.length) {
    // 完结收款取消的赔款
    console.log(completionRecordEntitiesData.value, '完结赔款');
    UncompletionRecordEntitiesDat.value.forEach(item => {
      console.log(item, '完结取消的赔款方');
      DataSubmit['unCompletionRecordEntities'].push(
        completionRecordEntitiesData.value.find(obj => obj.id == item.id).id
      );
    });
  }

  // completionRecordEntitiesData.value; //赔款方
  // completionRecipientEntityListData.value;//受款方

  // 这里处理新增的赔款方和受款方

  let CompletedModificationsData = CompensationParty.value.filter(itemB => {
    return !CompletionInformation.value.some(itemA => {
      return itemB.name === itemA.name;
    });
  });
  console.log(CompletedModificationsData, '新增或者修改的数据');
  console.log(CompletionInformation.value, '完结收款赔款累计信息');

  // 有新增或者有修改的完结收赔款信息
  if (CompletedModificationsData.length) {
    CompletedModificationsData.forEach(item => {
      if (item.state == 0) {
        // 赔款方
        DataSubmit['completionRecordEntities'].push({
          indemnitor: item.name, // 赔款方
          reason: item.reason, // 原因
          money: Number(item.num), // 金额
          // reasonArbitration: item.reason, // 说明
          workOrderId: $route.query.id, // 异常工单
          // warehouseId: $route.query.warehouseId == '/' ? '' : $route.query.warehouseId, // 仓库ID
          warehouseId: item.warehouseId, //责任仓库
          personResponsibleList: item.personResponsibleList, //责任人
        });
      } else {
        DataSubmit['completionRecipientEntities'].push({
          recipient: item.name, // 受款方
          reasonReceivingPayment: item.reason, // 原因
          money: Number(item.num), // 金额
          workOrderNumber: $route.query.workOrderNumber, // 工单号
          responsibleParty: FangAddList.value
            .map(aItem =>
              warehouseData.value
                .filter(bItem => bItem.value === aItem.businessName)
                .map(match => match.label)
                .join(',')
            )
            .join(','),
          warehouseId: $route.query.warehouseId == '/' ? '' : $route.query.warehouseId, // 仓库ID
          workOrderId: $route.query.id, //异常工单
        });
      }
    });
  }

  // 支付方式
  DataSubmit.aftersalesProcessingResultsDTO['compensationMethod'] = ProcessingList.value
    .map(item => item.text)
    .join(',');

  DataSubmit.aftersalesProcessingResultsDTO['processingMoneyEntityList'] = ProcessingList.value
    .map(item => {
      console.log(item);
      let match = ProcessingResults.value.find(element => element.dictValue == item.name);
      if (match) {
        let paymentMethodMatch = Paymentmethod.value.find(
          paymentMethod => paymentMethod.dictKey == item.payment
        );
        return {
          resultType: match.dictKey, //赔方式的key
          money: item.input, //金额
          typesOf: 1, //固定参数
          compensationMethod: paymentMethodMatch ? paymentMethodMatch.dictKey : '',
          compensationMethodName: paymentMethodMatch ? paymentMethodMatch.dictValue : '',
          resultName: item.name, //处理结果名字
          paymentUnit: item.paymentUnit, //支付单位
        };
      } else {
        return null;
      }
    })
    .filter(item => item !== null);

  //移除的货损图片
  DataSubmit = removeEmptyProperties(DataSubmit);
  console.log(DataSubmit, '处理好的数据');
  $_modifyData(DataSubmit)
    .then(res => {
      console.log(res, '编辑成功返回值');
      ElMessage({
        message: res.data.msg,
        type: 'success',
      });
      if (res.data.code == 200) {
        $router.push({
          path: '/aftersales/aftersalesWorkOrderInfo',
          query: {
            id: $route.query.id,
            name: $route.query.workOrderNumber + '-信息查看',
            warehouseId: $route.query.warehouseId,
            workOrderNumber: $route.query.workOrderNumber, //添加异常记录包条码
            businessId: $route.query.businessId,
            ProcessType: $route.query.ProcessType,
          },
        });
        AddressClosed('/aftersales/aftersalesWorkOrdermodify');
      }
    })
    .catch(error => {
      ElMessage({
        message: res.data.msg,
        type: 'success',
      });
    });
};

// 客服仲裁完结
const Arbitrationcompleted = () => {
  if (Processingresults.value) {
    // 理赔金额未出编辑
    // 处理结果编辑
    let data = {
      id: $route.query.id,
      // workOrderId: $route.query.id, //异常工单ID
      resultDescription:Indexform.value.resultDescription,//处理结果说明
      aftersalesProcessingResultsDTO: {
        resultDescription:Indexform.value.resultDescription,//处理结果说明
        id:$route.query.subId,
      },
    };
    data.aftersalesProcessingResultsDTO['processingMoneyEntityList'] = ProcessingList.value
      .map(item => {
        console.log(item);
        let match = ProcessingResults.value.find(element => element.dictValue == item.name);
        if (match) {
          let paymentMethodMatch = Paymentmethod.value.find(
            paymentMethod => paymentMethod.dictKey == item.payment
          );
          return {
            resultType: match.dictKey, //赔方式的key
            money: item.input, //金额
            typesOf: 1, //固定参数
            compensationMethod: paymentMethodMatch ? paymentMethodMatch.dictKey : '',
            compensationMethodName: paymentMethodMatch ? paymentMethodMatch.dictValue : '',
            resultName: item.name, //处理结果名字
            paymentUnit: item.paymentUnit, //支付单位
            id:item.id, //id
            compensationTime:item.compensationTime,//时间
          };
        } else {
          return null;
        }
      })
      .filter(item => item !== null);

    // 总金额
    let sum = 0; //金额总计
    for (let i = 0; i < ProcessingList.value.length; i++) {
      sum = computeNumber(sum, '+', ProcessingList.value[i].input).result;
    }
    data.aftersalesProcessingResultsDTO.money = sum; //金额汇总
    data.aftersalesProcessingResultsDTO['resultType'] = ProcessingList.value
      .map(item => item.name)
      .join(','); //处理结果说明文字拼接
      data.aftersalesProcessingResultsDTO['compensationMethod'] = ProcessingList.value
      .map(item => item.text)
      .join(',');
    console.log(data, '编辑后的数据');
    $_addProcessingResults(data).then(res=>{
      console.log(res, '理赔编辑成功返回值');
      ElMessage({
          message: res.data.msg,
          type: 'success',
        });
        if (res.data.code == 200) {
          $router.push({
            path: '/aftersales/aftersalesWorkOrder',
          });
          AddressClosed('/aftersales/aftersalesWorkOrdermodify'); //关闭当前页面
        }
    })  .catch(error => {
        ElMessage({
          message: res.data.msg,
          type: 'success',
        });
      });
    return;
  }
// 申诉只修改完结信息
  if (Appealeditor.value == 'appeal') {
    // 表示当前是申诉状态,只修改完结信息
    let data = {
      completionRecipientEntities: [], //处理结果受款方
      completionRecordEntities: [], //处理结果赔款方
      typesOf: '1', //申诉完结编辑新增标识
      reasonArbitration: Indexform.value.arbitrate, //仲裁原因
      appealId: $route.query.appealID,
      id: $route.query.id,
      workOrderId: $route.query.id, //异常工单ID（这里是workOrderId）
    };

    data['completionRecordEntities'] = CompensationParty.value
      .filter(item => item.state === 0) // 先筛选出状态为 0 的项
      .map(item => {
        return {
          indemnitor: item.name, // 赔款方
          reason: item.reason, // 原因
          money: Number(item.num), // 金额
          reasonArbitration: Indexform.value.arbitrate, //仲裁原因
          workOrderId: $route.query.id, // 异常工单
          warehouseId: item.warehouseId, //仓库ID
          compensationPersonnel: item.personResponsibleList, //责任人
          explains:item.reason,//说明（页面不展示）
        };
      });
    data['completionRecipientEntities'] = CompensationParty.value
      .filter(item => item.state === 1) // 先筛选出状态为 1 的项
      .map(item => {
        return {
          recipient: item.name, // 受款方
          reasonReceivingPayment: item.reason, // 原因
          money: Number(item.num), // 金额
          workOrderNumber: $route.query.workOrderNumber, // 工单号
          responsibleParty: FangAddList.value
            .map(aItem =>
              warehouseData.value
                .filter(bItem => bItem.value === aItem.businessName)
                .map(match => match.label)
                .join(',')
            )
            .join(','),
          warehouseId: $route.query.warehouseId == '/' ? '' : $route.query.warehouseId, // 仓库ID
          workOrderId: $route.query.id, //异常工单
        };
      });
    console.log(data, '处理好的值');
    editloading.value = true; //开启加载效果
    $_updateCompletionEnd(data).then(res => {
        console.log(res, '完结编辑');
        if (res.data.code == 200) {
          ElMessage({
            message: res.data.msg,
            type: 'success',
          });
          $store.commit('DEL_TAG_CURRENT'); //关闭当前页面
          $router.push({
            //跳转到首页
            path: '/aftersales/aftersalesWorkOrder',
          });
          editloading.value = false; //关闭加载效果
        }
      })
      .catch(res => {
        editloading.value = false; //关闭加载效果
      });
    return;
    // 下面不执行
  }

  let data = {
    id: $route.query.id,
    completionRecipientEntities: [], //处理结果受款方
    completionRecordEntities: [], //处理结果赔款方
    reasonArbitration: Indexform.value.arbitrate, //仲裁原因
    aftersalesProcessingResultsDTO: {
      workOrderId: $route.query.id, //异常工单ID
    },
    assignList: [],
  };
  data.aftersalesProcessingResultsDTO.workOrderId = $route.query.id; //异常工单ID
  data['assignList'].push($route.query.id);
  data['completionRecordEntities'] = CompensationParty.value
    .filter(item => item.state === 0) // 先筛选出状态为 0 的项
    .map(item => {
      return {
        indemnitor: item.name, // 赔款方
        reason: item.reason, // 原因
        money: Number(item.num), // 金额
        reasonArbitration: item.reason, // 说明
        workOrderId: $route.query.id, // 异常工单
        warehouseId: item.warehouseId, //仓库ID
        personResponsibleList: item.personResponsibleList, //责任人
        explains:item.reason,//说明（页面不展示）
      };
    });

  data['completionRecipientEntities'] = CompensationParty.value
    .filter(item => item.state === 1) // 先筛选出状态为 1 的项
    .map(item => {
      return {
        recipient: item.name, // 受款方
        reasonReceivingPayment: item.reason, // 原因
        money: Number(item.num), // 金额
        workOrderNumber: $route.query.workOrderNumber, // 工单号
        responsibleParty: FangAddList.value
          .map(aItem =>
            warehouseData.value
              .filter(bItem => bItem.value === aItem.businessName)
              .map(match => match.label)
              .join(',')
          )
          .join(','),
        warehouseId: $route.query.warehouseId == '/' ? '' : $route.query.warehouseId, // 仓库ID
        workOrderId: $route.query.id, //异常工单
      };
    });

  // 处理结果

  data.aftersalesProcessingResultsDTO['processingMoneyEntityList'] = ProcessingList.value
    .map(item => {
      console.log(item);
      let match = ProcessingResults.value.find(element => element.dictValue == item.name);
      if (match) {
        let paymentMethodMatch = Paymentmethod.value.find(
          paymentMethod => paymentMethod.dictKey == item.payment
        );
        return {
          resultType: match.dictKey, //赔方式的key
          money: item.input, //金额
          typesOf: 1, //固定参数
          compensationMethod: paymentMethodMatch ? paymentMethodMatch.dictKey : '',
          compensationMethodName: paymentMethodMatch ? paymentMethodMatch.dictValue : '',
          resultName: item.name, //处理结果名字
          paymentUnit: item.paymentUnit, //支付单位
          id:item.id,//当前id
        };
      } else {
        return null;
      }
    })
    .filter(item => item !== null);

  // 总金额
  let sum = 0; //金额总计
  for (let i = 0; i < ProcessingList.value.length; i++) {
    sum = computeNumber(sum, '+', ProcessingList.value[i].input).result;
  }
  data.aftersalesProcessingResultsDTO.money = sum; //金额汇总
  console.log(data, '处理好的值');
  $_arbitrateEnd(data).then(res => {
    console.log(res, '处理结果');
    ElMessage({
      message: res.data.msg,
      type: 'success',
    });
    if (res.data.code == 200) {
      $router.push('/aftersales/aftersalesWorkOrder'); //打回成功跳转到列表
      AddressClosed('/aftersales/aftersalesWorkOrdermodify');///删除当前页面
    }
  });
};

// 少货件数对应事件
const ShortageTtems = val => {
  ShortageList.value = []; //进入之前重置参数
  const pattern = /\s+/g;
  const result = val.replace(pattern, '');
  console.log(result); // 输出 "33"
  Indexform.value.number = result;
  if (Indexform.value.number > 1) {
    ShortageState.value = true; //数量大于1，开启弹窗输入
  }
  for (let i = 0; i < val; i++) {
    ShortageList.value.push({
      number: i + 1, //件数
      packageCode: null, //输入框
    });
  }
};
// 少货关闭回调
const ShortageStateFun = () => {
  ShortageList.value.forEach(item => {
    if (item.packageCode == null) {
      Indexform.value.number = null;
    }
  });
};
// 少货按钮取消
const ShortageCancellation = () => {
  Indexform.value.number = null; //少货件数
  ShortageList.value = []; //进入之前重置参数
  ShortageState.value = false; //关闭弹窗
};
// 窜货关闭回调
const fleeingFun = () => {
  fleeingList.value.forEach(item => {
    if (item.packageCode == null) {
      Indexform.value.number = null;
    }
  });
};
// 窜货取消事件
const fleeingCancellation = () => {
  Indexform.value.number = null; //少货件数
  fleeingList.value = []; //进入之前重置参数
  fleeingState.value = false; //关闭弹窗
};
// 窜货输入框
const fleeingTtems = val => {
  fleeingList.value = []; //进入之前重置参数
  const pattern = /\s+/g;
  const result = val.replace(pattern, '');
  console.log(result); // 输出 "33"
  Indexform.value.number = result;
  if (Indexform.value.number > 1) {
    fleeingState.value = true; //数量大于1，开启弹窗输入
  }
  for (let i = 0; i < val; i++) {
    fleeingList.value.push({
      number: i + 1, //件数
      packageCode: null, //输入框
    });
  }
};
// 少货编辑
const moneyBtnA = () => {
  if (!Indexform.value.number) {
    ElMessage({
      message: '请输入少货数量',
      type: 'warning',
    });
    return;
  }
  ShortageState.value = true; //开启弹窗输入
};
// 窜货编辑
const moneyBtnB = () => {
  if (!Indexform.value.number) {
    ElMessage({
      message: '请输入窜货数量',
      type: 'warning',
    });
    return;
  }
  fleeingState.value = true; //开启弹窗输入
};
// 查询包件信息自动回显
const ChangePackageInfo = (val, index) => {
  if(!val){
    return
  }
  PackageInfo.value[index].orderCode = ''; //订单自编码
  PackageInfo.value[index].waybillNumber = ''; //运单号
  PackageInfo.value[index].orderId = ''; //运单号
  PackageInfo.value[index].brandName = ''; //品牌
  let data = {
    packageCode: val,
  };
  $_getAbnormalPackage(data).then(res => {
    console.log(res, '包件信息');
    console.log(res.data.data, '包件信息');
    if (res.data.data.length) {
      const packageData = res.data.data[0];
      PackageInfo.value[index].orderCode = packageData.orderCode; //订单自编码
      PackageInfo.value[index].waybillNumber = packageData.waybillNumber; //运单号
      PackageInfo.value[index].orderId = packageData.orderId; //运单号
      PackageInfo.value[index].brandName = packageData.brandName; //品牌

      PackageInfo.value[index].state = false; //状态

      if (res.data.data.length > 1) {
        HistoricalPackageList.value = res.data.data;
        PackageInfo.value[index].state = true; //状态
      }
    }
    // packageCode; //包件码
    // //订单自编码
    // orderCode: orderId; //运单号
    // workOrderId; //工单id
    // workOrderNumber; //工单名称
    console.log(PackageInfo.value, '处理好的参数');
  });
};

// 查看历史包件
const historicalPackages = val => {
  dialogHistoricalPackage.value = true; //打开历史包件弹窗
  HistorIndex.value = val;
};
// 历史包件确定选择
const HistoricalPackage = val => {
  let info = HistoricalPackageList.value.find(obj => obj.workOrderId == val);
  PackageInfo.value[HistorIndex.value].orderCode = info.orderCode; //订单自编码
  PackageInfo.value[HistorIndex.value].waybillNumber = info.waybillNumber; //运单号
  PackageInfo.value[HistorIndex.value].orderId = info.orderId; //运单号
  PackageInfo.value[HistorIndex.value].brandName = info.brandName; //运单号

  dialogHistoricalPackage.value = false; //关闭历史包件弹窗

  PackageInfo.value[HistorIndex.value].relatedWorkOrdersId = info.workOrderId;
  console.log(PackageInfo.value, '处理好的参数');
};
// 历史包件里面的查看
const ViewPackageDetails = val => {
  if (!val) {
    ElMessage({
      message: '请选择要查看的数据',
      type: 'warning',
    });
    return;
  }
  console.log(val);
  let info = HistoricalPackageList.value.find(obj => obj.workOrderId == val);
  console.log(info, '筛选的值');
  $router.push({
    path: '/aftersales/aftersalesWorkOrderInfo',
    query: {
      id: info.workOrderId,
      name: info.workOrderId + '-信息查看',
      routerState: 'view',
    },
  });
  dialogHistoricalPackage.value = false; //打开历史包件弹窗
};
</script>

<style scoped lang="scss">
.IndexFrom {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;

  .el-form-item {
    height: 46px;
    display: flex;
    align-items: center;
    margin: 0;
    margin-bottom: 18px;
    flex: 1 0 30%;
    :deep(.el-form-item__label) {
      width: 100px !important;
      justify-content: flex-start;
    }
  }
  :deep(.el-form-item__content) {
    height: 100%;
    width: 70% !important;
    flex: none;
    .el-input {
      height: 100% !important;
      display: flex;
      align-items: center;
    }
  }
  .el-input__wrapper {
    height: 32px !important;
  }
  :deep(.el-input) {
    width: 100% !important;
  }
  :deep(.el-input__wrapper) {
    height: 30px !important;
  }
  :deep(.el-select) {
    width: 100%;
  }
  :deep(.el-form-item__label) {
    margin-left: 20px;
  }
}
.el_clzr {
  margin-top: 40px;

  :deep(.el-select) {
    width: 100%;
  }
  :deep(.el-input) {
    height: 38px;
  }
  :deep(.el-form-item__label) {
    margin-left: 20px;
    font-size: 14px;
    width: 100px !important;
    justify-content: flex-start;
  }
  .el-form-item {
    margin: 0;
    margin-bottom: 34px;
  }
  :deep(.el-input__wrapper) {
    height: 35px !important;
  }
  :deep(.el-form-item__content) {
    height: 100%;
    width: 90% !important;
    flex: none;
    .el-input {
      height: 100% !important;
      display: flex;
      align-items: center;
    }
  }
}
.Transport_damage_photos {
  display: flex;
  padding: 0 15px;
  margin-top: 20px;
  .title {
    width: 100px;
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
  }
}
.dialog-footer {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding: 0 10px;
  box-sizing: border-box;
  padding-right: 36px;
}
.investigate {
  :deep(.el-form-item__content) {
    width: 90% !important;
    box-sizing: border-box;
  }
}
.ShortageStatenum {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  .title {
    width: 80px;
  }
  .remove {
    width: 47px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ff0000;
  }
}
.moneyNum {
  display: flex;
  flex: 1;
  .el_btn {
    width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
    margin-left: 3px;
    border-radius: 4px;
    cursor: pointer;
  }
}
.ResponsibilityBox {
  width: 100%;
  display: flex;
  flex-direction: column;
  .leftbox {
    width: 80%;
    display: flex;
    justify-content: space-between;
    .el_zb {
      width: 140px;
      margin-right: 50px;
      text-align: right;
      :deep(.el-input) {
        margin-left: 10px;
        text-align: right;
      }
    }
  }
  .maxBox {
    display: flex;
    align-items: center;
    width: 30%;
    margin-right: 16px;
    font-size: 14px;
    .title {
      width: 80px;
      font-size: 14px;
      color: #606266;
    }
    .el-select {
      width: 100%;
    }
    :deep(.el-form-item) {
      margin-bottom: 0;
    }
  }
  .el-btn {
    margin-left: 5%;
    border: none;
  }
  .el_btbox {
    display: flex;
    margin-top: 10px;
  }
}
.ResponsibilityBoxS {
  width: 100%;
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
  .leftbox {
    width: 80%;
    display: flex;
    justify-content: space-between;
  }
  .maxBox {
    display: flex;
    align-items: center;
    width: 30%;
    margin-right: 20px;
    .title {
      width: 140px;
      color: #606266;
      font-size: 14px;
    }
    .el-select {
      width: 100%;
    }
  }
  .el-btn {
    margin-left: 5%;
    border: none;
  }
  .el_btbox {
    display: flex;
    margin-top: 10px;
  }
}
.PackageInformation {
  margin-bottom: 10px;
}
.NumTotal {
  width: 30%;
  margin-top: 16px;
  display: flex;
  align-items: center;
  span {
    width: 120px;
    font-size: 14px;
  }
}
.Proportion {
  margin-top: 16px;
  .title {
    font-size: 14px;
    color: #606266;
  }
}

:deep(.is-active) {
  border-bottom: 1px solid #e4e7ed !important;
}
.topClass {
  :deep(.el-tabs__content) {
    padding: 0;
  }
}
.foot_btn {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(0, -50%);
  width: 100%;
  height: 40px;
  background-color: #ffffff;
  border-top: 1px solid #fff;
  box-shadow: 3px -1px 1px #ccc;
  display: flex;
  align-items: center;
  padding-left: 10px;
}
:deep(.el-card__body) {
  margin-bottom: 50px;
}
.ProcessingResults {
  width: 100%;
  min-height: 260px;
  border: 1px solid #ccc;
  position: relative;
  padding: 26px;
  box-sizing: border-box;
  margin-top: 35px;
  color: #606266;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-bottom: 16px;
  .title {
    position: absolute;
    top: -20px;
    left: 20px;
    font-size: 26px;
    background-color: #fff;
  }
  .Listadmiration {
    display: flex;
    flex-wrap: wrap;
    margin-top: 26px;
    justify-content: space-between;
    .name {
      display: flex;
      margin-bottom: 20px;
      height: 30px;
      width: 48%;
      :deep(.el-input-number) {
        width: 230px;
      }
      span {
        display: block;
        width: 30%;
        color: #606266;
        font-size: 16px;
      }
    }
  }

  .lptime,
  .ZFlptime {
    display: flex;
    .name {
      width: 10%;
      color: #606266;
    }
    .el-input {
      width: auto;
    }
    :deep(.el-input--prefix) {
      width: 200px;
    }
  }
  .ZFlptime {
    margin: 10px 0;
  }
  .Paymentname {
    width: 180px;
    margin: 0 10px;
  }
}
.el_handle {
  margin-top: 16px;
  :deep(.el-select) {
    width: 100%;
  }
}
.lptime {
  height: 30px;
}
.Paymentname {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid #bfbfbf;
  margin-left: 2px;
  border-radius: 4px;
  width: 100px;
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
  width: 100px;
}

.payanindemnity {
  display: flex;
  align-items: center;
  margin-top: 20px;
  .title {
    width: 126px;
    height: 100%;
    display: flex;
    display: block;
    align-items: center;
  }
  .sk_input {
    margin: 0 5px;
    margin-left: 20px;
    height: 30px;
    width: 20%;
  }
  .el-button {
    border: none;
  }
}
.payanindemnity {
  display: flex;
  align-items: center;
  margin-top: 20px;
  .title {
    width: 126px;
    height: 100%;
    display: flex;
    display: block;
    align-items: center;
  }
  .sk_input {
    margin: 0 5px;
    margin-left: 20px;
    width: 20%;
  }
  .el-button {
    border: none;
  }
}
.el_pkLi {
  width: 100%;
  display: flex;
}
.paySum {
  margin-top: 36px;
  font-size: 14px;
  display: flex;
  span {
    margin-right: 30px;
    display: flex;
    align-items: center;
  }
}
:deep(.el-upload-dragger) {
  display: flex;
  align-items: center;
  justify-content: center;
}
:deep(.el-input) {
  height: 100% !important;
}
.el_PaymentUnit {
  display: flex;
  align-items: center;
  margin-right: 4px;
  span {
    display: flex;
    width: 80px !important;
    align-items: center;
  }
  :deep(.el-input) {
    width: 150px;
  }
}
</style>
