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',
|
||||||
|
});
|
||||||
|
};
|
@ -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,
|
||||||
|
};
|
Loading…
Reference in new issue