|
@@ -0,0 +1,198 @@
|
|
|
+import { BasicColumn, FormSchema } from '@/components/Table';
|
|
|
+import { useI18n } from '@/hooks/web/useI18n';
|
|
|
+import { formatToDateTime } from '@/utils/dateUtil';
|
|
|
+import { updateWhatsapp } from '@/api/wechat/whatsapp';
|
|
|
+import { Switch } from 'ant-design-vue';
|
|
|
+import { h } from 'vue';
|
|
|
+
|
|
|
+const { t } = useI18n();
|
|
|
+
|
|
|
+export const columns: BasicColumn[] = [
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.ak'),
|
|
|
+ dataIndex: 'ak',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.sk'),
|
|
|
+ dataIndex: 'sk',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.callback'),
|
|
|
+ dataIndex: 'callback',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.account'),
|
|
|
+ dataIndex: 'account',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.nickname'),
|
|
|
+ dataIndex: 'nickname',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.phone'),
|
|
|
+ dataIndex: 'phone',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.organizationId'),
|
|
|
+ dataIndex: 'organizationId',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.agentId'),
|
|
|
+ dataIndex: 'agentId',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.apiBase'),
|
|
|
+ dataIndex: 'apiBase',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('wechat.whatsapp.apiKey'),
|
|
|
+ dataIndex: 'apiKey',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('common.status'),
|
|
|
+ dataIndex: 'status',
|
|
|
+ width: 80,
|
|
|
+ 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;
|
|
|
+ updateWhatsapp({ id: record.id, status: newStatus })
|
|
|
+ .then(() => {
|
|
|
+ record.status = newStatus;
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ record.pendingStatus = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('common.createTime'),
|
|
|
+ dataIndex: 'createdAt',
|
|
|
+ width: 170,
|
|
|
+ customRender: ({ record }) => {
|
|
|
+ return formatToDateTime(record.createdAt);
|
|
|
+ },
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+export const searchFormSchema: FormSchema[] = [
|
|
|
+ {
|
|
|
+ field: 'ak',
|
|
|
+ label: t('wechat.whatsapp.ak'),
|
|
|
+ component: 'Input',
|
|
|
+ colProps: { span: 8 },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'sk',
|
|
|
+ label: t('wechat.whatsapp.sk'),
|
|
|
+ component: 'Input',
|
|
|
+ colProps: { span: 8 },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'callback',
|
|
|
+ label: t('wechat.whatsapp.callback'),
|
|
|
+ component: 'Input',
|
|
|
+ colProps: { span: 8 },
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+export const formSchema: FormSchema[] = [
|
|
|
+ {
|
|
|
+ field: 'id',
|
|
|
+ label: 'ID',
|
|
|
+ component: 'Input',
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'ak',
|
|
|
+ label: t('wechat.whatsapp.ak'),
|
|
|
+ component: 'Input',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'sk',
|
|
|
+ label: t('wechat.whatsapp.sk'),
|
|
|
+ component: 'Input',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'callback',
|
|
|
+ label: t('wechat.whatsapp.callback'),
|
|
|
+ component: 'Input',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'account',
|
|
|
+ label: t('wechat.whatsapp.account'),
|
|
|
+ component: 'Input',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'nickname',
|
|
|
+ label: t('wechat.whatsapp.nickname'),
|
|
|
+ component: 'Input',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'phone',
|
|
|
+ label: t('wechat.whatsapp.phone'),
|
|
|
+ component: 'Input',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'organizationId',
|
|
|
+ label: t('wechat.whatsapp.organizationId'),
|
|
|
+ component: 'InputNumber',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'agentId',
|
|
|
+ label: t('wechat.whatsapp.agentId'),
|
|
|
+ component: 'InputNumber',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'apiBase',
|
|
|
+ label: t('wechat.whatsapp.apiBase'),
|
|
|
+ component: 'Input',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'apiKey',
|
|
|
+ label: t('wechat.whatsapp.apiKey'),
|
|
|
+ component: 'Input',
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'status',
|
|
|
+ label: t('wechat.whatsapp.status'),
|
|
|
+ component: 'RadioButtonGroup',
|
|
|
+ defaultValue: 1,
|
|
|
+ componentProps: {
|
|
|
+ options: [
|
|
|
+ { label: t('common.on'), value: 1 },
|
|
|
+ { label: t('common.off'), value: 2 },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+];
|