diff --git a/src/components/registerGlobComp.ts b/src/components/registerGlobComp.ts index 9daebce8..ae2bf508 100644 --- a/src/components/registerGlobComp.ts +++ b/src/components/registerGlobComp.ts @@ -7,6 +7,7 @@ import { Image, Badge, Popover, + QRCode, InputNumber, Empty, Popconfirm, @@ -55,6 +56,7 @@ export function registerGlobComp(app: App) { app.use(Upload) app.use(Badge) app.use(Popover) + app.use(QRCode) app.use(Checkbox) app.use(List) app.use(Space) diff --git a/src/views/baseapi/dict/DictItemList.vue b/src/views/baseapi/dict/DictItemList.vue index 36131f10..dfe75066 100644 --- a/src/views/baseapi/dict/DictItemList.vue +++ b/src/views/baseapi/dict/DictItemList.vue @@ -112,7 +112,7 @@ function add() { dictItemEdit.value.init(null, FormEditType.Add, dictInfo) } - // 查看 + // 编辑 function edit(record) { dictItemEdit.value.init(record.id, FormEditType.Edit, dictInfo) } diff --git a/src/views/daxpay/common/merchant/app/MchAppList.vue b/src/views/daxpay/common/merchant/app/MchAppList.vue index 5e89386d..2f6b13ff 100644 --- a/src/views/daxpay/common/merchant/app/MchAppList.vue +++ b/src/views/daxpay/common/merchant/app/MchAppList.vue @@ -208,7 +208,7 @@ * 收银配置 */ function showCashierConfig(record) { - channelCashierConfigList.value.init(record.appId) + channelCashierConfigList.value.init(record) } /** diff --git a/src/views/daxpay/common/merchant/cashier/ChannelCashierConfig.api.ts b/src/views/daxpay/common/merchant/cashier/ChannelCashierConfig.api.ts index e5bc4940..5643998d 100644 --- a/src/views/daxpay/common/merchant/cashier/ChannelCashierConfig.api.ts +++ b/src/views/daxpay/common/merchant/cashier/ChannelCashierConfig.api.ts @@ -5,8 +5,11 @@ import { MchEntity } from '#/web' /** * 配置列表 */ -export function findAll() { - return defHttp.get>({ url: '/channel/cashier/config/list' }) +export function findAll(appId) { + return defHttp.get>({ + url: '/channel/cashier/config/findByAppId', + params: { appId }, + }) } /** @@ -19,10 +22,30 @@ export function get(id) { }) } +/** + * 配置是否存在 + */ +export function existsByType(appId, type) { + return defHttp.get>({ + url: '/channel/cashier/config/existsByType', + params: { appId, type }, + }) +} + +/** + * 配置是否存在 + */ +export function existsByTypeNotId(appId, type, id) { + return defHttp.get>({ + url: '/channel/cashier/config/existsByTypeNotId', + params: { appId, type, id }, + }) +} + /** * 配置保存 */ -export function save(data: ChannelCashierConfig) { +export function add(data: ChannelCashierConfig) { return defHttp.post>({ url: '/channel/cashier/config/save', data, @@ -44,19 +67,25 @@ export function update(data: ChannelCashierConfig) { */ export function remove(id) { return defHttp.post>({ - url: '/channel/cashier/config/remove', + url: '/channel/cashier/config/delete', params: { id }, }) } +/** + * 获取码牌地址 + */ +export function getQrCodeUrl(appId) { + return defHttp.get>({ + url: '/channel/cashier/config/qrCodeUrl', + params: { appId }, + }) +} + /** * 通道收银台配置 */ -export interface ChannelCashierConfig { - // 商户号 - mchNo?: string - // 应用号 - appId?: string +export interface ChannelCashierConfig extends MchEntity { // 收银台类型 cashierType?: string // 收银台名称 @@ -69,4 +98,6 @@ export interface ChannelCashierConfig { allocation?: boolean // 自动分账 autoAllocation?: boolean + // 备注 + remark?: string } diff --git a/src/views/daxpay/common/merchant/cashier/ChannelCashierConfigEdit.vue b/src/views/daxpay/common/merchant/cashier/ChannelCashierConfigEdit.vue index 0a8d203d..69f6d448 100644 --- a/src/views/daxpay/common/merchant/cashier/ChannelCashierConfigEdit.vue +++ b/src/views/daxpay/common/merchant/cashier/ChannelCashierConfigEdit.vue @@ -1,11 +1,231 @@ - - - + const { + initFormEditType, + handleCancel, + labelCol, + wrapperCol, + modalWidth, + title, + confirmLoading, + visible, + showable, + formEditType, + } = useFormEdit() + + const { dictDropDown } = useDict() + + // 表单 + const formRef = ref() + + const cashierTypeList = ref([]) + const channelList = ref([]) + const methodList = ref([]) + + let form = ref({ + allocation: false, + autoAllocation: false, + }) + // 校验 + const rules = reactive({ + cashierType: [ + { required: true, message: '请选择收银台类型' }, + { validator: validateCode, trigger: 'blur' }, + ], + cashierName: [{ required: true, message: '请输入收银台名称' }], + name: [{ required: true, message: '请输入字典项名称' }], + } as Record) + + // 事件 + const emits = defineEmits(['ok']) + + onMounted(() => { + initData() + }) + + /** + * 初始化数据 + */ + async function initData() { + cashierTypeList.value = await dictDropDown('cashier_type') + channelList.value = await dictDropDown('channel') + methodList.value = await dictDropDown('pay_method') + } + + /** + * 入口 + */ + function init(id, editType: FormEditType, mchApp: MchApp) { + initFormEditType(editType) + resetForm() + form.value.appId = unref(mchApp.appId) + form.value.mchNo = unref(mchApp.mchNo) + getInfo(id, editType) + } + /** + * 获取信息 + */ + function getInfo(id, editType: FormEditType) { + if ([FormEditType.Edit, FormEditType.Show].includes(editType)) { + confirmLoading.value = true + get(id).then(({ data }) => { + form.value = data + confirmLoading.value = false + }) + } else { + confirmLoading.value = false + } + } + /** + * 保存 + */ + function handleOk() { + formRef.value?.validate().then(async () => { + confirmLoading.value = true + if (formEditType.value === FormEditType.Add) { + await add(form.value).finally(() => (confirmLoading.value = false)) + } else if (formEditType.value === FormEditType.Edit) { + await update(form.value).finally(() => (confirmLoading.value = false)) + } + handleCancel() + emits('ok') + }) + } + + /** + * 校验编码重复 + */ + async function validateCode() { + const { cashierType, appId, id } = form.value + if (id) { + const res = await existsByTypeNotId(appId, cashierType, id) + return res.data ? Promise.reject('该收银台类型已存在') : Promise.resolve() + } else { + const res = await existsByType(appId, cashierType) + return res.data ? Promise.reject('该收银台类型已存在') : Promise.resolve() + } + } + + // 重置表单的校验 + function resetForm() { + nextTick(() => { + formRef.value?.resetFields() + }) + } + defineExpose({ + init, + }) + + + diff --git a/src/views/daxpay/common/merchant/cashier/ChannelCashierConfigList.vue b/src/views/daxpay/common/merchant/cashier/ChannelCashierConfigList.vue index 51e9dc5e..91974308 100644 --- a/src/views/daxpay/common/merchant/cashier/ChannelCashierConfigList.vue +++ b/src/views/daxpay/common/merchant/cashier/ChannelCashierConfigList.vue @@ -3,92 +3,105 @@ showFooter v-bind="$attrs" width="70%" - title="通道配置" + title="收银配置" :mask-closable="true" :open="visible" @close="handleCancel" > -
- - - - - -
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/views/daxpay/common/merchant/cashier/ChannelCashierQrCode.vue b/src/views/daxpay/common/merchant/cashier/ChannelCashierQrCode.vue index 0a8d203d..59cfc922 100644 --- a/src/views/daxpay/common/merchant/cashier/ChannelCashierQrCode.vue +++ b/src/views/daxpay/common/merchant/cashier/ChannelCashierQrCode.vue @@ -1,11 +1,82 @@ - - - + const confirmLoading = ref(false) + const visible = ref(false) + const url = ref('') + const qrcodeCanvasRef = ref() + + /** + * 初始化 + */ + function init(appId: string) { + visible.value = true + confirmLoading.value = true + getQrCodeUrl(appId).then((res) => { + url.value = res.data + confirmLoading.value = false + }) + } + + /** + * 复制 + */ + function copy() { + copyText(url.value) + } + /** + * 关闭 + */ + function handleCancel() { + visible.value = false + } + + /** + * 下嘴 + */ + async function download() { + const url = qrcodeCanvasRef.value.toDataURL() + const a = document.createElement('a') + a.download = 'QRCode.png' + a.href = url + document.body.appendChild(a) + a.click() + document.body.removeChild(a) + } + + defineExpose({ + init, + }) + + + diff --git a/src/views/daxpay/common/order/pay/PayOrderInfo.vue b/src/views/daxpay/common/order/pay/PayOrderInfo.vue index 82936dae..5907e46a 100644 --- a/src/views/daxpay/common/order/pay/PayOrderInfo.vue +++ b/src/views/daxpay/common/order/pay/PayOrderInfo.vue @@ -19,6 +19,13 @@ {{ order.refundableBalance }} + + {{ dictConvert('channel', order.channel) }} + + + {{ dictConvert('pay_method', order.method) }} + + {{ dictConvert('pay_status', order.status) }} diff --git a/src/views/iam/role/RolePathModal.vue b/src/views/iam/role/RolePathModal.vue index 3c3d5b79..a8e72b37 100644 --- a/src/views/iam/role/RolePathModal.vue +++ b/src/views/iam/role/RolePathModal.vue @@ -37,7 +37,12 @@