Commit 4b3ecb9b authored by mengwenhao's avatar mengwenhao

Merge branch 'test' of https://git.yidian-inc.com:8021/bp/op-web-service into test

parents 9b2fe1b0 f4835bcb
/*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/5p/f45l166j057533bqfd5n9w880000gp/T/jest_dy",
// Automatically clear mock calls and instances between every test
clearMocks: true,
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,
// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,
// The directory where Jest should output its coverage files
// coverageDirectory: undefined,
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,
// A path to a custom dependency extractor
// dependencyExtractor: undefined,
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
// A set of global variables that need to be available in all test environments
// globals: {},
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
// An array of file extensions your modules use
moduleFileExtensions: ["js", "json", "vue"],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
"@/(.*)$": "<rootDir>/src/$1"
},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
// Activates notifications for test results
// notify: false,
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
// preset: undefined,
// Run tests from one or more projects
// projects: undefined,
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// Automatically reset mock state between every test
// resetMocks: false,
// Reset the module registry before running each individual test
// resetModules: false,
// A path to a custom resolver
// resolver: undefined,
// Automatically restore mock state between every test
// restoreMocks: false,
// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,
// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],
// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: "jsdom",
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
// Adds a location field to test results
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
// This option allows the use of a custom results processor
// testResultsProcessor: undefined,
// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",
// A map from regular expressions to paths to transformers
transform: {
"^.+\\.vue$": "vue3-jest",
"^.+\\.js$": "babel-jest"
}
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
// Indicates whether each individual test should be reported during the run
// verbose: undefined,
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling
// watchman: true,
};
......@@ -11,7 +11,7 @@
"web-dev": "NODE_ENV=development vue-cli-service serve",
"web-test": "NODE_ENV=test vue-cli-service build",
"web-build": "NODE_ENV=production vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:unit": "jest",
"lint": "vue-cli-service lint"
},
"dependencies": {
......@@ -34,6 +34,7 @@
"vuex": "^4.0.0-beta.4"
},
"devDependencies": {
"@testing-library/vue": "^6.4.2",
"@vue/cli-plugin-babel": "^4.5.6",
"@vue/cli-plugin-eslint": "^4.5.6",
"@vue/cli-plugin-unit-jest": "^4.5.6",
......@@ -42,15 +43,18 @@
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/test-utils": "^2.0.0-alpha.1",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.0.6",
"cross-env": "^7.0.3",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^7.0.0-alpha.0",
"jest": "^27.0.6",
"less": "^3.0.4",
"less-loader": "^5.0.0",
"nodemon": "^2.0.7",
"pm2": "3.5.1",
"prettier": "^1.19.1"
"prettier": "^1.19.1",
"vue3-jest": "^27.0.0-alpha.1"
},
"browserslist": [
"> 1%",
......
......@@ -44,7 +44,8 @@ exports.getWithdrawAudit = async ctx => {
url,
method: "POST",
json: true,
body: ctx.request.body
body: ctx.request.body,
timeout: 10000
}
ctx.body = await req(ctx, opts)
}
......
const request = require("request");
exports.httpReq = (ctx, opts) => {
opts.timeout = opts.timeout || 1000;
opts.timeout = opts.timeout || 10000;
return new Promise((resolve, reject) => {
var time_start = +new Date();
......@@ -18,7 +18,8 @@ exports.httpReq = (ctx, opts) => {
request(opts, (err, res, body) => {
console.info(
`[Api] httpReq (${opts.url}, user:[${opts.qs.op_cur_user
`[Api] httpReq (${opts.url}, user:[${
opts.qs.op_cur_user
}]) spent: ${+new Date() - time_start}ms`
);
......@@ -31,5 +32,3 @@ exports.httpReq = (ctx, opts) => {
});
});
};
......@@ -10,24 +10,26 @@
</template>
<script>
import { fetchCurrentUser } from './service/user';
import { redirectToLogin } from './utils/util';
import { fetchCurrentUser } from "./service/user";
import { redirectToLogin } from "./utils/util";
export default {
async mounted () {
console.log("master debug 2 !!!!!!")
if (this.$store.state.permissions && this.$store.state.userInfo) return
async created() {
console.log("master debug 2 !!!!!!");
if (this.$store.state.permissions && this.$store.state.userInfo) return;
const { status, user } = await fetchCurrentUser();
if (status === 'success') {
this.$store.commit('updateUserInfo', user);
this.$store.dispatch('updateUserPermission', { email: user.email })
if (status === "success") {
this.$store.commit("updateUserInfo", user);
this.$store.dispatch("updateUserPermission", { email: user.email });
// 无奈之举,后期需要重构到提现管理中
this.$store.dispatch("fetchPermission", {
appId: "merchant-op-auditing",
});
} else {
redirectToLogin();
}
},
};
</script>
<style lang="less" src="./global.less"></style>
......@@ -70,7 +70,7 @@
<script>
import {
get_role_info as reqGet_role_info,
getAll_role_list as reqGetAll_role_list
getAll_role_list as reqGetAll_role_list,
} from "../../service/role";
export default {
name: "RoleDetail",
......@@ -82,7 +82,7 @@ export default {
multiple: true, //设置为多选
value: "id", //value值和哪个值绑定
label: "desc", //label值和哪个值绑定
children: "sub_permissions" //children值和哪个值绑定
children: "sub_permissions", //children值和哪个值绑定
},
selectedOptions: [],
permissionsAll: [],
......@@ -95,17 +95,17 @@ export default {
update_user_name: "",
create_time: "",
create_user_name: "",
role_account_list: []
}
role_account_list: [],
},
};
},
mounted() {
this.roleId = this.$route.query.roleId;
let { email } = this.$store.state.userInfo;
reqGetAll_role_list(email, this.appId).then(res => {
reqGetAll_role_list(email, this.appId).then((res) => {
this.permissionsAll = res.permissions;
});
reqGet_role_info(this.roleId, this.appId).then(res => {
reqGet_role_info(this.roleId, this.appId).then((res) => {
const {
role_name,
role_status,
......@@ -114,7 +114,7 @@ export default {
create_time,
create_user_name,
role_account_list,
permissions
permissions,
} = res.result;
this.role_info_detail = {
role_name,
......@@ -123,7 +123,7 @@ export default {
update_user_name,
create_time,
create_user_name,
role_account_list
role_account_list,
};
this.editEchoData(permissions);
});
......@@ -135,18 +135,18 @@ export default {
//遍历回显值selectedOptions
editEchoData(permissions) {
let selectData = [];
permissions.map(item => {
permissions.map((item) => {
let one = { id: item.id };
if (item.sub_permissions) {
item.sub_permissions.map(info => {
item.sub_permissions.map((info) => {
let selectId = [one.id, info.id];
selectData.push(selectId);
});
}
});
this.selectedOptions = selectData;
}
}
},
},
};
</script>
<style lang="less" scoped>
......
......@@ -141,31 +141,33 @@ import {
getUpdate_role as reqGetUpdate_role,
get_role_info as reqGet_role_info,
getDelete_role as reqGetDelete_role,
getAdd_role as reqGetAdd_role
getAdd_role as reqGetAdd_role,
} from "../../service/role";
export default {
name: "RoleList",
props: ["appId", "detailPath"],
props: ["appId", "detailPath", "rolePermissionId"],
components: {
page
page,
},
computed: {
permission() {
let rolePermissionId = this.rolePermissionId || "role";
let appId = this.appId || "";
const modulePermissions =
this.$store.getters.moduleSubPermissions("role") || [];
return new Map(modulePermissions.map(ele => [ele.name, true]));
}
this.$store.getters.moduleSubPermissions(rolePermissionId, appId) || [];
return new Map(modulePermissions.map((ele) => [ele.name, true]));
},
},
data() {
return {
searchForm: {
roleName: "",
roleStatus: ""
roleStatus: "",
},
formLabelWidth: "120px",
params: {
page: 1,
page_size: 20
page_size: 20,
},
totalNum: null,
roleTitle: "",
......@@ -175,7 +177,7 @@ export default {
multiple: true, //设置为多选
value: "id", //value值和哪个值绑定
label: "desc", //label值和哪个值绑定
children: "sub_permissions" //children值和哪个值绑定
children: "sub_permissions", //children值和哪个值绑定
},
selectedOptions: [],
dialogVisible: false,
......@@ -184,11 +186,11 @@ export default {
role_info_detail: {
//详情非编辑项
role_id: "",
role_name: ""
role_name: "",
},
permissionsAll: [],
currenPermissionsUpdate: [],
currentRolePrivilege: []
currentRolePrivilege: [],
};
},
beforeMount() {
......@@ -212,12 +214,12 @@ export default {
toRoleDetail(row) {
this.$router.push({
path: this.detailPath,
query: { roleId: row.role_id }
query: { roleId: row.role_id },
});
},
getPermissionsAll() {
let { email } = this.$store.state.userInfo;
reqGetAll_role_list(email, this.appId).then(res => {
reqGetAll_role_list(email, this.appId).then((res) => {
this.permissionsAll = res.permissions;
});
},
......@@ -228,9 +230,9 @@ export default {
page,
page_size,
role_status: this.searchForm.roleStatus,
role_name: this.searchForm.roleName
role_name: this.searchForm.roleName,
};
reqGetRole_list(paramsRole_list, this.appId).then(res => {
reqGetRole_list(paramsRole_list, this.appId).then((res) => {
this.managementList = res.result;
this.totalNum = res.count;
});
......@@ -255,7 +257,7 @@ export default {
this.$confirm(`${this.dialogText}是否继续?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
type: "warning",
})
.then(() => {
if (type === "disable") {
......@@ -267,23 +269,23 @@ export default {
.catch(() => {
this.$message({
type: "info",
message: "已取消"
message: "已取消",
});
});
},
//删除
delete(role_id) {
reqGetDelete_role(role_id, this.appId).then(res => {
reqGetDelete_role(role_id, this.appId).then((res) => {
if (res.status == "success") this.getGetRole_list();
});
},
//角色详情数据
getRole_info_detail(type, role_id) {
reqGet_role_info(role_id, this.appId).then(res => {
reqGet_role_info(role_id, this.appId).then((res) => {
const { role_id, role_name, permissions } = res.result;
this.role_info_detail = {
role_id,
role_name
role_name,
};
this.roleName = role_name;
// this.permissionsUpdate = permissions
......@@ -306,10 +308,10 @@ export default {
//遍历回显值selectedOptions
editEchoData(permissions) {
let selectData = [];
permissions.map(item => {
permissions.map((item) => {
let one = { id: item.id };
if (item.sub_permissions) {
item.sub_permissions.map(info => {
item.sub_permissions.map((info) => {
let selectId = [one.id, info.id];
selectData.push(selectId);
});
......@@ -322,7 +324,7 @@ export default {
if (row.role_status == 1) {
this.$message({
type: "info",
message: "该条数据已启用"
message: "该条数据已启用",
});
return false;
}
......@@ -333,7 +335,7 @@ export default {
if (row.role_status == 2) {
this.$message({
type: "info",
message: "该条数据已禁用"
message: "该条数据已禁用",
});
return false;
}
......@@ -346,9 +348,9 @@ export default {
role_name: role_name,
role_id,
role_status,
permissions
permissions,
};
reqGetUpdate_role(paramsUpdate_role, this.appId).then(res => {
reqGetUpdate_role(paramsUpdate_role, this.appId).then((res) => {
if (res.status === "success") {
this.dialogVisible = false;
this.getGetRole_list();
......@@ -356,7 +358,7 @@ export default {
this.dialogVisible = false;
this.$message({
type: "info",
message: `${res.reason}`
message: `${res.reason}`,
});
}
});
......@@ -383,7 +385,7 @@ export default {
if (!(this.roleName && checkRolePrivilege.length > 0)) {
this.$message({
type: "error",
message: "请完善信息"
message: "请完善信息",
});
return false;
}
......@@ -408,16 +410,16 @@ export default {
getAdd_role() {
let paramsAdd_role = {
role_name: this.roleName,
permissions: this.currenPermissionsUpdate
permissions: this.currenPermissionsUpdate,
};
reqGetAdd_role(paramsAdd_role, this.appId).then(res => {
reqGetAdd_role(paramsAdd_role, this.appId).then((res) => {
this.dialogVisible = false;
if (res.status === "success") {
this.getGetRole_list();
} else {
this.$message({
type: "info",
message: `${res.reason}`
message: `${res.reason}`,
});
}
});
......@@ -427,13 +429,13 @@ export default {
},
getSelectedOptions(selectedOptions) {
let oldDataRule = [];
selectedOptions.forEach(el => {
selectedOptions.forEach((el) => {
let oldObj = {
id: el[0],
sub_permissions: []
sub_permissions: [],
};
let btnObj = {
id: el[1]
id: el[1],
};
oldObj.sub_permissions.push(btnObj);
oldDataRule.push(oldObj);
......@@ -445,11 +447,11 @@ export default {
newData.push(el);
newObj[el.id] = true;
} else {
newData.forEach(el => {
newData.forEach((el) => {
if (el.id === oldDataRule[i].id) {
el.sub_permissions = [
...el.sub_permissions,
...oldDataRule[i].sub_permissions
...oldDataRule[i].sub_permissions,
];
}
});
......@@ -457,8 +459,8 @@ export default {
});
this.currentRolePrivilege = newData;
this.currenPermissionsUpdate = newData;
}
}
},
},
};
</script>
<style lang="less" scoped>
......
......@@ -114,17 +114,17 @@ import {
getUserList as reqGetUserList,
getUserDetail as reqGetUserDetail,
editUser as reqEditUser,
createUser as reqCreateUser
createUser as reqCreateUser,
} from "@/service/user";
export default {
name: "UserList",
props: ["appId"],
props: ["appId", "userPermissionId"],
components: {
page,
UserInfoModal,
UserInfoEditModal,
UserInfoNewModal
UserInfoNewModal,
},
data() {
return {
......@@ -135,7 +135,7 @@ export default {
user_name: "",
user_email: "",
user_mobile: "",
user_status: ""
user_status: "",
},
totalNum: 0,
userList: [],
......@@ -143,30 +143,32 @@ export default {
modalVisable: {
info: false,
edit: false,
new: false
new: false,
},
curOperateMode: "new"
curOperateMode: "new",
};
},
computed: {
permission() {
const appId = this.appId || "";
const userPermissionId = this.userPermissionId || "user";
const modulePermissions =
this.$store.getters.moduleSubPermissions("user") || [];
this.$store.getters.moduleSubPermissions(userPermissionId, appId) || [];
console.log("Current page func-permissions:", modulePermissions);
return new Map(modulePermissions.map(ele => [ele.name, true]));
return new Map(modulePermissions.map((ele) => [ele.name, true]));
},
renderUserList() {
const statusMap = new Map([
[1, "启用"],
[2, "禁用"],
[3, "删除"]
[3, "删除"],
]);
return this.userList.map(ele => {
return this.userList.map((ele) => {
ele.user_status = statusMap.get(ele.user_status);
return ele;
});
}
},
},
beforeMount() {
this.getUserList();
......@@ -187,12 +189,12 @@ export default {
async setCurUserInfo(user_id) {
const { code, result } = await reqGetUserDetail({
appid: this.appId,
user_id
user_id,
});
if (code === 0) {
this.curUserInfo = {
...result.user_info,
roles: result.role_list
roles: result.role_list,
};
} else {
ElMessage.error("获取用户信息出错!");
......@@ -214,7 +216,7 @@ export default {
},
openModal(key) {
Object.keys(this.modalVisable).forEach(ele => {
Object.keys(this.modalVisable).forEach((ele) => {
this.modalVisable[ele] = key === ele;
});
},
......@@ -228,7 +230,7 @@ export default {
user_mobile,
roles,
user_status,
organization
organization,
} = userInfo;
let res = {};
......@@ -241,7 +243,7 @@ export default {
is_sensitive_authority: parseInt(is_sensitive_authority),
user_mobile,
role_id: roles,
user_status: parseInt(user_status)
user_status: parseInt(user_status),
};
res = await reqEditUser(editData, this.appId);
} else if (this.curOperateMode === "new") {
......@@ -252,7 +254,7 @@ export default {
user_mobile,
role_id: roles,
user_status: parseInt(user_status),
organization
organization,
};
res = await reqCreateUser(newData, this.appId);
}
......@@ -283,7 +285,7 @@ export default {
user_name: "",
user_email: "",
user_mobile: "",
user_status: ""
user_status: "",
};
this.getUserList();
},
......@@ -300,7 +302,7 @@ export default {
const { code, reason } = await reqEditUser(
{
user_status: 1,
user_id
user_id,
},
this.appId
);
......@@ -317,7 +319,7 @@ export default {
const { code, reason } = await reqEditUser(
{
user_status: 2,
user_id
user_id,
},
this.appId
);
......@@ -327,8 +329,8 @@ export default {
} else {
ElMessage.error(reason);
}
}
}
},
},
};
</script>
<style lang="less" scoped>
......
<template>
<div>
<layout> 没有权限! </layout>
没有权限!
</div>
</template>
<script>
import Layout from '@/layouts';
export default {
components: {
Layout,
},
};
</script>
......
import { render } from "@testing-library/vue";
import ExaminePage from "..";
import { getApplyList } from "@/service/Withdrawal/withdrawal";
import store from "@/store";
jest.mock("@/service/Withdrawal/withdrawal");
it("should not enable audition for people without such privilege", () => {
const $route = {
path: "/op/withdrawal/examine"
};
getApplyList.mockResolvedValue({
code: 0,
status: "success",
result: {
list: [
{
withdraw_apply_id: "21072711253403105009",
wallet_id: "21072214560673105003",
user_id: 510227177373,
amount: "6.00",
withdraw_apply_status: 0,
withdraw_audit_time: "2021-07-27 11:25:34",
refuse_reason: "",
audit_user_name: "",
create_time: "2021-07-27 11:25:34",
lately_amount: "0.00",
id: "21072711253403105009",
city_name: "简网员工",
lately_share: 0,
lately_download: 0,
history_share: 52,
history_download: 0,
history_download_keep: "0%",
status_text: "待审核"
}
],
count: 1
}
});
const { getByText } = render(ExaminePage, {
store,
global: {
mocks: {
$route,
$store: {
getters: {
moduleSubPermissions: jest.fn().mockReturnValue(true)
}
}
}
}
});
getByText("审核");
});
......@@ -37,7 +37,11 @@
<el-form inline class="search_condition">
<!-- 用户id -->
<el-form-item label="用户id">
<el-input v-model="searchProps.user_id"></el-input>
<el-input v-model="searchProps.user_id" @input="
searchProps.user_id = $event
.replace(/[^a-z0-9A-Z\u4e00-\u9fa5()()\\-]+/g, '')
.replace(/\s/g, '')
"></el-input>
</el-form-item>
<el-button
type="primary"
......@@ -47,12 +51,7 @@
>
</el-form>
<!-- 列表区 -->
<el-table
class="goods_list"
:data="goodsList"
border
stripe
>
<el-table class="goods_list" :data="goodsList" border stripe>
<el-table-column
label="提现用户"
prop="user_id"
......@@ -78,13 +77,23 @@
prop="lately_share"
align="center"
></el-table-column>
<el-table-column
label="近两天分享下载量"
prop="lately_download"
align="center"
></el-table-column>
<el-table-column
label="历史分享增长"
prop="history_share"
align="center"
></el-table-column>
<el-table-column
label="历史分享留存"
label="历史分享下载量"
prop="history_download"
align="center"
></el-table-column>
<el-table-column
label="历史下载留存"
prop="history_download_keep"
align="center"
></el-table-column>
......@@ -107,7 +116,7 @@
></el-table-column>
<!-- 操作快捷键 -->
<el-table-column label="操作" align="center" fixed="right" width="200">
<template #default="scope">
<template v-slot:default="scope">
<el-button
type="text"
@click="handleDetail('look', scope.row.id)"
......@@ -120,7 +129,10 @@
@click="handleDetail('audit', scope.row.id)"
>审核</el-button
>
<el-popconfirm title="确定解冻吗?" @confirm="handleFinzingFind(scope.row.id)">
<el-popconfirm
title="确定解冻吗?"
@confirm="handleFinzingFind(scope.row.id)"
>
<template #reference>
<el-button
type="text"
......@@ -129,7 +141,7 @@
>
</template>
</el-popconfirm>
<!-- <el-button
type="text"
v-if="searchProps.withdraw_apply_status == '3'"
......@@ -223,8 +235,8 @@
label="分享用户量"
width="120"
>
<template #default="scope">
<span>{{ "+" + scope.row.amount }}</span>
<template v-slot:default="scope">
<span>{{ scope ? "+" + scope.row.amount : null }}</span>
</template>
</el-table-column>
<el-table-column
......@@ -267,9 +279,10 @@ import {
getWithdrawAudit,
getApplyDetail,
getFreezingFund,
getAll_role_list,
} from "../../../service/Withdrawal/withdrawal";
getRolesForUser,
} from "@/service/Withdrawal/withdrawal";
import { ElMessage } from "element-plus";
import { fetchCurrentUser } from "../../../service/user";
const TABS = {
pending: "0",
......@@ -304,7 +317,7 @@ export default {
searchProps: {
user_id: "", //用户id
page: 1,
count:0,
count: 0,
page_size: 20, //每页条数
status: TABS.pending, //状态
},
......@@ -331,12 +344,44 @@ export default {
created() {
this.getApplyList();
},
async mounted() {
const res = await this.getPermissionsAll();
if (!res) {
this.$router.push({ name: "Forbidden" });
return;
}
let withdrawlPermission = res.filter(
({ name }) => name === "withdrawal_audit"
);
if (withdrawlPermission.length === 0) {
// push to forbidden
this.$router.push({ name: "Forbidden" });
return;
}
console.log("withdrawlPermission", withdrawlPermission);
withdrawlPermission = withdrawlPermission[0];
// judge subpermission
let subpermissions = withdrawlPermission.sub_permissions.filter(
({ name }) => name === "show"
);
if (subpermissions.length === 0) {
this.$router.push({ name: "Forbidden" });
}
},
methods: {
async getPermissionsAll() {
let { email } = this.$store.state.userInfo;
const res = await getAll_role_list(email);
// 不能够信赖 store 中的 email,无法知道全局中的 fetchCurrentUser 处理完毕
// 是一个重构的点
const { user } = await fetchCurrentUser();
const res = await getRolesForUser(user.email);
this.permissions = res;
return res;
},
// tab切换
handleTabChange() {
this.searchProps.page = 0;
......@@ -403,7 +448,7 @@ export default {
//获取黑名单
handleBlackList(action) {
const {id, user_id, wallet_id } = this.dialogData.showData;
const { id, user_id, wallet_id } = this.dialogData.showData;
const params = {
id,
user_id,
......@@ -473,8 +518,8 @@ export default {
showMode: "audit", //判断是审核还是查看
}),
(this.award = ""), //奖励明细
(this.outerVisible = false) //外层弹框
},
(this.outerVisible = false); //外层弹框
},
},
computed: {
isAllowedToAudit() {
......@@ -485,22 +530,20 @@ export default {
const WITHDRAWAL_PERMISSION_ID = 10;
const withdrawlPermission = this.permissions.filter(
let withdrawlPermission = this.permissions.filter(
(item) => item.id === WITHDRAWAL_PERMISSION_ID
);
// 无此模块权限
if (!withdrawlPermission) {
if (withdrawlPermission.length === 0) {
return false;
}
const AUDIT_PERMSSION_ID = 14;
const auditPermission = withdrawlPermission.filter(
const auditPermission = withdrawlPermission[0].sub_permissions.filter(
(item) => item.id === AUDIT_PERMSSION_ID
);
return !!auditPermission;
return auditPermission.length !== 0;
},
},
};
......
......@@ -3,6 +3,7 @@
<role-list
appId="merchant-op-auditing"
detailPath="/op/withdrawal/roleRoleDetail"
rolePermissionId="role_management"
></role-list>
</layout>
</template>
......
<template>
<layout>
<user-list appId="merchant-op-auditing"></user-list>
<user-list
appId="merchant-op-auditing"
userPermissionId="user_management"
></user-list>
</layout>
</template>
......
......@@ -4,14 +4,17 @@ const headerConfig = [
path: "/op/withdrawal/examine"
},
{
path: '/op/withdrawal/roleManageRole',
name: '角色管理'
path: "/op/withdrawal/roleManageRole",
name: "角色管理",
requireAuthentication: true,
requiredPermission: "role_management"
},
{
path: '/op/withdrawal/user',
name: '用户管理'
path: "/op/withdrawal/user",
name: "用户管理",
requireAuthentication: true,
requiredPermission: "user_management"
}
];
export default headerConfig;
\ No newline at end of file
export default headerConfig;
......@@ -12,16 +12,13 @@
unique-opened
>
<el-menu-item
v-for="item in headerConfig"
v-for="item in visibleMenuItems"
:index="item.path"
:key="item.path"
>
{{ item.name }}
</el-menu-item>
<el-menu-item
key="usermenu"
class="user-menu"
>
<el-menu-item key="usermenu" class="user-menu">
<user></user>
</el-menu-item>
</el-menu>
......@@ -35,22 +32,42 @@ import User from "./User.vue";
export default {
name: "PageHeader",
components: {
User
User,
},
data () {
data() {
return {
headerConfig
headerConfig,
};
},
computed: {
activeMenu () {
activeMenu() {
return this.$route.path;
}
},
visibleMenuItems() {
const visibleMenuItems = this.headerConfig.filter((item) => {
if (!item.requireAuthentication) {
return true;
}
if (this.hasPermission(item.requiredPermission)) {
return true;
}
return false;
});
return visibleMenuItems;
},
},
beforeMount() {},
methods: {
hasPermission(permissionId) {
return (
this.$store.getters.moduleSubPermissions(
permissionId,
"merchant-op-auditing"
).length !== 0
);
},
},
beforeMount () { },
methods: {}
};
</script>
<style lang="less">
</style>
<style lang="less"></style>
......@@ -7,19 +7,26 @@ const withdrawalRoutes = [
{
path: "/op/withdrawal/examine",
name: "Examine",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Examine"),
component: () =>
import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Examine")
},
//用户管理
{
path: "/op/withdrawal/user",
name: "User",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/User/userList"),
component: () =>
import(
/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/User/userList"
)
},
//角色管理
{
path: "/op/withdrawal/roleAddRole",
name: "AddRole",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/add-role"),
component: () =>
import(
/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/add-role"
),
meta: {
requireAuth: true,
keepAlive: true
......@@ -28,7 +35,10 @@ const withdrawalRoutes = [
{
path: "/op/withdrawal/roleManageRole",
name: "ManageRole",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/manage-role"),
component: () =>
import(
/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/manage-role"
),
meta: {
requireAuth: true,
keepAlive: true
......@@ -37,11 +47,11 @@ const withdrawalRoutes = [
{
path: "/op/withdrawal/roleRoleDetail",
name: "RoleDetail",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/role-detail"),
meta: {
keepAlive: true
}
},
component: () =>
import(
/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/role-detail"
)
}
];
export default withdrawalRoutes;
\ No newline at end of file
export default withdrawalRoutes;
......@@ -6,23 +6,28 @@ const getParams = (p = {}) => {
};
// 获取提现审核列表
export async function getApplyList (params) {
const res = await axios.get("/api/v1/get_withdrawal_apply_list", {params: getParams(params)});
return res;
}
// 黑名单,冻结用户
export async function getBlackList (params) {
const res = await axios.post("/api/v1/get_withdrawal_black_list" ,getParams(params));
return res;
}
export async function getApplyList(params) {
const res = await axios.get("/api/v1/get_withdrawal_apply_list", {
params: getParams(params)
});
return res;
}
// 黑名单,冻结用户
export async function getBlackList(params) {
const res = await axios.post(
"/api/v1/get_withdrawal_black_list",
getParams(params)
);
return res;
}
// 获取订单审核--通过,拒绝
export async function getWithdrawAudit (params) {
export async function getWithdrawAudit(params) {
const res = await axios.post("/api/v1/get_withdraw_audit", getParams(params));
return res;
}
// 获取提现失败冻结
export async function getFreezingFund (params) {
const res = await axios.post("/api/v1/get_freezing_fund",getParams(params));
// 获取提现失败冻结
export async function getFreezingFund(params) {
const res = await axios.post("/api/v1/get_freezing_fund", getParams(params));
return res;
}
// 获取提现审核详情
......@@ -33,7 +38,7 @@ export async function getApplyDetail(params) {
return res;
}
//权限列表
export async function getAll_role_list(user_email) {
export async function getRolesForUser(user_email) {
const res = await axios.post(
"/api/v1/merchant/authority/get_role_list?appid=merchant-op-auditing",
{
......
import axios from '../utils/request';
import axios from "../utils/request";
// import qs from 'qs';
//角色列表
export async function getRole_list (parmasRole_list, appid) {
export async function getRole_list(parmasRole_list, appid) {
const opts = {
method: "post",
url: "/api/v1/merchant/authority/role_list",
......@@ -13,7 +13,7 @@ export async function getRole_list (parmasRole_list, appid) {
return await axios(opts);
}
//添加角色
export async function getAdd_role (parmasAdd_role, appid) {
export async function getAdd_role(parmasAdd_role, appid) {
const opts = {
method: "post",
url: "/api/v1/merchant/authority/add_role",
......@@ -25,7 +25,7 @@ export async function getAdd_role (parmasAdd_role, appid) {
// return res;
}
//角色编辑
export async function getUpdate_role (parmasUpdate_role, appid) {
export async function getUpdate_role(parmasUpdate_role, appid) {
const opts = {
method: "post",
url: "/api/v1/merchant/authority/update_role",
......@@ -37,7 +37,7 @@ export async function getUpdate_role (parmasUpdate_role, appid) {
// return res;
}
//角色详情
export async function get_role_info (role_id, appid) {
export async function get_role_info(role_id, appid) {
const opts = {
method: "post",
url: "/api/v1/merchant/authority/get_role_info",
......@@ -52,7 +52,7 @@ export async function get_role_info (role_id, appid) {
// return res.result;
}
//角色删除
export async function getDelete_role (role_id, appid) {
export async function getDelete_role(role_id, appid) {
const opts = {
method: "post",
url: "/api/v1/merchant/authority/delete_role",
......@@ -68,7 +68,7 @@ export async function getDelete_role (role_id, appid) {
}
//权限列表
export async function getAll_role_list (user_email, appid) {
export async function getAll_role_list(user_email, appid) {
const opts = {
method: "post",
url: "/api/v1/merchant/authority/get_role_list",
......
import { createStore } from "vuex";
import { getPermissions } from '@/service/user';
import { PERMISSIONNAME_PAGEMODULE } from '../config/pageconfig'
import { getPermissions } from "@/service/user";
import { PERMISSIONNAME_PAGEMODULE } from "../config/pageconfig";
import { getRolesForUser } from "@/service/Withdrawal/withdrawal";
export default createStore({
state: {
permissions: null,
userInfo: null
userInfo: null,
permissionsForApp: {}
},
mutations: {
updateUserPermission (state, payload) {
updateUserPermission(state, payload) {
state.permissions = payload;
},
updateUserInfo (state, payload) {
updateUserInfo(state, payload) {
state.userInfo = payload;
},
updatePermissionForApp(state, payload) {
const { appId, permissions } = payload;
state.permissionsForApp = state.permissionsForApp || {};
state.permissionsForApp[appId] = permissions;
}
},
actions: {
async updateUserPermission ({ commit }, payload) {
async updateUserPermission({ commit }, payload) {
const { permissions = [] } = await getPermissions(payload.email);
console.log("VUEX action updateUserPermission::", permissions);
commit('updateUserPermission', permissions)
commit("updateUserPermission", permissions);
},
async fetchPermission({ commit }, { email, appId }) {
if (appId === "merchant-op-auditing") {
const permissions = await getRolesForUser(email);
if (!permissions) {
return;
}
const permissionMap = permissions.reduce((prev, permission) => {
prev[permission.name] = permission;
return prev;
}, {});
commit("updatePermissionForApp", { appId, permissions: permissionMap });
return;
}
console.error("无 appId 注册", appId);
}
},
modules: {},
......@@ -29,19 +52,33 @@ export default createStore({
subPermissions: state => {
const permissionCol = {};
(state.permissions || []).forEach(element => {
PERMISSIONNAME_PAGEMODULE[element.name] && (permissionCol[PERMISSIONNAME_PAGEMODULE[element.name]] = element.sub_permissions)
PERMISSIONNAME_PAGEMODULE[element.name] &&
(permissionCol[PERMISSIONNAME_PAGEMODULE[element.name]] =
element.sub_permissions);
});
return permissionCol;
},
/**
*
*
* @param {*} module 模块名,可选值: enterprise, lifeNo, role, user
* @returns
* @returns
*/
moduleSubPermissions: (state) => (module) => {
moduleSubPermissions: state => (module, appId = "") => {
if (appId !== "") {
if (!state.permissionsForApp[appId]) {
return [];
}
if (!state.permissionsForApp[appId][module]) {
return [];
}
return state.permissionsForApp[appId][module].sub_permissions;
}
const permissionCol = {};
(state.permissions || []).forEach(element => {
PERMISSIONNAME_PAGEMODULE[element.name] && (permissionCol[PERMISSIONNAME_PAGEMODULE[element.name]] = element.sub_permissions)
PERMISSIONNAME_PAGEMODULE[element.name] &&
(permissionCol[PERMISSIONNAME_PAGEMODULE[element.name]] =
element.sub_permissions);
});
return permissionCol[module];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment