From 92679b841ba116640b6b1d0b461c8b8d33c5e951 Mon Sep 17 00:00:00 2001 From: danial Date: Thu, 6 Mar 2025 23:40:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(card-walmart-c-trip):=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E6=B2=83=E5=B0=94=E7=8E=9B=20Cookie=20=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增沃尔玛 Cookie管理页面,包括搜索、添加、编辑、删除等功能 - 实现批量导入和导出功能 - 添加账户详情和操作日志组件 - 集成通知和表单验证功能 --- .../account/components/add-modal.vue | 219 +++++++++ .../account/components/component.tsx | 257 +++++++++++ .../account/components/detail.vue | 162 +++++++ .../card-walmart-c-trip/account/index.vue | 416 ++++++++++++++++++ .../order-summary/index.vue | 129 ++++++ .../order/components/config.tsx | 113 +++++ .../order/components/history.vue | 137 ++++++ src/views/card-walmart-c-trip/order/index.vue | 394 +++++++++++++++++ .../account/components/component.tsx | 1 - 9 files changed, 1827 insertions(+), 1 deletion(-) create mode 100644 src/views/card-walmart-c-trip/account/components/add-modal.vue create mode 100644 src/views/card-walmart-c-trip/account/components/component.tsx create mode 100644 src/views/card-walmart-c-trip/account/components/detail.vue create mode 100644 src/views/card-walmart-c-trip/account/index.vue create mode 100644 src/views/card-walmart-c-trip/order-summary/index.vue create mode 100644 src/views/card-walmart-c-trip/order/components/config.tsx create mode 100644 src/views/card-walmart-c-trip/order/components/history.vue create mode 100644 src/views/card-walmart-c-trip/order/index.vue diff --git a/src/views/card-walmart-c-trip/account/components/add-modal.vue b/src/views/card-walmart-c-trip/account/components/add-modal.vue new file mode 100644 index 0000000..d9aabb3 --- /dev/null +++ b/src/views/card-walmart-c-trip/account/components/add-modal.vue @@ -0,0 +1,219 @@ + + + + + diff --git a/src/views/card-walmart-c-trip/account/components/component.tsx b/src/views/card-walmart-c-trip/account/components/component.tsx new file mode 100644 index 0000000..dabeaf5 --- /dev/null +++ b/src/views/card-walmart-c-trip/account/components/component.tsx @@ -0,0 +1,257 @@ +import { getAPIBaseUrl, handleDownLoadFile } from '@/api/utils'; +import useLoading from '@/hooks/loading'; +import { getToken, getTokenFrom } from '@/utils/auth'; +import { + Button, + Col, + type FileItem, + Message, + Modal, + Notification, + Row, + Space, + Table, + type TableColumnData, + type TableData, + Tag, + Upload +} from '@arco-design/web-vue'; +import { isArray } from 'lodash'; +import { defineComponent, reactive, ref } from 'vue'; +import type { KamiApiCardInfoCTripV1AccountCookieCheckRes } from '@/api/generated'; +import { apiClient } from '@/api'; + +const tableColumns: TableColumnData[] = [ + { + title: '序号', + dataIndex: 'index', + render: (data: { rowIndex: number }) => { + return data.rowIndex + 1; + } + }, + { + title: '名称', + dataIndex: 'name' + }, + { + title: '昵称', + dataIndex: 'nickname' + }, + { + title: '限额(金额)', + dataIndex: 'maxAmountLimit' + }, + { + title: '限额(次数)', + dataIndex: 'maxCountLimit' + }, + { + title: 'cookie', + dataIndex: 'cookie', + ellipsis: true, + tooltip: true + }, + { + title: '是否存在系统内', + dataIndex: 'isExist', + render: (data: { record: TableData }) => { + let color = 'red'; + let text = '不存在'; + if (data.record.isExist) { + color = 'green'; + text = '存在'; + } + return ( + + {text} + + ); + } + }, + { + title: '是否可用', + dataIndex: 'isAvailable', + render: (data: { record: TableData }) => { + let color = 'red'; + let text = '不可用'; + if (data.record.isAvailable) { + color = 'green'; + text = '可用'; + } + return ( + + {text} + + ); + } + } +]; + +export const notification = ( + isSucceed: boolean = true, + nickname: string = '', + balance: number = 0, + isExist: boolean = false +) => { + if (isSucceed) { + const id = `${Date.now()}`; + Notification.success({ + id, + title: '用户信息', + content: () => ( +
+
用户昵称:{nickname}
+
用户余额:{balance}
+
是否存在于系统:{isExist ? '存在' : '不存在'}
+
+ ), + closable: true, + footer: () => ( + + + + ), + duration: 0 + }); + } else { + const id = `${Date.now()}`; + Notification.error({ + id, + title: '用户信息', + content: 'cookie无效', + footer: () => ( + + + + ), + duration: 0 + }); + } +}; + +// 新增下载模板文件的函数 +const downloadDataList = async () => { + const response = await apiClient.apiCardInfoCTripAccountDownloadGet({ + responseType: 'blob' + }); + handleDownLoadFile(response.data as any, '沃尔玛账号下载数据.xlsx'); +}; + +export const batchImportModel = defineComponent({ + name: 'batchImportWalmartAccountModel', + emits: { + close: () => {} + }, + setup(props, { emit }) { + const state = reactive<{ + visible: boolean; + }>({ + visible: false + }); + const { loading, setLoading } = useLoading(false); + const tableData = ref([]); + + return () => ( + <> + + void) => { + try { + await apiClient.apiCardInfoCTripAccountBatchAddPost({ + list: tableData.value + }); + emit('close'); + Message.success('上传成功'); + done(true); + } catch { + Message.error('上传失败'); + done(false); + } + }} + > + + + + + => { + setLoading(true); + tableData.value = []; + return file; + }} + draggable + limit={1} + accept='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + onSuccess={(fileItem: FileItem) => { + setLoading(false); + if (fileItem.response.code === 0) { + if ( + isArray(fileItem.response.data.list) && + fileItem.response.data.list.length > 0 + ) { + tableData.value = fileItem.response.data.list; + } + Message.success( + `上传成功${fileItem.response.data?.msg ? ':' + fileItem.response.data?.msg : ''}` + ); + return; + } + Message.error(`上传失败:${fileItem.response.message}`); + }} + onError={() => { + Message.error('上传失败'); + setLoading(false); + }} + action={`${getAPIBaseUrl()}/api/cardInfo/cTrip/account/check`} + headers={{ + Authorization: `Bearer ${getToken()}`, + tokenFrom: getTokenFrom() + }} + tip='点击批量上传ck' + /> + + + +
+ +
+
+ + ); + } +}); diff --git a/src/views/card-walmart-c-trip/account/components/detail.vue b/src/views/card-walmart-c-trip/account/components/detail.vue new file mode 100644 index 0000000..bc2a89e --- /dev/null +++ b/src/views/card-walmart-c-trip/account/components/detail.vue @@ -0,0 +1,162 @@ + + + diff --git a/src/views/card-walmart-c-trip/account/index.vue b/src/views/card-walmart-c-trip/account/index.vue new file mode 100644 index 0000000..928e861 --- /dev/null +++ b/src/views/card-walmart-c-trip/account/index.vue @@ -0,0 +1,416 @@ + + + diff --git a/src/views/card-walmart-c-trip/order-summary/index.vue b/src/views/card-walmart-c-trip/order-summary/index.vue new file mode 100644 index 0000000..863ddad --- /dev/null +++ b/src/views/card-walmart-c-trip/order-summary/index.vue @@ -0,0 +1,129 @@ + + + diff --git a/src/views/card-walmart-c-trip/order/components/config.tsx b/src/views/card-walmart-c-trip/order/components/config.tsx new file mode 100644 index 0000000..c8ab3d5 --- /dev/null +++ b/src/views/card-walmart-c-trip/order/components/config.tsx @@ -0,0 +1,113 @@ +import { apiClient } from '@/api'; +import { getWalmartConfig } from '@/api/card-walmart-order'; +import type { KamiApiCardInfoWalmartV1RedeemConfigGetRes } from '@/api/generated'; +import { + Button, + Modal, + Form, + FormItem, + Switch, + type FormInstance, + InputNumber +} from '@arco-design/web-vue'; +import { defineComponent, onMounted, reactive, ref } from 'vue'; + +export default defineComponent({ + name: 'cardJdConfig', + setup() { + const state = reactive<{ + visible: boolean; + }>({ + visible: false + }); + const formData = ref>({ + isAllowDifferentAmount: true, + isAllowDifferentSucceedCallback: true, + isAllowDifferentFailCallback: true, + redeemCardMinAmount: 0, + isAllowCompensatedCallback: true, + redeemCardRate: 100 + }); + const formRef = ref(); + onMounted(() => { + getWalmartConfig().then(res => { + formData.value = res.data; + }); + }); + return () => ( + <> + + void) => { + if (await formRef.value.validate()) { + done(false); + } + try { + await apiClient.apiCardInfoWalmartConfigSetPost(formData.value); + done(true); + } catch { + done(false); + } + }} + > +
+ + + + + + + + + + + + + + + + + + +
+
+ + ); + } +}); diff --git a/src/views/card-walmart-c-trip/order/components/history.vue b/src/views/card-walmart-c-trip/order/components/history.vue new file mode 100644 index 0000000..7b2f9c2 --- /dev/null +++ b/src/views/card-walmart-c-trip/order/components/history.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/src/views/card-walmart-c-trip/order/index.vue b/src/views/card-walmart-c-trip/order/index.vue new file mode 100644 index 0000000..fb707f7 --- /dev/null +++ b/src/views/card-walmart-c-trip/order/index.vue @@ -0,0 +1,394 @@ + + + diff --git a/src/views/card-walmart-info/account/components/component.tsx b/src/views/card-walmart-info/account/components/component.tsx index 3341130..8c78f2d 100644 --- a/src/views/card-walmart-info/account/components/component.tsx +++ b/src/views/card-walmart-info/account/components/component.tsx @@ -1,4 +1,3 @@ -// import { batchAdd, downloadJDCardData } from '@/api/card-jd-account'; import { batchAdd, downloadDataList } from '@/api/card-walmart-account'; import type { KamiApiCardInfoWalmartV1AccountCookieCheckRes } from '@/api/generated'; import { getAPIBaseUrl } from '@/api/utils';