<template>
  <basic-container>
<!--    <div class="avue-crud">
      <el-row :hidden="!search" style="padding:6px 18px">
        &lt;!&ndash; 查询模块 &ndash;&gt;
        <el-form :inline="true" :model="query">
          <el-form-item label="提货证件:">
            <el-input v-model="query.deliveryDocument" placeholder="请输入提货证件"></el-input>
          </el-form-item>
          <el-form-item label="证件类型:">
            <el-input v-model="query.certificateType" placeholder="请输入证件类型"></el-input>
          </el-form-item>
          &lt;!&ndash; 查询按钮 &ndash;&gt;
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="searchChange">搜 索</el-button>
            <el-button icon="el-icon-delete" @click="searchReset()">清 空</el-button>
          </el-form-item>
        </el-form>
      </el-row>
      <el-row>
        <div class="avue-crud__header">
          &lt;!&ndash; 头部左侧按钮模块 &ndash;&gt;
          <div class="avue-crud__left">
            <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新 增</el-button>
            <el-button type="danger" icon="el-icon-delete" @click="handleDelete" plain>删 除</el-button>
          </div>
          &lt;!&ndash; 头部右侧按钮模块 &ndash;&gt;
          <div class="avue-crud__right">
            <el-button icon="el-icon-refresh" @click="searchChange" circle></el-button>
            <el-button icon="el-icon-search" @click="searchHide" circle></el-button>
          </div>
        </div>
      </el-row>
      <el-row>
        &lt;!&ndash; 列表模块 &ndash;&gt;
        <el-table ref="table" v-loading="loading"
                  @selection-change="selectionChange"
                  :data="data"
                  :height="height"
                  style="width: 100%"
                  :border="option.border">
          <el-table-column type="selection" v-if="option.selection" width="55" align="center"></el-table-column>
          <el-table-column type="expand" v-if="option.expand" align="center"></el-table-column>
          <el-table-column v-if="option.index" label="#" type="index" width="50" align="center">
          </el-table-column>
          <template v-for="(item,index) in option.column">
            &lt;!&ndash; table字段 &ndash;&gt;
            <el-table-column v-if="item.hide!==true"
                             :prop="item.prop"
                             :label="item.label"
                             :width="item.width"
                             :key="index">
            </el-table-column>
          </template>
          &lt;!&ndash; 操作栏模块 &ndash;&gt;
          <el-table-column prop="menu" label="操作" :width="220" align="center">
            <template #="{row}">
              <el-button type="primary" text icon="el-icon-view" @click="handleView(row)">查看</el-button>
              <el-button type="primary" text icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
              <el-button type="primary" text icon="el-icon-delete" @click="rowDel(row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-row>
      <el-row>
        <div class="avue-crud__pagination" style="width:100%">
          &lt;!&ndash; 分页模块 &ndash;&gt;
          <el-pagination align="right"
                         background
                         @size-change="sizeChange"
                         @current-change="currentChange"
                         :current-page="page.currentPage"
                         :page-sizes="[10, 20, 30, 40, 50, 100]"
                         :page-size="page.pageSize"
                         layout="total, sizes, prev, pager, next, jumper"
                         :total="page.total">
          </el-pagination>
        </div>
      </el-row>
      &lt;!&ndash; 表单模块 &ndash;&gt;
      <el-dialog :title="title"
                 v-model="box"
                 width="50%"
                 :before-close="beforeClose"
                 append-to-body>
        <el-form :disabled="view" ref="form" :model="form" label-width="80px">
          &lt;!&ndash; 表单字段 &ndash;&gt;
          <el-form-item label="提货时间" prop="pickUpTime">
            <el-input v-model="form.pickUpTime" placeholder="请输入提货时间"/>
          </el-form-item>
          <el-form-item label="提货人" prop="consignee">
            <el-input v-model="form.consignee" placeholder="请输入提货人"/>
          </el-form-item>
          <el-form-item label="提货车牌" prop="pickUpPlate">
            <el-input v-model="form.pickUpPlate" placeholder="请输入提货车牌"/>
          </el-form-item>
          <el-form-item label="提货证件" prop="deliveryDocument">
            <el-input v-model="form.deliveryDocument" placeholder="请输入提货证件"/>
          </el-form-item>
          <el-form-item label="证件类型" prop="certificateType">
            <el-select v-model="form.certificateType" clearable placeholder="请选择证件类型">
              <el-option
                v-for="item in certificateTypeData"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="item.dictKey">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="费用合计" prop="totalCost">
            <el-input v-model="form.totalCost" placeholder="请输入费用合计"/>
          </el-form-item>
        </el-form>
        &lt;!&ndash; 表单按钮 &ndash;&gt;
        <template #footer>
          <span v-if="!view" class="dialog-footer">
            <el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit">提 交</el-button>
            <el-button icon="el-icon-circle-close" @click="box = false">取 消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>-->
    <div class="avue-crud" :style="`height:`+ height+';overflow:auto;' " >
      <el-form :disabled="view" ref="form" :model="form" label-width="100px" :rules="rules" >
        <!-- 表单字段 -->
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="提货时间" prop="pickUpTime">
<!--              <el-input v-model="form.pickUpTime" placeholder="请输入提货时间"/>-->
              <el-date-picker style="width: 100%"
                v-model="form.pickUpTime"
                type="datetime"
                placeholder="请输入提货时间"
                format="YYYY-MM-DD hh:mm:ss"
                value-format="YYYY-MM-DD hh:mm:ss"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提货人" prop="consignee">
              <el-input v-model="form.consignee" placeholder="请输入提货人"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="提货车牌号码" prop="pickUpPlate" label-width="98px">
              <el-input v-model="form.pickUpPlate" placeholder="请输入提货车牌"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提货证件号码" prop="deliveryDocument" label-width="120px">
              <el-input v-model="form.deliveryDocument" placeholder="请输入提货证件"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="证件类型" prop="certificateType">
              <el-select v-model="form.certificateType" clearable placeholder="请选择证件类型" style="width: 100%">
                <el-option
                  v-for="item in certificateType"
                  :key="item.dictKey"
                  :label="item.dictValue"
                  :value="item.dictKey">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">

          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="费用" prop="freightMark">
              <el-checkbox-group v-model="form.freightMark" @change="handleCheckedCitiesChange">
                <el-checkbox style="width: 16%;margin-bottom: 3%"
                             v-for="(item,index) in clientType"
                             :key="item.dictKey"
                             :label="item.dictKey"
                >{{item.dictValue}}
                  <el-input type="number"   v-model="item.remark" placeholder="请输入费用" :disabled = "this.form?.freightMark?.indexOf(item.dictKey) == -1"
                            @change="textbox($event,index)"  style="width: 70%"/>
                </el-checkbox>

              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="费用合计" prop="totalCost">
              <el-input v-model="form.totalCost" placeholder="请输入费用合计"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="物品明细" prop="certificateType">
              <el-tabs type="border-card" style="width: 100%">
                <el-tab-pane label="定制品">
                  <el-button type="primary" link icon="el-icon-view" @click="handleAddOrder" v-if="orderAdd">新 增</el-button>
                  <el-table ref="table" v-loading="loading"
                            @selection-change="selectionChange"
                            :data="dataList"
                            style="width: 100%"
                            :border="option.border">
                    <el-table-column v-if="option.index" label="序号" type="index" width="60" align="center"></el-table-column>
                    <template v-for="(item,index) in option.columnOrder">

                      <!-- table字段 -->
                      <el-table-column v-if="item.hide!==true"
                                       :prop="item.prop"
                                       :label="item.label"
                                       :width="item.width"
                                       :key="index">
                      </el-table-column>
                    </template>
                    <!-- 操作栏模块 -->
                                    <el-table-column prop="menu"  fixed="right" label="操作" :width="220" align="center">
                                      <template #="{row}">
<!--                                        <el-button type="primary" text icon="el-icon-view" @click="handleView(row)">查看</el-button>-->
<!--                                        <el-button type="primary" text icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>-->
                                        <el-button type="primary" text icon="el-icon-delete" @click="rowOrder(row)">移除</el-button>
                                      </template>
                                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <el-tab-pane label="库存品">
                  <el-button type="primary" text icon="el-icon-view" @click="handleAddView(row)">新增</el-button>
                  <el-table ref="table" v-loading="loading"
                                                       @selection-change="selectionChange"
                                                       :data="data"
                                                       style="width: 100%"
                                                       :border="option.border">
<!--                    <el-table-column type="selection" v-if="option.selection" width="50" align="center"></el-table-column>-->
                    <el-table-column type="expand" v-if="option.expand" align="center"></el-table-column>
                    <el-table-column v-if="option.index" label="序号" type="index" width="70" align="center">
                    </el-table-column>
                  <template v-for="(item,index) in option.columnStock">
                    <!-- table字段 -->
                    <el-table-column v-if="item.hide!==true"
                                     :prop="item.prop"
                                     :label="item.label"
                                     :width="item.width"
                                     :key="index">
                    </el-table-column>
                  </template>
                  <!-- 操作栏模块 -->
                    <el-table-column prop="menu" label="添加数量" :width="220" align="center">
                      <template #="{row}">
                        <el-input v-model="row.inventoryQuantity"  @blur="handleNumberRange($event,row)" ></el-input>
                      </template>
                    </el-table-column>
                    <!-- 操作栏模块 -->
                    <el-table-column prop="menu" label="操作" :width="220" align="center">
                      <template #="{row}">
                        <el-button type="primary" text icon="el-icon-delete" @click="rowStock(row)">移除</el-button>
                      </template>
                    </el-table-column>
                </el-table>
                </el-tab-pane>
              </el-tabs>



            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="提货证件"  label-width ='120px'>
              <el-upload
                v-model:file-list="fileListSell"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="(response, file, fileList) => {uploadSuccess(fileListSell)}"
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传jpg/png文件，且不超过500kb
                  </div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="文员确定图片"  label-width ='120px'>
              <el-upload
                v-model:file-list="fileListClerk"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="(response, file, fileList) => {uploadSuccess(fileListClerk)}"
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传jpg/png文件，且不超过500kb
                  </div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="库管签收图片"  label-width ='120px'>
              <el-upload
                v-model:file-list="fileListLibrary"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="(response, file, fileList) => {uploadSuccess(fileListLibrary)}"
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传jpg/png文件，且不超过500kb
                  </div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>


      </el-form>
      <!-- 表单按钮 -->
      <div class="foot" v-if="!view" >
        <div  class="dialog-footer" >
          <el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit('form')">提 交</el-button>
          <!--          <el-button icon="el-icon-circle-close" @click="box = false">取 消</el-button>-->
        </div>
      </div>
    </div>
    <el-dialog v-model="dialogFormVisible" title="添加库存品" style="width: 80%  ">
      <el-table ref="table" v-loading="loading"
                @selection-change="selectionChangeStock"
                @row-click="handleHighlightChangeTable"
                :data="dataOwn"
                style="width: 100%"
                :border="option.border">
        <el-table-column type="selection" v-if="option.selection" width="50" align="center"></el-table-column>
        <el-table-column type="expand" v-if="option.expand" align="center"></el-table-column>
        <el-table-column v-if="option.index" label="序号" type="index" width="70" align="center">
        </el-table-column>
        <template v-for="(item,index) in option.columnStock">
          <!-- table字段 -->
          <el-table-column v-if="item.hide!==true"
                           :prop="item.prop"
                           :label="item.label"
                           :width="item.width"
                           :key="index">
          </el-table-column>
        </template>
        <!-- 操作栏模块 -->
        <el-table-column prop="menu" label="添加数量" :width="220" align="center">
          <template #="{row}">
            <el-input v-model="row.inventoryQuantity"  @blur="handleNumberRange($event,row)" ></el-input>
          </template>
        </el-table-column>
      </el-table>
      <div class="avue-crud__pagination" style="width:100%">
        <!-- 分页模块 -->
        <el-pagination align="right"
                       background
                       @size-change="sizeChangeStock"
                       @current-change="currentChangeStock"
                       :current-page="pageStock.currentPage"
                       :page-sizes="[10, 20, 30, 40, 50, 100]"
                       :page-size="pageStock.pageSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="pageStock.total">
        </el-pagination>
      </div>

      <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <!--        <el-button type="primary" @click="dialogFormVisible = false"> 确定 </el-button>-->
        <el-button type="primary" @click="callFordelivery('1')"> 确定 </el-button>
      </span>
      </template>
    </el-dialog>
    <el-dialog v-model="dialogFormOrderVisible" title="添加订单" style="width: 80%  ">

      <tablecmt
        ref="multipleTable"
        :columnList="columnList"
        :tableData="dataOrder"
        :loading="loading"
        @inputTxt="inputsc"
        @timeCheck="timesc"
        @btnCheck="btnsc"
        @selectCheck="selectsc"
        @selection="selectionChange"
      >
        <template #default="slotProps">
     <!--     <el-button type="primary" text icon="el-icon-view" @click="handleView(slotProps.scope)">查看</el-button>
          <el-button type="primary" text icon="el-icon-edit" @click="handleCallDeliveryOwn(slotProps.scope)">修改客户信息</el-button>-->
        </template>
      </tablecmt>
      <div class="avue-crud__pagination" style="width:100%">
        <!-- 分页模块 -->
        <el-pagination align="right"
                       background
                       @size-change="sizeChangeStock"
                       @current-change="currentChangeStock"
                       :current-page="pageOrder.currentPage"
                       :page-sizes="[10, 20, 30, 40, 50, 100]"
                       :page-size="pageOrder.pageSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="pageOrder.total">
        </el-pagination>
      </div>

      <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogFormOrderVisible = false">取消</el-button>
        <!--        <el-button type="primary" @click="dialogFormVisible = false"> 确定 </el-button>-->
        <el-button type="primary" @click="callFordeliveryOrder('1')"> 确定 </el-button>
      </span>
      </template>
    </el-dialog>

  </basic-container>
</template>

<script>
import { getList, getDetail, add, update, remove } from "@/api/distribution/distrilbutionBillLading";
import { getListOwn } from "@/api/distribution/distributionParcelList";
import option from "@/option/distribution/distrilbutionBillLading";
import { mapGetters } from "vuex";
import { getDictionaryBiz } from '@/api/system/dict';
import { getToken } from '@/utils/auth';
import { getListStockList } from '@/api/distribution/distributionStockList';
import { getListOne} from "@/api/distribution/distributionStockArticle";
import dayjs from 'dayjs';

export default {
  data () {
    return {
      dialogFormVisible: false,
      dialogFormOrderVisible: false, //订单详细
      height: 0,
      // 弹框标题
      title: '',
      // 是否展示弹框
      box: false,
      // 是否显示查询
      search: true,
      orderAdd: false,
      // 加载中
      loading: false,
      // 是否为查看模式
      view: false,
      // 查询信息
      query: {},
      queryOrder: {},
      dataOrder: [],
      // 分页信息
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 40
      },
      pageOrder: {
        currentPage: 1,
        pageSize: 10,
        total: 40
      },
      // 分页信息
      pageStock: {
        currentPage: 1,
        pageSize: 10,
        total: 40
      },
      // 表单数据
      form: {},
      // 选择行
      selectionList: [],
      stockupDate: [], // 时间
      selectionListStock: [],// 库存品选择
      // 表单配置
      option: option,
      // 表单列表
      data: [],
      dataList: [],
      dataOwn: [],
      clientType: [],
      costList: [],
      costListName: [],
      certificateType: [],
      fileListLibrary: [],
      fileListSell: [],
      fileListClerk: [],
      fileList:[
      //   {
      //   name: 'food.jpeg',
      //   url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
      // },
      //   {
      //     name: 'food2.jpeg',
      //     url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
      //   },
      ],
      rules: {
        pickUpTime: [
          { type: 'date', required: true, message: '请选择提货时间', trigger: 'change' }
        ],
        consignee: [
          { required: true, message: '请输入提货人', trigger: 'blur' },
          // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        pickUpPlate: [
          { required: true, message: '请输入提货车牌号', trigger: 'change' }
        ],
        deliveryDocument: [
          { required: true, message: '请输入提货证件码', trigger: 'change' },
          // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        certificateType: [
          { required: true, message: '请选择证件类型', trigger: 'change' }
        ],
        freightMark: [
          { required: true, message: '请选择费用', trigger: 'change' }
        ],
        totalCost: [
          { required: true, message: '请输入费用合计', trigger: 'change' }
        ],
        deliveryDocuments: [
          { required: true, message: '请上传提货证件', trigger: 'change' }
        ],
      },
      columnList: [
        {
          prop: '',
          label: '序号',
          type: 0,
          values: '',
          width: 55,
          checkarr: [],
          fixed: true,
        },
        {
          prop: 'serviceNumber',
          label: '服务号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: true,
          sortable: true,
          head: false,
        },
        {
          prop: 'waybillNumber ',
          label: '运单号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: true,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderCode',
          label: '订单自编号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'mallName',
          label: '商场名称',
          type: 2,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'descriptionGoods',
          label: '货物名称',
          type: 2,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'warehouse',
          label: '所在仓库',
          type: 2,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'warehouseEntryTime',
          label: '入库时间',
          type: 4,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'warehouseEntryTimeEnd',
          label: '最新入库时间',
          type: 4,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'storeTime',
          label: '在库时间',
          type: 1,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'totalNumber',
          label: '订单总件数',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'consigneeUnit',
          label: '收货单位',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        }, {
          prop: 'consigneePerson',
          label: '收货人',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        }, {
          prop: 'handQuantity',
          label: '在库件数',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        }, {
          prop: 'availableQuantity',
          label: '可用数量',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'notReceived',
          label: '未入库数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },  {
          prop: 'sortingQuantity',
          label: '分拣数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },  {
          prop: 'deliveryQuantity',
          label: '配送数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        }, {
          prop: 'transferQuantity',
          label: '中转数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        }, {
          prop: 'signinQuantity',
          label: '签收数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },{
          prop: 'groundingStatusName',
          label: '上架状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },{
          prop: 'allocation',
          label: '货区-货位-货架',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },{
          prop: 'resource',
          label: '订单来源',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'trays',
          label: '所在托盘',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'freezeStatusName',
          label: '冻结状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [
            {
              value: '1',
              label: '已冻结',
            },
            {
              value: '0',
              label: '未冻结',
            },
          ],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'orderStatusName',
          label: '订单状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'reservationStatusName',
          label: '预约状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'stockupStatusName',
          label: '备货状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'completeSetName',
          label: '是否齐套',
          type: 3,
          values: '',
          width: '150',
          checkarr: [
            {
              value: '2',
              label: '是',
            },
            {
              value: '1',
              label: '否',
            },
          ],
          fixed: false,
          sortable: true,
        },
        // {
        //   prop: 'brand',
        //   label: '品牌',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        // },
        // {
        //   prop: 'typeServerName',
        //   label: '服务类型',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        // },
        {
          prop: 'notificationName',
          label: '通知状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [
            {
              value: '2',
              label: '已通知',
            },
            {
              value: '1',
              label: '未通知',
            },
          ],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'customerName',
          label: '顾客名字',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'customerTelephone',
          label: '顾客电话',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'customerAddress',
          label: '顾客地址',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'fee',
          label: '增值服务',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        }, {
          prop: 'createUserName',
          label: '创建人',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        }, {
          prop: 'createTime',
          label: '创建时间',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        // {
        //   prop: 'inventoryDate',
        //   label: '最新盘点时间',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        // }, {
        //   prop: 'inventoryPerson',
        //   label: '盘点人',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        // },
        // {
        //   prop: '',
        //   label: '操作',
        //   type: 6,
        //   values: '',
        //   width: '230',
        //   checkarr: [],
        //   fixed: 'right',
        //   hide: true,
        // },
        // 更多列的配置...
      ],
      columnListedit: [],
    }
  },
  mounted () {
    this.init();

    if(this.$route.query.type == '2'){
      //查询提货编辑数据
      this.getDetailOen();
    }else{
      this.onLoad(this.page);
    }
    /**
     * 初始化获取本地缓存的编辑隐藏的列表
     *  固定搭配，不能更改
     */
      // let checkList=[]
      // this.columnList.map(item => {
      //     item.head = false;
      // });
    let checkListnewarr = this.$functions.getStorage(window.location.pathname+'checkList');
    let flexListnewarr = this.$functions.getStorage(window.location.pathname+'flexList');
    let sortlistnewarr = this.$functions.getStorage(window.location.pathname+'sortlist');
    if (checkListnewarr) {
      this.columnList.map(item => {
        item.head = false;
      });
      checkListnewarr.map(ite => {
        this.columnList.map(item => {
          if (ite == item.label) {
            item.head = true;
          }
        });
      });
    }else{
      let arr=[]
      this.columnList.map(item => {
        if(item.head){
          arr.push(item.label)
        }
      });
      this.$functions.setStorage(window.location.pathname+'checkList',arr)
    }
    if (flexListnewarr) {
      this.columnList.map(item => {
        item.fixed = false;
      });
      flexListnewarr.map(ite => {
        this.columnList.map(item => {
          if (ite == item.label) {
            if(item.type==6){
              item.fixed = 'right';
            }else{
              item.fixed = true;
            }
          }
        });
      });
    }else{
      let arr=[]
      this.columnList.map(item => {
        if(item.fixed){
          arr.push(item.label)
        }
      });
      this.$functions.setStorage(window.location.pathname+'flexList',arr)
    }
    if (sortlistnewarr) {
      this.columnList.map(item => {
        item.sortable = false;
      });
      sortlistnewarr.map(ite => {
        this.columnList.map(item => {
          if (ite == item.label) {
            item.sortable = true;
          }
        });
      });
    }else{
      let arr=[]
      this.columnList.map(item => {
        if(item.sortable){
          arr.push(item.label)
        }
      });
      this.$functions.setStorage(window.location.pathname+'sortlist',arr)
    }
  },
  watch:{
    '$route.query.id':{
      handler(newVal, oldVal) {
        // console.log(newVal, oldVal);
        if(this.$route.query.type == '2'){
          //查询提货编辑数据
          this.getDetailOen();
        }else{
          this.onLoad(this.page);
          // this.onLoadOwn(this.page);
        }
      },
      deep: true,
      immediate: true
    }
  },
  computed: {
    ...mapGetters(["permission",'tagWel','tagList','tag']),
    ids () {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    stockIds () {
      let ids = [];
      this.selectionListStock.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    headers() {
      return {
        "Blade-Auth":'Bearer ' + getToken()
      }
    },
    action() {
      // return '/api/logpm-basicdata/common/uploadFile'
      return '/api/blade-resource/oss/endpoint/put-file'
    }
  },
  methods: {
    showdrawer(value){
      this.drawerShow=value
    },
    /**
     * 弹窗的勾选回调，用于更改头部数组
     * 固定搭配，只需要更换   columnList
     */
    setnewcolum(newarr, headarr,type) {
      // console.log(newarr,'+++++++++++')
      if(type==1){
        this.columnList = newarr;
        this.$functions.setStorage(window.location.pathname+'checkList', headarr);
      }else if(type==2){
        this.columnList = newarr;
        this.$functions.setStorage(window.location.pathname+'flexList', headarr);
      }else if(type==3){
        this.columnList = newarr;
        this.$functions.setStorage(window.location.pathname+'sortlist', headarr);
      }

    },
    selectionsc(value) {
      console.log(value);
    },
    delectsolt(scope) {
      const { row } = scope;
      console.log(row);
    },
    editsolt(scope) {
      const { row } = scope;
      console.log(row);
    },
    btnsc(index, row) {
      console.log(index, row);
    },
    selectsc(index, row) {
      console.log(index, row);
      if(row.prop ==='freezeStatusName'){
        this.queryOrder['freezeStatus'] = index;
      }else if(row.prop ==='completeSetName'){
        this.queryOrder['completeSet'] = index;
      }else if(row.prop ==='reservationStatusName'){
        this.queryOrder['reservationStatus'] = index;
      }else if(row.prop ==='groundingStatusName'){
        this.queryOrder['groundingStatus'] = index;
      }else if(row.prop ==='stockupStatusName'){
        this.queryOrder['stockupStatus'] = index;
      }else if(row.prop ==='orderStatusName'){
        this.queryOrder['orderStatus'] = index;
      }else if(row.prop ==='notificationName'){
        this.queryOrder['notification'] = index;
      }else if(row.prop ==='typeName'){
        this.queryOrder['typeService'] = index;
      }else{
        this.queryOrder[row.prop] = index;
      }
      this.onLoadOrder(this.pageOrder);
    },
    timesc(index, row) {
      console.log(index, row);
      if (!!index){
        index = dayjs(index).format('YYYY-MM-DD');
      }
      this.query[row.prop] =  index
      if (!index){
        delete this.query[row.prop]
      }
      this.onLoadOrder(this.pageOrder);
    },
    inputsc(index, row) {
      console.log(index, row);
      this.query[row.prop] = index;
      this.onLoadOrder(this.pageOrder);
    },
    //查询提货详情信息
    getDetailOen(){
      this.orderAdd = true;
      getDetail(this.$route.query.id).then(res =>{
        // console.log("详情信息》》》》",res.data.data);
        let s = res.data.data;
        this.form = s;
        let f =[];
        s.chargeList.forEach(c =>{
        let a =  this.clientType.find( i =>c.cost == i.dictKey );

          if(!!c.cost && c.cost != '-1'){
            f.push(c.cost)
          }
          if(!!a){
            a.remark = c.money.substring(0,c.money.lastIndexOf("."))
            this.costList[c.cost] = a.remark;
          }
        })
        this.form.freightMark = f;
        this.costListName = f;
        this.form.totalCost =  s.totalCost.substring(0,s.totalCost.lastIndexOf("."))
        this.dataList = s.stockArticleVOS;
        this.data = s.stockListVOS;
        this.data.forEach( i =>{
          i.available = i.quantityStock - i.quantityOccupied;
        })
        if (!!s.printVOS) {
          let le1 = [];
          let le2 = [];
          let le3 = [];

          const genreMapping = {
            '1': le1, // 提
            '2': le2, // 文
            '3': le3, // 库
          };
          s.printVOS.forEach(i => {
            if (i.genre in genreMapping) {
              const q = {
                name: i.siteName,
                url: i.site
              };
              genreMapping[i.genre].push(q);
            }
          });

          this.fileListLibrary = genreMapping['3'];
          this.fileListSell = genreMapping['1'];
          this.fileListClerk = genreMapping['2'];
          // console.log("le1",le1);
          // console.log("le2",le2);
          // console.log("le3",le3);

        }

        this.loading = false;
      })
    },
    //移除数据
    rowStock (row) {
      console.log(">>?>?><?",row);
      this.data.forEach( i =>{
        if(i.id === row.id){
          this.data
        }
      })
      let id1 = this.data.findIndex(item => {
        if (item.id == row.id) {
          return true
        }
      })
      this.data.splice(id1, 1)

    },
    //移除数据
    rowOrder (row) {
      console.log(">>?>?><?",row);
      this.dataList.forEach( i =>{
        if(i.id === row.id){
          this.dataList
        }
      })
      let id1 = this.dataList.findIndex(item => {
        if (item.id == row.id) {
          return true
        }
      })
      this.dataList.splice(id1, 1)
    },
    //订单选择确定
    callFordeliveryOrder(){
      let st = false;
      let sts = false;
      let ad = false;
      let consigneePerson = '';
      let consigneeMobile = '';
      this.selectionList.some( i =>{

        if(this.dataList.length > 0){
          let w =  this.dataList.find(c => c.consigneeMobile == i.consigneeMobile  && c.consigneePerson == i.consigneePerson);
          if(!w){
            ad = true;
          }
        }
        if(i.reservationStatusName === "已预约"){ st = true; this.$message.warning(i.orderCode+"已预约，请勿重复预约！！！"); }
        if(!consigneePerson && !consigneeMobile){
          consigneeMobile = i.consigneeMobile;
          consigneePerson = i.consigneePerson;
        }else{
          if(consigneeMobile != i.consigneeMobile && consigneePerson != i.consigneePerson ){ sts = true; }
        }
      })
      //待打开
      // if(ad){
      //   this.$message.warning("请选择同一收货人！！");
      //   return ;
      // }
      if(st){
        return ;
      }
      if(sts){
        this.$message.warning("收货人不相同，请选择相同的收货人！！！");
        return ;
      }

      let isa= false;
      this.selectionList.some( i =>{
        let a = this.dataList.filter((ele) => ele.id == i.id ).length >= 1
        // console.log("asdgfasdv",a);
        if(!a){
          this.dataList.push(i);
        }
      })
      if(!isa){
        this.dialogFormOrderVisible = false;
      }

    },
    //确定
    callFordelivery(inde){
      let isa= false;
      console.log("执行了");
      this.selectionListStock.some( i =>{
        console.log("asdgfasdv",i);
        if(parseInt(i.inventoryQuantity) > parseInt(i.quantityStock) ){
          // this.$message.warning("添加数量大于可以数量");
          isa= true;
          return ;
        }
        let a = this.data.filter((ele) => ele.id == i.id ).length >= 1
        // console.log("asdgfasdv",a);
        if(!a){
          this.data.push(i);
        }
      })

      if(!isa){
        this.dialogFormVisible = false;
      }
    },
    //数量校验
    handleNumberRange(e,row) {
      console.log("执行了2222",e,e.target.value,row);
      if(e.target.value) {
        e.target.value = e.target.value.replace(/[^\.\d]/g,'') //替换掉与数字无关的字符（中英文与符号都会被替换掉，只留下数字，此时值类型为字符串）
        if(e.target.value) { //如果替换后还有值
          e.target.value = parseInt(e.target.value); //把字符型转成整数型
        }
        if((e.target.value > row.available )) {
          this.$message.error('数量不能大于可用数量')
          // e.target.value = row.quantityStock;
          return
        }
      }
    },
    uploadSuccess(fileList) {
      console.log('123123123', fileList);
      // console.log('123123123==fileListSell', this.fileListSell);
      // console.log('123123123==fileListClerk', this.fileListClerk);
      // console.log('123123123==fileListLibrary', this.fileListLibrary);
      // this.form.fileName =
      // this.$set(row, 'imageCos', fileList);
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    textbox(e,index) {
      // console.log("e,index",e,index);
      this.costList[index+1] = e;
      //计算合计费用
      let n = 0;
      this.costList.forEach( i =>{
        n += parseInt(i);
      })
      this.form.totalCost = n;
    },
    handleCheckedCitiesChange(value) {
      console.log(">>>>>>>",value );
      if(value.length < 1){
        this.costList = [];
        this.costListName = [];
      }
      this.clientType.forEach(i =>{
        if(value.includes(i.dictKey)){
          console.log(i);
          i.pitch = true;
          this.costListName = value;
        }

      });

    },
    init () {
      this.height = this.setPx(document.body.clientHeight - 160);
      //字典
      getDictionaryBiz('delivery_cost').then(res => {
        this.clientType = res.data.data;
      }); //字典
      getDictionaryBiz('certificate_type').then(res => {
        this.certificateType = res.data.data;
      });
      getDictionaryBiz('distribution_type').then(res => {
        this.distributionType = res.data.data;
      });
      getDictionaryBiz('logpm_unit').then(res => { //单位
        this.logpmUnit = res.data.data;
      });
      getDictionaryBiz('order_status').then(res => {
        this.deliveryOrderStatus = res.data.data;
        this.checkcColumnList("orderStatusName", this.columnList).checkarr=res.data.data.map(item=>{
          item.value=item.dictKey
          item.label=item.dictValue
          return item
        });
      });
      getDictionaryBiz('basic_grounding').then(res => {
        this.checkcColumnList("groundingStatusName", this.columnList).checkarr=res.data.data.map(item=>{
          item.value=item.dictKey
          item.label=item.dictValue
          return item
        });
      });
      getDictionaryBiz('freeze_status').then(res => {
        this.checkcColumnList("freezeStatusName", this.columnList).checkarr=res.data.data.map(item=>{
          item.value=item.dictKey
          item.label=item.dictValue
          return item
        });
      });
      getDictionaryBiz('stockup_status').then(res => {
        this.checkcColumnList("stockupStatusName", this.columnList).checkarr=res.data.data.map(item=>{
          item.value=item.dictKey
          item.label=item.dictValue
          return item
        });

      });
      getDictionaryBiz('order_reservation_status').then(res => {
        this.checkcColumnList("reservationStatusName", this.columnList).checkarr=res.data.data.map(item=>{
          item.value=item.dictKey
          item.label=item.dictValue
          return item
        });
      });

    },
    checkcColumnList(prop,columnList){
      for(var a = 0; a < columnList.length; a++){
        if(columnList[a].prop===prop){
          // console.log("1111111111111",columnList[a]);
          return columnList[a];
        }
      }
    },
    searchHide () {
      this.search = !this.search;
    },
    searchChange () {
      this.onLoad(this.page);
    },
    searchReset () {
      this.query = {};
      this.page.currentPage = 1;
      this.onLoad(this.page);
    },
    bianLier(costListName,clientType,costList,fei){
      // console.log(">>>>>>>>>",costListName,clientType,costList,fei);
      this.pan = false;
      for (let i = 0;i< costListName.length;i++){
        if(!costList){ this.pan = true; return }
        for(let a = 0;a < clientType.length;a++){
          // console.log("进来了",clientType[a].dictKey , costListName[i]);
          if(clientType[a].dictKey == costListName[i]){
            // console.log("进来了",clientType[a].dictKey , costListName[i]);
            let zhi = costList[costListName[i]];
            if(!zhi){
              this.pan = true;
              continue;
            }else{
              //2.添加
              fei.set(clientType[a].dictKey,zhi);
            }

          }
        }

      }
    },
     async handleSubmit () {
       this.$refs.form.validate( async valid=>{
         if (valid) {
           if (!this.form.id) {
             if(this.fileListSell.length === 0) {this.$message.warning("请上传提货证件！！！"); return;}
             let fei = new Map();
             await this.bianLier(this.costListName,this.clientType,this.costList,fei);
             this.form.fei = Object.fromEntries(fei);
             this.form.stockArticleId = !this.$route.query.id ? null : this.$route.query.id+','; //订单ID
             this.form.stockDTOList = this.data;
             let o = [];
             if(this.fileListClerk.length > 0){
               this.fileListClerk.forEach( i =>{
                 // console.log("iiii文员",i);
                 let num = {};
                 num.state = "2";
                 num.name = i.name;
                 num.url = i.response.data.link;
                 o.push(num);
               });

             }
             if(this.fileListLibrary.length > 0){
               this.fileListLibrary.forEach( i =>{
                 // console.log("库管》》》",i);
                 let num = {};
                 num.state = "3";
                 num.name = i.name;
                 num.url = i.response.data.link;
                 o.push(num);
               });

             }
             if(this.fileListSell.length > 0){
               this.fileListSell.forEach( i =>{
                 // console.log(",.,.,.,.提货",i);
                 let num = {};
                 num.state = "1";
                 num.name = i.name;
                 num.url = i.response.data.link;
                 o.push(num);
               });
             }
             this.form.printList = o.length > 0 ? o : [];
             if(this.dataList.length === 0 && this.data.length === 0 ){
               this.$message.warning("请填写需要自提的物品！！");
             }
             if(this.orderAdd && this.dataList.length > 0){
               let a = this.dataList.map(i =>i.id);
               console.log("aaaaa",a);
               this.form.stockArticleId =  this.form.stockArticleId != null ? this.form.stockArticleId+a.join(',') :  a.join(',');
             }

             console.log("this.form",this.form);
             add(this.form).then(() => {
               this.box = false;
               this.onLoad(this.page);
               this.$message({
                 type: "success",
                 message: "操作成功!"
               });
               this.contextmenuFlag = false;
               this.$store.commit('DEL_TAG_CURRENT');
               this.$router.push(this.tagWel);
             });
           } else {
             let fei = new Map();
             await this.bianLier(this.costListName,this.clientType,this.costList,fei);
             this.form.fei = Object.fromEntries(fei);
             this.form.stockDTOList = this.data;
             let o = [];
             const fileListMapping = {
               fileListClerk: '2',   // 文员
               fileListLibrary: '3', // 库管
               fileListSell: '1',    // 提货
             };
             let mark = false;
             Object.entries(fileListMapping).forEach(([fileList, state]) => {
               if (this[fileList].length > 0) {
                 this[fileList].forEach(i => {
                   console.log("i>>>>",i);
                   let num = {
                     state,
                   };
                   if(!!i.response){
                     num.name = i.name;
                     num.url = i.response.data.link;
                     mark = true;
                   }else{
                     num.name = i.name;
                     num.url = i.url;
                   }
                   o.push(num);
                 });
               }
             });
             this.form.printList = o.length > 0 ? o : [];
             // console.log("修改》》》",this.form);
             let up = {}
             up.printList =  o.length > 0 ? o : [];
             up.fei = this.form.fei;
             up.stockDTOList = this.form.stockDTOList;
             up.id = this.form.id;
             up.pickUpPlate = this.form.pickUpPlate;
             up.pickUpTime = this.form.pickUpTime;
             up.consignee = this.form.consignee;
             up.deliveryDocument = this.form.deliveryDocument;
             up.certificateType = this.form.certificateType;
             up.totalCost = this.form.totalCost;
             up.mark = mark;
             up.stockArticleList = this.dataList;


             console.log("修改提交数据》》》",up);
             /*console.log(this.$route.matched) // 当前路由匹配的路由信息
               console.log(tag,key);
             let { tag, key } = this.findTag(this.$route.path);
             this.$store.commit('DEL_TAG', tag);
               if (tag.fullPath === this.tag.fullPath) {
                 tag = this.tagList[key - 1];
                 this.$router.push({
                   path: tag.path,
                   query: tag.query,
                 });
               }
*/
             update(up).then(() => {
               // this.box = false;
               // this.onLoad(this.page);
               this.$message({
                 type: "success",
                 message: "操作成功!"
               });
               this.$store.commit('DEL_TAG_CURRENT');
               this.$router.push(this.tagWel);
             })
           }
         }
       })
    },
    findTag(fullPath) {
      let tag = this.tagList.find(item => item.fullPath === fullPath);
      let key = this.tagList.findIndex(item => item.fullPath === fullPath);
      return { tag, key };
    },

    handleAdd () {
      this.title = '新增'
      this.form = {}
      this.box = true
    },
    handleEdit (row) {
      this.title = '编辑'
      this.box = true
      getDetail(row.id).then(res => {
        this.form = res.data.data;
      });
    },
    handleView (row) {
      this.title = '查看'
      this.view = true;
      this.box = true;
      getDetail(row.id).then(res => {
        this.form = res.data.data;
      });
    },
    //查询自提订单
    handleAddOrder(){
      this.selectionList = [];
      this.dialogFormOrderVisible = true;
      //查询自提订单
      this.onLoadOrder(this.pageOrder);
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    onLoadOrder (page, params = {}) {
      this.loading = true;
      if(this.stockupDate.length > 0){
        let startDate = this.stockupDate[0];
        let entDate = this.stockupDate[1];
        params.startDate = this.getTime(startDate.toString());
        params.entDate = this.getTime(entDate.toString());
      }
      params.genre = 1;
      params.typeService = 3;
      params.reservation = '30';
      getListOne(page.currentPage, page.pageSize, Object.assign(params,this.queryOrder)).then(res => {
        const data = res.data.data;
        console.log(">>>>>>>",data.records);
        this.pageOrder.total = data.total;
        this.dataOrder = data.records;
        this.dataOrder = this.dataOrder.map(i => {
          const notificationMap = {
            '1': "已通知",
            '2': "未通知",
            default: "无"
          };
          const nuMap = {
            '-1': "0"
          };
          i.notificationName = notificationMap[i.notification] || notificationMap.default;
          i.handQuantity = nuMap[i.handQuantity] || i.handQuantity;
          i.sortingQuantity = nuMap[i.sortingQuantity] || i.sortingQuantity;
          i.deliveryQuantity = nuMap[i.deliveryQuantity] || i.deliveryQuantity;
          i.signinQuantity = nuMap[i.signinQuantity] || i.signinQuantity;
          i.transferQuantity = nuMap[i.transferQuantity] || i.transferQuantity;
          i.availableQuantity = nuMap[i.availableQuantity] || i.availableQuantity;
          i.notReceived = parseInt( i.totalNumber) - parseInt( i.handQuantity );
          return i;
        });
        this.dataOrder.forEach(i =>{
         let asas =  this.dataList.find( l => l.id == i.id);
         if(!!asas){
           console.log("存在的数据》》》",asas);
           this.selectionList.push(i.id);

         }

        })
        this.$nextTick(() => {
          this.toggleSelection(this.selectionList)
        })
        this.loading = false;
        this.selectionClear();
      });
    },
    //库存品
    handleAddView (row) {
      this.selectionList = [];
      this.dialogFormVisible = true;
      this.onLoadList(this.pageStock);
    },
    handleDelete () {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.selectionClear();
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    rowDel (row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    beforeClose (done) {
      done()
      this.form = {};
      this.view = false;
    },
    selectionChange (list) {
      this.selectionList = list;
    },
    handleHighlightChangeTable(row) {
      if(!row.disabled){
        this.$refs.table.toggleRowSelection(row);
      }
    },
    selectionChangeStock (list) {
      console.log("执行了啦啦啦",list);
      this.selectionListStock = list;
    },
    selectionClear () {
      this.selectionList = [];
      // this.$refs.table.clearSelection();
    },
    currentChangeStock (currentPage) {
      this.pageStock.currentPage = currentPage;
      this.onLoadList(this.pageStock);
    },
    sizeChangeStock (pageSize) {
      this.pageStock.pageSize = pageSize;
      this.onLoadList(this.pageStock);
    },
    currentChange (currentPage) {
      this.page.currentPage = currentPage;
      this.onLoad(this.page);
    },
    sizeChange (pageSize) {
      this.page.pageSize = pageSize;
      this.onLoad(this.page);
    },

    onLoad (page, params = {}) {
      this.loading = true;
      params.id = this.$route.query.id;
      this.orderAdd = false;
      getListOne(page.currentPage, page.pageSize, params).then(res => {
        const data = res.data.data;
        console.log("订单详细>>>>>>>>>===",data);
        this.dataList = data.records;
        this.loading = false;
        this.selectionClear();
      });
    } ,
    //库存品
    onLoadList (page, params = {}) {
      this.loading = true;
      getListStockList(page.currentPage, page.pageSize,params ).then(res => {
        const dataOwn = res.data.data;
        this.pageStock.total = dataOwn.total;
        this.dataOwn = dataOwn.records;
        this.dataOwn.forEach( i =>{
          i.available = i.quantityStock - i.quantityOccupied;
        })
        this.loading = false;
        this.selectionClear();
      });
    } ,
    //包件信息
    onLoadOwn (page, params = {}) {
      this.loading = true;
      this.query.stockArticleId = this.$route.query.id;
      getListOwn(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        console.log("包件信息>>>>",res.data.data);
        const dataList = res.data.data;
        this.page.total = dataList.total;
        this.dataList = dataList.records;
        this.loading = false;
        this.selectionClear();
      });
    }
  }
};
</script>
<style >
.foot {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 999;
  height: 60px;


}
.foot .dialog-footer {
  margin-bottom: 130px;
  text-align: center;
}
.ca .el-radio__inner {
  top: -18px;
  left: -19px;
  border-radius: 0;
  border: 0;
  width: 170px;
  height: 34px;
  background-color: transparent;
  cursor: pointer;
  box-sizing: border-box;
  position: absolute;
}

.ca .el-radio__input.is-checked .el-radio__inner {
  background: transparent;
}
</style>
