<template>
  <div class="view-carrierFlightMission-MissionPlane">
    <div class="view-dataSpecies-left">
      <MenuTree :currentNodeKey="currentNodeKey" :treedata="menuTreeData" @TreeNodeclick="treeNodeClick" v-bind="treeObj"> </MenuTree>
    </div>
    <div class="view-dataSpecies-right">
      <div class="view-dataType-title">
        <div class="view-dataType-title-btn">
          <el-button type="success" @click="openStructureEquippingDialog()">新增</el-button>
          <el-button type="warning">删除</el-button>
        </div>
      </div>
      <div class="view-dataType-table">
        <LTable ref="table" @select-all="selectAll" @selection-change="selection" :defaultFetch="false" :columns="columns" :dataSource="tableData" :options="options" :fetch="fetchTableData" :pagination="tableRequset"></LTable>
      </div>
      <StructureEquipping v-if="structureEquippingVisible" :structureEquippingVisible="structureEquippingVisible" :closeStructureEquipping="closeStructureEquipping" @handleStructureEquipping="handleStructureEquipping" />
    </div>
  </div>
</template>

<script>
import { defaultProps, mockTableData, tableData, tableData1, tableData2, columns, options } from './index'
import StructureEquipping from './components/StructureEquipping/index.vue'
export default {
  name: 'MissionPlane',
  components: { StructureEquipping },
  data() {
    // 这里存放数据
    return {
      structureEquippingVisible: false,
      currentNodeKey: '',
      menuTreeData: mockTableData,
      treeObj: {
        title: '所属机种',
        activityheight: '275px',
        searchIcon: false,
        configure: defaultProps
      },
      tableRequset: {
        total: 0,
        pageIndex: 1,
        pageSize: 10,
        searchValue: ''
      },
      columns: columns(this),
      options,
      tableData: tableData
    }
  },
  mounted() {},
  methods: {
    fetchTableData() {},
    selectAll() {},
    selection() {},
    updateRow(row, index, scope) {
      console.log(row, index, scope)
    },
    remove(rwo) {
      this.$confirm('是否删除该机种', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
        })
        .catch(() => {})
    },
    openStructureEquippingDialog() {
      this.structureEquippingVisible = true
    },
    closeStructureEquipping() {
      this.structureEquippingVisible = false
    },
    handleStructureEquipping(row) {
      this.structureEquippingVisible = false
      this.tableData.push(row)
    },
    treeNodeClick(data) {
      this.$refs.table.clearSelection()
      // 点击树节点传值
      this.currentNodeKey = data.id
      this.currentNodeName = data.aircraftTypeName
      if (this.currentNodeName == '歼20' || this.currentNodeName == '运20') {
        this.tableData = tableData
      }
      if (this.currentNodeName == '歼23' || this.currentNodeName == '运23') {
        this.tableData = tableData1
      }
      if (this.currentNodeName == '歼22' || this.currentNodeName == '运22') {
        this.tableData = tableData2
      }
      this.fetchTableData()
    }
  }
}
</script>

<style lang="scss">
@import './index.scss';
</style>
