<!-- 用户管理 -->
<template>
  <div class="app-container">
    <!-- 用户新增/编辑表单 -->
    <el-card shadow="never" class="form-container" v-loading="loading">
      <template #header>添加工具链</template>
      <el-row>
        <el-col :lg="12" :xs="24">
          <el-form
            ref="userFormRef"
            :model="formData"
            :rules="rules"
            label-width="100px"
          >
          <el-divider content-position="left"
              ><strong style="color: #409eff">未注册工具链</strong></el-divider
            >
            <el-table :data="list" style="width: 100%" stripe>
              <el-table-column
      type="selection"
      width="55">
    </el-table-column>
              <el-table-column prop="csmc" label="IP地址" align="left"/>
              <el-table-column prop="csmc" label="类型" align="left"/>
              <el-table-column prop="csmc1" label="ID编号" align="left"/>
              <el-table-column prop="csmc2" label="厂商名称" align="left"/>
              <el-table-column prop="csmc3" label="服务程序版本" align="left"/>
              <el-table-column prop="csmc4" label="连接状态" align="left"/>
            </el-table>
            <el-divider content-position="left"
              ><strong style="color: #409eff">工具链信息</strong></el-divider
            >
            <el-form-item label="工具链名称" prop="username">
              <el-input
                v-model="formData.username"
                :readonly="!!formData.id"
                placeholder="请输入工具链名称"
              />
            </el-form-item>
            <el-form-item label="工具链标签" prop="nickname">
              <el-input v-model="formData.nickname" placeholder="请输入工具链标签" />
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :lg="12" :xs="24">
        </el-col>
      </el-row>
    </el-card>
    <el-card class="button-scope">
      <div class="buttonml-55">
        <el-button type="primary" @click="handleSubmit"><i-ep-check />确 定</el-button>
        <el-button @click="closeBack"><i-ep-close />取 消</el-button>
      </div>
    </el-card>
  </div>
</template>

<script setup lang="ts">
defineOptions({
  name: "User",
  inheritAttrs: false,
});

import UserAPI from "@/api/user";
import { UserForm } from "@/api/user/model";

const router = useRouter();
const loading = ref(false); //  加载状态

const calTypeList = ref<OptionType[]>(); // 角色下拉数据源

// 用户表单数据
const formData = reactive<UserForm>({
  status: 1,
});

// 校验规则
const rules = reactive({
  username: [{ required: true, message: "用户名不能为空", trigger: "blur" }],
  nickname: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
  deptId: [{ required: true, message: "所属部门不能为空", trigger: "blur" }],
  roleIds: [{ required: true, message: "用户角色不能为空", trigger: "blur" }],
  email: [
    {
      pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/,
      message: "请输入正确的邮箱地址",
      trigger: "blur",
    },
  ],
  mobile: [
    {
      pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
      message: "请输入正确的手机号码",
      trigger: "blur",
    },
  ],
});

const list = [
  {
    csmc: "10.0.8.12",
    csms: "DOCKER-TOOL",
    csmc1:"acd0032a-6833-4348-b0fc-04798f94354c",
    csmc2:"华为",
    csmc3:"1.2",
    csmc4:"已连接",
  },
  {
    csmc: "192.10.71.44",
    csms: "ETL",
    csmc1:"ac1232a-6233-4348-b0fc-04798f94551",
    csmc2:"华为",
    csmc3:"1.2",
    csmc4:"已连接",
  },
];

/** 表单提交 */
const handleSubmit = useThrottleFn(() => {
  loading.value = true;
  setTimeout(() => {
    ElMessage.success("保存成功");
    loading.value = false;
    closeBack();
  }, 1000);
}, 3000);

/** 返回默认页面 */
function closeBack() {
  router.replace({ path: "/tester/otherTool" });
}

onMounted(() => {
  //handleQuery();
});
</script>
<style scope>
.button-scope {
  position: fixed;
  width: calc(100% - 220px);
  bottom: 0px;
}
.buttonml-55 {
  margin-left: 55px;
}
</style>
