Compare commits
1 Commits
main
...
perf/2025b
| Author | SHA1 | Date |
|---|---|---|
|
|
fb3b2d7bae | 10 months ago |
@ -1,57 +0,0 @@
|
||||
# Build & deploy
|
||||
name: 🚀 Deploy GHH
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: 🎉 Deploy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 🚚 Get latest code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: "npm"
|
||||
|
||||
- name: 🔨 Build Project
|
||||
run: |
|
||||
npm install
|
||||
npm run build --if-present
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fe-build
|
||||
path: |
|
||||
dist
|
||||
build
|
||||
out
|
||||
if-no-files-found: ignore
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: fe-build
|
||||
path: ./build-output
|
||||
|
||||
- name: 📂 Sync files
|
||||
uses: SamKirkland/FTP-Deploy-Action@v4.3.4
|
||||
with:
|
||||
server: ${{ secrets.GHH_SERVER }}
|
||||
username: ${{ secrets.GHH_USER }}
|
||||
password: ${{ secrets.GHH_PASSWORD }}
|
||||
port: ${{ secrets.GHH_PORT }}
|
||||
local-dir: ./build-output
|
||||
server-dir: ${{ secrets.GHH_PATH }}
|
||||
# dangerous-clean-slate: true # deletes remote files before upload
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 4.2 KiB |
@ -1,130 +1,108 @@
|
||||
{
|
||||
"lang": {
|
||||
"en": "English",
|
||||
"zh": "中文"
|
||||
},
|
||||
"Search": "Search",
|
||||
"Reset": "Reset",
|
||||
"Cancel": "Cancel",
|
||||
"Submit": "Submit",
|
||||
"Confirm": "Confirm",
|
||||
"Close": "Close",
|
||||
"Save": "Save",
|
||||
"New": "New",
|
||||
"Edit": "Edit",
|
||||
"Audit": "Audit",
|
||||
"Delete": "Delete",
|
||||
"Add": "Add",
|
||||
"View": "View",
|
||||
"Back": "Back",
|
||||
"Download": "Download",
|
||||
"Upload": "Upload",
|
||||
"Preview": "Preview",
|
||||
"Total": "Total",
|
||||
"Action": "Action",
|
||||
"Import": "Import",
|
||||
"Export": "Export",
|
||||
"Copy": "Copy",
|
||||
"Clear": "Clear",
|
||||
"Publish": "Publish",
|
||||
"Read": "Read",
|
||||
"UnRead": "UnRead",
|
||||
"sureCancel": "Are you sure to cancel?",
|
||||
"sureDelete": "Are you sure to delete?",
|
||||
"sureSubmit": "Are you sure to submit?",
|
||||
"Yes": "Yes",
|
||||
"No": "No",
|
||||
"Success": "Success",
|
||||
"Failed": "Failed",
|
||||
"All": "All",
|
||||
"Select": "Select",
|
||||
"Table": {
|
||||
"Total": "Total {{total}} items"
|
||||
},
|
||||
"operator": "Operator",
|
||||
"time": "Time",
|
||||
"Login": "Login",
|
||||
"Username": "Username",
|
||||
"Realname": "Realname",
|
||||
"Password": "Password",
|
||||
"ChangePassword": "Change password",
|
||||
"Profile": "Profile",
|
||||
"Logout": "Logout",
|
||||
"LoginTimeout": "Login timeout",
|
||||
"LoginTimeoutTip": "Please input your password",
|
||||
"userProfile": "User Profile",
|
||||
"Telephone": "Telephone",
|
||||
"Email": "Email address",
|
||||
"Address": "Address",
|
||||
"Company": "Company",
|
||||
"Department": "Department",
|
||||
"datetime": {
|
||||
"thisWeek": "This Week",
|
||||
"lastWeek": "Last Week",
|
||||
"thisMonth": "This Month",
|
||||
"lastMonth": "Last Month",
|
||||
"nextMonth": "Next Month",
|
||||
"lastThreeMonth": "Last Three Month",
|
||||
"nextThreeMonth": "Next Three Month",
|
||||
"firstHalfYear": "First Half Year",
|
||||
"latterHalfYear": "Latter Half Year",
|
||||
"thisYear": "This Year"
|
||||
},
|
||||
"weekdays": {
|
||||
"1": "Monday",
|
||||
"2": "Tuesday",
|
||||
"3": "Wednesday",
|
||||
"4": "Thursday",
|
||||
"5": "Friday",
|
||||
"6": "Saturday",
|
||||
"7": "Sunday"
|
||||
},
|
||||
"weekdaysShort": {
|
||||
"1": "Mon",
|
||||
"2": "Tue",
|
||||
"3": "Wed",
|
||||
"4": "Thu",
|
||||
"5": "Fri",
|
||||
"6": "Sat",
|
||||
"7": "Sun"
|
||||
},
|
||||
"menu": {
|
||||
"Reservation": "Reservation",
|
||||
"Invoice": "Invoice",
|
||||
"Feedback": "Feedback",
|
||||
"Notice": "Notice",
|
||||
"Report": "Report",
|
||||
"external-reviews": "External Reviews",
|
||||
"Airticket": "AirTicket",
|
||||
"Trainticket": "TrainTicket",
|
||||
"Products": "Products"
|
||||
},
|
||||
"Validation": {
|
||||
"Title": "Notification",
|
||||
"LoginFailed": "Incorrect password, Login failed.",
|
||||
"UsernameIsEmpty": "Please input your username",
|
||||
"PasswordIsEmpty": "Please input your password"
|
||||
},
|
||||
"invoiceStatus": {
|
||||
"Status": "Status",
|
||||
"Not_submitted": "Not submitted",
|
||||
"Submitted": "Submitted",
|
||||
"Travel_advisor_approved": "Travel advisor approved",
|
||||
"Finance_Dept_arrproved": "Finance Dept arrproved",
|
||||
"Paid": "Paid"
|
||||
},
|
||||
"Compare": "Compare",
|
||||
"SystemUpdate": "System Update",
|
||||
"review": {
|
||||
"ReviewLink": "Review Link",
|
||||
"DatePosted": "Date Posted",
|
||||
"ReferenceNumber": "Reference Number",
|
||||
"AdminNotes": "Admin Notes",
|
||||
"CustomerID": "Customer ID",
|
||||
"Guide": "Guide",
|
||||
"Bonus": "Bonus",
|
||||
"ApprovalStatus": "Approval Status",
|
||||
"ApprovalDate": "Approval Date",
|
||||
"Action": "Action"
|
||||
}
|
||||
}
|
||||
{
|
||||
"lang": {
|
||||
"en": "English",
|
||||
"zh": "中文"
|
||||
},
|
||||
"Search": "Search",
|
||||
"Reset": "Reset",
|
||||
"Cancel": "Cancel",
|
||||
"Submit": "Submit",
|
||||
"Confirm": "Confirm",
|
||||
"Close": "Close",
|
||||
"Save": "Save",
|
||||
"New": "New",
|
||||
"Edit": "Edit",
|
||||
"Audit": "Audit",
|
||||
"Delete": "Delete",
|
||||
"Add": "Add",
|
||||
"View": "View",
|
||||
"Back": "Back",
|
||||
"Download": "Download",
|
||||
"Upload": "Upload",
|
||||
"preview": "Preview",
|
||||
"Total": "Total",
|
||||
"Action": "Action",
|
||||
"Import": "Import",
|
||||
"Export": "Export",
|
||||
"Copy": "Copy",
|
||||
"sureCancel": "Are you sure to cancel?",
|
||||
"sureDelete": "Are you sure to delete?",
|
||||
"sureSubmit": "Are you sure to submit?",
|
||||
"Yes": "Yes",
|
||||
"No": "No",
|
||||
"Success": "Success",
|
||||
"Failed": "Failed",
|
||||
"All": "All",
|
||||
"Table": {
|
||||
"Total": "Total {{total}} items"
|
||||
},
|
||||
"Login": "Login",
|
||||
"Username": "Username",
|
||||
"Realname": "Realname",
|
||||
"Password": "Password",
|
||||
"ChangePassword": "Change password",
|
||||
"Profile": "Profile",
|
||||
"Logout": "Logout",
|
||||
"LoginTimeout": "Login timeout",
|
||||
"LoginTimeoutTip": "Please input your password",
|
||||
"userProfile": "User Profile",
|
||||
"Telephone": "Telephone",
|
||||
"Email": "Email address",
|
||||
"Address": "Address",
|
||||
"Company": "Company",
|
||||
"Department": "Department",
|
||||
"datetime": {
|
||||
"thisWeek": "This Week",
|
||||
"lastWeek": "Last Week",
|
||||
"thisMonth": "This Month",
|
||||
"lastMonth": "Last Month",
|
||||
"nextMonth": "Next Month",
|
||||
"lastThreeMonth": "Last Three Month",
|
||||
"nextThreeMonth": "Next Three Month",
|
||||
"firstHalfYear": "First Half Year",
|
||||
"latterHalfYear": "Latter Half Year",
|
||||
"thisYear": "This Year"
|
||||
},
|
||||
"weekdays": {
|
||||
"1": "Monday",
|
||||
"2": "Tuesday",
|
||||
"3": "Wednesday",
|
||||
"4": "Thursday",
|
||||
"5": "Friday",
|
||||
"6": "Saturday",
|
||||
"7": "Sunday"
|
||||
},
|
||||
"weekdaysShort": {
|
||||
"1": "Mon",
|
||||
"2": "Tue",
|
||||
"3": "Wed",
|
||||
"4": "Thu",
|
||||
"5": "Fri",
|
||||
"6": "Sat",
|
||||
"7": "Sun"
|
||||
},
|
||||
"menu": {
|
||||
"Reservation": "Reservation",
|
||||
"Invoice": "Invoice",
|
||||
"Feedback": "Feedback",
|
||||
"Notice": "Notice",
|
||||
"Report": "Report",
|
||||
"Airticket": "AirTicket",
|
||||
"Trainticket": "TrainTicket",
|
||||
"Products": "Products"
|
||||
},
|
||||
"Validation": {
|
||||
"Title": "Notification",
|
||||
"LoginFailed": "Incorrect password, Login failed.",
|
||||
"UsernameIsEmpty": "Please input your username",
|
||||
"PasswordIsEmpty": "Please input your password"
|
||||
},
|
||||
"invoiceStatus": {
|
||||
"Status": "Status",
|
||||
"Not_submitted": "Not submitted",
|
||||
"Submitted": "Submitted",
|
||||
"Travel_advisor_approved": "Travel advisor approved",
|
||||
"Finance_Dept_arrproved": "Finance Dept arrproved",
|
||||
"Paid": "Paid"
|
||||
}
|
||||
}
|
||||
@ -1,117 +1,108 @@
|
||||
{
|
||||
"lang": {
|
||||
"en": "English",
|
||||
"zh": "中文"
|
||||
},
|
||||
"Search": "查询",
|
||||
"Reset": "重置",
|
||||
"Cancel": "取消",
|
||||
"Submit": "提交",
|
||||
"Confirm": "确认",
|
||||
"Close": "关闭",
|
||||
"Save": "保存",
|
||||
"New": "新增",
|
||||
"Edit": "编辑",
|
||||
"Audit": "审核",
|
||||
"Delete": "删除",
|
||||
"Add": "添加",
|
||||
"View": "查看",
|
||||
"Back": "返回",
|
||||
"Download": "下载",
|
||||
"Upload": "上传",
|
||||
"Preview": "预览",
|
||||
"Total": "总数",
|
||||
"Action": "操作",
|
||||
"Import": "导入",
|
||||
"Export": "导出",
|
||||
"Copy": "复制",
|
||||
"Clear": "清空",
|
||||
"Publish": "发布",
|
||||
"Read": "已读",
|
||||
"UnRead": "未读",
|
||||
"sureCancel": "确定取消?",
|
||||
"sureDelete": "确定删除?",
|
||||
"sureSubmit": "确定提交?",
|
||||
"Yes": "是",
|
||||
"No": "否",
|
||||
"Success": "成功",
|
||||
"Failed": "失败",
|
||||
"All": "所有",
|
||||
"Select": "选择",
|
||||
"Table": {
|
||||
"Total": "共 {{total}} 条"
|
||||
},
|
||||
"operator": "操作",
|
||||
"time": "时间",
|
||||
"Login": "登录",
|
||||
"Username": "账号",
|
||||
"Realname": "姓名",
|
||||
"Password": "密码",
|
||||
"ChangePassword": "修改密码",
|
||||
"Profile": "账户中心",
|
||||
"Logout": "退出",
|
||||
"LoginTimeout": "登录超时",
|
||||
"LoginTimeoutTip": "请输入密码",
|
||||
"userProfile": "账号信息",
|
||||
"Telephone": "联系电话",
|
||||
"Email": "电子邮箱",
|
||||
"Address": "公司地址",
|
||||
"Company": "公司名称",
|
||||
"Department": "部门",
|
||||
"datetime": {
|
||||
"thisWeek": "本周",
|
||||
"lastWeek": "上周",
|
||||
"thisMonth": "本月",
|
||||
"lastMonth": "上月",
|
||||
"nextMonth": "下月",
|
||||
"lastThreeMonth": "前三个月",
|
||||
"nextThreeMonth": "后三个月",
|
||||
"firstHalfYear": "上半年",
|
||||
"latterHalfYear": "下半年",
|
||||
"thisYear": "今年"
|
||||
},
|
||||
"weekdays": {
|
||||
"1": "周一",
|
||||
"2": "周二",
|
||||
"3": "周三",
|
||||
"4": "周四",
|
||||
"5": "周五",
|
||||
"6": "周六",
|
||||
"7": "周日"
|
||||
},
|
||||
"weekdaysShort": {
|
||||
"1": "一",
|
||||
"2": "二",
|
||||
"3": "三",
|
||||
"4": "四",
|
||||
"5": "五",
|
||||
"6": "六",
|
||||
"7": "日"
|
||||
},
|
||||
"menu": {
|
||||
"Reservation": "团预订",
|
||||
"Invoice": "账单",
|
||||
"Feedback": "反馈表",
|
||||
"Notice": "通知",
|
||||
"Report": "质量评分",
|
||||
"Airticket": "机票订票",
|
||||
"Trainticket": "火车订票",
|
||||
"Products": "产品管理"
|
||||
},
|
||||
"Validation": {
|
||||
"Title": "温馨提示",
|
||||
"LoginFailed": "密码错误,登陆失败。",
|
||||
"UsernameIsEmpty": "请输入账号",
|
||||
"PasswordIsEmpty": "请输入密码"
|
||||
},
|
||||
"invoiceStatus": {
|
||||
"Status": "审核状态",
|
||||
"Not_submitted": "待提交",
|
||||
"Submitted": "待审核",
|
||||
"Travel_advisor_approved": "顾问已审核",
|
||||
"Finance_Dept_arrproved": "财务已审核",
|
||||
"Paid": "已打款"
|
||||
},
|
||||
"Compare": "对比",
|
||||
"SystemUpdate": "系统更新"
|
||||
}
|
||||
{
|
||||
"lang": {
|
||||
"en": "English",
|
||||
"zh": "中文"
|
||||
},
|
||||
"Search": "查询",
|
||||
"Reset": "重置",
|
||||
"Cancel": "取消",
|
||||
"Submit": "提交",
|
||||
"Confirm": "确认",
|
||||
"Close": "关闭",
|
||||
"Save": "保存",
|
||||
"New": "新增",
|
||||
"Edit": "编辑",
|
||||
"Audit": "审核",
|
||||
"Delete": "删除",
|
||||
"Add": "添加",
|
||||
"View": "查看",
|
||||
"Back": "返回",
|
||||
"Download": "下载",
|
||||
"Upload": "上传",
|
||||
"preview": "预览",
|
||||
"Total": "总数",
|
||||
"Action": "操作",
|
||||
"Import": "导入",
|
||||
"Export": "导出",
|
||||
"Copy": "复制",
|
||||
"sureCancel": "确定取消?",
|
||||
"sureDelete": "确定删除?",
|
||||
"sureSubmit": "确定提交?",
|
||||
"Yes": "是",
|
||||
"No": "否",
|
||||
"Success": "成功",
|
||||
"Failed": "失败",
|
||||
"All": "所有",
|
||||
"Table": {
|
||||
"Total": "共 {{total}} 条"
|
||||
},
|
||||
"Login": "登录",
|
||||
"Username": "账号",
|
||||
"Realname": "姓名",
|
||||
"Password": "密码",
|
||||
"ChangePassword": "修改密码",
|
||||
"Profile": "账户中心",
|
||||
"Logout": "退出",
|
||||
"LoginTimeout": "登录超时",
|
||||
"LoginTimeoutTip": "请输入密码",
|
||||
"userProfile": "账号信息",
|
||||
"Telephone": "联系电话",
|
||||
"Email": "电子邮箱",
|
||||
"Address": "公司地址",
|
||||
"Company": "公司名称",
|
||||
"Department": "部门",
|
||||
"datetime": {
|
||||
"thisWeek": "本周",
|
||||
"lastWeek": "上周",
|
||||
"thisMonth": "本月",
|
||||
"lastMonth": "上月",
|
||||
"nextMonth": "下月",
|
||||
"lastThreeMonth": "前三个月",
|
||||
"nextThreeMonth": "后三个月",
|
||||
"firstHalfYear": "上半年",
|
||||
"latterHalfYear": "下半年",
|
||||
"thisYear": "今年"
|
||||
},
|
||||
"weekdays": {
|
||||
"1": "周一",
|
||||
"2": "周二",
|
||||
"3": "周三",
|
||||
"4": "周四",
|
||||
"5": "周五",
|
||||
"6": "周六",
|
||||
"7": "周日"
|
||||
},
|
||||
"weekdaysShort": {
|
||||
"1": "一",
|
||||
"2": "二",
|
||||
"3": "三",
|
||||
"4": "四",
|
||||
"5": "五",
|
||||
"6": "六",
|
||||
"7": "日"
|
||||
},
|
||||
"menu": {
|
||||
"Reservation": "团预订",
|
||||
"Invoice": "账单",
|
||||
"Feedback": "反馈表",
|
||||
"Notice": "通知",
|
||||
"Report": "质量评分",
|
||||
"Airticket": "机票订票",
|
||||
"Trainticket": "火车订票",
|
||||
"Products": "产品管理"
|
||||
},
|
||||
"Validation": {
|
||||
"Title": "温馨提示",
|
||||
"LoginFailed": "密码错误,登陆失败。",
|
||||
"UsernameIsEmpty": "请输入账号",
|
||||
"PasswordIsEmpty": "请输入密码"
|
||||
},
|
||||
"invoiceStatus": {
|
||||
"Status": "审核状态",
|
||||
"Not_submitted": "待提交",
|
||||
"Submitted": "待审核",
|
||||
"Travel_advisor_approved": "顾问已审核",
|
||||
"Finance_Dept_arrproved": "财务已审核",
|
||||
"Paid": "已打款"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@ -1,14 +0,0 @@
|
||||
.quill-editor .ql-container{
|
||||
font-size: 14px;
|
||||
}
|
||||
.quill-editor .ql-container.ql-snow {
|
||||
min-height: 12rem;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.quill-editor .ql-toolbar.ql-snow {
|
||||
border-radius: 6px 6px 0 0;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.quill-editor .ql-editor{
|
||||
min-height: 12rem;
|
||||
}
|
||||
@ -1,144 +0,0 @@
|
||||
import React, { forwardRef, useEffect, useLayoutEffect, useRef } from 'react';
|
||||
import Quill from 'quill';
|
||||
import 'quill/dist/quill.snow.css';
|
||||
// import 'quill/dist/quill.bubble.css';
|
||||
import './custom.snow.css';
|
||||
|
||||
|
||||
function decodeEntities(str) {
|
||||
const entities = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'",
|
||||
' ': ' ',
|
||||
};
|
||||
return str.replace(/&|<|>|"|'| /g, (match) => entities[match]);
|
||||
}
|
||||
|
||||
const toolbarOptions = [
|
||||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
|
||||
// [{ 'font': [] }],
|
||||
['bold', 'italic', 'underline', 'strike'], // toggled buttons
|
||||
// ['blockquote'], // 'code-block'
|
||||
['link', ], // 'image' 'video', 'formula'
|
||||
|
||||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], // { 'list': 'check' }
|
||||
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
|
||||
|
||||
// [{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
|
||||
// [{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent
|
||||
// [{ 'align': [] }],
|
||||
|
||||
['clean'], // remove formatting button
|
||||
];
|
||||
|
||||
// Editor is an uncontrolled React component
|
||||
const Editor = forwardRef(({ readOnly, defaultValue, value, onChange, onTextChange, onSelectionChange }, ref) => {
|
||||
const containerRef = useRef(null);
|
||||
const cntContainerRef = useRef(null);
|
||||
const defaultValueRef = useRef(defaultValue);
|
||||
const valueRef = useRef(value);
|
||||
const onTextChangeRef = useRef(onTextChange);
|
||||
const onChangeRef = useRef(onChange);
|
||||
const onSelectionChangeRef = useRef(onSelectionChange);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
onTextChangeRef.current = onTextChange;
|
||||
onChangeRef.current = onChange;
|
||||
onSelectionChangeRef.current = onSelectionChange;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const editor = ref.current;
|
||||
if (!editor) return;
|
||||
|
||||
valueRef.current = value;
|
||||
const current = editor.root.innerHTML;
|
||||
const incoming = value || defaultValue || '';
|
||||
// treat quill empty markup as empty string
|
||||
const currentNormalized = current === '<p><br></p>' ? '' : current;
|
||||
|
||||
// if (incoming !== currentNormalized) {
|
||||
if (!currentNormalized) { // ! 只设置一次value
|
||||
const value = valueRef.current;
|
||||
const delta = editor.clipboard.convert({ html: value });
|
||||
editor.setContents(delta, 'silent');
|
||||
|
||||
const sel = editor.getSelection && editor.getSelection();
|
||||
// restore selection if possible
|
||||
if (sel && sel.index != null) {
|
||||
try { editor.setSelection(Math.min(sel.index, editor.getLength() - 1), sel.length || 0); } catch {}
|
||||
}
|
||||
}
|
||||
}, [ref, defaultValue, value]);
|
||||
|
||||
useEffect(() => {
|
||||
ref.current?.enable(!readOnly);
|
||||
}, [ref, readOnly]);
|
||||
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
const cntContainer = cntContainerRef.current;
|
||||
const editorContainer = container.appendChild(container.ownerDocument.createElement('div'));
|
||||
|
||||
// Add fonts to whitelist
|
||||
// const Font = Quill.import('formats/font');
|
||||
// Font.whitelist = ['mirza', 'roboto'];
|
||||
// Quill.register(Font, true);
|
||||
|
||||
Quill.register('modules/counter', function (quill, options) {
|
||||
// quill.on('text-change', function() {
|
||||
quill.on(Quill.events.TEXT_CHANGE, () => {
|
||||
// const text = quill.getText();
|
||||
const length = quill.getLength();
|
||||
cntContainer.innerText = length; // text.length; // text.split(/\s+/).length;
|
||||
});
|
||||
});
|
||||
|
||||
const quill = new Quill(editorContainer, {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: toolbarOptions,
|
||||
counter: true,
|
||||
},
|
||||
});
|
||||
|
||||
ref.current = quill;
|
||||
|
||||
// if (defaultValueRef.current) {
|
||||
// quill.setContents(defaultValueRef.current);
|
||||
// }
|
||||
|
||||
quill.on(Quill.events.TEXT_CHANGE, (...args) => {
|
||||
// const text = quill.getText();
|
||||
onTextChangeRef.current?.(...args);
|
||||
const html = quill.getSemanticHTML();
|
||||
const htmlText = decodeEntities(html);
|
||||
onChangeRef.current?.(htmlText);
|
||||
});
|
||||
|
||||
quill.on(Quill.events.SELECTION_CHANGE, (...args) => {
|
||||
onSelectionChangeRef.current?.(...args);
|
||||
});
|
||||
|
||||
return () => {
|
||||
ref.current = null;
|
||||
container.innerHTML = '';
|
||||
};
|
||||
}, [ref]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div ref={containerRef} style={{ minHeight: '12rem' }} className='quill-editor'></div>
|
||||
<div style={{ border: '1px solid #ccc', borderWidth: '0px 1px 1px 1px', color: '#aaa', padding: '0 3px', textAlign: 'right', borderRadius: '0 0 6px 6px' }}>
|
||||
<span ref={cntContainerRef}>0</span> / 4000
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
Editor.displayName = 'Editor';
|
||||
|
||||
export default Editor;
|
||||
@ -1,77 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import { Popover, message, FloatButton, Button, Form, Input } from "antd";
|
||||
import { BugOutlined } from "@ant-design/icons";
|
||||
import useAuthStore from "@/stores/Auth";
|
||||
import { sendNotify } from "@/pageSpy";
|
||||
import { uploadPageSpyLog } from '@haina/utils-pagespy';
|
||||
|
||||
function LogUploader() {
|
||||
const [open, setOpen] = useState(false);
|
||||
const hide = () => {
|
||||
setOpen(false);
|
||||
};
|
||||
const handleOpenChange = (newOpen) => {
|
||||
setOpen(newOpen);
|
||||
};
|
||||
|
||||
const [currentUser] = useAuthStore((s) => [s.currentUser]);
|
||||
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
const [formBug] = Form.useForm();
|
||||
|
||||
const popoverContent = (
|
||||
<Form
|
||||
layout={"vertical"}
|
||||
form={formBug}
|
||||
initialValues={{ problem: '' }}
|
||||
scrollToFirstError
|
||||
onFinish={async (values) => {
|
||||
const success = await uploadPageSpyLog();
|
||||
messageApi.success("Thanks for the feedback😊");
|
||||
if (success) {
|
||||
sendNotify(currentUser?.realname + "说:" + values.problem);
|
||||
} else {
|
||||
sendNotify(currentUser?.realname + "上传日志失败");
|
||||
}
|
||||
hide();
|
||||
formBug.setFieldsValue({problem: ''});
|
||||
}}
|
||||
>
|
||||
<Form.Item
|
||||
name="problem"
|
||||
label="Need help?"
|
||||
rules={[{ required: true, message: "Specify issue needing support." }]}
|
||||
>
|
||||
<Input.TextArea rows={3} />
|
||||
</Form.Item>
|
||||
<Button
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
color="cyan"
|
||||
variant="solid"
|
||||
block
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
</Form>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{contextHolder}
|
||||
<Popover
|
||||
content={popoverContent}
|
||||
trigger={["click"]}
|
||||
placement="topRight"
|
||||
open={open}
|
||||
onOpenChange={handleOpenChange}
|
||||
fresh
|
||||
destroyOnHidden
|
||||
>
|
||||
<FloatButton icon={<BugOutlined />} />
|
||||
</Popover>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default LogUploader;
|
||||
@ -1,77 +0,0 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Spin, Cascader } from 'antd';
|
||||
import { fetchJSON } from '@haina/utils-request';
|
||||
import { HT_HOST } from '@/config';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { groupBy } from '@haina/utils-commons';
|
||||
|
||||
// 产品列表
|
||||
export const fetchAgencyProductsList = async (params) => {
|
||||
const map = { title: 'label', id: 'value' };
|
||||
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel_agency_products`, params);
|
||||
const byTypes = errcode !== 0 ? {} : (groupBy(result.products, (row) => row.info.product_type_name));
|
||||
// console.log(byTypes)
|
||||
return Object.keys(byTypes).map((type_name) => ({
|
||||
label: type_name,
|
||||
title: type_name,
|
||||
key: type_name,
|
||||
value: type_name,
|
||||
// disableCheckbox: true,
|
||||
level: 1,
|
||||
options: byTypes[type_name].map((row) => ({ ...row, label: `${row.info.code} : ${row.info.title}`, value: row.info.id })),
|
||||
children: byTypes[type_name].map((row) => ({ ...row, label: `${row.info.code} : ${row.info.title}`, value: row.info.id, key: row.info.id, level:2 })),
|
||||
}));
|
||||
};
|
||||
|
||||
const ProductsSelector = ({ params, value, ...props }) => {
|
||||
const { t } = useTranslation();
|
||||
const [fetching, setFetching] = useState(false);
|
||||
const [options, setOptions] = useState([]);
|
||||
|
||||
const fetchAction = async () => {
|
||||
setOptions([]);
|
||||
setFetching(true);
|
||||
const data = await fetchAgencyProductsList(params);
|
||||
// console.log(data)
|
||||
setOptions(data);
|
||||
setFetching(false);
|
||||
return data;
|
||||
};
|
||||
useEffect(() => {
|
||||
fetchAction();
|
||||
|
||||
return () => {};
|
||||
}, []);
|
||||
|
||||
const filter = (inputValue, path) => path.some((option) => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
|
||||
|
||||
const onCascaderChange = (value, selectedOptions) => {
|
||||
// console.log(value, selectedOptions)
|
||||
const selectedP = selectedOptions.map(([parent, item]) => item);
|
||||
// console.log(selectedP);
|
||||
if (typeof props.onChange === 'function') {
|
||||
props.onChange(selectedP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Cascader
|
||||
placeholder={t('products:ProductName')}
|
||||
allowClear
|
||||
expandTrigger="hover"
|
||||
multiple
|
||||
showCheckedStrategy={Cascader.SHOW_CHILD}
|
||||
maxTagCount={0}
|
||||
classNames={{ popup: { root: 'h-96 overflow-y-auto [&_.ant-cascader-menu]:h-full [&_.ant-cascader-checkbox-disabled]:hidden'}}}
|
||||
{...props}
|
||||
notFoundContent={fetching ? <Spin size='small' /> : null}
|
||||
options={options}
|
||||
onChange={onCascaderChange}
|
||||
showSearch={{ filter }}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ProductsSelector;
|
||||
@ -1,397 +0,0 @@
|
||||
import { flush, groupBy, isEmpty, isNotEmpty, pick, unique, uniqWith } from '@haina/utils-commons';
|
||||
import dayjs from 'dayjs';
|
||||
import { formatGroupSize } from './useProductsSets';
|
||||
|
||||
// Shoulder Season 平季; peak season 旺季
|
||||
export const isFullYearOrLonger = (year, startDate, endDate) => {
|
||||
// Parse the dates
|
||||
const start = dayjs(startDate, 'YYYY-MM-DD');
|
||||
const end = dayjs(endDate, 'YYYY-MM-DD');
|
||||
|
||||
// Create the start and end dates for the year
|
||||
const yearStart = dayjs(`${year}-01-01`, 'YYYY-MM-DD');
|
||||
const yearEnd = dayjs(`${year}-12-31`, 'YYYY-MM-DD');
|
||||
|
||||
// Check if start is '01-01' and end is '12-31' and the year matches
|
||||
const isFullYear = start.isSame(yearStart, 'day') && end.isSame(yearEnd, 'day');
|
||||
|
||||
// Check if the range is longer than a year
|
||||
const isLongerThanYear = end.diff(startDate, 'year') >= 1;
|
||||
const isLongerThan12M = end.diff(startDate, 'month') >= 11;
|
||||
|
||||
return isFullYear || isLongerThanYear || isLongerThan12M;
|
||||
};
|
||||
|
||||
const uniqueBySub = (arr) => {
|
||||
const sortedArr = arr.sort((a, b) => b.length - a.length);
|
||||
const uniqueArr = [];
|
||||
sortedArr.forEach((currentSubArr) => {
|
||||
const isSubsetOfUnique = uniqueArr.some((uniqueSubArr) => {
|
||||
return currentSubArr.every((item) => uniqueSubArr.includes(item));
|
||||
});
|
||||
if (!isSubsetOfUnique) {
|
||||
uniqueArr.push(currentSubArr);
|
||||
}
|
||||
});
|
||||
|
||||
return uniqueArr;
|
||||
}
|
||||
|
||||
export const chunkBy = (use_year, dataList = [], by = []) => {
|
||||
const dataRollSS = dataList.map((rowp, ii) => {
|
||||
const quotation = rowp.quotation.map((quoteItem) => {
|
||||
return {
|
||||
...quoteItem,
|
||||
quote_season: isFullYearOrLonger(use_year, quoteItem.use_dates_start, quoteItem.use_dates_end) ? 'SS' : 'PS',
|
||||
};
|
||||
});
|
||||
return { ...rowp, quotation };
|
||||
});
|
||||
|
||||
// 人等分组只取平季, 因为产品只一行
|
||||
const allQuotesSS = dataRollSS.reduce((acc, rowp) => acc.concat(rowp.quotation.filter((q) => q.quote_season === 'SS')), []);
|
||||
|
||||
const allQuotesPS = dataRollSS.reduce((acc, rowp) => acc.concat(rowp.quotation.filter((q) => q.quote_season === 'PS')), []);
|
||||
const allQuotesSSS = isEmpty(allQuotesSS) ? allQuotesPS : allQuotesSS;
|
||||
|
||||
const allQuotesSSS2 = [].concat(allQuotesSS, allQuotesPS);
|
||||
|
||||
const PGroupSizeSS = allQuotesSSS.reduce((aq, cq) => {
|
||||
aq[cq.WPI_SN] = aq[cq.WPI_SN] || [];
|
||||
const minSize = cq.group_size_min === 0 ? 1 : cq.group_size_min;
|
||||
aq[cq.WPI_SN].push(`${minSize}-${cq.group_size_max}`);
|
||||
// aq[cq.WPI_SN].push([cq.group_size_min, cq.group_size_max]);
|
||||
// aq[cq.WPI_SN].push(cq.group_size_min);
|
||||
aq[cq.WPI_SN] = unique(aq[cq.WPI_SN]);
|
||||
aq[cq.WPI_SN] = aq[cq.WPI_SN].slice().sort((a, b) => a.split('-')[0] - b.split('-')[0]);
|
||||
return aq;
|
||||
}, {});
|
||||
// debug:
|
||||
// PGroupSizeSS['5098'] = ['1-1000'];
|
||||
// PGroupSizeSS['5099'] = ['1-2', '3-4'];
|
||||
|
||||
const PGroupSizePS = allQuotesPS.reduce((aq, cq) => {
|
||||
aq[cq.WPI_SN] = aq[cq.WPI_SN] || [];
|
||||
const minSize = cq.group_size_min === 0 ? 1 : cq.group_size_min;
|
||||
aq[cq.WPI_SN].push(`${minSize}-${cq.group_size_max}`);
|
||||
// aq[cq.WPI_SN].push([cq.group_size_min, cq.group_size_max]);
|
||||
// aq[cq.WPI_SN].push(cq.group_size_min);
|
||||
aq[cq.WPI_SN] = unique(aq[cq.WPI_SN]);
|
||||
aq[cq.WPI_SN] = aq[cq.WPI_SN].slice().sort((a, b) => a.split('-')[0] - b.split('-')[0]);
|
||||
return aq;
|
||||
}, {});
|
||||
|
||||
// 补全产品旺季的人等分组 (当旺季和平季的人等不完全一致时)
|
||||
const allWPI = unique(allQuotesSSS2.map((ele) => ele.WPI_SN));
|
||||
for (const WPI of allWPI) {
|
||||
// for (const WPI in PGroupSizeSS) {
|
||||
// if (Object.prototype.hasOwnProperty.call(PGroupSizeSS, WPI)) {
|
||||
const element = PGroupSizeSS[WPI] || [];
|
||||
const elementP = PGroupSizePS[WPI] || [];
|
||||
const diff = (elementP || []).filter((ele, index) => !element.includes(ele));
|
||||
PGroupSizeSS[WPI] = element.concat(diff);
|
||||
// }
|
||||
}
|
||||
|
||||
// console.log('PGroupSizeSS', PGroupSizeSS, '\nPGroupSizePS', PGroupSizePS, '\nallQuotesSSS', allQuotesSSS2)
|
||||
|
||||
// const maxGroupSize = Math.max(...allQuotesSSS.map((q) => q.group_size_max));
|
||||
// const maxSet = maxGroupSize === 1000 ? Infinity : maxGroupSize;
|
||||
|
||||
const _SSMinSet = uniqWith(Object.values(PGroupSizeSS), (a, b) => a.join(',') === b.join(','));
|
||||
// const uSSsizeSetArr = (_SSMinSet)
|
||||
const uSSsizeSetArr = uniqueBySub(_SSMinSet);
|
||||
// console.log('_SSMinSet', _SSMinSet, '\n uSSsizeSetArr', uSSsizeSetArr)
|
||||
|
||||
// * 若不重叠分组, 则上面不要 uniqueBySub
|
||||
for (const key in PGroupSizeSS) {
|
||||
if (Object.prototype.hasOwnProperty.call(PGroupSizeSS, key)) {
|
||||
const element = PGroupSizeSS[key];
|
||||
const findSet = uSSsizeSetArr.find((minCut) => element.every((v) => minCut.includes(v)));
|
||||
PGroupSizeSS[key] = findSet;
|
||||
}
|
||||
}
|
||||
// console.log('PGroupSizeSS -- ', PGroupSizeSS)
|
||||
|
||||
const [SSsizeSets, PSsizeSets] = [uSSsizeSetArr, []].map((arr) => {
|
||||
const _arr = structuredClone(arr);
|
||||
const arrSets = _arr.map((keyMinMaxStrs) =>
|
||||
keyMinMaxStrs.reduce((acc, curr, idx, minMaxArr) => {
|
||||
const curArr = curr.split('-').map(val => parseInt(val, 10));
|
||||
acc.push(curArr);
|
||||
// const _max = idx === minsArr.length - 1 ? maxSet : Number(minsArr[idx + 1]) - 1;
|
||||
// acc.push([Number(curr), _max]);
|
||||
return acc;
|
||||
}, [])
|
||||
);
|
||||
return arrSets;
|
||||
});
|
||||
|
||||
// console.log('uSSsizeSetArr', uSSsizeSetArr);
|
||||
const [SSsizeSetsMap, PSsizeSetsMap] = [uSSsizeSetArr, []].map((arr) => {
|
||||
const _arr = structuredClone(arr);
|
||||
const SetsMap = _arr.reduce((acc, keyMinMaxStrs, ii, strArr) => {
|
||||
const _key = keyMinMaxStrs.join(',');
|
||||
// console.log(_key);
|
||||
const _value = keyMinMaxStrs.reduce((acc, curr, idx, minMaxArr) => {
|
||||
const curArr = curr.split('-').map((val) => parseInt(val, 10));
|
||||
acc.push(curArr);
|
||||
return acc;
|
||||
}, []);
|
||||
return { ...acc, [_key]: _value };
|
||||
}, {});
|
||||
return SetsMap;
|
||||
});
|
||||
// console.log('SSsizeSetsMap', SSsizeSetsMap);
|
||||
|
||||
const compactSizeSets = {
|
||||
SSsizeSetKey: uSSsizeSetArr.map((s) => s.join(',')).filter(isNotEmpty),
|
||||
sizeSets: SSsizeSets,
|
||||
SSsizeSetsMap,
|
||||
};
|
||||
// console.log('sizeSets -- ', SSsizeSets, '\nSSsizeSetKey', compactSizeSets.SSsizeSetKey, '\nSSsizeSetsMap', SSsizeSetsMap)
|
||||
|
||||
const chunkSS = structuredClone(dataRollSS).map((rowp) => {
|
||||
const pkey = (PGroupSizeSS[rowp.info.id] || []).join(',') || compactSizeSets.SSsizeSetKey[0]; // todo:
|
||||
|
||||
let unitCnt = { '0': 0, '1': 0 }; // ? todo: 以平季的为准
|
||||
const _quotation = rowp.quotation.map((quoteItem) => {
|
||||
unitCnt[quoteItem.unit_id]++;
|
||||
|
||||
quoteItem.quote_size = pkey;
|
||||
quoteItem.quote_col_key = formatGroupSize(quoteItem.group_size_min, quoteItem.group_size_max);
|
||||
quoteItem.use_dates_start = quoteItem.use_dates_start.replace(/-/g, '.');
|
||||
quoteItem.use_dates_end = quoteItem.use_dates_end.replace(/-/g, '.');
|
||||
return quoteItem;
|
||||
});
|
||||
const quote_chunk_flat = groupBy(_quotation, (quoteItem2) => by.map((key) => quoteItem2[key]).join('@') || '#');
|
||||
const quote_chunk = Object.keys(quote_chunk_flat).reduce((qc, ckey) => {
|
||||
const ckeyArr = ckey.split('@');
|
||||
if (isEmpty(qc[ckeyArr[0]])) {
|
||||
qc[ckeyArr[0]] = ckeyArr[1] ? { [ckeyArr[1]]: quote_chunk_flat[ckey] } : quote_chunk_flat[ckey];
|
||||
} else {
|
||||
qc[ckeyArr[0]][ckeyArr[1]] = (qc[ckeyArr[0]][ckeyArr[1]] || []).concat(quote_chunk_flat[ckey]);
|
||||
}
|
||||
return qc;
|
||||
}, {});
|
||||
|
||||
const _quotationTransposeBySize = Object.keys(quote_chunk).reduce((accBy, byKey) => {
|
||||
const byValues = quote_chunk[byKey];
|
||||
const groupTablesBySize = groupBy(byValues, 'quote_size');
|
||||
const transposeTables = Object.keys(groupTablesBySize).reduce((accBy, sizeKeys) => {
|
||||
const _sizeRows = groupTablesBySize[sizeKeys];
|
||||
const rowsByDate = groupBy(_sizeRows, qi => `${qi.use_dates_start}~${qi.use_dates_end}`);
|
||||
const _rowsFromDate = Object.keys(rowsByDate).reduce((accDate, dateKeys) => {
|
||||
const _dateRows = rowsByDate[dateKeys];
|
||||
const rowKey = _dateRows.map(e => e.id).join(',');
|
||||
const keepCol = pick(_dateRows[0], ['WPI_SN', 'WPP_VEI_SN', 'currency', 'unit_id', 'unit_name', 'use_dates_start', 'use_dates_end', 'weekdays', 'quote_season']);
|
||||
const _colFromDateRow = _dateRows.reduce((accCols, rowp) => {
|
||||
// const _colRow = pick(rowp, ['currency', 'unit_id', 'unit_name', 'use_dates_start', 'use_dates_end', 'weekdays', 'child_cost', 'adult_cost']);
|
||||
return { ...accCols, [rowp.quote_col_key]: rowp };
|
||||
}, {...keepCol, originRows: _dateRows, rowKey });
|
||||
accDate.push(_colFromDateRow);
|
||||
return accDate;
|
||||
}, []);
|
||||
return { ...accBy, [sizeKeys]: _rowsFromDate };
|
||||
}, {});
|
||||
return { ...accBy, [byKey]: transposeTables };
|
||||
}, {});
|
||||
// console.log(_quotationTransposeBySize);
|
||||
|
||||
return {
|
||||
...rowp,
|
||||
unitCnt,
|
||||
unitSet: Object.keys(unitCnt).reduce((a, b) => unitCnt[a] > unitCnt[b] ? a : b),
|
||||
sizeSetsSS: pkey,
|
||||
_quotationTransposeBySize,
|
||||
quotation: _quotation,
|
||||
quote_chunk,
|
||||
};
|
||||
});
|
||||
|
||||
const allquotation = chunkSS.reduce((a, c) => a.concat(c.quotation), []);
|
||||
// 取出两季相应的时效区间
|
||||
const SSRange = unique((allquotation || []).filter((q) => q.quote_season === 'SS').map((qr) => `${qr.use_dates_start}~${qr.use_dates_end}`));
|
||||
const PSRange = unique((allquotation || []).filter((q) => q.quote_season === 'PS').map((qr) => `${qr.use_dates_start}~${qr.use_dates_end}`));
|
||||
|
||||
// const transposeDataSS = chunkSS
|
||||
|
||||
return {
|
||||
chunk: chunkSS,
|
||||
// dataSource: chunkSS,
|
||||
SSRange,
|
||||
PSRange,
|
||||
...compactSizeSets, // { SSsizeSetKey, sizeSets }
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 按[单位, 人等]拆分表格
|
||||
* @use D J B R 8
|
||||
*/
|
||||
export const splitTable_SizeSets = (chunkData) => {
|
||||
const { SSRange, PSRange, SSsizeSetKey, SSsizeSetsMap, chunk } = chunkData;
|
||||
// console.log('---- chunk', chunk);
|
||||
const bySizeUnitSetKey = groupBy(chunk, pitem => ['unitSet', 'sizeSetsSS', ].map((key) => pitem[key]).join('@'));
|
||||
// agencyProducts.J.
|
||||
// console.log('bySizeSetKey', bySizeUnitSetKey);
|
||||
const tables = Object.keys(bySizeUnitSetKey).map((sizeSetsUnitStr) => {
|
||||
const [unitSet, sizeSetsStr] = sizeSetsUnitStr.split('@');
|
||||
const _thisSSsetProducts = bySizeUnitSetKey[sizeSetsUnitStr];
|
||||
const _subTable = _thisSSsetProducts.map(({ info, sizeSetsSS, _quotationTransposeBySize, unitSet, ...pitem }) => {
|
||||
const transpose = _quotationTransposeBySize?.['#']?.[sizeSetsSS] || [];
|
||||
const _pRow = transpose.map((quote, qi) => ({ ...quote, rowSpan: qi === 0 ? transpose.length : 0 }));
|
||||
return { info, sizeSetsSS, unitSet, rows: _pRow, transpose };
|
||||
});
|
||||
return { cols: SSsizeSetsMap[sizeSetsStr], colsKey: sizeSetsStr, unitSet, sizeSetsUnitStr, data: _subTable };
|
||||
});
|
||||
// console.log('---- tables', tables);
|
||||
const tablesQuote = tables.map(({ cols, colsKey, unitSet, sizeSetsUnitStr, data }, ti) => {
|
||||
const _table = data.reduce((acc, prow) => {
|
||||
const prows = prow.rows.map((_q) => ({ ..._q, info: prow.info, dateText: `${_q.use_dates_start}~${_q.use_dates_end}` }));
|
||||
return acc.concat(prows);
|
||||
}, []);
|
||||
return { cols: (cols || []), colsKey: sizeSetsUnitStr, data: _table }; // `${unitSet}@${colsKey}`
|
||||
});
|
||||
// console.log('---- tablesQuote', tablesQuote);
|
||||
return tablesQuote;
|
||||
};
|
||||
|
||||
/**
|
||||
* 按季度分列 [平季, 旺季]
|
||||
* @use Q 7 6
|
||||
*/
|
||||
export const splitTable_Season = (chunkData) => {
|
||||
const { SSRange, PSRange, SSsizeSetKey, SSsizeSetsMap, chunk } = chunkData;
|
||||
// console.log(chunkData);
|
||||
const tablesQuote = chunk.map((pitem) => {
|
||||
const { quote_chunk } = pitem;
|
||||
// const bySeason = groupBy(pitem.quotation, (ele) => ele.quote_season);
|
||||
const rowSeason = Object.keys(quote_chunk).reduce((accp, _s) => {
|
||||
const bySeasonValue = groupBy(quote_chunk[_s], (ele) => ['adult_cost', 'child_cost', 'group_size_min', 'group_size_max', 'unit_id'].map((k) => ele[k]).join('@'));
|
||||
// console.log('---- bySeasonValue', _s, bySeasonValue);
|
||||
|
||||
const byDate = groupBy(quote_chunk[_s], (ele) => `${ele.use_dates_start}~${ele.use_dates_end}`);
|
||||
// console.log('---- byDate', _s, byDate);
|
||||
|
||||
const subHeader = Object.keys(bySeasonValue).length >= Object.keys(byDate).length ? 'dates' : 'priceValues';
|
||||
// console.log('---- subHeader', _s, subHeader);
|
||||
|
||||
let valuesArr = [];
|
||||
switch (subHeader) {
|
||||
case 'priceValues':
|
||||
valuesArr = Object.keys(bySeasonValue).reduce((accv, valKey) => {
|
||||
const valRows = bySeasonValue[valKey];
|
||||
const valRow = pick(valRows[0], ['adult_cost', 'child_cost', 'currency', 'unit_id', 'unit_name', 'group_size_min', 'group_size_max']);
|
||||
// valRow.dates = valRows.map((v) => pick(v, ['id', 'use_dates_end', 'use_dates_start']));
|
||||
valRow.rows = [valRows[0]];
|
||||
valRow.originRows = valRows;
|
||||
valRow.rowKey = valRows.map((v) => v.id).join(',');
|
||||
valRow.headerDates = valRows.map((v) => pick(v, ['use_dates_end', 'use_dates_start']));
|
||||
accv.push(valRow);
|
||||
return accv;
|
||||
}, []);
|
||||
break;
|
||||
case 'dates':
|
||||
valuesArr = Object.keys(byDate).reduce((accv, dateKey) => {
|
||||
const valRows = byDate[dateKey];
|
||||
const valRow = pick(valRows[0], ['use_dates_end', 'use_dates_start']);
|
||||
valRow.rows = valRows;
|
||||
valRow.originRows = valRows;
|
||||
valRow.rowKey = valRows.map((v) => v.id).join(',');
|
||||
valRow.headerDates = [pick(valRows[0], ['use_dates_end', 'use_dates_start'])];
|
||||
accv.push(valRow);
|
||||
return accv;
|
||||
}, []);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const valUnderSeason = Object.keys(bySeasonValue).reduce((accv, valKey) => {
|
||||
const valRows = bySeasonValue[valKey];
|
||||
const valRow = pick(valRows[0], ['adult_cost', 'child_cost', 'currency', 'unit_id', 'unit_name', 'group_size_min', 'group_size_max']);
|
||||
// valRow.dates = valRows.map((v) => pick(v, ['id', 'use_dates_end', 'use_dates_start']));
|
||||
valRow.rows = valRows;
|
||||
valRow.rowKey = valRows.map(v => v.id).join(',');
|
||||
accv.push(valRow);
|
||||
return accv;
|
||||
}, []);
|
||||
|
||||
return { ...accp, [_s]: valUnderSeason, [_s + 'Data']: valuesArr };
|
||||
}, {});
|
||||
return { info: pitem.info, ...rowSeason, rowKey: pitem.info.id };
|
||||
});
|
||||
// console.log('---- tablesQuote', tablesQuote);
|
||||
return tablesQuote;
|
||||
};
|
||||
|
||||
export const splitTable_D = (use_year, dataSource, retTableOnly = true) => {
|
||||
const chunked = chunkBy(use_year, dataSource);
|
||||
// console.log(chunked);
|
||||
const tables = addCityRow4Split(splitTable_SizeSets(chunked));
|
||||
return retTableOnly ? tables : { ...chunked, tables };
|
||||
};
|
||||
|
||||
export const splitTable_J = (use_year, dataSource, retTableOnly = true) => {
|
||||
const chunked = chunkBy(use_year, dataSource);
|
||||
// console.log(chunked);
|
||||
const tables = addCityRow4Split(splitTable_SizeSets(chunked));
|
||||
return retTableOnly ? tables : { ...chunked, tables };
|
||||
};
|
||||
|
||||
export const splitTable_Q = (use_year, dataSource) => {
|
||||
const chunked = chunkBy(use_year, dataSource, ['quote_season']);
|
||||
return addCityRow4Season(splitTable_Season(chunked));
|
||||
};
|
||||
|
||||
export const splitTable_7 = (use_year, dataSource) => {
|
||||
const chunked = chunkBy(use_year, dataSource, ['quote_season']);
|
||||
return addCityRow4Season(splitTable_Season(chunked));
|
||||
};
|
||||
|
||||
export const splitTable_R = (use_year, dataSource, retTableOnly = true) => {
|
||||
const chunked = chunkBy(use_year, dataSource);
|
||||
// console.log(chunked);
|
||||
const tables = addCityRow4Split(splitTable_SizeSets(chunked));
|
||||
return retTableOnly ? tables : { ...chunked, tables };
|
||||
};
|
||||
|
||||
export const splitTable_8 = (use_year, dataSource, retTableOnly = true) => {
|
||||
const chunked = chunkBy(use_year, dataSource);
|
||||
// console.log(chunked);
|
||||
const tables = addCityRow4Split(splitTable_SizeSets(chunked));
|
||||
return retTableOnly ? tables : { ...chunked, tables };
|
||||
};
|
||||
|
||||
export const splitTable_6 = (use_year, dataSource, retTableOnly = true) => {
|
||||
const chunked = chunkBy(use_year, dataSource, ['quote_season']);
|
||||
const tables = splitTable_Season(chunked);
|
||||
return retTableOnly ? tables : { ...chunked, tables };
|
||||
};
|
||||
|
||||
export const splitTable_B = (use_year, dataSource, retTableOnly = true) => {
|
||||
const chunked = chunkBy(use_year, dataSource);
|
||||
// console.log(chunked);
|
||||
const tables = addCityRow4Split(splitTable_SizeSets(chunked));
|
||||
return retTableOnly ? tables : { ...chunked, tables };
|
||||
};
|
||||
|
||||
export const addCityRow4Season = (table) => {
|
||||
const byCity = groupBy(table, (ele) => `${ele.info.city_id}@${ele.info.city_name}`);
|
||||
const withCityRow = Object.keys(byCity).reduce((acc, cityIdName) => {
|
||||
const [cityId, cityName] = cityIdName.split('@');
|
||||
acc.push({ info: { product_title: cityName, isCityRow: true,}, use_dates_end: '', use_dates_start: '', quote_season: 'SS', rowSpan: 1, rowKey: `c_${cityId}` });
|
||||
return acc.concat(byCity[cityIdName]);
|
||||
}, []);
|
||||
return withCityRow;
|
||||
};
|
||||
|
||||
export const addCityRow4Split = (splitTables) => {
|
||||
const tables = splitTables.map(table => {
|
||||
return { ...table, data: addCityRow4Season(table.data)}
|
||||
});
|
||||
return tables;
|
||||
};
|
||||
|
||||
@ -1,23 +1,51 @@
|
||||
import { loadScript } from '@/utils/commons';
|
||||
import { PROJECT_NAME, BUILD_VERSION } from '@/config';
|
||||
import { fetchJSON } from '@haina/utils-request'
|
||||
import { usingStorage } from "@/hooks/usingStorage";
|
||||
|
||||
export const sendNotify = async (message) => {
|
||||
export const loadPageSpy = (title) => {
|
||||
|
||||
const { userId, travelAgencyId } = usingStorage();
|
||||
const notifyUrl = 'https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/SendMDMsgByDingRobotToGroup';
|
||||
if (import.meta.env.DEV || window.$pageSpy) return
|
||||
|
||||
const params = {
|
||||
groupid: 'cidFtzcIzNwNoiaGU9Q795CIg==',
|
||||
msgTitle: '有人求助',
|
||||
msgText: `${message}\\n\\nID: ${userId}, ${travelAgencyId} | ${PROJECT_NAME} (${BUILD_VERSION})`,
|
||||
};
|
||||
const PageSpyConfig = { api: 'page-spy.mycht.cn', project: PROJECT_NAME, title: title, autoRender: false };
|
||||
const PageSpySrc = [
|
||||
'https://page-spy.mycht.cn/page-spy/index.min.js'+`?${BUILD_VERSION}`,
|
||||
'https://page-spy.mycht.cn/plugin/data-harbor/index.min.js'+`?${BUILD_VERSION}`,
|
||||
'https://page-spy.mycht.cn/plugin/rrweb/index.min.js'+`?${BUILD_VERSION}`,
|
||||
];
|
||||
|
||||
return fetchJSON(notifyUrl, params).then((json) => {
|
||||
if (json.errcode === 0) {
|
||||
console.info('发送通知成功');
|
||||
} else {
|
||||
throw new Error(json?.errmsg + ': ' + json.errcode);
|
||||
}
|
||||
Promise.all(PageSpySrc.map((src) => loadScript(src))).then(() => {
|
||||
// 注册插件
|
||||
window.$harbor = new DataHarborPlugin();
|
||||
window.$rrweb = new RRWebPlugin();
|
||||
[window.$harbor, window.$rrweb].forEach(p => {
|
||||
PageSpy.registerPlugin(p)
|
||||
})
|
||||
window.$pageSpy = new PageSpy(PageSpyConfig);
|
||||
});
|
||||
};
|
||||
|
||||
export const uploadPageSpyLog = async () => {
|
||||
// window.$pageSpy.triggerPlugins('onOfflineLog', 'upload');
|
||||
if (window.$pageSpy) {
|
||||
await window.$harbor.upload() // 上传日志 { clearCache: true, remark: '' }
|
||||
alert('Success')
|
||||
} else {
|
||||
alert('Failure')
|
||||
}
|
||||
}
|
||||
|
||||
export const PageSpyLog = () => {
|
||||
return (
|
||||
<>
|
||||
{window.$pageSpy && (
|
||||
<a
|
||||
className='text-primary'
|
||||
onClick={() => {
|
||||
window.$pageSpy.triggerPlugins('onOfflineLog', 'download');
|
||||
window.$pageSpy.triggerPlugins('onOfflineLog', 'upload');
|
||||
}}>
|
||||
上传Debug日志 ({window.$pageSpy.address.substring(0, 4)})
|
||||
</a>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@ -1,82 +0,0 @@
|
||||
import { create } from 'zustand'
|
||||
import { devtools } from 'zustand/middleware'
|
||||
import { fetchJSON, postForm } from '@haina/utils-request'
|
||||
import { DATE_FORMAT, TGA_HOST } from "@/config"
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const fetchAllItinerary = async (reservationId) => {
|
||||
const { errcode, result } = await fetchJSON(
|
||||
`${TGA_HOST}/api/index.php/oversea/all_itinerary/`,
|
||||
{ group_id: reservationId })
|
||||
|
||||
return errcode !== 0 ? {} : result
|
||||
}
|
||||
|
||||
export const fetchTransport = async (reservationId) => {
|
||||
const { errcode, result } = await fetchJSON(
|
||||
`${TGA_HOST}/api/index.php/oversea/transport/`,
|
||||
{ group_id: reservationId })
|
||||
|
||||
return errcode !== 0 ? {} : result
|
||||
}
|
||||
|
||||
export const fetchRecentGroup = async (travelAgencyId) => {
|
||||
const { errcode, result } = await fetchJSON(
|
||||
`${TGA_HOST}/api/index.php/plan/get_recent_group/`,
|
||||
{ travel_agency_id: travelAgencyId })
|
||||
|
||||
return errcode !== 0 ? {} : result
|
||||
}
|
||||
|
||||
export const initialState = {
|
||||
review: {
|
||||
"reviewId": undefined,
|
||||
"reviewLink": '',
|
||||
"datePosted": undefined,
|
||||
"customerId": '',
|
||||
"referenceId": null,
|
||||
"guideId": null,
|
||||
"cityId": null
|
||||
}
|
||||
};
|
||||
|
||||
const useExternalReviewStore = create(devtools((set, get) => ({
|
||||
|
||||
reviewList: [],
|
||||
|
||||
fetchReviewList: async (formValues, travelAgencyId) => {
|
||||
|
||||
const { errcode, errmsg, result } = await fetchJSON(`${TGA_HOST}/api/index.php/customer_review/search/`,
|
||||
{ agent_id: travelAgencyId, group_number: formValues?.referenceNo??'',
|
||||
from_date: formValues?.startdate??'', thru_date: formValues?.enddate??'',
|
||||
approval_status: formValues?.approvalStatus??''
|
||||
})
|
||||
|
||||
if (errcode !== 0) {
|
||||
return Promise.reject(new Error(errmsg + ': ' + errcode))
|
||||
} else {
|
||||
set(() => ({
|
||||
reviewList: result
|
||||
}))
|
||||
|
||||
return Promise.resolve(result)
|
||||
}
|
||||
},
|
||||
|
||||
postReview: (formValues, travelAgencyId) => {
|
||||
const formData = new FormData()
|
||||
formData.append('agent_id', travelAgencyId)
|
||||
formData.append('review_id', formValues.reviewId??'')
|
||||
formData.append('review_link', formValues.reviewLink)
|
||||
formData.append('date_posted', dayjs(formValues.datePosted).format(DATE_FORMAT))
|
||||
formData.append('customer_id', formValues.customerId)
|
||||
formData.append('reference_id', formValues.referenceId)
|
||||
formData.append('guide_id', formValues.guideId)
|
||||
formData.append('city_id', formValues.cityId)
|
||||
|
||||
return postForm(`${TGA_HOST}/api/index.php/customer_review/agent_submit/`, formData)
|
||||
},
|
||||
|
||||
}), { name: 'externalReviewStore' }))
|
||||
|
||||
export default useExternalReviewStore
|
||||
@ -1,20 +1,12 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
import { usingStorage } from '@/hooks/usingStorage'
|
||||
|
||||
export const useFormStore = create(
|
||||
devtools((set, get) => ({
|
||||
formValues: {},
|
||||
setFormValues: (values) => set((state) => ({ formValues: { ...state.formValues, ...values } })),
|
||||
formValuesToSub: { agency: usingStorage().travelAgencyId },
|
||||
formValuesToSub: {},
|
||||
setFormValuesToSub: (values) => set((state) => ({ formValuesToSub: { ...state.formValuesToSub, ...values } })),
|
||||
|
||||
vendorList0: [],
|
||||
setVendorList0: (values) => set((state) => ({ vendorList0: values })),
|
||||
|
||||
cache: { },
|
||||
setCache: (values) => set((state) => ({ cache: { ...state.cache, ...values } })),
|
||||
|
||||
}), { name: 'formStore' })
|
||||
);
|
||||
export default useFormStore;
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
// 顾问查看客人上传的护照
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Input, Button, Card, Typography, Space, Alert } from 'antd';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import ImageUploader from '@/components/ImageUploader';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
const ImageViewer = () => {
|
||||
const { GRI_SN, GRI_No } = useParams();
|
||||
const [ossKey, setOssKey] = useState('');
|
||||
const [showUploader, setShowUploader] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (GRI_SN && GRI_No) {
|
||||
const key = `ghh/${GRI_SN}-${GRI_No}/passport_image`;
|
||||
setOssKey(key);
|
||||
setShowUploader(true);
|
||||
}
|
||||
}, [GRI_SN, GRI_No]);
|
||||
|
||||
|
||||
return (
|
||||
<div style={{ padding: '20px' }}>
|
||||
<Title level={2}>{GRI_SN}-{GRI_No}</Title>
|
||||
|
||||
{showUploader && (
|
||||
<ImageUploader osskey={ossKey} />
|
||||
)}
|
||||
|
||||
{!showUploader && (
|
||||
<Text>无法从URL中提取订单信息</Text>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageViewer;
|
||||
@ -1,116 +1,109 @@
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
import { Button, Form, Input, Row, Radio, App, Typography } from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import useAuthStore from "@/stores/Auth";
|
||||
import { appendRequestParams } from "@haina/utils-request";
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useEffect } from 'react'
|
||||
import { Button, Form, Input, Row, Radio, App } from 'antd'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import useAuthStore from '@/stores/Auth'
|
||||
import { appendRequestParams } from '@/utils/request'
|
||||
|
||||
function Login() {
|
||||
const [authenticate, loginStatus, defaultRoute] = useAuthStore((state) => [
|
||||
state.authenticate,
|
||||
state.loginStatus,
|
||||
state.defaultRoute,
|
||||
]);
|
||||
const [authenticate, loginStatus, defaultRoute] =
|
||||
useAuthStore((state) => [state.authenticate, state.loginStatus, state.defaultRoute])
|
||||
|
||||
const { t, i18n } = useTranslation();
|
||||
const { notification } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
const [form] = Form.useForm();
|
||||
const { t, i18n } = useTranslation()
|
||||
const { notification } = App.useApp()
|
||||
const navigate = useNavigate()
|
||||
const [form] = Form.useForm()
|
||||
|
||||
const handleLngChange = (lng) => {
|
||||
appendRequestParams("lgc", lng === "zh" ? 2 : 1);
|
||||
i18n.changeLanguage(lng);
|
||||
};
|
||||
appendRequestParams('lgc', lng === 'zh' ? 2 : 1)
|
||||
i18n.changeLanguage(lng)
|
||||
}
|
||||
|
||||
const defaultLng = i18n.language ?? "zh";
|
||||
appendRequestParams("lgc", defaultLng === "zh" ? 2 : 1);
|
||||
const defaultLng = i18n.language??'zh'
|
||||
appendRequestParams('lgc', defaultLng === 'zh' ? 2 : 1)
|
||||
|
||||
useEffect(() => {
|
||||
useEffect (() => {
|
||||
if (loginStatus === 302) {
|
||||
navigate(defaultRoute);
|
||||
navigate(defaultRoute)
|
||||
}
|
||||
}, [loginStatus]);
|
||||
}, [loginStatus])
|
||||
|
||||
const onFinish = (values) => {
|
||||
authenticate(values.username, values.password).catch((ex) => {
|
||||
console.error(ex);
|
||||
notification.error({
|
||||
message: t("Validation.Title"),
|
||||
description: t("Validation.LoginFailed"),
|
||||
placement: "top",
|
||||
duration: 4,
|
||||
});
|
||||
});
|
||||
};
|
||||
authenticate(values.username, values.password)
|
||||
.catch(ex => {
|
||||
console.error(ex)
|
||||
notification.error({
|
||||
message: t('Validation.Title'),
|
||||
description: t('Validation.LoginFailed'),
|
||||
placement: 'top',
|
||||
duration: 4,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const onFinishFailed = (errorInfo) => {
|
||||
console.log("Failed:", errorInfo);
|
||||
};
|
||||
console.log('Failed:', errorInfo);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Typography.Title className="text-center" level={3}>
|
||||
Highlights Hub
|
||||
</Typography.Title>
|
||||
<Row justify="center" align="middle" className="min-h-96">
|
||||
<Form
|
||||
name="login"
|
||||
layout="vertical"
|
||||
form={form}
|
||||
size="large"
|
||||
labelCol={{
|
||||
span: 8,
|
||||
}}
|
||||
wrapperCol={{
|
||||
span: 24,
|
||||
}}
|
||||
className="max-w-xl"
|
||||
initialValues={{
|
||||
language: defaultLng,
|
||||
}}
|
||||
onFinish={onFinish}
|
||||
onFinishFailed={onFinishFailed}
|
||||
autoComplete="off"
|
||||
<Row justify='center' align='middle' className='min-h-96'>
|
||||
<Form
|
||||
name='login'
|
||||
layout='vertical'
|
||||
form={form}
|
||||
size='large'
|
||||
labelCol={{
|
||||
span: 8,
|
||||
}}
|
||||
wrapperCol={{
|
||||
span: 24,
|
||||
}}
|
||||
className='max-w-xl'
|
||||
initialValues={{
|
||||
language: defaultLng,
|
||||
}}
|
||||
onFinish={onFinish}
|
||||
onFinishFailed={onFinishFailed}
|
||||
autoComplete='off'
|
||||
>
|
||||
<Form.Item
|
||||
label={t('Username')}
|
||||
name='username'
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t('Validation.UsernameIsEmpty'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Form.Item
|
||||
label={t("Username")}
|
||||
name="username"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("Validation.UsernameIsEmpty"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("Password")}
|
||||
name="password"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("Validation.PasswordIsEmpty"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item name="language">
|
||||
<Radio.Group onChange={(e) => handleLngChange(e.target.value)}>
|
||||
<Radio value="zh">中文</Radio>
|
||||
<Radio value="en">English</Radio>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type="primary" htmlType="submit" className="w-full">
|
||||
{t("Login")}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t('Password')}
|
||||
name='password'
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t('Validation.PasswordIsEmpty'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item name='language'>
|
||||
<Radio.Group onChange={e => handleLngChange(e.target.value)}>
|
||||
<Radio value='zh'>中文</Radio>
|
||||
<Radio value='en'>English</Radio>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type='primary' htmlType='submit' className='w-full'>
|
||||
{t('Login')}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Row>
|
||||
)
|
||||
}
|
||||
|
||||
export default Login;
|
||||
export default Login
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
import { Button } from 'antd';
|
||||
import { clearAllCaches } from '@haina/utils-commons';
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
const ReloadUpdate = ({ ...props }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const forceReload = async () => {
|
||||
await clearAllCaches();
|
||||
window.location.reload(true);
|
||||
};
|
||||
return (
|
||||
<Button type={'link'} onClick={forceReload} className={`ms-2 `} {...props}>
|
||||
{t('SystemUpdate')} 🚀
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
export default ReloadUpdate;
|
||||
@ -1,227 +0,0 @@
|
||||
import { createContext, useEffect, useMemo, useState, useRef } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { App, Row, Col, Space, Typography, Divider, Form, Input, Select, Button, Tag } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { fetchNotifsDetail, fetchNotifsStatusAgency, postNotifsNewOrEdit } from '@/stores/Notice';
|
||||
import useFormStore from "@/stores/Form";
|
||||
import BackBtn from '@/components/BackBtn';
|
||||
import { usingStorage } from '@/hooks/usingStorage';
|
||||
import VendorSelector from '@/components/VendorSelector';
|
||||
import { isEmpty, objectMapper } from '@haina/utils-commons';
|
||||
import Editor from '@/components/Editor';
|
||||
|
||||
const { Title, Paragraph } = Typography;
|
||||
|
||||
const allOverseasAgency = [
|
||||
{ key: 30008, value: 30008, label: 'Luxe Voyage Tours-已签海纳协议' },
|
||||
{ key: 31596, value: 31596, label: '印度Legend' },
|
||||
{ key: 32531, value: 32531, label: '越南ANP TRAVEL' },
|
||||
{ key: 32704, value: 32704, label: '泰北 NUT ' },
|
||||
{ key: 32717, value: 32717, label: 'JCT株式会社' },
|
||||
{ key: 32865, value: 32865, label: '泰国IAT' },
|
||||
{ key: 32876, value: 32876, label: 'Japan Fleet' },
|
||||
// { key: 33031, value: 33031, label: 'test海外地接A' },
|
||||
// { key: 33032, value: 33032, label: 'test海外地接B' },
|
||||
{ key: 33200, value: 33200, label: '新加坡途游' },
|
||||
{ key: 33508, value: 33508, label: '日本DJ(注意加服务交通费)' },
|
||||
{ key: 33796, value: 33796, label: '韩国 Halla Tour' },
|
||||
];
|
||||
|
||||
const Edit = ({ ...props }) => {
|
||||
const { t } = useTranslation();
|
||||
const { message } = App.useApp();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { CCP_BLID } = useParams();
|
||||
const { userId } = usingStorage();
|
||||
const actionNew = useMemo(() => CCP_BLID === '0', [CCP_BLID]);
|
||||
const [form] = Form.useForm();
|
||||
const clickedButton = useRef('');
|
||||
const quillRef = useRef();
|
||||
const setCache = useFormStore(state => state.setCache);
|
||||
|
||||
|
||||
const [showAgencySelector, setShowAgencySelector] = useState(1);
|
||||
const [showAgencySeleted, setShowAgencySeleted] = useState(0);
|
||||
|
||||
// const [noticeInfo, setNoticeInfo] = useState({});
|
||||
// const [recipientsAgency, setRecipientsAgency] = useState([]);
|
||||
useEffect(() => {
|
||||
if (CCP_BLID !== '0') {
|
||||
fetchNotifsDetail(CCP_BLID).then((res) => {
|
||||
form.setFieldsValue({
|
||||
title: res.title,
|
||||
body: res.body,
|
||||
target: { value: '_list', key: '_list', label: '我自己选' },
|
||||
});
|
||||
setShowAgencySelector(1);
|
||||
setShowAgencySeleted(1);
|
||||
});
|
||||
fetchNotifsStatusAgency(CCP_BLID).then((res) => {
|
||||
const _list = res.map((item) => ({ key: item.agencyId, value: item.agencyId, label: item.agencyName }));
|
||||
// setRecipientsAgency(_list);
|
||||
form.setFieldsValue({
|
||||
agency_list: _list,
|
||||
});
|
||||
setCache({ vendorList: _list })
|
||||
});
|
||||
} else {
|
||||
setCache({ vendorList: allOverseasAgency })
|
||||
}
|
||||
}, []);
|
||||
|
||||
const onValuesChange = (changeValues, allValues) => {
|
||||
if ('target' in changeValues) {
|
||||
setShowAgencySelector(changeValues.target.value === '_list' ? 1 : 0);
|
||||
setShowAgencySeleted(changeValues.target.value === '_list' ? 1 : 0);
|
||||
// if (changeValues.target.value !== '_list') {
|
||||
// setShowAgencySeleted(0);
|
||||
// }
|
||||
}
|
||||
if ('agency_list' in changeValues) {
|
||||
setShowAgencySeleted(changeValues.agency_list.length > 0 ? 1 : 0);
|
||||
}
|
||||
// console.log('⏩', changeValues);
|
||||
};
|
||||
|
||||
const handleRemoveAgency = (ele) => {
|
||||
// console.log('⛔', ele);
|
||||
const newSeleted = form.getFieldValue('agency_list').filter((item) => item.key !== ele.key);
|
||||
// remove from form fieldsValues
|
||||
form.setFieldsValue({ agency_list: newSeleted });
|
||||
setShowAgencySeleted(newSeleted.length > 0 ? 1 : 0);
|
||||
};
|
||||
|
||||
const [cLoading, setCLoading] = useState(false);
|
||||
const onSubmitNotifs = (values) => {
|
||||
// console.log('🟩', clickedButton.current);
|
||||
// console.log('Received values of form, origin form value: \n', values);
|
||||
setCLoading(true);
|
||||
const formValuesMapper = {
|
||||
title: { key: 'title', transform: (value) => value || '' },
|
||||
body: { key: 'body', transform: (value) => value || '' },
|
||||
// target: { key: 'groups', transform: (value) => value?.value || '' }, // === '_list' ? '' : value.value
|
||||
target: { key: 'groups', transform: (value) => (value?.value || '') === '_list' ? '' : value.value }, // === '_list' ? '' : value.value
|
||||
agency_list: {
|
||||
key: 'ids',
|
||||
transform: (value) => {
|
||||
// .join(',')
|
||||
return Array.isArray(value) ? value.map((ele) => Number(ele.value)) : value ? value.value : [];
|
||||
},
|
||||
},
|
||||
};
|
||||
let dest = {};
|
||||
const { target, agency_list, ...omittedValue } = values;
|
||||
dest = { ...omittedValue, ...objectMapper(values, formValuesMapper) }; // 映射+保留原始字段名
|
||||
// dest = objectMapper(values, formValuesMapper);
|
||||
for (const key in dest) {
|
||||
if (Object.prototype.hasOwnProperty.call(dest, key)) {
|
||||
dest[key] = typeof dest[key] === 'string' ? (dest[key] || '').trim() : dest[key];
|
||||
}
|
||||
}
|
||||
const { ids, groups, ...readyFormData } = dest;
|
||||
readyFormData.recipientsAgency = { ids: isEmpty(groups) ? ids : [], groups: groups || '' };
|
||||
readyFormData.publish_state = clickedButton.current === 'saveAndPublish' ? '1' : '0';
|
||||
readyFormData.id = CCP_BLID === '0' ? '' : CCP_BLID;
|
||||
// console.log('form value send to onSubmit:\n', readyFormData);
|
||||
postNotifsNewOrEdit(CCP_BLID, readyFormData).then((res) => {
|
||||
message.success(t('Success'));
|
||||
navigate('/notice');
|
||||
setCLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
const onFinishFailed = ({ values, errorFields }) => {
|
||||
// console.log('form validate failed', '\nform values:', values, '\nerrorFields', errorFields);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Space direction='vertical' style={{ width: '100%' }}>
|
||||
<Row gutter={16}>
|
||||
<Col span={4}></Col>
|
||||
<Col span={16}>
|
||||
<Form
|
||||
form={form}
|
||||
layout={'vertical'}
|
||||
onFinish={onSubmitNotifs}
|
||||
onValuesChange={onValuesChange}
|
||||
onFinishFailed={onFinishFailed}>
|
||||
<Form.Item name='title' label='公告标题' rules={[{ required: true }]}>
|
||||
<Input placeholder='请输入公告标题' />
|
||||
</Form.Item>
|
||||
<Form.Item noStyle>
|
||||
<Space.Compact className='w-full'>
|
||||
<Form.Item name='target' label='公告区域' initialValue={{value: '_list', label: '我自己选'}} className='w-1/3' rules={[{ required: true }]}>
|
||||
<Select placeholder='请选择公告区域' labelInValue>
|
||||
<Select.Option value='all'>所有</Select.Option>
|
||||
<Select.Option value='domestic'>国内</Select.Option>
|
||||
<Select.Option value='global'>海外</Select.Option>
|
||||
<Select.Option value='_list'>我自己选</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name={`agency_list`}
|
||||
label={'供应商'}
|
||||
dependencies={['target']}
|
||||
hidden={showAgencySelector !== 1}
|
||||
className='w-auto flex-auto'
|
||||
rules={[{ required: showAgencySelector }]}>
|
||||
<VendorSelector />
|
||||
</Form.Item>
|
||||
</Space.Compact>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item shouldUpdate hidden={showAgencySeleted !== 1}>
|
||||
{() =>
|
||||
showAgencySelector === 1 ? (
|
||||
<div className='max-h-96 overflow-auto '>
|
||||
{!isEmpty(form.getFieldValue('agency_list')) && <b>已选择的供应商: </b>}
|
||||
{(form.getFieldValue('agency_list') || []).map((item, index) => (
|
||||
<Tag key={item.value} closable={true} onClose={() => handleRemoveAgency(item)}>
|
||||
{item.label}
|
||||
</Tag>
|
||||
))}
|
||||
{!isEmpty(form.getFieldValue('agency_list')) && (
|
||||
<Button
|
||||
size='small'
|
||||
danger
|
||||
onClick={() => {
|
||||
form.setFieldValue('agency_list', []);
|
||||
setShowAgencySeleted(0);
|
||||
}}>
|
||||
{t('Clear')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<></>
|
||||
)
|
||||
}
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name='body' label='公告内容' rules={[{ required: true, }]}>
|
||||
<Editor ref={quillRef} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button type='primary' ghost htmlType='submit' loading={cLoading} onClick={() => (clickedButton.current = 'save')}>
|
||||
先保存
|
||||
</Button>
|
||||
<Button type='primary' htmlType='submit' loading={cLoading} onClick={() => (clickedButton.current = 'saveAndPublish')}>
|
||||
保存并发布
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<BackBtn />
|
||||
</Col>
|
||||
</Row>
|
||||
</Space>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Edit;
|
||||
@ -1,137 +0,0 @@
|
||||
import { Link, NavLink, useNavigate } from 'react-router-dom';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { App, Row, Col, Space, Typography, Badge, List, Button, Flex, Tabs, Popconfirm } from 'antd';
|
||||
import useNoticeStore, { fetchMyNotifsList, fetchNotifsList, delNotifs } from '@/stores/Notice';
|
||||
import { usingStorage } from '@/hooks/usingStorage';
|
||||
import useAuthStore from '@/stores/Auth';
|
||||
import { PERM_NOTIFS_MANAGEMENT, PERM_NOTIFS_DELETE_DANGER } from '@/config';
|
||||
import RequireAuth from '@/components/RequireAuth';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
function Index() {
|
||||
const { t } = useTranslation();
|
||||
const {message} = App.useApp();
|
||||
|
||||
const navigate = useNavigate();
|
||||
const isPermitted = useAuthStore((state) => state.isPermitted);
|
||||
|
||||
const { userId } = usingStorage();
|
||||
// const getBulletinUnReadCount = useNoticeStore((state) => state.getBulletinUnReadCount);
|
||||
const getNoticeUnReadCount = useNoticeStore((state) => state.getNoticeUnReadCount);
|
||||
|
||||
const [noticeList, setNoticeList] = useState([]);
|
||||
|
||||
const getList = (params) => {
|
||||
const fetchFunction = isPermitted(PERM_NOTIFS_MANAGEMENT) ? fetchNotifsList : fetchMyNotifsList;
|
||||
return fetchFunction(params);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getList().then((data) => {
|
||||
setNoticeList(data);
|
||||
});
|
||||
if (!isPermitted(PERM_NOTIFS_MANAGEMENT)) {
|
||||
getNoticeUnReadCount(userId); //进入列表页的时候更新一下未读公告
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleListByState = (state) => {
|
||||
getList({ notificationsReadState: state }).then((res) => {
|
||||
setNoticeList(res);
|
||||
});
|
||||
};
|
||||
|
||||
const handleDelNotifs = (id) => {
|
||||
delNotifs(id).then((res) => {
|
||||
message.success(t('Success'));
|
||||
getList().then((data) => {
|
||||
setNoticeList(data);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Space direction='vertical' style={{ width: '100%' }}>
|
||||
<Row gutter={16}>
|
||||
<Col span={4}></Col>
|
||||
<Col span={16}>
|
||||
<Flex align='center' justify='space-between'>
|
||||
{/* <Typography.Title level={4}>公告列表</Typography.Title> */}
|
||||
{isPermitted(PERM_NOTIFS_MANAGEMENT) ? (
|
||||
<Typography.Title level={4}>公告列表</Typography.Title>
|
||||
) : (
|
||||
<Tabs
|
||||
items={[
|
||||
{ key: '', label: t('All') },
|
||||
{ key: '0', label: t('UnRead') },
|
||||
{ key: '1', label: t('Read') },
|
||||
]}
|
||||
defaultActiveKey=''
|
||||
onChange={handleListByState}></Tabs>
|
||||
)}
|
||||
<RequireAuth subject={PERM_NOTIFS_MANAGEMENT}>
|
||||
<Link to='/notice/edit/0'>
|
||||
<Button>公告发布</Button>
|
||||
</Link>
|
||||
</RequireAuth>
|
||||
</Flex>
|
||||
<List
|
||||
dataSource={noticeList}
|
||||
pagination={{
|
||||
pageSize: 20,
|
||||
}}
|
||||
renderItem={(item) => (
|
||||
<List.Item
|
||||
className={item.notificationsReadState ? '' : 'font-bold'}
|
||||
// debug: publish_state
|
||||
actions={
|
||||
item.publish_state === 0
|
||||
? [
|
||||
<RequireAuth subject={PERM_NOTIFS_MANAGEMENT} key='notifs-edit'>
|
||||
<NavLink to={`/notice/edit/${item.notificationId}`}>{t('Edit')}</NavLink>
|
||||
</RequireAuth>,
|
||||
// <RequireAuth subject={PERM_NOTIFS_MANAGEMENT} key='notifs-pub'>
|
||||
// <Button key='publish' disabled={item.publish_state === 10} size='small' type='link' onClick={() => {}}>
|
||||
// {t('Publish')}
|
||||
// </Button>
|
||||
// </RequireAuth>,
|
||||
<RequireAuth subject={PERM_NOTIFS_MANAGEMENT} key='notifs-del'>
|
||||
<Popconfirm key='del'
|
||||
title={t('sureDelete')}
|
||||
onConfirm={e => handleDelNotifs(item.notificationId)}
|
||||
okText={t('Yes')}
|
||||
cancelText={t('No')}
|
||||
>
|
||||
<Button size='small' type='link' danger>
|
||||
{t('Delete')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</RequireAuth>,
|
||||
]
|
||||
: [
|
||||
<RequireAuth subject={PERM_NOTIFS_DELETE_DANGER} key='notifs-del'>
|
||||
<Popconfirm key='del'
|
||||
title={t('sureDelete')}
|
||||
onConfirm={e => handleDelNotifs(item.notificationId)}
|
||||
okText={t('Yes')}
|
||||
cancelText={t('No')}
|
||||
>
|
||||
<Button size='small' type='link' danger>
|
||||
{t('Delete')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</RequireAuth>,
|
||||
]
|
||||
}>
|
||||
<Typography.Text>[{item.date}]</Typography.Text>
|
||||
<NavLink to={item.publish_state === 1 ? `/notice/${item.notificationId}` : `/notice/edit/${item.notificationId}`}> {item.title}</NavLink>{' '}
|
||||
{item.notificationsReadState ? '' : <Badge dot />}
|
||||
</List.Item>
|
||||
)}></List>
|
||||
</Col>
|
||||
<Col span={4}></Col>
|
||||
</Row>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
export default Index;
|
||||
@ -1,285 +0,0 @@
|
||||
import { useState, useMemo } from 'react';
|
||||
import { Button, Table, Popover, Typography } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { HT_HOST } from '@/config';
|
||||
import { fetchJSON } from '@haina/utils-request';
|
||||
import { formatGroupSize } from '@/hooks/useProductsSets';
|
||||
import { isEmpty, isNotEmpty } from '@haina/utils-commons';
|
||||
import { usingStorage } from '@/hooks/usingStorage';
|
||||
|
||||
/**
|
||||
* 产品价格日志
|
||||
*/
|
||||
const getPPLogAction = async (params) => {
|
||||
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_price_log`, params)
|
||||
return errcode !== 0 ? [] : result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 产品价格: 已发布的
|
||||
*/
|
||||
const getPPRunningAction = async (params) => {
|
||||
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_price_running`, params)
|
||||
return errcode !== 0 ? [] : result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 产品价格快照
|
||||
*/
|
||||
const getPPSnapshotAction = async (params) => {
|
||||
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_price_snapshot`, params)
|
||||
return errcode !== 0 ? [] : result;
|
||||
}
|
||||
|
||||
const parseJson = (str) => {
|
||||
let result;
|
||||
if (str === null || str === undefined || str === '') {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
result = typeof str === 'string' ? JSON.parse(str) : str;
|
||||
return Array.isArray(result) ? result.reduce((acc, cur) => ({ ...acc, ...cur }), {}) : result;
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
const statesForHideEdited = [1, 2];
|
||||
export const columnsSets = (t, colorize = true) => [
|
||||
{
|
||||
key: 'adult',
|
||||
title: t('AgeType.Adult'),
|
||||
width: '12rem',
|
||||
render: (_, { adult_cost, currency, unit_id, unit_name, audit_state_id, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const ifCompare = colorize && !statesForHideEdited.includes(audit_state_id);
|
||||
const ifData = isNotEmpty(_changed.adult_cost) || isNotEmpty(_changed.unit_id) || isNotEmpty(_changed.currency);
|
||||
const preValue =
|
||||
ifCompare && ifData ? (
|
||||
<div className='text-muted line-through '>{`${_changed.adult_cost || adult_cost} ${_changed.currency || currency} / ${t(`PriceUnit.${_changed.unit_id || unit_id}`)}`}</div>
|
||||
) : null;
|
||||
const editCls = ifCompare && ifData ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{`${adult_cost} ${currency} / ${t(`PriceUnit.${unit_id}`)}`}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'child',
|
||||
title: t('AgeType.Child'),
|
||||
width: '12rem',
|
||||
render: (_, { child_cost, currency, unit_id, unit_name, audit_state_id, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const ifCompare = colorize && !statesForHideEdited.includes(audit_state_id);
|
||||
const ifData = isNotEmpty(_changed.child_cost) || isNotEmpty(_changed.unit_id) || isNotEmpty(_changed.currency);
|
||||
const preValue =
|
||||
ifCompare && ifData ? (
|
||||
<div className='text-muted line-through '>{`${_changed.child_cost || child_cost} ${_changed.currency || currency} / ${t(`PriceUnit.${_changed.unit_id || unit_id}`)}`}</div>
|
||||
) : null;
|
||||
const editCls = ifCompare && ifData ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{`${child_cost} ${currency} / ${t(`PriceUnit.${unit_id}`)}`}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
// {key: 'unit', title: t('Unit'), },
|
||||
{
|
||||
key: 'groupSize',
|
||||
dataIndex: ['group_size_min'],
|
||||
title: t('group_size'),
|
||||
width: '6rem',
|
||||
render: (_, { audit_state_id, group_size_min, group_size_max, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const preValue =
|
||||
colorize && !statesForHideEdited.includes(audit_state_id) && (isNotEmpty(_changed.group_size_min) || isNotEmpty(_changed.group_size_max)) ? (
|
||||
<div className='text-muted line-through '>{`${_changed.group_size_min ?? group_size_min} - ${_changed.group_size_max ?? group_size_max}`}</div>
|
||||
) : null;
|
||||
const editCls = colorize && !statesForHideEdited.includes(audit_state_id) && (isNotEmpty(_changed.group_size_min) || isNotEmpty(_changed.group_size_max)) ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{formatGroupSize(group_size_min, group_size_max)}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'useDates',
|
||||
dataIndex: ['use_dates_start'],
|
||||
title: t('use_dates'),
|
||||
width: '12rem',
|
||||
render: (_, { use_dates_start, use_dates_end, weekdays, audit_state_id, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const preValue =
|
||||
colorize && !statesForHideEdited.includes(audit_state_id) && (isNotEmpty(_changed.use_dates_start) || isNotEmpty(_changed.use_dates_end)) ? (
|
||||
<div className='text-muted'>
|
||||
{isNotEmpty(_changed.use_dates_start) ? <span className=' line-through '>{_changed.use_dates_start}</span> : use_dates_start} ~{' '}
|
||||
{isNotEmpty(_changed.use_dates_end) ? <span className='t line-through '>{_changed.use_dates_end}</span> : use_dates_end}
|
||||
</div>
|
||||
) : null;
|
||||
const editCls = colorize && !statesForHideEdited.includes(audit_state_id) && (isNotEmpty(_changed.use_dates_start) || isNotEmpty(_changed.use_dates_end)) ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{`${use_dates_start} ~ ${use_dates_end}`}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'weekdays',
|
||||
dataIndex: ['weekdays'],
|
||||
title: t('Weekdays'),
|
||||
width: '6rem',
|
||||
render: (text, { weekdays, audit_state_id, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const ifCompare = colorize && !statesForHideEdited.includes(audit_state_id);
|
||||
const ifData = !isEmpty(_changed.weekdays);
|
||||
const _weekdays = ifData
|
||||
? _changed.weekdays
|
||||
.split(',')
|
||||
.filter(Boolean)
|
||||
.map((w) => t(`common:weekdaysShort.${w}`))
|
||||
.join(', ')
|
||||
: '';
|
||||
const preValue = ifCompare && ifData ? <div className='text-muted line-through '>{_weekdays}</div> : null;
|
||||
const editCls = ifCompare && ifData ? 'text-danger' : '';
|
||||
const weekdaysTxt = weekdays
|
||||
.split(',')
|
||||
.filter(Boolean)
|
||||
.map((w) => t(`common:weekdaysShort.${w}`))
|
||||
.join(', ');
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{weekdaysTxt || t('Unlimited')}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const useLogMethod = (method) => {
|
||||
const { t } = useTranslation('products');
|
||||
const methodMap = {
|
||||
'history': {
|
||||
title: '📑' + t('versionHistory'),
|
||||
btnText: t('versionHistory'),
|
||||
fetchData: async (params) => {
|
||||
const data = await getPPLogAction(params);
|
||||
return { data };
|
||||
},
|
||||
},
|
||||
'published': {
|
||||
title: '✅' + t('versionPublished'),
|
||||
btnText: t('versionPublished'),
|
||||
fetchData: async (params) => {
|
||||
const { travel_agency_id, product_id, price_id, use_year } = params;
|
||||
const data = await getPPRunningAction({ travel_agency_id, product_id_list: product_id, use_year });
|
||||
return { data: data?.[0]?.quotation || [] };
|
||||
},
|
||||
},
|
||||
'snapshot': {
|
||||
title: '📷' + t('versionSnapshot'),
|
||||
btnText: t('versionSnapshot'),
|
||||
fetchData: async (params) => {
|
||||
const { price_id, ..._params } = params;
|
||||
const data = await getPPSnapshotAction(_params);
|
||||
return data; //?.[0]?.quotation || [];
|
||||
},
|
||||
},
|
||||
};
|
||||
return methodMap[method];
|
||||
};
|
||||
|
||||
/**
|
||||
* ProductQuotationLogPopover - A popover component that displays product quotation change logs or published data
|
||||
*
|
||||
* This component shows a history of price changes for a specific product quotation in a popover table.
|
||||
* It supports displaying different data sources (history logs or published data) and shows
|
||||
* comparison between previous and current values with visual indicators.
|
||||
*
|
||||
* @param {Object} props - Component props
|
||||
* @param {string} props.btnText - The text to display on the trigger button and in the popover header
|
||||
* @param {'history' | 'published' | 'snapshot'} props.method - Determines data source - "history" for change logs or "published" for published quotations
|
||||
* @param {Object} props.triggerProps - Additional props to pass to the trigger button
|
||||
* @param {number} props.travel_agency_id - ID of the travel agency (used in data fetching)
|
||||
* @param {number} props.product_id - ID of the product (used in data fetching)
|
||||
* @param {number} props.price_id - ID of the price entry (used in data fetching)
|
||||
* @param {number} props.use_year - Year to use for fetching data (used in data fetching)
|
||||
* @param {Function} props.onOpenChange - Callback function to be called when the popover opens or closes
|
||||
*/
|
||||
const ProductQuotationLogPopover = ({ method, triggerProps = {}, onOpenChange, ...props }) => {
|
||||
const { travel_agency_id, product_id, price_id, use_year } = props;
|
||||
const { travelAgencyId } = usingStorage();
|
||||
|
||||
const { t } = useTranslation('products');
|
||||
const [open, setOpen] = useState(false);
|
||||
const [logData, setLogData] = useState([]);
|
||||
|
||||
const { title, btnText: methodBtnText, fetchData } = useLogMethod(method);
|
||||
|
||||
const tablePagination = useMemo(() => method === 'history' ? { pageSize: 5, position: ['bottomLeft']} : { pageSize: 10, position: ['bottomLeft']}, [method]);
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const getData = async () => {
|
||||
setLoading(true);
|
||||
const { data } = await fetchData({ travel_agency_id: travel_agency_id || travelAgencyId, product_id, price_id, use_year });
|
||||
setLogData(data);
|
||||
invokeOpenChange(true);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const invokeOpenChange = (_open) => {
|
||||
if (typeof onOpenChange === 'function') {
|
||||
onOpenChange(_open);
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [...columnsSets(t, false),
|
||||
{ title: t('common:time'), dataIndex: 'updatetime', key: 'updatetime', width: '10rem', },
|
||||
{ title: t('common:operator'), dataIndex: 'update_by', key: 'update_by' }
|
||||
];
|
||||
return (
|
||||
<Popover
|
||||
placement='bottom'
|
||||
className=''
|
||||
rootClassName='w-5/6'
|
||||
{...props}
|
||||
title={
|
||||
<div className='flex justify-between mt-0 gap-4 items-center '>
|
||||
<Typography.Text strong>{title}</Typography.Text>
|
||||
<Button
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
invokeOpenChange(false);
|
||||
}}>
|
||||
×
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
content={
|
||||
<>
|
||||
<Table columns={columns} dataSource={logData} rowKey={'id'} size='small' loading={loading} pagination={tablePagination} />
|
||||
</>
|
||||
}
|
||||
trigger={['click']}
|
||||
open={open}
|
||||
onOpenChange={(v) => {
|
||||
setOpen(v);
|
||||
invokeOpenChange(v);
|
||||
}}>
|
||||
<Button {...triggerProps} onClick={getData} title={title}>
|
||||
{props.btnText || methodBtnText}
|
||||
</Button>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
export default ProductQuotationLogPopover;
|
||||
@ -1,299 +0,0 @@
|
||||
import { useState, useMemo } from 'react';
|
||||
import { Button, Table, Popover, Typography, List, Flex } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { HT_HOST } from '@/config';
|
||||
import { fetchJSON } from '@haina/utils-request';
|
||||
import { formatGroupSize } from '@/hooks/useProductsSets';
|
||||
import { isEmpty, isNotEmpty } from '@haina/utils-commons';
|
||||
import { chunkBy } from '@/hooks/useProductsQuotationFormat';
|
||||
|
||||
/**
|
||||
* 产品价格日志
|
||||
*/
|
||||
const getPPLogAction = async (params) => {
|
||||
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_price_log`, params)
|
||||
return errcode !== 0 ? [] : result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 产品价格: 已发布的
|
||||
*/
|
||||
const getPPRunningAction = async (params) => {
|
||||
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_price_running`, params)
|
||||
return errcode !== 0 ? [] : result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 产品价格快照
|
||||
*/
|
||||
const getPPSnapshotAction = async (params) => {
|
||||
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_price_snapshot`, params)
|
||||
return errcode !== 0 ? [] : result;
|
||||
}
|
||||
|
||||
const parseJson = (str) => {
|
||||
let result;
|
||||
if (str === null || str === undefined || str === '') {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
result = JSON.parse(str);
|
||||
return Array.isArray(result) ? result.reduce((acc, cur) => ({ ...acc, ...cur }), {}) : result;
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
export const columnsSets = (t, colorize = true) => [
|
||||
{
|
||||
key: 'adult',
|
||||
title: t('AgeType.Adult'),
|
||||
width: '12rem',
|
||||
render: (_, { adult_cost, currency, unit_id, unit_name, audit_state_id, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const ifCompare = colorize && ![-1, 1, 2].includes(audit_state_id);
|
||||
const ifData = isNotEmpty(_changed.adult_cost) || isNotEmpty(_changed.unit_id) || isNotEmpty(_changed.currency);
|
||||
const preValue =
|
||||
ifCompare && ifData ? (
|
||||
<div className='text-muted line-through '>{`${_changed.adult_cost} ${_changed.currency || currency} / ${t(`PriceUnit.${_changed.unit_id || unit_id}`)}`}</div>
|
||||
) : null;
|
||||
const editCls = ifCompare && ifData ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{`${adult_cost} ${currency} / ${t(`PriceUnit.${unit_id}`)}`}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'child',
|
||||
title: t('AgeType.Child'),
|
||||
width: '12rem',
|
||||
render: (_, { child_cost, currency, unit_id, unit_name, audit_state_id, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const ifCompare = colorize && ![-1, 1, 2].includes(audit_state_id);
|
||||
const ifData = isNotEmpty(_changed.child_cost) || isNotEmpty(_changed.unit_id) || isNotEmpty(_changed.currency);
|
||||
const preValue =
|
||||
ifCompare && ifData ? (
|
||||
<div className='text-muted line-through '>{`${_changed.child_cost} ${_changed.currency || currency} / ${t(`PriceUnit.${_changed.unit_id || unit_id}`)}`}</div>
|
||||
) : null;
|
||||
const editCls = ifCompare && ifData ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{`${child_cost} ${currency} / ${t(`PriceUnit.${unit_id}`)}`}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
// {key: 'unit', title: t('Unit'), },
|
||||
{
|
||||
key: 'groupSize',
|
||||
dataIndex: ['group_size_min'],
|
||||
title: t('group_size'),
|
||||
width: '6rem',
|
||||
render: (_, { audit_state_id, group_size_min, group_size_max, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const preValue =
|
||||
colorize && ![-1, 1, 2].includes(audit_state_id) && (isNotEmpty(_changed.group_size_min) || isNotEmpty(_changed.group_size_max)) ? (
|
||||
<div className='text-muted line-through '>{`${_changed.group_size_min ?? group_size_min} - ${_changed.group_size_max ?? group_size_max}`}</div>
|
||||
) : null;
|
||||
const editCls = colorize && ![-1, 1, 2].includes(audit_state_id) && (isNotEmpty(_changed.group_size_min) || isNotEmpty(_changed.group_size_max)) ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{formatGroupSize(group_size_min, group_size_max)}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'useDates',
|
||||
dataIndex: ['use_dates_start'],
|
||||
title: t('use_dates'),
|
||||
width: '12rem',
|
||||
render: (_, { use_dates_start, use_dates_end, weekdays, audit_state_id, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const preValue =
|
||||
colorize && ![-1, 1, 2].includes(audit_state_id) && (isNotEmpty(_changed.use_dates_start) || isNotEmpty(_changed.use_dates_end)) ? (
|
||||
<div className='text-muted'>
|
||||
{isNotEmpty(_changed.use_dates_start) ? <span className=' line-through '>{_changed.use_dates_start}</span> : use_dates_start} ~{' '}
|
||||
{isNotEmpty(_changed.use_dates_end) ? <span className='t line-through '>{_changed.use_dates_end}</span> : use_dates_end}
|
||||
</div>
|
||||
) : null;
|
||||
const editCls = colorize && ![-1, 1, 2].includes(audit_state_id) && (isNotEmpty(_changed.use_dates_start) || isNotEmpty(_changed.use_dates_end)) ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{`${use_dates_start} ~ ${use_dates_end}`}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'weekdays',
|
||||
dataIndex: ['weekdays'],
|
||||
title: t('Weekdays'),
|
||||
width: '6rem',
|
||||
render: (text, { weekdays, audit_state_id, lastedit_changed }) => {
|
||||
const _changed = parseJson(lastedit_changed);
|
||||
const ifCompare = colorize && ![-1, 1, 2].includes(audit_state_id);
|
||||
const ifData = !isEmpty((_changed.weekdayList || []).filter((s) => s));
|
||||
const preValue = ifCompare && ifData ? <div className='text-muted line-through '>{_changed.weekdayList}</div> : null;
|
||||
const editCls = ifCompare && ifData ? 'text-danger' : '';
|
||||
return (
|
||||
<div>
|
||||
{preValue}
|
||||
<span className={editCls}>{text || t('Unlimited')}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const useLogMethod = (method) => {
|
||||
const { t } = useTranslation('products');
|
||||
const methodMap = {
|
||||
'history': {
|
||||
title: '📑' + t('versionHistory'),
|
||||
btnText: t('versionHistory'),
|
||||
fetchData: async (params) => {
|
||||
const data = await getPPLogAction(params);
|
||||
return {data};
|
||||
},
|
||||
},
|
||||
'published': {
|
||||
title: '✅' + t('versionPublished'),
|
||||
btnText: t('versionPublished'),
|
||||
fetchData: async (params) => {
|
||||
const { travel_agency_id, product_id, price_id, use_year } = params;
|
||||
const data = await getPPRunningAction({ travel_agency_id, product_id_list: product_id, use_year });
|
||||
return {data: data?.[0]?.quotation || []};
|
||||
},
|
||||
},
|
||||
'snapshot': {
|
||||
title: '📷' + t('versionSnapshot'),
|
||||
btnText: t('versionSnapshot'),
|
||||
subTitle: t('点击左侧价格版本查看具体价格'),
|
||||
fetchData: async (params) => {
|
||||
const { price_id, ..._params } = params;
|
||||
const data = await getPPSnapshotAction(_params);
|
||||
return {data}; //?.[0]?.quotation || [];
|
||||
},
|
||||
},
|
||||
};
|
||||
return methodMap[method];
|
||||
};
|
||||
|
||||
/**
|
||||
* ProductQuotationLogPopover - A popover component that displays product quotation change logs or published data
|
||||
*
|
||||
* This component shows a history of price changes for a specific product quotation in a popover table.
|
||||
* It supports displaying different data sources (history logs or published data) and shows
|
||||
* comparison between previous and current values with visual indicators.
|
||||
*
|
||||
* @param {Object} props - Component props
|
||||
* @param {string} props.btnText - The text to display on the trigger button and in the popover header
|
||||
* @param {'history' | 'published' | 'snapshot'} props.method - Determines data source - "history" for change logs or "published" for published quotations
|
||||
* @param {Object} props.triggerProps - Additional props to pass to the trigger button
|
||||
* @param {number} props.travel_agency_id - ID of the travel agency (used in data fetching)
|
||||
* @param {number} props.product_id - ID of the product (used in data fetching)
|
||||
* @param {number} props.price_id - ID of the price entry (used in data fetching)
|
||||
* @param {number} props.use_year - Year to use for fetching data (used in data fetching)
|
||||
* @param {Function} props.onOpenChange - Callback function to be called when the popover opens or closes
|
||||
*/
|
||||
const ProductQuotationSnapshotPopover = ({ method, triggerProps = {}, onOpenChange, ...props }) => {
|
||||
const { travel_agency_id, product_id, price_id, use_year } = props;
|
||||
|
||||
const { t } = useTranslation('products');
|
||||
const [open, setOpen] = useState(false);
|
||||
const [logData, setLogData] = useState([]);
|
||||
|
||||
const { title, subTitle, btnText: methodBtnText, fetchData } = useLogMethod(method);
|
||||
|
||||
const tablePagination = useMemo(() => method === 'history' ? { pageSize: 5, position: ['bottomLeft']} : { pageSize: 10, position: ['bottomLeft']}, [method]);
|
||||
|
||||
const [viewSnapshotItem, setViewSnapshotItem] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const getData = async () => {
|
||||
setLoading(true);
|
||||
const { data } = await fetchData({ travel_agency_id, product_id, price_id, use_year });
|
||||
setLogData(data);
|
||||
invokeOpenChange(true);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const invokeOpenChange = (_open) => {
|
||||
if (typeof onOpenChange === 'function') {
|
||||
onOpenChange(_open);
|
||||
}
|
||||
};
|
||||
|
||||
const onClickSnapshotItem = (item) => {
|
||||
console.log(item)
|
||||
setViewSnapshotItem(item);
|
||||
console.log('cc\n');
|
||||
const chunk = chunkBy(2025, [{...item, quotation: item.quotation.map(q => ({...q, WPI_SN: product_id })), info: { id: product_id }}], ['quote_season', 'quote_size']);
|
||||
console.log(chunk)
|
||||
};
|
||||
|
||||
const columns = [...columnsSets(t, false), { title: '时间', dataIndex: 'updatetime', key: 'updatetime' }];
|
||||
return (
|
||||
<Popover
|
||||
placement='bottom'
|
||||
className=''
|
||||
rootClassName='w-5/6'
|
||||
{...props}
|
||||
title={
|
||||
<div className='flex mt-0 gap-4 items-center '>
|
||||
<Typography.Text strong>{title}</Typography.Text>
|
||||
{subTitle && <Typography.Text type='secondary'>{subTitle}</Typography.Text>}
|
||||
<Button
|
||||
size='small' className='ml-auto'
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
invokeOpenChange(false);
|
||||
}}>
|
||||
×
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
content={
|
||||
<>
|
||||
<Flex direction='column' gap='small'>
|
||||
<List
|
||||
bordered
|
||||
dataSource={logData}
|
||||
loading={loading}
|
||||
renderItem={(item) => (
|
||||
<List.Item onClick={() => onClickSnapshotItem(item)} className={viewSnapshotItem.version === item.version ? 'active' : ''}>
|
||||
{item.version}
|
||||
</List.Item>
|
||||
)}
|
||||
pagination={{ pageSize: 5, size: 'small', showLessItems: true, simple: { readOnly: true } }}
|
||||
className=' cursor-pointer basis-48 flex flex-col [&>*:first-child]:flex-1 [&_.ant-list-pagination]:m-1 [&_.ant-list-item]:py-1 [&_.ant-list-item.active]:bg-blue-100'
|
||||
/>
|
||||
<div className='flex-auto'>
|
||||
<Table columns={columns} dataSource={viewSnapshotItem.quotation} rowKey={'id'} size='small' loading={loading} pagination={tablePagination} />
|
||||
</div>
|
||||
</Flex>
|
||||
</>
|
||||
}
|
||||
trigger={['click']}
|
||||
open={open}
|
||||
onOpenChange={(v) => {
|
||||
setOpen(v);
|
||||
invokeOpenChange(v);
|
||||
if (v === false) {
|
||||
setLogData([]);
|
||||
setViewSnapshotItem([]);
|
||||
}
|
||||
}}>
|
||||
<Button {...triggerProps} onClick={getData} title={title}>
|
||||
{props.btnText || methodBtnText}
|
||||
</Button>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
export default ProductQuotationSnapshotPopover;
|
||||
@ -1,40 +0,0 @@
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Row, DatePicker, Flex, Col, Typography } from "antd";
|
||||
import dayjs from "dayjs";
|
||||
import { usingStorage } from "@/hooks/usingStorage";
|
||||
|
||||
function PickYear() {
|
||||
const navigate = useNavigate();
|
||||
const { travelAgencyId } = usingStorage();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Row justify="center">
|
||||
<Col span={4}>
|
||||
<Flex gap="middle" vertical>
|
||||
<Typography.Title className="text-center" level={3}>
|
||||
请选择产品年份
|
||||
</Typography.Title>
|
||||
<DatePicker
|
||||
className="w-full"
|
||||
size="large"
|
||||
variant="underlined"
|
||||
needConfirm
|
||||
inputReadOnly={true}
|
||||
minDate={dayjs('2022-01-01')}
|
||||
maxDate={dayjs().add(2, "year")}
|
||||
allowClear={false}
|
||||
picker="year"
|
||||
open={true}
|
||||
onOk={(date) => {
|
||||
const useYear = date.year();
|
||||
navigate(`/products/${travelAgencyId}/${useYear}/all/edit`);
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
</Col>
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
}
|
||||
export default PickYear;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,65 +0,0 @@
|
||||
import { Button } from 'antd';
|
||||
import { useProductsAuditStatesMapVal, useProductsTypesMapVal } from '@/hooks/useProductsSets';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import useProductsStore, { getAgencyAllExtrasAction } from '@/stores/Products/Index';
|
||||
import RequireAuth from '@/components/RequireAuth';
|
||||
import { PERM_PRODUCTS_OFFER_AUDIT } from '@/config';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import AgencyContract from '../Print/AgencyContract';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { Packer } from 'docx';
|
||||
import { isEmpty } from '@haina/utils-commons';
|
||||
|
||||
const ExportDocxBtn = ({ params = { travel_agency_id: '', use_year: '', audit_state: '' }, ...props }) => {
|
||||
const { t } = useTranslation();
|
||||
const [agencyProducts] = useProductsStore((state) => [state.agencyProducts]);
|
||||
const [activeAgency] = useProductsStore((state) => [state.activeAgency]);
|
||||
const { travel_agency_id, use_year, audit_state } = params;
|
||||
|
||||
const auditStatesMap = useProductsAuditStatesMapVal();
|
||||
const productsTypesMapVal = useProductsTypesMapVal();
|
||||
|
||||
const { getRemarkList } = useProductsStore((selector) => ({
|
||||
getRemarkList: selector.getRemarkList,
|
||||
}));
|
||||
const handleDownload = async () => {
|
||||
// await refresh();
|
||||
const _agencyExtras = await getAgencyAllExtrasAction(params);
|
||||
const agencyExtras = Object.keys(_agencyExtras).reduce((acc, pid) => {
|
||||
const pitemExtras = _agencyExtras[pid];
|
||||
const _pitem = (pitemExtras || []).map(eitem => ({ ...eitem, info: { ...eitem.info, product_type_name_txt: productsTypesMapVal[eitem.info.product_type_id]?.label || eitem.info.product_type_name } } ));
|
||||
return { ...acc, [pid]: _pitem };
|
||||
}, {});
|
||||
const remarks = await getRemarkList();
|
||||
const remarksMappedByType = remarks.reduce((r, v) => ({ ...r, [v.product_type_id]: v }), {});
|
||||
const documentCreator = new AgencyContract();
|
||||
const doc = documentCreator.create([
|
||||
params,
|
||||
activeAgency,
|
||||
agencyProducts,
|
||||
agencyExtras,
|
||||
// remarks,
|
||||
remarksMappedByType,
|
||||
]);
|
||||
|
||||
const _d = dayjs().format('YYYYMMDD_HH.mm.ss.SSS'); // Date.now().toString(32)
|
||||
// console.log(params);
|
||||
const _state = isEmpty(audit_state) ? '' : auditStatesMap[audit_state].label;
|
||||
Packer.toBlob(doc).then((blob) => {
|
||||
saveAs(blob, `${activeAgency.travel_agency_name}${use_year}年地接合同-${_state}-${_d}.docx`);
|
||||
});
|
||||
};
|
||||
return (
|
||||
<>
|
||||
{/* todo: export, 审核完成之后才能导出 */}
|
||||
<RequireAuth subject={PERM_PRODUCTS_OFFER_AUDIT}>
|
||||
<Button size='small' onClick={handleDownload}>
|
||||
{t('Export')} .docx
|
||||
</Button>
|
||||
{/* <PrintContractPDF /> */}
|
||||
</RequireAuth>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ExportDocxBtn;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue