<template>
  <div class="airportInfo">
    <div class="wrap">
      <Minheader :is-auth="true" :is-statuser="true" @addForm="addForm">
        <template #header>
          <div class="status flex-wrap">
            <div class="manageTitle">机场公司维护</div>
          </div>
        </template></Minheader
      >
      <DataTable
        :tableHeader="state.list"
        :tableData="tableData"
        :tableBtnGroup="tableBtnGroup"
        :tableProperty="{ rowKey: 'ID' }"
        @btnClick="btnClick"
      />
      <Dialog
        :flag="flag"
        :type="type"
        :msgTitle="msgTitle"
        @resetForm="resetForm"
        @delRest="delRest"
      >
        <div class="diacont">
          <el-form :model="tableForm">
            <el-row :gutter="24">
              <el-col>
                <el-form-item label="公司名称">
                  <el-input
                    v-model="tableForm.name"
                    placeholder="请输入公司名称"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="上级公司">
                  <!-- <el-input v-model="tableForm.china" /> -->
                  <el-select
                    style="width: 100%"
                    v-model="tableForm.china"
                    class="input-shadow"
                    size="small"
                    filterable
                    default-first-option
                    clearable
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in tableOptionser"
                      :key="item.v ? item.v : item.planDepartureApt"
                      :label="item.k ? item.k : item.planDepartureApt"
                      :value="item.v ? item.v : item.planDepartureApt"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="公司描述">
                  <el-input
                    type="textarea"
                    v-model="tableForm.englin"
                    placeholder="请输入公司描述"
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </Dialog>
    </div>
  </div>
</template>
<script setup lang="ts">
import DataTable from "@/components/tableTemp/index.vue";
import Minheader from "@/components/minheader/index.vue";
import Dialog from "@/components/dialog/index.vue";
const flag = ref<Boolean>(false); //弹窗开关
const type = ref<String>(""); //判断是否删除
const msgTitle = ref<String>("新增机场公司维护"); //弹窗标题
const tableOptionser = ref<Array>([]); //弹窗下拉
const tableColsCopys = reactive<Object>({}); //弹窗
const tableForm = reactive({
  name: "",
  china: "",
  englin: "",
}); //弹窗内容
const tableBtnGroup = ref([
  {
    name: "编辑",
    className: "editBtn",
    param: 2,
  },
  {
    name: "删除",
    className: "delBtn",
    param: 3,
  },
]);
//列表
const tableData = ref([
  {
    name: "中国国际航空",
    china: "中国国际航空",
    englin: "",
  },
  {
    name: "中国国际航空",
    china: "中国国际航空",
    englin: "",
  },
  {
    name: "中国国际航空",
    china: "中国国际航空",
    englin: "",
  },
]);
//表头
const state = reactive({
  list: [
    { label: "公司名称", key: "name" },
    { label: "公司描述", key: "china" },
    { label: "上级公司", key: "englin" },
  ],
  listLoading: true,
});
//新增
const addForm = () => {
  msgTitle.value = "新增机场公司维护";
  flag.value = true;
  type.value = "";
};
//取消
const resetForm = () => {
  flag.value = false;
  tableForm.name = "";
  tableForm.china = "";
  tableForm.englin = "";
};
//编辑-删除
const btnClick = (row, index, param) => {
  if (param === 2) {
    msgTitle.value = "编辑机场公司维护";
    flag.value = true;
    type.value = "";
    tableForm.name = index.name;
    tableForm.china = index.china;
    tableForm.englin = index.englin;
  } else if (param === 3) {
    msgTitle.value = "删除机场公司维护";
    flag.value = true;
    type.value = "del";
  } else if (param === 4) {
  }
};
//删除
const delRest = () => {
  flag.value = false;
};
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__label {
  width: 100px;
}
</style>
