<template>
  <div>
    <el-card class="el-card">
      <el-form  v-if="queryList && queryList.length > 0 && showSearch" :model="query" label-width="100px">
        <!-- <el-row style="width: 100%">
          <el-col :span="8">
            <el-form-item label="单号:">
              <el-input v-model="query.billNo" style="width: 90%" placeholder="请输入单号" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="打印状态：" prop="inCodeStatus" clearable>
              <el-select v-model="query.inCodeStatus" style="width: 90%">
                <el-option label="未打印" :value="0"></el-option>
                <el-option label="已打印" :value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item class="query-form-item" label="单据类型:">
              <el-select v-model="query.action" placeholder="请选择单据类型"
                         style="width: 90%"
                         clearable>
                <el-option
                  v-for="item in busTypes"
                  :key="item.name"
                  :label="item.name"
                  :value="item.action">
                  <span style="float: left">{{ item.name }}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="单据状态:">
              <el-select v-model="query.status" placeholder="请选择单据状态" style="width: 90%">
                <el-option label="草稿" :value=1>草稿</el-option>
                <el-option label="待校验" :value=3>待校验</el-option>
                <el-option label="待核对" :value=5>待核对</el-option>
                <el-option label="待审核" :value=10>待审核</el-option>
                <el-option label="已审核" :value=7>已审核</el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="创建时间:">
              <el-date-picker
                :picker-options="pickerOptions"
                v-model="actDateRange"
                type="daterange"
                format="yyyy 年 MM 月 dd 日"
                style="width: 90%"
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row> -->
         <el-row style=" display:flex;  flex-wrap: wrap; ">
                  <template v-for="(item, index) in queryList" >
                    <el-form-item v-if="item.columnType == 'input' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`" :key="item.id">
                      <el-input
                        v-model="query[item.columnName]"
                        :placeholder="item.columnDesc"
                        :disabled="executeEval(null,item.disabledFuc,false)"
                        @keyup.enter.native="executeFuc($event,'5',item.clickFuc)"
                        clearable
                      ></el-input>
                    </el-form-item>
                    <el-form-item v-if="item.columnType == 'select' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`">
                      <el-select v-model="query[item.columnName]"
                                 :placeholder="item.columnDesc"
                                 :disabled="executeEval(null,item.disabledFuc,false)"
                                 clearable>
                        <el-option
                          v-for="dict in item.lableRuleObj"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        />
                      </el-select>
                    </el-form-item>
                    <el-form-item v-if="item.columnType == 'selectServer' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`">
                      <el-select
                        v-model="query[item.columnName]"
                        :placeholder="item.columnDesc"
                        @change="executeFuc($event,'5',item.checkRules)"
                        :disabled="executeEval(null,item.disabledFuc,false)"
                        filterable
                        remote
                        :remote-method="(query) => executeFuc(query,'5',item.clickFuc)"
                        clearable>
                        <el-option
                          v-for="item in options[item.clickFuc]"
                          :key="item.code"
                          :label="item.label"
                          :value="item.code"
                        />
                      </el-select>
                    </el-form-item>
                    <el-form-item v-if="item.columnType == 'datePicker' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`">
                      <el-date-picker
                        :picker-options="pickerOptions"
                        v-model="actDateRange"
                        type="daterange"
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                      ></el-date-picker>
                    </el-form-item>
                    <el-form-item v-if="item.columnType == 'date' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`">
                      <el-date-picker
                        v-model="query[item.columnName]"
                        :style="`width:${item.width+'px'}`"
                        value-format="yyyy-MM-dd"
                        :disabled="executeEval(null,item.disabledFuc,false)"
                        type="date"
                        :placeholder="item.columnDesc"
                      ></el-date-picker>
                    </el-form-item>
                  </template>
                </el-row>

      </el-form>


      <div class="top-right-btn">
        <el-button-group style="display:flex;">
          <el-button icon="el-icon-view" type="primary" @click="hideSearch">显示/隐藏搜索栏</el-button>
          <el-button type="primary" icon="el-icon-refresh" @click="onReset">重置</el-button>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
        </el-button-group>
      </div>

      <el-divider style="margin: 15px"></el-divider>


      <el-table v-loading="loading" :data="list" style="width: 100%;" border highlight-current-row
                @row-click="(row) => executeFuc(row,'0',tableObj.handleChangeFuc)" ref="multipleTable"
                :default-sort="defaultSort"
                @sort-change="handleSortChange">
        <!-- <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column type="index" label="序号" width="50"></el-table-column>
        <el-table-column label="单据号" prop="billNo" width="140" show-overflow-tooltip></el-table-column>
        <el-table-column label="单据类型" prop="billTypeName" width="120">
        </el-table-column>
        <el-table-column label="创建时间" prop="createTime" width="150"
                         sortable="custom"
                         :sort-orders="['ascending', 'descending']"></el-table-column>
        <el-table-column label="打印状态" width="100" prop="inCodeStatus">
          <template slot-scope="scope">
            <span>{{ enableMap[scope.row.inCodeStatus] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="所属部门" prop="deptName" width="120">
        </el-table-column>
        <el-table-column label="所属仓库" prop="invName" width="150">
        </el-table-column>
        <el-table-column label="单据来源" prop="fromType" width="120">
          <template slot-scope="scope">
            <span>{{ sourceMap[scope.row.fromType] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click.native="qrcodeDetail(scope.row)"
            >内部码
            </el-button
            >
          </template>
        </el-table-column> -->
        <template v-for="(item, index) in tableHeader">
          <el-table-column
            v-if="item.columnType == 'id' && executeEval(row,item.expression,true)"
            type="index" :label="item.columnDesc"></el-table-column>
          <el-table-column
            v-if="item.columnType == 'selection'"
            type="selection"
            :width="item.width"
            :selectable="(row,number) => executeFuc(row,'3',item.clickFuc)"
          ></el-table-column>

          <el-table-column
            v-if="item.columnType == 'radio' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template  slot-scope="scope">
              <el-radio :label="scope.row.id" v-model="radioCheck"><span></span></el-radio>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'laber' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template   slot-scope="scope">
              <span :style="{color: executeFuc(scope.row,'4',item.lableRuleObj[scope.row[item.columnName]])}">{{ item.lableRuleObj[scope.row[item.columnName]] }}</span>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'eltag' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template   slot-scope="scope">
              <el-tag :type="executeFuc(scope.row,'4',item,item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName])">
                <span>{{ item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName] }}</span>
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'button' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :width="item.width"
            :key="item.columnName"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button v-for="(buttonItem, buttonIndex) in item.buttonRulObj"
                         :type="buttonItem.type"
                         :size="buttonItem.size"
                         :style="buttonItem.style"
                         :key="buttonItem"
                         v-if="executeEval(scope.row,buttonItem.hasPermi,true)"
                         :disabled="executeEval(scope.row,buttonItem.disabledFuc,false)"
                         @click.native.stop="executeFuc(scope.row,'1',buttonItem.clickFuc)"
              >{{ buttonItem.name }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'text' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template slot-scope="scope">
              <span :style="{color: executeFuc(scope.row,'4',item,scope.row[item.columnName])}">{{ scope.row[item.columnName] }}</span>
            </template>
          </el-table-column>
        </template>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :limit.sync="query.limit"
        :page.sync="query.page"
        @pagination="handleCurrentChange"
      ></pagination>

    </el-card>

    <el-card class="el-card">
      <el-table v-loading="detailLoading" :data="detailList" style="width: 100%" border>
       <!-- <el-table-column type="index" label="序号" width="50"></el-table-column>
        <el-table-column label="物资名称" prop="coName"></el-table-column>
        <el-table-column label="规格型号" prop="spec"></el-table-column>
        <el-table-column label="批次号" prop="batchNo"></el-table-column>
        <el-table-column label="单据数量" prop="count"></el-table-column>
        <el-table-column label="生产日期" prop="productDate">
          <template slot-scope="scope">
            <span>{{ convertDateFun(scope.row.productDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="失效日期" prop="expireDate">
          <template slot-scope="scope">
            <span>{{ convertDateFun(scope.row.expireDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="价格" prop="price"></el-table-column>
        <el-table-column label="生产企业" prop="ylqxzcrbarmc"></el-table-column>
        <el-table-column label="注册/备案号" prop="certCode"></el-table-column> -->
        <template v-for="(item, index) in tableHeader2">
          <el-table-column
            v-if="item.columnType == 'id' && executeEval(row,item.expression,true)"
            type="index" :label="item.columnDesc"></el-table-column>
          <el-table-column
            v-if="item.columnType == 'selection'"
            type="selection"
            :width="item.width"
            :selectable="(row,number) => executeFuc(row,'3',item.clickFuc)"
          ></el-table-column>

          <el-table-column
            v-if="item.columnType == 'radio' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template  slot-scope="scope">
              <el-radio :label="scope.row.id" v-model="radioCheck"><span></span></el-radio>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'laber' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template   slot-scope="scope">
              <span :style="{color: executeFuc(scope.row,'4',item.lableRuleObj[scope.row[item.columnName]])}">{{ item.lableRuleObj[scope.row[item.columnName]] }}</span>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'eltag' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template   slot-scope="scope">
              <el-tag :type="executeFuc(scope.row,'4',item,item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName])">
                <span>{{ item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName] }}</span>
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'button' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :width="item.width"
            :key="item.columnName"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button v-for="(buttonItem, buttonIndex) in item.buttonRulObj"
                         :type="buttonItem.type"
                         :size="buttonItem.size"
                         :style="buttonItem.style"
                         :key="buttonItem"
                         v-if="executeEval(scope.row,buttonItem.hasPermi,true)"
                         :disabled="executeEval(scope.row,buttonItem.disabledFuc,false)"
                         @click.native.stop="executeFuc(scope.row,'1',buttonItem.clickFuc)"
              >{{ buttonItem.name }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'text'  && !(item.columnName == 'productDate' || item.columnName == 'expireDate') && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template slot-scope="scope">
              <span :style="{color: executeFuc(scope.row,'4',item,scope.row[item.columnName])}">{{ scope.row[item.columnName] }}</span>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'text' && (item.columnName == 'productDate' || item.columnName == 'expireDate') && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template slot-scope="scope">
              <span :style="{color: executeFuc(scope.row,'4',item,scope.row[item.columnName])}">{{ convertDateFun(scope.row[item.columnName]) }}</span>
            </template>
          </el-table-column>
        </template>
      </el-table>

      <pagination
        v-show="detailTotal>0"
        :total="detailTotal"
        :limit.sync="detailQuery.limit"
        :page.sync="detailQuery.page"
        @pagination="detailHandleCurrentChange"
      ></pagination>
    </el-card>

    <el-dialog
      title="内部码管理"
      :visible.sync="qrcodeDetailVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      width="70%"
      append-to-body
      v-if="qrcodeDetailVisible"
      @close='closeQRCodeDetailDialog'
    >
      <stockOrderQRCodeDetail
        :closeDialog="closeQRCodeDetailDialog"
        :idQuery="idQuery"
      ></stockOrderQRCodeDetail>
    </el-dialog>

  </div>
</template>

<script>
import {
  stockOrderList, stockOrderDetail, deleteStockOrderById, deleteStockOrderDetailById,
  copyStockOrderDetail, submitStockOrder,
  uploadStockOrderDetail, uploadStockOrderDetailCount,
  generateStockOrderQRCodeText
} from "@/api/inout/stockOrder";
import stockOrderDistribution from "./stockOrderDistribution";
import stockOrderQRCodeDetail from "./stockOrderQRCodeDetail";
import stockQRCodeExport from "./stockQRCodeExport";
import draggable from "vuedraggable";
import {inspectionStockOrderPDFFromTemplateFile, stockOrderPDFFromTemplateFile} from "@/api/itextpdf/itextpdf";
import store from "@/store";
import {getLocalJoinBusType} from "@/api/basic/busLocalType";
import {filterAll, filterAllByUser} from "@/api/system/invWarehouse";
import {filterSubByInv, findInvByUser} from '@/api/system/invSubWarehouse'
import {convertDate} from "@/utils/date"
import {filterOrder} from "@/api/inout/order";
import {getLocalJoinByUserOptimize} from "@/api/basic/busType";
import {
  getHead,executeFuc
} from "@/utils/customConfig";

export default {
  name: "stockOrder",
  data() {
    return {
      defaultSort: {prop: 'createTime', order: 'desc'},
      showSearch: true,
      convertDateFun: convertDate,
      query: {
        billType: null,
        corpName: null,
        locStorageCode: this.$store.getters.locInvCode,
        invWarehouseCode: this.$store.getters.locSubInvCode,
        billNo: "",
        status: "",
        action: null,
        statusType: "supInCode",
        page: 1,
        limit: 10,
        startTime: "",
        endTime: "",
        inCodeStatus: '0',
        productType:1
      },
      detailQuery: {
        orderIdFk: "",
        page: 1,
        limit: 20
      },
      isSp: store.getters.customerId,
      storageList: [],
      subInvList: [],
      busTypes: [],
      list: [],
      detailList: [],
      total: 0,
      tableHeader:[],
      queryList:[],
      fromList:[],
      tableHeader2:[],
      queryList2:[],
      fromList2:[],
      options: {
        getBusType:[]
      },
      detailTotal: 0,
      loading: false,
      detailLoading: false,
      enableMap: {
        1: "已打印",
        0: "未打印",
      },
      sourceMap: {
        "1": "UDIMS平台",
        "2": "网页新增",
        "3": "pda已校验",
        "4": "pda未校验",
        "5": "pc端扫码精灵",
        "6": "单据流转",
        "7": "供应商平台",
        "8": "平衡补单",
        "9": "单据验收直接补单",
        "10": "单据复制",
        "11": "盘点单据转单",
        "12": "申购计划转单",
        "13": "领用单据转单",
        "14": "第三方单据转单",

      },
      idQuery: {
        id: "",
        filterUDIType: null,
      },
      distributionVisible: false,
      detailFormRules: {
        batchNo: [
          {required: true, message: "请输入批次号", trigger: "blur"}
        ],
        productDate: [
          {required: true, message: "请输入生产日期", trigger: "blur"}
        ],
        expireDate: [
          {required: true, message: "请输入失效日期", trigger: "blur"}
        ],
        sweepCount: [
          {required: true, message: "请输入扫码数量", trigger: "blur"}
        ]
      },
      detailFormVisible: false,
      detailFormData: {},
      detailFormLoading: false,
      haveDistributionVisible: true,
      qrcodeDetailVisible: false,
      qrcodeExportVisible: false,
      filterUDIType: true,
      actDateRange: [],
      auditDateRange: [],
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
    }
  },
  methods: {
    onReset() {
      this.$router.push({
        path: ""
      });
      this.query = {
        billType: null,
        corpName: null,
        locStorageCode: this.$store.getters.locInvCode,
        invWarehouseCode: this.$store.getters.locSubInvCode,
        billNo: "",
        status: "",
        action: null,
        statusType: "supInCode",
        page: 1,
        limit: 10,
        startTime: "",
        endTime: "",
        inCodeStatus: '0',
        productType:1
      };
      this.haveDistributionVisible = true;
      this.actDateRange = [];
      this.getList();
    },
    hideSearch() {
      this.showSearch = !this.showSearch;
    },
    onSubmit() {
      this.query.page = 1;
      if (this.actDateRange !== null) {
        this.query.startTime = this.actDateRange[0];
        this.query.endTime = this.actDateRange[1];
      } else {
        this.query.startTime = null;
        this.query.endTime = null;
      }

      if (this.auditDateRange !== null) {
        this.query.startAduditTime = this.auditDateRange[0];
        this.query.endAduditTime = this.auditDateRange[1];
      } else {
        this.query.startAduditTime = null;
        this.query.endAduditTime = null;
      }
      this.getList();
      this.haveDistributionVisible = true;
    },
    handleCurrentChange(val) {
      this.query.page = val.page;
      this.getList();
    },
    detailHandleCurrentChange(val) {
      this.detailQuery.page = val.page;
      this.getStockOrderDetailList(this);
    },
    // 刷新表单
    resetForm() {
      if (this.$refs["dataForm"]) {
        // 清空验证信息表单
        this.$refs["dataForm"].clearValidate();
        // 刷新表单
        this.$refs["dataForm"].resetFields();
        this.getList();
      }
    },

    handleSortChange(column, prop, order) {
      if (column.order === 'descending') {
        this.query.sort = 'desc'
      } else {
        this.query.sort = 'asc'
      }
      this.query.orderBy = column.prop;
      this.getList();
    },


    getList() {
      this.loading = true;
      this.query.corpId = store.getters.customerId;
      if (this.actDateRange !== null) {
        this.query.startTime = this.actDateRange[0];
        this.query.endTime = this.actDateRange[1];
      } else {
        this.query.startTime = null;
        this.query.endTime = null;
      }
      this.query.vueType = "stock";
      filterOrder(this.query)
        .then(response => {
          this.loading = false;
          if (response.code == 20000) {
            this.list = response.data.list || [];
            this.total = response.data.total || 0;
            this.detailList = [];
          } else {
            this.$message.error(response.message);
          }
        })
        .catch(() => {
          this.loading = false;
          this.list = [];
          this.detailList = [];
          this.total = 0;
        });
    },

    closeDialog(type) {
      this.distributionVisible = false;
      this.getList();
      if (this.$isNotBlank(type)) {
        this.detailList = [];
      }
    },


    qrcodeDetail(_this,row) {
      _this.idQuery.id = '';
      if (_this.$isNotBlank(row.id)) {
        _this.idQuery.id = row.id;
        _this.idQuery.formData = row;
        _this.idQuery.filterUDIType = _this.filterUDIType;
        _this.qrcodeDetailVisible = true;
      }
    },
    closeQRCodeDetailDialog() {
      this.qrcodeDetailVisible = false;
      this.getList();
    },
    getStockOrderDetailList(_this,row) {
      if (_this.$isNotBlank(row)) {
        _this.detailQuery.orderIdFk = row.billNo;
      }
      _this.detailLoading = true;
      stockOrderDetail(_this.detailQuery)
        .then((response) => {
          _this.detailLoading = false;
          _this.detailList = response.data.list || [];
          _this.detailTotal = response.data.total;
        })
        .catch(() => {
          _this.detailLoading = false;
          _this.detailList = [];
        });
    },
    getBusType(_this) {
      let query = {
        enabled: true,
        vueType: "stock",
        productType:1
      };
      getLocalJoinByUserOptimize(query)
        .then((response) => {
          _this.options.getBusType = response.data || [];
          _this.query.action = this.busTypes[0].action;
          // this.getList();
        })
        .catch(() => {
        });
    },
    getSubInvList(_this) {
      findInvByUser()
        .then((response) => {
          _this.options.getSubInvList = response.data || [];
        })
        .catch(() => {
        });
    },

    subInvChange() {
      this.getBusType(this);
    },
    executeFuc(row,type,clickFuc,value){
      return executeFuc(this,row,type,clickFuc,value);
    },
    executeEval(row,expression,defaultRet){
      if(expression){
        return eval(expression);
      }
      return defaultRet;
    }
  },
  components: {
    draggable,
    stockOrderDistribution,
    stockOrderQRCodeDetail,
    stockQRCodeExport,
  },
  filters: {
    statusFilterType(status) {
      const statusMap = {
        0: "gray",
        1: "success"
      };
      return statusMap[status];
    },
    statusFilterName(status) {
      const statusMap = {
        "1": "草稿",
        "2": "未配货",
        "3": "待校验",
      };
      return statusMap[status];
    },
    typeFilterName(type) {
      const typeMap = {
        1: "预入库",
        2: "普通采购",
      };
      return typeMap[type];
    }
  },
  created() {
    // 加载表格数据
    this.getSubInvList(this);
    this.getBusType(this);
    getHead("stockOrder-1","1").then((re) => {
      // 处理返回的数据
      this.tableObj = re.data;
      this.tableHeader = re.data.tableList;
      this.queryList = re.data.queryList;
      this.fromList = re.data.fromList;
      this.getList()
    });
    getHead("stockOrder-2","1").then((re) => {
      // 处理返回的数据
      this.tableObj2 = re.data;
      this.tableHeader2 = re.data.tableList;
      this.queryList2 = re.data.queryList;
      this.fromList2 = re.data.fromList;
    });
  }
}
</script>

<style scoped>

</style>
