Browse Source

feat: 添加设置默认推送类型

master
wangxiang 2 years ago
parent
commit
e9e4020bc5
  1. 3
      src/api/platform/common/controller/pushConcernFanType.ts
  2. 114
      src/views/common/push/pushConcern/concern.data.ts
  3. 10
      src/views/common/push/pushConcern/index.vue
  4. 1
      src/views/common/push/pushType/type.data.ts

3
src/api/platform/common/controller/pushConcernFanType.ts

@ -7,6 +7,7 @@ enum Api { @@ -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<PushConcernFanTypeParams>) => defHttp.get<PushConcernFanTypeResult>({ url: Api.list, params }, { isReturnResultResponse: true });
@ -18,3 +19,5 @@ export const editPushConcernFanType = (params: Partial<PushConcernFanType>) => d @@ -18,3 +19,5 @@ export const editPushConcernFanType = (params: Partial<PushConcernFanType>) => d
export const getPushConcernFanType = (id: string) => defHttp.get<PushConcernFanType>({ url: `${Api.get}/${id}` });
export const delPushConcernFanType = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` });
export const setDefaultType = (params: Partial<PushConcernFanType>) => defHttp.put({ url: Api.setDefaultType, data: params });

114
src/views/common/push/pushConcern/concern.data.ts

@ -1,7 +1,10 @@ @@ -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[] = [ @@ -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[];

10
src/views/common/push/pushConcern/index.vue

@ -57,16 +57,16 @@ @@ -57,16 +57,16 @@
</template>
<script lang="ts" setup>
import { reactive, toRaw } from 'vue';
import {onMounted, reactive, toRaw} from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listPushConcernFan, delPushConcernFan } from '/@/api/platform/common/controller/pushConcernFan';
import { useModal } from '/@/components/Modal';
import ConcernModal from './ConcernModal.vue';
import TypeModal from '../pushType/TypeModal.vue';
import { columns, searchFormSchema } from './concern.data';
import { columns, searchFormSchema, pushTypeColumns } from './concern.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { useUserStore } from '/@/store/modules/user';
import { columns as pushTypeColumns, searchFormSchema as pushTypeSearchFormSchema} from '../pushType/type.data';
import { searchFormSchema as pushTypeSearchFormSchema} from '../pushType/type.data';
import { listPushConcernFanType } from '/@/api/platform/common/controller/pushConcernFanType';
const userStore = useUserStore();
@ -118,11 +118,11 @@ @@ -118,11 +118,11 @@
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});
const [pushTypeRegisterTable, { reload: pushTypeReload }] = useTable({
const [pushTypeRegisterTable, { reload: pushTypeReload, setColumns }] = useTable({
title: '推送类型列表',
api: listPushConcernFanType,
rowKey: 'id',
columns: pushTypeColumns,
columns: pushTypeColumns(handleRefreshPushTypeTable),
formConfig: {
compact: true,
labelWidth: 80,

1
src/views/common/push/pushType/type.data.ts

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { listPushRingtone } from '/@/api/platform/common/controller/pushRingtone';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';

Loading…
Cancel
Save