dgy

<!--
 * @Author: your name
 * @Date: 2021-05-19 09:34:05
 * @LastEditTime: 2021-08-10 18:40:05
 * @LastEditors: Please set LastEditors
 * @Description: 异常管理
 * @FilePath: \shiva-trtms-air-service-web\src\views\airLink\exceptionManage.vue
-->
<template>
  <div class="sfair-module">
    <resourceControl v-if="showIsControl" />
    <!-- UI改造增加-偏好设置按钮 , 可直接复制 -->
    <sfair-page-config
      @click="showConfig"
      :class="[pageConfigBtnClass]"
    ></sfair-page-config>

    <sfair-normal-config
      :dataId="'condition'"
      :moduleCode="conditionConfigDataKey"
      :sysCode="sysCode"
      :more="searchMoreConfig"
      :normal="searchNormalConfig"
      :showConfig.sync="conditionConfigShow"
      @sure="switchItem"
      @moreToggle="moreToggle"
      @heightChange="conditionChange"
      class="query-condition"
      :class="[conditionToggleBtnClass]"
    >
      <!-- 查询条件 -->
      <el-form
        class="searchform1"
        :inline="true"
        :model="searchListForm"
        :label-position="'top'"
        ref="searchListForm"
        label-width="210px"
      >
        <template v-for="item in conditions">
          <el-form-item
            v-if="item.prop === 'deptCode' && isVisible(item)"
            :key="item.prop"
            class="label_required"
            label="网点"
            prop="deptCode"
            label-width="120px"
          >
            <SelectCodeMultiple
              v-model="searchListForm.departDeptCode"
              @change="changDeptCodeEvent"
            ></SelectCodeMultiple>
          </el-form-item>

          <el-form-item
            label="异常类型:"
            v-if="item.prop === 'exceptionTypeCode' && isVisible(item)"
            :key="item.prop"
            prop="exceptionTypeCode"
          >
            <el-select v-model="searchListForm.exceptionTypeCode" clearable>
              <el-option
                v-for="(item, index) in errorTypeOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="item.prop === 'exceptionCode' && isVisible(item)"
            label="异常ID:"
            :key="item.prop"
          >
            <el-input
              v-model="searchListForm.exceptionCode"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item
            label="是否升级调度:"
            v-if="item.prop === 'isUpgradeOrder' && isVisible(item)"
            :key="item.prop"
          >
            <el-select v-model="searchListForm.isUpgradeOrder" clearable>
              <el-option
                v-for="(item, index) in isUpOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="异常开始日期:"
            label-width="130px"
            class="label_required"
            v-if="item.prop === 'exceptionDateStart' && isVisible(item)"
            :key="item.prop"
          >
            <el-date-picker
              v-model="searchListForm.exceptionDateStart"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item
            label="异常结束日期:"
            label-width="130px"
            class="label_required"
            v-if="item.prop === 'exceptionDateEnd' && isVisible(item)"
            :key="item.prop"
          >
            <el-date-picker
              v-model="searchListForm.exceptionDateEnd"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item
            label="始发地:"
            v-if="item.prop === 'departCityCode' && isVisible(item)"
            :key="item.prop"
          >
            <el-select
              v-model="searchListForm.departCityCode"
              multiple
              clearable
              filterable
              :multiple-limit="5"
            >
              <el-option
                v-for="(item, index) in cityCodeOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="目的地:"
            v-if="item.prop === 'arriveCityCode' && isVisible(item)"
            :key="item.prop"
          >
            <el-select
              v-model="searchListForm.arriveCityCode"
              clearable
              filterable
              multiple
              :multiple-limit="5"
            >
              <el-option
                v-for="(item, index) in cityCodeOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="班次:"
            v-if="item.prop === 'sendBatch' && isVisible(item)"
            :key="item.prop"
          >
            <el-select
              v-model="searchListForm.sendBatch"
              @click.native="getExceptionAirnoOptions(0)"
              clearable
              filterable
            >
              <el-option
                v-for="item in sendBatchList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item
            label="调度处理结果:"
            v-if="item.prop === 'processStatus' && isVisible(item)"
            :key="item.prop"
          >
            <el-select v-model="searchListForm.processStatus" clearable>
              <el-option
                v-for="(item, index) in resultTypeOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </template>
      </el-form>
    </sfair-normal-config>

    <!-- UI改造增加-按钮组 , 可直接复制 - start -->
    <sfair-btns
      :sysCode="sysCode"
      :dataId="'list'"
      :moduleCode="conditionConfigDataKey"
      :showConfig.sync="butConfigShow"
      @click="btnClick"
      @heightChange="btnChange"
      :normal="btns"
      :more="moreBtns"
      class="sfair-first-level"
    >
    </sfair-btns>

    <sfair-list-config
      :height="tableHeight"
      ref="listConfig"
      @sure="tableConfigChange"
      :showConfig.sync="listConfigShow"
      :isCumputeHeight="false"
      :sysCode="sysCode"
      :moduleCode="listConfigDataKey"
      :dataId="'list'"
      :left="colLeftConfig"
      :right="colRightConfig"
      :normal="colNormalConfig"
      class="sfair-first-level"
    >
      <el-table
        class="data-list"
        v-loading="loadind"
        :data="dataList"
        ref="multipleTable1"
        border
        highlight-current-row
        :height="'calc(100%)'"
        @selection-change="changeSelectedList"
        :row-class-name="setRowExpand"
      >
        <el-table-column type="expand">
          <template slot-scope="scope">
            <el-table
              :data="scope.row.deliverExceptionsList"
              style="width: calc(100% - 47px); margin-left: 47px"
              class="data-list"
            >
              <el-table-column
                prop="tranferDate"
                label="改配航班日期"
                :formatter="tranferDateFormat"
                width="100"
              ></el-table-column>
              <el-table-column
                prop="tranferDepartCityCode"
                label="改配始发地"
                :formatter="tranferDepartCityNameShow"
                width="140"
              ></el-table-column>
              <el-table-column
                prop="tranferArriveCityCode"
                label="改配目的地"
                :formatter="tranferArriveCityNameShow"
                width="120"
              ></el-table-column>
              <el-table-column
                prop="tranferCapacityName"
                label="改配航班号"
                width="110"
              ></el-table-column>
              <el-table-column
                prop="tranferScheduleFlightType"
                label="改配航班时效"
                :formatter="tranferScheduleFlightTypeNameShow"
                width="140"
              ></el-table-column>
              <el-table-column
                prop="tranferDepartTm"
                label="改配计划起飞时间"
                :formatter="tranferDepartTmFormat"
                width="140"
              ></el-table-column>
              <el-table-column
                prop="tranferArriveTm"
                label="改配计划落地时间"
                :formatter="tranferArriveTmFormat"
                width="140"
              ></el-table-column>
              <el-table-column
                prop="tranferScheduleFlightType"
                label="改配时效描述"
                :formatter="tranferScheduleFlightTypeFormat"
                width="340"
              >
              </el-table-column>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column type="selection" align="center" width="50" prop="id" />
        <el-table-column
          prop="exceptionCode"
          label="异常ID"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="exceptionTypeCode"
          label="异常类型"
          width="100"
          align="center"
          :formatter="exceptionTypeFormat"
        >
        </el-table-column>
        <el-table-column
          prop="exceptionDate"
          label="异常日期"
          width="110"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="processStatus"
          label="是否升级调度"
          align="center"
          width="110"
          :formatter="isUpOrder"
        >
        </el-table-column>
        <el-table-column
          prop="processStatus"
          label="调度处理结果"
          width="110"
          align="center"
          :formatter="getProcessStatusReason"
        >
        </el-table-column>
        <el-table-column
          prop="orderCode"
          label="调令编号"
          width="140"
          align="center"
        >
          <template slot-scope="scope">
            <el-link
              type="primary"
              :underline="true"
              style="font-size: 12px; font-weight: normal"
              @click.native="queryOrderDetailBtn(scope.row)"
              >{{ scope.row.orderCode }}</el-link
            >
          </template>
        </el-table-column>
        <el-table-column
          prop="departAreaCode"
          label="地区"
          align="center"
          width="100"
        >
        </el-table-column>
        <el-table-column
          prop="departDeptCode"
          label="网点"
          align="center"
          width="120"
        >
        </el-table-column>
        <el-table-column
          prop="departCityCode"
          label="始发地"
          align="center"
          width="120"
          :formatter="departCityNameShow"
        >
        </el-table-column>
        <el-table-column
          prop="arriveCityCode"
          label="目的地"
          align="center"
          width="120"
          :formatter="arriveCityNameShow"
        >
        </el-table-column>
        <el-table-column
          prop="sendBatch"
          label="发货班次"
          width="100"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="capacityName"
          label="异常航班"
          align="center"
          :formatter="capacityNameMainShow"
        >
        </el-table-column>
        <el-table-column
          prop="scheduleFlightType"
          label="异常航班时效类型"
          align="center"
          width="140"
          :formatter="scheduleFlightTypeMainNameShow"
        >
        </el-table-column>
        <el-table-column prop="exceptionNums" label="异常件数" align="center">
        </el-table-column>
        <el-table-column
          prop="phWeight"
          label="普货(KG)"
          width="100"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="sxWeight"
          label="生鲜(KG)"
          width="100"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="xhWeight"
          label="鲜活(KG)"
          width="100"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="taWeight"
          label="TA(KG)"
          width="100"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="carsNo"
          label="笼号或车标号"
          width="120"
          align="center"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column prop="operatingResult" label="驳回原因" align="center">
          <template slot-scope="scope">
            <el-popover placement="top-start" width="400" trigger="hover">
              <p>{{ scope.row.operatingResult }}</p>
              <div class="oneLine" slot="reference">
                {{ scope.row.operatingResult }}
              </div>
            </el-popover>
          </template>
        </el-table-column>

        <el-table-column prop="exceptionDesc" label="备注" align="center">
          <template slot-scope="scope">
            <el-popover placement="top-start" width="400" trigger="hover">
              <p>{{ scope.row.exceptionDesc }}</p>
              <div class="oneLine" slot="reference">
                {{ scope.row.exceptionDesc }}
              </div>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column
          prop="reportDate"
          label="异常升级调度时间 "
          width="150"
          align="center"
          :formatter="reportDateFormat"
        >
        </el-table-column>
        <el-table-column
          prop="reportEmpno"
          label="升级调度人"
          align="center"
          width="100"
          :formatter="reportEmpNoFormat"
        >
        </el-table-column>
        <el-table-column
          prop="modifiedEmpCode"
          label="调度处理人"
          width="100"
          align="center"
          :formatter="orderProcessEmp"
        >
        </el-table-column>
        <el-table-column
          prop="modifiedTm"
          label="调度处理时间"
          width="170"
          align="center"
          :formatter="orderProcessDate"
        >
        </el-table-column>
      </el-table>
    </sfair-list-config>

    <!-- UI改造增加-分页栏 , 先直接复制,再修改属性和事件,默认每页数量为20 -->
    <sfair-pagination
      @sizeChange="pageSizeChange"
      @currentChange="handleCurrentChangePage"
      :currentPage.sync="Pagination.currentPage"
      :pageSize.sync="Pagination.pageSize"
      :total="Pagination.totalSize"
      class="sfair-first-level"
    >
    </sfair-pagination>

    <!-- 双击新增异常||修改 -->
    <el-dialog
      :title="DialogTitle"
      :visible.sync="DialogVisible"
      width="640px"
      :close-on-click-modal="false"
      :before-close="closeProcessForm"
      class="sfair-dialog"
    >
      <el-form
        :inline="true"
        label-width="100px"
        :model="ProcessForm"
        ref="ProcessForm"
        class="searchform1"
      >
        <div class="operateBtn" style="margin-bottom: 20px">
          <el-button
            size="mini"
            type="main"
            @click="
              ProcessType == 'update' ? modifyException() : saveException()
            "
            >保 存</el-button
          >
          <el-button
            size="mini"
            type="operate"
            @click="ProcessFormReset('ProcessForm')"
            >重 置</el-button
          >
          <el-button
            size="mini"
            type="operate"
            @click="
              ProcessType == 'update' ? modifyAndUpgrade() : saveAndUpgrade()
            "
            >上报&升级调度</el-button
          >
        </div>

        <el-row>
          <el-form-item
            label="异常日期"
            prop="exceptionDate"
            class="label_required"
          >
            <div>
              <el-date-picker
                v-model="ProcessForm.exceptionDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                :disabled="ProcessType == 'update'"
                :picker-options="addExceptionPickerOptions"
              >
              </el-date-picker>
            </div>
          </el-form-item>

          <el-form-item
            label="异常类型"
            prop="exceptionTypeCode"
            class="label_required"
          >
            <el-select
              v-model="ProcessForm.exceptionTypeCode"
              :placeholder="$t('common.selectPlaceholder')"
              clearable
              disabled
            >
              <el-option
                v-for="(item, index) in exceptionTypeOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item
            label="始发地"
            prop="departCityCode"
            class="label_required"
          >
            <el-select
              v-model="ProcessForm.departCityCode"
              clearable
              filterable
              disabled
            >
              <el-option
                v-for="(item, index) in cityCodeOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="目的地"
            prop="arriveCityCode"
            class="label_required"
          >
            <el-select
              v-model="ProcessForm.arriveCityCode"
              clearable
              filterable
            >
              <el-option
                v-for="(item, index) in cityCodeOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="班次" prop="sendBatch" class="label_required">
            <el-select
              v-model="ProcessForm.sendBatch"
              @click.native="getExceptionAirnoOptions(1)"
              clearable
            >
              <el-option
                v-for="(item, index) in sendBatchList"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="异常件数"
            prop="exceptionNums"
            class="label_required"
          >
            <el-input
              v-model="ProcessForm.exceptionNums"
              v-limit-input-number="0"
            ></el-input>
          </el-form-item>
        </el-row>

        <el-row>
          <el-form-item label="普货(KG)" prop="phWeight" class="label_required">
            <el-input
              v-model="ProcessForm.phWeight"
              v-limit-input-number="0"
            ></el-input>
          </el-form-item>
          <el-form-item label="生鲜(KG)" prop="sxWeight" class="label_required">
            <el-input
              v-model="ProcessForm.sxWeight"
              v-limit-input-number="0"
            ></el-input>
          </el-form-item>
        </el-row>

        <el-row>
          <el-form-item label="鲜活(KG)" prop="xhWeight" class="label_required">
            <el-input
              v-model="ProcessForm.xhWeight"
              v-limit-input-number="0"
            ></el-input>
          </el-form-item>
          <el-form-item label="TA(KG)" prop="taWeight" class="label_required">
            <el-input
              v-model="ProcessForm.taWeight"
              v-limit-input-number="0"
              max="99999.99"
              min="0"
            ></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="笼号或车标号" prop="carsNo">
            <el-input
              v-model="ProcessForm.carsNo"
              maxlength="12"
              oninput="value=value.replace(/[^\d]/g,'')"
            ></el-input>
          </el-form-item>
          <el-form-item label="备注" prop="exceptionDesc">
            <el-input
              type="textarea"
              label="备注"
              prop="exceptionDesc"
              :autosize="{ minRows: 2, maxRows: 4 }"
              placeholder="请输入内容"
              v-model="ProcessForm.exceptionDesc"
              maxlength="300"
            >
            </el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </el-dialog>

    <!-- 转调令 -->
    <el-dialog
      title="转调令"
      :visible.sync="this.changeOrderFormDialogVisible"
      width="90%"
      :close-on-click-modal="false"
      :before-close="closeOrderForm"
      class="sfair-dialog"
      custom-class="orderDialog"
    >
      <el-form
        :inline="true"
        label-width="120px"
        :model="OrderForm"
        ref="OrderForm"
        class="searchform1"
      >
        <el-row v-if="this.ProcessType != 'query'">
          <el-button @click="saveOrderBtn()" type="main" size="mini"
            >保 存</el-button
          >
          <el-button @click="formReset('OrderForm')" type="operate" size="mini"
            >重 置</el-button
          >
          <el-button type="main" @click="saveAndReport" size="mini"
            >保存&发布</el-button
          >
        </el-row>

        <!--标题-->
        <div
          style="
            padding: 10px 20px;
            width: 60%;
            margin: 0 auto;
            text-align: center;
            margin-bottom: 20;
          "
        >
          <el-input
            style="height: 40px; line-height: 40px; font-size: 20px"
            :disabled="ProcessType == 'query'"
            v-model="OrderForm.orderTitle"
            placeholder=""
            size="small"
          ></el-input>
        </div>

        <el-row>
          <el-divider>基础信息</el-divider>

          <el-form-item label="调令编号" prop="type" class="label_required">
            <el-input
              v-model="OrderForm.orderCode"
              size="small"
              disabled
            ></el-input>
          </el-form-item>

          <el-form-item label="监控时效" prop="type" class="label_required">
            <el-select
              v-model="OrderForm.timeEffect"
              clearable
              filterable
              disabled
            >
              <el-option
                v-for="(item, index) in monitorTypeOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="环节" prop="type" class="label_required">
            <el-select
              v-model="OrderForm.exceptionType"
              clearable
              filterable
              disabled
              size="small"
            >
              <el-option
                v-for="(item, index) in exceptionTypeSelectOptions"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="签发人"
            prop="businessType"
            class="label_required"
          >
            <el-input
              v-model="OrderForm.issuerEmpCode"
              placeholder="请输入工号"
              @blur="getIssuerEmpInfo"
              size="small"
              :disabled="ProcessType == 'query'"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="签发人电话"
            prop="exceptionNums"
            class="label_required"
          >
            <el-input
              size="small"
              v-model="OrderForm.issuerPhoneNoShow"
              :disabled="ProcessType == 'query'"
              @change="setOrgPhoneNo"
              placeholder=""
              style="cursor: pointer"
              v-if="ProcessType != 'changeorder'"
            >
              <el-button
                slot="suffix"
                type="text"
                class="el-input__icon"
                @mousedown.native="showissuerPhoneNo"
                @mouseup.native="hideissuerPhoneNo"
              >
                <template>
                  <i class="el-icon-view"></i>
                </template>
              </el-button>
            </el-input>
            <el-input
              size="small"
              v-model="OrderForm.issuerPhoneNo"
              :disabled="ProcessType == 'query'"
              placeholder=""
              v-if="ProcessType == 'changeorder'"
            >
            </el-input>
          </el-form-item>

          <el-form-item
            label="异常获悉时间"
            prop="exceptionDate"
            class="label_required"
          >
            <el-date-picker
              v-model="OrderForm.exceptionDate"
              type="datetime"
              value-format="yyyy-MM-dd HH:mm:ss"
              placeholder="选择日期"
              size="small"
              :disabled="ProcessType == 'query'"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label="发布部门" prop="sxWeight" class="label_required">
            <el-input
              v-model="OrderForm.issuingUnit"
              disabled
              size="small"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="发布时间"
            prop="issuingTime"
            class="label_required"
          >
            <el-input
              v-model="OrderForm.issuingTime"
              disabled
              size="small"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="发布人"
            prop="issuingEmpCode"
            class="label_required"
            @blur="getIssuingEmpInfo"
          >
            <el-input
              v-model="OrderForm.issuingEmpCode"
              @blur="getIssuingEmpInfo"
              disabled
              size="small"
            ></el-input>
          </el-form-item>
          <el-form-item
            label=" 发布人电话"
            prop="taWeight"
            class="label_required"
          >
            <el-input
              v-model="OrderForm.issuingPhoneNoShow"
              :disabled="ProcessType == 'query'"
              @change="setIssuingOrgPhoneNo"
              placeholder=""
              style="cursor: pointer"
              v-if="ProcessType != 'changeorder'"
              size="small"
            >
              <el-button
                slot="suffix"
                type="text"
                size="mini"
                class="el-input__icon"
                @mousedown.native="showissuingPhoneNo"
                @mouseup.native="hideissuingPhoneNo"
              >
                <template>
                  <i class="el-icon-view"></i>
                </template>
              </el-button>
            </el-input>

            <el-input
              v-model="OrderForm.issuingPhoneNo"
              :disabled="ProcessType == 'query'"
              placeholder=""
              v-if="ProcessType == 'changeorder'"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <div class="inputinrow">
          <label class="label_required"
            ><span style="color: red">* </span>执行单位</label
          >
          <el-input
            size="small"
            v-model="OrderForm.executableUnit"
            :disabled="ProcessType == 'query'"
          ></el-input>
        </div>
        <div class="inputinrow">
          <label>
            <el-button
              type="operate-text"
              class="label_required"
              @click="showEmailDialog(1)"
              :disabled="ProcessType == 'query'"
              ><span style="color: red">* </span>收件人</el-button
            >
          </label>
          <el-input
            size="small"
            v-model="OrderForm.sendEmailList"
            :disabled="ProcessType == 'query'"
          ></el-input>
        </div>
        <div class="inputinrow">
          <label>
            <el-button
              type="operate-text"
              class="label_required"
              @click="showEmailDialog(2)"
              :disabled="ProcessType == 'query'"
              >抄送人</el-button
            >
          </label>
          <el-input
            size="small"
            v-model="OrderForm.ccEmailList"
            :disabled="ProcessType == 'query'"
          ></el-input>
        </div>

        <div class="inputinrow">
          <label><span style="color: red">* </span>分流说明</label>
          <el-input
            v-model="OrderForm.shuntDesc"
            :disabled="ProcessType == 'query'"
            size="small"
          ></el-input>
        </div>

        <el-row type="flex">
          <el-table
            class="data-list"
            v-loading="loadind"
            :data="orderExceptionTempGridList"
            ref="multipleTableExceptionOrder"
            border
            highlight-current-row
            style="width: 50%"
            :span-method="mergerOrderTable"
          >
            <el-table-column label="异常信息" align="center">
              <el-table-column width="40" align="center">
                <template slot-scope="scope">
                  <el-radio
                    v-model="exceptionOrderRadio"
                    :label="scope.row"
                    @change="clickChange"
                    :disabled="ProcessType == 'query'"
                    ><i></i
                  ></el-radio>
                </template>
              </el-table-column>
              <el-table-column
                prop="exceptionDate"
                label="异常日期"
                width="100"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="exceptionDepartDeptCode"
                label="发货网点"
                width="100"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="exceptionDepartCityCode"
                label="始发地"
                width="90"
                align="center"
                :formatter="exceptionDepartCityCodeFormatter"
              >
              </el-table-column>

              <el-table-column
                prop="exceptionArriveCityCode"
                label="目的地"
                width="90"
                align="center"
                :formatter="exceptionArriveCityCodeFormatter"
              >
              </el-table-column>
              <el-table-column
                prop="exceptionSendBatch"
                label="发出班次"
                width="100"
                align="center"
              >
              </el-table-column>

              <el-table-column
                prop="goodsStowageTypeName"
                label="货物类型"
                width="90"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="exceptionWeight"
                label="缺口量"
                width="90"
                align="center"
              >
              </el-table-column>
            </el-table-column>

            <el-table-column label="分流信息" align="center">
              <el-table-column
                prop="shuntDate"
                label="需求日期"
                width="120"
                align="center"
              >
                <template slot-scope="scope">
                  <el-date-picker
                    v-model="scope.row.shuntDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    size="mini"
                    :disabled="
                      scope.row.dataFrom == 'shunt' || ProcessType == 'query'
                    "
                  ></el-date-picker>
                </template>
              </el-table-column>

              <el-table-column
                prop="departCityCode"
                label="始发地"
                width="100"
                align="center"
              >
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.departCityCode"
                    clearable
                    filterable
                    :disabled="
                      scope.row.dataFrom == 'shunt' || ProcessType == 'query'
                    "
                    size="mini"
                    @change="departCityCodeChangeClear($event, scope)"
                    @visible-change="emptyCityCodeOptionsSet($event, scope, 1)"
                  >
                    <el-option
                      v-for="(item, index) in scope.row
                        .rowDepartCityCodeOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </template>
              </el-table-column>

              <el-table-column
                prop="arriveCityCode"
                label="目的地"
                width="100"
                align="center"
              >
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.arriveCityCode"
                    clearable
                    filterable
                    :disabled="
                      scope.row.dataFrom == 'shunt' || ProcessType == 'query'
                    "
                    size="mini"
                    @visible-change="emptyCityCodeOptionsSet($event, scope, 2)"
                  >
                    <el-option
                      v-for="(item, index) in scope.row
                        .rowArriveCityCodeOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column
                prop="sendBatch"
                label="发出班次"
                width="120"
                align="center"
              >
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.sendBatch"
                    @focus="
                      getExceptionAirnoOptionsByRow(scope.row, scope.$index)
                    "
                    clearable
                    filterable
                    :disabled="
                      scope.row.dataFrom == 'shunt' || ProcessType == 'query'
                    "
                    size="mini"
                    @change="rowSendBatchCurrOperatorChange($event,scope)"
                  >
                    <el-option
                      v-for="(item, index) in scope.row.sendBatchListOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </template>
              </el-table-column>

              <el-table-column
                prop="scheduleFlightType"
                label="时效类型"
                width="100"
                align="center"
              >
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.scheduleFlightType"
                    clearable
                    filterable
                    size="mini"
                    :disabled="
                      ProcessType == 'query' || scope.row.dataFrom == 'shunt'
                    "
                  >
                    <el-option
                      v-for="(item, index) in scheduleFlightTypeOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column
                prop="shuntNum"
                label="分流量"
                width="100"
                align="center"
              >
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.shuntNum"
                    size="mini"
                    :disabled="ProcessType == 'query'"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                prop="airTypeCode"
                label="运力类型"
                width="120"
                align="center"
              >
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.airTypeCode"
                    clearable
                    filterable
                    size="mini"
                    :disabled="
                      scope.row.dataFrom == 'shunt' || ProcessType == 'query'
                    "
                  >
                    <el-option
                      v-for="(item, index) in scope.row.airTypeCodeShuntOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column
                prop="exceptionTypeCode"
                label="操作"
                min-width="120"
                align="center"
              >
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    :disabled="ProcessType == 'query'"
                    @click="handleAddRow(scope.$index, scope.row)"
                    >+</el-button
                  >
                  <el-button
                    size="mini"
                    type="danger"
                    :disabled="ProcessType == 'query'"
                    @click="handleDeleteRow(scope.$index, scope.row)"
                    >-</el-button
                  >
                </template>
              </el-table-column>
            </el-table-column>
          </el-table>
        </el-row>

        <el-divider v-if="ProcessType != 'query'">决策参考</el-divider>
        <el-row v-if="ProcessType != 'query'">
          <el-form
            class="searchform1 exceptForm"
            :inline="true"
            :model="searchListDecisionForm"
            ref="searchListDecisionForm"
            label-width="120px"
          >
            <el-row>
              <el-col :span="24" class="flex flex-vc rowItem">
                <el-form-item
                  class="label_required"
                  label="需求日期:"
                  prop="exceptionDate"
                >
                  <el-date-picker
                    v-model="searchListDecisionForm.exceptionDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    :picker-options="addDecisionExceptionPickerOptions"
                    placeholder="选择日期"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item label="始发地:" prop="departCityCode">
                  <el-select
                    v-model="searchListDecisionForm.departCityCode"
                    clearable
                    filterable
                  >
                    <el-option
                      v-for="(item, index) in cityCodeOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="目的地:" prop="arriveCityCode">
                  <el-select
                    v-model="searchListDecisionForm.arriveCityCode"
                    clearable
                    filterable
                  >
                    <el-option
                      v-for="(item, index) in cityCodeOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="班次:" prop="sendBatch">
                  <el-select
                    v-model="searchListDecisionForm.sendBatch"
                    clearable
                    filterable
                    @click.native="getExceptionAirnoOptions(2)"
                  >
                    <el-option
                      v-for="item in sendBatchList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-button
                  size="mini"
                  type="main"
                  icon="el-icon-search"
                  style="margin-bottom: 6px"
                  @click="onDecisionFormSearch('1')"
                  >查询</el-button
                >
                <el-button
                  size="mini"
                  icon="el-icon-plus"
                  @click="handleAddRow()"
                  style="margin-bottom: 6px"
                  >添加分流</el-button
                >
              </el-col>
            </el-row>
          </el-form>

          <sfair-pagination
            @sizeChange="decisionPageSizeChange"
            @currentChange="decisionHandleCurrentChangePage"
            :currentPage.sync="decisionPagination.currentPage"
            :pageSize.sync="decisionPagination.pageSize"
            :total="decisionPagination.total"
            class="sfair-first-level"
          ></sfair-pagination>

          <el-table
            class="data-list"
            v-loading="loadind"
            :data="orderExceptionTempShuntGridList"
            ref="multipleTable1"
            border
            highlight-current-row
            @selection-change="changeDecisionSelectedList"
          >
            <el-table-column type="expand">
              <template slot-scope="scope">
                <el-table :data="scope.row.capacityList" class="data-list">
                  <el-table-column width="700"></el-table-column>
                  <el-table-column
                    prop="capacityName"
                    label="航班号"
                    width="100"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="departTm"
                    label="最晚离场时间"
                    :formatter="departTmShow"
                    width="100"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="avaiableSpaceAmount"
                    label="可用舱位"
                    width="100"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="planSpaceAmount"
                    label="订舱量"
                    width="100"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="approvalSpaceAmount"
                    label="批舱量"
                    width="100"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="restSpaceAmount"
                    label="剩余可用舱位"
                    align="center"
                  ></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column
              type="selection"
              align="center"
              width="50"
              prop="id"
            />
            <el-table-column
              prop="sendBatchDt"
              label="需求日期"
              width="100"
              align="center"
              :formatter="sendBatchDtShow"
            >
            </el-table-column>
            <el-table-column
              prop="departDeptCode"
              label="发货网点"
              width="100"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="sendBatch"
              label="发出班次"
              align="center"
              width="100"
            >
            </el-table-column>
            <el-table-column
              prop="departCityCode"
              label="始发地"
              align="center"
              width="100"
              :formatter="departCityNameShow"
            >
            </el-table-column>
            <el-table-column
              prop="arriveCityCode"
              label="目的地"
              align="center"
              width="100"
              :formatter="arriveCityNameShow"
            >
            </el-table-column>
            <el-table-column
              prop="arriveDeptCode"
              label="目的网点"
              align="center"
              width="100"
            >
            </el-table-column>
            <el-table-column
              prop="scheduleFlightType"
              label="时效类型"
              align="center"
              :formatter="scheduleFlightTypeNameShow"
              width="100"
            >
            </el-table-column>
            <el-table-column
              prop="cargoType"
              label="货物类型"
              align="center"
              width="100"
              :formatter="cargoTypeTypeNameShow"
            >
            </el-table-column>
            <el-table-column
              prop="avaiableSpaceAmount"
              label="可用舱位"
              align="center"
              width="100"
            >
            </el-table-column>
            <el-table-column
              prop="planSpaceAmount"
              label="订舱量"
              align="center"
              width="100"
            >
            </el-table-column>
            <el-table-column
              prop="approvalSpaceAmount"
              label="批舱量"
              align="center"
              width="100"
            >
            </el-table-column>
            <el-table-column
              prop="restSpaceAmount"
              label="剩余可用舱位"
              align="center"
              width="140"
            >
            </el-table-column>
          </el-table>
        </el-row>
      </el-form>
    </el-dialog>

    <el-dialog
      title="邮件地址选择页面"
      :visible.sync="this.emailFormDialogVisible"
      width="100%"
      :close-on-click-modal="false"
      :before-close="closeEmailForm"
      class="sfair-dialog"
    >
      <el-form
        class="searchform1 exceptForm"
        :inline="true"
        :model="emailSearchListForm"
        ref="searchListForm"
        label-width="80px"
      >
        <el-row>
          <el-col :span="24">
            <el-form-item
              label="组织:"
              prop="processStatus"
              class="label_required"
            >
              <el-select
                v-model="emailSearchListForm.orgId"
                filterable
                :filter-method="orgFilter"
                clearable
              >
                <el-option
                  v-for="(item, index) in orgDataShowList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="工号:" prop="empCode">
              <el-input v-model="emailSearchListForm.empCode"></el-input>
            </el-form-item>
            <el-form-item label="姓名:" prop="empName">
              <el-input v-model="emailSearchListForm.empName"></el-input>
            </el-form-item>
            <el-button
              size="mini"
              type="main"
              icon="el-icon-search"
              @click="onEmpListSearch()"
              style="margin-top: 5px"
              >查询</el-button
            >
            <el-button
              size="mini"
              type="operate"
              icon="el-icon-search"
              @click="onAddEmailTo()"
              style="margin-top: 5px"
              >添加</el-button
            >
          </el-col>
        </el-row>
      </el-form>

      <el-table
        class="data-list"
        v-loading="loadind"
        :data="emailDataList"
        ref="multipleEmailDataTable"
        border
        highlight-current-row
        @selection-change="changeEmailSelectedList"
        height="400"
      >
        <el-table-column type="selection" align="center" width="50" prop="id" />
        <el-table-column prop="empNum" label="工号" width="150" align="center">
        </el-table-column>
        <el-table-column prop="empName" label="姓名" align="center" width="150">
        </el-table-column>
        <el-table-column
          prop="email"
          label="邮件地址"
          width="260"
          align="center"
        >
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template> 
<script>
import { userHttp } from "@/api/user";
import SelectCodeMultiple from "@/components/SelectCodeMultiple";
// UI改造增加-引用
import {
  getPageConditionToggleBtnClass,
  getPageConfigBtnClass,
  getSysCode,
} from "@/utils/auth";
import { Loading } from "element-ui";
import selectCode from "../marketCollection/components/selectCode.vue";
import resourceControl from "./resourceControl.vue";
export default {
  components: { selectCode, SelectCodeMultiple, resourceControl },
  data() {
    // UI改造增加-变量
    const baiyuanModuleCode = window.baiyuanModuleCode
      ? window.baiyuanModuleCode
      : "exceptionManage";
    return {
      emptyCityCodeOptions: [],
      //UI改造增加-属性 - start
      queryTableVisible: true,
      colLeftConfig: [],
      colRightConfig: [],
      colNormalConfig: [
        {
          prop: "exceptionCode",
          label: "异常ID",
        },
        {
          prop: "exceptionTypeCode",
          label: "异常类型",
        },
        {
          prop: "exceptionDate",
          label: "异常日期",
        },
        {
          prop: "processStatus",
          label: "是否升级调度",
        },
        {
          prop: "processStatus1",
          label: "调度处理结果",
        },
        {
          prop: "orderCode",
          label: "调令编号",
        },
        {
          prop: "departAreaCode",
          label: "地区",
        },
        {
          prop: "departDeptCode",
          label: "网点",
        },
        {
          prop: "departCityCode",
          label: "始发地",
        },
        {
          prop: "arriveCityCode",
          label: "目的地",
        },
        {
          prop: "sendBatch",
          label: "发货班次",
        },
        {
          prop: "capacityName",
          label: "异常航班",
        },

        {
          prop: "scheduleFlightType",
          label: "异常航班时效类型",
        },
        {
          prop: "exceptionNums",
          label: "异常件数",
        },

        {
          prop: "phWeight",
          label: "普货(KG)",
        },
        {
          prop: "sxWeight",
          label: "生鲜(KG)",
        },

        {
          prop: "xhWeight",
          label: "鲜活(KG)",
        },
        {
          prop: "taWeight",
          label: "TA(KG)",
        },

        {
          prop: "carsNo",
          label: "笼号或车标号",
        },
        {
          prop: "operatingResult",
          label: "驳回原因",
        },
        {
          prop: "exceptionDesc",
          label: "备注",
        },
        {
          prop: "reportDate",
          label: "异常升级调度时间",
        },
        {
          prop: "reportEmpno",
          label: "升级调度人",
        },
        {
          prop: "modifiedEmpCode",
          label: "调度处理人",
        },
      ],
      searchNormalConfig: [
        {
          prop: "deptCode",
          label: "网点",
        },
        {
          prop: "exceptionTypeCode",
          label: "异常类型",
        },
        {
          prop: "exceptionDateStart",
          label: "异常开始日期",
        },
        {
          prop: "exceptionDateEnd",
          label: "异常结束日期",
        },
      ],
      searchMoreConfig: [
        {
          prop: "exceptionCode",
          label: "异常ID",
        },
        {
          prop: "isUpgradeOrder",
          label: "是否升级调度",
        },
        {
          prop: "departCityCode",
          label: "始发地",
        },
        {
          prop: "arriveCityCode",
          label: "目的地",
        },
        {
          prop: "sendBatch",
          label: "班次",
        },
        {
          prop: "processStatus",
          label: "调度处理结果",
        },
      ],
      listConfigDataKey: baiyuanModuleCode,
      listConfigShow: false,
      conditionConfigDataKey: baiyuanModuleCode,
      conditionToggleBtnClass: getPageConditionToggleBtnClass(),
      pageConfigBtnClass: getPageConfigBtnClass(),
      sysCode: getSysCode(), // 获取系统编码
      butConfigDataKey: baiyuanModuleCode, // 模块编码
      btnHeight: 0, // 按钮模块高度
      conditionHeight: 0,
      butConfigShow: false, // 按钮配置开关
      conditionConfigShow: false,
      moreBtnsData: [], // 更多按钮
      moreVisible: false, // 展示更多查询条件
      btnsData: [
        // 按钮显示配置
        {
          key: "search_exceptionManage_btn",
          label: "查询",
          type: "main",
          icon: "el-icon-search",
        },
        {
          key: "add_exceptionManage_btn",
          label: "新增",
          type: "list",
          icon: "el-icon-plus",
        },
        {
          key: "modify_exceptionManage_btn",
          label: "修改",
          type: "list",
          icon: "el-icon-edit",
        },
        {
          key: "cancle_exceptionManage_btn",
          label: "取消",
          type: "operate",
        },
        {
          key: "upgrade_exceptionManage_btn",
          label: "升级调度",
          type: "operate",
        },
        {
          key: "changeOrder_exceptionManage_btn",
          label: "转调令",
          type: "operate",
        },
        {
          key: "confirm_exceptionManage_btn",
          label: "同意改配",
          type: "permission",
        },
        {
          key: "rejected_exceptionManage_btn",
          label: "驳回",
          type: "operate",
        },
      ],
      searchListForm: {
        exceptionTypeCode: "",
        exceptionDateStart: "",
        exceptionDateEnd: "",
        exceptionIdcode: "",
        processStatus: null,
        exceptionAirNo: "",
        arriveCityCode: "",
        departCityCode: "",
        departDeptCode: "",
        isUpgradeOrder: null,
      },
      Pagination: {
        totalSize: 0,
        pageSize: 20,
        currentPage: 1,
      },
      decisionPagination: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },

      addexceptionDateCheck(dt) {
        return false;
      },
      loadind: false,
      deptIds: "",
      dataList: [],
      isUpOptions: [
        { label: "是", value: 1 },
        { label: "否", value: 2 },
      ],
      errorTypeOptions: [
        { label: "舱位缺口预警", value: 1 },
        { label: "中转航空溢出", value: 2 },
        { label: "发货异常", value: 3 },
      ],
      resultTypeOptions: [
        { label: "待处理", value: 6 },
        { label: "转调令", value: 4 },
        { label: "已发布调令", value: 5 },
        { label: "同意改配", value: 7 },
        { label: "驳回", value: 8 },
      ],
      //异常数据
      DialogVisible: false,
      DialogTitle: "新增异常",
      ProcessType: "add",
      ProcessForm: {
        exceptionTypeCode: "2",
        exceptionDate: "",
        exceptionDesc: "",
        carsNo: "",
        taWeight: 0,
        xhWeight: 0,
        sxWeight: 0,
        phWeight: 0,
        exceptionNums: "",
        exceptionAirNo: "",
        arriveCityCode: "",
        departCityCode: "",
        departDeptCode: "",
        saveType: 0,
        id: "",
      },
      changeOrderFormDialogVisible: false,
      emailFormDialogVisible: false,
      OrderForm: {
        orderTitle: "",
        orderCode: "",
        timeEffect: "",
        exceptionType: "",
        issuerEmpCode: "",
        issuerEmpName: "",
        issuerPhoneNo: "",
        exceptionDate: "",
        issuingEmpCode: "",
        issuingEmpName: "",
        issuingPhoneNo: "",
        executableUnit: "",
        departDeptCode: "",
        reportTime: "",
        issuingUnit: "",
        sendEmailList: "",
        sendEmailOrgIds: "",
        ccEmailList: "",
        ccEmailOrgIds: "",
        shuntDesc: "",
        issuerPhoneNoShow: "",
        issuingPhoneNoShow: "",
      },
      btnObj: {
        search_exceptionManage_btn: true,
        add_exceptionManage_btn: true,
        modify_exceptionManage_btn: true,
        cancle_exceptionManage_btn: true,
        upgrade_exceptionManage_btn: true,
        changeOrder_exceptionManage_btn: true,
        confirm_exceptionManage_btn: true,
        rejected_exceptionManage_btn: true,
      },
      exceptionOrderRadio: null,
      exceptionOrderMap: null,
      exceptionShuntMap: null,
      OrderExceptionTempForm: {
        exceptionDate: "",
        arriveCityCode: "",
        departCityCode: "",
        sendBatch: "",
        goodsStowageType: "",
        nums: 0,
        exceptionCode: "",
      },

      ShuntForm: {
        requiredDate: "",
        arriveCityCode: "",
        departCityCode: "",
        sendBatch: "",
      },
      exceptionTypeOptions: [{ label: "中转航空溢出", value: "2" }],
      exceptionTypeSelectOptions: [
        { label: "舱位缺口预警", value: "1" },
        { label: "中转航空溢出", value: "2" },
        { label: "发货异常", value: "3" },
      ],
      monitorTypeOptions: [
        { label: "事前", value: "1" },
        { label: "事中", value: "2" },
        { label: "事后", value: "3" },
      ],
      scheduleFlightTypeOptions: [
        { label: "早", value: "1" },
        { label: "午", value: "2" },
        { label: "晚", value: "3" },
      ],
      scheduleFlightTypeOptionsMap: new Map([
        ["1", "早航班"],
        ["2", "午航班"],
        ["3", "晚航班"],
      ]),

      airTypeCodeOptions: [
        { label: "全货机", value: "1" },
        { label: "干线", value: "2" },
        { label: "铁路", value: "4" },
      ],
      airTypeCodeShuntOptions: [{ label: "散航", value: "3" }],
      cityCodeOptions: [],
      exceptionAirnoOptions: [],

      selectionsList: [],
      secisionselectionsList: [],
      tableRowIndex: 0,
      exceptionOrderSelectionsList: [],

      orderExceptionTempGridList: [],
      orderExceptionTempShuntGridList: [],
      shuntDataList: [],
      orderTitle: "关于{0}年{1}月{2}日{3}分流调整的调令",
      emailDataList: [],
      orgDataList: [],
      orgDataShowList: [],
      emailSearchListForm: {
        orgId: "",
      },
      emailTxtType: "",
      emailSectionList: [],
      orderSpanArr: [],
      pos: 0,

      searchListDecisionForm: {
        exceptionDate: "",
        arriveCityCode: "",
        departCityCode: "",
        sendBatch: "",
      },

      sendBatchList: [],
      addExceptionPickerOptions: {
        disabledDate(time) {
          return (
            time.getTime() < new Date().getTime() - 2 * 24 * 3600 * 1000 ||
            time.getTime() > new Date().getTime() + 7 * 24 * 3600 * 1000
          );
        },
      },
      addDecisionExceptionPickerOptions: {
        disabledDate(time) {
          return (
            time.getTime() < new Date().getTime() - 2 * 24 * 3600 * 1000 ||
            time.getTime() > new Date().getTime() + 1 * 24 * 3600 * 1000
          );
        },
      },
      searchDepartDeptCodeList: [],
      shuntTableRowSubid: 0,
    };
  },
  computed: {
    // UI改造增加-计算属性 - start
    // 列表的所有列
    cols() {
      const left = this.colLeftConfig.map((val) => {
        return { ...val, fixed: "left" };
      });
      const right = this.colRightConfig.map((val) => {
        return { ...val, fixed: "right" };
      });
      const normal = this.colNormalConfig.map((val) => {
        return { ...val, fixed: null };
      });
      return left.concat(right).concat(normal);
    },
    // 列表高度
    tableHeight() {
      const paginationHeight = 26 + 12;
      let conditionHeight = this.conditionHeight;
      let btnHeight = this.btnHeight;
      if (btnHeight) btnHeight += 16;
      let sum = btnHeight + conditionHeight + paginationHeight + 16;
      if (this.showIsControl) {
        sum += 42;
      }
      return `calc(100% - ${sum}px)`;
    },
    // 所有查询条件
    conditions() {
      const normal = this.searchNormalConfig.map((val) => {
        return { ...val, area: "normal" };
      });
      const more = this.searchMoreConfig.map((val) => {
        return { ...val, area: "more" };
      });
      return normal.concat(more);
    },
    // 常用按钮
    btns() {
      const btnsData = this.btnsData.map((val) => {
        return { ...val, area: "normal" };
      });
      return btnsData.filter((val) => {
        return this.btnObj[val.key];
      });
      //return btnsData
    },
    // 更多按钮
    moreBtns() {
      const btnsData = this.moreBtnsData.map((val) => {
        return { ...val, area: "more" };
      });
      return btnsData.filter((val) => {
        return this.btnObj[val.key];
      });
    },
    // UI改造增加-计算属性 - end
    showIsControl() {
      const isControl = this.$route.query.isControl;
      if (isControl) {
        return true;
      } else {
        return false;
      }
    },
  },
  methods: {
    // UI改造增加-方法 - start
    // 重新渲染
    reRender() {
      this.queryTableVisible = false;
      this.$nextTick(() => {
        this.queryTableVisible = true;
        this.$nextTick(() => {
          this.resizeLogic();
        });
      });
    },
    // 更新列的状态
    tableConfigChange({ normal, left, right }) {
      this.colLeftConfig = left;
      this.colRightConfig = right;
      this.colNormalConfig = normal;
      this.reRender();
    },
    // 窗口尺寸发生变化时 重新调整布局
    resizeLogic() {
      if (this.$refs.multipleTable) {
        this.$nextTick(() => {
          this.$refs.multipleTable.doLayout();
        });
      }
    },
    // 条件高度变化
    conditionChange(height) {
      this.conditionHeight = height;
    },
    // 按钮查询条件是否显示
    isVisible({ visible, area }) {
      if (area === "normal") {
        return visible !== false;
      }
      if (area === "more") {
        return visible !== false && this.moreVisible;
      }
    },
    // 展示更多按钮
    moreToggle(val) {
      this.moreVisible = val;
    },
    // 响应偏好设置
    switchItem({ normal, more }) {
      this.searchMoreConfig = more
        .filter(() => {
          return true;
        })
        .map((val) => {
          return {
            label: val.label,
            prop: val.prop,
            visible: val.visible,
            area: "more",
          };
        });
      this.searchNormalConfig = normal
        .filter(() => {
          return true;
        })
        .map((val) => {
          return {
            label: val.label,
            prop: val.prop,
            visible: val.visible,
            area: "normal",
          };
        });
    },
    // 显示自定义配置
    showConfig(key) {
      if (key === "query") this.conditionConfigShow = true;
      if (key === "list") this.listConfigShow = true;
      if (key === "btn") this.butConfigShow = true;
    },
    // 按钮高度变化
    btnChange(height) {
      this.btnHeight = height;
    },
    // 相应按钮组件的点击事件
    btnClick(key) {
      if (key === "search_exceptionManage_btn") this.onExceptionSearch();
      if (key === "add_exceptionManage_btn") this.addNewExceptionBtn();
      if (key === "modify_exceptionManage_btn") this.modifyExceptionBtn();
      if (key === "cancle_exceptionManage_btn") this.cancelExceptionBtn();
      if (key === "cancelTask_bookingInteraction_btn") this.cancelTask();
      if (key === "cancle_exceptionManage_btn") this.cancelExceptionBtn();
      if (key === "upgrade_exceptionManage_btn") this.reportExceptionOrderBtn();
      if (key === "changeOrder_exceptionManage_btn") this.changeOrderBtn();
      if (key === "confirm_exceptionManage_btn") this.confirmTaskBtn();
      if (key === "rejected_exceptionManage_btn") this.rejectedTaskBtn();
    },
    // UI改造增加-方法 - end
    changDeptCodeEvent(val, list) {
      if (list !== undefined) {
        this.searchDepartDeptCodeList = list;
      }
    },
    stringFormat() {
      if (arguments.length == 0) return null;
      var str = arguments[0];
      for (var i = 1; i < arguments.length; i++) {
        var re = new RegExp("\\{" + (i - 1) + "\\}", "gm");
        str = str.replace(re, arguments[i]);
      }
      return str;
    },
    taNumberChange(val, maxNum) {
      //重新渲染
      this.$nextTick(() => {
        //比较输入的值和最大值,返回小的
        let num = Math.min(Number(val), maxNum);
        //输入负值的情况下, = 0(可根据实际需求更该)
        if (num < 0) {
          this.ProcessForm.taWeight = 0;
        } else {
          //反之
          this.ProcessForm.taWeight = num;
        }
      });
    },
    phNumberChange(val, maxNum) {
      //重新渲染
      this.$nextTick(() => {
        //比较输入的值和最大值,返回小的
        let num = Math.min(Number(val), maxNum);
        //输入负值的情况下, = 0(可根据实际需求更该)
        if (num < 0) {
          this.ProcessForm.phWeight = 0;
        } else {
          //反之
          this.ProcessForm.phWeight = num;
        }
      });
    },
    sxNumberChange(val, maxNum) {
      //重新渲染
      this.$nextTick(() => {
        //比较输入的值和最大值,返回小的
        let num = Math.min(Number(val), maxNum);
        //输入负值的情况下, = 0(可根据实际需求更该)
        if (num < 0) {
          this.ProcessForm.sxWeight = 0;
        } else {
          //反之
          this.ProcessForm.sxWeight = num;
        }
      });
    },
    xhNumberChange(val, maxNum) {
      //重新渲染
      this.$nextTick(() => {
        //比较输入的值和最大值,返回小的
        let num = Math.min(Number(val), maxNum);
        //输入负值的情况下, = 0(可根据实际需求更该)
        if (num < 0) {
          this.ProcessForm.xhWeight = 0;
        } else {
          //反之
          this.ProcessForm.xhWeight = num;
        }
      });
    },
    numsNumberChange(val, maxNum) {
      //重新渲染
      this.$nextTick(() => {
        //比较输入的值和最大值,返回小的
        let num = Math.min(Number(val), maxNum);
        //输入负值的情况下, = 0(可根据实际需求更该)
        if (num < 0) {
          this.ProcessForm.exceptionNums = 0;
        } else {
          //反之
          this.ProcessForm.exceptionNums = num;
        }
      });
    },
    showissuerPhoneNo() {
      this.OrderForm.issuerPhoneNoShow = this.OrderForm.issuerPhoneNo; // 电话号码 4位星号
      this.phoneType1 = "show";
      this.setEyeStyle();
    },

    hideissuerPhoneNo() {
      this.OrderForm.issuerPhoneNoShow = this.phoneNumFilter(
        this.OrderForm.issuerPhoneNo
      ); // 电话号码 明文
      this.phoneType1 = "";
      this.setEyeStyle();
    },

    setOrgPhoneNo(value) {
      this.OrderForm.issuerPhoneNo = value;
      this.hideissuerPhoneNo();
    },

    setEyeStyle() {
      let e = document.getElementsByClassName("el-icon-view")[0];
      if (e) {
        this.phoneType1 == ""
          ? e.setAttribute("style", "color: #c0c4cc")
          : e.setAttribute("style", "color: #409EFF");
      }
    },

    showissuingPhoneNo() {
      this.OrderForm.issuingPhoneNoShow = this.OrderForm.issuingPhoneNo; // 电话号码 4位星号
      this.phoneType2 = "show";
      this.setIssuingEyeStyle();
    },

    hideissuingPhoneNo() {
      this.OrderForm.issuingPhoneNoShow = this.phoneNumFilter(
        this.OrderForm.issuingPhoneNo
      ); // 电话号码 明文
      this.phoneType2 = "";
      this.setIssuingEyeStyle();
    },

    setIssuingOrgPhoneNo(value) {
      this.OrderForm.issuingPhoneNo = value;
      this.hideissuingPhoneNo();
    },

    setIssuingEyeStyle() {
      let e = document.getElementsByClassName("el-icon-view")[1];
      if (e) {
        this.phoneType2 == ""
          ? e.setAttribute("style", "color: #c0c4cc")
          : e.setAttribute("style", "color: #409EFF");
      }
    },

    phoneNumFilter(phone) {
      if (phone) {
        let reg = /(\d{3})\d{4}(\d{4})/;
        let tel1 = phone.replace(reg, "$1****$2");
        return tel1;
      }
    },
    orgFilter(query = "") {
      let arr = this.orgDataList.filter((item) => {
        return item.label.includes(query);
      });
      if (arr.length > 50) {
        this.orgDataShowList = arr.slice(0, 50);
      } else {
        this.orgDataShowList = arr;
      }
    },
    onExceptionSearch() {
      if (
        !this.searchDepartDeptCodeList ||
        this.searchDepartDeptCodeList.length == 0
      ) {
        this.$message({
          message: "查询时,网点代码必须输入",
          type: "warning",
        });
        return false;
      }
      if (!this.searchListForm.exceptionDateStart) {
        this.$message({
          message: "查询时,异常开始时间必须输入",
          type: "warning",
        });
        return false;
      }
      if (!this.searchListForm.exceptionDateEnd) {
        this.$message({
          message: "查询时,异常结束时间必须输入",
          type: "warning",
        });
        return false;
      }

      var startTime = new Date(
        this.searchListForm.exceptionDateStart
      ).getTime();
      var endTime = new Date(this.searchListForm.exceptionDateEnd).getTime();
      var dates = Math.abs(startTime - endTime) / (1000 * 60 * 60 * 24);
      if (dates > 31) {
        this.$message({
          message: "查询时,异常结束时间和异常开时间间隔不允许超过31天",
          type: "warning",
        });
        return false;
      }

      if (startTime > endTime) {
        this.$message({
          message: "查询时,异常结束时间不能大于异常开始时间",
          type: "warning",
        });
        return false;
      }

      this.Pagination.pageSize = 20;
      this.Pagination.currentPage = 1;
      this.getTableData();
    },

    onEmpListSearch() {
      if (!this.emailSearchListForm.orgId) {
        this.$message({
          message: "根据组织查询员工信息时,组织信息不允许为空",
          type: "warning",
        });
        return false;
      }

      var urlH = "/air/dispatch/webapi/getEmpInfoByOrgId";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      let params = {
        orgId: this.emailSearchListForm.orgId,
        empCode: this.emailSearchListForm.empCode,
        empName: this.emailSearchListForm.empName,
      };
      this.$httpExt()
        .get(urlH, params)
        .then(
          (response) => {
            loadingInstance.close();
            this.emailDataList = response.result;
            //this.emailPagination.total = response.result.total;
          },
          (response) => {
            loadingInstance.close();
          }
        );
    },
    onAddEmailTo() {
      if (this.emailSectionList.length == 0) {
        return;
      }

      let emailList = "";

      this.emailSectionList.forEach((item) => {
        emailList = emailList + item.email + ";";
      });
      if ("send" == this.emailTxtType) {
        this.OrderForm.sendEmailList = emailList + this.OrderForm.sendEmailList;
        this.OrderForm.sendEmailOrgIds = this.emailSearchListForm.orgId;
      } else if ("cc" == this.emailTxtType) {
        this.OrderForm.ccEmailList = emailList + this.OrderForm.ccEmailList;
        this.OrderForm.ccEmailOrgIds = this.emailSearchListForm.orgId;
      }
      //this.emailFormDialogVisible = false;
    },
    getTableData() {
      let isUpgradeOrderProcessStatusList = [];
      if (this.searchListForm.isUpgradeOrder == 1) {
        //
        isUpgradeOrderProcessStatusList = [3, 4, 5, 6, 7, 8];
      } else if (this.searchListForm.isUpgradeOrder == 2) {
        //
        isUpgradeOrderProcessStatusList = [0, 1, 2];
      }

      let processStatusList = [];
      if (this.searchListForm.processStatus) {
        if (this.searchListForm.processStatus == 6) {
          processStatusList.push(0);
          processStatusList.push(1);
          processStatusList.push(2);
          processStatusList.push(3);
          processStatusList.push(6);
        } else {
          processStatusList.push(this.searchListForm.processStatus);
        }
      }

      let postProcessStatusList = [];
      if (
        isUpgradeOrderProcessStatusList.length > 0 &&
        processStatusList.length > 0
      ) {
        let mergeList = isUpgradeOrderProcessStatusList.filter(function (item) {
          return processStatusList.indexOf(item) !== -1;
        });
        if (mergeList && mergeList.length > 0) {
          postProcessStatusList = mergeList;
        } else {
          postProcessStatusList.push(999);
        }
      } else if (isUpgradeOrderProcessStatusList.length > 0) {
        postProcessStatusList = isUpgradeOrderProcessStatusList;
      } else if (processStatusList.length > 0) {
        postProcessStatusList = processStatusList;
      }

      let tmpSearchDeptCodeList = [];
      if (this.searchListForm.departDeptCode) {
        this.searchDepartDeptCodeList.forEach((item) => {
          tmpSearchDeptCodeList.push(item.id);
        });
      }

      var param = {
        totalCount: 1,
        operType: 0, // 查询
        processObject: {
          exceptionTypeCode: this.searchListForm.exceptionTypeCode,
          exceptionDateStart: this.$format(
            new Date(this.searchListForm.exceptionDateStart).getTime(),
            "yyyy-MM-dd"
          ),
          exceptionDateEnd: this.$format(
            new Date(this.searchListForm.exceptionDateEnd).getTime(),
            "yyyy-MM-dd"
          ),
          exceptionCode: this.searchListForm.exceptionCode,
          sendBatch: this.searchListForm.sendBatch,
          arriveCityCodeList: this.searchListForm.arriveCityCode,
          departCityCodeList: this.searchListForm.departCityCode,
          //departDeptCode:this.searchListForm.departDeptCode,
          processStatusList: postProcessStatusList,
          deptCodeList: tmpSearchDeptCodeList,
        },
        pageNum: this.Pagination.currentPage,
        pageSize: this.Pagination.pageSize,
      };
      var urlH = "/air/dispatch/webapi/queryExceptions";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .post(urlH, param)
        .then(
          (response) => {
            loadingInstance.close();
            // 处理成一个包括 子表的list
            this.dataList = response.result.records;
            this.Pagination.totalSize = response.result.total;
            this.DialogVisible = false;
          },
          (response) => {
            loadingInstance.close();
            this.$message({
              message: response.msg
                ? response.msg
                : this.$t("common.exceptionWornText"),
              type: "warning",
            });
          }
        );
    },
    pageSizeChange(val) {
      this.Pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChangePage(val) {
      this.Pagination.currentPage = val;
      this.getTableData();
    },

    decisionPageSizeChange(val) {
      this.decisionPagination.pageSize = val;
      this.onDecisionFormSearch();
    },
    decisionHandleCurrentChangePage(val) {
      this.decisionPagination.currentPage = val;
      this.onDecisionFormSearch();
    },

    /**
     * @description: 关闭弹窗事件
     * @param {*}
     * @return {*}
     */
    closeProcessForm() {
      this.ProcessType = "";
      this.ProcessFormReset("ProcessForm");
      this.DialogVisible = false;
    },
    closeOrderForm() {
      this.changeOrderFormDialogVisible = false;
      this.$refs["OrderForm"].resetFields();
      this.OrderForm.orderCode = "";
      this.OrderForm.timeEffect = "";
      this.OrderForm.issuerEmpCode = "";
      this.OrderForm.issuerEmpName = "";
      this.OrderForm.issuerPhoneNo = "";
      this.OrderForm.issuingEmpCode = "";
      this.OrderForm.issuingEmpName = "";
      this.OrderForm.issuingPhoneNo = "";
      this.OrderForm.executableUnit = "";
      this.OrderForm.shuntDesc = "";
      this.OrderForm.sendEmailList = "";
      this.OrderForm.ccEmailList = "";
      this.$refs["searchListDecisionForm"].resetFields();

      this.searchListDecisionForm.exceptionDate = "";
      this.searchListDecisionForm.departCityCode = "";
      this.searchListDecisionForm.arriveCityCode = "";
      this.searchListDecisionForm.sendBatch = "";
      this.searchListDecisionForm.cargoType = "";
      this.orderExceptionTempShuntGridList = [];
      this.orderExceptionTempGridList.forEach((item) => {
        item = {};
      });
      this.decisionPagination.total = 0;
      this.exceptionOrderRadio = null;
    },
    closeEmailForm() {
      this.emailFormDialogVisible = false;
      this.$refs.multipleEmailDataTable.clearSelection();

      this.emailSearchListForm.empCode = "";
      this.emailSearchListForm.empName = "";
      this.emailSearchListForm.orgId = "";
      this.emailDataList = [];
    },

    queryOrderDetailBtn(row) {
      this.ProcessType = "query";
      this.DialogTitle = "详情查看";
      this.changeOrderFormDialogVisible = true;

      //查看明细数据 显示表格中
      this.getOrderDetailInfo(row.orderId);
    },

    getOrderDetailInfo(id) {
      var params = {
        processObject: { id: id },
      };
      var urlH = "/air/dispatch/webapi/queryTransferOrderDetail";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .post(urlH, params)
        .then(
          (response) => {
            loadingInstance.close();
            if ("ok" == response.succ) {
              this.settingDetails(response.result);
            } else {
            }
            loadingInstance.close();
          },
          (response) => {
            loadingInstance.close();
          }
        );
    },

    settingDetails(result) {
      let obj = this.$deepCopy(result);
      this.OrderForm = obj;

      this.orderExceptionTempGridList = result.exceptionsSubList;

      //this.OrderForm.issuingEmpCode = obj.issuingEmpName;
      //this.OrderForm.issuerEmpCode = obj.issuerEmpName;
    let that = this;
      if (this.ProcessType != "query") {
        this.OrderForm.issuingEmpCode = "";
        // 获取  当前登录人信息
        this.getIssuingEmpInfo();

        this.OrderForm.issuingTime = this.$format(
          new Date().getTime(),
          "yyyy-MM-dd hh:mm:ss"
        );
        this.orderExceptionTempGridList.forEach((item) => {
          if (item.dataFrom == "shunt") {
            item.airTypeCodeShuntOptions = this.airTypeCodeShuntOptions;
          } else {
            item.airTypeCodeShuntOptions = this.airTypeCodeOptions;
          }
        });
      } else {
        this.orderExceptionTempGridList.forEach((item) => {
          if (item.dataFrom == "shunt") {
            item.airTypeCodeShuntOptions = this.airTypeCodeShuntOptions;
          } else {
            item.airTypeCodeShuntOptions = this.airTypeCodeOptions;
          }
        item.subid = this.tableRowIndex;
        this.tableRowIndex++;
          item.goodsStowageTypeName = this.goodsStowageTypeNameShow(
            item.goodsStowageType
          );
          item.exceptionRowDepartCityOptions = [
          {
            label: that.exceptionDepartCityCodeFormatter(item),
            value: item.exceptionDepartCityCode,
          },
        ];

        item.exceptionRowArriveCityCodeOptions = [
          {
            label: that.exceptionArriveCityCodeFormatter(item),
            value: item.exceptionArriveCityCode,
          },
        ];
        item.rowDepartCityCodeOptions = [
          {
            label: that.departCityNameShow(item),
            value: item.departCityCode,
          },
        ];

        item.rowArriveCityCodeOptions = [
          {
            label: that.arriveCityNameShow(item),
            value: item.arriveCityCode,
          },
        ];
        });
      }

      this.$set(
        this.OrderForm,
        "issuerPhoneNoShow",
        this.phoneNumFilter(this.OrderForm.issuerPhoneNo)
      );
      //this.OrderForm.issuerPhoneNoShow = ;  // 电话号码 密文
      this.phoneType1 = "";
      this.setEyeStyle();

      this.$set(
        this.OrderForm,
        "issuingPhoneNoShow",
        this.phoneNumFilter(this.OrderForm.issuingPhoneNo)
      );

      this.$set(
        this.OrderForm,
        "issuingTime",
        this.$format(new Date(this.OrderForm.issuingTime).getTime(),"yyyy-MM-dd hh:mm:ss")
      );

      //this.OrderForm.issuerPhoneNoShow = ;  // 电话号码 密文
      this.phoneType2 = "";
      this.setIssuingEyeStyle();

      this.calcRowMerger(this.orderExceptionTempGridList);
    },

    changeOrderBtn() {
      if (!this.selectionsList || this.selectionsList.length < 1) {
        this.$message({
          message: `请选择需要进行转调令的数据`,
          type: "warning",
        });
        return;
      }

      if (this.selectionsList && this.selectionsList.length > 20) {
        this.$message({
          message: `最多可支持20条异常合并转调令,请分批处理`,
          type: "warning",
        });
        return;
      }

      if (this.selectionsList && this.selectionsList.length == 1) {
        if (
          this.selectionsList[0].processStatus == 4 ||
          this.selectionsList[0].processStatus == 5 ||
          this.selectionsList[0].processStatus == 7 ||
          this.selectionsList[0].processStatus == 8
        ) {
          let result = "";
          if (this.selectionsList[0].processStatus == 4) {
            result = "转调令";
          }
          if (this.selectionsList[0].processStatus == 5) {
            result = "已发布调令";
          }
          if (this.selectionsList[0].processStatus == "8") {
            result = "驳回";
          }
          if (this.selectionsList[0].processStatus == "7") {
            result = "同意改配";
          }

          this.$message({
            message: `调度处理结果为${result}, 请勿重复操作`,
            type: "warning",
          });
          return;
        }

        if (this.selectionsList[0].processStatus != 6) {
          this.$message({
            message: `异常未升级调度,不可转调令处理`,
            type: "warning",
          });
          return;
        }
      }

      let exceptionDepartDeptCodeSet = new Set();
      this.selectionsList.forEach((item) => {
        exceptionDepartDeptCodeSet.add(item.departAreaCode);
      });
      if (exceptionDepartDeptCodeSet.size > 1) {
        this.$message({
          message: `区部网点不同,可不可合并转调令`,
          type: "warning",
        });
        return;
      }

      let exceptionTypeCodeSet = new Set();
      this.selectionsList.forEach((item) => {
        exceptionTypeCodeSet.add(item.exceptionTypeCode);
      });
      if (exceptionTypeCodeSet.size > 1) {
        this.$message({
          message: `存在异常类型不同/未升级调度/调度已处理的异常, 不可合并转调令`,
          type: "warning",
        });
        return;
      }

      let res = this.selectionsList.filter((item) => {
        return item.processStatus != 6;
      });
      if (res && res.length > 0) {
        this.$message({
          message: `存在异常类型不同/未升级调度/调度已处理的异常, 不可合并转调令`,
          type: "warning",
        });
        return;
      }

      let res1 = this.selectionsList.filter((item) => {
        return item.processStatus == 5;
      });
      if (res1 && res1.length > 0) {
        this.$message({
          message: `存在异常类型不同/未升级调度/调度已处理的异常, 不可合并转调令`,
          type: "warning",
        });
        return;
      }

      this.tableRowIndex = 0;

      //获取订单编号
      // this.getOrderCode("");

      this.OrderForm.issuingEmpName = "";
      // 获取  当前登录人信息
      this.getIssuingEmpInfo();

      this.ProcessType = "changeorder";

      this.selectionsList.sort((a, b) => {
        return a.reportDate < b.reportDate ? -1 : 1;
      });

      let converted = new Date(
        Date.parse(this.selectionsList[0].exceptionDate)
      );

      let year = converted.getFullYear();
      let month = converted.getMonth() + 1;
      let date = converted.getDate();

      let exceptionTitle = "中转航空溢出";
      if (this.selectionsList[0].exceptionTypeCode == "1") {
        exceptionTitle = "舱位缺口预警";
      } else if (this.selectionsList[0].exceptionTypeCode == "3") {
        exceptionTitle = "发货异常";
      }

      this.OrderForm.orderTitle = this.stringFormat(
        this.orderTitle,
        year,
        month,
        date,
        exceptionTitle
      );

      this.exceptionTypeSelectOptions.forEach((item) => {
        if (item.value == this.selectionsList[0].exceptionTypeCode) {
          this.OrderForm.exceptionType = item.value;
        }
      });

      this.OrderForm.timeEffect = this.selectionsList[0].exceptionTypeCode;
      this.OrderForm.exceptionDate = this.selectionsList[0].reportDate;

      this.OrderForm.departDeptCode = this.selectionsList[0].departDeptCode;
      this.orderExceptionTempGridList = [];
      this.changeOrderFormDialogVisible = true;

      //this.OrderForm.issuingEmpCode=  sessionStorage.getIte("userName");

      // 根据选择的数据进行数据处理 按照
      //异常日期 //场地代码//始发地//目的地 //发出班次//货物类型//缺口量
      this.selectionsList.forEach((item) => {
        let ph = false,
          ta = false,
          sx = false,
          xh = false;
        let phList = [],
          taList = [],
          sxList = [],
          xhList = [];

        for (let i = 0; i < 4; i++) {
          let tempOrderExceptionGridObj = {};
          tempOrderExceptionGridObj.exceptionDate = item.exceptionDate;
          //tempOrderExceptionGridObj.shuntDate =item.exceptionDate;
          tempOrderExceptionGridObj.exceptionDepartCityCode =
            item.departCityCode;
          tempOrderExceptionGridObj.exceptionArriveCityCode =
            item.arriveCityCode;
          tempOrderExceptionGridObj.exceptionSendBatch = item.sendBatch;
          tempOrderExceptionGridObj.exceptionDepartDeptCode =
            item.departDeptCode;
          tempOrderExceptionGridObj.id = item.id;
          tempOrderExceptionGridObj.groupId = this.tableRowIndex;
          tempOrderExceptionGridObj.match = false;
          tempOrderExceptionGridObj.dataFrom = "tableadd";
          tempOrderExceptionGridObj.isCanDelete = false;
          tempOrderExceptionGridObj.airTypeCodeShuntOptions =
            this.airTypeCodeOptions;

          if (item.phWeight && item.phWeight != 0 && !ph) {
            tempOrderExceptionGridObj.goodsStowageType = "ph";
            tempOrderExceptionGridObj.goodsStowageTypeName = "普货";
            tempOrderExceptionGridObj.exceptionWeight = item.phWeight;
            //tempOrderExceptionGridObj.shuntNum = item.phWeight;
            tempOrderExceptionGridObj.subid = this.tableRowIndex;
            this.orderExceptionTempGridList.push(tempOrderExceptionGridObj);
            ph = true;
            this.tableRowIndex++;
          } else if (item.taWeight && item.taWeight != 0 && !ta) {
            tempOrderExceptionGridObj.goodsStowageType = "ta";
            tempOrderExceptionGridObj.goodsStowageTypeName = "TA";
            tempOrderExceptionGridObj.exceptionWeight = item.taWeight;
            //tempOrderExceptionGridObj.shuntNum = item.taWeight;
            tempOrderExceptionGridObj.subid = this.tableRowIndex;
            this.orderExceptionTempGridList.push(tempOrderExceptionGridObj);
            ta = true;
            this.tableRowIndex++;
          } else if (item.sxWeight && item.sxWeight != 0 && !sx) {
            tempOrderExceptionGridObj.goodsStowageType = "sx";
            tempOrderExceptionGridObj.goodsStowageTypeName = "生鲜";
            tempOrderExceptionGridObj.exceptionWeight = item.sxWeight;
            //tempOrderExceptionGridObj.shuntNum = item.sxWeight;
            tempOrderExceptionGridObj.subid = this.tableRowIndex;
            this.orderExceptionTempGridList.push(tempOrderExceptionGridObj);
            sx = true;
            this.tableRowIndex++;
          } else if (item.xhWeight && item.xhWeight != 0 && !xh) {
            tempOrderExceptionGridObj.goodsStowageType = "xh";
            tempOrderExceptionGridObj.goodsStowageTypeName = "鲜活";
            tempOrderExceptionGridObj.exceptionWeight = item.xhWeight;
            //tempOrderExceptionGridObj.shuntNum = item.xhWeight;
            tempOrderExceptionGridObj.subid = this.tableRowIndex;
            this.orderExceptionTempGridList.push(tempOrderExceptionGridObj);
            xh = true;
            this.tableRowIndex++;
          }
        }
      });

      this.calcRowMerger(this.orderExceptionTempGridList);
    },

    getIssuingEmpInfo() {
      let empcode = "empCode";
      if (this.OrderForm.issuingEmpName) {
        empcode = this.OrderForm.issuingEmpName;
      }
      var urlH = "/air/dispatch/webapi/getEmpInfoByEmpCode/" + empcode;
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .get(urlH)
        .then(
          (response) => {
            loadingInstance.close();
            if ("ok" == response.succ) {
              this.OrderForm.issuingEmpName = response.result.empNum;
              this.OrderForm.issuingEmpCode = response.result.empName;
              this.OrderForm.issuingPhoneNo = response.result.phoneNum;
              this.OrderForm.issuingUnit = response.result.orgName;

              this.OrderForm.issuerEmpName = response.result.supervisorNumber;
              this.OrderForm.issuerEmpCode = response.result.supervisorName;
              this.OrderForm.issuerPhoneNo = response.result.supervisorPhoneNo;

              this.$set(
                this.OrderForm,
                "issuerPhoneNoShow",
                this.phoneNumFilter(this.OrderForm.issuerPhoneNo)
              );
              //this.OrderForm.issuerPhoneNoShow = ;  // 电话号码 密文
              this.phoneType1 = "";
              this.setEyeStyle();

              this.$set(
                this.OrderForm,
                "issuingPhoneNoShow",
                this.phoneNumFilter(this.OrderForm.issuingPhoneNo)
              );
              //this.OrderForm.issuerPhoneNoShow = ;  // 电话号码 密文
              this.phoneType2 = "";
              this.setIssuingEyeStyle();
            } else {
              this.OrderForm.issuingEmpCode = "";
            }
          },
          (response) => {
            this.OrderForm.issuingEmpCode = "";
            loadingInstance.close();
          }
        );
    },
    getIssuerEmpInfo() {
      var urlH =
        "/air/dispatch/webapi/getEmpInfoByEmpCode/" +
        this.OrderForm.issuerEmpCode;
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .get(urlH)
        .then(
          (response) => {
            loadingInstance.close();
            if ("ok" == response.succ  && response.result) {
              this.OrderForm.issuerEmpName = response.result.empCode;
              this.OrderForm.issuerEmpCode = response.result.empName;
              this.OrderForm.issuerPhoneNo = response.result.phoneNum;
            } else {
              this.OrderForm.issuerEmpCode = "";
              this.$message({
                    message: `工号${this.OrderForm.issuerEmpCode}不存在`,
                    type: "warning",
                });
            }
          },
          (response) => {
            this.OrderForm.issuerEmpCode = "";
            loadingInstance.close();
            this.$message({
                    message: `查询${this.OrderForm.issuerEmpCode}工号时,系统发生异常,请稍后重试`,
                    type: "warning",
                });
          }
        );
    },
    confirmTaskBtn() {
      if (this.selectionsList.length < 1) {
        this.$message({
          message: `请至少选择一条数据进行改配操作`,
          type: "warning",
        });
        return false;
      }

      let typeRes = this.selectionsList.filter((item) => {
        return item.exceptionTypeCode != 3;
      });
      if (typeRes && typeRes.length > 0) {
        this.$message({
          message: `仅发货异常可操作同意改配`,
          type: "warning",
        });
        return false;
      }

      let res = this.selectionsList.filter((item) => {
        return item.processStatus != "6";
      });

      if (res && res.length > 0) {
        this.$message({
          message: "仅待处理中的异常可操作同意改配",
          type: "warning",
        });
        return;
      }
      //提示是否确认
      this.$confirm(`现场将根据预改配航班发运,请确认是否同意!`, "温馨提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.modifyDataBatch(7, "异常任务同意改配");
      });
    },

    rejectedTaskBtn() {
      if (this.selectionsList.length != 1) {
        this.$message({
          message: `仅允许单条勾选驳回`,
          type: "warning",
        });
        return false;
      }

      if (this.selectionsList[0].exceptionTypeCode == 3) {
        this.$message({
          message: `发货异常不可驳回`,
          type: "warning",
        });
        return false;
      }

      if (
        this.selectionsList[0].processStatus != 6 &&
        !(
          this.selectionsList[0].processStatus == 0 ||
          this.selectionsList[0].processStatus == 1 ||
          this.selectionsList[0].processStatus == 2
        )
      ) {
        let result = "";
        if (this.selectionsList[0].processStatus == 4) {
          result = "转调令";
        }
        if (this.selectionsList[0].processStatus == 5) {
          result = "已发布调令";
        }
        if (this.selectionsList[0].processStatus == "8") {
          result = "驳回";
        }
        this.$message({
          message: `调度处理结果为${result},不可驳回`,
          type: "warning",
        });
        return false;
      }

      if (
        this.selectionsList[0].processStatus == 0 ||
        this.selectionsList[0].processStatus == 1 ||
        this.selectionsList[0].processStatus == 2
      ) {
        this.$message({
          message: `异常未升级调度,不可驳回`,
          type: "warning",
        });
        return false;
      }

      //提示是否确认
      this.$prompt("请输入驳回原因:", "温馨提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputValue: "",
        inputErrorMessage: "输入不能为空",
        inputValidator: (value) => {
          // 点击按钮时,对文本框里面的值进行验证
          if (!value) {
            return "输入不能为空";
          }
          if (value.length > 300) {
            return "最大的长度不能超过300";
          }
        },
      })
        .then(({ value }) => {
          let selectionsListTemp = [];

          this.selectionsList.forEach((item) => {
            item.operatingResult = value;
            selectionsListTemp.push(item);
          });

          var param = {
            totalCount: 1,
            operType: 8,
            totalList: selectionsListTemp,
          };

          var urlH = "/air/dispatch/webapi/updateException";
          let loadingInstance = Loading.service({
            fullscreen: true,
          });
          this.$httpExt()
            .post(urlH, param)
            .then(
              (response) => {
                loadingInstance.close();
                if ("0000" != response.result.errorCode) {
                  this.$message({
                    message: response.result.errorMessage
                      ? response.result.errorMessage
                      : "异常任务驳回未知系统返回值",
                    type: "warning",
                  });
                } else {
                  this.$message({
                    message: response.result.errorMessage
                      ? response.result.errorMessage
                      : "异常任务驳回未知系统返回值",
                    type: "success",
                  });
                  this.getTableData();
                }
              },
              (response) => {
                loadingInstance.close();
              }
            );
        })
        .catch((err) => {});
    },

    checkException() {
      if (!this.ProcessForm.exceptionDate) {
        this.$message({
          message: "新增异常数据时,异常日期必须选择",
          type: "error",
        });
        return false;
      }
      if (!this.ProcessForm.arriveCityCode) {
        this.$message({
          message: "新增异常数据时,目的地必须选择",
          type: "error",
        });
        return false;
      }
      if (!this.ProcessForm.sendBatch) {
        this.$message({
          message: "新增异常数据时,班次必须选择",
          type: "error",
        });
        return false;
      }
      if (this.ProcessForm.departCityCode == this.ProcessForm.arriveCityCode) {
        this.$message({
          message: "新增异常数据时,始发地和目的地不能一致",
          type: "error",
        });
        return false;
      }
      if (this.ProcessForm.carsNo && this.ProcessForm.carsNo.length != 12) {
        this.$message({
          message: "新增异常数据时,笼号或车标号长度为12位数字",
          type: "error",
        });
        return false;
      }

      if (
        !this.ProcessForm.exceptionNums ||
        !(
          this.ProcessForm.exceptionNums > 0 &&
          this.ProcessForm.exceptionNums <= 99999
        )
      ) {
        this.$message({
          message: "新增异常数据时,异常件数必须输入,并且为1到99999",
          type: "error",
        });
        return false;
      }
      if (
        "" + this.ProcessForm.phWeight == "" ||
        !(this.ProcessForm.phWeight >= 0 && this.ProcessForm.phWeight <= 99999)
      ) {
        this.$message({
          message: "新增异常数据时,普货必须输入,并且为0到99999",
          type: "error",
        });
        return false;
      }
      if (
        "" + this.ProcessForm.sxWeight == "" ||
        !(this.ProcessForm.sxWeight >= 0 && this.ProcessForm.sxWeight <= 99999)
      ) {
        this.$message({
          message: "新增异常数据时,生鲜必须输入,并且为0到99999",
          type: "error",
        });
        return false;
      }
      if (
        "" + this.ProcessForm.xhWeight == "" ||
        !(this.ProcessForm.xhWeight >= 0 && this.ProcessForm.xhWeight <= 99999)
      ) {
        this.$message({
          message: "新增异常数据时,鲜活必须输入,并且为0到99999",
          type: "error",
        });
        return false;
      }
      if (
        "" + this.ProcessForm.taWeight == "" ||
        !(this.ProcessForm.taWeight >= 0 && this.ProcessForm.taWeight <= 99999)
      ) {
        this.$message({
          message: "新增异常数据时,TA必须输入,并且为0到99999",
          type: "error",
        });
        return false;
      }

      let totalWeight =
        parseFloat(this.ProcessForm.phWeight) +
        parseFloat(this.ProcessForm.sxWeight) +
        parseFloat(this.ProcessForm.xhWeight) +
        parseFloat(this.ProcessForm.taWeight);
      if (!(totalWeight > 0 && totalWeight <= 99999)) {
        this.$message({
          message: "班次溢出总量必须大于0且小于等于99999",
          type: "error",
        });
        return false;
      }
    },

    saveException() {
      if (this.checkException() == false) {
        return;
      }
      this.saveData(1);
      this.closeProcessForm();
      this.getTableData();
    },
    ProcessFormReset(form) {
      if (
        this.selectionsList &&
        this.selectionsList.length == 1 &&
        this.ProcessType == "update"
      ) {
        let obj = this.$deepCopy(this.selectionsList[0]);
        this.ProcessForm = obj;
      } else {
        this.ProcessForm.exceptionDate = "";
        this.ProcessForm.arriveCityCode = "";
        this.ProcessForm.sendBatch = "";
        this.ProcessForm.exceptionNums = "";
        this.ProcessForm.phWeight = "0";
        this.ProcessForm.sxWeight = "0";
        this.ProcessForm.xhWeight = "0";
        this.ProcessForm.taWeight = "0";
        this.ProcessForm.carsNo = "";
        this.ProcessForm.exceptionDesc = "";
      }
    },

    formReset(form) {
      this.$refs[form].resetFields(); // 重置表单
    },

    saveAndReport() {
      if (this.orderCheck() == false) {
        return;
      }
      this.postOrder(5);
    },
    orderCheck() {
      if (!this.OrderForm.orderTitle) {
        this.$message({
          message: `调令主题不允许为空`,
          type: "warning",
        });
        return false;
      }
      if (this.OrderForm.orderTitle && this.OrderForm.orderTitle.length > 100) {
        this.$message({
          message: `调令标题最大长度100`,
          type: "warning",
        });
        return false;
      }
      if (!this.OrderForm.sendEmailList) {
        this.$message({
          message: `收件人地址不允许为空`,
          type: "warning",
        });
        return false;
      }
      if (!this.OrderForm.executableUnit) {
        this.$message({
          message: `相关执行单位不允许为空`,
          type: "warning",
        });
        return false;
      }
      if (
        this.OrderForm.executableUnit &&
        this.OrderForm.executableUnit.length > 300
      ) {
        this.$message({
          message: `相关执行单位最大长度300`,
          type: "warning",
        });
        return false;
      }
      if (
        !this.OrderForm.shuntDesc ||
        (this.OrderForm.shuntDesc && this.OrderForm.shuntDesc.length > 1000)
      ) {
        this.$message({
          message: `分流说明必须输入,并且长度不允许超过1000`,
          type: "warning",
        });
        return false;
      }

      //const regMobile = /(\d{11})|(\(?(\d{3,4}\)?)?-?\d{7,8}-?(\d{1,4})?)/;
      const regMobile = /^[\d\(\)\-\/]{1,20}$/g;
      
      if (!this.OrderForm.issuingPhoneNo) {
        this.$message({
          message: `发布人电话号码不允许为空`,
          type: "warning",
        });
        return false;
      }

      if (this.OrderForm.issuingPhoneNo &&  (!regMobile.test(this.OrderForm.issuingPhoneNo)) ) {
          this.$message({
            message: `发布人电话号码格式不正确`,
            type: "warning",
          });
          return false;
      }


      const regMobile1 = /^[\d\(\)\-\/]{1,20}$/g;
      if (!this.OrderForm.issuerPhoneNo) {
        this.$message({
          message: `签发人电话号码不允许为空`,
          type: "warning",
        });
        return false;
      }
       if (this.OrderForm.issuerPhoneNo &&  (!regMobile1.test(this.OrderForm.issuerPhoneNo)) ) {
        this.$message({
          message: `签发人电话号码格式不正确`,
          type: "warning",
        });
        return false;
      }

      if (!this.OrderForm.issuerEmpCode || this.OrderForm.issuerEmpCode == "") {
        this.$message({
          message: `签发人不允许为空`,
          type: "warning",
        });
        return false;
      }
      if (
        !this.OrderForm.issuingEmpCode ||
        this.OrderForm.issuingEmpCode == ""
      ) {
        this.$message({
          message: `发布人不允许为空`,
          type: "warning",
        });
        return false;
      }

      let errorMessage = [];
      if (this.orderExceptionTempGridList) {
        this.orderExceptionTempGridList.forEach((exce) => {
          let errorInfo = "";
          if (!exce.shuntDate) {
            errorInfo = errorInfo + "分流信息需求日期不允许为空" + ";";
          }
          if (!exce.departCityCode) {
            errorInfo = errorInfo + "分流信息始发地不允许为空" + ";";
          }
          if (!exce.arriveCityCode) {
            errorInfo = errorInfo + "分流信息目的地不允许为空" + ";";
          }
          if (!exce.sendBatch) {
            errorInfo = errorInfo + "分流信息发出班次不允许为空" + ";";
          }
          if (!exce.scheduleFlightType) {
            errorInfo = errorInfo + "分流信息时效类型不允许为空" + ";";
          }
          if (!exce.shuntNum) {
            errorInfo = errorInfo + "分流信息分流量不允许为空" + ";";
          }
          if (exce.shuntNum && (exce.shuntNum < 1 || exce.shuntNum > 99999)) {
            errorInfo = errorInfo + "分流信息分流量范围为1到99999" + ";";
          }
          if (!exce.airTypeCode) {
            errorInfo = errorInfo + "分流信息运力类型不允许为空" + ";";
          }
          if (errorInfo && errorInfo != "") {
            errorMessage.push(
              "异常日期:[" +
                exce.exceptionDate +
                "] " +
                "发货网点:[" +
                exce.exceptionDepartDeptCode +
                "] " +
                "始发地:[" +
                exce.exceptionDepartCityCode +
                "] " +
                "目的地:[" +
                exce.exceptionArriveCityCode +
                "] " +
                (exce.exceptionSendBatch != ""
                  ? "发出班次:[" + exce.exceptionSendBatch + "] "
                  : "") +
                "货物类型:[" +
                exce.goodsStowageTypeName +
                "] 存在如下多个异常信息" +
                " : " +
                errorInfo
            );
          }
        });

        if (errorMessage && errorMessage.length > 0) {
          let newDatas = [];
          const h = this.$createElement;
          for (let i in errorMessage) {
            if (errorMessage[i] && errorMessage[i] != "") {
              newDatas.push(h("p", null, errorMessage[i]));
            }
          }
          if (newDatas && newDatas.length > 0) {
            this.$message({
              message: h("div", null, newDatas),
              type: "warning",
            });
            return false;
          }
        }
      }

      let tempList = this.$deepCopy(this.orderExceptionTempGridList);

      // 需求日期***, 流向***,发出班次***,运力类型** 分流总量为0,不可保存,请检查。
      let that = this;
      let errorRes = tempList
        .reduce(
          function (res, obj) {
            // 需求日期***, 流向***,发出班次***,运力类型** 分流总量为0,不可保存,请检查
            //let showStr = "需求日期"+obj.exceptionDate+", 流向"+ that.departCityNameShow(obj)+"到"+ that.arriveCityNameShow(obj)+",发出班次"+obj.sendBatch+",运力类型"+obj.airTypeCode+ "分流总量为0,不可保存,请检查";
            let showStr =
              "异常日期" +
              obj.exceptionDate +
              "," +
              that.departCityNameShow(obj) +
              "至" +
              that.arriveCityNameShow(obj) +
              ",发出班次" +
              obj.sendBatch +
              "," +
              that.goodsStowageTypeNameShow(obj.goodsStowageType) +
              "分流量大于缺口量,请修正后再提交";

            let key = obj.groupId + ";" + obj.goodsStowageType;
            if (!(key in res)) {
              obj.showStr = showStr;
              res.__array.push((res[key] = obj));
            } else {
              res[key].shuntNum =
                parseFloat(res[key].shuntNum) + parseFloat(obj.shuntNum);
              if (!res[key].showStr) {
                res[key].showStr = showStr;
              }
            }
            return res;
          },
          { __array: [] }
        )
        .__array.filter((item) => {
          return parseFloat(item.exceptionWeight) < parseFloat(item.shuntNum);
        });

      if (errorRes && errorRes.length > 0) {
        this.$message({
          message: errorRes[0].showStr,
          type: "warning",
        });
        return false;
      }
    },
    saveAndUpgrade() {
      if (this.checkException() == false) {
        return;
      }
      this.$confirm(
        `异常升级调度后不可修改,请确认是否继续升级!`,
        "温馨提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          this.saveData(1, "异常任务创建", true);
        })
        .catch(() => {});
    },
    modifyAndUpgrade() {
      if (this.checkException() == false) {
        return;
      }
      this.$confirm(
        `异常升级调度后不可修改,请确认是否继续升级!`,
        "温馨提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          this.modifyData(6, "异常任务修改&升级调度", true);
          this.closeProcessForm();
        })
        .catch(() => {});
    },

    showEmailDialog(type) {
      if (type == 1) {
        this.emailTxtType = "send";
        this.emailSectionList = [];
      } else if (type == 2) {
        this.emailTxtType = "cc";
        this.emailSectionList = [];
      }
      this.emailFormDialogVisible = true;
    },
    /**
     * @description: 新增异常--按钮
     * @param {*}
     * @return {*}
     */
    addNewExceptionBtn() {
      this.ProcessForm.departDeptCode = this.searchListForm.departDeptCode;

      if (!this.ProcessForm.departDeptCode || !this.searchDepartDeptCodeList) {
        this.$message({
          message: "新增异常数据时,请先选择网点",
          type: "error",
        });
        return;
      }

      if (
        this.searchDepartDeptCodeList &&
        this.searchDepartDeptCodeList.length > 1
      ) {
        this.$message({
          message: "新增异常数据时,只允许选择一个网点",
          type: "error",
        });
        return;
      }

      if (
        !(
          this.searchDepartDeptCodeList[0].typeLevel == 3 ||
          this.searchDepartDeptCodeList[0].typeLevel == 4
        )
      ) {
        this.$message({
          message: "新增异常数据时,选择网点类型必须为非总部及区部网点",
          type: "error",
        });
        return;
      }

      //设置为 发货网点对应的城市 代码
      this.getCityCodeByDepartCode();

      this.DialogVisible = true;
      this.ProcessType = "add";
      this.DialogTitle = "新增异常";
    },

    onDecisionFormSearch(isfirstQuery) {
      if (isfirstQuery == "1") {
        this.decisionPagination.currentPage = 1;
      }
      if (!this.searchListDecisionForm.exceptionDate) {
        this.$message({
          message: `决策参考查询时,需求日期不允许为空`,
          type: "warning",
        });
        return;
      }
      let cargoType;
      // ( 1普货,2鲜活,3生鲜,4ta件)
      if (this.exceptionOrderRadio) {
        if (this.exceptionOrderRadio.goodsStowageType == "ph") {
          cargoType = 1;
        }
        if (this.exceptionOrderRadio.goodsStowageType == "xh") {
          cargoType = 2;
        }
        if (this.exceptionOrderRadio.goodsStowageType == "sx") {
          cargoType = 3;
        }
        if (this.exceptionOrderRadio.goodsStowageType == "ta") {
          cargoType = 4;
        }
      }

      var param = {
        sendBatchDt: this.searchListDecisionForm.exceptionDate,
        departCityCode: this.searchListDecisionForm.departCityCode,
        sendBatch: this.searchListDecisionForm.sendBatch,
        arriveCityCode: this.searchListDecisionForm.arriveCityCode,
        cargoType: cargoType,
        pageNum: this.decisionPagination.currentPage,
        pageSize: this.decisionPagination.pageSize,
      };

      var urlH = "/air/requirement/bookRequirementRps/pageQuery";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      let that = this;
      this.$httpExt()
        .post(urlH, param)
        .then(
          (response) => {
            loadingInstance.close();
            if ("ok" != response.succ) {
              this.$message({
                message: response.msg
                  ? response.msg
                  : "决策参考信息查询失败未知系统返回值",
                type: "warning",
              });
            } else {
              this.orderExceptionTempShuntGridList = response.result.records;
              this.orderExceptionTempShuntGridList.forEach((item) => {
                item.departCityCodeOptions = [
                  {
                    label: that.departCityNameShow(item),
                    value: item.departCityCode,
                  },
                ];
                item.arriveCityCodeOptions = [
                  {
                    label: that.arriveCityNameShow(item),
                    value: item.arriveCityCode,
                  },
                ];
              });
              this.decisionPagination.total = response.result.total;
            }
          },
          (response) => {
            loadingInstance.close();
          }
        );
    },

    goodsStowageTypeNameShow(value) {
      if (value == "ph") {
        return "普货";
      } else if (value == "xh") {
        return "鲜活";
      } else if (value == "sx") {
        return "生鲜";
      } else if (value == "ta") {
        return "TA";
      }
    },

    airTypeCodeNameShow(value) {
      if (value == "1") {
        return "全货机";
      } else if (value == "2") {
        return "干线";
      } else if (value == "3") {
        return "散航";
      } else if (value == "4") {
        return "铁路";
      }
    },

    addShuntInfo(currentRowKey, shuntDefault) {
      if (this.exceptionShuntMap.get(currentRowKey)) {
        //不为空时
        this.exceptionShuntMap.get(currentRowKey).push(shuntDefault);
      } else {
        let shuntDataTempList = [];
        shuntDataTempList.push(shuntDefault);
        this.exceptionShuntMap.set(currentRowKey, shuntDataTempList);
      }
    },

    getCityCodeByDepartCode() {
      if (this.searchDepartDeptCodeList) {
        var urlH =
          "/air/dispatch/webapi/getCityCodeByDeptCode/" +
          this.searchDepartDeptCodeList[0].id;
        this.$httpExt()
          .get(urlH)
          .then(
            (response) => {
              if (response.succ) {
                this.ProcessForm.departCityCode = response.msg;
              }
            },
            (response) => {}
          );
      }
    },

    postOrder(type) {
      var nowDate = new Date();

      let exceptionIdSet = new Set();
      this.orderExceptionTempGridList.forEach((item) => {
        exceptionIdSet.add(item.id);
      });

      var param = {
        totalCount: 1,
        operType: type,
        batchNo: this.selectionsList[0].processNo,
        processObject: {
          exceptionIdList: Array.from(exceptionIdSet),
          airDispatcherTransferOrderDTO: {
            orderTitle: this.OrderForm.orderTitle,
            orderCode: this.OrderForm.orderCode,
            timeEffect: this.OrderForm.timeEffect,
            exceptionType: this.OrderForm.exceptionType,
            issuerEmpCode: this.OrderForm.issuerEmpName,
            issuerEmpName: this.OrderForm.issuerEmpCode,
            issuerPhoneNo: this.OrderForm.issuerPhoneNo,
            reportTime: this.selectionsList[0].exceptionDate,
            issuingUnit: this.OrderForm.issuingUnit,
            issuingTime: this.$format(nowDate.getTime(), "yyyy-MM-dd hh:mm:ss"),
            issuingEmpCode: this.OrderForm.issuingEmpName,
            issuingEmpName: this.OrderForm.issuingEmpCode,
            issuingPhoneNo: this.OrderForm.issuingPhoneNo,
            executableUnit: this.OrderForm.executableUnit,
            shuntDesc: this.OrderForm.shuntDesc,
            exceptionIdCode: this.selectionsList[0].exceptionIdCode,
            exceptionId: this.selectionsList[0].id,
            exceptionsSubList: this.orderExceptionTempGridList,
            orderStatus: type,
            departDeptCode: this.selectionsList[0].departAreaCode,
            exceptionDate: this.OrderForm.exceptionDate,
            sendEmailList: this.OrderForm.sendEmailList,
            ccEmailList: this.OrderForm.ccEmailList,
            airDispatcherExceptionsList: this.selectionsList,
            departAreaCode: this.selectionsList[0].departAreaCode,
          },
        },
      };
      var urlH = "/air/dispatch/webapi/updateException";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .post(urlH, param)
        .then(
          (response) => {
            loadingInstance.close();
            if ("0000" != response.result.errorCode) {
              this.$message({
                message: "调令发布失败,请查看错误信息",
                type: "warning",
              });
              // 下载错误文件
              if ("9587" == response.result.errorCode) {
                let url =
                  `/air/dispatch/webapi/downloadStream/` +
                  response.result.errorMessage;
                let fileName = response.result.errorMessage;
                this.$http()
                  .get(url, {}, { responseType: "blob" })
                  .then((response) => {
                    let blob = new Blob([response]);
                    let downloadElement = document.createElement("a");
                    let href = window.URL.createObjectURL(blob); //创建下载的链接
                    downloadElement.href = href;
                    downloadElement.download = "调令发布临时需求异常信息.xlsx"; //下载后文件名
                    document.body.appendChild(downloadElement);
                    downloadElement.click(); //点击下载
                    document.body.removeChild(downloadElement); //下载完成移除元素
                    window.URL.revokeObjectURL(href); //释放掉blob对象
                  });
              }
              //this.closeOrderForm();
            } else {
              this.$message({
                message: response.result.errorMessage
                  ? response.result.errorMessage
                  : "转调令创建未知系统返回值",
                type: "success",
              });
              this.changeOrderFormDialogVisible = false;
            this.closeOrderForm();
            this.getTableData();
            }
            
          },
          (response) => {
            loadingInstance.close();
            this.changeOrderFormDialogVisible = false;
          }
        );
    },

    saveOrderBtn() {
      // 保存转调令数据
      if (this.orderCheck() == false) {
        return;
      }
      this.postOrder(4);
    },

    departCityCodeChangeClear(val, scope) {
      if (scope && scope.row && val) {
        scope.row.sendBatch = "";
        this.$set(this.orderExceptionTempGridList, scope.$index, scope.row);
      }
    },
    rowSendBatchCurrOperatorChange(val,scope){
        if (val) {
            let obj ={};
            obj = scope.row.sendBatchListOptions.find(item => {
              return item.value === val //筛选出匹配数据
            })
            scope.row.sendBatch = obj.label;
            this.$set(this.orderExceptionTempGridList, scope.$index, scope.row);
          } else {
            scope.row.sendBatch = ''
            this.$set(this.orderExceptionTempGridList, scope.$index, scope.row);
        }
    },
    emptyCityCodeOptionsSet(event, scope, cityType) {
      if (event) {
        if (cityType == 1) {
          scope.row.rowDepartCityCodeOptions = this.cityCodeOptions;
        } else {
          scope.row.rowArriveCityCodeOptions = this.cityCodeOptions;
        }
      } else {
        if (cityType == 1) {
          scope.row.rowDepartCityCodeOptions = [];
        } else {
          scope.row.rowArriveCityCodeOptions = [];
        }
      }
      this.$set(this.orderExceptionTempGridList, scope.$index, scope.row);
    },

    getExceptionAirnoOptionsByRow(row, index) {
      let departCityCode = row.departCityCode;

      if (!departCityCode) {
        return false;
      }

      let url =
        `/air/requirement/menu/getDeptCodeBathListByCityCode?cityCode=` +
        departCityCode;
      this.$http()
        .get(url)
        .then((res) => {
          let sendBatchList = res.result.map((item) => {
            return {
              label: item.batchCode,
              value: item.batchCode,
            };
          });
          row.sendBatchListOptions = sendBatchList;
          this.$set(this.orderExceptionTempGridList, index, row);
        });
    },
    sendBatchDtShow(value) {
      return value.sendBatchDt.substr(0, 10);
    },
    departTmShow(value) {
      if (value.departTm) {
        if (("" + value.departTm).length == 3) {
          return "0" + value.departTm;
        }
        if (("" + value.departTm).length == 2) {
          return "00" + value.departTm;
        }
        if (("" + value.departTm).length == 1) {
          return "000" + value.departTm;
        }
      }
      return value.departTm;
    },

    checkGirdRowByGroupId(data, addRowCount) {
      if (!data || data.length + addRowCount <= 20) {
        return true;
      }

      //let showStr = "异常日期"+this.exceptionOrderRadio.exceptionDate+","+this.exceptionDepartCityCodeFormatter(this.exceptionOrderRadio)+"至"+this.exceptionArriveCityCodeFormatter(this.exceptionOrderRadio)+",发出班次"+this.exceptionOrderRadio.exceptionSendBatch+ ","+ this.goodsStowageTypeNameShow(this.exceptionOrderRadio.goodsStowageType) +"分流明细数据最多只能支持20条";
      let showStr = "每个异常最多可添加20条分流信息,请分批处理";
      let maxRowsError = data.filter((item) => {
        return item.groupId == this.exceptionOrderRadio.groupId;
      });

      if (maxRowsError && maxRowsError.length + addRowCount > 20) {
        this.$message({
          message: showStr,
          type: "warning",
        });
        return false;
      }
      return true;
    },
    checkGirdRowByCargoType(data) {
      //let showStr = "异常日期"+this.exceptionOrderRadio.exceptionDate+","+this.exceptionDepartCityCodeFormatter(this.exceptionOrderRadio)+"至"+this.exceptionArriveCityCodeFormatter(this.exceptionOrderRadio)+",发出班次"+this.exceptionOrderRadio.exceptionSendBatch+ ","+ this.goodsStowageTypeNameShow(this.exceptionOrderRadio.goodsStowageType) +"分流明细数据最多只能支持20条";
      let showStr = "异常货物类型与决策数据的货物类型不一致,不允许添加";
      let maxRowsError = data.filter((item) => {
        return (
          this.cargoTypeTypeNameShow(item) !=
          this.exceptionOrderRadio.goodsStowageTypeName
        );
      });

      if (maxRowsError && maxRowsError.length > 0) {
        this.$message({
          message: showStr,
          type: "warning",
        });
        return false;
      }
      return true;
    },

    handleAddRow(index, row) {
      if (!this.exceptionOrderRadio) {
        this.$message({
          message: "请选择一条异常信息",
          type: "warning",
        });
        return;
      }
      let exceptionOrderTempList = this.orderExceptionTempGridList;

      if (!row) {
        if (
          this.secisionselectionsList &&
          this.secisionselectionsList.length > 0
        ) {
          // 本次添加是否覆盖掉 第一行 不允许删除的记录;
          let isMeger = false; //默认不合并
          let isRemove = 0;

          let minList = this.orderExceptionTempGridList.filter((item) => {
            return item.groupId == this.exceptionOrderRadio.groupId;
          });
          let minSubId = minList[0].subid;

          let isMegerList = this.orderExceptionTempGridList.filter((item) => {
            return (
              item.groupId == this.exceptionOrderRadio.groupId &&
              item.subid == minSubId &&
              (!item.shuntDate || item.shuntDate == "") &&
              (!item.departCityCode || item.departCityCode == "") &&
              (!item.arriveCityCode || item.arriveCityCode == "") &&
              (!item.sendBatch || item.sendBatch == "") &&
              (!item.scheduleFlightType || item.scheduleFlightType == "") &&
              (!item.shuntNum || item.shuntNum == "") &&
              (!item.airTypeCode || item.airTypeCode == "")
            );
          });
          if (isMegerList && isMegerList.length > 0) {
            isMeger = true;
            isRemove = -1;
          }

          if (
            !this.checkGirdRowByGroupId(
              this.orderExceptionTempGridList,
              this.secisionselectionsList.length + isRemove
            )
          ) {
            return;
          }

          if (!this.checkGirdRowByCargoType(this.secisionselectionsList)) {
            return;
          }

          this.secisionselectionsList.forEach((item) => {
            if (isMeger) {
              let tempRowList = this.orderExceptionTempGridList.filter(
                (item) => {
                  return (
                    item.groupId == this.exceptionOrderRadio.groupId &&
                    item.subid == minSubId
                  );
                }
              );

              let tempRowObj = {};
              if (tempRowList && tempRowList.length > 0) {
                tempRowObj = tempRowList[0];
              }

              tempRowObj.rowDepartCityCodeOptions = item.departCityCodeOptions;
              tempRowObj.rowArriveCityCodeOptions = item.arriveCityCodeOptions;

              this.$set(
                tempRowObj,
                "shuntDate",
                this.$format(new Date(item.sendBatchDt).getTime(), "yyyy-MM-dd")
              );

              //shuntDefault.departCityCode=item.departCityCode;
              this.$set(tempRowObj, "departCityCode", item.departCityCode);
              //shuntDefault.departDeptCode = item.departDeptCode;
              this.$set(tempRowObj, "departDeptCode", item.departDeptCode);
              //shuntDefault.arriveCityCode = item.arriveCityCode;
              this.$set(tempRowObj, "arriveCityCode", item.arriveCityCode);
              //shuntDefault.sendBatch = item.sendBatch;
              this.$set(tempRowObj, "sendBatch", item.sendBatch);
              //shuntDefault.scheduleFlightType =""+item.scheduleFlightType;
              this.$set(
                tempRowObj,
                "scheduleFlightType",
                "" + item.scheduleFlightType
              );
              //shuntDefault.shuntNum = this.exceptionOrderRadio.exceptionWeight;
              this.$set(
                tempRowObj,
                "shuntNum",
                this.exceptionOrderRadio.exceptionWeight
                  ? this.exceptionOrderRadio.exceptionWeight
                  : 0
              );
              //shuntDefault.airTypeCode = "3";
              this.$set(tempRowObj, "airTypeCode", "3");
              // shuntDefault.goodsStowageType = this.exceptionOrderRadio.goodsStowageType;
              //tempRowObj.subid = this.tableRowIndex;
              tempRowObj.match = true;
              tempRowObj.dataFrom = "shunt";
              this.$set(tempRowObj, "arriveDeptCode", item.arriveDeptCode);
              //shuntDefault.arriveDeptCode = item.arriveDeptCode;
              tempRowObj.airTypeCodeShuntOptions = this.airTypeCodeShuntOptions;
              //this.tableRowIndex++;
              isMeger = false;
            } else {
              let shuntDefault = {};

              shuntDefault.rowDepartCityCodeOptions =
                item.departCityCodeOptions;
              shuntDefault.rowArriveCityCodeOptions =
                item.arriveCityCodeOptions;

              shuntDefault.exceptionDate =
                this.exceptionOrderRadio.exceptionDate;
              shuntDefault.exceptionDepartDeptCode =
                this.exceptionOrderRadio.exceptionDepartDeptCode;
              shuntDefault.exceptionDepartCityCode =
                this.exceptionOrderRadio.exceptionDepartCityCode;
              shuntDefault.exceptionArriveCityCode =
                this.exceptionOrderRadio.exceptionArriveCityCode;
              shuntDefault.exceptionSendBatch =
                this.exceptionOrderRadio.exceptionSendBatch;
              shuntDefault.goodsStowageType =
                this.exceptionOrderRadio.goodsStowageType;
              shuntDefault.goodsStowageTypeName =
                this.exceptionOrderRadio.goodsStowageTypeName;
              shuntDefault.exceptionWeight =
                this.exceptionOrderRadio.exceptionWeight;
              //shuntDefault.emptyCityCodeOptions = this.cityCodeOptions;
              this.$set(
                shuntDefault,
                "shuntDate",
                this.$format(new Date(item.sendBatchDt).getTime(), "yyyy-MM-dd")
              );

              //shuntDefault.departCityCode=item.departCityCode;
              this.$set(shuntDefault, "departCityCode", item.departCityCode);
              //shuntDefault.departDeptCode = item.departDeptCode;
              this.$set(shuntDefault, "departDeptCode", item.departDeptCode);
              //shuntDefault.arriveCityCode = item.arriveCityCode;
              this.$set(shuntDefault, "arriveCityCode", item.arriveCityCode);
              //shuntDefault.sendBatch = item.sendBatch;
              this.$set(shuntDefault, "sendBatch", item.sendBatch);
              //shuntDefault.scheduleFlightType =""+item.scheduleFlightType;
              this.$set(
                shuntDefault,
                "scheduleFlightType",
                "" + item.scheduleFlightType
              );
              //shuntDefault.shuntNum = this.exceptionOrderRadio.exceptionWeight;
              this.$set(
                shuntDefault,
                "shuntNum",
                this.exceptionOrderRadio.exceptionWeight
                  ? this.exceptionOrderRadio.exceptionWeight
                  : 0
              );
              //shuntDefault.airTypeCode = "3";
              this.$set(shuntDefault, "airTypeCode", "3");
              // shuntDefault.goodsStowageType = this.exceptionOrderRadio.goodsStowageType;

              shuntDefault.id = this.exceptionOrderRadio.id;
              shuntDefault.subid = this.tableRowIndex;
              shuntDefault.groupId = this.exceptionOrderRadio.groupId;
              shuntDefault.match = true;
              shuntDefault.dataFrom = "shunt";
              this.$set(shuntDefault, "arriveDeptCode", item.arriveDeptCode);
              //shuntDefault.arriveDeptCode = item.arriveDeptCode;
              shuntDefault.airTypeCodeShuntOptions =
                this.airTypeCodeShuntOptions;
              this.tableRowIndex++;
              shuntDefault.isCanDelete = true;

              exceptionOrderTempList.push(shuntDefault);
            }
          });
        } else {
          this.$message({
            message: "请选择分流决策参考数据",
            type: "warning",
          });
          return;
        }
      } else {
        if (!this.checkGirdRowByGroupId(this.orderExceptionTempGridList, 1)) {
          return;
        }
        let shuntDefault = {};

        shuntDefault.exceptionDate = this.exceptionOrderRadio.exceptionDate;
        shuntDefault.exceptionDepartDeptCode =
          this.exceptionOrderRadio.exceptionDepartDeptCode;
        shuntDefault.exceptionDepartCityCode =
          this.exceptionOrderRadio.exceptionDepartCityCode;
        shuntDefault.exceptionArriveCityCode =
          this.exceptionOrderRadio.exceptionArriveCityCode;
        shuntDefault.exceptionSendBatch =
          this.exceptionOrderRadio.exceptionSendBatch;
        shuntDefault.goodsStowageType =
          this.exceptionOrderRadio.goodsStowageType;
        shuntDefault.goodsStowageTypeName =
          this.exceptionOrderRadio.goodsStowageTypeName;
        shuntDefault.exceptionWeight = this.exceptionOrderRadio.exceptionWeight;

        //shuntDefault.shuntDate = this.exceptionOrderRadio.exceptionDate;
        shuntDefault.departDeptCode = ""; //this.exceptionOrderRadio.departDeptCode;
        shuntDefault.departCityCode = ""; //this.exceptionOrderRadio.departCityCode;
        shuntDefault.arriveCityCode = ""; //this.exceptionOrderRadio.arriveCityCode;
        shuntDefault.sendBatch = "";
        //shuntDefault.shuntNum = this.exceptionOrderRadio.exceptionWeight;
        shuntDefault.airTypeCode = "";
        shuntDefault.id = this.exceptionOrderRadio.id;
        //shuntDefault.goodsStowageType = this.exceptionOrderRadio.goodsStowageType;
        //shuntDefault.scheduleFlightType = "3";
        shuntDefault.subid = this.tableRowIndex;
        shuntDefault.groupId = this.exceptionOrderRadio.groupId;
        shuntDefault.match = true;
        shuntDefault.dataFrom = "tableadd";
        shuntDefault.airTypeCodeShuntOptions = this.airTypeCodeOptions;
        shuntDefault.isCanDelete = true;
        exceptionOrderTempList.push(shuntDefault);
        this.tableRowIndex++;
      }

      this.orderExceptionTempGridList = exceptionOrderTempList.sort((a, b) => {
        if (a.groupId < b.groupId) {
          return -1;
        } else if (a.groupId == b.groupId) {
          return a.subid < b.subid ? -1 : 1;
        } else {
          return 1;
        }
      });

      this.calcRowMerger(this.orderExceptionTempGridList);
    },
    handleDeleteRow(index, row) {
      
      let rowGroupId =  row.groupId;

      let groupShuntList =  this.orderExceptionTempGridList.filter(
        function (element, ind, self) {
          return element.groupId == rowGroupId;
        }
      );

      if(groupShuntList && groupShuntList.length==1){ 
             this.$set(
                row,
                "shuntDate",
                ""
              );
              this.$set(
                row,
                "departDeptCode",
                ""
              );
              this.$set(
                row,
                "departCityCode",
                ""
              );
            this.$set(
                row,
                "arriveCityCode",
                ""
              );
            
            this.$set(
                row,
                "sendBatch",
                ""
              );
            this.$set(
                row,
                "shuntNum",
                ""
              );
            this.$set(
                row,
                "airTypeCode",
                ""
              );
                this.$set(
                row,
                "scheduleFlightType",
                "" 
              );
            row.airTypeCodeShuntOptions = this.airTypeCodeOptions;
            row.dataFrom="tableadd";

            this.$set(this.orderExceptionTempGridList, index, row);
      }

      if(groupShuntList && groupShuntList.length>1){
        this.orderExceptionTempGridList = this.orderExceptionTempGridList.filter(
            function (element, ind, self) {
              return ind != index;
            }
        );
      }
   
      this.calcRowMerger(this.orderExceptionTempGridList);
    },
    /**
     * @description: 修改异常--按钮
     * @param {*}
     * @return {*}
     */
    modifyExceptionBtn() {
      if (this.selectionsList.length !== 1) {
        this.$message({
          message: `请选择一条数据修改`,
          type: "warning",
        });
        return false;
      }

      if (this.selectionsList[0].exceptionTypeCode != "2") {
        this.$message({
          message: `异常类型非“中转航空溢出”,不允许修改`,
          type: "warning",
        });
        return false;
      }
      if (
        this.selectionsList[0].processStatus != 0 &&
        this.selectionsList[0].processStatus != 1 &&
        this.selectionsList[0].processStatus != 2
      ) {
        this.$message({
          message: `异常已升级调度,不可修改`,
          type: "warning",
        });
        return false;
      }

      this.DialogVisible = true;
      this.ProcessType = "update";
      this.DialogTitle = "修改";
      let obj = this.$deepCopy(this.selectionsList[0]);
      this.ProcessForm = obj;
    },
    cancelExceptionBtn() {
      if (this.selectionsList.length < 1) {
        this.$message({
          message: `请至少选择一条数据进行取消`,
          type: "warning",
        });
        return false;
      }
      let isCanModify = true;
      try {
        this.selectionsList.forEach((row) => {
          if (row.exceptionTypeCode != "2") {
            this.$message({
              message: `异常类型非“中转航空溢出”,不允许取消`,
              type: "warning",
            });
            isCanModify = false;
            throw new Error("异常类型非“中转航空溢出”,不允许取消");
          }
          if (
            row.processStatus != "0" &&
            row.processStatus != "1" &&
            row.processStatus != "2"
          ) {
            this.$message({
              message: `异常已升级调度,不可取消`,
              type: "warning",
            });
            isCanModify = false;
            throw new Error("异常已升级调度,不可取消");
          }
        });
      } catch (e) {
        if (
          e.message != "异常类型非“中转航空溢出”,不允许取消" &&
          e.message != "异常已升级调度,不可取消"
        ) {
        }
      }
      if (isCanModify) {
        //提示是否确认
        this.$confirm(`请确认是否取消异常`, "温馨提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.cancelData();
          this.getTableData();
        });
      }
    },
    reportExceptionOrderBtn() {
      if (this.selectionsList.length < 1) {
        this.$message({
          message: `请至少选择一条数据进行调度升级`,
          type: "warning",
        });
        return false;
      }

      let res = this.selectionsList.filter((item) => {
        return (
          item.processStatus == 4 ||
          item.processStatus == 5 ||
          item.processStatus == 6 ||
          item.processStatus == 7 ||
          item.processStatus == 8 ||
          item.processStatus == 9
        );
      });

      if (res && res.length > 0) {
        this.$message({
          message: `该异常已升级调度,请勿重复操作`,
          type: "warning",
        });
        return;
      }

      let zeroRes = this.selectionsList.filter((item) => {
        let allValue =
          parseFloat(item.phWeight) +
          parseFloat(item.taWeight) +
          parseFloat(item.sxWeight) +
          parseFloat(item.xhWeight);
        return allValue == 0 && item.exceptionTypeCode == 1;
      });

      if (zeroRes && zeroRes.length > 0) {
        this.$message({
          message: `缺口总量为0 ,不允许升级调度`,
          type: "warning",
        });
        return;
      }

      //提示是否确认
      this.$confirm(
        `异常升级调度后不可修改,请确认是否继续升级!`,
        "温馨提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          var param = {
            totalCount: 1,
            operType: 6,
            totalList: this.selectionsList,
          };

          var urlH = "/air/dispatch/webapi/updateException";
          let loadingInstance = Loading.service({
            fullscreen: true,
          });
          this.$httpExt()
            .post(urlH, param)
            .then(
              (response) => {
                loadingInstance.close();
                if ("0000" != response.result.errorCode) {
                  this.$message({
                    message: response.result.errorMessage
                      ? response.result.errorMessage
                      : "异常任务升级调度未知系统返回值",
                    type: "warning",
                  });
                } else {
                  this.$message({
                    message: response.result.errorMessage
                      ? response.result.errorMessage
                      : "异常任务升级调度未知系统返回值",
                    type: "success",
                  });
                  this.getTableData();
                }
              },
              (response) => {
                loadingInstance.close();
              }
            );
        })
        .catch(() => {});

      //this.changeOrderFormDialogVisible=true;
    },
    cancelData() {
      this.modifyDataBatch(3, "异常取消操作");
    },

    modifyException() {
      if (this.checkException() == false) {
        return;
      }
      this.modifyData(2, "异常信息修改");
      this.closeProcessForm();
    },

    modifyData(type, title, isreport) {
      if (this.checkException() == false) {
        return;
      }

      var param = {
        totalCount: 1,
        operType: type,
        processObject: {
          id: this.ProcessForm.id,
          exceptionTypeCode: this.ProcessForm.exceptionTypeCode,
          exceptionDate: this.ProcessForm.exceptionDate,
          departDeptCode: this.ProcessForm.departDeptCode,
          departCityCode: this.ProcessForm.departCityCode,
          arriveCityCode: this.ProcessForm.arriveCityCode,
          sendBatch: this.ProcessForm.sendBatch,
          exceptionNums: this.ProcessForm.exceptionNums,
          phWeight: this.ProcessForm.phWeight,
          sxWeight: this.ProcessForm.sxWeight,
          xhWeight: this.ProcessForm.xhWeight,
          taWeight: this.ProcessForm.taWeight,
          carsNo: this.ProcessForm.carsNo,
          exceptionDesc: this.ProcessForm.exceptionDesc,
        },
      };

      var urlH = "/air/dispatch/webapi/updateException";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .post(urlH, param)
        .then(
          (response) => {
            loadingInstance.close();
            if ("0000" != response.result.errorCode) {
              this.$message({
                message: response.result.errorMessage
                  ? response.result.errorMessage
                  : title + "未知系统返回值",
                type: "warning",
              });
            } else {
              this.$message({
                message: response.result.errorMessage
                  ? response.result.errorMessage
                  : title + "未知系统返回值",
                type: "warning",
              });
            }
            this.getTableData();
          },
          (response) => {
            loadingInstance.close();
          }
        );
    },

    modifyDataBatch(type, title) {
      var param = {
        totalCount: 1,
        operType: type,
        totalList: this.selectionsList,
      };

      var urlH = "/air/dispatch/webapi/updateException";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .post(urlH, param)
        .then(
          (response) => {
            loadingInstance.close();
            if ("0000" != response.result.errorCode) {
              this.$message({
                message: response.result.errorMessage
                  ? response.result.errorMessage
                  : title + "未知系统返回值",
                type: "warning",
              });
            } else {
              this.$message({
                message: response.result.errorMessage
                  ? response.result.errorMessage
                  : title + "未知系统返回值",
                type: "success",
              });
            }
            this.DialogVisible = false;
            this.getTableData();
          },
          (response) => {
            loadingInstance.close();
            this.DialogVisible = false;
          }
        );
    },

    saveData(type, title, isreport) {
      var param = {
        totalCount: 1,
        operType: type,
        processObject: {
          exceptionTypeCode: this.ProcessForm.exceptionTypeCode,
          exceptionDate: this.ProcessForm.exceptionDate,
          departAreaCode: "",
          departDeptCode: this.ProcessForm.departDeptCode,
          departCityCode: this.ProcessForm.departCityCode,
          arriveCityCode: this.ProcessForm.arriveCityCode,
          sendBatch: this.ProcessForm.sendBatch,
          exceptionNums: this.ProcessForm.exceptionNums,
          phWeight: this.ProcessForm.phWeight,
          sxWeight: this.ProcessForm.sxWeight,
          xhWeight: this.ProcessForm.xhWeight,
          taWeight: this.ProcessForm.taWeight,
          carsNo: this.ProcessForm.carsNo,
          exceptionDesc: this.ProcessForm.exceptionDesc,
          channel: "web",
          saveType: 0,
        },
      };
      var urlH = "/air/dispatch/webapi/addNewExceptions";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .post(urlH, param)
        .then(
          (response) => {
            if ("0000" != response.result.errorCode) {
              this.$message({
                message: response.result.errorMessage
                  ? response.result.errorMessage
                  : "异常任务创建未知系统返回值",
                type: "warning",
              });
            } else {
              this.ProcessForm.id = response.result.resultObject.id;
              if (!isreport) {
                this.$message({
                  message: response.result.errorMessage
                    ? response.result.errorMessage
                    : "异常任务创建未知系统返回值",
                  type: "success",
                });
              }
            }
            if (isreport) {
              this.modifyData(6, "异常任务升级调度");
            }
            this.closeProcessForm();
            loadingInstance.close();
            this.getTableData();
          },
          (response) => {
            loadingInstance.close();
          }
        );
    },
    //初始化城市信息
    initCityCodeData() {
      let url = `/air/shiva-trtms-air/district/findDistI18nList.pub`;
      this.$http()
        .get(url)
        .then((res) => {
          this.cityCodeOptions = res.map((item) => {
            return {
              label: item.distName,
              value: item.distCode,
            };
          });
        });
    },
    //初始化班次信息
    getExceptionAirnoOptions(type) {
      let operateZoneCode;
      if (type == 0) {
        // 查询面板
        operateZoneCode = this.searchListForm.departDeptCode;
      }
      if (type == 1) {
        // 新增
        operateZoneCode = this.ProcessForm.departDeptCode;
      }
      if (type == 2) {
        //决策参考
        operateZoneCode = this.searchListDecisionForm.departCityCode;
      }

      if (!operateZoneCode) {
        return false;
      }

      let url =
        `/air/requirement/menu/getDeptCodeBathList4Lv3Lv4?deptCode=` +
        operateZoneCode;
      if (type == 2) {
        //决策参考
        url =
          `/air/requirement/menu/getDeptCodeBathListByCityCode?cityCode=` +
          operateZoneCode;
      }

      this.$http()
        .get(url)
        .then((res) => {
          this.sendBatchList = res.result.map((item) => {
            return {
              label: item.batchCode,
              value: item.batchCode,
            };
          });
        });
    },

    initOrgDataList() {
      let url = `/air/dispatch/webapi/getOrgDataList`;
      this.$http()
        .get(url)
        .then((res) => {
          if (res.result) {
            this.orgDataList = res.result.map((item) => {
              return {
                label: item.orgName,
                value: item.orgId,
              };
            });
          }
        });
    },

    defaultRowStyle({ row, rowIndwx }) {
      let styleJson = { height: "50px" };
      return styleJson; // 返回对象
    },
    defaultRowShuntStyle({ row, rowIndwx }) {
      let styleJson = { height: "50px" };
      return styleJson; // 返回对象
    },

    changeSelectedList(selection) {
      this.selectionsList = selection;
    },
    setRowExpand(row) {
      if (row.row.exceptionTypeCode != 3) {
        // 即该行没有子元素时,添加row-expand-cover类
        // 通过自己的逻辑返回一个class或者空
        return "expand";
      }
      return "";
    },

    changeDecisionSelectedList(selection) {
      this.secisionselectionsList = selection;
    },

    clickChange(item) {
      if (item) {
        this.exceptionOrderRadio = item;
        if (
          item.exceptionDate &&
          new Date(item.exceptionDate).getTime() >
            new Date().getTime() - 2 * 24 * 3600 * 1000 &&
          new Date(item.exceptionDate).getTime() <
            new Date().getTime() + 1 * 24 * 3600 * 1000
        ) {
          this.searchListDecisionForm.exceptionDate = item.exceptionDate;
        }
        // this.onDecisionFormSearch();
      }
    },
    getProcessStatusReason(value) {
      if (
        value.processStatus == "0" ||
        value.processStatus == "1" ||
        value.processStatus == "2" ||
        value.processStatus == "3"
      ) {
        return "待处理";
      }
      if (value.processStatus == "4") {
        return "转调令";
      }
      if (value.processStatus == "5") {
        return "已发布调令";
      }
      if (value.processStatus == "7") {
        return "同意改配";
      }
      if (value.processStatus == "8") {
        return "驳回";
      }
      if (value.processStatus == "6") {
        return "待处理";
      }
    },
    departCityNameShow(value) {
      if (value.departCityCode) {
        let cityName = "";
        try {
          this.cityCodeOptions.forEach((item) => {
            if (item.value == value.departCityCode) {
              cityName = item.label;
              throw new Error("");
            }
          });
        } catch (e) {}
        return cityName;
      }
    },

    exceptionDepartCityCodeFormatter(value) {
      if (value.exceptionDepartCityCode) {
        let cityName = "";
        try {
          this.cityCodeOptions.forEach((item) => {
            if (item.value == value.exceptionDepartCityCode) {
              cityName = item.label;
              throw new Error("");
            }
          });
        } catch (e) {}
        return cityName;
      }
    },

    exceptionArriveCityCodeFormatter(value) {
      if (value.exceptionArriveCityCode) {
        let cityName = "";
        try {
          this.cityCodeOptions.forEach((item) => {
            if (item.value == value.exceptionArriveCityCode) {
              cityName = item.label;
              throw new Error("");
            }
          });
        } catch (e) {}
        return cityName;
      }
    },

    arriveCityNameShow(value) {
      if (value.arriveCityCode) {
        let cityName = "";
        try {
          this.cityCodeOptions.forEach((item) => {
            if (item.value == value.arriveCityCode) {
              cityName = item.label;
              throw new Error("");
            }
          });
        } catch (e) {}
        return cityName;
      }
    },

    tranferDepartCityNameShow(value) {
      if (value.tranferDepartCityCode) {
        let cityName = "";
        try {
          this.cityCodeOptions.forEach((item) => {
            if (item.value == value.tranferDepartCityCode) {
              cityName = item.label;
              throw new Error("");
            }
          });
        } catch (e) {}
        return cityName;
      }
    },

    tranferArriveCityNameShow(value) {
      if (value.tranferArriveCityCode) {
        let cityName = "";
        try {
          this.cityCodeOptions.forEach((item) => {
            if (item.value == value.tranferArriveCityCode) {
              cityName = item.label;
              throw new Error("");
            }
          });
        } catch (e) {}
        return cityName;
      }
    },

    tranferScheduleFlightTypeNameShow(value) {
      if (value.tranferScheduleFlightType == "1") {
        return "早航班";
      } else if (value.tranferScheduleFlightType == "2") {
        return "午航班";
      } else if (value.tranferScheduleFlightType == "3") {
        return "晚航班";
      }
    },
    tranferDepartTmFormat(value) {
      return this.$format(
        new Date(value.tranferDepartTm).getTime(),
        "yyyy-MM-dd hh:mm:ss"
      );
    },
    tranferArriveTmFormat(value) {
      return this.$format(
        new Date(value.tranferArriveTm).getTime(),
        "yyyy-MM-dd hh:mm:ss"
      );
    },

    scheduleFlightTypeNameShow(value) {
      if (value.scheduleFlightType == "1") {
        return "早航班";
      } else if (value.scheduleFlightType == "2") {
        return "午航班";
      } else if (value.scheduleFlightType == "3") {
        return "晚航班";
      }
    },

    cargoTypeTypeNameShow(value) {
      if (value.cargoType == "1") {
        return "普货";
      } else if (value.cargoType == "2") {
        return "鲜活";
      } else if (value.cargoType == "3") {
        return "生鲜";
      } else if (value.cargoType == "4") {
        return "TA";
      }
    },

    scheduleFlightTypeMainNameShow(value) {
      if (value.deliverExceptionsList[0]) {
        if (value.deliverExceptionsList[0].scheduleFlightType == "1") {
          return "早航班";
        } else if (value.deliverExceptionsList[0].scheduleFlightType == "2") {
          return "午航班";
        } else if (value.deliverExceptionsList[0].scheduleFlightType == "3") {
          return "晚航班";
        }
      }
    },

    capacityNameMainShow(value) {
      if (value.deliverExceptionsList[0]) {
        return value.deliverExceptionsList[0].capacityName;
      }
      return "";
    },

    isUpOrder(value) {
      if (
        value.processStatus == "0" ||
        value.processStatus == "1" ||
        value.processStatus == "2" ||
        value.processStatus == "3"
      ) {
        return "否";
      }
      return "是";
    },
    reportEmpNoFormat(value) {
      if (value.exceptionTypeCode == "3") {
        return "SYS_SEND";
      } else {
        return value.reportEmpno;
      }
    },

    reportDateFormat(value) {
      if (value.reportDate) {
        return this.$format(
          new Date(value.reportDate).getTime(),
          "yyyy-MM-dd hh:mm:ss"
        );
      }
    },

    orderProcessDate(value) {
      if (
        (value.processStatus == 4 ||
          value.processStatus == 5 ||
          value.processStatus == 7 ||
          value.processStatus == 8) &&
        value.modifiedTm
      ) {
        return this.$format(
          new Date(value.modifiedTm).getTime(),
          "yyyy-MM-dd hh:mm:ss"
        );
      }
      return "";
    },
    orderProcessEmp(value) {
      if (
        (value.processStatus == 4 ||
          value.processStatus == 5 ||
          value.processStatus == 7 ||
          value.processStatus == 8) &&
        value.modifiedEmpCode
      ) {
        return value.modifiedEmpCode;
      }
      return "";
    },
    tranferScheduleFlightTypeFormat(value) {
      return (
        value.sendDate +
        " " +
        this.scheduleFlightTypeNameShow(value) +
        " 改配 " +
        this.$format(new Date(value.tranferDate).getTime(), "yyyy-MM-dd") +
        " " +
        this.tranferScheduleFlightTypeNameShow(value)
      );
    },

    tranferDateFormat(value) {
      if (value) {
        return this.$format(
          new Date(value.tranferDate).getTime(),
          "yyyy-MM-dd"
        );
      }
      return value;
    },
    exceptionTypeFormat(value) {
      if (value.exceptionTypeCode == "1") {
        return "舱位缺口预警";
      }
      if (value.exceptionTypeCode == "2") {
        return "中转航空溢出";
      }
      if (value.exceptionTypeCode == "3") {
        return "发货异常";
      }
    },
    changeEmailSelectedList(selection) {
      this.emailSectionList = selection;
    },
    calcRowMerger(data) {
      this.orderSpanArr = [];
      for (let i = 0; i < data.length; i++) {
        if (i === 0) {
          this.orderSpanArr.push(1);
          this.pos = 0;
        } else {
          // 判断当前元素与上一个元素是否相同
          if (
            data[i].groupId + ";" + data[i].goodsStowageType ==
            data[i - 1].groupId + ";" + data[i - 1].goodsStowageType
          ) {
            this.orderSpanArr[this.pos] += 1;
            this.orderSpanArr.push(0);
          } else {
            this.orderSpanArr.push(1);
            this.pos = i;
          }
        }
      }
    },
    mergerOrderTable({ row, column, rowIndex, columnIndex }) {
      if (columnIndex <= 7) {
        const _row = this.orderSpanArr[rowIndex];
        const _col = _row > 0 ? 1 : 0;
        return {
          //
          rowspan: _row,
          colspan: _col,
        };
      }
    },

    getOrderCode(deptartDeptCode) {
      var urlH = "/air/dispatch/webapi/getOrderCode";
      let loadingInstance = Loading.service({
        fullscreen: true,
      });
      this.$httpExt()
        .get(urlH, { departDeptCode: this.selectionsList[0].departAreaCode })
        .then(
          (response) => {
            loadingInstance.close();
            if ("0000" != response.result.errorCode) {
              this.$message({
                message: response.result.errorMessage
                  ? response.result.errorMessage
                  : "调度编号获取失败,请重试",
                type: "warning",
              });
            } else {
              this.OrderForm.orderCode = response.result.resultObject;
            }
          },
          (response) => {
            loadingInstance.close();
          }
        );
    },

    initDefaultValue() {
      //this.searchListForm.departDeptCode ="021B";
      this.searchListForm.exceptionDateStart = new Date(
        new Date().setDate(new Date().getDate() - 2)
      );
      this.searchListForm.exceptionDateEnd = new Date();
    },
  },
  created() {
    this.initCityCodeData();
    //this.getExceptionAirnoOptions();
    this.initOrgDataList();
    this.initDefaultValue();
  },
  mounted() {
    userHttp.queryAllBtns(this.$route.meta.moduleId).then((response) => {
      let data = response.result ? response.result : [];
      let obj = {};
      for (let i = 0; i < data.length; i++) {
        obj[data[i]] = true;
      }
      this.btnObj = obj;
    });
  },
};
</script>
<style lang="less" scoped>
.searchform1 {
  .el-button.el-button--primary {
    margin-bottom: 12px;
  }
  /deep/.el-form-item {
    margin-bottom: 0px;
  }
  /deep/.el-form-item__content {
    width: 180px;
    .el-input-group {
      margin-top: 5px;
    }
    .el-date-editor.el-input,
    .el-date-editor.el-input__inner,
    .el-input {
      width: 100%;
      input,
      .el-input__inner {
        height: 30px;
        line-height: 30px;
      }
    }
  }
  .daterangeTime {
    /deep/.el-form-item__content {
      width: 280px;
      .el-input-group {
        margin-top: 5px;
      }
      .el-date-editor.el-input,
      .el-date-editor.el-input__inner,
      .el-input {
        width: 100%;
        input,
        .el-input__inner {
          height: 30px;
          line-height: 30px;
        }
      }
    }
  }
}
.el-form-item {
  padding-bottom: 5px;
  & /deep/ .el-form-item__label {
    // font-size: 12px;
    padding-bottom: 5px;
    line-height: unset;
  }
  &.label_required /deep/ .el-form-item__label::before {
    content: "*";
    color: #f56c6c;
    margin-right: 4px;
  }
}
.pagination /deep/.el-pagination__rightwrapper {
  display: inline-block;
  float: none;
}
.oneLine {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.orderTitle {
  width: 50%;
  text-align: center;
  vertical-align: middle;
  border: none;
  input {
    min-width: 130px;
    text-align: center;
    vertical-align: middle;

    font-size: 14px;
    color: #606266;
    line-height: 40px;
    padding: 0 12px 0 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }
}
/deep/ .expand .el-table__expand-column .cell {
  display: none;
}
.inputinrow {
  display: flex;
  width: 92%;
  margin-top: 8px;
  margin-bottom: 8px;
  label {
    min-width: 120px;
    text-align: right;
    vertical-align: middle;
    float: left;
    font-size: 14px;
    color: #606266;
    line-height: 30px;
    padding: 0 12px 0 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }
}

.sfair-dialog {
  /deep/ .el-form--inline .el-form-item__content {
    vertical-align: middle;
  }

  /deep/ .searchform1.el-form--inline .el-form-item {
    margin-bottom: 0 !important;
  }

  /deep/ .exceptForm.el-form--inline .el-form-item__content {
    width: 150px;
  }

  /deep/ .el-form-item .el-form-item__label {
    padding-bottom: 0;
  }
}
.el-divider__text {
  font-size: 16px;
}

.el-dialog__wrapper.sfair-dialog {
  height: calc(100% - 60px) !important;
  /deep/ .orderDialog.el-dialog {
    margin: auto !important;
    height: calc(100%);
    .el-dialog__body {
      height: calc(100% - 30px) !important;
      overflow: auto;
    }
  }
}
</style>

 

posted @ 2021-08-11 22:54  热心市民~菜先生  阅读(475)  评论(0编辑  收藏  举报