<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <el-input v-model="query.tckw" clearable placeholder="台车" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
      <el-input v-model="query.bigItemCode" clearable placeholder="机型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
      <rrOperation :crud="crud" />
      <crudOperation :permission="permission" :tableKey="this.$options.name">
          <el-button
                  slot="right"
                  class="filter-item"
                  type="primary"
                  size="mini"
                  @click="saveBomPrintTc()"
                  icon="el-icon-document-add"
          >
            台车标签
          </el-button>
        <el-button
          slot="right"
          class="filter-item"
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="crud.selections.length == 0"
          @click="tcOutBtn(crud.selections)"
          v-permission="permission.tcOut"
        >
          台车配料
        </el-button>
      </crudOperation>
      <!--表格渲染-->
      <el-table id="mytable" ref="table" border :height="crud.tableHeight" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler" >
        <el-table-column type="selection" width="55" />
        <el-table-column prop="hw" label="台车名" />
        <el-table-column prop="code" label="机型" />
        <el-table-column prop="pm" label="机型名" />
      </el-table>
      <!--分页组件-->
      <div style="position:absolute;right: 0">
      <pagination />
      </div>
    </div>
  </div>
</template>

<script>
import {exportExcel} from '@/components/TableToExcel/ExportExcel'
import {initData} from '@/api/data'
import crudBomAccount, {queryBomPrintListTC} from '@/api/bomAccount'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import bigItem from '@/api/bigItem'
import { getItemsList } from '@/api/item'
import DateRangePicker from "@/components/DateRangePicker/index.vue";
import { getAreas, queryAreaList } from '@/api/area'
import { getToken } from '@/utils/auth'
import DonMessage from '@/utils/message'
import Link from "@/layout/components/Sidebar/Link.vue";
import excelUtil from "@/api/tools/excelUtil"
import { formatDate } from '@/utils/commonUtils'
import {mapGetters} from "vuex";
import AreaSelect from "@/views/generic-component/AreaSelect.vue";
import PointSelect from "@/views/generic-component/PointSelect.vue";
import PointCodeSelect from "@/views/generic-component/PointCodeSelect.vue";
import {xbjsOut} from "@/api/pickOut";
const defaultForm = { id: null, bigItem: null, supplier: null,item: null, contents: null, singles: null, rArea: null, cArea: null, outType: null, station_type: null, bp_type: null,  dept: null, enabled: null, createBy: null, updateBy: null, createTime: null, updateTime: null, description: null, ac: null, bonded: null, zPoint: { code: null }}
export default {
  name: 'BomAccountTcbq',
  components: {
    PointCodeSelect,
    PointSelect, AreaSelect, Link, DateRangePicker, pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['process_content', 'out_type', 'station_type', 'bp_type','bonded_type','ac_type','zdw_type'],
  cruds() {
    return CRUD({ title: '台车标签', url: 'api/bomAccount/queryBomTckwPrintList', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBomAccount },
      optShow: {
        add: false,
        edit: false,
        del: false,
        reset: true,
        download: false
      },
    })
  },
  computed: {
    ...mapGetters([
      'baseApi'
    ])
  },
  data() {
    return {
      permission: {
        tcOut: ['admin', 'tcbq:tcOut']
      },
      headers: { 'Authorization': getToken() },
      loading_add:false,
      fileList: [],
      // 下拉框
      bigItemList: [],
      itemList: [],
      rAreaList: [],
      cAreaList: [],
      excelQueryParam: {
        excelConfigId: '912967151437389824',
        queryParam: {
          pageNo: 1,
          bomAccount__机型: null,
          bomAccount__机型名: null,
          bomAccount__工位: null,
          bomAccount__部品品番: null,
          currentPageNo: 1,
          currentPageSize: 10,
          pageSize: 10
        }
      },}
  },
  mounted() {
    //计算界面高度

  },
  methods: {

    handleErr(err, file, fileList) {

      let myError = err.toString();//转字符串
      myError = myError.replace("Error: ", "") // 去掉前面的" Error: "
      myError = JSON.parse(myError);//转对象
      DonMessage.error("" + myError['message'])
    },
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    saveBomPrintTc() {
      console.log("打印台车标签")
      queryBomPrintListTC(this.crud.getQueryParams2()).then(res => {
            this.showEwmReportTc();
        })
    },
    showEwmReportTc(){
          this.$router.push({path:'/base-data/base-ware/point_print_tc',query:{tableID: '打印台车标签'}})
      },
    tcOutBtn(data){
      this.loading_add=true;
      let tckws = [];
      for (const obj of data) {
        tckws.push(obj.hw)
      }
      tcOut(ids).then(res=>{
        this.crud.toQuery()
        this.loading_add=false;
        this.$message.success("台车配料出库")
      },e=>{
        this.loading_add=false;
      })
    }
  }
}
</script>

<style scoped>

</style>
