<template>
  <basic-container>
    <div class="avue-crud">
      <el-row   v-if="!search" style="margin-bottom: 5%">
        <!-- 列表模块 -->
        <el-table
          ref="table"
          v-loading="loading"
          :data="data"
          height="20%"
          style="width: 100%"
          :border="option.border"
        >
          <template v-for="(item, index) in option.columnBasic">
            <!-- 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>
      </el-row>
      <!--   <el-row style="margin-bottom: 5%">
        &lt;!&ndash; 列表模块 &ndash;&gt;
        <el-table ref="table" v-loading="loading"
                  @selection-change="selectionChange"
                  :data="data"
                  height="20%"
                  style="width: 100%"
                  :border="option.border">
          <template v-for="(item,index) in option.columnTakeOver">
            &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>

        </el-table>


      </el-row>
      <el-row style="margin-bottom: 5%">
        &lt;!&ndash; 列表模块 &ndash;&gt;
        <el-table ref="table" v-loading="loading"
                  @selection-change="selectionChange"
                  :data="data"
                  style="width: 100%"
                  :border="option.border">
          <template v-for="(item,index) in option.columnStockUp">
            &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>
        </el-table>
      </el-row>-->
      <el-row>
        <el-tabs
          type="card"
          class="demo-tabs"
          style="width: 100%"
          v-model="activeName"
          @tab-click="handleClick"
        >
          <el-tab-pane label="自提列表" name="reservation">
            <el-table
              ref="table"
              v-loading="loading"
              @selection-change="selectionChange"
              :data="data3"
              :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="60"
                align="center"
              >
              </el-table-column>
              <template v-for="(item, index) in option.columnReservationSelf">
                <!-- 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}">-->
              <!--                  &lt;!&ndash;              <el-button type="primary" text icon="el-icon-view" @click="handleView(row)">查看</el-button>&ndash;&gt;-->
              <!--                  &lt;!&ndash;              <el-button type="primary" text icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>&ndash;&gt;-->
              <!--                  &lt;!&ndash;              <el-button type="primary" text icon="el-icon-delete" @click="rowDel(row)">删除</el-button>&ndash;&gt;-->
              <!--                </template>-->
              <!--              </el-table-column>-->
            </el-table>
            <div class="avue-crud__pagination" style="width: 100%">
              <!-- 分页模块 -->
              <el-pagination
                align="right"
                background
                @size-change="sizeChange"
                @current-change="currentChange"
                :current-page="page3.currentPage"
                :page-sizes="[30, 50,80, 120]"
                :page-size="page3.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page3.total"
              >
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="订单列表" name="library">
            <el-table
              ref="table"
              v-loading="loading"
              @selection-change="selectionChange"
              :data="dataPare"
              :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="60"
                align="center"
              >
              </el-table-column>
              <template v-for="(item, index) in option.columnStockOrder">
                <!-- 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}">-->
              <!--                  &lt;!&ndash;              <el-button type="primary" text icon="el-icon-view" @click="handleView(row)">查看</el-button>&ndash;&gt;-->
              <!--                  &lt;!&ndash;              <el-button type="primary" text icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>&ndash;&gt;-->
              <!--                  &lt;!&ndash;              <el-button type="primary" text icon="el-icon-delete" @click="rowDel(row)">删除</el-button>&ndash;&gt;-->
              <!--                </template>-->
              <!--              </el-table-column>-->
            </el-table>
            <div class="avue-crud__pagination" style="width: 100%">
              <!-- 分页模块 -->
              <el-pagination
                align="right"
                background
                @size-change="sizeChange"
                @current-change="currentChange"
                :current-page="page.currentPage"
                :page-sizes="[30, 50,80, 120]"
                :page-size="page.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page.total"
              >
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="备货包件" name="outbound">
            <el-button type="primary" text icon="el-icon-view" v-if =isStockUp  @click="handleStockUp(row,'1')">备货</el-button>
            <el-table
              ref="table"
              v-loading="loading"
              @selection-change="selectionChange"
              :data="data1"
              :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="60"
                align="center"
              >
              </el-table-column>
              <template v-for="(item, index) in option.columnStockingBag">
                <!-- 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-button type="primary" text icon="el-icon-view" v-if=" row.stockupStatusName== '待备货' " @click="handleStockUp(row,'2')">备货</el-button>
                  <!--              <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>
            <div class="avue-crud__pagination" style="width: 100%">
              <!-- 分页模块 -->
              <el-pagination
                align="right"
                background
                @size-change="sizeChange"
                @current-change="currentChange"
                :current-page="page1.currentPage"
                :page-sizes="[30, 50,80, 120]"
                :page-size="page1.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page1.total"
              >
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="库存品" name="enter">
            <el-table
              ref="table"
              v-loading="loading"
              @selection-change="selectionChange"
              :data="data2"
              :height="height"
              style="width: 100%"
              :border="option.border"
            >
              <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.columnInventory">
                <!-- 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>
            <div class="avue-crud__pagination" style="width: 100%">
              <!-- 分页模块 -->
              <el-pagination
                align="right"
                background
                @size-change="sizeChange"
                @current-change="currentChange"
                :current-page="page2.currentPage"
                :page-sizes="[30, 50,80, 120]"
                :page-size="page2.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page2.total"
              >
              </el-pagination>
            </div>
          </el-tab-pane>
        </el-tabs>
      </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="[30, 50,80, 120]"
                         :page-size="page.pageSize"
                         layout="total, sizes, prev, pager, next, jumper"
                         :total="page.total">
          </el-pagination>
        </div>
      </el-row>-->
      <el-dialog v-model="dialogHand" title="系统备货">
        <el-form :model="form">
          <el-form-item label="备货区域" :label-width="formLabelWidth" >
            <el-select v-model="form.goodsAreaId" clearable placeholder="请选择备货区编号" @change="getForklift($event,'3')">
              <el-option
                v-for="item in goodsAreaIdData"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="item.dictKey">
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogHand = false">取消</el-button>
        <!--        <el-button type="primary" @click="dialogFormVisible = false"> 确定 </el-button>-->
        <el-button type="primary" @click="callFordelivery()"> 确定 </el-button>
      </span>
        </template>
      </el-dialog>
      <el-dialog v-model="dialogFormCustomer" title="修改客户信息">
        <el-form :model="formCustomer">
          <el-form-item label="姓名" :label-width="formLabelWidth">
            <el-input v-model="formCustomer.name" autocomplete="off" />
          </el-form-item>
          <el-form-item label="电话" :label-width="formLabelWidth">
            <el-input v-model="formCustomer.phone" autocomplete="off" />
          </el-form-item>
          <el-form-item label="地址" :label-width="formLabelWidth">
            <el-input
              v-model="formCustomer.address"
              :rows="2"
              type="textarea"
              placeholder="请填写地址"
            />
          </el-form-item>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button @click="dialogFormCustomer = false">取消</el-button>
            <!--        <el-button type="primary" @click="dialogFormVisible = false"> 确定 </el-button>-->
            <el-button type="primary" @click="callFordelivery('3')"> 确定 </el-button>
          </span>
        </template>
      </el-dialog>
    </div>
  </basic-container>
</template>

<script>
import {
  getList,
  getDetail,
  add,
  update,
  remove,
  getDetailStockupOwnSelf,
  getDetailReservationOwn,
  getDetailOrderOwn,
  getDetailInventoryOwn,
  billStockList, getDetailOrderOwnSelf, getDetailInventoryOwnSelf, getListUser
} from '@/api/distribution/distributionStockup';
import option from '@/option/distribution/distributionStockup';
import { mapGetters } from 'vuex';
import { getDictionaryBiz } from '@/api/system/dict';
import { getParcelListOwn, getParcelListOwnSelf } from '@/api/distribution/distributionParcelList';
import { stockUp } from '@/api/basicdata/basicdataGoodsArea';
import { getStockDetail } from '@/api/distribution/distributionStock';

export default {
  data() {
    return {
      height: 0,
      activeName: 'reservation',
      // 弹框标题
      title: '',
      // 是否展示弹框
      box: false,
      isStockUp: false,
      // 是否显示查询
      search: true,
      // 加载中
      loading: true,
      // 是否为查看模式
      view: false,
      // 查询信息
      query: {},
      // 分页信息
      page: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      // 分页信息
      page1: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      // 分页信息
      page2: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      // 分页信息
      page3: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      // 表单数据
      form: {},
      formCall: {}, // 通知
      formService: {}, // 服务
      formCustomer: {}, // 客户
      // 选择行
      selectionList: [],
      // 表单配置
      option: option,
      // 表单列表
      data: [],
      data1: [],
      data2: [],
      dataPare: [],
      data3: [],
      distributionType: [],
      serveTypeList: [],
      deliveryWayList: [],
      stockupStatusList: [],
      dialogTableVisible: false,
      dialogFormVisible: false,
      dialogFormCustomer: false,
      dialogHand: false,
      goodsAreaIdData: [],
      dialogFormService: false,
      deptId: '',
      formLabelWidth: '120px',
      handler: true, //首次
      trade: false, // 商
      municipal: true, // 市
      taker: true, // 自提
    };
  },
  mounted() {
    this.init();
  },
  watch: {
    '$route.query.id': {
      handler(newVal, oldVal) {
        // console.log(newVal, oldVal);
        this.init();
      },
      deep: true,
      immediate: true,
    },
  },
  computed: {
    ...mapGetters(['permission']),
    permissionList() {
      return {
        addBtn: this.validData(this.permission.basicdataBrandCategory_add, false),
        viewBtn: this.validData(this.permission.basicdataBrandCategory_view, false),
        delBtn: this.validData(this.permission.basicdataBrandCategory_delete, false),
        editBtn: this.validData(this.permission.basicdataBrandCategory_edit, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(',');
    },
  },
  methods: {
    //选择
    getForklift(row,ty){
      switch (ty){
        case '3':
          let f = this.goodsAreaIdData.find(i =>i.dictKey == row)
          this.form.stockupArea = f.dictValue;
          break;
      }
    },
    //系统备货确定
    callFordelivery(){
      // console.log("确定操作",this.form);
      let c = false;
      let ids = [];
      if (this.selectionList.length > 0) {
         ids = this.selectionList.map(i => i.id).join(',');
        this.selectionList.forEach( i =>{
          if(!!i.stockupStatus){
            c = true;
          }
        })
        this.form.ids = ids.split(",");
      }
      if(c){
        this.$message.warning("有已备货的数据！！")
        return ;
      }
      this.form.stockupId = this.$route.query.id;
      this.form.stockupType = "ZT";
      console.log("ids",this.form);
      getStockDetail( Object.assign(this.form)).then(res =>{
        console.log("resd",res.data.data);
        this.$message({
          type: "success",
          message: "操作成功!"
        });
        this.getStockUpParcelsList(this.page1);
        this.form = {};
        this.dialogHand = false;
      });

    },
    //备货id
    handleStockUp(row,type){
      getListUser().then(res =>{ //查询当前人信息
        console.log("res>>>",res.data.data);
        this.deptId = res.data.data.deptId;
        this.getStorageArea();
      })
      console.log("备货数据！！",row);
      switch (type){
        case '1':
          if(this.selectionList.length === 0){
            this.$message.warning("至少选择一条数据！！！");
            return;
          }
          let ar = this.selectionList.find(i =>i.stockupStatusName === '已备货');
          console.log("ar",ar);
          if(!!ar){
            this.$message.warning("有已备货的数据，请勿选择！！！");
            return ;
          }
          break;
        case '2':
          let i = [];
          i.push(row.id);
          this.form.ids = i;
          break;
      }
      this.dialogHand = true;
    },
    //备货区
    async getStorageArea(){
      let params ={
        department: this.deptId
      }
      stockUp(params).then(res =>{
        // console.log("res>>>",res.data.data);
        let fo =[];
        res.data.data.forEach(i =>{
          let v = {
            dictKey: i.id,
            dictValue: i.name +'-'+i.headline
          }
          fo.push(v)
        })
        this.goodsAreaIdData = fo;
      })
    },
    handleClick(tab, event) {
      console.log(tab, event);
      console.log(tab.props.name);
      this.leibiao = tab.props.name;
      if (this.leibiao == 'library') {
        //订单
        this.getOrderList(this.page);
      } else if (this.leibiao == 'outbound') {
        //包件
        this.getStockUpParcelsList(this.page1);
      } else if (this.leibiao == 'enter') {
        //库存品
        this.getInventoryList(this.page2);
      }
    },
    init() {
      this.height = this.setPx(document.body.clientHeight - 570);
      getDictionaryBiz('distribution_type').then(res => {
        //配送类型
        this.distributionType = res.data.data;
      });
      // 费用类型字典
      getDictionaryBiz('delivery_cost').then(res => {
        this.clientType = res.data.data;
      });
      // console.log("配送方式123", this.deliveryWayList);
      getDictionaryBiz('delivery_way').then(res => {
        //配送方式
        this.deliveryWayList = res.data.data;
        console.log('配送方式123', this.deliveryWayList);
      });
      getDictionaryBiz('stockup_status').then(res => {
        //配送方式
        this.stockupStatusList = res.data.data;
      });
      getDictionaryBiz('addvalue_serve_type').then(res => {
        //服务类型
        this.serveTypeList = res.data.data;
      });
      this.onLoad(this.page);
    },
    searchHide() {
      this.search = !this.search;
    },
    searchChange() {
      this.onLoad(this.page);
    },
    searchReset() {
      this.query = {};
      this.page.currentPage = 1;
      this.onLoad(this.page);
    },
    handleSubmit() {
      if (!this.form.id) {
        add(this.form).then(() => {
          this.box = false;
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!',
          });
        });
      } else {
        update(this.form).then(() => {
          this.box = false;
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!',
          });
        });
      }
    },

    //全部
    handleEntire() {
      this.handler = true;
      this.taker = true;
      this.trade = false;
    },
    //商配
    handleTrade() {
      // this.handler = true;
      this.trade = true;
    },
    //商配
    handleMunicipal() {
      // this.handler = true;
      // this.taker = true;
    },
    //自提
    handlePickUpStore() {
      this.loading = true;
      // console.log("this.query",this.query);
      let params = {};
      this.query.typeService = '1';
      getList(this.page.currentPage, this.page.pageSize, Object.assign(params, this.query)).then(
        res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
          this.handler = false;
          this.taker = false;
        }
      );
    }, //自提的通知
    handleInform(index) {
      this.loading = true;
      // console.log("this.query",this.query);
      let params = {};
      this.query.typeService = '1';
      switch (index) {
        case '1':
          this.query.notification = index;
          break;
        case '2':
          this.query.notification = index;
          break;
      }
      this.query.typeService = '1';
      getList(this.page.currentPage, this.page.pageSize, Object.assign(params, this.query)).then(
        res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
          this.handler = false;
          this.taker = false;
        }
      );
    },
    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;
      });
    },
    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) {
      // console.log("添加阿斯顿发生",list);
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      // this.$refs.table.clearSelection();
    },
    currentChange(currentPage) {
      if (!!this.leibiao && this.leibiao == 'library') {
        this.page.currentPage = currentPage;
        this.getOrderList(this.page);
      } else if (!!this.leibiao && this.leibiao == 'outbound') {
        this.page1.currentPage = currentPage;
        this.getStockUpParcelsList(this.page1);
      } else if (!!this.leibiao && this.leibiao == 'enter') {
        this.page2.currentPage = currentPage;
        this.getInventoryList(this.page2);
      } else {
        this.page3.currentPage = currentPage;
        this.getReservationList(this.page3);
      }
    },
    sizeChange(pageSize) {
      if (!!this.leibiao && this.leibiao == 'library') {
        this.page.pageSize = pageSize;
        this.getOrderList(this.page);
      } else if (!!this.leibiao && this.leibiao == 'outbound') {
        this.page1.pageSize = pageSize;
        this.getStockUpParcelsList(this.page1);
      } else if (!!this.leibiao && this.leibiao == 'enter') {
        this.page2.pageSize = pageSize;
        this.getInventoryList(this.page2);
      } else {
        this.page3.pageSize = pageSize;
        this.getReservationList(this.page3);
      }
    },
    onLoad(page, params = {}) {
      this.loading = true;
      this.query.id = this.$route.query.id;
      getDetailStockupOwnSelf(this.$route.query.id).then(res => {
        const data = res.data.data;
        this.data[0] = data;

        this.loading = false;
        this.billStockListPage(page);

      });
    },


    /**
     * 查询备货任务关联的自提任务
     * @param {*} page
     */
    async billStockListPage(page) {
      let a = await billStockList(page.currentPage, page.pageSize, { id: this.$route.query.id });
      this.data3 = a.data.data.records;
      console.log("自提任务》》》》》》",this.data3);
      console.log("费用类型lll",this.clientType);
      this.data3.forEach(i =>{
        if(!!i.list){
          i.collectFee = 0;
          i.storageFee = 0;
          i.transport = 0;
          i.forklift = 0;
          i.otherFee = 0;
          i.list.forEach(a =>{
            const { cost, money } = a; // 对象解构，获取a对象的cost和money属性
            switch (cost) {
              case '1': // 到付
                i.collectFee = money ? parseInt(money) : 0;
                break;
              case '2': // 仓储费用
                i.storageFee = money ? parseInt(money) : 0;
                break;
              case '3': // 搬运费
                console.log("0=-0-=");
                i.transport = money ? parseInt(money) : 0;
                break;
              case '4': // 叉车费
                i.forklift = money ? parseInt(money) : 0;
                break;
              case '5': // 其他增值费
                i.otherFee = money ? parseInt(money) : 0;
                break;
            }
          })
        }
      });


      // if (!!this.data3 && this.data3.length > 0) {
      //   this.data3.forEach(i => {
      //     let b = this.stockupStatusList.find(a => a.dictKey == i.stockupStatus);
      //     if (!!b) {
      //       i.stockupStatusName = b.dictValue;
      //     }
      //   });
      // }

      this.page3.total = a.data.data.total;
      this.loading = false;
      this.selectionClear();
    },

    //查询包件列表
    async getStockUpParcelsList(page) {
      let a = await getParcelListOwnSelf(page.currentPage, page.pageSize, { id: this.$route.query.id });
      console.log('包件...', a.data);
      const data = a.data.data;
      this.data1 = data.records;
      this.data1.forEach(i => {
        let b = this.stockupStatusList.find(a => a.dictKey == i.stockupStatus);
        if (!!b) {
          i.stockupStatusName = b.dictValue;
        }
        if(i.stockupStatusName == '待备货'){
            this.isStockUp = true;
        }
      });
      this.page1.total = a.data.data.total;
      this.loading = false;
      this.selectionClear();
    },
    //查询订单列表
    async getOrderList(page) {
      let a = await getDetailOrderOwnSelf(page.currentPage, page.pageSize, {
        id: this.$route.query.id,
      });
      // console.log("订单...",a.data);
      const data = a.data.data;
      this.dataPare = data.records;
      this.dataPare.forEach(i => {
        let b = this.stockupStatusList.find(a => a.dictKey == i.stockupStatus);
        if (!!b) {
          i.stockupStatusName = b.dictValue;
        }
      });
      this.page.total = a.data.data.total;
      this.loading = false;
      this.selectionClear();
    },
    //查询库存品列表
    async getInventoryList(page) {
      let a = await getDetailInventoryOwnSelf(page.currentPage, page.pageSize, {
        id: this.$route.query.id,
      });
      // console.log("库存品...",a.data);
      const data = a.data.data;
      this.data2 = data.records;
      this.data2.forEach(i => {
        let b = this.stockupStatusList.find(a => a.dictKey == i.stockupStatus);
        if (!!b) {
          i.stockupStatusName = b.dictValue;
        }
      });
      this.page2.total = a.data.data.total;
      this.loading = false;
      this.selectionClear();
    },
    //转换类型
    getOwnServer(row, name, list) {
      // console.log(">>>>>",row,name,list);
      // console.log(">>>>>",row);
      // console.log(">>>>>",name);
      // console.log(">>>>>",list);
      row.forEach(i => {
        // console.log(i,"-=-=-=-");
        let a = list.find(s => s.dictKey == i);
        // console.log("aaaa",a);
        if (!!a) {
          name += a.dictValue;
        }
      });
      return name;
    },
  },
};
</script>
<style scoped>
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>

