|
@@ -0,0 +1,231 @@
|
|
|
|
+import { BasicColumn, FormSchema } from '@/components/Table';
|
|
|
|
+import { useI18n } from '@/hooks/web/useI18n';
|
|
|
|
+import { formatToDateTime } from '@/utils/dateUtil';
|
|
|
|
+import { updateWhatsappBatch } from '@/api/whatsapp_batch/whatsappBatch';
|
|
|
|
+import { Switch } from 'ant-design-vue';
|
|
|
|
+import { h } from 'vue';
|
|
|
|
+
|
|
|
|
+const { t } = useI18n();
|
|
|
|
+
|
|
|
|
+export const columns: BasicColumn[] = [
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.batchNo'),
|
|
|
|
+ dataIndex: 'batchNo',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.taskName'),
|
|
|
|
+ dataIndex: 'taskName',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.fromPhone'),
|
|
|
|
+ dataIndex: 'fromPhone',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.msg'),
|
|
|
|
+ dataIndex: 'msg',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.tag'),
|
|
|
|
+ dataIndex: 'tag',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.tagids'),
|
|
|
|
+ dataIndex: 'tagids',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.total'),
|
|
|
|
+ dataIndex: 'total',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.success'),
|
|
|
|
+ dataIndex: 'success',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.fail'),
|
|
|
|
+ dataIndex: 'fail',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.startTime'),
|
|
|
|
+ dataIndex: 'startTime',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.stopTime'),
|
|
|
|
+ dataIndex: 'stopTime',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.sendTime'),
|
|
|
|
+ dataIndex: 'sendTime',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('whatsapp_batch.whatsappBatch.organizationId'),
|
|
|
|
+ dataIndex: 'organizationId',
|
|
|
|
+ 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;
|
|
|
|
+ updateWhatsappBatch({ 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[] = [
|
|
|
|
+ {
|
|
|
|
+ field: 'batchNo',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.batchNo'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ colProps: { span: 8 },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'taskName',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.taskName'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ colProps: { span: 8 },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'fromPhone',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.fromPhone'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ colProps: { span: 8 },
|
|
|
|
+ },
|
|
|
|
+];
|
|
|
|
+
|
|
|
|
+export const formSchema: FormSchema[] = [
|
|
|
|
+ {
|
|
|
|
+ field: 'id',
|
|
|
|
+ label: 'ID',
|
|
|
|
+ component: 'Input',
|
|
|
|
+ show: false,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'batchNo',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.batchNo'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'taskName',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.taskName'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'fromPhone',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.fromPhone'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'msg',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.msg'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'tag',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.tag'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'tagids',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.tagids'),
|
|
|
|
+ component: 'Input',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'total',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.total'),
|
|
|
|
+ component: 'InputNumber',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'success',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.success'),
|
|
|
|
+ component: 'InputNumber',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'fail',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.fail'),
|
|
|
|
+ component: 'InputNumber',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'startTime',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.startTime'),
|
|
|
|
+ component: 'InputNumber',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'stopTime',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.stopTime'),
|
|
|
|
+ component: 'InputNumber',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'sendTime',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.sendTime'),
|
|
|
|
+ component: 'InputNumber',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'organizationId',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.organizationId'),
|
|
|
|
+ component: 'InputNumber',
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ field: 'status',
|
|
|
|
+ label: t('whatsapp_batch.whatsappBatch.status'),
|
|
|
|
+ component: 'RadioButtonGroup',
|
|
|
|
+ defaultValue: 1,
|
|
|
|
+ componentProps: {
|
|
|
|
+ options: [
|
|
|
|
+ { label: t('common.on'), value: 1 },
|
|
|
|
+ { label: t('common.off'), value: 2 },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+];
|