123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import { BasicColumn, FormSchema } from '@/components/Table';
- import { useI18n } from '@/hooks/web/useI18n';
- import { formatToDateTime } from '@/utils/dateUtil';
- import { updateLabelRelationship } from '@/api/wechat/labelRelationship';
- import { Switch } from 'ant-design-vue';
- import { h } from 'vue';
- const { t } = useI18n();
- export const columns: BasicColumn[] = [
- {
- title: t('wechat.labelRelationship.labelId'),
- dataIndex: 'labelId',
- width: 100,
- },
- {
- title: t('wechat.labelRelationship.contactId'),
- dataIndex: 'contactId',
- width: 100,
- },
- {
- title: t('wechat.labelRelationship.contact'),
- dataIndex: 'contact',
- width: 100,
- },
- {
- title: t('wechat.labelRelationship.label'),
- dataIndex: 'label',
- width: 100,
- },
- {
- title: t('common.status'),
- dataIndex: 'status',
- width: 50,
- customRender: ({ record }) => {
- if (!Reflect.has(record, 'pendingStatus')) {
- record.pendingStatus = false;
- }
- return h(Switch, {
- checked: record.status === 1,
- checkedChildren: t('common.on'),
- unCheckedChildren: t('common.off'),
- loading: record.pendingStatus,
- onChange(checked, _) {
- record.pendingStatus = true;
- const newStatus = checked ? 1 : 2;
- updateLabelRelationship({ id: record.id, status: newStatus })
- .then(() => {
- record.status = newStatus;
- })
- .finally(() => {
- record.pendingStatus = false;
- });
- },
- });
- },
- },
- {
- title: t('common.createTime'),
- dataIndex: 'createdAt',
- width: 70,
- customRender: ({ record }) => {
- return formatToDateTime(record.createdAt);
- },
- },
- ];
- export const searchFormSchema: FormSchema[] = [
- ];
- export const formSchema: FormSchema[] = [
- {
- field: 'id',
- label: 'ID',
- component: 'Input',
- show: false,
- },
- {
- field: 'labelId',
- label: t('wechat.labelRelationship.labelId'),
- component: 'InputNumber',
- required: true,
- },
- {
- field: 'contactId',
- label: t('wechat.labelRelationship.contactId'),
- component: 'InputNumber',
- required: true,
- },
- {
- field: 'contact',
- label: t('wechat.labelRelationship.contact'),
- component: 'Input',
- required: true,
- },
- {
- field: 'label',
- label: t('wechat.labelRelationship.label'),
- component: 'Input',
- required: true,
- },
- {
- field: 'status',
- label: t('wechat.labelRelationship.status'),
- component: 'RadioButtonGroup',
- defaultValue: 1,
- componentProps: {
- options: [
- { label: t('common.on'), value: 1 },
- { label: t('common.off'), value: 2 },
- ],
- },
- },
- ];
|