<template>
  <div id="transferOrder">
    <div v-if="isList">
      <el-card style="position: relative">
        <el-form class="search_area" label-width="100px">
          <el-row :gutter="10">
            <el-col :span="1.5">
              <el-form-item label="调出库存组织">
                <el-select
                  clearable
                  size="mini"
                  v-model="queryParams.deliveryInventoryOrg"
                  @focus="chooseRefer('ORG_PARAM', true, '调出库存组织')"
                  style="width: 200px"
                >
                  <el-option
                    v-for="item in chuOrgOptions"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="1.5">
              <el-form-item label="单据日期">
                <el-date-picker
                  size="mini"
                  v-model="dateRange"
                  style="width: 240px"
                  value-format="yyyy-MM-dd"
                  type="daterange"
                  range-separator="-"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="1.5">
              <el-form-item label="订单类型">
                <el-select
                  v-model="queryParams.billType"
                  size="mini"
                  style="width: 200px"
                  clearable
                >
                  <el-option
                    v-for="dict in dict.type.sys_allot_billtype"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="1.5">
              <el-form-item label="调入库存组织">
                <el-select
                  clearable
                  size="mini"
                  v-model="queryParams.storageInventoryOrg"
                  @focus="chooseRefer('ORG_PARAM', true, '调入库存组织')"
                  style="width: 200px"
                >
                  <el-option
                    v-for="item in ruOrgOptions"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <div style="position: absolute; top: 3px; right: 10px">
              <el-button type="primary" size="mini" @click="searchList"
                >搜索</el-button
              >
              <el-button size="mini" plain @click="resetList">重置</el-button>
            </div>
          </el-row>

          <CollapseTransition>
            <div v-show="expanded">
              <el-row :gutter="10">
                <el-col :span="1.5">
                  <el-form-item label="单据号">
                    <el-input
                      v-model.trim="queryParams.code"
                      size="mini"
                      clearable
                      style="width: 200px"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="1.5">
                  <el-form-item label="制单人">
                    <el-select
                      clearable
                      size="mini"
                      v-model="queryParams.createBy"
                      @focus="chooseRefer('CONTACTS_PARAM', true, '制单人')"
                      style="width: 200px"
                    >
                      <el-option
                        v-for="item in manOptions"
                        :key="item.id"
                        :label="item.name"
                        :value="item.code"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
          </CollapseTransition>
        </el-form>
        <el-divider class="lines"
          ><i
            style="cursor: pointer"
            :class="expanded ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
            @click="drop"
          ></i
        ></el-divider>

        <div class="btn_grooup">
          <el-button-group>
            <el-button type="primary" size="mini" @click="addOrder"
              >新增</el-button
            >
          </el-button-group>
          <el-button-group>
            <el-dropdown @command="btnImport">
              <el-button type="primary" size="mini">
                导入<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-button size="mini" type="primary" @click="useImportTemplate"
                  >模板下载</el-button
                >
                <el-upload ref="upload" action="" :http-request="onUpload">
                  <el-button size="mini" type="primary">数据导入</el-button>
                </el-upload>
              </el-dropdown-menu>
            </el-dropdown>
          </el-button-group>
        </div>

        <el-table
          v-loading="loading"
          :data="tableList"
          fit
          :cell-style="{ borderColor: '#c0c0c0' }"
          :header-cell-style="{ borderColor: '#c0c0c0' }"
          class="exporttable"
          border
          show-summary
          :summary-method="getSummaries"
          highlight-current-row
          height="600"
          max-height="600"
          style="font-size: 12px"
          ref="multipleTable"
          @row-click="select"
          @row-dblclick="doubleClick"
        >
          <el-table-column
            show-overflow-tooltip
            label="单据号"
            align="center"
            prop="code"
            width="150px"
          />
          <el-table-column
            show-overflow-tooltip
            label="单据状态"
            align="center"
            prop="status"
            width="100px"
            :formatter="formatterStatus"
          />
          <el-table-column
            show-overflow-tooltip
            label="调出库存组织"
            align="center"
            prop="deliveryInventoryOrgName"
            width="200px"
          />
          <el-table-column
            show-overflow-tooltip
            label="订单类型"
            align="center"
            prop="billType"
            width="220px"
            :formatter="formatterBillType"
          />
          <el-table-column
            show-overflow-tooltip
            label="制单人"
            align="center"
            prop="createByName"
            width="100px"
          />
          <el-table-column
            show-overflow-tooltip
            label="当前审批人"
            align="center"
            width="120"
            prop="approveUser"
          />
          <el-table-column
            show-overflow-tooltip
            label="单据日期"
            align="center"
            prop="billDate"
            width="100px"
          />
          <el-table-column
            show-overflow-tooltip
            label="调拨方式"
            align="center"
            prop="allotType"
            width="180px"
          >
            <template slot-scope="scope">
              <span>{{
                scope.row.allotType == "2"
                  ? "财务组织间调拨"
                  : "财务组织内库存组织内调拨"
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="调拨出库单号"
            align="center"
            prop="deliveryCode"
            width="150px"
          />
          <el-table-column
            show-overflow-tooltip
            label="调拨入库单号"
            align="center"
            prop="storageCode"
            width="150px"
          />
          <el-table-column
            show-overflow-tooltip
            label="调拨入库组织"
            align="center"
            prop="storageInventoryOrgName"
            width="200px"
          />
          <el-table-column
            show-overflow-tooltip
            label="调出业务员"
            align="center"
            prop="businessPersonalName"
            width="100px"
          />
          <el-table-column
            show-overflow-tooltip
            label="调出部门"
            align="center"
            prop="deliveryDeptName"
            width="120px"
          />
          <el-table-column
            show-overflow-tooltip
            label="币种"
            align="center"
            prop="currencyName"
          />
          <el-table-column
            show-overflow-tooltip
            label="折本汇率"
            align="center"
            prop="rate"
          />
          <el-table-column
            show-overflow-tooltip
            label="在途归属"
            align="center"
            prop="onRouteAffilliation"
            width="200px"
          />
          <el-table-column
            show-overflow-tooltip
            label="总数量"
            align="center"
            prop="qty"
          />
          <el-table-column
            show-overflow-tooltip
            label="结算路径"
            align="center"
            prop="accountPath"
            width="100px"
          />
          <el-table-column
            show-overflow-tooltip
            label="客户"
            align="center"
            prop="customerName"
            width="150px"
          />
          <el-table-column
            show-overflow-tooltip
            label="调出仓库"
            align="center"
            prop="deliveryWarehouseName"
            width="180px"
          />
          <el-table-column
            show-overflow-tooltip
            label="调入仓库"
            align="center"
            prop="storageWarehouseName"
            width="180px"
          />
          <el-table-column
            show-overflow-tooltip
            label="物流项目组"
            align="center"
            prop="materialProject"
            width="120px"
          />
          <el-table-column
            show-overflow-tooltip
            label="利润中心"
            align="center"
            prop="liacenterName"
            width="150px"
          />
          <!-- <el-table-column show-overflow-tooltip label="已同步WMS" align="center" prop="isSendWms" width="150px"/> -->
          <el-table-column
            show-overflow-tooltip
            label="备注"
            align="center"
            prop="remark"
            width="150px"
          />
          <el-table-column
            show-overflow-tooltip
            label="制单日期"
            align="center"
            prop="createTime"
            width="150px"
          />
          <!-- <el-table-column show-overflow-tooltip label="审批人" align="center" prop="code" width="150px"/> -->
          <!-- <el-table-column show-overflow-tooltip label="审批日期" align="center" prop="code" width="150px"/> -->
          <!-- <el-table-column show-overflow-tooltip label="最后修改人" align="center" prop="updateByName" width="100px"/>
          <el-table-column show-overflow-tooltip label="最后修改时间" align="center" prop="updateTime" width="150px"/> -->
          <el-table-column
            fixed="right"
            label="操作"
            align="center"
            width="180"
          >
            <template slot-scope="scope">
              <el-button type="text" size="mini" @click="check(scope.row)"
                >查看</el-button
              >
              <el-button
                type="text"
                size="mini"
                v-if="scope.row.status == '0' || scope.row.status == '3'"
                @click="edit(scope.row)"
                >编辑</el-button
              >
              <el-button
                type="text"
                size="mini"
                v-if="scope.row.status == '0' || scope.row.status == '3'"
                @click="commit(scope.row)"
                >提交</el-button
              >
              <el-button
                type="text"
                size="mini"
                v-if="scope.row.status == '1'"
                @click="handleBack(scope.row)"
                >流程收回</el-button
              >
              <el-button
                type="text"
                size="mini"
                v-if="scope.row.status == '0' || scope.row.status == '3'"
                @click="deleteids(scope.row)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <pagination
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList(queryParams)"
          style="height: 32px; padding: 0 !important; flex: 1; overflow-x: auto"
        />

        <el-tabs style="margin-top: 10px">
          <el-tab-pane label="物料信息">
            <el-table
              v-loading="itemLoading"
              :data="materialInfo"
              fit
              :cell-style="{ borderColor: '#c0c0c0' }"
              :header-cell-style="{ borderColor: '#c0c0c0' }"
              class="exporttable"
              border
              height="500"
              max-height="500"
              style="font-size: 12px"
            >
              <el-table-column
                show-overflow-tooltip
                label="行号"
                align="center"
                prop="rowno"
              />
              <el-table-column
                show-overflow-tooltip
                label="物料编码"
                align="center"
                prop="materialCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="物料名称"
                align="center"
                prop="materialName"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="调拨出库单号"
                align="center"
                prop="deliveryCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="调拨入库单号"
                align="center"
                prop="storageCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="规格"
                align="center"
                prop="specification"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产厂家/代理人"
                align="center"
                prop="manufacturer"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="产地"
                align="center"
                prop="originPlace"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="型号"
                align="center"
                prop="model"
              />
              <el-table-column
                show-overflow-tooltip
                label="单位"
                align="center"
                prop="unitName"
              />
              <!-- <el-table-column show-overflow-tooltip label="调出仓库" align="center" prop="deliveryWarehouseName"/> -->
              <el-table-column
                show-overflow-tooltip
                label="数量"
                align="center"
                prop="qty"
              />
              <el-table-column
                show-overflow-tooltip
                label="主单位"
                align="center"
                prop="mainUnit"
              />
              <el-table-column
                show-overflow-tooltip
                label="换算率"
                align="center"
                prop="equation"
              />
              <el-table-column
                show-overflow-tooltip
                label="主数量"
                align="center"
                prop="mainQty"
              />
              <el-table-column
                show-overflow-tooltip
                label="税率"
                align="center"
                prop="rate"
              />
              <!-- <el-table-column show-overflow-tooltip label="调入仓库" align="center" prop="storageWarehouseName"/> -->
              <el-table-column
                show-overflow-tooltip
                label="批次号"
                align="center"
                prop="patchNo"
              />
              <el-table-column
                show-overflow-tooltip
                label="产品批号"
                align="center"
                prop="producBatch"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产日期"
                align="center"
                prop="manufactureDate"
              />
              <el-table-column
                show-overflow-tooltip
                label="有效期至/失效日期"
                align="center"
                prop="periodEndDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="批准文号"
                align="center"
                prop="ratifyCode"
              />
              <el-table-column
                show-overflow-tooltip
                label="注册证号"
                align="center"
                prop="registration"
              />
              <el-table-column
                show-overflow-tooltip
                label="商品名"
                align="center"
                prop="productCode"
              />
              <el-table-column
                show-overflow-tooltip
                label="通用名"
                align="center"
                prop="commonCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="剂型"
                align="center"
                prop="drug"
              />
              <el-table-column
                show-overflow-tooltip
                label="调入调出结算规则明细"
                align="center"
                prop="ruleDetail"
                width="180px"
              />
              <el-table-column
                show-overflow-tooltip
                label="上市许可持有人"
                align="center"
                prop="marketingApprovalPersonal"
                width="120px"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产许可证号/经营许可证号/备案凭证号"
                align="center"
                prop="production"
                width="260px"
              />
              <el-table-column
                show-overflow-tooltip
                label="pi码"
                align="center"
                prop="pi"
              />
              <!-- <el-table-column show-overflow-tooltip label="无税金额" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="备注" align="center" prop="code"/> -->
              <el-table-column
                show-overflow-tooltip
                label="类别"
                align="center"
                prop="classify"
              />
              <el-table-column
                show-overflow-tooltip
                label="客户物料码"
                align="center"
                prop="customerLogistic"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="客户物料名称"
                align="center"
                prop="customerLogisticName"
                width="150px"
              />
            </el-table>
          </el-tab-pane>

          <el-tab-pane label="收发货信息">
            <el-table
              :data="receiveInfo"
              fit
              :cell-style="{ borderColor: '#c0c0c0' }"
              :header-cell-style="{ borderColor: '#c0c0c0' }"
              class="exporttable"
              border
              max-height="380"
              style="font-size: 12px"
            >
              <el-table-column
                show-overflow-tooltip
                label="行号"
                align="center"
                prop="rowno"
              />
              <el-table-column
                show-overflow-tooltip
                label="调拨出库单号"
                align="center"
                prop="deliveryCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="调拨入库单号"
                align="center"
                prop="storageCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产厂家/代理人"
                align="center"
                prop="manufacturer"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="产地"
                align="center"
                prop="originPlace"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="类别"
                align="center"
                prop="classify"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="调出仓库"
                align="center"
                prop="deliveryWarehouseName"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="调入仓库"
                align="center"
                prop="storageWarehouseName"
                width="150px"
              />
              <!-- <el-table-column show-overflow-tooltip label="收货利润中心" align="center" prop="code"/>
              <el-table-column show-overflow-tooltip label="发货利润中心" align="center" prop="code"/> -->
              <el-table-column
                show-overflow-tooltip
                label="调入业务员"
                align="center"
                prop="businessPersonalName"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="产品批号"
                align="center"
                prop="productBatch"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产日期"
                align="center"
                prop="manufactureDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="有效期至/失效日期"
                align="center"
                prop="periodEndDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="批准文号"
                align="center"
                prop="ratifyCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="注册证号"
                align="center"
                prop="registration"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="商品名"
                align="center"
                prop="productCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="通用名"
                align="center"
                prop="commonCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="剂型"
                align="center"
                prop="drug"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="收货客户"
                align="center"
                prop="customerName"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="收货地址"
                align="center"
                prop="addressaddress"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="收货地区"
                align="center"
                prop="area"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="收货地点"
                align="center"
                prop="place"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="计划发货日期"
                align="center"
                prop="deliveryDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="计划到货日期"
                align="center"
                prop="strageDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="运输方式"
                align="center"
                prop="transportation"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="备注"
                align="center"
                prop="remark"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="客户物料编码"
                align="center"
                prop="customerLogistic"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="客户物料名称"
                align="center"
                prop="customerLogisticName"
                width="150px"
              />
            </el-table>
          </el-tab-pane>

          <el-tab-pane label="价格费用">
            <el-table
              :data="priceList"
              fit
              :cell-style="{ borderColor: '#c0c0c0' }"
              :header-cell-style="{ borderColor: '#c0c0c0' }"
              class="exporttable"
              border
              max-height="380"
              style="font-size: 12px"
            >
              <el-table-column
                show-overflow-tooltip
                label="行号"
                align="center"
                prop="rowno"
              />
              <el-table-column
                show-overflow-tooltip
                label="调拨出库单号"
                align="center"
                prop="deliveryCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="调拨入库单号"
                align="center"
                prop="storageCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产厂家/代理人"
                align="center"
                prop="manufacturer"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="产地"
                align="center"
                prop="originPlace"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="类别"
                align="center"
                prop="classify"
                width="150px"
              />
              <!-- <el-table-column show-overflow-tooltip label="税率" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="无税单价" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="含税单价" align="center" prop="code"/> -->
              <el-table-column
                show-overflow-tooltip
                label="产品批号"
                align="center"
                prop="productBatch"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产日期"
                align="center"
                prop="manufactureDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="有效期至/失效日期"
                align="center"
                prop="periodEndDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="批准文号"
                align="center"
                prop="ratifyCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="注册证号"
                align="center"
                prop="registration"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="商品名"
                align="center"
                prop="productCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="通用名"
                align="center"
                prop="commonCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="剂型"
                align="center"
                prop="drug"
                width="150px"
              />
              <!-- <el-table-column show-overflow-tooltip label="询价无税价" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="询价含税价" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="税额" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="加价率" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="无税金额" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="价税合计" align="center" prop="code"/> -->
              <el-table-column
                show-overflow-tooltip
                label="客户物料码"
                align="center"
                prop="customerLogistic"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="客户物料名称"
                align="center"
                prop="customerLogisticName"
                width="150px"
              />
            </el-table>
          </el-tab-pane>

          <el-tab-pane label="执行结果">
            <el-table
              :data="resultList"
              fit
              :cell-style="{ borderColor: '#c0c0c0' }"
              :header-cell-style="{ borderColor: '#c0c0c0' }"
              class="exporttable"
              border
              max-height="380"
              style="font-size: 12px"
            >
              <el-table-column
                show-overflow-tooltip
                label="行号"
                align="center"
                prop="rowno"
              />
              <el-table-column
                show-overflow-tooltip
                label="调拨出库单号"
                align="center"
                prop="deliveryCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="调拨入库单号"
                align="center"
                prop="storageCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产厂家/代理人"
                align="center"
                prop="manufacturer"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="产地"
                align="center"
                prop="originPlace"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="类别"
                align="center"
                prop="classify"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="产品批号"
                align="center"
                prop="productBatch"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="生产日期"
                align="center"
                prop="manufactureDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="有效期至/失效日期"
                align="center"
                prop="periodEndDate"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="批准文号"
                align="center"
                prop="ratifyCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="注册证号"
                align="center"
                prop="registration"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="商品名"
                align="center"
                prop="productCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="通用名"
                align="center"
                prop="commonCode"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="剂型"
                align="center"
                prop="drug"
                width="150px"
              />
              <!-- <el-table-column show-overflow-tooltip label="已调出主数量" align="center" prop="code"/>
            <el-table-column show-overflow-tooltip label="已调入主数量" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="调拨在途主数量" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="已发货主数量" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="途损主数量" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="累计退货主数量" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="调出与调入已结算主数量" align="center" prop="code"/> -->
              <!-- <el-table-column show-overflow-tooltip label="调出与调入已结算金额" align="center" prop="code"/> -->
              <el-table-column
                show-overflow-tooltip
                label="客户物料码"
                align="center"
                prop="customerLogistic"
                width="150px"
              />
              <el-table-column
                show-overflow-tooltip
                label="客户物料名称"
                align="center"
                prop="customerLogisticName"
                width="150px"
              />
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </el-card>
    </div>

    <Add
      v-model="isList"
      v-if="!isList"
      :pageStu="page"
      :disable="disable"
      :row="rowDetail"
      @refresh="searchList"
    />
    <Refers ref="refer" @doSubmit="selectionsToInput" :single="true" />
  </div>
</template>

<script>
import Add from "./add.vue";
import CollapseTransition from "@/components/MyCollapse/collapse.vue";
import Refers from "@/components/Refers/refers.vue";
import {
  getOrderList,
  delOrder,
  submitOrder,
  listStAllotItem,
  importData,
  oaBack,
} from "@/api/purchase/transferOrder.js";
export default {
  name: "transferOrder",
  dicts: ["sys_allot_billtype", "oa_templete_id"],
  components: {
    Add,
    CollapseTransition,
    Refers,
  },
  data() {
    return {
      loading: true,
      itemLoading: false,
      expanded: false,
      // 页面配置
      isList: true,
      // 页面状态
      page: "",
      queryParams: {
        deliveryInventoryOrg: "",
        storageInventoryOrg: "",
        code: this.$route.query.billCode,
        createBy: "",
        pageNum: 1,
        pageSize: 50,
      },
      //单据日期查询范围
      dateRange: [],
      referCondition: {
        type: "",
        isPage: true,
        title: "",
      },
      options: [
        {
          value: "1",
          label: "是",
        },
        {
          value: "0",
          label: "否",
        },
      ],
      chuOrgOptions: [],
      ruOrgOptions: [],
      manOptions: [],
      tableList: [],
      total: 0,
      materialInfo: [],
      receiveInfo: [],
      priceList: [],
      resultList: [],
      rowDetail: {},
      disable: false,
      ids: [],
    };
  },
  created() {
    this.getList(this.queryParams);
  },
  methods: {
    // 指定列合计
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        const values = data.map((item) => Number(item[column.property]));
        if (column.property === "qty") {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[index];
        }
      });
      return sums;
    },
    formatterBillType(row) {
      switch (row.billType) {
        case "5X-01":
          return "普通+不传wms+外仓互调（同组织）";
        case "5X-Cxx-01":
          return "普通+传wms+外仓调中心仓";
        case "5X-Cxx-02":
          return "普通+传wms+中心仓调中心仓（跨组织）";
        case "5X-Cxx-03":
          return "普通+传wms+中心仓调外仓";
        case "5X-Cxx-04":
          return "普通+传wms+中心仓中心分仓互调";
        case "5X-Cxx-05":
          return "GH+不传WMS+外仓互调（同组织）";
        case "5X-Cxx-06":
          return "GH+传WMS+中心仓调外仓";
        case "5X-Cxx-07":
          return "GH+传WMS+外仓调中心仓";
        case "5X-Cxx-08":
          return "GH+传WMS+中心仓调中心仓";
        case "5X-Cxx-09":
          return "GH+传WMS+中心仓中心分仓互调";
      }
    },
    // 格式化表格内容
    formatterStatus(row) {
      switch (row.status) {
        case "0":
          return "未提交";
        case "1":
          return "审批中";
        case "2":
          return "已完成";
        case "3":
          return "已驳回";
      }
    },
    searchList() {
      this.getList(this.queryParams);
    },
    resetList() {
      this.dateRange = [];
      this.queryParams = {
        deliveryInventoryOrg: "",
        billType: "",
        storageInventoryOrg: "",
        code: "",
        createBy: "",
        pageNum: 1,
        pageSize: 50,
      };
      this.getList(this.queryParams);
    },
    getList(params) {
      this.loading = true;
      getOrderList(this.addDateRange(params, this.dateRange))
        .then((res) => {
          if (res.code === 200) {
            this.tableList = res.rows;
            this.total = res.total;
          }
          this.loading = false;
        })
        .then(() => {
          // 合计不显示重绘
          this.$refs.multipleTable.doLayout();
        })
        .catch((err) => {});
    },
    getlistStAllotItem(pid) {
      this.itemLoading = true;
      listStAllotItem(pid).then((response) => {
        this.materialInfo = response.rows;
        this.itemLoading = false;
      });
    },
    addOrder() {
      this.isList = false;
      this.page = "add";
      this.disable = false;
    },
    check(row) {
      this.isList = false;
      this.page = "check";
      this.rowDetail = row;
      this.disable = true;
    },
    doubleClick(row) {
      this.isList = false;
      this.page = "check";
      this.rowDetail = row;
      this.disable = true;
    },
    edit(row) {
      this.isList = false;
      this.page = "edit";
      this.rowDetail = row;
      this.disable = false;
    },
    commit(row) {
      this.$modal.loading("提交中...");
      submitOrder(row)
        .then((res) => {
          if (res.code === 200) {
            this.$modal.closeLoading();
            this.$modal.notifySuccess("提交成功");
            this.getList(this.queryParams);
          }
        })
        .catch((err) => {
          this.$modal.closeLoading();
        });
    },
    //查询条件单据日期改变后
    billDateAfterChange(val) {
      console.log("val", val);
    },
    // 选中某行
    select(row) {
      this.getlistStAllotItem(row.id);
    },
    // 行内删除
    deleteids(row) {
      console.log("row", row);
      this.$modal
        .confirm("确认信息")
        .then(() => {
          delOrder(row.id).then((res) => {
            if (res.code === 200) {
              this.$modal.notifySuccess("删除成功");
              this.getList(this.queryParams);
            }
          });
        })
        .catch(() => {});
    },

    drop() {
      this.expanded = !this.expanded;
    },
    chooseRefer(type, isPage, title) {
      this.referCondition.type = type;
      this.referCondition.isPage = isPage;
      this.referCondition.title = title;
      this.$refs.refer.init(this.referCondition);
    },
    selectionsToInput(selection) {
      if (this.referCondition.title == "调出库存组织") {
        this.chuOrgOptions = selection;
        this.queryParams.deliveryInventoryOrg = selection[0].id;
      }
      if (this.referCondition.title == "调入库存组织") {
        this.ruOrgOptions = selection;
        this.queryParams.storageInventoryOrg = selection[0].id;
      }
      if (this.referCondition.title == "制单人") {
        this.manOptions = selection;
        this.queryParams.createBy = selection[0].code;
      }
    },
    //导入按钮
    btnImport(command) {
      if (command == "useImportTemplate") {
        this.useImportTemplate();
      }
      if (command == "useImportData") {
        this.useImportData();
      }
    },
    //模板下载
    useImportTemplate() {
      this.download(
        "pu/allot/importTemplate",
        {},
        `调拨单导入模板_${new Date().getTime()}.xlsx`
      );
    },
    //导入
    useImportData() {
      console.log("导入");
    },
    // 上传文件
    onUpload(file) {
      this.loading = true;
      let formData = new FormData();
      formData.append("file", file.file);
      importData(formData)
        .then((res) => {
          console.log("res", res);
          if (res.code == "200") {
            this.$message.success(res.msg);
          } else {
            this.$message.success(res.msg);
          }
        })
        .catch((e) => {
          console.log("e", e);
          this.$message.error(e.message);
        })
        .finally((e) => {
          this.$refs["upload"].clearFiles();
          this.resetList();
          this.loading = false;
        });
    },
    //流程收回
    async handleBack(row) {
      try {
        const { msg, code } = await oaBack({
          fdTemplateId: this.dict.type.oa_templete_id.find((item) => {
            return item.label == "调拨订单";
          }).value,
          billCode: row.code,
          billMaker: row.createBy,
        });
        if (code === 200) {
          this.$emit("success");
          this.$notify.success(msg);
        }
      } catch (err) {
        console.error(err);
      } finally {
        this.getList(this.queryParams);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
#transferOrder {
  padding: 12px;
  box-sizing: border-box;
  overflow-y: scroll;
}
.btn_grooup {
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-end;
}
.lines {
  margin-top: 0;
}
.el-pagination {
  margin-top: 10px;
  text-align: right;
}
::v-deep .el-table__row > td {
  border-right: none;
}
::v-deep .el-card .el-form-item {
  margin-bottom: 3px;
}
</style>
<style>
.exporttable {
  border: solid 1px #c0c0c0;
}
.el-dropdown {
  vertical-align: top;
}
.el-dropdown + .el-dropdown {
  margin-left: 15px;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>
