<template>
  <div>
    <el-dialog class="structureEquipping-modal-s" title="航材" :visible="structureEquippingVisible" width="600px" :before-close="closeStructureEquipping">
      <div class="structureEquipping-list">
        <label class="structureEquipping-list-label">航材名称</label>
        <el-input v-model="activeRow.sparePartsName" placeholder="请选择航材" disabled></el-input>
        <el-button type="primary" @click="openFittingsModal">选择航材</el-button>
      </div>
      <div class="structureEquipping-list">
        <label class="structureEquipping-list-label">航材编号</label>
        <el-input v-model="activeRow.spareNumber" placeholder="请输入航材编号" disabled></el-input>
      </div>

      <div class="structureEquipping-list">
        <label class="structureEquipping-list-label">所属分类</label>
        <el-input v-model="activeRow.classification" placeholder="请输入所属分类" disabled></el-input>
      </div>
      <div class="structureEquipping-list">
        <label class="structureEquipping-list-label">携带数量</label>
        <el-input v-model="activeRow.carryQuantity" placeholder="请输入携带数量"></el-input>
      </div>
      <div class="structureEquipping-list">
        <label class="structureEquipping-list-label">单价</label>
        <el-input v-model="activeRow.unitPrice" placeholder="请输入单价" disabled></el-input>
      </div>
      <div class="structureEquipping-list">
        <label class="structureEquipping-list-label">携带金额</label>
        <el-input v-model="activeRow.carryingAmount" placeholder="请输入携带金额" disabled></el-input>
      </div>
      <div class="structureEquipping-list">
        <label class="structureEquipping-list-label">自动生成</label>
        <el-radio disabled v-model="activeRow.autoGeneration" label="1">是</el-radio>
        <el-radio disabled v-model="activeRow.autoGeneration" label="0">否</el-radio>
      </div>
      <div class="structureEquipping-list">
        <label class="structureEquipping-list-label">是否修改</label>
        <el-radio disabled v-model="activeRow.isModified" label="1">是</el-radio>
        <el-radio disabled v-model="activeRow.isModified" label="0">否</el-radio>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeStructureEquipping">取 消</el-button>
        <el-button type="primary" @click="handleStructureEquipping">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog class="fittings-modal" title="选择航材" :visible="fittingsVisible" width="1200px" :before-close="closefittingsVisible">
      <div class="fittings-modal-box">
        <div class="fittings-modal-box-left">
          <MenuTree :currentNodeKey="currentNodeKey" :treedata="menuTreeData" @TreeNodeclick="treeNodeClick" v-bind="treeObj"> </MenuTree>
        </div>
        <div class="fittings-modal-box-right">
          <LTable ref="table" :defaultFetch="false" :columns="columns" :dataSource="tableData" :options="options" :fetch="fetchTableData" :pagination="tableRequset"></LTable>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { defaultProps, mockMenuTreeData, tableData, columns, options } from './index'
export default {
  name: 'StructureEquipping',
  props: {
    structureEquippingVisible: {},
    closeStructureEquipping: {}
  },
  components: {},
  data() {
    // 这里存放数据
    return {
      fittingsVisible: false,
      currentNodeKey: '',
      menuTreeData: mockMenuTreeData,
      treeObj: {
        title: '所属分类',
        activityheight: '500px',
        searchIcon: false,
        configure: defaultProps
      },
      tableData: tableData,
      columns: columns(this),
      options,
      tableRequset: {
        total: 0,
        pageIndex: 1,
        pageSize: 10,
        searchValue: ''
      },
      activeRow: {
        sparePartsName: '',
        spareNumber: '',
        classification: '',
        carryQuantity: '',
        unitPrice: '',
        carryingAmount: '',
        autoGeneration: '',
        isModified: ''
      }
    }
  },
  mounted() {},
  methods: {
    handleClose() {},
    closefittingsVisible() {
      this.fittingsVisible = false
      this.activeRow = {
        sparePartsName: '',
        spareNumber: '',
        classification: '',
        carryQuantity: '',
        unitPrice: '',
        carryingAmount: '',
        autoGeneration: '',
        isModified: ''
      }
    },

    handleFittingsVisible() {
      this.fittingsVisible = false
    },
    handleStructureEquipping() {
      this.$emit('handleStructureEquipping', this.activeRow)
    },

    openFittingsModal() {
      this.fittingsVisible = true
    },
    treeNodeClick(data) {
      this.$refs.table.clearSelection()
      this.fetchTableData()
    },
    fetchTableData() {},
    select(row) {
      this.activeRow = row
      this.fittingsVisible = false
    }
  }
}
</script>

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