<template>
  <basic-container>
    <!-- 库存汇总 -->
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      v-model="form"
      v-model:page="page"
      ref="crud"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template #menu-left>
        <el-button type="primary" @click="handlePrepare">准备</el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>

<script>
import { getList } from "@/api/productionManagement/frontTooling";
export default {
  data() {
    return {
      selectionList: [],
      loading: false,
      data: [],
      form: {},
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        height: 'auto',
        align: 'center',
        calcHeight: 32,
        rowKey: 'rlsId',
        tip: false,
        size: 'medium',
        simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: false,
        selection: true,
        viewBtn: false,
        delBtn: false,
        addBtn: false,
        editBtn: false,
        editBtnText: '修改',
        addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        viewBtnText: '详情',
        labelWidth: 120,
        searchLabelWidth: 120,
        menu: false,
        menuWidth: 220,
        dialogWidth: 1200,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: false,
        filterBtn: true,
        searchShowBtn: false,
        columnSort: true,
        excelBtn: true,
        columnSort: true,
        showOverflowTooltip: true,
        searchLabelPosition: 'left',
        searchLabelPosition: 'left',
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: 'left',
        gridBtn: false,
        searchMenuPosition: 'right',
        column: [
          {
            label: '准备状态',
            prop: 'readStatusTiTle',
            type: 'select',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入准备状态',
                trigger: 'blur',
              },
            ],
            dicData: [
              {
                value: 1,
                label: '已准备',
              },
            ],
          },
          {
            label: '生产计划号',
            prop: 'poCode',
            bind: 'pjYieldOrder.poCode',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入生产计划号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '生产订单号',
            prop: 'yoCode',
            bind: 'pjYieldOrder.yoCode',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入生产订单号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '车间订单号',
            prop: 'woCode',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入车间订单号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '零件号',
            prop: 'partCode',
            bind: 'pjYieldOrder.partCode',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入零件号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '零件名称',
            prop: 'partName',
            bind: 'pjYieldOrder.partName',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入零件名称',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '流程卡号',
            prop: 'cardNo',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入流程卡号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '批次号',
            prop: 'batchNo',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入批次号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '镀种信息',
            prop: 'plate',
            bind: 'pjYieldOrder.plate',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入镀种信息',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '生产标识',
            prop: 'prodIdent',
            bind: 'pjYieldOrder.prodIdent',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入生产标识',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '生产数量',
            prop: 'makeQty',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入生产数量',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '面积(dm²)',
            prop: 'poArea',
            bind: 'pjYieldOrder.poArea',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入面积(dm²)',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '订单优先级',
            prop: 'priority',
            type: 'select',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入订单优先级',
                trigger: 'blur',
              },
            ],
            dicUrl: '/blade-system/dict/dictionary?code=orderPriority',
            props: {
              label: 'dictValue',
              value: 'dictKey',
            },
          },
          {
            label: '计划下达时间',
            prop: 'createTime',
            type: 'date',
            searchRange: true,
            startPlaceholder: '开始时间',
            endPlaceholder: '结束时间',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入计划下达时间',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '需求交期',
            prop: 'demandDate',
            type: 'date',
            searchRange: true,
            startPlaceholder: '开始时间',
            endPlaceholder: '结束时间',
            width: 200,
            search: true,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入需求交期',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '石墨模具号',
            prop: 'moCode',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入石墨模具号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '库位号',
            prop: 'moLocal',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入库位号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '待出库数量',
            prop: 'moNumber',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入待出库数量',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '玻璃饼',
            prop: 'glassPie',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入玻璃饼',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '待出库数量',
            prop: 'glassNumber',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入待出库数量',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '压饼模具号',
            prop: 'ybCode',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入压饼模具号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '库位号',
            prop: 'ybLocal',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入库位号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '待出库数量',
            prop: 'ybNumber',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入待出库数量',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '备注',
            prop: 'memo',
            width: 200,
            search: false,
            sortable: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: '请输入备注',
                trigger: 'blur',
              },
            ],
          },
        ],
      },
    };
  },
  mounted() {},
  methods: {
    selectionChange(val) {
      this.selectionList = val;
    },
    handlePrepare() {
      if (this.selectionList.length == 0) {
        this.$message.error('请先选择数据');
        return;
      }
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      this.onLoad(this.page, this.query);
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      this.onLoad(this.page, this.query);
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    searchReset() {
      this.query = {};
      this.treeDeptId = '';
      this.onLoad(this.page, this.query);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    onLoad(page, params = {}) {
    //   this.loading = true;
    //   getList(
    //     page.currentPage,
    //     page.pageSize,
    //     Object.assign(params, this.query, { yieldType: '1' })
    //   ).then(res => {
    //     this.data = res.data.data.records;
    //     this.loading = false;
    //     this.page.total = res.data.data.total;
    //     this.selectionClear();
    //   });
    },
  },
};
</script>

<style></style>
