<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
      >
      <div class="app-container scroll-y">
        <DataTable
          :tableHeader="state.list"
          :tableData="tableData"
          :tableBtnGroup="tableBtnGroup"
          :tableProperty="{ rowKey: 'ID' }"
          @btnClick="btnClick"
        />
      </div>
      <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="货代名称" size="default">
                  <el-input
                    v-model="tableForm.name"
                    placeholder="请输入货代名称"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="货代编码" size="default">
                  <el-input
                    v-model="tableForm.china"
                    placeholder="请输入货代编码"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="货代描述" size="default">
                  <el-input
                    type="textarea"
                    v-model="tableForm.two"
                    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 tableColsCopys = reactive<Object>({}); //弹窗
const tableForm = reactive({
  name: "",
  china: "",
  two: "",
}); //弹窗内容
//列表
const tableData = ref([
  {
    name: "测试",
    china: "测试",
    englin: "测试",
    two: "测试",
  },
  {
    name: "测试",
    china: "测试",
    englin: "测试",
    two: "测试",
  },
  {
    name: "测试",
    china: "测试",
    englin: "测试",
    two: "测试",
  },
]);
//表头
const state = reactive({
  list: [
    { label: "货代名称", key: "name" },
    { label: "货代编码", key: "china" },
    { label: "货代等级", key: "englin" },
    { label: "货代描述", key: "two" },
  ],
  listLoading: true,
});
const tableBtnGroup = ref([
  {
    name: "编辑",
    className: "editBtn",
    param: 2,
  },
  {
    name: "删除",
    className: "delBtn",
    param: 3,
  },
]);
//新增
const addForm = () => {
  msgTitle.value = "新增货代管理";
  flag.value = true;
  type.value = "";
};
//取消
const resetForm = () => {
  flag.value = false;
  tableForm.name = "";
  tableForm.china = "";
  tableForm.two = "";
};
//编辑
const editDialog = (data) => {
  msgTitle.value = "编辑货代管理";
  flag.value = true;
  type.value = "";
  tableForm.name = data.name;
  tableForm.china = data.china;
  tableForm.two = data.two;
};
//删除
const eleDialog = () => {
  msgTitle.value = "删除货代管理";
  flag.value = true;
  type.value = "del";
};
//删除
const delRest = () => {
  flag.value = false;
};
//编辑-删除
const btnClick = (row, index, param) => {
  if (param === 2) {
    msgTitle.value = "编辑货代管理";
    flag.value = true;
    type.value = "";
    tableForm.name = index.name;
    tableForm.china = index.china;
    tableForm.two = index.two;
  } else if (param === 3) {
    msgTitle.value = "删除货代管理";
    flag.value = true;
    type.value = "del";
  } else if (param === 4) {
  }
};
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__label {
  width: 80px;
}
</style>
