feat: 应用管理

feature/pay-0704-ch
ch 2 years ago
parent f58303e37f
commit 2be7fceb7b

@ -0,0 +1,54 @@
/*
* @Author: ch
* @Date: 2022-07-04 15:20:02
* @LastEditors: ch
* @LastEditTime: 2022-07-06 14:27:54
* @Description: file content
*/
import request from '@/utils/request.js';
export const create = (data) => {
return request({
url: '/payCenter/mchInfo',
method: 'post',
data,
});
};
export const del = (mchPrimaryId) => {
return request({
url: `/payCenter/mchInfo/${mchPrimaryId}`,
method: 'delete',
});
};
export const detail = (mchPrimaryId) => {
return request({
url: `/payCenter/mchInfo/${mchPrimaryId}`,
method: 'get',
});
};
export const update = (data) => {
return request({
url: '/payCenter/mchInfo',
method: 'put',
data,
});
};
export const updateStatus = (params) => {
return request({
url: `/payCenter/appInfo/updateStatus`,
method: 'put',
params,
});
};
export const getApplicationList = (params) => {
return request({
url: '/payCenter/appInfo/page',
method: 'get',
params,
});
};
export const getPayType = () => {
return request({
url: '/payCenter/appInfo/payCode',
method: 'get',
});
};

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-07-04 15:20:02
* @LastEditors: ch
* @LastEditTime: 2022-07-06 10:09:07
* @LastEditTime: 2022-07-06 14:14:31
* @Description: file content
*/
import request from '@/utils/request.js';
@ -46,6 +46,12 @@ export const getMerchantList = (params) => {
params,
});
};
export const getMerchantSelector = () => {
return request({
url: '/payCenter/mchInfo/mchSelector',
method: 'get',
});
};
export const getMerchantPlatform = (params) => {
return request({
url: '/payCenter/mchInfo/mchCode',

@ -0,0 +1,112 @@
/*
* @Author: ch
* @Date: 2022-07-04 15:21:30
* @LastEditors: ch
* @LastEditTime: 2022-07-06 14:31:27
* @Description: file content
*/
import * as api from '@/api/pay/application.js';
import * as mchApi from '@/api/pay/merchant.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
const state = {
code: 'PayApplicationManagement',
list: [],
detail: {},
total: 0,
opts: {
status: [
{
value: false,
label: '启用',
},
{
value: true,
label: '禁用',
},
],
merchant: [],
payType: [],
},
};
const getters = {};
const mutations = {
setList: (state, data) => (state.list = data),
setPayType: (state, data) => (state.opts.payType = data),
setMerchant: (state, data) => (state.opts.merchant = data),
setTotal: (state, data) => (state.total = data),
setDetail: (state, data) => (state.detail = data),
};
const actions = {
async search({ rootGetters, commit }, params) {
const res = await api.getApplicationList({
...rootGetters['local/page'](state.code),
...params,
});
if (res) {
commit('setList', res?.records.map((i) => ({ ...i, isShow: !i.isDisabled })) || []);
commit('setTotal', res?.total || 0);
}
},
async save({ dispatch }, data) {
let save = data.mchPrimaryId ? api.update : api.create;
let res = await save(data);
if (res) {
ElMessage.success('保存成功');
dispatch('search');
} else {
ElMessage.error('保存失败');
}
return res;
},
detail: async (context, id) => {
let res = await api.detail(id);
if (!res) {
ElMessage.error('加载详情失败');
}
return res;
},
del: async ({ dispatch }, id) => {
try {
await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
let res = await api.del(id);
if (res) {
ElMessage.success('删除成功');
dispatch('search');
} else {
ElMessage.error('删除失败');
}
return res;
} catch (e) {
console.info('取消删除', e);
}
},
async updateStatus({ dispatch }, data) {
let res = await api.updateStatus(data);
if (res) {
ElMessage.success('保存成功');
dispatch('search');
} else {
ElMessage.error('保存失败');
}
return res;
},
async getMerchantList({ commit }) {
const res = await mchApi.getMerchantSelector();
if (res) {
commit('setMerchant', res || []);
}
},
async getPayType({ commit }) {
const res = await api.getPayType();
if (res) {
commit('setPayType', res || []);
}
},
};
export default {
state,
getters,
mutations,
actions,
};

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-07-04 15:21:30
* @LastEditors: ch
* @LastEditTime: 2022-07-06 11:16:50
* @LastEditTime: 2022-07-06 11:26:06
* @Description: file content
*/
import * as api from '@/api/pay/merchant.js';

@ -2,38 +2,48 @@
* @Author: ch
* @Date: 2022-06-15 17:29:32
* @LastEditors: ch
* @LastEditTime: 2022-07-04 16:56:20
* @LastEditTime: 2022-07-06 14:31:59
* @Description: file content
-->
<template>
<table-list
v-loading="loading"
:operation="['search']"
:code="_pagingCode"
:code="code"
:config="config"
:data="list"
:total="total"
:operation="['create', 'search']"
:reset="handleReset"
title="商户"
:total="total"
@create="handleCreate"
@search="handleSearch"
@create="handleCreate()"
:reset="handleReset"
>
<template #search>
<el-form inline>
<el-form-item label="商户名称">
<el-input v-model="state.condition.mchName" />
<el-form-item label="所属商户">
<el-select v-model="state.condition.mchPrimaryId">
<el-option
v-for="item in opts.merchant"
:key="item.mchPrimaryId"
:label="item.mchName"
:value="item.mchPrimaryId"
/>
</el-select>
</el-form-item>
<el-form-item label="商户ID">
<el-input v-model="state.condition.mchId" />
<el-form-item label="应用名称">
<el-input v-model="state.condition.appName" />
</el-form-item>
<el-form-item label="商户平台">
<el-select v-model="state.condition.mchCode">
<el-form-item label="应用ID">
<el-input v-model="state.condition.appId" />
</el-form-item>
<el-form-item label="支付方式">
<el-select v-model="state.condition.payCode">
<el-option
v-for="(item, idx) in opts.platform"
v-for="(item, idx) in opts.payType"
:key="idx"
:label="item.text"
:value="item.code"
></el-option>
/>
</el-select>
</el-form-item>
<el-form-item label="商户状态">
@ -43,7 +53,7 @@
:key="idx"
:label="item.label"
:value="item.value"
></el-option>
/>
</el-select>
</el-form-item>
</el-form>
@ -57,17 +67,17 @@
const store = useStore();
const loading = ref(false);
//
const opts = computed(() => store.state.merchant.opts);
const opts = computed(() => store.state.application.opts);
//
const list = computed(() => _.cloneDeep(store.state.merchant.list));
const total = computed(() => store.state.merchant.total);
// code使codesotre
const _pagingCode = 'PayMerchantManagement';
const code = computed(() => store.state.application.code);
const list = computed(() => _.cloneDeep(store.state.application.list));
const total = computed(() => store.state.application.total);
//
const _condition = {
mchCode: '',
mchId: '',
mchName: '',
mchPrimaryId: '',
payCode: '',
appId: '',
appName: '',
isDisabled: null,
};
const state = reactive({
@ -79,11 +89,12 @@
*/
const handleSearch = async () => {
loading.value = true;
await store.dispatch('merchant/search', { ...state.condition, pagingCode: _pagingCode });
await store.dispatch('application/search', { ...state.condition });
loading.value = false;
};
store.dispatch('merchant/getMerchantPlatform');
store.dispatch('application/getMerchantList');
store.dispatch('application/getPayType');
onActivated(handleSearch);
/**
* 重置
@ -91,28 +102,61 @@
const handleReset = () => {
state.condition = { ..._condition };
};
const handleCreate = () => {};
const handleCreate = () => {
router.push('./create');
};
const handleShowHide = (row) => {
store.dispatch('application/updateStatus', {
appPrimaryId: row.appPrimaryId,
isDisabled: !row.isShow,
});
};
const handleEdit = (id) => {
router.push({
path: './update',
params: {
id,
},
});
};
const handleDelete = (id) => {
store.dispatch('application/del', id);
};
const config = reactive({
columns: [
{
label: '商户名称',
label: '应用名称',
align: 'left',
prop: 'appName',
},
{
label: '应用代号',
align: 'left',
prop: 'mchName',
prop: 'appCode',
},
{
label: '商户ID',
label: '应用ID',
align: 'left',
prop: 'mchId',
prop: 'appId',
},
{
label: '商户平台',
label: '所属商户',
width: 120,
prop: 'mchCode',
slots: {
default: ({ row }) => <span>{row.mchInfo.mchName}</span>,
},
},
{
label: '商户状态',
label: '支付方式',
width: 120,
prop: 'isDisabledDesc',
prop: 'payCodes',
},
{
label: '状态',
width: 80,
slots: {
default: ({ row }) => <ElSwitch v-model={row.isShow} onChange={() => handleShowHide(row)} />,
},
},
{
label: '创建时间',
@ -121,12 +165,17 @@
},
{
label: '操作',
width: 70,
width: 120,
slots: {
default: ({ row }) => (
<ElButton type="text" onClick={() => handleDetail(row.id)}>
查看
</ElButton>
<div>
<ElButton type="text" onClick={() => handleEdit(row.mchPrimaryId)}>
编辑
</ElButton>
<ElButton type="text" onClick={() => handleDelete(row.mchPrimaryId)}>
删除
</ElButton>
</div>
),
},
},

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-06-15 17:29:32
* @LastEditors: ch
* @LastEditTime: 2022-07-06 11:19:31
* @LastEditTime: 2022-07-06 14:34:01
* @Description: file content
-->
<template>
@ -125,7 +125,7 @@
{
label: '商户平台',
width: 120,
prop: 'mchCode',
prop: 'mchCodeText',
},
{
label: '状态',

Loading…
Cancel
Save