You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
274 lines
6.1 KiB
274 lines
6.1 KiB
import { BasicColumn } from '/@/components/Table'; |
|
import { FormSchema } from '/@/components/Table'; |
|
import { h } from 'vue'; |
|
import { Tag, Switch } from 'ant-design-vue'; |
|
import { setDefaultType } from '/@/api/platform/common/controller/pushConcernFanType'; |
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
import { useUserStore } from '/@/store/modules/user'; |
|
|
|
const { createConfirm, createMessage } = useMessage(); |
|
const userStore = useUserStore(); |
|
const userInfoStore = userStore.getUserInfo; |
|
|
|
/** 表格列配置 */ |
|
export const columns: BasicColumn[] = [ |
|
{ |
|
title: '昵称', |
|
dataIndex: 'nickName' |
|
}, |
|
{ |
|
title: '性别', |
|
dataIndex: 'sex', |
|
width: 80, |
|
customRender: ({ record }) => { |
|
const sex = record.sex; |
|
const enable = ~~sex === 0; |
|
const color = enable ? 'green' : 'red'; |
|
const text = enable ? '男' : '女'; |
|
return h(Tag, { color: color }, () => text); |
|
} |
|
}, |
|
{ |
|
title: '手机号', |
|
dataIndex: 'phone' |
|
}, |
|
{ |
|
title: '邮箱', |
|
dataIndex: 'email' |
|
}, |
|
{ |
|
title: '所属部门', |
|
dataIndex: 'deptName' |
|
}, |
|
{ |
|
title: '创建人', |
|
dataIndex: 'createByName' |
|
}, |
|
{ |
|
title: '创建时间', |
|
dataIndex: 'createTime', |
|
width: 200 |
|
}, |
|
]; |
|
|
|
/** 搜索表单配置 */ |
|
export const searchFormSchema: FormSchema[] = [ |
|
{ |
|
field: 'nickName', |
|
label: '用户昵称', |
|
component: 'Input', |
|
componentProps: { |
|
placeholder: '请输入昵称', |
|
}, |
|
colProps: { span: 6 } |
|
} |
|
]; |
|
|
|
/** 表单配置 */ |
|
export const formSchema: FormSchema[] = [ |
|
{ |
|
field: 'id', |
|
label: 'ID', |
|
component: 'Input', |
|
show: false |
|
}, |
|
{ |
|
field: 'nickName', |
|
label: '昵称', |
|
component: 'Input', |
|
}, |
|
{ |
|
field: 'deptName', |
|
label: '所属部门', |
|
component: 'Input', |
|
colProps: { |
|
span: 12 |
|
}, |
|
}, |
|
{ |
|
field: 'sex', |
|
label: '性别', |
|
component: 'Select', |
|
colProps: { |
|
span: 12 |
|
}, |
|
componentProps: { |
|
options: [ |
|
{ label: '男', value: '0' }, |
|
{ label: '女', value: '1' } |
|
] |
|
}, |
|
}, |
|
{ |
|
field: 'phone', |
|
label: '手机号', |
|
component: 'Input', |
|
}, |
|
{ |
|
field: 'email', |
|
label: '邮箱', |
|
component: 'Input', |
|
}, |
|
]; |
|
|
|
/** 推送类型表格列配置 */ |
|
export const pushTypeColumns = (refreshPushType: Function) => [ |
|
{ |
|
title: '类型名称', |
|
dataIndex: 'name' |
|
}, |
|
{ |
|
title: '播放声音', |
|
dataIndex: 'playSound', |
|
width: 80, |
|
customRender: ({ record }) => { |
|
const playSound = record?.playSound; |
|
const enable = ~~playSound === 1; |
|
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) { |
|
checked ? createConfirm({ |
|
iconType: 'warning', |
|
title: '警告', |
|
content: `确认要启用${record.name}推送类型吗?`, |
|
onOk: async () => { |
|
record.pendingStatus = true; |
|
setDefaultType({ |
|
id: record.id, |
|
concernFanId: record.concernFanId, |
|
defaultType: '1' |
|
}).then(() => { |
|
refreshPushType(); |
|
createMessage.success('启用成功!'); |
|
}).catch(() => { |
|
createMessage.error('启用失败!'); |
|
}).finally(() => record.pendingStatus = false); |
|
} |
|
}) : createMessage.error('不允许禁用!'); |
|
} |
|
}); |
|
} |
|
}, |
|
{ |
|
title: '震动', |
|
dataIndex: 'playVibrate', |
|
width: 80, |
|
customRender: ({ record }) => { |
|
const playVibrate = record?.playVibrate; |
|
const enable = ~~playVibrate === 1; |
|
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 === 1; |
|
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: 'createByName' |
|
}, |
|
{ |
|
title: '创建时间', |
|
dataIndex: 'createTime', |
|
width: 200 |
|
} |
|
] as BasicColumn[]; |
|
|
|
|
|
/** 关注用户发送消息表单 */ |
|
export const concernSendFormSchema: FormSchema[] = [ |
|
{ |
|
field: 'userId', |
|
label: '推送方用户id', |
|
component: 'Input', |
|
defaultValue: userInfoStore.id, |
|
show: false |
|
}, |
|
{ |
|
field: 'alias', |
|
label: '推送用户', |
|
component: 'Input', |
|
show: false |
|
}, |
|
{ |
|
field: 'concernFanStatus', |
|
label: '关注粉丝状态', |
|
component: 'Input', |
|
defaultValue: '1', |
|
show: false |
|
}, |
|
{ |
|
field: 'remarks', |
|
label: '任务描述', |
|
component: 'Input', |
|
required: true, |
|
componentProps: { |
|
showCount: true, |
|
maxlength: 20, |
|
} |
|
}, |
|
{ |
|
field: 'title', |
|
label: '通知标题', |
|
component: 'Input', |
|
required: true, |
|
}, |
|
{ |
|
label: '通知内容', |
|
field: 'text', |
|
component: 'InputTextArea', |
|
required: true, |
|
componentProps: { |
|
rows: 6 |
|
}, |
|
}, |
|
{ |
|
field: 'pushTypeId', |
|
label: '推送类型', |
|
component: 'ApiSelect', |
|
componentProps: { |
|
labelField: 'name', |
|
valueField: 'typeId', |
|
resultField: 'data' |
|
}, |
|
} |
|
];
|
|
|