| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import { h } from 'vue';
- import type { BasicColumn } from '@/components/Table';
- import { ElSwitch } from 'element-plus';
- import { pushChannelName, recipientTypeName, statusName } from './constant'
- import { statisticTypeName } from '@/views/message/constant'
- import { storeToRefs } from 'pinia';
- import useFormList from './store/useFormList';
- const formStore = useFormList();
- const { type } = storeToRefs(formStore);
- const { getForm } = formStore;
- import { updateStatus, updateStatusParams } from './api/index'
- export const reportDataCol: BasicColumn[] = [
- {
- label: '报表周期',
- prop: 'statisticType',
- render(record) {
- const typeName = statisticTypeName.find(item => item.value === record.row.statisticType);
- return h(
- 'span',
- {},
- typeName ? typeName.label : ''
- )
- }
- },
- {
- label: '推送渠道',
- prop: 'pushChannel',
- render(record) {
- const labels = record.row.pushChannel
- .map(channel => {
- const typeName = pushChannelName.find(item => item.value === channel);
- return typeName ? typeName.label : '';
- })
- .filter(label => label !== '')
- .join(', ');
- return h('span', {}, labels);
- }
- },
- {
- label: '推送对象',
- prop: 'recipientType',
- render(record) {
- const length = record.row.recipientType.length;
- if (length > 1) {
- return h('span', {}, '多类对象');
- }
- const label = recipientTypeName.find(item => item.value === record.row.recipientType[0])
- return h('span', {}, label ? label.label : '');
- }
- },
- {
- label: '是否启用',
- prop: 'status',
- render(record) {
- return h(
- ElSwitch,
- {
- modelValue: record.row.status,
- onChange: () => {
- const params: updateStatusParams = {
- type: type.value,
- statisticType: record.row.statisticType,
- status: record.row.status === 1 ? 0 : 1
- }
- updateStatus(params).then(() => {
- getForm(type.value);
- });
- },
- activeValue: 0,
- inactiveValue: 1,
- },
- {},
- );
- },
- },
- {
- label: '操作时间',
- prop: 'updatedAt',
- }
- ];
- export const logColumns: BasicColumn[] = [
- {
- label: '序号',
- type: 'index',
- minWidth: 56,
- },
- {
- label: '推送时间',
- prop: 'createdAt',
- },
- {
- label: '推送状态',
- prop: 'status',
- render(record) {
- const name = statusName.find(item => item.value === record.row.status);
- const style = record.row.status === 1 ? { color: '#FAAD14' } : {};
- return h(
- 'span',
- { style },
- name ? name.label : ''
- )
- }
- },
- ];
|