|
@@ -1,13 +1,351 @@
|
|
<template>
|
|
<template>
|
|
|
|
+ <div class="table-box">
|
|
|
|
+ <div class="card table-main">
|
|
|
|
+ <!-- 表格头部 操作按钮 -->
|
|
|
|
+ <div class="table-header">
|
|
|
|
+ <div class="header-button-lf">
|
|
|
|
+ <el-form :model="queryParams" label-width="auto" :inline="true">
|
|
|
|
+ <el-form-item label="账号:">
|
|
|
|
+ <el-input v-model="queryParams.account" style="width: 200px" placeholder="请输入账号" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="姓名:">
|
|
|
|
+ <el-input v-model="queryParams.name" style="width: 200px" placeholder="请输入姓名" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-button type="primary" @click="handleQuery"> 查询 </el-button>
|
|
|
|
+ <el-button style="margin-left: 10px" @click="resetQuery"> 重置 </el-button>
|
|
|
|
+ <el-button style="margin-left: 10px" type="primary" plain @click="handleAdd"> 新增 </el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <!-- 表格主体 -->
|
|
|
|
+ <el-table stripe ref="tableRef" :border="true" :data="processTableData" size="small">
|
|
|
|
+ <el-table-column align="left" label="序号" width="80px" :show-overflow-tooltip="true">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <template v-for="item in columns" :key="item">
|
|
|
|
+ <el-table-column v-bind="item" :align="item.align ?? 'left'" :reserve-selection="item.type == 'selection'" :show-overflow-tooltip="true">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <template v-if="item.prop === 'operation'">
|
|
|
|
+ <el-tooltip
|
|
|
|
+ class="box-item"
|
|
|
|
+ effect="dark"
|
|
|
|
+ content="编辑"
|
|
|
|
+ placement="top"
|
|
|
|
+ >
|
|
|
|
+ <el-button type="primary" link @click="handleUpdate">
|
|
|
|
+ <img class="operation-img" src="@/assets/images/edit.png">
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ <el-tooltip
|
|
|
|
+ class="box-item"
|
|
|
|
+ effect="dark"
|
|
|
|
+ content="删除"
|
|
|
|
+ placement="top"
|
|
|
|
+ >
|
|
|
|
+ <el-button type="primary" link @click="handleDelete(scope.row)">
|
|
|
|
+ <img class="operation-img" src="@/assets/images/delete.png">
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
|
|
|
+ <el-tooltip
|
|
|
|
+ class="box-item"
|
|
|
|
+ effect="dark"
|
|
|
|
+ content="修改密码"
|
|
|
|
+ placement="top"
|
|
|
|
+ >
|
|
|
|
+ <el-button type="primary" link @click="handlePassword(scope.row)">
|
|
|
|
+ <img class="operation-img" src="@/assets/images/password.png">
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </template>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </template>
|
|
|
|
+
|
|
|
|
+ <!-- 无数据 -->
|
|
|
|
+ <template #empty>
|
|
|
|
+ <div class="table-empty">
|
|
|
|
+ <slot name="empty">
|
|
|
|
+ <img src="@/assets/images/notData.png" alt="notData" />
|
|
|
|
+ <div>暂无数据</div>
|
|
|
|
+ </slot>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table>
|
|
|
|
+ <!-- 分页组件 -->
|
|
|
|
+ <Pagination :pageable="pageable" :handle-size-change="handleSizeChange" :handle-current-change="handleCurrentChange" />
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <!-- 添加或修改对话框 -->
|
|
|
|
+ <el-dialog :title="dialog.title" v-model="dialog.visible" width="700px" append-to-body>
|
|
|
|
+ <el-form ref="formRef" :model="userForm" :rules="rules" label-width="120px">
|
|
|
|
+ <el-form-item label="用户账号" prop="account">
|
|
|
|
+ <el-input v-model="userForm.account" placeholder="请输入" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item v-if="dialog.isMode" label="登录密码" prop="password">
|
|
|
|
+ <el-input v-model="userForm.password" type="password" placeholder="请输入" clearable show-password />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item v-if="dialog.isMode" label="确认密码" prop="confirmPassword">
|
|
|
|
+ <el-input v-model="userForm.confirmPassword" type="password" placeholder="请输入" clearable show-password />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="角色" prop="role">
|
|
|
|
+ <el-select v-model="userForm.role" placeholder="请选择" clearable>
|
|
|
|
+ <el-option label="观测员" value="1" />
|
|
|
|
+ <el-option label="预报员" value="2" />
|
|
|
|
+ <el-option label="管理员" value="3" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="关联台站" prop="stations">
|
|
|
|
+ <el-select v-model="userForm.stations" multiple placeholder="请选择" clearable>
|
|
|
|
+ <el-option label="便携站" value="1" />
|
|
|
|
+ <el-option label="固定站" value="2" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="用户姓名" prop="name">
|
|
|
|
+ <el-input v-model="userForm.name" placeholder="请输入" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="职务" prop="post">
|
|
|
|
+ <el-input v-model="userForm.post" placeholder="请输入" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="所属单位" prop="affiliation">
|
|
|
|
+ <el-input v-model="userForm.affiliation" placeholder="请输入" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="联系电话" prop="phone">
|
|
|
|
+ <el-input v-model="userForm.phone" placeholder="请输入" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <template #footer>
|
|
|
|
+ <div class="dialog-footer">
|
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-dialog>
|
|
|
|
+
|
|
|
|
+ <!-- 修改密码对话框 -->
|
|
|
|
+ <el-dialog :title="dialogPassword.title" v-model="dialogPassword.visible" width="700px" append-to-body>
|
|
|
|
+ <el-form ref="formRef" :model="userForm" :rules="rules" label-width="120px">
|
|
|
|
+ <el-form-item label="用户账号" >
|
|
|
|
+ <el-input v-model="userForm.account" disabled placeholder="请输入" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="登录密码" prop="password">
|
|
|
|
+ <el-input v-model="userForm.password" type="password" placeholder="请输入" clearable show-password />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="确认密码" prop="confirmPassword">
|
|
|
|
+ <el-input v-model="userForm.confirmPassword" type="password" placeholder="请输入" clearable show-password />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <template #footer>
|
|
|
|
+ <div class="dialog-footer">
|
|
|
|
+ <el-button @click="cancelPassword">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="submitFormPassword">确 定</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
|
-export default {
|
|
|
|
- name: "index"
|
|
|
|
|
|
+<script setup lang="ts" name="useProTable">
|
|
|
|
+import Pagination from "@/components/ProTable/components/Pagination.vue";
|
|
|
|
+import { ref, reactive } from "vue";
|
|
|
|
+import { ColumnProps } from "@/components/ProTable/interface";
|
|
|
|
+import { ElMessageBox } from 'element-plus'
|
|
|
|
+const pageable = ref<any>({
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: 20,
|
|
|
|
+ total: 1
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const queryParams = ref({
|
|
|
|
+ account:'',
|
|
|
|
+ name: '',
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: 20,
|
|
|
|
+ total: 2
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+// 查询功能
|
|
|
|
+const handleQuery = () => {
|
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+//搜索功能
|
|
|
|
+const resetQuery = () => {
|
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @description 每页条数改变
|
|
|
|
+ * @param {Number} val 当前条数
|
|
|
|
+ * @return void
|
|
|
|
+ * */
|
|
|
|
+const handleSizeChange = (val: number) => {
|
|
|
|
+ console.log(val);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @description 当前页改变
|
|
|
|
+ * @param {Number} val 当前页
|
|
|
|
+ * @return void
|
|
|
|
+ * */
|
|
|
|
+const handleCurrentChange = (val: number) => {
|
|
|
|
+ console.log(val);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const processTableData = ref([
|
|
|
|
+ {
|
|
|
|
+ id: "681913747276782417",
|
|
|
|
+ a: "www",
|
|
|
|
+ b: "王武",
|
|
|
|
+ c: "装备保障人员",
|
|
|
|
+ d: "装备保障人员",
|
|
|
|
+ e: "某个气象局",
|
|
|
|
+ f: "13312341234",
|
|
|
|
+ g: "便携站1,固定站1",
|
|
|
|
+ }
|
|
|
|
+]);
|
|
|
|
+
|
|
|
|
+// 表格配置项
|
|
|
|
+const columns = reactive<ColumnProps[]>([
|
|
|
|
+ { prop: "a", label: "用户账号" },
|
|
|
|
+ { prop: "b", label: "用户姓名" },
|
|
|
|
+ { prop: "c", label: "角色" },
|
|
|
|
+ { prop: "d", label: "职务" },
|
|
|
|
+ { prop: "e", label: "所属单位" },
|
|
|
|
+ { prop: "f", label: "联系电话" },
|
|
|
|
+ { prop: "g", label: "台站",width:250 },
|
|
|
|
+ { prop: "operation", label: "操作", width:150,align: 'center' }
|
|
|
|
+]);
|
|
|
|
+
|
|
|
|
+const dialog = reactive<any>({
|
|
|
|
+ visible: false,
|
|
|
|
+ title: '',
|
|
|
|
+ isMode: true
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const dialogPassword = reactive<any>({
|
|
|
|
+ visible: false,
|
|
|
|
+ title: ''
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const formRef = ref<any>();
|
|
|
|
+const rules = ref<any>(
|
|
|
|
+ {
|
|
|
|
+ account: [{ required: true, message: "用户账号不能为空", trigger: "blur" }],
|
|
|
|
+ password: [{ required: true, message: "登录密码不能为空", trigger: "blur" }],
|
|
|
|
+ confirmPassword: [{ required: true, message: "确认密码不能为空", trigger: "blur" }],
|
|
|
|
+ role: [{ required: true, message: "角色不能为空", trigger: "blur" }],
|
|
|
|
+ stations: [{ required: true, message: "关联台站不能为空", trigger: "blur" }],
|
|
|
|
+ }
|
|
|
|
+);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+const initFormData = ref<any>(
|
|
|
|
+ {
|
|
|
|
+ account: "Admin",
|
|
|
|
+ password: "",
|
|
|
|
+ confirmPassword: "",
|
|
|
|
+ role: "",
|
|
|
|
+ stations:[],
|
|
|
|
+ name: "",
|
|
|
|
+ post: "",
|
|
|
|
+ affiliation: "",
|
|
|
|
+ phone: ""
|
|
|
|
+ }
|
|
|
|
+);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+const userForm = ref<any>({
|
|
|
|
+ account: "Admin",
|
|
|
|
+ password: "",
|
|
|
|
+ confirmPassword: "",
|
|
|
|
+ role: "",
|
|
|
|
+ stations:[],
|
|
|
|
+ name: "",
|
|
|
|
+ post: "",
|
|
|
|
+ affiliation: "",
|
|
|
|
+ phone: ""
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+/** 新增按钮操作 */
|
|
|
|
+const handleAdd = () => {
|
|
|
|
+ reset();
|
|
|
|
+ dialog.visible = true;
|
|
|
|
+ dialog.title = "新增用户";
|
|
|
|
+ dialog.isMode = true;
|
|
}
|
|
}
|
|
-</script>
|
|
|
|
|
|
|
|
-<style scoped>
|
|
|
|
|
|
+/** 修改按钮操作 */
|
|
|
|
+const handleUpdate = async (row?: any) => {
|
|
|
|
+ reset();
|
|
|
|
+ dialog.visible = true;
|
|
|
|
+ dialog.title = "编辑用户";
|
|
|
|
+ dialog.isMode = false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 修改密码按钮操作 */
|
|
|
|
+const handlePassword = async (row?: any) => {
|
|
|
|
+ reset();
|
|
|
|
+ dialogPassword.visible = true;
|
|
|
|
+ dialogPassword.title = "修改密码";
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 修改密码取消按钮 */
|
|
|
|
+const cancelPassword = () => {
|
|
|
|
+ reset();
|
|
|
|
+ dialogPassword.visible = false;
|
|
|
|
+}
|
|
|
|
|
|
-</style>
|
|
|
|
|
|
+
|
|
|
|
+/** 修改密码提交按钮 */
|
|
|
|
+const submitFormPassword = () => {
|
|
|
|
+ formRef.value?.validate(async (valid: boolean) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ dialogPassword.visible = false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/** 取消按钮 */
|
|
|
|
+const cancel = () => {
|
|
|
|
+ reset();
|
|
|
|
+ dialog.visible = false;
|
|
|
|
+}
|
|
|
|
+/** 表单重置 */
|
|
|
|
+const reset = () => {
|
|
|
|
+ userForm.value = { ...initFormData };
|
|
|
|
+ formRef.value?.resetFields();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 提交按钮 */
|
|
|
|
+const submitForm = () => {
|
|
|
|
+ formRef.value?.validate(async (valid: boolean) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ dialog.visible = false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 删除按钮操作 */
|
|
|
|
+const handleDelete = async (row?: any) => {
|
|
|
|
+ ElMessageBox.confirm('是否确认删除账号为"' + row.a + '"的数据项?', {
|
|
|
|
+ confirmButtonText: '删除',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning',
|
|
|
|
+ title:'删除数据',
|
|
|
|
+ draggable: true
|
|
|
|
+ })
|
|
|
|
+ .then(() => {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+</script>
|