<template>
  <div class="airportInfo">
    <div class="headerBox">
      <Minheader :is-Preser="true" :is-statuser="true">
        <template #header>
          <div class="status flex-wrap">
            <div class="manageTitle">编辑源数据信息</div>
          </div>
        </template></Minheader
      >
      <div class="diacont">
        <el-form :model="tableForm" class="w100 fw">
          <div class="outersurface pd30">
            <el-form-item label="源数据名称" size="default">
              <el-input
                v-model="tableForm.name"
                placeholder="请输入源数据名称"
              />
            </el-form-item>
          </div>
          <div class="outersurface pd30">
            <el-form-item label="数据格式" size="default">
              <el-select
                style="width: 100%"
                v-model="tableForm.china"
                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>
          </div>
          <div class="outersurface50">
            <el-form-item label="描述" size="default">
              <el-input v-model="tableForm.englin" placeholder="请输入描述" />
            </el-form-item>
          </div>
          <div class="outersurface50 pd30">
            <el-form-item label="取值方法" size="default">
              <el-input v-model="tableForm.two" placeholder="请输入取值方法" />
            </el-form-item>
          </div>
          <div class="outersurface50">
            <el-form-item label="检测方法" size="default">
              <el-input
                v-model="tableForm.three"
                placeholder="请输入检测方法"
              />
            </el-form-item>
          </div>
        </el-form>
      </div>
    </div>
    <div class="centerBox">
      <Minheader
        :is-auth="true"
        :is-statuser="true"
        :is-Search="true"
        @addForm="addForm"
        style="margin-top: 20px"
      >
        <template #header>
          <div class="status flex-wrap">
            <div class="manageTitle">数据项信息</div>
          </div>
        </template></Minheader
      >
    </div>
    <div class="containers scroll-y">
      <DataTable
        :tableHeader="state.list"
        :tableData="tableData"
        :tableBtnGroup="tableBtnGroup"
        :tableProperty="{ rowKey: 'ID' }"
        @btnClick="btnClick"
      />
    </div>
    <Dialog
      width="748px"
      :flag="flag"
      :type="type"
      :msgTitle="msgTitle"
      @resetForm="resetForm"
      @delRest="delRest"
    >
      <div class="diacont">
        <el-form :model="tableForms">
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="策略名称" size="default">
                <el-input
                  v-model="tableForms.name"
                  placeholder="请输入策略名称"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="数据类型" size="default">
                <el-select
                  style="width: 100%"
                  v-model="tableForms.china"
                  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 :span="12">
              <el-form-item label="取值方法" size="default">
                <el-select
                  style="width: 100%"
                  v-model="tableForms.two"
                  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 :span="12">
              <el-form-item label="输出标识符" size="default">
                <el-input
                  v-model="tableForms.two"
                  placeholder="请输入输出标识符"
                />
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="输出标识符" size="default">
                <el-input
                  type="textarea"
                  v-model="tableForms.three"
                  placeholder="请输入输出标识符"
                />
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="数据项描述" size="default">
                <el-input
                  v-model="tableForms.text"
                  placeholder="请输入数据项描述"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="多条拆分" prop="roleStatus">
                <el-radio-group v-model="tableForms.radio1">
                  <el-radio label="1">是</el-radio>
                  <el-radio label="2"> 否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否必填" prop="roleStatus">
                <el-radio-group v-model="tableForms.radio2">
                  <el-radio label="1">是</el-radio>
                  <el-radio label="2"> 否</el-radio>
                </el-radio-group>
              </el-form-item></el-col
            >
            <el-col :span="12">
              <el-form-item label="是否唯一" prop="roleStatus">
                <el-radio-group v-model="tableForms.radio3">
                  <el-radio label="1">是</el-radio>
                  <el-radio label="2"> 否</el-radio>
                </el-radio-group>
              </el-form-item></el-col
            >
          </el-row>
        </el-form>
      </div>
    </Dialog>
  </div>
</template>

<script setup lang="ts">
import Minheader from "@/components/minheader/index.vue";
import DataTable from "@/components/tableTemp/index.vue";
import Dialog from "@/components/dialog/index.vue";
const tableForm = reactive({
  name: "",
  china: "",
  englin: "",
  two: "",
  three: "",
  text: "",
  time: "",
}); //报警预警场景
const tableForms = reactive({
  name: "",
  china: "",
  englin: "",
  two: "",
  three: "",
  radio1: "1",
  radio2: "1",
  radio3: "1",
}); //弹窗内容
const tableOptionser = ref<Array>([]); //下拉
const flag = ref<Boolean>(false); //弹窗开关
const type = ref<String>(""); //判断是否删除
const msgTitle = ref<String>("新增报警预警策略"); //弹窗标题
//列表
const tableData = ref([
  {
    name: "测试",
    china: "测试",
    englin: "测试",
    two: "测试",
    three: "测试",
  },
  {
    name: "测试",
    china: "测试",
    englin: "测试",
    two: "测试",
    three: "测试",
  },
  {
    name: "测试",
    china: "测试",
    englin: "测试",
    two: "测试",
    three: "测试",
  },
]);
//表头
const state = reactive({
  list: [
    { label: "数据项名称", key: "name" },
    { label: "源数据编号", key: "china" },
    { label: "数据类型", key: "englin" },
    { label: "数据项描述", key: "two" },
    { label: "取值方法", key: "three" },
    { label: "取值表达式", key: "text" },
    { label: "输出标识符", key: "text1" },
    { label: "多条拆分", key: "radio1" },
    { label: "是否必填", key: "radio2" },
    { label: "是否唯一", key: "radio3" },
  ],
  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 delRest = () => {
  flag.value = false;
};
//编辑-删除
const btnClick = (row, index, param) => {
  if (param === 2) {
    msgTitle.value = "编辑报警预警策略";
    flag.value = true;
    type.value = "";
    tableForms.name = index.name;
    tableForms.china = index.china;
    tableForms.englin = index.englin;
    tableForms.two = index.two;
    tableForms.three = index.three;
    tableForms.text = index.text;
    tableForms.text1 = index.text1;
    tableForms.text2 = index.text2;
  } else if (param === 3) {
    msgTitle.value = "删除报警预警策略";
    flag.value = true;
    type.value = "del";
  } else if (param === 4) {
  }
};
</script>

<style lang="scss" scoped>
.airportInfo {
  .headerBox {
    width: 100%;
    min-height: 200px;
    background: #ffffff;
    border-radius: 4px;
    padding: 24px;
    .diacont {
      width: 100%;
      padding: 0;
      .w100 {
        width: 100%;
      }
      .fw {
        display: flex;
        flex-wrap: wrap;
      }
      .outersurface {
        width: 25%;
      }
      .outersurface50 {
        width: 50%;
      }
      .pd30 {
        padding: 0 30px 0 0;
      }
      .outertwowid {
        width: 40%;
      }
      .outerthreewid {
        width: 60%;
      }
    }
  }
  .centerBox {
    padding: 0 24px;
  }
  .containers {
    height: 540px;
  }
}
::v-deep .el-form-item__label {
  width: 90px;
}
</style>
