| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845 |
- <template>
- <div class="content-box">
- <div class="left">
- <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
- <span class="cameratxt">IC卡管理</span>
- </div>
- <div class="middle">
- <div class="filter">
- <div class="condition">
- <span>关键字 : </span>
- <el-input clearable v-model="searchInput.adminName" @clear="searchBtn" class="w-50 m-2"
- placeholder="请输入用户名" style="width: 150px" />
- </div>
- <el-button style="margin-left: 20px" color="rgba(9, 101, 98, 1)" type="primary" class="search"
- @click="searchBtn"><el-icon>
- <Search />
- </el-icon> <span>查询</span></el-button>
- </div>
- <!-- 按钮列表 -->
- <div class="gongneng">
- <el-button type="primary" color="rgba(9, 101, 98, 1)" @click="addlist"><el-icon>
- <CirclePlus />
- </el-icon><span>新增账号</span></el-button>
- </div>
- </div>
- <div class="footer" v-loading="loading">
- <el-table :row-class-name="tableRowClassName" :data="tableData.list" @selection-change="handleSelectionChange"
- style="width: 100%" :header-cell-style="{
- background: 'rgba(240, 243, 247, 1)',
- height: '50px',
- border: 0,
- }">
- <!-- <el-table-column align="center" type="selection" width="80" /> -->
- <el-table-column width="150" align="center" label="序号" type="index" index="1" />
- <el-table-column align="center" prop="corpnPhone" label="手机" />
- <el-table-column align="center" prop="adminName" label="用户名" />
- <el-table-column align="center" prop="corpnName" label="姓名" />
- <el-table-column align="center" label="角色">
- <template #default="{ row }">
- {{ row.level == 1 ? "管理员" : "超级管理员" }}
- </template>
- </el-table-column>
- <el-table-column align="center" prop="remark" label="备注" />
- <el-table-column align="center" label="操作" width="220">
- <template #default="scope">
- <div class="options">
- <div class="reset" @click="reset(scope.row)">密码重置</div>
- <div class="look" @click="edit(scope.row)">修改</div>
- <el-popconfirm width="220" confirm-button-text="确认" cancel-button-text="取消" :icon="InfoFilled"
- icon-color="#f89626" title="是否删除此账号?" @confirm="del(scope.row)" @cancel="cancelEvent">
- <template #reference>
- <div class="del">删除</div>
- </template>
- </el-popconfirm>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <!-- 添加车辆弹窗 -->
- <el-dialog class="addStaff" v-model="addDialogVisible" :close-on-click-modal="false"
- :close-on-press-escape="false" :title="dialongTitle" align-center width="609" :before-close="cancelAdd">
- <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm"
- :size="formSize" label-position="left" status-icon>
- <el-form-item label="用户名 :" prop="adminName">
- <el-input v-model="ruleForm.adminName" placeholder="请输入用户名" clearable />
- </el-form-item>
- <el-form-item label="姓名 :" prop="corpnName">
- <el-input v-model="ruleForm.corpnName" placeholder="请输入姓名" clearable />
- </el-form-item>
- <el-form-item label="手机号码 :" prop="corpnPhone">
- <el-input v-model="ruleForm.corpnPhone" placeholder="请输入手机号码" clearable />
- </el-form-item>
- <el-form-item label="密码 :" prop="password">
- <el-input v-model="ruleForm.password" placeholder="请输入密码" clearable />
- </el-form-item>
- <el-form-item label="确认密码 :" prop="againPass">
- <el-input v-model="ruleForm.againPass" placeholder="请再一次输入密码" clearable />
- </el-form-item>
- <el-form-item label="角色 :" prop="level">
- <el-radio-group v-model="ruleForm.level">
- <el-radio :label="1" v-if="ruleForm.level == 1">管理员</el-radio>
- <el-radio :label="2" v-if="ruleForm.level == 2">超级管理员</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="简介 :" prop="remark">
- <el-input v-model="ruleForm.remark" :rows="3" type="textarea" placeholder="请输入民宿简介信息" />
- </el-form-item>
- <el-form-item class="options">
- <el-button color="rgba(9, 101, 98, 1)" class="queding" type="primary"
- @click="submitAdd(ruleFormRef)">
- 确定
- </el-button>
- <el-button @click="cancelAdd(ruleFormRef)">取消</el-button>
- </el-form-item>
- </el-form>
- </el-dialog>
- </div>
- <!-- 分页组件 -->
- <el-pagination background :current-page="currentPage" :page-size="pageSize"
- layout="total, prev, pager, next, jumper, slot" :total="total" @update:current-page="handleCurrentChange" />
- </div>
- </template>
-
- <script setup>
- import { ref, reactive, nextTick, onBeforeMount, onUnmounted } from "vue";
- import { useRouter } from "vue-router";
- import { ElMessage, ElMessageBox } from "element-plus";
- import { Calendar } from "@element-plus/icons-vue";
- import { dayjs } from "element-plus";
- import lodash, { reduce } from "lodash";
- import axios from "axios";
- import { useStore } from "vuex";
- const store = useStore();
- const router = useRouter();
- // 表格数据
- const loading = ref(false);
- const tableData = reactive({
- list: [
- // {
- // phone: 1234,
- // adminName: "admin",
- // userName: "张三",
- // level: 1,
- // remark: "测试",
- // },
- // {
- // phone: 1234,
- // adminName: "test",
- // userName: "李四",
- // level: 1,
- // remark: "测试11",
- // },
- // {
- // phone: 1234,
- // adminName: "admin1",
- // userName: "张三",
- // level: 1,
- // remark: "测试",
- // },
- // {
- // phone: 1234,
- // adminName: "admin2",
- // userName: "张三",
- // level: 1,
- // remark: "测试",
- // },
- ],
- });
- const activeIndex = ref(); // 默认跳转路由
- const dialongTitle = ref("新增账号"); // 弹窗标题
- const searchInput = reactive({
- adminName: "",
- }); // 搜索按钮数据
- 5;
- const currentPage = ref(1); // 当前页
- const pageSize = ref(10);
- const total = ref(); // 当前总数
- const selectData = reactive({
- list: [],
- }); // 多选框选择的数据
- const api = ref("");
- const addDialogVisible = ref(false); // 控制添加员工弹窗
- // 表单数据
- const formSize = ref("default");
- const ruleFormRef = ref();
- const ruleForm = reactive({
- corpnPhone: "",
- adminName: "",
- corpnName: "",
- level: 1,
- remark: "",
- password: "",
- againPass: "",
- id: "",
- });
- var checkUserName = (rule, value, callback) => {
- if (!value) {
- return callback(new Error("请输入用户名)"));
- }
- var reg = /^[a-zA-Z0-9]{6,16}$/;
- if (!reg.test(value)) {
- callback(new Error("必须为6-16个数字或字母!"));
- } else {
- callback();
- }
- };
- var checkFullName = (rule, value, callback) => {
- if (!value) {
- return callback(new Error("请输入姓名"));
- }
- var reg = /^[\u4e00-\u9fa5]{2,6}$/;
- if (!reg.test(value)) {
- callback(new Error("必须为2-6个汉字!"));
- } else {
- callback();
- }
- };
- var checkPhone = (rule, value, callback) => {
- if (!value) {
- return callback(new Error("请输入手机号"));
- }
- setTimeout(() => {
- var reg = /^1[3456789]\d{9}$/;
- if (!reg.test(value)) {
- callback(new Error("手机号格式不对"));
- } else {
- callback();
- }
- }, 100);
- };
- // 表单验证
- const rules = reactive({
- corpnName: [
- { required: true, message: "姓名不能为空", trigger: "blur" },
- { validator: checkFullName, trigger: "blur" },
- ],
- adminName: [
- { required: true, message: "用户名不能为空", trigger: "blur" },
- { validator: checkUserName, trigger: "blur" },
- ],
- // ^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\._\+(){}])[0-9a-zA-Z!@#$%^&*,\\._\+(){}]{8,20}$
- password: [
- {
- required: true,
- message: "密码不能为空",
- trigger: "blur",
- },
- {
- min: 8,
- max: 20,
- pattern:
- /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\._\+(){}])[0-9a-zA-Z!@#$%^&*,\\._\+(){}]{8,20}$/,
- message: "请输入8-20位正确密码(大小写字母·字符·数字)",
- trigger: "blur",
- },
- ],
- againPass: [
- {
- required: true,
- message: "确认密码不能为空",
- trigger: "blur",
- },
- {
- min: 8,
- max: 20,
- pattern:
- /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\._\+(){}])[0-9a-zA-Z!@#$%^&*,\\._\+(){}]{8,20}$/,
- message: "请输入8-20位正确密码(大小写字母·字符·数字)",
- trigger: "blur",
- },
- ],
- level: [
- {
- required: true,
- message: "角色不能为空",
- trigger: "blur",
- },
- ],
- remark: [
- {
- required: true,
- message: "备注不能为空",
- trigger: "blur",
- },
- ],
- corpnPhone: [
- {
- required: true,
- message: "电话号码不能为空",
- trigger: "blur",
- },
- { validator: checkPhone, trigger: "blur" },
- ],
- // desc: [{ required: true, message: "Please input activity form", trigger: "blur" }],
- });
- // 获取账户列表
- const getList = async () => {
- // if (searchInput.account) {
- // data.adminName = searchInput.adminName;
- // }
- loading.value = true;
- let data = {
- page: currentPage.value, // 当前页
- rows: pageSize.value, // 一页数据条数
- adminName: searchInput.adminName, //用户名
- managerId: sessionStorage.getItem("token"),
- };
- let res = await axios({
- method: "get",
- url: api.value + "/mhotel/managerAdminqueryPage.action",
- headers: {
- // token: sessionStorage.getItem("token"),
- },
- params: data,
- });
- console.log(res, "账号信息");
- if (res.data.code == 200) {
- tableData.list = res.data.data.pageList;
- total.value = res.data.data.total;
- loading.value = false;
- // ElMessage({
- // type: "success",
- // showClose: true,
- // message: res.data.message,
- // center: true,
- // });
- } else {
- loading.value = false;
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- }
- };
- // 搜索功能
- const searchBtn = lodash.debounce(async () => {
- getList();
- }, 300);
- // 添加员工
- const addlist = () => {
- dialongTitle.value = "新增账号";
- addDialogVisible.value = true;
- ruleForm.corpnPhone = "";
- ruleForm.adminName = "";
- ruleForm.corpnName = "";
- ruleForm.level = 1;
- ruleForm.remake = "";
- ruleForm.password = "";
- ruleForm.againPass = "";
- ruleForm.reamark = "";
- };
- // 取消添加员工
- const cancelAdd = () => {
- addDialogVisible.value = false;
- ruleFormRef.value.resetFields();
- };
- //编辑按钮
- const edit = (row) => {
- dialongTitle.value = "编辑信息";
- addDialogVisible.value = true;
- ruleForm.adminName = row.adminName;
- ruleForm.corpnName = row.corpnName;
- ruleForm.level = Number(row.level);
- ruleForm.remark = row.remark;
- ruleForm.password = row.password;
- ruleForm.againPass = row.password;
- ruleForm.corpnPhone = row.corpnPhone;
- ruleForm.id = row.id;
- };
- // 确认添加员工
- const submitAdd = lodash.debounce(async (formEl) => {
- if (!formEl) return;
- await formEl.validate(async (valid, fields) => {
- if (valid) {
- if (dialongTitle.value == "新增账号") {
- if (ruleForm.password == ruleForm.againPass) {
- let data = {
- adminName: ruleForm.adminName,
- corpnName: ruleForm.corpnName,
- level: ruleForm.level,
- remark: ruleForm.remark,
- password: ruleForm.password,
- corpnPhone: ruleForm.corpnPhone,
- managerId: sessionStorage.getItem("token"),
- };
- let res = await axios({
- method: "post",
- url: api.value + "/mhotel/managerAdmininsertAdminManager.action",
- headers: {
- // token: sessionStorage.getItem("token"),
- },
- params: data,
- });
- console.log(res, "添加账号");
- if (res.data.code == 200) {
- getList();
- ElMessage({
- type: "success",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- addDialogVisible.value = false;
- ruleFormRef.value.resetFields();
- } else {
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- }
- } else {
- ElMessage({
- type: "error",
- showClose: true,
- message: "两次密码输入不一致",
- center: true,
- });
- }
- } else {
- if (ruleForm.password == ruleForm.againPass) {
- let data = {
- adminName: ruleForm.adminName,
- corpnName: ruleForm.corpnName,
- level: ruleForm.level,
- remark: ruleForm.remark,
- password: ruleForm.password,
- corpnPhone: ruleForm.corpnPhone,
- id: ruleForm.id,
- };
- let res = await axios({
- method: "post",
- url: api.value + "/mhotel/managerAdminupdateAdminManager.action",
- headers: {
- // token: sessionStorage.getItem("token"),
- // user_head: sessionStorage.getItem("userhead"),
- },
- params: data,
- });
- // console.log(res, "修改账号");
- if (res.data.code == 200) {
- getList();
- ElMessage({
- type: "success",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- addDialogVisible.value = false;
- ruleFormRef.value.resetFields();
- } else {
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- }
- } else {
- ElMessage({
- type: "error",
- showClose: true,
- message: "两次密码输入不一致",
- center: true,
- });
- }
- }
- } else {
- console.log("error submit!", fields);
- }
- });
- }, 1000);
- //删除按钮
- const del = async (row) => {
- // console.log(row);
- let data = {
- id: row.id,
- };
- let res = await axios({
- method: "post",
- url: api.value + "/mhotel/managerAdmindelAdmin.action",
- headers: {
- // token: sessionStorage.getItem("token"),
- // user_head: sessionStorage.getItem("userhead"),
- },
- params: data,
- });
- if (res.data.code == 200) {
- if (tableData.list.length == 1 && currentPage.value != 1) {
- currentPage.value = currentPage.value - 1;
- }
- getList();
- ElMessage({
- type: "success",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- } else {
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- }
- // console.log(res);
- };
- // 取消删除
- const cancelEvent = () => {
- ElMessage({
- type: "info",
- showClose: true,
- message: "取消删除",
- center: true,
- });
- };
- // 重置密码
- const reset = async (row) => {
- // console.log(row);
- let data = {
- id: row.id,
- };
- let res = await axios({
- method: "post",
- url: api.value + "/mhotel/managerAdminremovePwd.action",
- headers: {
- // token: sessionStorage.getItem("token"),
- // user_head: sessionStorage.getItem("userhead"),
- },
- params: data,
- });
- if (res.data.code == 200) {
- getList();
- ElMessage({
- type: "success",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- } else {
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- }
- };
- // 多选框功能
- // const handleSelectionChange = (val) => {
- // console.log(val);
- // selectData.list = val;
- // };
- // 表格斑马纹颜色修改
- const tableRowClassName = ({ row, rowIndex }) => {
- if (rowIndex % 2 === 0) {
- return "even";
- } else if (rowIndex % 2 !== 0) {
- return "odd";
- }
- return "";
- };
- // 分页
- const handleCurrentChange = (value) => {
- // console.log(value);
- currentPage.value = value;
- getList();
- };
- onBeforeMount(() => {
- api.value = store.state.user.api;
- getList();
- });
- onUnmounted(() => {
- // document.removeEventListener("keyup", Enters);
- });
- </script>
-
- <style scoped lang="scss">
- .content-box {
- width: 97.5%;
- height: 89%;
- margin: 20px auto;
- background-color: #fff;
- color: #fff;
- display: flex;
- flex-direction: column;
- box-shadow: 0px 3px 10px rgba(0, 97, 255, 0.2);
- .left {
- // width: calc(100wh - 40px);
- display: flex;
- align-items: center;
- height: 60px;
- margin: 0 30px;
- border-bottom: 1px solid #ccc;
- color: #000;
- font-size: 18px;
- font-weight: 600;
- .camera {
- margin-right: 15px;
- color: #4392f7;
- }
- }
- .middle {
- width: 96%;
- margin: 0 auto;
- color: #000;
- // border-bottom: 1px solid rgb(231, 231, 231);
- .filter {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- margin: 10px 0 0 0;
- .search {
- margin-left: 0 !important;
- color: #fff;
- }
- .condition {
- display: flex;
- align-items: center;
- margin: 10px 30px 10px 0;
- :deep(.el-input .el-input__inner) {
- font-size: 14px;
- }
- span {
- margin: 0 10px 0 0;
- }
- }
- }
- .gongneng {
- margin: 10px 0;
- .el-button {
- color: #fff;
- }
- }
- :deep(.cont) {
- width: 60%;
- margin: 20px auto;
- }
- :deep(.download) {
- display: flex;
- align-items: center;
- margin: 10px;
- }
- :deep(.download span) {
- font-size: 16px;
- margin-left: 20px;
- }
- :deep(.cont .el-button) {
- margin-left: 60px;
- margin-bottom: 30px;
- }
- :deep(.cont .accomplish) {
- width: 100%;
- display: flex;
- justify-content: center;
- }
- :deep(.cont .accomplish .el-button) {
- width: 50%;
- margin: 0;
- }
- }
- .footer {
- width: 96%;
- height: 550px;
- margin: 10px auto 10px;
- .el-table--fit {
- height: 100%;
- :deep(.el-table__header-wrapper) {
- background-color: #000;
- font-size: 15px;
- color: #000;
- .cell {
- color: #000;
- }
- }
- :deep(.el-table__row) {
- height: 50px;
- font-size: 15px;
- color: #000;
- }
- :deep(.el-table__row td) {
- padding: 0;
- border: 0;
- }
- .el-button--primary {
- margin-left: 5px;
- }
- :deep(.el-table__body .even) {
- background-color: #fff;
- }
- :deep(.el-table__body .odd) {
- background-color: rgba(240, 243, 247, 1);
- }
- :deep(.options) {
- display: flex;
- justify-content: center;
- align-items: center;
- .reset {
- color: rgba(9, 101, 98, 1);
- cursor: pointer;
- }
- .look {
- margin: 0 15px;
- color: rgba(30, 125, 251, 1);
- cursor: pointer;
- }
- .del {
- color: rgba(212, 48, 48, 1);
- cursor: pointer;
- }
- }
- }
- // 添加员工弹窗样式
- :deep(.addStaff) {
- // height: 420px;
- border-radius: 11px;
- .el-dialog__header {
- border-radius: 11px 11px 0 0;
- background: rgba(237, 241, 245, 1);
- font-weight: 600;
- margin: 0;
- .el-dialog__headerbtn {
- outline: none;
- }
- }
- .el-dialog__body {
- padding: 30px 20px 10px 20px;
- .el-input {
- width: 200px;
- .el-input__suffix-inner {
- color: rgba(61, 81, 232, 1);
- }
- }
- .options {
- margin: 10px 20px 20px 0;
- width: 100%;
- .el-form-item__content {
- display: flex;
- flex-direction: row-reverse;
- }
- .queding {
- color: #fff;
- margin-left: 15px;
- }
- }
- }
- }
- }
- .el-pagination {
- // width: 1600px;
- width: 96%;
- margin: 20px auto 18px;
- justify-content: flex-end;
- :deep(.el-pagination__total) {
- color: #000;
- }
- :deep(.el-pagination__goto) {
- color: #000;
- }
- :deep(.el-pagination__classifier) {
- color: #000;
- }
- :deep(.el-input__wrapper) {
- border: 1px solid rgba(0, 0, 0, 1);
- border-radius: 5px;
- box-shadow: none;
- }
- :deep(.el-pager li) {
- margin: 0 5px;
- border: 1px solid rgba(0, 0, 0, 1);
- border-radius: 5px;
- background-color: transparent;
- }
- :deep(.el-pager li.is-active) {
- background-color: rgba(111, 182, 184, 1);
- }
- :deep(.btn-prev) {
- margin-right: 5px;
- border: 1px solid rgba(0, 0, 0, 1);
- border-radius: 5px;
- background-color: transparent;
- }
- :deep(.btn-next) {
- margin-left: 5px;
- border: 1px solid rgba(0, 0, 0, 1);
- border-radius: 5px;
- background-color: transparent;
- }
- }
- }
- .el-input {
- width: 192px;
- }
- </style>
-
|