diff --git a/src/api/platform/common/controller/pushConcernFanType.ts b/src/api/platform/common/controller/pushConcernFanType.ts index d389872..1a8ba40 100644 --- a/src/api/platform/common/controller/pushConcernFanType.ts +++ b/src/api/platform/common/controller/pushConcernFanType.ts @@ -7,6 +7,7 @@ enum Api { add = '/common_proxy/common/pushConcernFanType/save', edit = '/common_proxy/common/pushConcernFanType/update', del = '/common_proxy/common/pushConcernFanType/remove', + setDefaultType = '/common_proxy/common/pushConcernFanType/setDefaultType' } export const listPushConcernFanType = (params?: Partial) => defHttp.get({ url: Api.list, params }, { isReturnResultResponse: true }); @@ -18,3 +19,5 @@ export const editPushConcernFanType = (params: Partial) => d export const getPushConcernFanType = (id: string) => defHttp.get({ url: `${Api.get}/${id}` }); export const delPushConcernFanType = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` }); + +export const setDefaultType = (params: Partial) => defHttp.put({ url: Api.setDefaultType, data: params }); diff --git a/src/views/common/push/pushConcern/concern.data.ts b/src/views/common/push/pushConcern/concern.data.ts index e58a700..e53ad2e 100644 --- a/src/views/common/push/pushConcern/concern.data.ts +++ b/src/views/common/push/pushConcern/concern.data.ts @@ -1,7 +1,10 @@ import { BasicColumn } from '/@/components/Table'; import { FormSchema } from '/@/components/Table'; import { h } from 'vue'; -import { Tag } from 'ant-design-vue'; +import { Tag, Switch } from 'ant-design-vue'; +import { setDefaultType } from '/@/api/platform/common/controller/pushConcernFanType'; +import { useMessage } from '/@/hooks/web/useMessage'; +const { createConfirm } = useMessage(); /** 表格列配置 */ export const columns: BasicColumn[] = [ @@ -116,3 +119,112 @@ export const formSchema: FormSchema[] = [ } }, ]; + +/** 推送类型表格列配置 */ +export const pushTypeColumns = (refreshPushType: Function) => [ + { + title: '类型名称', + dataIndex: 'name' + }, + { + title: '播放声音', + dataIndex: 'playSound', + width: 80, + customRender: ({ record }) => { + const playSound = record?.playSound; + const enable = ~~playSound === 0; + const color = enable ? 'green' : 'red'; + const text = enable ? '是' : '否'; + return h(Tag, { color: color }, () => text); + } + }, + { + title: '默认', + dataIndex: 'defaultType', + width: 120, + customRender: ({ record }) => { + // 设置请求加载状态标识 + if (!Reflect.has(record, 'pendingStatus')) { + record.pendingStatus = false; + } + return h(Switch, { + checked: record.defaultType === '1', + checkedChildren: '已启用', + unCheckedChildren: '已禁用', + loading: record.pendingStatus, + onChange(checked: boolean) { + const text = checked ? '启用' : '禁用'; + createConfirm({ + iconType: 'warning', + title: '警告', + content: `确认要"${text}${record.name}推送类型吗?`, + onOk: async () => { + record.pendingStatus = true; + const { createMessage } = useMessage(); + const defaultType = checked ? '1' : '0'; + setDefaultType({ + id: record.id, + concernFanId: record.concernFanId, + defaultType + }).then(() => { + refreshPushType(); + createMessage.success(`${text}成功`); + }).catch(() => { + createMessage.error(`${text}失败`); + }).finally(() => record.pendingStatus = false); + } + }); + } + }); + } + }, + { + title: '震动', + dataIndex: 'playVibrate', + width: 80, + customRender: ({ record }) => { + const playVibrate = record?.playVibrate; + const enable = ~~playVibrate === 0; + const color = enable ? 'green' : 'red'; + const text = enable ? '是' : '否'; + return h(Tag, { color: color }, () => text); + } + }, + { + title: '闪光', + dataIndex: 'playLights', + width: 80, + customRender: ({ record }) => { + const playLights = record?.playLights; + const enable = ~~playLights === 0; + const color = enable ? 'green' : 'red'; + const text = enable ? '是' : '否'; + return h(Tag, { color: color }, () => text); + } + }, + { + title: '文字转语音', + dataIndex: 'playToText', + width: 120, + customRender: ({ record }) => { + const playToText = record?.playToText; + const enable = ~~playToText === 1; + const color = enable ? 'green' : 'red'; + const text = enable ? '是': '否'; + return h(Tag, { color: color }, () => text); + } + }, + { + title: '在线铃声', + dataIndex: 'onlineRingtone' + }, + { + title: '创建人', + dataIndex: 'createByName' + }, + { + title: '创建时间', + dataIndex: 'createTime', + width: 200 + } +] as BasicColumn[]; diff --git a/src/views/common/push/pushConcern/index.vue b/src/views/common/push/pushConcern/index.vue index 8be38cb..669b58a 100644 --- a/src/views/common/push/pushConcern/index.vue +++ b/src/views/common/push/pushConcern/index.vue @@ -57,16 +57,16 @@