bug fixed

This commit is contained in:
cxc
2022-10-31 17:45:39 +08:00
parent fd5e278fa7
commit d2163317fe
31 changed files with 1946 additions and 443 deletions

View File

@ -115,6 +115,27 @@
@click="handleDelete(row.id)"
>删除</el-button
>
<el-button
size="small"
type="text"
icon="edit"
@click="openAssignAccount(row.id)"
>分配账号</el-button
>
<el-button
size="small"
type="text"
icon="edit"
@click="openResetPassword(row.id)"
>重置密码</el-button
>
<el-button
size="small"
type="text"
icon="edit"
@click="handleOpenVip(row.id)"
>开通会员</el-button
>
</template>
</el-table-column>
</el-table>
@ -123,7 +144,7 @@
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.page_size"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
@ -173,6 +194,102 @@
</div>
</template>
</el-dialog>
<el-dialog
title="分配账号"
v-model="showAssignAccount"
width="400px"
append-to-body
>
<el-form
:model="assignAccountForm"
:rules="assignAccoutRules"
label-width="80px"
ref="assignAccountFormRef"
>
<el-form-item label="用户名" prop="username">
<el-input v-model="assignAccountForm.username"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input
v-model="assignAccountForm.password"
show-password
></el-input>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitAssignAccount"
> </el-button
>
<el-button @click="closeAssignAccount"> </el-button>
</div>
</template>
</el-dialog>
<el-dialog
title="重置密码"
v-model="showResetPassword"
width="400px"
append-to-body
>
<el-form
:model="resetPasswordForm"
:rules="assignAccoutRules"
label-width="80px"
ref="resetPasswordFormRef"
>
<el-form-item label="密码" prop="password">
<el-input
v-model="resetPasswordForm.password"
show-password
></el-input>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitResetPassword"
> </el-button
>
<el-button @click="closeResetPassword"> </el-button>
</div>
</template>
</el-dialog>
<el-dialog
:title="vipForm.id ? `修改会员` : `开通会员`"
v-model="showOpenVip"
width="400px"
append-to-body
>
<el-form
:model="vipForm"
:rules="assignAccoutRules"
label-width="80px"
ref="vipFormRef"
>
<el-form-item label="会员类型" prop="vipType">
<el-radio-group v-model="vipForm.vipType">
<el-radio label="1">VIP</el-radio>
<el-radio label="2">SVIP</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="到期时间" prop="expireTime">
<el-date-picker
v-model="vipForm.expireTime"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="选择到期时间"
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitVip"> </el-button>
<el-button @click="closeVip"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
@ -181,7 +298,14 @@ import {
companyList,
companyExport,
companyDelete,
allocateAccount,
getAccount,
restPassword,
openCasVip,
getCasVip,
updateCasVip,
} from "@/api/dataList/enterprise";
import md5 from "js-md5";
import { getToken } from "@/utils/auth";
import SiteOptions from "@/views/components/SiteOptions";
// import axios from "axios";
@ -193,7 +317,7 @@ import { tenantSelect } from "@/api/subPlatform/tenant";
import { reactive, ref, toRefs } from "vue";
import { useRouter } from "vue-router";
import { enterpriseOptions } from "@/utils/parameter";
import { ElLoading, ElMessageBox } from "element-plus";
import { ElLoading, ElMessage, ElMessageBox } from "element-plus";
import request from "@/utils/request";
import dayjs from "dayjs";
@ -201,7 +325,7 @@ const router = useRouter();
const data = reactive({
queryParams: {
pageNum: 1,
page_size: 10,
pageSize: 10,
examine_status: 2,
name: undefined,
tenantId: undefined,
@ -249,6 +373,132 @@ const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
const assignAccoutRules = {
username: [{ required: true, message: "请输入用户名", trigger: "blur" }],
password: [{ required: true, message: "请输入密码", trigger: "blur" }],
vipType: [{ required: true, message: "请选择会员类型", trigger: "change" }],
expireTime: [
{ required: true, message: "请选择到期时间", trigger: "change" },
],
};
const showAssignAccount = ref(false);
const assignAccountForm = reactive({
username: undefined,
password: undefined,
});
const assignAccountFormRef = ref();
const resetPasswordForm = reactive({
password: undefined,
});
const resetPasswordFormRef = ref();
const showResetPassword = ref(false);
const openAssignAccount = async (id) => {
resetForm();
const { have, data } = await getAccount(id);
if (have) {
ElMessageBox.alert(`已经存在账号:${data}`, "账号已经存在");
} else {
assignAccountForm.id = id;
showAssignAccount.value = true;
}
};
const openResetPassword = async (id) => {
resetForm();
const { have } = await getAccount(id);
if (have) {
resetPasswordForm.id = id;
showResetPassword.value = true;
} else {
ElMessageBox.alert(`尚未分配账号,请先分配账号`, "尚未分配账号");
}
};
const resetForm = () => {
if (resetPasswordFormRef.value) {
resetPasswordFormRef.value.resetFields();
}
if (assignAccountFormRef.value) {
assignAccountFormRef.value.resetFields();
}
resetPasswordForm.password = undefined;
assignAccountForm.username = undefined;
assignAccountForm.password = undefined;
};
const closeResetPassword = () => {
resetForm();
showResetPassword.value = false;
};
const closeAssignAccount = () => {
resetForm();
showAssignAccount.value = false;
};
const submitAssignAccount = async () => {
await assignAccountFormRef.value.validate();
await allocateAccount({
...assignAccountForm,
password: md5(assignAccountForm.password),
});
ElMessage.success("账号分配成功");
showAssignAccount.value = false;
};
const submitResetPassword = async () => {
await resetPasswordFormRef.value.validate();
await restPassword(resetPasswordForm.id, md5(resetPasswordForm.password));
ElMessage.success("密码重置成功");
showResetPassword.value = false;
};
//TODO:
/** 开通vip操作 */
const vipData = reactive({
vipForm: { userType: "1" },
});
const { vipForm } = toRefs(vipData);
const showOpenVip = ref(false);
const vipFormRef = ref();
const handleOpenVip = async (id) => {
resetVipForm();
const { have, userId } = await getAccount(id);
if (have) {
const resp = await getCasVip(userId);
if (resp.have) {
vipForm.value = resp.data;
showOpenVip.value = true;
} else {
vipForm.value.userId = userId;
showOpenVip.value = true;
}
} else {
ElMessageBox.alert(`尚未分配账号,请先分配账号`, "尚未分配账号");
}
};
const submitVip = async () => {
await vipFormRef.value.validate();
if (vipForm.value.id) {
await updateCasVip(vipForm.value);
ElMessage.success("会员修改成功");
} else {
await openCasVip(vipForm.value);
ElMessage.success("会员开通成功");
}
showOpenVip.value = false;
};
const resetVipForm = () => {
vipForm.value.vipType = undefined;
vipForm.value.expireTime = undefined;
if (vipFormRef.value) {
vipFormRef.value.resetFields();
}
};
const closeVip = () => {
resetVipForm();
showOpenVip.value = false;
};
/** 重置按钮操作 */
const resetQuery = () => {
dateRange.value = [];
@ -300,6 +550,7 @@ const handleFileSuccess = (response, file, fileList) => {
);
getList();
};
/** 提交上传文件 */
function submitFileForm() {
uploadRef.value.submit();