<template>
  <div class="airportInfo scroll-y">
    <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-containers">
        <DataTable
          :tableHeader="tableCols"
          :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-select
                    style="width: 100%"
                    v-model="tableForm.name"
                    class="input-shadow"
                    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="源数据名称" size="default">
                  <el-input
                    v-model="tableForm.china"
                    placeholder="请输入源数据名称"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="数据格式" size="default">
                  <el-select
                    style="width: 100%"
                    v-model="tableForm.englin"
                    class="input-shadow"
                    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="描述" size="default">
                  <el-input
                    type="textarea"
                    v-model="tableForm.two"
                    placeholder="请输入描述"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="取值方法" size="default">
                  <el-input
                    type="textarea"
                    v-model="tableForm.three"
                    placeholder="请输入取值方法"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="检测方法" size="default">
                  <el-input
                    type="textarea"
                    v-model="tableForm.text"
                    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";
import { Query, GeneralDataReception } from "@/api/webApi";
import { ElMessage } from "element-plus";
const page = ref<number>(0); //分页参数
const dataContent = ref<object>({});
const noMore = ref<Boolean>(false);
const asShow = ref<Boolean>(false);
const rowTitle = ref<String>("");
const tableCols = ref([]); //表头数据
const serviceId = ref<String>("");
const tableObj = ref({}); //增删改数据缓存
const router = useRouter();
const flag = ref<Boolean>(false); //弹窗开关
const type = ref<String>(""); //判断是否删除
const msgTitle = ref<String>("新增源数据管理"); //弹窗标题
const tableColsCopys = reactive<Object>({}); //弹窗
const tableOptionser = ref<Array>([]); //弹窗下拉
const tableForm = reactive({
  name: "",
  china: "",
  englin: "",
  two: "",
  three: "",
  text: "",
}); //弹窗内容
//列表
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.englin = "";
  tableForm.two = "";
  tableForm.three = "";
  tableForm.text = "";
};
//编辑
// const editDialog = (data) => {
//   msgTitle.value = "编辑航司信息维护";
//   flag.value = true;
//   type.value = "";
//   tableForm.name = data.name;
//   tableForm.china = data.china;
//   tableForm.englin = data.englin;
//   tableForm.two = data.two;
//   tableForm.three = data.three;
//   tableForm.text = data.text;
// };
//编辑-删除
const btnClick = (row, index, param) => {
  if (param === 2) {
    router.push({ path: "/systemSettings/sourceserviceEdit" });
    // msgTitle.value = "编辑源数据管理";
    // flag.value = true;
    // type.value = "";
    // tableForm.name = index.name;
    // tableForm.china = index.china;
    // tableForm.englin = index.englin;
    // tableForm.two = index.two;
    // tableForm.three = index.three;
    // tableForm.text = index.text;
  } else if (param === 3) {
    msgTitle.value = "删除源数据管理";
    flag.value = true;
    type.value = "del";
  } else if (param === 4) {
  }
};
//删除
const eleDialog = () => {
  msgTitle.value = "删除源数据管理";
  flag.value = true;
  type.value = "del";
};
//删除
const delRest = () => {
  flag.value = false;
};
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__label {
  width: 100px;
}
.app-containers {
  height: calc(100vh - 180px);
}
</style>
