spring
2025-03-19 07a41ade45c962e93a9d449ce1be0eec52e66a6a
src/components/view/b1-sample.vue
@@ -1,46 +1,47 @@
<style scoped>
   .title {
      height: 60px;
      line-height: 60px;
   }
  .title {
    height: 60px;
    line-height: 60px;
  }
   .search {
      background-color: #fff;
      height: 80px;
      display: flex;
      align-items: center;
  .search {
    background-color: #fff;
    height: 80px;
    display: flex;
    align-items: center;
    position: relative;
   }
  }
   .search_thing {
      display: flex;
      align-items: center;
      height: 50px;
   }
  .search_thing {
    display: flex;
    align-items: center;
    height: 50px;
  }
   .search_label {
      width: 90px;
      font-size: 14px;
      text-align: right;
   }
  .search_label {
    width: 90px;
    font-size: 14px;
    text-align: right;
  }
   .search_input {
      width: calc(100% - 120px);
   }
  .search_input {
    width: calc(100% - 120px);
  }
   .table {
      margin-top: 10px;
      background-color: #fff;
      width: calc(100% - 40px);
      height: calc(100% - 60px - 80px - 10px - 40px);
      padding: 20px;
   }
  .table {
    margin-top: 10px;
    background-color: #fff;
    width: calc(100% - 40px);
    height: calc(100% - 60px - 80px - 10px - 40px);
    padding: 20px;
    overflow-y: auto;
  }
   .el-form-item {
      margin-bottom: 16px;
   }
  .el-form-item {
    margin-bottom: 16px;
  }
  .btns{
  .btns {
    position: absolute;
    right: 10px;
    top: 25px;
@@ -49,29 +50,31 @@
    z-index: 9;
  }
  .tables{
  .tables {
    width: 100%;
    height: 100%;
    border-bottom: none;
  }
  .tables th{
      font-size: 14px;
  .tables th {
    font-size: 14px;
  }
  .tables td{
      font-size: 12px;
      text-align: center;
      vertical-align: top;
      border-color: rgb(192, 191, 191) !important;
      padding: 5px;
  .tables td {
    font-size: 12px;
    text-align: center;
    vertical-align: top;
    border-color: rgb(192, 191, 191) !important;
    padding: 5px;
    box-sizing: border-box;
    height: 120px;
  }
  .tables ul{
  .tables ul {
    list-style-type: none;
  }
  .tables ul li{
  .tables ul li {
    border-radius: 3px;
    padding: 4px 10px;
    box-sizing: border-box;
@@ -82,9 +85,12 @@
    justify-content: start;
    color: #333333;
    cursor: pointer;
    overflow: hidden; /*超出部分隐藏*/
    white-space: nowrap; /*禁止换行*/
    text-overflow: ellipsis; /*省略号*/
  }
  .tables h4{
  .tables h4 {
    color: #999999;
    font-size: 14px;
    font-weight: 400;
@@ -99,35 +105,35 @@
    margin-right: 6px;
  }
  .blue{
    background: rgba(58,123,250,0.18);
  li:hover {
    background: rgba(58, 123, 250, 0.18);
  }
  .blue i{
  li:hover i {
    background: #3A7BFA;
  }
  .blue .num{
  li:hover .num {
    color: #3A7BFA;
  }
  .green{
  .green {
    background: #E0F6EA;
  }
  .green i{
  .green i {
    background: #34BD66;
  }
  .green .num{
  .green .num {
    color: #34BD66;
  }
  .el-dialog{
  .el-dialog {
    position: relative;
  }
  .shaoma{
  .shaoma {
    display: flex;
    align-items: center;
    font-size: 14px;
@@ -139,190 +145,229 @@
  }
  .node_i {
      color: orange;
      font-size: 18px;
   }
    color: orange;
    font-size: 18px;
  }
  .custom-tree-node .el-button {
      opacity: 0;
   }
    opacity: 0;
  }
   .custom-tree-node:hover .el-button {
      opacity: 1;
   }
  .custom-tree-node:hover .el-button {
    opacity: 1;
  }
  >>>.el-loading-mask {
    z-index: 10;
  }
</style>
<template>
   <div class="inspection_order">
      <div style="width: 100%;height: 100%;" v-if="!isDetail">
         <div>
            <el-row class="title">
               <el-col :span="12" style="padding-left: 20px;">样品管理</el-col>
  <div class="sample">
    <div style="width: 100%;height: 100%;" v-if="!isDetail">
      <div>
        <el-row class="title">
          <el-col :span="12" style="padding-left: 20px;text-align: left;">样品管理</el-col>
          <el-col :span="12" style="text-align: right;">
                  <el-button size="small" type="primary" @click="storageVisible=true">入库</el-button>
            <el-button size="small" type="primary" @click="storageVisible=true">入库</el-button>
            <el-button size="small" type="primary" @click="exportVisible=true">出库</el-button>
               </el-col>
            </el-row>
         </div>
         <div class="search">
            <div class="search_thing">
               <div class="search_label">仓库名称:</div>
               <div class="search_input">
            <el-select v-model="entity.status" placeholder="全部" size="small">
              <el-option
                v-for="item in statusList"
                :key="item.value"
                :label="item.label"
                :value="item.value">
          </el-col>
        </el-row>
      </div>
      <div class="search">
        <div class="search_thing">
          <div class="search_label">仓库名称:</div>
          <div class="search_input">
            <el-select v-model="entity.warehouseId" placeholder="选择仓库" size="small" @change="warehouseChange">
              <el-option v-for="item in warehouse" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </div>
            </div>
            <div class="search_thing">
               <div class="search_label">货架:</div>
               <div class="search_input">
            <el-select v-model="entity.status" placeholder="全部" size="small">
              <el-option
                v-for="item in statusList"
                :key="item.value"
                :label="item.label"
                :value="item.value">
        </div>
        <div class="search_thing">
          <div class="search_label">货架:</div>
          <div class="search_input">
            <el-select v-model="entity.shelfId" placeholder="选择货架" size="small" @change="handleShelf">
              <el-option v-for="item in shelf" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </div>
            </div>
            <div class="search_thing" style="padding-left: 30px;">
        </div>
        <div class="search_thing">
          <div class="search_label">样品编号:</div>
          <div class="search_input">
            <el-input placeholder="请输入样品编号" v-model="searchSampleCode" size="small" autocomplete="off" ref="organization" readonly="readonly" @focus="remove('organization')" @blur="setType('organization')">
              <!-- <el-button slot="append" icon="el-icon-search" @click="handleSearch"></el-button> -->
            </el-input>
          </div>
        </div>
        <div class="search_thing">
          <el-button size="small" @click="handleShelf(entity.shelfId,''),searchSampleCode=''">重置</el-button>
          <el-button size="small" type="primary" @click="handleShelf(entity.shelfId,searchSampleCode)">查询</el-button>
        </div>
        <!-- <div class="search_thing" style="padding-left: 30px;">
               <el-button size="small" @click="refresh()">重 置</el-button>
               <el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
            </div>
            </div> -->
        <div class="btns">
          <el-button size="small" style="color:#3A7BFA" @click="keepVisible=true">维护</el-button>
          <el-button size="small" style="color:#3A7BFA" @click="warehouseVisible=true">添加仓库</el-button>
          <el-button size="small" style="color:#3A7BFA" @click="shelvesVisible=true">添加货架</el-button>
          <el-button size="small" style="color:#3A7BFA" @click="warehouseVisible=true,isEdit=false">添加仓库</el-button>
          <el-button size="small" style="color:#3A7BFA" @click="shelvesVisible=true,isEdit=false"
            :disabled="entity.warehouseId==null">添加货架</el-button>
        </div>
         </div>
         <div class="table">
        <table border="1" class="tables" cellpadding="10">
      </div>
      <div class="table" v-loading="tableLoading">
        <table border="1" class="tables" cellpadding="10" style="table-layout:fixed;" v-if="tableList.length>0">
          <tbody>
              <tr v-for="(item,index) in tableList" :key="index">
                <td v-for="(m,i) in item" :key="i" class="content">
                  <h4>{{ m.title }}</h4>
                  <ul>
                    <li v-for="(n,j) in m.list" :key="j" :class="{blue:n.type==0,green:n.type==1}" @click="handelDetail(n)">
            <tr v-for="(item,index) in tableList" :key="index">
              <td v-for="(m,i) in item" :key="i" class="content">
                <h4 v-if="m.row!=undefined">{{ m.row }} - {{ m.col }}</h4>
                <ul>
                  <el-tooltip
                  effect="dark"
                  placement="top"
                  v-for="(n,j) in m.samples"
                  :key="j" :disabled="`${n.sample}${n.model}`.length<5">
                    <div slot="content"><span>{{ n.sample }}</span>
                      <span>&nbsp;({{ n.model }})&nbsp;[{{ n.sampleCode }}]</span></div>
                    <li class="green"
                      @click="handelDetail(n)">
                      <i></i>
                      <span>{{ n.name }}</span>
                      <span>&nbsp;({{ n.specs }})&nbsp;</span>
                      <span class="num">&nbsp;x{{ n.num }}</span>
                      <span>{{ n.sample }}</span>
                      <span>&nbsp;({{ n.model }})&nbsp;[{{ n.sampleCode }}]</span>
                      <!-- <span class="num">&nbsp;x{{ n.num }}</span> -->
                    </li>
                  </ul>
                </td>
              </tr>
              <tr>
                <td v-for="(item,index) in rowList" :key="index" style="background: ghostwhite;height: 20px;">{{ item }}</td>
              </tr>
            </tbody>
                  </el-tooltip>
                </ul>
              </td>
            </tr>
            <tr>
              <td v-for="(item,index) in rowList" :key="index" style="background: ghostwhite;height: 20px;">{{ item }}
              </td>
            </tr>
          </tbody>
        </table>
         </div>
      </div>
    <Detail v-else @hanldeBack="isDetail=false"/>
        <span v-else style="color: rgb(144, 147, 153);display: inline-block;position: absolute;top: 60%;left: 50%;transform: translate(-50%,-50%);">暂无数据</span>
      </div>
    </div>
    <Detail v-else @hanldeBack="isDetail=false" :id="currentId" />
    <el-dialog title="样品入库" :visible.sync="storageVisible" width="350px">
      <div class="shaoma">
      <!-- <div class="shaoma">
        <img src="../../../static/img/扫码.svg" alt="" style="margin-right: 5px;">
        <span>扫码入库</span>
      </div>
      </div> -->
      <el-row>
        <el-col class="search_thing" :span="24">
          <div class="search_label"><span class="required-span">* </span>样品编号:</div>
          <div class="search_input">
            <el-input v-model="value" size="small"></el-input>
            <el-input v-model="sampleCode" size="small" @change="sampleCodeChange" :disabled="sampleCodeBtnDisabled">
              <el-tooltip :content="sampleCodeBtnDisabled?'手动输入':'扫码枪输入'" placement="top" slot="append">
                <el-button type="primary" icon="el-icon-edit" @click="sampleCodeBtnDisabled=!sampleCodeBtnDisabled"></el-button>
              </el-tooltip>
            </el-input>
          </div>
        </el-col>
        <el-col class="search_thing" :span="24">
          <div class="search_label" style="width: 90px"><span class="required-span">* </span>订单编号:</div>
          <div class="search_input">
            <el-input v-model="entrustCode" size="small" clearable :disabled="sampleCodeBtnDisabled">
            </el-input>
          </div>
        </el-col>
      </el-row>
      <el-tree :data="list" ref="tree" :props="{ children: 'children', label: 'label' }" node-key="label"
               :filter-node-method="filterNode" @node-click="handleNodeClick" highlight-current @node-expand="nodeOpen"
               @node-collapse="nodeClose" :default-expanded-keys="expandedKeys" v-if="storageVisible">
               <div class="custom-tree-node" slot-scope="{ node, data }">
                  <el-row>
                     <el-col :span="24">
                        <span><i
                              :class="`node_i ${data.children != undefined ? 'el-icon-folder-opened' : 'el-icon-tickets'}`"></i>
                           {{ data.code }} {{ data.label }}</span>
                     </el-col>
                  </el-row>
               </div>
            </el-tree>
         <span slot="footer" class="dialog-footer">
            <el-button @click="storageVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmStorage" :loading="upLoadStorage">确 定</el-button>
         </span>
      </el-dialog>
      <el-tree :data="storageList" ref="tree" :props="{ children: 'warehouseShelfList', label: 'name' }" node-key="id"
        :filter-node-method="filterNode" @node-click="handleNodeClick" highlight-current @node-expand="nodeOpen"
        @node-collapse="nodeClose" :default-expanded-keys="expandedKeys" v-if="storageVisible"
        empty-text="暂无数据">
        <div class="custom-tree-node" slot-scope="{ node, data }">
          <el-row>
            <el-col :span="24">
              <span><i
                  :class="`node_i ${data.warehouseShelfList != undefined ? 'el-icon-folder-opened' : 'el-icon-tickets'}`"></i>
                {{ data.name }}</span>
            </el-col>
          </el-row>
        </div>
      </el-tree>
      <span slot="footer" class="dialog-footer">
        <el-button @click="storageVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmStorage" :loading="upLoadStorage">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="样品出库" :visible.sync="exportVisible" width="350px">
      <div class="shaoma">
      <!-- <div class="shaoma">
        <img src="../../../static/img/扫码.svg" alt="" style="margin-right: 5px;">
        <span>扫码出库</span>
      </div>
      </div> -->
      <el-row>
        <el-col class="search_thing" :span="24">
          <div class="search_label"><span class="required-span">* </span>样品编号:</div>
          <div class="search_input">
            <el-input v-model="value" size="small"></el-input>
            <el-input v-model="sampleCode" size="small" @change="sampleCodeChange" clearable :disabled="sampleCodeBtnDisabled">
              <el-tooltip :content="sampleCodeBtnDisabled?'手动输入':'扫码枪输入'" placement="top" slot="append">
                <el-button type="primary" icon="el-icon-edit" @click="sampleCodeBtnDisabled=!sampleCodeBtnDisabled"></el-button>
              </el-tooltip>
            </el-input>
          </div>
        </el-col>
        <el-col class="search_thing" :span="24">
          <div class="search_label" style="width: 90px"><span class="required-span">* </span>委托编号:</div>
          <div class="search_input">
            <el-input v-model="entrustCode" size="small" clearable :disabled="sampleCodeBtnDisabled">
            </el-input>
          </div>
        </el-col>
      </el-row>
         <span slot="footer" class="dialog-footer">
            <el-button @click="exportVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmExport" :loading="upLoadExport">确 定</el-button>
         </span>
      </el-dialog>
    <el-dialog title="库位维护" :visible.sync="keepVisible" width="350px">
      <el-tree :data="list" ref="tree" :props="{ children: 'children', label: 'label' }" node-key="label"
               :filter-node-method="filterNode" @node-click="handleNodeClick" highlight-current @node-expand="nodeOpen"
               @node-collapse="nodeClose" :default-expanded-keys="expandedKeys" v-if="keepVisible">
               <div class="custom-tree-node" style="width: 100%;" slot-scope="{ node, data }">
                  <el-row style="width: 100%;display: flex;align-items: center;">
                     <el-col :span="20">
                        <span><i
                              :class="`node_i ${data.children != undefined ? 'el-icon-folder-opened' : 'el-icon-tickets'}`"></i>
                           {{ data.code }} {{ data.label }}</span>
                     </el-col>
              <el-col :span="4" v-if="node.level<3">
                <el-button
                  type="text"
                  size="mini" icon="el-icon-edit" @click.stop="handleEdit(data,node.level)">
                </el-button>
                <el-button
                  type="text"
                  size="mini" icon="el-icon-delete" @click.stop="handleDelete(data,node.level)">
                </el-button>
              </el-col>
                  </el-row>
               </div>
            </el-tree>
         <span slot="footer" class="dialog-footer">
            <el-button @click="keepVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmKeep" :loading="upLoadKeep">确 定</el-button>
         </span>
      </el-dialog>
      <span slot="footer" class="dialog-footer">
        <el-button @click="exportVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmExport" :loading="upLoadExport">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="库位维护" :visible.sync="keepVisible" width="350px" :append-to-body="true">
      <el-tree :data="warehouse" ref="tree" :props="{ children: 'warehouseShelfList', label: 'name' }" node-key="id"
        :filter-node-method="filterNode" @node-click="handleNodeClick" highlight-current @node-expand="nodeOpen"
        @node-collapse="nodeClose" :default-expanded-keys="expandedKeys" v-if="keepVisible"
        empty-text="暂无数据">
        <div class="custom-tree-node" style="width: 100%;" slot-scope="{ node, data }">
          <el-row style="width: 100%;display: flex;align-items: center;">
            <el-col :span="20">
              <span><i
                  :class="`node_i ${node.level<2 ? 'el-icon-folder-opened': 'el-icon-tickets'}`"></i>
                {{ data.name }}</span>
            </el-col>
            <el-col :span="4" v-if="node.level<3">
              <el-button type="text" size="mini" icon="el-icon-edit" @click.stop="handleEdit(data,node.level)">
              </el-button>
              <el-button type="text" size="mini" icon="el-icon-delete" @click.stop="handleDelete(data,node.level)">
              </el-button>
            </el-col>
          </el-row>
        </div>
      </el-tree>
      <span slot="footer" class="dialog-footer">
        <el-button @click="keepVisible = false">取 消</el-button>
        <el-button type="primary" @click="keepVisible = false" >确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :title="isEdit?'仓库修改':'仓库新增'" :visible.sync="warehouseVisible" width="350px">
      <el-row>
        <el-col class="search_thing" :span="24">
          <div class="search_label"><span class="required-span">* </span>仓库名称:</div>
          <div class="search_input">
            <el-input v-model="value" size="small"></el-input>
            <el-input v-model="name" size="small" @keyup.enter.native="confirmWarehouse"></el-input>
          </div>
        </el-col>
      </el-row>
         <span slot="footer" class="dialog-footer">
            <el-button @click="warehouseVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmWarehouse" :loading="upLoadWarehouse">确 定</el-button>
         </span>
      </el-dialog>
      <span slot="footer" class="dialog-footer">
        <el-button @click="warehouseVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmWarehouse" :loading="upLoadWarehouse">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :title="isEdit?'货架修改':'货架新增'" :visible.sync="shelvesVisible" width="350px">
      <el-row>
        <el-col class="search_thing" :span="24">
          <div class="search_label"><span class="required-span">* </span>货架名称:</div>
          <div class="search_input">
            <el-input v-model="value" size="small"></el-input>
            <el-input v-model="shelves.name" size="small"></el-input>
          </div>
        </el-col>
      </el-row>
@@ -330,694 +375,522 @@
        <el-col class="search_thing" :span="24">
          <div class="search_label"><span class="required-span">* </span>货架层数:</div>
          <div class="search_input">
            <el-input v-model="value" size="small"></el-input>
            <el-input v-model="shelves.row" size="small"></el-input>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col class="search_thing" :span="24">
          <div class="search_label">货架列数:</div>
          <div class="search_label"><span class="required-span">* </span>货架列数:</div>
          <div class="search_input">
            <el-input v-model="value" size="small"></el-input>
            <el-input v-model="shelves.col" size="small"></el-input>
          </div>
        </el-col>
      </el-row>
         <span slot="footer" class="dialog-footer">
            <el-button @click="shelvesVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmShelves" :loading="upLoadShelves">确 定</el-button>
         </span>
      </el-dialog>
   </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="shelvesVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmShelves" :loading="upLoadShelves">确 定</el-button>
      </span>
    </el-dialog>
    <input  id="ScanCodeInfo0" v-model="codeInfo" @keyup.enter="keyup" style="opacity: 0;height: 0px;margin: 0px;padding: 0px;position: absolute;top: 0;"></input>
  </div>
</template>
<script>
import Detail from '../do/b1-sample/detail.vue'
   export default {
      components: {
  import Detail from '../do/b1-sample/detail.vue'
  export default {
    components: {
      Detail
      },
      data() {
         return {
            entity: {},
        statusList:[],
        storageVisible:false,
        exportVisible:false,
        keepVisible:false,
        warehouseVisible:false,
        shelvesVisible:false,
        upLoadStorage:false,
        upLoadExport:false,
        upLoadKeep:false,
        upLoadWarehouse:false,
        upLoadShelves:false,
        tableList:[
          [
            {
              title:'1-1-4',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-2-4',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-3-4',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-4-4',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-5-4',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-6-4',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-7-4',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
          ],
          [
          {
              title:'1-1-3',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-2-3',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-3-3',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-4-3',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-5-3',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-6-3',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-7-3',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
          ],
          [
          {
              title:'1-1-2',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-2-2',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-3-2',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-4-2',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-5-2',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-6-2',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-7-2',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
          ],
          [
          {
              title:'1-1-1',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-2-1',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-3-1',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-4-1',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-5-1',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-6-1',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
            {
              title:'1-7-1',
              list:[
                {
                  name:'原材料',
                  specs:'规格1',
                  num:20,
                  type:0,
                },
                {
                  name:'原材料',
                  specs:'规格2',
                  num:20,
                  type:1,
                },
              ]
            },
          ]
        ],
        rowList:[
          '1列',
          '2列',
          '3列',
          '4列',
          '5列',
          '6列',
          '7列',
        ],
        value:'',
        list:[
          {
            code:1,
            label:'父级',
            children:[
              {
                code:1,
                label:'子级1',
                children:[
                  {
                    code:1,
                    label:'子级2',
                    children:[
                      {
                        code:1,
                        label:'子级3',
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ],
        selectTree: null,
    },
    data() {
      return {
        entity: {
          warehouseId: null,
          shelfId: null
        },
        sampleCodeBtnDisabled:true,
        warehouse: [],
        startTime: null,
        shelf: [],
        storageList:[],
        storageVisible: false,
        exportVisible: false,
        keepVisible: false,
        warehouseVisible: false,
        shelvesVisible: false,
        upLoadStorage: false,
        upLoadExport: false,
        upLoadWarehouse: false,
        upLoadShelves: false,
        tableList: [],
        rowList: [],
        value: '',
        name:'',
        shelves:{},
        selectTree: [],
        expandedKeys: [],
        isEdit:false,//弹框--是否是修改,默认为false
        isDetail:false,//详情--是否展示为详情页面,默认为false
         }
      },
      mounted() {
      },
      methods: {
        isEdit: false, //弹框--是否是修改,默认为false
        isDetail: false, //详情--是否展示为详情页面,默认为false
        currentEdit:null,//当前要维护的信息
        tableLoading:false,
        sampleCode:'',
        entrustCode:'',
        currentId:null,
        searchSampleCode:null,
        codeInfo:null,
      }
    },
    watch:{
      storageVisible(newVal){
        if(newVal){
            this.selectList()
            this.sampleCode = null
            this.entrustCode = null
            // this.$message.success('扫码:打开')
            let input = document.getElementById('ScanCodeInfo0');
            input.focus();
            this.startTime = setInterval(()=>{
                input.focus()
            },1000)
        }else{
            // this.$message.warning('扫码:关闭')
            clearInterval(this.startTime)
            this.sampleCodeBtnDisabled=true
        }
      },
      exportVisible(newVal){
        if(newVal){
            // this.$message.success('扫码:打开')
            this.sampleCode = null
            this.entrustCode = null
            let input = document.getElementById('ScanCodeInfo0');
            input.focus();
            this.startTime = setInterval(()=>{
                input.focus()
            },1000)
        }else{
            // this.$message.warning('扫码:关闭')
            clearInterval(this.startTime)
            this.sampleCodeBtnDisabled=true
        }
      },
      sampleCodeBtnDisabled(val){
        if(!val){
          this.startTime&&clearInterval(this.startTime)
        }else if(this.exportVisible||this.storageVisible){
          let input = document.getElementById('ScanCodeInfo');
          input.focus();
          this.startTime = setInterval(()=>{
              input.focus()
          },1000)
        }
      },
      isEdit(newVal){
        if(!newVal){
          this.shelves = {}
        }
      }
    },
    mounted() {
      this.selectList()
    },
    methods: {
      keyup(e){
        var codeInfo = null
        try{
            console.log(2222,this.codeInfo)
            codeInfo = JSON.parse(this.codeInfo)
            if(!codeInfo||codeInfo.sampleCode==undefined||codeInfo.entrustCode==undefined){
                this.$message.error('该二维码有误')
            }else{
                this.sampleCode = codeInfo.sampleCode
                this.entrustCode = codeInfo.entrustCode
            }
        }catch(e){
            this.$message.error('请调至英文键盘')
        }
        this.codeInfo = null
      },
      selectList() {
        this.$axios.get(this.$api.warehouse.selectWarehouse).then(res => {
          this.warehouse = res.data
          if(res.data.length==0){
            this.entity.warehouseId = '';
            this.entity.shelfId = '';
            this.tableList = []
          }
          this.storageList = this.HaveJson(res.data).map(item=>{
            item.warehouseShelfList&&item.warehouseShelfList.length>0&&item.warehouseShelfList.map(m=>{
              let warehouseShelfList = [];
              let warehouseShelfList0 = []
              let warehouseCellList = m.warehouseCellList?m.warehouseCellList:[]
              warehouseCellList.forEach(a=>{
                if(warehouseShelfList.find(n=>n.id==a.row)){
                  warehouseShelfList0.push({
                    name:a.col+'列',
                    id:a.col
                  })
                }else if(warehouseShelfList.length==0){
                  warehouseShelfList.push({
                    name:a.row+'层',
                    id:a.row
                  })
                  warehouseShelfList0.push({
                    name:a.col+'列',
                    id:a.col
                  })
                }else if(!warehouseShelfList.find(n=>n.id==a.row)){
                  warehouseShelfList[warehouseShelfList.length-1].warehouseShelfList = JSON.parse(JSON.stringify(warehouseShelfList0))
                  warehouseShelfList0 = []
                  warehouseShelfList.push({
                    name:a.row+'层',
                    id:a.row
                  })
                  warehouseShelfList0.push({
                    name:a.col+'列',
                    id:a.col
                  })
                }
              })
              warehouseShelfList[warehouseShelfList.length-1].warehouseShelfList = JSON.parse(JSON.stringify(warehouseShelfList0))
              m.warehouseShelfList = warehouseShelfList;
              return m;
            })
            return item;
          })
          if(!this.entity.warehouseId&&this.warehouse.length>0){
            this.entity.warehouseId = this.warehouse[0].id
            this.warehouseChange(this.entity.warehouseId)
            if(this.shelf.length>0){
              this.entity.shelfId = this.shelf[0].id
              this.handleShelf(this.entity.shelfId)
            }else{
              this.tableList = []
            }
          }else if(this.warehouse.length>0){
            this.warehouseChange(this.entity.warehouseId)
            if(this.shelf.length>0){
              this.entity.shelfId = this.shelf[0].id
              this.handleShelf(this.entity.shelfId)
            }else{
              this.tableList = []
            }
          }
        })
      },
      selectStandardTreeList() {
            this.$axios.get(this.$api.standardTree.selectStandardTreeList).then(res => {
               this.list = res.data
               this.list.forEach(a => {
                  a.children.forEach(b => {
                     this.expandedKeys.push(b.label)
                  })
               })
            })
         },
         refreshTable() {
            this.$refs['ValueTable'].selectList()
         },
         refresh() {
            this.entity = this.HaveJson(this.entity)
         },
         handleClose() {
            this.upLoad = false;
         },
        this.$axios.get(this.$api.standardTree.selectStandardTreeList).then(res => {
          this.list = res.data
          this.list.forEach(a => {
            a.children.forEach(b => {
              this.expandedKeys.push(b.label)
            })
          })
        })
      },
      // 入库
      confirmStorage(){
        if(!this.value){
      confirmStorage() {
        if (!this.sampleCode) {
          this.$message.error('请填写样品编号')
          return
        }
        let trees = this.selectTree.split(" - ")
            if (trees.length < 4) {
               this.$message.error('未选择样品')
               return
            }
        if (!this.entrustCode) {
          this.$message.error('请填写订单编号')
          return
        }
        if (this.selectTree.length < 4) {
          this.$message.error('请选择样品入库位置')
          return
        }
        this.upLoadStorage = true;
        this.$axios.post(this.$api.warehouse.inWarehouse, {
            trees: this.selectTree.join('-'),
            sampleCode:this.sampleCode,
            entrustCode:this.entrustCode
          }).then(res => {
            this.upLoadStorage = false;
            this.storageVisible = false
            this.sampleCode = '';
            this.entrustCode = '';
            this.selectTree = []
            if (res.code == 201) {
              this.$message.error('入库失败')
              return
            }
            this.$message.success('入库成功')
            this.handleShelf(this.entity.shelfId)
          })
      },
      // 出库
      confirmExport(){
        if(!this.value){
      confirmExport() {
        if (!this.sampleCode) {
          this.$message.error('请填写样品编号')
          return
        }
        if (!this.entrustCode) {
          this.$message.error('请填写订单编号')
          return
        }
        this.upLoadExport = true;
        this.$axios.post(this.$api.warehouse.outWarehouse, {
            sampleCode:this.sampleCode,
            entrustCode:this.entrustCode,
          }).then(res => {
            this.upLoadExport = false;
            this.exportVisible = false
            this.sampleCode = '';
            this.entrustCode = '';
            if (res.code == 201) {
              this.$message.error('出库失败')
              return
            }
            this.$message.success('出库成功')
            this.handleShelf(this.entity.shelfId)
          })
      },
      // 维护
      confirmKeep(){
        this.upLoadKeep = true;
      },
      // 添加仓库
      confirmWarehouse(){
        if(!this.value){
      // 添加/修改仓库
      confirmWarehouse() {
        if (!this.name) {
          this.$message.error('请填写仓库名称')
          return
        }
        this.upLoadWarehouse = true;
        if(this.currentEdit&&this.currentEdit.id){
          // 修改仓库
          this.$axios.post(this.$api.warehouse.upWarehouse, {
            name: this.name,
            id:this.currentEdit.id
          }, {
               headers: {
                  'Content-Type': 'application/json'
               }
            }).then(res => {
            this.upLoadWarehouse = false;
            this.warehouseVisible = false
            // this.keepVisible = false
            this.currentEdit = null;
            if (res.code == 201) {
              this.$message.error('修改失败')
              return
            }
            this.$message.success('修改成功')
            this.selectList()
            this.name = ''
            this.warehouseChange(this.entity.warehouseId)
          })
        }else{
          // 新增仓库
          this.$axios.post(this.$api.warehouse.addWarehouse, {
            name: this.name
          }).then(res => {
            this.upLoadWarehouse = false;
            this.warehouseVisible = false
            if (res.code == 201) {
              this.$message.error('添加失败')
              return
            }
            this.$message.success('添加成功')
            this.selectList()
            this.name = ''
            this.warehouseChange(this.entity.warehouseId)
          })
        }
      },
      // 添加货架
      confirmShelves(){
        if(!this.value){
      // 添加/修改货架
      confirmShelves() {
        if (!this.shelves.name) {
          this.$message.error('请填写货架名称')
          return
        }
        if (!this.shelves.row) {
          this.$message.error('请填写货架层数')
          return
        }
        if (!this.shelves.col) {
          this.$message.error('请填写货架列数')
          return
        }
        this.upLoadShelves = true;
        if(this.currentEdit&&this.currentEdit.id){
          // 修改
          this.$axios.post(this.$api.warehouse.upShelf, {
            id:this.currentEdit.id,...this.shelves
          }, {
               headers: {
                  'Content-Type': 'application/json'
               }
            }).then(res => {
            this.upLoadShelves = false;
            this.shelvesVisible = false
            // this.keepVisible = false
            if (res.code == 201) {
              this.$message.error('修改失败')
              return
            }
            this.$message.success('修改成功')
            this.selectList()
            this.currentEdit ={};
          })
        }else{
          // 新增
          this.$axios.post(this.$api.warehouse.addShelf, {
            warehouseId: this.entity.warehouseId,...this.shelves
          }, {
               headers: {
                  'Content-Type': 'application/json'
               }
            }).then(res => {
            this.upLoadShelves = false;
            this.shelvesVisible = false
            if (res.code == 201) {
              this.$message.error('添加失败')
              return
            }
            this.$message.success('添加成功')
            this.selectList()
            this.shelves = {}
          })
        }
        this.warehouseChange(this.entity.warehouseId)
      },
      filterNode(value, data) {
            if (!value) return true;
            return data.label.indexOf(value) !== -1;
         },
      handleNodeClick(val, node, el) { //树的值
            this.selectTree = ''
            this.getNodeParent(node)
            this.selectTree = this.selectTree.replace(' - ', '')
            let data = this.selectTree.split(' - ')
            let data2 = ''
            for (let index = data.length - 1; index >= 0; index--) {
               data2 += " - " + data[index]
            }
            this.selectTree = data2.replace(' - ', '')
         },
      getNodeParent(val) {
            if (val.parent != null) {
               this.selectTree += ' - ' + val.label
               this.getNodeParent(val.parent)
            }
         },
      nodeOpen(data, node, el) {
            $($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder-opened')
         },
      nodeClose(data, node, el) {
            $($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder')
         },
      handleDelete(row,level){
        this.$confirm('是否当前数据?', "警告", {
                     confirmButtonText: "确定",
                     cancelButtonText: "取消",
                     type: "warning"
                  }).then(() => {
                     this.$axios.post(this.$api.insOrder.delInsOrderTemplate, {
                        id: row.id
                     }).then(res => {
                        if (res.code === 201) {
                           return
                        }
                        this.$message.success('成功')
                        // this.selectInsOrderTemplate()
                     }).catch(e => {
                        this.$message.error('失败')
                     })
                  }).catch(() => {})
        if (!value) return true;
        return data.label.indexOf(value) !== -1;
      },
      handleEdit(data,level){
      handleNodeClick(val, node, el) { //树的值
        this.selectTree[node.level-1] = val.id;
      },
      nodeOpen(data, node, el) {
        $($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder-opened')
        this.selectTree[node.level-1] = data.id;
      },
      nodeClose(data, node, el) {
        $($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder')
      },
      handleDelete(row, level) {
        this.$confirm('是否当前数据?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          if (level == 1) {
            // 删除仓库
            this.$axios.post(this.$api.warehouse.delWarehouse, {
              id: row.id
            }).then(res => {
              if (res.code === 201) {
                return
              }
              this.$message.success('成功')
              this.selectList()
            }).catch(e => {
              this.$message.error('失败')
            })
          }else{
            // 删除货架
            this.$axios.post(this.$api.warehouse.delShelf, {
              id: row.id
            }).then(res => {
              if (res.code === 201) {
                return
              }
              this.$message.success('成功')
              this.selectList()
            }).catch(e => {
              this.$message.error('失败')
            })
          }
          this.warehouseChange(this.entity.warehouseId)
        }).catch(() => {})
      },
      handleEdit(data, level) {
        this.isEdit = true;
        // 判断是第几层级,第一层级,修改仓库,第二层级修改货架
        if(level==1){
        if (level == 1) {
          this.warehouseVisible = true;
        }else{
          this.currentEdit = data;
          this.name = data.name
        } else {
          this.shelvesVisible = true;
          this.currentEdit = data;
          this.shelves = {
            name:data.name,
            row:data.row,
            col:data.col,
            warehouseId:data.warehouseId
          }
        }
      },
      // 查看详情
      handelDetail(row){
      handelDetail(row) {
        this.currentId = row.id;
        this.isDetail = true;
      },
      warehouseChange(val) {
        this.tableList = []
        let map = this.warehouse.find(a => {
          return a.id === val ? a : null
        })
        this.shelf = map.warehouseShelfList;
        this.entity.shelfId = '';
      },
      handleShelf(e,sampleCode=''){
        if(e){
          this.tableLoading = true;
          this.$axios.get(this.$api.warehouse.getWarehouse+'?shelfId='+e+'&sampleCode='+(sampleCode?sampleCode:'')).then(res => {
            this.tableLoading = false;
            let data = res.data;
            let set =new Set()
            this.tableList = [];
            let arr = []
            data.forEach(m=>{
              set.add(m.col)
              if(arr.length>0){
                if(arr.find(n=>n.row==m.row)){
                  arr.push(m)
                }else{
                  this.tableList.push(arr)
                  arr = []
                  arr.push(m)
                }
              }else{
                arr.push(m)
              }
            })
            this.tableList.push(arr)
            this.rowList = [];
            for(let i=0;i<set.size;i++){
              this.rowList.push(`${i+1} 列`)
            }
          }).catch(e=>{
            this.tableLoading = false;
          })
        }
      },
      handleSearch(){
        if(!this.searchSampleCode){
          this.$message.error('请输入样品编号')
          return;
        }
        this.$axios.post(this.$api.warehouse.searchSampleId, {
          sampleCode: this.searchSampleCode}).then(res => {
            if(res.code==200){
              this.currentId = res.data;
              this.isDetail = true;
            }
          })
      },
      sampleCodeChange(e){
        if(e){
          this.sampleCode = e.replaceAll('"','')
        }
      },
      remove(type){
        this.$refs[type].$el.querySelector('input').removeAttribute('readonly')
      },
      setType(type){
        this.$refs[type].$el.querySelector('input').setAttribute('readonly', 'true')
      }
      }
   }
    }
  }
</script>