diff --git a/src/api/pay/application.js b/src/api/pay/application.js new file mode 100644 index 0000000..5aee88d --- /dev/null +++ b/src/api/pay/application.js @@ -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', + }); +}; diff --git a/src/api/pay/merchant.js b/src/api/pay/merchant.js index 72b140e..b857ba5 100644 --- a/src/api/pay/merchant.js +++ b/src/api/pay/merchant.js @@ -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', diff --git a/src/store/modules/pay/application.js b/src/store/modules/pay/application.js new file mode 100644 index 0000000..6e33dfe --- /dev/null +++ b/src/store/modules/pay/application.js @@ -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, +}; diff --git a/src/store/modules/pay/merchant.js b/src/store/modules/pay/merchant.js index 6449959..be58c41 100644 --- a/src/store/modules/pay/merchant.js +++ b/src/store/modules/pay/merchant.js @@ -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'; diff --git a/src/views/pay/application/index.vue b/src/views/pay/application/index.vue index c66affc..0186278 100644 --- a/src/views/pay/application/index.vue +++ b/src/views/pay/application/index.vue @@ -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 -->