<template>
  <basic-container>
    <el-tabs v-model="tabPosition" class="demo-tabs" @tab-change="tabPositionChange">
      <el-tab-pane label="镀前入库" name="beforePlatingEntry"></el-tab-pane>
      <el-tab-pane label="镀前出库" name="beforePlatingBound"></el-tab-pane>
      <el-tab-pane label="镀后入库" name="afterPlatingEntry"></el-tab-pane>
    </el-tabs>

    <!-- 表格数据 -->
    <avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud"
      @row-del="rowDel" @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" icon="el-icon-plus" @click="handleAdd(tabPosition)">新 增</el-button>
      </template>
      <template #cardNo="{ row }">{{ row.prWorkOrder.cardNo }}</template>
      <template #woCode="{ row }">{{ row.prWorkOrder.woCode }}</template>
      <template #batchNo="{ row }">{{ row.prWorkOrder.batchNo }}</template>
      <template #orders="{ row }">{{ row.prWorkOrder.orders }}</template>
      <template #ppsName="{ row }">{{ row.prWorkOrder.orders }}</template>
      <template #partCode="{ row }">{{ row.prWorkOrder.pjYieldOrder.partCode }}</template>
      <template #partName="{ row }">{{ row.prWorkOrder.pjYieldOrder.partName }}</template>
      <template #tsName="{ row }"> {{ row.makeTeam != null ? row.makeTeam.tsName : row.oemCustomer.ocName }}</template>
      <template #userName="{ row }"> {{ row.makeMan.userName }}</template>
    </avue-crud>
    <before-plating-entry-dialog :show-dialog="showDialog"  @closeDialog="closeDialog"></before-plating-entry-dialog>
    <before-plating-bound-dialog :bound-dialog="boundDialog"  @closeDialog="closeDialog"></before-plating-bound-dialog>
    <after-plating-entry-dialog :after-bound-dialog="afterBoundDialog" @closeDialog="closeDialog"></after-plating-entry-dialog>
  </basic-container>
</template>

<script>
import columnData from './js/platingColumnData'
import addPlatingColumnData from './js/addPlatingColumnData';
import beforePlatingEntryDialog from './components/beforePlatingEntryDialog.vue';
import beforePlatingBoundDialog from './components/beforePlatingBoundDialog.vue';
import afterPlatingEntryDialog from './components/afterPlatingEntryDialog.vue';
export default {
  components: {
    beforePlatingEntryDialog,
    beforePlatingBoundDialog,
    afterPlatingEntryDialog
  },
  data() {
    return {
      tabPosition: 'beforePlatingEntry',
      showDialog: false,
      boundDialog:false,
      afterBoundDialog:false,
      option: {
        columnSort: true,
        tip: false,
        height: 'auto',
        align: 'center',
        calcHeight: 32,
        simplePage: false,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: false,
        viewBtn: false,
        delBtn: true,
        editBtn: false,
        delBtnIcon: ' ',
        addBtn: false,
        labelWidth: 120,
        searchLabelWidth: 120,
        menu: false,
        menuWidth: 140,
        dialogWidth: 600,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: true,
        gridBtn: false,
        searchShowBtn: false,
        showOverflowTooltip: true,
        searchLabelPosition:'left',
searchLabelPosition:'left',
 searchGutter:24,
  searchSpan:6,
menuAlign: 'left',
gridBtn:false,
searchMenuPosition:'right',
        column: []
      },
      addForm: {},
      addOption: {
        columnSort: true,
        tip: false,
        // height: 'auto',
        align: 'center',
        calcHeight: 32,
        simplePage: false,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: true,
        viewBtn: false,
        delBtn: true,
        editBtn: false,
        delBtnIcon: ' ',
        addBtn: false,
        labelWidth: 120,
        searchLabelWidth: 120,
        menu: false,
        menuWidth: 140,
        dialogWidth: 600,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: true,
        gridBtn: false,
        searchShowBtn: false,
        showOverflowTooltip: true,
        column: [

        ]
      },
      data: [],
      tableData: [],
      selectDialogData: [],
      cardNo: '',
      page:{
        pageSize: 10,
        currentPage: 1,
        total: 0,
      }
    }
  },
  mounted() {
    this.option.column = columnData[this.tabPosition]
    this.data = [
      {
        id: 1, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
        prWorkOrder: {
          orders: "0005",
          cardNo: '1016663941',
          woCode: 'WO-S22122668-R01',
          batchNo: 'WB135230311004',
          procedureSet: {
            ppsName: '上挂',
          },
          pjYieldOrder: {
            partName: '方盘壳体',
            partCode: '21E8-003-1149-E9-N',
          }
        },
        makeMan: {
          userName: '崔殿龙',
        },
        makeTeam: {
          tsName: '化学镀镍一班崔胜伟'
        },
        oemCustomer: null
      },
      {
        id: 2, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
        prWorkOrder: {
          orders: "0005",
          cardNo: '1016663941',
          woCode: 'WO-S22122668-R01',
          batchNo: 'WB135230311004',
          procedureSet: {
            ppsName: '上挂',
          },
          pjYieldOrder: {
            partName: '方盘壳体',
            partCode: '21E8-003-1149-E9-N',
          }
        },
        makeMan: {
          userName: '崔殿龙',
        },
        makeTeam: {
          tsName: '化学镀镍一班崔胜伟'
        },
        oemCustomer: null
      },
      {
        id: 3, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
        prWorkOrder: {
          orders: "0005",
          cardNo: '1016663941',
          woCode: 'WO-S22122668-R01',
          batchNo: 'WB135230311004',
          procedureSet: {
            ppsName: '上挂',
          },
          pjYieldOrder: {
            partName: '方盘壳体',
            partCode: '21E8-003-1149-E9-N',
          }
        },
        makeMan: {
          userName: '崔殿龙',
        },
        makeTeam: null,
        oemCustomer: {
          ocName: 'L235'
        },
      },
    ]
    this.page.total = this.data.length
  },
  methods: {
    // 流程卡号输入框点击回车按钮
    handleEnter() {
      console.log('this.cars-------------', this.cardNo)
      console.log('tab---------', this.tabPosition)
      if (this.tabPosition == 'beforePlatingEntry') {
        this.beforePlatingEntryData = [
          {
            paCode: 'FE-20231223003', woCode: 'WO-S22122668-R01', batchNo: '	WB135230311004', cardNo: "1016663941",
            tsName: '', orders: ''
          }
        ]
      }
    },
    // 点击新增按钮
    handleAdd(val) {
      console.log('val---------',val)
      if (val == 'beforePlatingEntry') {
        this.showDialog = true
      }else if(val == 'beforePlatingBound'){
        this.boundDialog = true
      }else{
        this.afterBoundDialog = true
      }
      
    },
    rowDel() {
      this.$confirm(
        '此操作将永久删除该数据, 是否继续?',
        '提示',
        {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).then(() => {

      })
    },
    // 关闭弹窗
    closeDialog() {
      this.showDialog = false
      this.boundDialog = false
      this.afterBoundDialog = false
    },
    tabPositionChange(value, event) {
      this.option.column = columnData[this.tabPosition]
      this.option.menu = false
      if (this.tabPosition == 'beforePlatingEntry') {
        this.data = [
          {
            id: 1, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            prWorkOrder: {
              orders: "0005",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '上挂',
              },
              pjYieldOrder: {
                partName: '方盘壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: {
              tsName: '化学镀镍一班崔胜伟'
            },
            oemCustomer: null
          },
          {
            id: 2, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            prWorkOrder: {
              orders: "0005",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '上挂',
              },
              pjYieldOrder: {
                partName: '方盘壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: {
              tsName: '化学镀镍一班崔胜伟'
            },
            oemCustomer: null
          },
          {
            id: 3, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            prWorkOrder: {
              orders: "0005",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '上挂',
              },
              pjYieldOrder: {
                partName: '方盘壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: null,
            oemCustomer: {
              ocName: 'L235'
            },
          },
        ]
        this.page.total = this.data.length
      } else if (this.tabPosition == 'beforePlatingBound') {
        this.data = [
          {
            id: 1, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            prWorkOrder: {
              orders: "0021",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '包装防护',
              },
              pjYieldOrder: {
                partName: '24-插头密封盖壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: {
              tsName: '化学镀镍一班崔胜伟'
            },
            oemCustomer: null
          },
          {
            id: 2, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            prWorkOrder: {
              orders: "0021",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '包装防护',
              },
              pjYieldOrder: {
                partName: '24-插头密封盖壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: {
              tsName: '化学镀镍一班崔胜伟'
            },
            oemCustomer: null
          },
          {
            id: 3, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            prWorkOrder: {
              orders: "0021",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '包装防护',
              },
              pjYieldOrder: {
                partName: '24-插头密封盖壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: null,
            oemCustomer: {
              ocName: 'L235'
            },
          },
        ]
        this.page.total = this.data.length
      } else {
        this.option.menu = true
        this.data = [
          {
            id: 1, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            weight: 111,
            prWorkOrder: {
              orders: "0021",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '包装防护',
              },
              pjYieldOrder: {
                partName: '24-插头密封盖壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: {
              tsName: '化学镀镍一班崔胜伟'
            },
            oemCustomer: null
          },
          {
            id: 2, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            weight: 111,
            prWorkOrder: {
              orders: "0021",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '包装防护',
              },
              pjYieldOrder: {
                partName: '24-插头密封盖壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: {
              tsName: '化学镀镍一班崔胜伟'
            },
            oemCustomer: null
          },
          {
            id: 3, paCode: 'FE-20231223003', quantity: 160, createTime: '2023-12-23 18:01:26',
            weight: 111,
            prWorkOrder: {
              orders: "0021",
              cardNo: '1016663941',
              woCode: 'WO-S22122668-R01',
              batchNo: 'WB135230311004',
              procedureSet: {
                ppsName: '包装防护',
              },
              pjYieldOrder: {
                partName: '24-插头密封盖壳体',
                partCode: '21E8-003-1149-E9-N',
              }
            },
            makeMan: {
              userName: '崔殿龙',
            },
            makeTeam: null,
            oemCustomer: {
              ocName: 'L235'
            },
          },
        ]
        this.page.total = this.data.length
      }
    }
  }
}
</script>

<style></style>