<template>
  <div class="testdiv">
    <div class="divborder newSearchDiv">
      <div>
        <div class="filter">
          <label>{{$t('1031')}}：</label>
          <Select
            v-model="ftype"
            label-in-value
            @on-change="ftypechange"
            clearable
            class="searchSelect"
          >
            <Option v-for="item in ftypelist" :value="item.id" :key="item.id">{{ item.title }}</Option>
          </Select>
        </div>
        <div class="filter">
          <label>{{$t('1032')}}：</label>
          <Select v-model="ctype" label-in-value clearable class="searchSelect">
            <Option v-for="item in ctypelist" :value="item.id" :key="item.id">{{ item.title }}</Option>
          </Select>
        </div>
        <div class="filter">
          <label>{{$t('300000')}}：</label>
          <Cascader
            :data="typelevel"
            :value="typeleveldata"
            @on-change="typechange"
            trigger="click"
            change-on-select
            class="searchSelect"
          ></Cascader>
        </div>
        <div class="filter">
            <label>{{$t('300029')}}：</label>
            <Select v-model="Standard_parts" label-in-value clearable class="searchSelect">
              <Option :value="1" v-text="$t('1000020')">是</Option>
              <Option :value="0" v-text="$t('1000021')">否</Option>
            </Select>
          </div>
      </div>
      <!-- 次级搜索条件 隐藏 -->
      <div v-show="!morecondition">

          <div class="filter">
            <label>{{$t('300006')}}：</label>
            <Select v-model="substitution" label-in-value clearable class="searchSelect">
              <Option :value="1" v-text="$t('1000020')">是</Option>
              <Option :value="0" v-text="$t('1000021')">否</Option>
            </Select>
          </div>
          <div class="filter">
            <label>{{$t('900699')}}：</label>
            <Select v-model="Stock" label-in-value clearable class="searchSelect">
              <Option :value="1" v-text="$t('100200')">正常</Option>
              <Option :value="2" v-text="$t('500044')">报警</Option>
              <Option :value="3" v-text="$t('900662')">采购中</Option>
            </Select>
          </div>

          <div class="filter">
            <label>{{$t('300028')}}：</label>
            <Select v-model="charger" label-in-value clearable filterable class="searchSelect">
              <Option v-for="item in chargerlist" :value="item.mid" :key="item.mid">{{ item.name }}</Option>
            </Select>
          </div>
          <div class="filter">
            <label>{{$t('1034')}}：</label>
            <Input
             class="searchInput"
              type="text"
              v-model="keyword"
              :placeholder="$t('200218')"
              @keyup.enter="search()"

            />
          </div>

      </div>
      <!-- 次级搜索条件  结束 -->
      <div class="searchBtn" style>
        <Button type="primary" class="twoWord" icon="ios-search" @click="tosearch()">{{$t('1001')}}</Button>
        <Button type="success" class="twoWord" icon="md-add-circle" @click="add()">{{$t('1002')}}</Button>
        <Button type="warning" class="twoWord" icon="ios-create-outline" @click="edit()">{{$t('1003')}}</Button>
        <Button type="error" class="twoWord" icon="md-close-circle" @click="dele()">{{$t('1004')}}</Button>
        <Button type="primary" class="twoWord" icon="ios-log-in" @click="warehousing()">{{$t('300008')}}</Button>
        <Button type="primary" class="twoWord intervalRight" icon="ios-log-out" @click="out_stock()">{{$t('300009')}}</Button>
        <Button type="primary" class="fourWord" icon="ios-cloud-download" @click="loadexcel1()">{{$t('1005')}}</Button>
        <Button type="primary" class="fourWord" icon="md-arrow-round-down" @click="loadexcel()">{{$t('1007')}}</Button>
        <Upload
          style="display:inline-block"
          ref="upload"
          :action="action"
          name="excel-file"
          :headers="headers"
          :show-upload-list="false"
          :on-format-error="handleFormatError"
          :on-success="handleSuccess"
          :on-error="handleError"
          :format="['xlsx']"
        >
          <Button class="fourWord intervalRight" icon="md-arrow-round-up" type="primary">{{$t('1006')}}</Button>
        </Upload>
        <Button class="fiveWord" type="primary" icon="ios-cash-outline" @click="qrcode()">{{$t('100068')}}</Button>
      </div>
      <!-- 更多条件 按钮 -->
      <MoreConbtn @getCon="morecondition = !morecondition" :morecondition="morecondition"></MoreConbtn>
    </div>

    <div class="divborder newTableDiv">
      <Table
        border
        @on-current-change="handleRowChange"
        @on-selection-change="selecttrchange"
        @on-sort-change="handlesortchange"
         class="tableClass"
        highlight-row
        :data="tableData1"
        :columns="tableColumns1"
      ></Table>
      <div class="pageDiv">
        <div class="pageDirection">
          <Page
            :total="total"
            :current="page"
            @on-change="changePage"
            show-elevator
            show-sizer
            show-total
            @on-page-size-change="handlePageSize"
            :page-size-opts="[10,20,30,40,100]"
          ></Page>
        </div>
      </div>
      <div class="detaildiv" v-show="detailshow">
        <div class="divfloat">
          <img
            :src="detailobj.image"
            alt
            style="width:168px;height:168px;display:block;margin:-1px;"
          />
        </div>
        <div class="divfloat spandiv">
          <div>
            <div v-text="$t('300050')">编号</div>
            <div>{{detailobj.code}}</div>
          </div>
          <div>
            <div v-text="$t('300080')">名称</div>
            <div>{{detailobj.title}}</div>
          </div>
          <div>
            <div v-text="$t('300000')">备件类型</div>
            <div>{{detailobj.typeTitle}}</div>
          </div>
          <div>
            <div v-text="$t('300062')">规格型号</div>
            <div>{{detailobj.param}}</div>
          </div>
          <div>
            <div v-text="$t('600062')">品牌</div>
            <div>{{detailobj.brand}}</div>
          </div>
          <div>
            <div v-text="$t('300006')">是否需要置换</div>
            <div>{{detailobj.is_substitute===1?$t("1000020"):$t("1000021")}}</div>
          </div>
        </div>
        <div class="divfloat spandiv">
          <div>
            <div v-text="$t('300019')">单价</div>
            <div>{{detailobj.price}}</div>
          </div>
          <div>
            <div v-text="$t('300035')">标准件/非标件</div>
            <div>{{detailobj.is_standard==1?$t("9600000"):$t("9600001")}}</div>
          </div>
          <div>
            <div v-text="$t('300016')">当前库存</div>
            <div>{{detailobj.sku}}</div>
          </div>
          <div>
            <div v-text="$t('400046')">最高库存</div>
            <div>{{detailobj.max_sku}}</div>
          </div>
          <div v-text="$t('600556')" class="fontclass">备件属性</div>
          <div>{{this.$t(detailobj.machinetitle)}}</div>
        </div>
        <div class="divfloat spandiv">
          <div>
            <div v-text="$t('100044')">描述</div>
            <div>{{detailobj.description}}</div>
          </div>
          <div>
            <div v-text="$t('300020')">材质</div>
            <div>{{detailobj.material}}</div>
          </div>
          <div>
            <div v-text="$t('1030')">备注</div>
            <div>{{detailobj.remark}}</div>
          </div>
          <div>
            <div v-text="$t('800253')">库存位置</div>
            <div>{{detailobj.warehouse}}</div>
          </div>
          <div>
            <div v-text="$t('300023')">最低库存</div>
            <div>{{detailobj.mini_sku}}</div>
          </div>
          <div>
            <div v-text="$t('600011')">供应商</div>
            <div>{{detailobj.supplier}}</div>
          </div>
        </div>
        <div class="divfloat spandiv">
          <div>
            <div v-text="$t('300034')">计量单位</div>
            <div>{{detailobj.unit}}</div>
          </div>
          <div>
            <div v-text="$t('900661')">货期</div>
            <div>{{detailobj.delivery_time}}</div>
          </div>
          <div>
            <div v-text="$t('900699')">库存状态</div>
            <div
              :style="detailobj.stock_status===2?'color:red':''"
            >{{detailobj.stock_status===1?$t('100200'):(detailobj.stock_status===2?$t('300007'):$t('900662'))}}</div>
          </div>
          <div>
            <div v-text="$t('900665')">当月收入</div>
            <div>{{detailobj.thisMonth_in}}</div>
          </div>
          <div>
            <div v-text="$t('900666')">上月领用</div>
            <div>{{detailobj.lastMonth_out}}</div>
          </div>
          <div>
            <div v-text="$t('900667')">当月领用</div>
            <div>{{detailobj.thisMonth_out}}</div>
          </div>
        </div>
      </div>
      <!-- 细节数据结束 -->
      <!-- echarts开始 -->
      <div v-show="detailshow">
        <div id="detailecharts" style="width:95%;height:400px;margin-left:2.5%;"></div>
      </div>
      <!-- echarts结束 -->

      <Modal
        class="newModalClass"
        :title="$t('1002')"
        v-model="addmodal"
        :styles="(addobj.subsu===1 || addobj.subsu===2)?{width: '1050px'}:{width: '800px'}"
      >
        <div class="modal_body">
          <div style="padding-top:10px;">
            <div id="addmodeltree" style="width:200px;display:inline-block;height:524px;">
              <Tree
                :data="treedata"
                @on-select-change="gettreeNodes"
                ref="tree"
                style="border:1px solid #eee;height:80%;border-radius:4px;overflow-y:scroll"
              ></Tree>
            </div>
            <div
              v-show="addobj.subsu===1 || addobj.subsu===2"
              id="addmodeltree2"
              style="width:200px;display:inline-block;height:524px;"
            >
              <Tree
                :data="treedata2"
                @on-select-change="gettreeNodes2"
                ref="tree2"
                style="border:1px solid #eee;height:80%;border-radius:4px;overflow-y:scroll"
              ></Tree>
            </div>
            <div
              style="width:560px;display:inline-block;height:580px;vertical-align:top;padding-left:10px;"
            >
              <Row>
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('300001')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.code" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('300002')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.title" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('100044')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.description" />
                  </div>
                </Col>
              </Row>
              <Row>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('300010')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.param" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('300019')}}：</label>
                    <Input class="searchInput" type="number" min="0" v-model="addobj.price" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('300020')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.material" />
                  </div>
                </Col>
              </Row>
              <Row>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('300027')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.brand" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('400046')}}：</label>
                    <Input class="searchInput" type="number" min="0" v-model="addobj.max_sku" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('300023')}}：</label>
                    <Input class="searchInput" type="number" min="0" v-model="addobj.mini_sku" />
                  </div>
                </Col>
              </Row>
              <Row>
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('300016')}}：</label>
                    <Input class="searchInput" type="number" min="0" v-model="addobj.sku" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('800253')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.warehouse" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('300028')}}：</label>
                    <Select
                      v-model="addobj.sku_report_mid"
                      filterable
                      remote
                      :remote-method="initmidlist"
                      class="searchSelect"
                    >
                      <Option
                        v-for="(item,index) in midlist"
                        :value="item.mid"
                        :key="index"
                      >{{ item.name }}</Option>
                    </Select>
                  </div>
                </Col>
              </Row>
              <Row>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('600011')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.supplier" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('300034')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.unit" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('900661')}}：</label>
                    <Input
                      class="searchInput"
                      type="number"
                      min="0"
                      v-model="addobj.delivery_time"
                    />
                    <span v-text="$t('950157')">天</span>
                  </div>
                </Col>
              </Row>
              <Row>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('800041')}}：</label>
                    <Input class="searchInput" type="text" v-model="addobj.remark" />
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('950439')}}：</label>
                    <Input
                      class="searchInput"
                      type="number"
                      min="0"
                      v-model="addobj.repair_upperlimit"
                    />
                    <span v-text="$t('200163')">次</span>
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label>{{$t('5000018')}}：</label>
                    <Input
                      class="searchInput"
                      type="number"
                      min="0"
                      v-model="addobj.sku_limit"
                    />
                  </div>
                </Col>
              </Row>
              <Row style="margin:10px 0px">
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('300014')}}：</label>
                    <RadioGroup v-model="addobj.is_substitute" style="margin-left:3px;">
                      <Radio label="1">
                        <span v-text="$t('1000020')">是</span>
                      </Radio>
                      <Radio label="0">
                        <span v-text="$t('1000021')">否</span>
                      </Radio>
                    </RadioGroup>
                  </div>
                </Col>
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('300029')}}：</label>
                    <RadioGroup v-model="addobj.is_standard" style="margin-left:3px;">
                      <Radio label="1">
                        <span v-text="$t('1000020')">是</span>
                      </Radio>
                      <Radio label="0">
                        <span v-text="$t('1000021')">否</span>
                      </Radio>
                    </RadioGroup>
                  </div>
                </Col>
              </Row>
              <Row style="margin:10px 0px">
                <Col span="8">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('950464')}}：</label>
                    <RadioGroup v-model="addobj.use_audit" style="margin-left:3px;">
                      <Radio label="1">
                        <span v-text="$t('1000020')">是</span>
                      </Radio>
                      <Radio label="0">
                        <span v-text="$t('1000021')">否</span>
                      </Radio>
                    </RadioGroup>
                  </div>
                </Col>
                <Col span="16" v-show="addobj.use_audit==='1'">
                  <div class="filter addfilter">
                    <label><i>*</i>{{$t('950465')}}：</label>
                    <Select
                      v-model="addobj.approvaluser"
                      filterable
                      clearable
                      remote
                      :remote-method="initmidlist"
                      class="searchSelect"
                    >
                      <Option
                        v-for="item in approvalusers"
                        :value="item.mid"
                        :key="item.mid"
                      >{{ item.name }}({{item.work_code}})</Option>
                    </Select>
                  </div>
                </Col>
              </Row>
              <div class="filter addfilter">
                <div style="display: flex;">
                  <label>{{$t(600528)}}：</label>
                  <div class="uploadMax">
                    <img :src="addobj.image" alt />
                    <input
                      type="file"
                      name
                      ref="fileIntimg"
                      id
                      @change="unloadimg"
                      accept="image/png, image/gif, image/jpeg"
                    />
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div slot="footer">
          <Button type="text" size="large" @click="addmodal=false" v-text="$t('1033')">取消</Button>
          <Button type="primary" size="large" @click="adddata" v-text="$t('1011')">确定</Button>
        </div>
      </Modal>
      <!-- 添加模态框结束 -->
      <!-- 修改模态框开始 -->
      <Modal class="newModalClass" :title="$t('1003')" v-model="editmodal" :styles="{width:'840px'}">
        <div class="modal_body">
          <div>
            <div class="filter">
              <label><i>*</i>{{$t('300001')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.code" />
            </div>
            <div class="filter">
              <label><i>*</i>{{$t('300002')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.title" />
            </div>
            <div class="filter">
              <label>{{$t('100044')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.description" />
            </div>
          </div>
          <div>
            <div class="filter">
              <label>{{$t('300010')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.param" />
            </div>
            <div class="filter">
              <label>{{$t('300019')}}：</label>
              <Input class="searchInput" type="number" min="0" v-model="editobj.price" />
            </div>
            <div class="filter">
              <label>{{$t('300020')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.material" />
            </div>
          </div>
          <div>
            <div class="filter">
              <label>{{$t('1202')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.brand" />
            </div>
            <div class="filter">
              <label>{{$t('600011')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.supplier" />
            </div>
            <div class="filter">
              <label>{{$t('300034')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.unit" />
            </div>
          </div>
          <div>
            <div class="filter">
              <label>{{$t('800041')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.remark" />
            </div>
            <div class="filter">
              <label><i>*</i>{{$t('300000')}}：</label>
              <!-- <input class="publicinput" type="text" disabled  v-model="editobj.typeTitle"> -->
              <Select v-model="editobj.spareparttype" label-in-value clearable class="searchSelect">
                <Option v-for="item in typelist" :value="item.id" :key="item.id">{{ item.title }}</Option>
              </Select>
            </div>
            <div class="filter">
              <label>{{$t('9700002')}}：</label>
              <Input
                class="searchInput"
                type="number"
                v-model="editobj.delivery_time"
              />
              <span v-text="$t('950157')">天</span>
            </div>
          </div>
          <div>
            <div class="filter">
              <label><i>*</i>{{$t('300014')}}：
              </label>
              <RadioGroup v-model="editobj.is_substitute">
                <Radio :label="1" class="rad">
                  <span v-text="$t('1000020')">是</span>
                </Radio>
                <Radio :label="0" class="rad">
                  <span v-text="$t('1000021')">否</span>
                </Radio>
              </RadioGroup>
            </div>
            <div class="filter">
              <label for>
                <i>*</i>{{$t('300029')}}：
              </label>
              <RadioGroup v-model="editobj.is_standard">
                <Radio :label="1" class="rad">
                  <span v-text="$t('1000020')">是</span>
                </Radio>
                <Radio :label="0" class="rad">
                  <span v-text="$t('1000021')">否</span>
                </Radio>
              </RadioGroup>
            </div>
          </div>
          <div>
            <div class="filter">
              <label><i>*</i>{{$t('950464')}}：
              </label>
              <RadioGroup
                v-model="editobj.use_audit"
                @on-change="auditchange"
              >
                <Radio label="1" class="rad">
                  <span v-text="$t('1000020')"></span>
                </Radio>
                <Radio label="0" class="rad">
                  <span v-text="$t('1000021')"></span>
                </Radio>
              </RadioGroup>
            </div>
            <div class="filter" v-if="approvalusershow">
              <label ><i>*</i>{{$t('950465')}}：
              </label>
              <Select
                v-model="editobj.approvaluser"
                filterable
                clearabindexle
                remote
                :remote-method="initmidlist"
                class="searchSelect"
              >
                <Option
                  v-for="(item,index) in approvalusers"
                  :value="item.mid"
                  :key="index"
                >{{ item.name }}({{item.work_code}})</Option>
              </Select>
            </div>
          </div>
          <div>
            <div style="width:500px;display:inline-block">
              <div>
                <div class="filter">
                  <label><i>*</i>{{$t('400046')}}：</label>
                  <Input class="searchInput" type="number" min="0" v-model="editobj.max_sku" />
                </div>
                <div class="filter">
                  <label><i>*</i>{{$t('300023')}}：</label>
                  <Input class="searchInput" type="number" min="0" v-model="editobj.mini_sku" />
                </div>
              </div>
              <div>
                <div class="filter">
                  <label><i>*</i>{{$t('300016')}}：</label>
                  <Input class="searchInput" type="number" min="0" v-model="editobj.sku" />
                </div>
                <div class="filter">
                  <label><i>*</i>{{$t('800253')}}：</label>
                  <Input class="searchInput" type="text" v-model="editobj.warehouse" />
                </div>
              </div>
              <div>
                <div class="filter">
                  <label><i>*</i>{{$t('300028')}}：</label>
                  <Select
                    v-model="editobj.sku_report_mid"
                    filterable
                    remote
                    :remote-method="initmidlist"
                    class="searchSelect"
                  >
                    <Option
                      v-for="(item,index) in midlist"
                      :value="item.mid"
                      :key="index"
                    >{{ item.name }}({{item.work_code}})</Option>
                  </Select>
                </div>
                <div class="filter">
                  <label>{{$t('950439')}}：</label>
                  <Input
                    class="searchInput"
                    type="number"
                    min="0"
                    v-model="editobj.repair_upperlimit"
                  />
                  <span v-text="$t('200163')">次</span>
                </div>
              </div>
              <div>
                <div class="filter">
                  <label>{{$t('5000018')}}：</label>
                  <Input class="searchInput" type="number" min="0" v-model="editobj.sku_limit" />
                </div>
              </div>
            </div>
            <div style="display:inline-block;vertical-align: top;">
              <div style="display: flex;">
                <label>{{$t(1045)}}：</label>
                <div class="uploadMax">
                  <img :src="editobj.image" alt />
                  <input
                    type="file"
                    name
                    ref="editfileIntimg"
                    id
                    @change="editunloadimg"
                    accept="image/png, image/gif, image/jpeg"
                  />
                </div>
              </div>
            </div>
          </div>
        </div>
        <div slot="footer">
          <Button type="text" size="large" @click="editmodal=false" v-text="$t('1033')">取消</Button>
          <Button type="primary" size="large" @click="editdata" v-text="$t('1011')">确定</Button>
        </div>
      </Modal>
      <!-- 入库模态框开始 -->
      <Modal class="newModalClass" :title="$t('900503')" v-model="warehousingmodel" :styles="{width:'730px'}">
        <div class="modal_body">
          <div
            style="width:190px;display:inline-block;height:280px;vertical-align:top;margin-left:40px;border:1px solid #eee;border-radius:5px;margin-right:10px;"
          >
            <img
              :src="warehousingdetailobj.image"
              alt
              style="width:190px;height:280px;display:block;"
            />
          </div>
          <div
            style="width:410px;display:inline-block;height:280px;vertical-align:top;"
          >
            <Row>
              <Col span="5" v-text="$t('300001')" class="fontclass">备件编号</Col>
              <Col span="19">{{warehousingdetailobj.code}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300002')" class="fontclass">备件名称</Col>
              <Col span="19">:{{warehousingdetailobj.title}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300000')" class="fontclass">备件类型</Col>
              <Col span="19">{{warehousingdetailobj.typeTitle}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300010')" class="fontclass">规格型号</Col>
              <Col span="19">{{warehousingdetailobj.param}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('9700003')" class="fontclass">生产厂牌</Col>
              <Col span="19"> {{warehousingdetailobj.brand}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300014')" class="fontclass">是否需要置换</Col>
              <Col span="19">{{warehousingdetailobj.is_common==1?$t('1000020'):$t('1000021')}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300034')" class="fontclass">计量单位</Col>
              <Col span="19">{{warehousingdetailobj.unit}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300019')" class="fontclass">单价</Col>
              <Col span="19">{{warehousingdetailobj.price}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300035')" class="fontclass">标准件/非标件</Col>
              <Col span="19">{{warehousingdetailobj.is_common==1?$t('300005'):$t('1000021')}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('800253')" class="fontclass">库存位置</Col>
              <Col span="19">{{warehousingdetailobj.warehouse}}</Col>
            </Row>
          </div>

          <div style="margin-top:10px;max-height:200px;overflow-y:auto;">
            <div v-for="(item ,key) in warehousinglist" :key="key" v-if="item">
              <div class="filter">
                <label>{{$t('950454')}}：</label>
                <Input class="searchInput" type="text" v-model="item.code" />
              </div>
              <div class="filter">
                <label>{{$t('1950468')}}：</label>
                <Input
                  class="searchInput"
                  type="number"
                  min="0"
                  v-model="item.repair_count"
                  style="width:100px"
                />
              </div>
              <Button icon="md-add" type="default" @click="addwarehousinglist()"></Button>
              <Button
                icon="ios-remove"
                type="default"
                @click="removewarehousinglist(key)"
                style="margin-left:10px;"
              ></Button>
            </div>
          </div>
        </div>
        <div slot="footer">
          <Button type="text" size="large" @click="warehousingmodel=false" v-text="$t('1033')">取消</Button>
          <Button type="primary" size="large" @click="warehousingdata" v-text="$t('1011')">确定</Button>
        </div>
      </Modal>
      <!-- 入库模态框开始 -->
      <Modal
         class="newModalClass"
        :title="$t('900503')"
        v-model="warehousingmodel2"
        :styles="{width:'730px'}"
      >
        <div class="modal_body">
          <div
            style="width:190px;display:inline-block;height:280px;vertical-align:top;border:1px solid #eee;border-radius:5px;margin-right:10px;"
          >
            <img src alt style="width:190px;height:280px;display:block;" />
          </div>
          <div
            style="width:410px;display:inline-block;height:280px;vertical-align:top;"
          >
            <Row>
              <Col span="5" v-text="$t('300001')" class="fontclass">备件编号</Col>
              <Col span="19">{{warehousingdetailobj.code}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300002')" class="fontclass">备件名称</Col>
              <Col span="19">{{warehousingdetailobj.title}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300000')" class="fontclass">备件类型</Col>
              <Col span="19">{{warehousingdetailobj.typeTitle}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300010')" class="fontclass">规格型号</Col>
              <Col span="19">{{warehousingdetailobj.param}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('9700003')" class="fontclass">生产厂牌</Col>
              <Col span="19">{{warehousingdetailobj.brand}}</Col>

            </Row>
            <Row>
              <Col span="5" v-text="$t('300014')" class="fontclass">是否需要置换</Col>
              <Col span="19">{{warehousingdetailobj.is_substitute==1?$t('1000020'):$t('1000021')}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300034')" class="fontclass">计量单位</Col>
              <Col span="19">{{warehousingdetailobj.unit}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300019')" class="fontclass">单价</Col>
              <Col span="19">{{warehousingdetailobj.price}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300035')" class="fontclass">标准件/非标件</Col>
              <Col span="19">{{warehousingdetailobj.is_common==1?$t('300005'):$t('1000021')}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('800253')" class="fontclass">库存位置</Col>
              <Col span="19">{{warehousingdetailobj.warehouse}}</Col>
            </Row>
          </div>
          <div>
            <div style="margin-top:10px;">
              <div class="filter">
                <label><i>*</i>{{$t('300036')}}：</label>
                <RadioGroup v-model="in_stockobj.IO_type">
                  <Radio label="1" border style="width:100px!important;">
                    <span>采购入库</span>
                  </Radio>
                  <Radio label="3" style="width:100px!important;">
                    <span>领用退回入库</span>
                  </Radio>
                  <Radio label="7" style="width:100px!important;">
                    <span>返修入库</span>
                  </Radio>
                  <Radio label="5" style="width:100px!important;">
                    <span>借出还入</span>
                  </Radio>
                  <Radio label="6" style="width:100px!important;">
                    <span>对账入库</span>
                  </Radio>
                </RadioGroup>
              </div>
            </div>
            <div>
              <div class="filter">
                <label><i>*</i>{{$t('300084')}}：</label>
                <Input class="searchInput" type="number" min="0" v-model="in_stockobj.count" />
              </div>
            </div>
          </div>
        </div>
        <div slot="footer">
          <Button type="text" size="large" @click="warehousingmodel2=false">取消</Button>
          <Button type="primary" size="large" @click="warehousingdata2">确定</Button>
        </div>
      </Modal>
      <!-- 入库模态框结束 -->
      <!-- 出库模态框开始 -->
      <Modal class="newModalClass" :title="$t('300041')" v-model="out_stockmodel" :styles="{width:'700px'}">
        <div class="modal_body">
          <div style="width:190px;display:inline-block;height:280px;vertical-align:top;">
            <img
              :src="out_stockdetailobj.image"
              alt
              style="width:190px;height:280px;display:block;border:1px solid #eee;border-radius:5px;margin-right:10px;"
            />
          </div>
          <div
            style="width:410px;display:inline-block;height:280px;vertical-align:top;margin-left:10px;"
          >
            <Row>
              <Col span="5" v-text="$t('300001')" class="fontclass">备件编号</Col>
              <Col span="19">{{out_stockdetailobj.code}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300002')" class="fontclass">备件名称</Col>
              <Col span="19">{{out_stockdetailobj.title}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300000')" class="fontclass">备件类型</Col>
              <Col span="19">{{out_stockdetailobj.typeTitle}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300010')" class="fontclass">规格型号</Col>
              <Col span="19">{{out_stockdetailobj.param}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('9700003')" class="fontclass">生产厂牌</Col>
              <Col span="19">{{out_stockdetailobj.brand}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300014')" class="fontclass">是否需要置换</Col>
              <Col span="19">{{out_stockdetailobj.is_substitute==1?$t('1000020'):$t('1000021')}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300034')" class="fontclass">计量单位</Col>
              <Col span="19">{{out_stockdetailobj.unit}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300019')" class="fontclass">单价</Col>
              <Col span="19">{{out_stockdetailobj.price}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300035')" class="fontclass">标准件/非标件</Col>
              <Col span="19">{{out_stockdetailobj.is_common==1?$t('300005'):$t('1000021')}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('800253')" class="fontclass">库存位置</Col>
              <Col span="19">{{out_stockdetailobj.warehouse}}</Col>
            </Row>
          </div>

          <div style="margin-top:10px;">
            <div style="display:inline-block;width:150px;vertical-align:top; text-align:center">
              <span>{{$t('300043')}}：</span>
            </div>
            <div style="display:inline-block;width:420px;">
              <RadioGroup v-model="out_stockobj.IO_type">
                <Radio :label="3" border style="width:150px!important;">
                  <span v-text="$t('900686')">应急维修领用出库</span>
                </Radio>
                <Radio :label="1" style="width:100px!important;">
                  <span v-text="$t('900688')">采购提货出库</span>
                </Radio>
                <Radio :label="2" style="width:100px!important;">
                  <span v-text="$t('900687')">销售提货出库</span>
                </Radio>
                <Radio :label="4" v-show="isShowOption" style="width:100px!important;">
                  <span v-text="$t('900685')">借贷出库</span>
                </Radio>
                <Radio :label="5" v-show="isShowOption" style="width:100px!important;">
                  <span v-text="$t('900684')">借入还出</span>
                </Radio>
                <Radio :label="6" v-show="isShowOption" style="width:100px!important;">
                  <span v-text="$t('900683')">对账出库</span>
                </Radio>
                <Radio :label="7" style="width:150px!important;">
                  <span v-text="$t('900682')">计划维护领用出库</span>
                </Radio>
              </RadioGroup>
            </div>
          </div>
          <div style="margin-top:10px;">
            <div class="filter">
              <label>{{$t('300045')}}：</label>
              <Input class="searchInput" type="number" :min="0" v-model="out_stockobj.number" />
            </div>
            <div class="filter">
              <label ><i>*</i>{{$t('300044')}}：</label>
              <Select
                class="searchSelect"
                v-model="out_stockobj.operate_mid"
                filterable
                remote
                :remote-method="remoteMethod2"
                :loading="loading2"
              >
                <Option
                  v-for="(option, index) in out_stockpeoplelist"
                  :value="option.mid"
                  :key="index"
                >{{option.name+':'+option.work_code}}</Option>
              </Select>
            </div>
          </div>
          <div>
            <div class="filter">
              <label >{{$t('300046')}}：</label>
              <Select
                v-model="out_stockobj.is_exchange"
                label-in-value
                clearable
                class="searchSelect"
              >
                <Option :value="1" v-text="$t('1000020')">是</Option>
                <Option :value="0" v-text="$t('1000021')">否</Option>
              </Select>
            </div>
            <div class="filter">
              <label >{{$t('800041')}}：</label>
              <Input class="searchInput" type="text" v-model="out_stockobj.remark" />
            </div>
          </div>
        </div>
        <div slot="footer">
          <Button type="text" size="large" @click="out_stockmodel=false" v-text="$t('1033')">取消</Button>
          <Button type="primary" size="large" @click="out_stockdata" v-text="$t('1011')">确定</Button>
        </div>
      </Modal>
      <!-- 出库模态框结束 -->
      <!-- 打印二维码模态框开始 -->
      <Modal class="newModalClass" :title="$t('100068')" v-model="qrcodemodel" :styles="{width:'710px'}">
        <div class="modal_body">
          <div
            style="width:190px;display:inline-block;height:280px;vertical-align:top;margin-left:20px;border:1px solid #eee;border-radius:5px;margin-right:10px;"
          >
            <img :src="qrcodeobj.image" alt style="width:190px;height:280px;display:block;" />
          </div>
          <div
            style="width:410px;display:inline-block;height:280px;vertical-align:top;"
          >
            <Row>
              <Col span="5" v-text="$t('300001')" class="fontclass">备件编号</Col>
              <Col span="19">{{qrcodeobj.code}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300002')" class="fontclass">备件名称</Col>
              <Col span="19">{{qrcodeobj.title}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300000')" class="fontclass">备件类型</Col>
              <Col span="19">{{qrcodeobj.typeTitle}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300010')" class="fontclass">规格型号</Col>
              <Col span="19">{{qrcodeobj.param}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('9700003')" class="fontclass">生产厂牌</Col>
              <Col span="19">{{qrcodeobj.brand}}</Col>
            </Row>
            <Row>
               <Col span="5" v-text="$t('300014')" class="fontclass">是否需要置换</Col>
              <Col span="19">{{qrcodeobj.is_common==1?$t('1000020'):$t('1000021')}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300034')" class="fontclass">计量单位</Col>
              <Col span="19">{{qrcodeobj.unit}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300019')" class="fontclass">单价</Col>
              <Col span="19">{{qrcodeobj.price}}</Col>
            </Row>
            <Row>
              <Col span="5" v-text="$t('300035')" class="fontclass">标准件/非标件</Col>
              <Col span="19">{{qrcodeobj.is_common==1?$t('300005'):$t('1000021')}}</Col>
            </Row>
              <Col span="5" v-text="$t('800253')" class="fontclass">库存位置</Col>
              <Col span="19">{{qrcodeobj.warehouse}}</Col>
            <Row>
            </Row>
          </div>
          <div style="margin-top:10px;max-height:200px;overflow-y:auto;">
            <div v-for="(item,key) in qrcodeobj.spareparts" :key="key">
              <div class="filter">
                <label>{{$t('950454')}}：</label>
                <Input
                  class="searchInput MaxWidth"
                  type="text"
                  disabled
                  v-model="item.code"
                />
              </div>
              <!-- <Button  icon="md-add" type="default" ></Button> -->
              <Button
                type="primary"
                style="margin-left:10px;"
                @mouseover.native="handleBatchPrintCode(item)"
                v-print="'printStyle'"
                v-text="$t('100077')"
              >打印</Button>
            </div>
            <div style="display:none">
              <div ref="print" id="printStyle" title="二维码">
                <div class="item">
                  <div class="qrcode-pic" ref="codeItem" id="codeItem"></div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div slot="footer">
          <Button type="primary" size="large" @click="qrcodemodel=false" v-text="$t('1011')">确定</Button>
        </div>
      </Modal>
    </div>
  </div>
</template>
<script>
import echarts from 'echarts';
import { thistle } from 'color-name';
import QRCode from 'qrcodejs2';
export default {
    data () {
        return {
            isShowOption: false, // 展示部分出库项目
            headers: {
                // 上传请求头添加
                token: localStorage.getItem('token'),
                timestamp: localStorage.getItem('timestamp'),
                nonce: localStorage.getItem('nonce'),
                sign: localStorage.getItem('sign')
            },
            datalevel: [], // 产线层级数据
            leveldata: [], // 产线层级value
            ftype: '', // 父级设备类型
            ftypelist: [], // 父级设备类型数据
            ctype: '', // 子级设备类型
            ctypelist: [], // 子级设备类型数据
            typelevel: [], // 备件类型数据
            typeleveldata: [], // 备件类型value
            morecondition: false, // 次级搜索条件
            Standard_parts: '', // 标准件
            substitution: '', // 置换
            Stock: '', // 库存
            charger: '',
            chargerlist: [],
            keyword: '', // 关键词
            treenode1: [], // 第一棵树的节点
            treenode2: [], // 第二棵树的节点
            addobj: {
                is_substitute: '1',
                is_standard: '1',
                purchase_status: '1',
                image: '',
                use_audit: '1',
                is_common: '1'
            }, // 添加数据
            approvalusers: [],
            approvaluser: '',
            approvalusershow: false,
            editobj: {}, // 修改模态框对象
            typelist: [],
            detailshow: false, // 细节默认隐藏
            action:
        this.axios.publicPath + 'tpm/Upload/Submit?templateName=SparepartList', // 上传excel
            tableData1: [], // 表格数据
            obj: {}, // 点击之后将某一行的数据赋值给这个对象
            total: 0, // 数据总条数
            page: 1, // 页码
            pagesize: 10, // 页码条数
            detailobj: {}, // 细节对象
            addmodal: false, // 添加模态框
            midlist: [], // 负责人list
            editmodal: false, // 修改模态框
            //    image:'',
            delelistobj: [], // 删除的所有对象
            warehousingmodel: false, // 入库模态框
            warehousingmodel2: false,
            in_stockobj: {},
            warehousingdetailobj: {}, // 入库细节对象
            warehousingobj: {}, // 入库对象
            warehousinglist: [
                {
                    code: '',
                    repair_count: ''
                }
            ], // 入库数组
            loading1: false, // 入库人查询等待
            warehousingpeoplelist: [], // 入库人list
            out_stockmodel: false, // 出库模态框
            out_stockdetailobj: {}, // 出库细节对象
            out_stockobj: {}, // 出库对象
            loading2: false, // 出库人查询等待
            out_stockpeoplelist: [], // 领用人list
            qrcodemodel: false, // 二维码模态框
            qrcodeobj: {}, // 打印二维码模态框对象
            sortkey: '', // 排序
            sortorder: '', // 排序
            treedata: [
                {
                    title: this.$t('300000'), // 备件类型
                    expand: true,
                    id: 0,
                    children: []
                }
            ], // 树初始化数据
            treedata2: [
                // 设备/产线层级'
                {
                    name: this.$t('900779'), // 设备/产线层级
                    title: this.$t('900779'), // 设备/产线层级
                    open: true,
                    expand: true,
                    id: 0,
                    children: []
                }
            ],
            tableColumns1: [
                // 表头数据
                {
                    type: 'selection',
                    width: 60,
                    align: 'center',
                    fixed: 'left'
                },
                {
                    type: 'index2',
                    title: this.$t('1008'), // 序号
                    width: 70,
                    align: 'center',
                    render: (h, params) => {
                        return h(
                            'span',
                            params.index + (this.page - 1) * this.pagesize + 1
                        );
                    },
                    fixed: 'left'
                },
                {
                    title: this.$t('300050'), // 编号
                    key: 'code',
                    width: '150',
                    fixed: 'left',
                    align: 'center',
                    sortable: 'custom'
                },
                {
                    title: this.$t('300080'), // 名称
                    key: 'title',
                    width: '150',
                    align: 'center'
                },
                {
                    title: this.$t('300000'), // 备件类型
                    key: 'typeTitle',
                    width: '150',
                    align: 'center'
                },
                {
                    title: this.$t('1045'), // 图片
                    key: 'pic',
                    width: '90',
                    align: 'center',
                    render: (h, params) => {
                        return h(
                            'Poptip',
                            {
                                props: {
                                    trigger: 'hover',
                                    title: this.$t('1045'), // 图片
                                    placement: 'bottom',
                                    transfer: true,
                                    left: '30%'
                                }
                            },
                            [
                                h('Tag', this.$t('1045')),
                                h(
                                    'div',
                                    {
                                        slot: 'content'
                                    },
                                    [
                                        h('img', {
                                            attrs: {
                                                src: params.row.image,
                                                style:
                          'border-radius: 2px;z-index:9999;width:500px;height:500px;'
                                            }
                                        })
                                    ]
                                )
                            ]
                        );
                    }
                },
                {
                    title: this.$t('300062'), // 型号类型/图纸号
                    key: 'param',
                    width: '150',
                    align: 'center'
                },
                {
                    title: this.$t('1202'), // 厂商/品牌
                    key: 'brand',
                    width: '150',
                    align: 'center'
                },
                {
                    title: this.$t('300006'), // 置换
                    key: 'is_substitute1',
                    width: '120',
                    align: 'center'
                },
                {
                    title: this.$t('900665'), // 当月收入
                    key: 'thisMonth_in',
                    width: '100',
                    align: 'center'
                },
                {
                    title: this.$t('900666'), // 上月领用
                    key: 'lastMonth_out',
                    width: '100',
                    align: 'center'
                },
                {
                    title: this.$t('900667'), // 当月领用
                    key: 'thisMonth_out',
                    width: '90',
                    align: 'center'
                },
                {
                    title: this.$t('900668'), // 领用异常报警
                    key: 'out_status',
                    width: '120',
                    align: 'center',
                    render: (h, params) => {
                        let tmpStr = '';
                        if (params.row.out_status === 1) {
                            tmpStr = this.$t('300007'); // 库存报警
                        } else {
                            tmpStr = this.$t('100200'); // 正常
                        }
                        return h(
                            'span',
                            {
                                style: {
                                    color: params.row.out_status === 1 ? '#ff0000' : '#515a6e'
                                }
                            },
                            tmpStr
                        );
                    }
                },
                {
                    title: this.$t('300016'), // 当前库存
                    key: 'sku',
                    width: '100',
                    fixed: 'right',
                    align: 'center'
                },
                {
                    title: this.$t('1590031'), // 货值
                    key: 'totalvalue',
                    width: '100',
                    fixed: 'right',
                    align: 'center'
                },
                {
                    title: this.$t('300003'), // 库位
                    key: 'warehouse',
                    width: '150',
                    fixed: 'right',
                    align: 'center',
                    sortable: 'custom'
                },
                {
                    title: this.$t('200054'), // 状态
                    width: '120',
                    key: 'status',
                    fixed: 'right',
                    align: 'center',
                    render: (h, params) => {
                        let tmpStr = '';
                        if (params.row.status === 2) {
                            tmpStr = this.$t('300007'); // 库存报警
                        } else if (params.row.status === 3) {
                            tmpStr = this.$t('900662'); // 采购中
                        } else {
                            tmpStr = this.$t('100200'); // 正常
                        }
                        return h(
                            'span',
                            {
                                style: {
                                    color:
                    params.row.status == 2
                        ? '#ff0000'
                        : params.row.status == 1
                            ? '#515a6e'
                            : '#515a6e'
                                }
                            },
                            tmpStr
                        );
                    }
                }
            ]
        };
    },
    created () {
    // this.initlevel()
        this.initftype();
        this.inittype(); // 初始化备件类型
        //  this.inittree2()//初始化产线树
        this.remoteMethod2(); // 初始化领用人
        this.remoteMethod1(); // 初始化领用人
        this.initmidlist('');
        this.inichargerlist();
        this.tosearch();
        // 格式化表格样式
        this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1)
    },
    watch: {
    // 'addobj.approvaluser':{
    //   handler(newName, oldName){
    //     console.log(newName, oldName)
    //      if(!newName){
    //        this.initmidlist("")
    //      }
    //   },
    //   deep: true,
    //   immediate: true
    // }
    },
    methods: {
        handleFormatError (file) {
            this.$Message.error(this.$t('950396') + file.name + this.$t('950397'))
        },
        handleSuccess (res, file) {
            // 导入成功函数
            if (res.ret === 1) {
                this.$Message.success(this.$t('950398'));
                this.tosearch();
            } else {
                if ((res.msg + '').indexOf(',') != -1) {
                    inittip(res.msg);
                } else {
                    this.$Message.error(this.$t(res.msg));
                }
            }
        },
        handleError () {
            // 导入失败函数
            this.$Message.error(this.$t('950399'));
        },
        // 初始化产线层级
        initlevel () {
            this.axios
                .request({
                    url: 'config/ProjectLevelSection/GetSectionTree',
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        const arr = [];
                        this.datalevel = res.data.data;
                        arr.push(res.data.data[0].value);
                        this.leveldata = arr;
                        this.tosearch();
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        levelchange (value) {
            this.leveldata = value;
        },
        initftype () {
            this.axios
                .request({
                    url: '/config/MachineType/GetEditDcategory',
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.ftypelist = res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        ftypechange () {
            if (this.ftype == undefined) {
                this.ctype = '';
                return false;
            }
            this.ctype = '';
            this.fault_type = '';
            this.failure_mode = '';
            this.axios
                .request({
                    url: '/config/MachineType/GetLastMachineType?id=' + this.ftype,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.ctypelist = res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        // 初始化备件类型
        inittype () {
            this.axios
                .request({
                    url: '/tpm/SparepartType/SparepartListType',
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.typelevel = res.data.data.children;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        inichargerlist () {
            this.axios
                .request({
                    url: '/config/projectuser/GetAllUserByCurrentProjectId',
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        if (Array.isArray(res.data.data)) {
                            this.chargerlist = res.data.data;
                        } else {
                            this.chargerlist = [];
                        }
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        // 备件类型变化
        typechange (value) {
            this.typeleveldata = value;
        },
        // 次级搜索条件
        changecondition () {
            this.morecondition = !this.morecondition;
        },
        handleRowChange (currentRow, oldCurrentRow) {
            this.detailshow = true;
            this.obj = currentRow;
            var params = {
                id: this.obj.id
            };
            this.axios
                .request({
                    url: '/tpm/Sparepart/GetoneSparepartItem',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.detailobj = res.data.data;
                        this.echartsdetail(res.data.data.nums, res.data.data.times);
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        handlesortchange (column, key, order) {
            this.sortkey = column.key
            this.sortorder = column.order
            this.search()
        },
        changePage (value) {
            this.page = value;
            // The simulated data is changed directly here, and the actual usage scenario should fetch the data from the server
            this.search();
        },
        handlePageSize (value) {
            this.pagesize = value;
            this.search();
        },
        tosearch () {
            this.page = 1
            this.sortkey = ''
            this.sortorder = ''
            this.search()
        },
        search () {
            this.detailshow = false;
            var params = {
                machinetype1: this.ftype,
                machinetype2: this.ctype,
                keyword: this.keyword,
                s_is_standard: this.Standard_parts,
                s_is_substitute: this.substitution,
                lastCheckValsparepart:
          this.typeleveldata.length === 0
              ? 0
              : this.typeleveldata[this.typeleveldata.length - 1],
                s_report: this.Stock,
                charger: this.charger,
                page: this.page,
                pagesize: this.pagesize,
                key: this.sortkey,
                order: this.sortorder
            };
            this.axios
                .request({
                    url: '/tpm/Sparepart/searchsparepartsbysection',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.total = res.data.total;
                        this.mockTableData1(res.data.data);
                        this.page = res.data.page;
                        this.pagesize = res.data.pagesize;
                    }
                });
        },
        mockTableData1 (tablelist) {
            let data = [];
            tablelist.forEach(item => {
                data.push({
                    code: item.code,
                    title: item.title,
                    param: item.param,
                    brand: item.brand,
                    is_substitute: item.is_substitute,
                    is_substitute1:
            item.is_substitute === 0 ? this.$t('1000021') : this.$t('1000020'),
                    sku: item.sku,
                    warehouse: item.warehouse,
                    status: item.stock_status,
                    thisMonth_in: item.thisMonth_in,
                    lastMonth_out: item.lastMonth_out,
                    thisMonth_out: item.thisMonth_out,
                    out_status: item.out_status,
                    id: item.id,
                    image: item.image,
                    description: item.description,
                    param: item.param,
                    price: item.price,
                    material: item.material,
                    unit: item.unit,
                    supplier: item.supplier,
                    delivery_time: item.delivery_time,
                    remark: item.remark,
                    is_standard: item.is_standard,
                    purchase_status: item.purchase_status,
                    typeTitle: item.typeTitle,
                    totalvalue: item.price * item.sku
                });
            });
            this.tableData1 = data;
        },
        echartsdetail (nums, time) {
            var myChart = echarts.init(document.getElementById('detailecharts'));
            var option = {
                title: {
                    text: this.$t('900695')
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: [this.$t('300037')]
                },
                toolbox: {
                    show: true,
                    feature: {
                        dataView: { show: true, readOnly: false, title: 'dataView' },
                        magicType: {
                            show: true,
                            title: {
                                line: 'Switch to polygraph',
                                bar: 'Switch to a histogram'
                            },
                            type: ['line', 'bar']
                        },
                        restore: { show: true, title: 'restore' },
                        saveAsImage: { show: true, title: 'Save pictures' }
                    }
                },
                calculable: true,
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: false,
                        data: time
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        axisLabel: {
                            formatter: '{value}'
                        }
                    }
                ],
                series: [
                    {
                        name: this.$t('300045'),
                        type: 'line',
                        data: nums,
                        markLine: {
                            data: [{ type: 'average', name: this.$t('900468') }]
                        }
                    }
                ]
            };
            myChart.setOption(option);
        },
        inittree () {
            this.axios
                .request({
                    url: '/tpm/SparepartType/SparepartListType',
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.treedata[0].children = res.data.data.children;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        applychange () {
            delete this.addobj.machinetype;
            if (this.addobj.subsu === 1) {
                this.axios
                    .request({
                        // 初始化 设备/产线层级树
                        url: '/config/MachineType/ListTypeTree',
                        method: 'get'
                    })
                    .then(res => {
                        if (res.data.ret === 1) {
                            this.treedata2[0].children = res.data.data.children;
                        } else {
                            this.$Message.error(this.$t(res.data.msg));
                        }
                    });
            } else if (this.addobj.subsu === 2) {
                this.axios
                    .request({
                        // 初始化 设备/产线层级树
                        url: '/config/ProjectLevelSection/GetLevelSectionTreeForTpm',
                        method: 'get'
                    })
                    .then(res => {
                        if (res.data.ret === 1) {
                            this.treedata2[0].children = res.data.data.children;
                        } else {
                            this.$Message.error(this.$t(res.data.msg));
                        }
                    });
            } else {
            }
        },
        initmidlist (query) {
            var params = {
                name: query
            };
            this.axios
                .request({
                    // 初始化负责人
                    url: '/config/projectuser/GetAllUserByCurrentProjectId',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        if (res.data.data.length > 0) {
                            this.midlist = res.data.data;
                        }
                    }
                });
        },
        unloadimg () {
            // 上传照片
            const file = this.$refs.fileIntimg.files[0];
            const data = new FormData();
            data.append('file', file);
            this.axios
                .request({
                    url: '/config/upload/UploadImage',
                    data,
                    method: 'post'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t('100378'));
                        // this.image = this.axios.publicPath + res.data.data
                        this.addobj.image = this.axios.publicPath + res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                })
                .catch(err => {
                    this.$Message.error(this.$t(err.msg));
                });
        },
        editunloadimg () {
            // 修改上传照片
            const file = this.$refs.editfileIntimg.files[0];
            const data = new FormData();
            data.append('file', file);
            this.axios
                .request({
                    url: '/config/upload/UploadImage',
                    data,
                    method: 'post'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t('100378'));
                        // this.image = this.axios.publicPath + res.data.data
                        this.editobj.image = this.axios.publicPath + res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                })
                .catch(err => {
                    this.$Message.error(this.$t(err.msg));
                });
        },
        gettreeNodes (value) {
            if (value.length > 0) {
                this.treenode1 = value;
                this.addobj.spareparttype = value[0].id;
            }
        },
        gettreeNodes2 (value) {
            if (value.length > 0) {
                if (this.addobj.subsu === 1) {
                    this.treenode2 = value;
                    this.addobj.machinetype = value[0].id;
                } else if (this.addobj.subsu === 2) {
                    this.treenode2 = value;
                    this.addobj.sectionid = value[0].machineid;
                }
            }
        },
        iniapprovalusers () {
            this.axios
                .request({
                    url: '/config/projectuser/GetAllUserByCurrentProjectId',
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.approvalusers = res.data.data;
                    }
                });
        },
        add () {
            this.initmidlist('');
            delete this.addobj.subsu;
            this.addmodal = true;
            this.addobj.code = '';
            this.addobj.title = '';
            this.addobj.max_sku = '';
            this.addobj.mini_sku = '';
            this.addobj.sku = '';
            this.addobj.warehouse = '';
            this.addobj.sku_report_mid = '';
            this.addobj.approvaluser = '';
            this.addobj.image = require('../../../static/images/xiangjitwo.png');
            this.addobj.is_substitute = '1';
            this.addobj.is_standard = '1';
            this.addobj.use_audit = '1';
            this.addobj.purchase_status = '1';
            this.inittree(); // 初始化树
            this.addobj.description = '';
            this.addobj.param = '';
            this.addobj.price = 0;
            this.addobj.material = '';
            this.addobj.brand = '';
            this.addobj.supplier = '';
            this.addobj.unit = '';
            this.addobj.delivery_time = '';
            this.addobj.remark = '';
            this.addobj.repair_upperlimit = '';
            this.addobj.sku_limit = '';
            this.iniapprovalusers();
            this.addmodal = true;
        },
        adddata () {
            if (
                this.addobj.spareparttype != undefined ||
        this.addobj.spareparttype != 0
            ) {
                // 树一的子节点选中
                if (
                    this.treenode1.length > 0 &&
          this.treenode1[0].children.length == 0
                ) {
                    /// /树一的子节点不含有子级
                    if (this.addobj.is_common == 1) {
                        // 是为通用件
                    } else if (this.addobj.is_common == 0) {
                        // 否 为通用件
                        if (this.addobj.subsu === 1) {
                            if (!this.addobj.machinetype) {
                                this.$Message.error(this.$t('100180'));
                                return false;
                            }
                        } else if (this.addobj.subsu === 2) {
                            if (!this.addobj.machinetype) {
                                this.$Message.error(this.$t('800082'));
                                return false;
                            }
                        } else {
                            this.$Message.error(this.$t('800209'));
                            return;
                        }
                    } else {
                        // 是否为通用件未选择
                        this.$Message.error(this.$t('9600003'));
                        return false;
                    }
                } else {
                    /// /树一的子节点含有子级
                    this.$Message.error(this.$t('9600002'));
                    return false;
                }
            } else {
                // 树一的子节点未选中
                this.$Message.error(this.$t('900698'));
                return false;
            }
            /* var re = new RegExp("[`~!@%#$^&*()=|{}':;',\\[\\]<>/?／＼］\\.；：%……+￥（）【】‘”“'．。，、？１２３４５６７８９０－＝＿＋～？！＠＃＄％＾＆＊）]")
      if (re.test(this.addobj.brand) || re.test(this.addobj.code) || re.test(this.addobj.title) || re.test(this.addobj.description) || re.test(this.addobj.param) || re.test(this.addobj.material) || re.test(this.addobj.supplier) || re.test(this.addobj.unit) || re.test(this.addobj.remark) || re.test(this.addobj.warehouse) || re.test(this.addobj.sku_report_mid)) {
        this.$Message.error('100316')
        return false
      } */
            // 最新库存不能大于最高库存
            if (Number(this.addobj.max_sku) < Number(this.addobj.mini_sku)) {
                this.$Message.error(this.$t('5000004'));
                return false;
            }
            if (
                this.addobj.image == require('../../../static/images/xiangjitwo.png')
            ) {
                this.addobj.image = '';
            }
            if (
                this.addobj.use_audit === '1' &&
        (this.addobj.approvaluser === undefined ||
          this.addobj.approvaluser === 0)
            ) {
                this.$Message.error(this.$t('950466'));
                return false;
            }
            if (this.addobj.sku == '') {
                this.$Message.error(this.$t(930113));
                return false;
            }
            if(this.addobj.title==''){
                this.$Message.error(this.$t(300002)+this.$t(150000));
                return false;
            }
            var data = this.addobj;

            this.axios
                .request({
                    url: '/tpm/Sparepart/AddTypeSparepart',
                    data,
                    method: 'post'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t('1055'));
                        this.tosearch();
                        this.addmodal = false;
                    } else {
                        this.addmodal = true;
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        edit () {
            this.initmidlist('');
            if (!this.obj.id) {
                this.$Message.error(this.$t('1043'));
                return false;
            }
            var params = {
                id: this.obj.id
            };
            this.axios
                .request({
                    url: '/tpm/Sparepart/GetoneSparepartItem',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.editobj = res.data.data;
                        this.editobj.sku_report_mid = Number(this.editobj.sku_report_mid);
                        if (this.editobj.image == '') {
                            this.editobj.image = require('../../../static/images/xiangjitwo.png');
                        }
                        if (this.editobj.approvaluser_mid > 0) {
                            this.iniapprovalusers();
                            this.editobj.use_audit = '1';
                            this.editobj.approvaluser = this.editobj.approvaluser_mid;
                            this.approvalusershow = true;
                        } else {
                            this.editobj.use_audit = '0';
                            this.approvalusershow = false;
                        }

                        this.axios
                            .request({
                                url: '/tpm/SparepartType/GetScategory',
                                method: 'get'
                            })
                            .then(res => {
                                if (res.data.ret === 1) {
                                    this.typelist = res.data.data;
                                    this.editobj.spareparttype = this.editobj.typeid;
                                } else {
                                    this.typelist = [];
                                }
                            });
                    }
                });
            this.editmodal = true;
        },
        auditchange () {
            this.approvalusershow = this.editobj.use_audit === '1';
            if (this.approvalusershow) {
                this.iniapprovalusers();
            }
        },
        editdata () {
            // var re = new RegExp("[`~!@%#$^&*()=|{}':;',\\[\\]<>/?／＼］\\.；：%……+￥（）【】‘”“'．。，、？１２３４５６７８９０－＝＿＋～？！＠＃＄％＾＆＊）]")
            // if (re.test(this.editobj.code) || re.test(this.editobj.title) || re.test(this.editobj.description) || re.test(this.editobj.param) || re.test(this.editobj.material) || re.test(this.editobj.supplier) || re.test(this.editobj.unit) || re.test(this.editobj.remark) || re.test(this.editobj.warehouse) || re.test(this.editobj.sku_report_mid)) {
            //   this.$Message.error('100316')
            //   return false
            // }
            // 最新库存不能大于最高库存
            if (Number(this.editobj.max_sku) < Number(this.editobj.mini_sku)) {
                this.$Message.error(this.$t('5000004'));
                return false;
            }
            if (
                this.editobj.use_audit === '1' &&
        (this.editobj.approvaluser === undefined ||
          this.editobj.approvaluser === 0)
            ) {
                this.$Message.error(this.$t('950466'));
                return false;
            }
            if (
                this.editobj.spareparttype === undefined ||
        this.editobj.spareparttype === 0
            ) {
                this.$Message.error(this.$t('900698'));
                return false;
            }
            if (
                this.editobj.image == require('../../../static/images/xiangjitwo.png')
            ) {
                this.editobj.image = '';
            }
            if (this.editobj.sku === '') {
                this.$Message.error(this.$t(930113));
                return false;
            }
            var data = this.editobj;
            if (this.editobj.use_audit === '0') {
                data.approvaluser = 0;
            }
            this.axios
                .request({
                    url: '/tpm/Sparepart/EditSparepart',
                    data,
                    method: 'post'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t('1060'));
                        this.tosearch();
                        this.editmodal = false;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        selecttrchange (value) {
            this.delelistobj = value;
        },
        dele () {
            if (this.delelistobj.length < 1) {
                this.$Message.error(this.$t('1017'));
                return false;
            }
            this.confirm();
        },
        confirm () {
            // 确认删除
            this.$Modal.confirm({
                title: this.$t('1018'),
                content: '',
                width: '290px',
                closable: true,
                okText: this.$t('1004'),
                onOk: () => {
                    var arr = [];
                    this.delelistobj.forEach(item => {
                        arr.push(item.id);
                    });
                    var data = {
                        ids: arr
                    };
                    this.delelist = arr;
                    this.axios
                        .request({
                            url: '/tpm/Sparepart/DeleteSpareparts',
                            data,
                            method: 'post'
                        })
                        .then(res => {
                            if (res.data.ret === 1) {
                                this.tosearch();
                                this.$Message.success(this.$t('1'));
                                this.delelistobj = [];
                            } else {
                                this.error(this.$t(res.data.msg));
                            }
                        });
                },
                onCancel: () => {
                    return false;
                }
            });
        },
        warehousing () {
            if (!this.obj.id) {
                this.$Message.error(this.$t('1043'));
                return false;
            }
            //  console.log(this.obj.id)
            var params = {
                id: this.obj.id
            };
            this.axios
                .request({
                    url: '/tpm/Sparepart/GetoneSparepartItem',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        // 替换件与非替换件
                        this.warehousingdetailobj = res.data.data;
                        if (this.warehousingdetailobj.is_substitute === 1) {
                            this.warehousingmodel = true;
                            this.warehousingobj = {};
                            this.warehousinglist = [
                                {
                                    code: '',
                                    repair_count: ''
                                }
                            ];
                        } else {
                            this.warehousingobj.IO_type = 1;
                            this.warehousingmodel2 = true;
                            this.in_stockobj.count = 0;
                        }
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                        return false;
                    }
                });
        },
        addwarehousinglist () {
            this.warehousinglist.push({
                code: '',
                repair_count: ''
            });
        },
        removewarehousinglist (item) {
            // console.log(item)
            if (this.warehousinglist.length > 1) {
                this.warehousinglist.splice(item, 1);
            } else {
                this.$Message.error(this.$t('5000001'));
            }
        },
        remoteMethod1 (query) {
            if (query != '') {
                this.loading1 = true;
                setTimeout(() => {
                    this.loading1 = false;
                    var params = {
                        keyword: query
                    };
                    this.axios
                        .request({
                            url: '/config/ProjectUser/getWorkByKeyword',
                            params,
                            method: 'get'
                        })
                        .then(res => {
                            if (res.data.ret == 1) {
                                this.warehousingpeoplelist = res.data.data;
                            }
                        });
                }, 200);
            } else {
                this.warehousingpeoplelist = [];
            }
        },
        warehousingdata () {
            var i = 1;
            var vm = this;
            var arrture = true;
            this.warehousinglist.forEach(item => {
                if (arrture) {
                    if (item.code == '') {
                        this.$Message.error(
                            vm.$t('1077') + i + vm.$t('1083') + vm.$t('5000002')
                        );
                        arrture = false;
                        return false;
                    }
                    if (item.repair_count == '') {
                        this.$Message.error(
                            vm.$t('1077') + i + vm.$t('1083') + vm.$t('5000003')
                        );
                        arrture = false;
                        return false;
                    }
                    i++;
                }
            });
            if (!arrture) {
                return false;
            }
            this.warehousingobj.sparepart_id = this.obj.id;
            this.warehousingobj.spareparts = this.warehousinglist;
            var data = this.warehousingobj;
            this.axios
                .request({
                    url: '/tpm/SparepartRecord/AddEnterSparepart',
                    data,
                    method: 'post'
                })
                .then(res => {
                    if (res.data.ret == 1) {
                        this.$Message.success(this.$t('1'));
                        this.warehousingmodel = false;
                        this.page = 1;
                        this.search();
                        this.warehousinglist = [
                            {
                                code: '',
                                repair_count: ''
                            }
                        ];
                        this.obj = {};
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        warehousingdata2 () {
            if (
                this.in_stockobj.IO_type === undefined ||
        this.in_stockobj.IO_type <= 0
            ) {
                this.$Message.error(this.$t('9000136'));
                return false;
            }
            if (this.in_stockobj.count === undefined || this.in_stockobj.count <= 0) {
                this.$Message.error(this.$t('9000136'));
                return false;
            }
            this.warehousingobj.sparepart_id = this.obj.id;
            this.warehousingobj.count = this.in_stockobj.count;
            this.warehousingobj.io_type = this.in_stockobj.IO_type;
            this.warehousingobj.location = '';
            var data = this.warehousingobj;
            this.axios
                .request({
                    url: '/tpm/SparepartRecord/AddEnterSparepart2',
                    data,
                    method: 'post'
                })
                .then(res => {
                    if (res.data.ret == 1) {
                        this.$Message.success(this.$t('1'));
                        this.warehousingmodel2 = false;
                        this.page = 1;
                        this.search();
                        this.obj = {};
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        out_stock () {
            if (!this.obj.id) {
                this.$Message.error(this.$t('1043'));
                return false;
            }
            var params = {
                id: this.obj.id
            };
            this.axios
                .request({
                    url: '/tpm/Sparepart/GetoneSparepartItem',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.out_stockmodel = true;
                        this.out_stockobj.number = 0;
                        this.out_stockdetailobj = res.data.data;
                        this.out_stockobj.IO_type = 3;
                        // console.log(this.warehousingobj)
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                        return false;
                    }
                });
        },
        remoteMethod2 (query) {
            if (query != '') {
                this.loading2 = true;
                setTimeout(() => {
                    this.loading2 = false;
                    var params = {
                        keyword: query
                    };
                    this.axios
                        .request({
                            url: '/config/ProjectUser/getWorkByKeyword',
                            params,
                            method: 'get'
                        })
                        .then(res => {
                            if (res.data.ret == 1) {
                                this.out_stockpeoplelist = res.data.data;
                            }
                        });
                }, 200);
            } else {
                this.out_stockpeoplelist = [];
            }
        },
        out_stockdata () {
            if (this.out_stockobj.number == '') {
                this.$Message.error(this.$t('900690'));
                return false;
            }
            if (this.out_stockobj.number < 0) {
                this.$Message.error(this.$t('8000049'));
                return false;
            }
            if (!this.out_stockobj.operate_mid) {
                this.$Message.error(this.$t('900802'));
                return false;
            }
            // var re = new RegExp("[`~!@%#$^&*()=|{}':;',\\[\\]<>/?／＼］\\.；：%……+￥（）【】‘”“'．。，、？１２３４５６７８９０－＝＿＋～？！＠＃＄％＾＆＊）]")
            // if (re.test(this.out_stockobj.remark)) {
            //   this.$Message.error('100316')
            //   return false
            // }
            this.out_stockobj.sparepartid = this.obj.id;
            var data = this.out_stockobj;
            this.axios
                .request({
                    url: '/tpm/SparepartRecord/AddcomeSparepart',
                    data,
                    method: 'post'
                })
                .then(res => {
                    if (res.data.ret == 1) {
                        this.$Message.success(this.$t('1'));
                        this.out_stockmodel = false;
                        this.page = 1
                        this.pagesize = 10
                        this.search();
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        loadexcel1 () {
            var params = {
                name: 'SparepartList'
            };
            this.axios
                .request({
                    url: '/config/download/GetTemplate',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret == 1) {
                        window.location.href = this.axios.publicPath + res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        loadexcel () {
            var params = {
                id: this.leveldata[this.leveldata.length - 1]
            };
            this.axios
                .request({
                    url: '/config/UserLevel/ListMachineIdArrEx',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        var params = {
                            machinetype1: this.ftype,
                            machinetype2: this.ctype,
                            keyword: this.keyword,
                            s_is_standard: this.Standard_parts,
                            s_is_substitute: this.substitution,
                            lastCheckValsparepart:
                this.typeleveldata.length === 0
                    ? 0
                    : this.typeleveldata[this.typeleveldata.length - 1],
                            s_report: this.Stock,
                            charger: this.charger
                        };
                        this.axios
                            .request({
                                url: '/tpm/Sparepart/ExportSparepartList',
                                params,
                                method: 'get'
                            })
                            .then(res => {
                                if (res.data.ret === 1) {
                                    window.location.href = this.axios.publicPath + res.data.data;
                                } else {
                                    this.$Message.error(this.$t(res.data.msg));
                                }
                            });
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        qrcode () {
            if (this.obj.is_substitute === 0) {
                this.$Message.error(this.$t('4000013'));
                return false;
            }
            if (!this.obj.id) {
                this.$Message.error(this.$t('1043'));
                return false;
            }
            var params = {
                id: this.obj.id
            };
            this.axios
                .request({
                    url: '/tpm/Sparepart/GetoneSparepartItem',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        this.qrcodemodel = true;
                        this.qrcodeobj = res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                        return false;
                    }
                });
        },
        handleBatchPrintCode (item) {
            // 必须要等到页面加载完成，不然会报错
            this.$nextTick(() => {
                let code = item.code;
                this.$refs.codeItem.innerHTML = '';
                let qrcode = new QRCode(this.$refs.codeItem, {
                    text: code, // 二维码内容
                    width: 150,
                    height: 150
                    // colorDark: "#333333", //二维码颜色
                    // colorLight: "#ffffff", //二维码背景色
                });
            });
        }
    }
};
</script>
<style lang="less" scoped>
.detaildiv {
  border: 1px solid #ccc;
  .divfloat {
    display: inline-block;
    width: 168px;
    height: 168px;
    vertical-align: top;
    border: 1px solid #ccc;
    margin: -1px;
    div {
      margin-bottom: 0px;
      line-height: 1;
      border: 1px solid #ccc;
      margin: -1px;
      vertical-align: top;
      height: 28.6px;
      text-align: center;
      line-height: 28.6px;
      div {
        height: 28.6px;
        width: 94px;
        display: inline-block;
        border: 1px solid #ccc;
        vertical-align: top;
        margin: -1px;
        overflow: hidden;
      }
    }
  }
  .spandiv {
    width: 188px;
  }

}
.addfilter {
    height:50px!important;
    label{
      text-align:left;
    }
  }
.editload {
  position: relative;
  padding-left: 100px;
  padding-top: 20px;
  img {
    vertical-align: top;
    width: 150px;
    height: 128px;
    margin: 10px 0px;
  }
  input {
    position: absolute;
    // font-size: 100px;
    left: 210px;
    top: 20px;
    opacity: 0;
    width: 138px;
    height: 128px;
  }
}
.editfilter {
  display: inline-block;
  i {
    display: inline-block;
    width: 5px;
  }
  label {
    display: inline-block;
    width: 80px;
    text-align: right;
  }
  input {
    vertical-align: middle;
  }
  .rad {
    width: 40px;
  }
}

.warehousingdetail > div {
  margin: 10px 0;
}
@media print {
  #printStyle .item {
    margin: 10px;
  }
  #printStyle h2 {
    font-size: 30px;
  }
}
.detaildiv > div.divfloat > div > div:first-child,
.fontclass,
.warehousingdetail > div > span:first-child {
  font-weight: 900;
}
.warehousingdetail > div > span {
  display: inline-block;
  width: 115px;
  vertical-align: top;
}
.warehousingdetail > div > span:first-child {
  display: inline-block;
  width: 80px;
}
.fontclass {
  margin-bottom: 10px;
}
</style>
<style media="printContent">
@page {
  margin: 15mm; /* this affects the margin in the printer settings */
}
</style>
