@pisell/private-materials 6.3.220 → 6.3.222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +13 -13
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +13 -13
- package/es/components/kioskSkuDetail/index.js +7 -7
- package/es/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +53 -26
- package/es/components/scanOrder/components/Content/index.js +14 -2
- package/es/components/scanOrder/components/ExitConfirmModal/index.js +84 -0
- package/es/components/scanOrder/components/ExitConfirmModal/index.less +182 -0
- package/es/components/scanOrder/locales.js +20 -0
- package/es/index.d.ts +9 -1
- package/es/index.js +6 -2
- package/es/plus/inventory/BindingModal.js +94 -0
- package/es/plus/inventory/InventoryItemManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryItemManagement.js +204 -0
- package/es/plus/inventory/InventoryLocationManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryLocationManagement.js +296 -0
- package/es/plus/inventory/InventoryUnitManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryUnitManagement.js +144 -0
- package/es/plus/inventory/ItemDrawer.js +266 -0
- package/es/plus/inventory/RecordDialog.js +141 -0
- package/es/plus/inventory/StockList.js +132 -0
- package/es/plus/inventory/api.js +66 -0
- package/es/plus/inventory/components.js +172 -0
- package/es/plus/inventory/context.js +118 -0
- package/es/plus/inventory/forms.js +46 -0
- package/es/plus/inventory/hooks.js +235 -0
- package/es/plus/inventory/index.less +559 -0
- package/es/plus/inventory/locales.js +277 -0
- package/es/plus/inventory/types.d.ts +10 -0
- package/es/plus/inventory/utils.js +24 -0
- package/es/plus/panpacificTask/JobCard.js +22 -0
- package/es/plus/panpacificTask/JobDrawer.js +366 -0
- package/es/plus/panpacificTask/JobForm.js +312 -0
- package/es/plus/panpacificTask/JobStatus.js +29 -0
- package/es/plus/panpacificTask/PanpacificTask.d.ts +7 -0
- package/es/plus/panpacificTask/PanpacificTask.js +552 -0
- package/es/plus/panpacificTask/PhotoPreview.js +37 -0
- package/es/plus/panpacificTask/README.md +114 -0
- package/es/plus/panpacificTask/attachments.js +64 -0
- package/es/plus/panpacificTask/index.d.ts +2 -0
- package/es/plus/panpacificTask/index.less +539 -0
- package/es/plus/panpacificTask/locales.js +586 -0
- package/es/plus/panpacificTask/model.js +260 -0
- package/es/plus/panpacificTask/saveJob.js +68 -0
- package/es/plus/panpacificTask/serve.js +243 -0
- package/es/plus/panpacificTask/tenant.js +16 -0
- package/es/plus/panpacificTask/types.d.ts +19 -0
- package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
- package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
- package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
- package/es/plus/pisellSupersetDashboard/README.md +291 -0
- package/es/plus/pisellSupersetDashboard/index.d.ts +15 -0
- package/es/plus/pisellSupersetDashboard/index.js +187 -0
- package/es/plus/pisellSupersetDashboard/index.less +83 -0
- package/es/plus/pisellSupersetDashboard/locales.js +36 -0
- package/es/plus/pisellSupersetDashboard/serve.js +51 -0
- package/es/plus/pisellSupersetDashboard/types.d.ts +17 -0
- package/es/plus/skuOptionsSelection/store/createStore.js +2 -2
- package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +1 -2
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/lib/components/kioskSkuDetail/index.js +7 -7
- package/lib/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +53 -26
- package/lib/components/scanOrder/components/Content/index.js +14 -2
- package/lib/components/scanOrder/components/ExitConfirmModal/index.js +86 -0
- package/lib/components/scanOrder/components/ExitConfirmModal/index.less +182 -0
- package/lib/components/scanOrder/locales.js +20 -0
- package/lib/index.d.ts +9 -1
- package/lib/index.js +136 -126
- package/lib/plus/inventory/BindingModal.js +96 -0
- package/lib/plus/inventory/InventoryItemManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryItemManagement.js +206 -0
- package/lib/plus/inventory/InventoryLocationManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryLocationManagement.js +298 -0
- package/lib/plus/inventory/InventoryUnitManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryUnitManagement.js +146 -0
- package/lib/plus/inventory/ItemDrawer.js +268 -0
- package/lib/plus/inventory/RecordDialog.js +143 -0
- package/lib/plus/inventory/StockList.js +134 -0
- package/lib/plus/inventory/api.js +66 -0
- package/lib/plus/inventory/components.js +181 -0
- package/lib/plus/inventory/context.js +121 -0
- package/lib/plus/inventory/forms.js +50 -0
- package/lib/plus/inventory/hooks.js +240 -0
- package/lib/plus/inventory/index.less +559 -0
- package/lib/plus/inventory/locales.js +277 -0
- package/lib/plus/inventory/types.d.ts +10 -0
- package/lib/plus/inventory/utils.js +30 -0
- package/lib/plus/panpacificTask/JobCard.js +24 -0
- package/lib/plus/panpacificTask/JobDrawer.js +368 -0
- package/lib/plus/panpacificTask/JobForm.js +314 -0
- package/lib/plus/panpacificTask/JobStatus.js +33 -0
- package/lib/plus/panpacificTask/PanpacificTask.d.ts +7 -0
- package/lib/plus/panpacificTask/PanpacificTask.js +555 -0
- package/lib/plus/panpacificTask/PhotoPreview.js +39 -0
- package/lib/plus/panpacificTask/README.md +114 -0
- package/lib/plus/panpacificTask/attachments.js +66 -0
- package/lib/plus/panpacificTask/index.d.ts +2 -0
- package/lib/plus/panpacificTask/index.less +539 -0
- package/lib/plus/panpacificTask/locales.js +586 -0
- package/lib/plus/panpacificTask/model.js +289 -0
- package/lib/plus/panpacificTask/saveJob.js +68 -0
- package/lib/plus/panpacificTask/serve.js +260 -0
- package/lib/plus/panpacificTask/tenant.js +17 -0
- package/lib/plus/panpacificTask/types.d.ts +19 -0
- package/lib/plus/pisellSupersetDashboard/README.md +291 -0
- package/lib/plus/pisellSupersetDashboard/index.d.ts +15 -0
- package/lib/plus/pisellSupersetDashboard/index.js +189 -0
- package/lib/plus/pisellSupersetDashboard/index.less +83 -0
- package/lib/plus/pisellSupersetDashboard/locales.js +36 -0
- package/lib/plus/pisellSupersetDashboard/serve.js +52 -0
- package/lib/plus/pisellSupersetDashboard/types.d.ts +17 -0
- package/lowcode/inventory-item-management/meta.ts +20 -0
- package/lowcode/inventory-location-management/meta.ts +20 -0
- package/lowcode/inventory-unit-management/meta.ts +20 -0
- package/lowcode/panpacific-task/meta.ts +51 -0
- package/lowcode/pisell-superset-dashboard/meta.ts +75 -0
- package/package.json +4 -2
- package/es/plus/pisellReservation/index.js +0 -17
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
|
+
let dayjs = require("dayjs");
|
|
4
|
+
dayjs = require_runtime.__toESM(dayjs);
|
|
5
|
+
//#region src/plus/panpacificTask/model.ts
|
|
6
|
+
const statuses = [
|
|
7
|
+
"create",
|
|
8
|
+
"collected",
|
|
9
|
+
"invoice",
|
|
10
|
+
"complete",
|
|
11
|
+
"cancel"
|
|
12
|
+
];
|
|
13
|
+
const displayStatuses = [...statuses, "delayed"];
|
|
14
|
+
const statusColors = {
|
|
15
|
+
create: "#f3f4f6",
|
|
16
|
+
collected: "#f3f1f9",
|
|
17
|
+
invoice: "#f3f1f9",
|
|
18
|
+
complete: "#d1fae5",
|
|
19
|
+
cancel: "#fee2e2",
|
|
20
|
+
delayed: "#ffedd5"
|
|
21
|
+
};
|
|
22
|
+
const statusTextColors = {
|
|
23
|
+
create: "#374151",
|
|
24
|
+
collected: "#634db3",
|
|
25
|
+
invoice: "#634db3",
|
|
26
|
+
complete: "#047857",
|
|
27
|
+
cancel: "#991b1b",
|
|
28
|
+
delayed: "#c2410c"
|
|
29
|
+
};
|
|
30
|
+
const emptyBase = {
|
|
31
|
+
suppliers: [],
|
|
32
|
+
materials: [],
|
|
33
|
+
products: [],
|
|
34
|
+
paymentTerms: [],
|
|
35
|
+
categories: []
|
|
36
|
+
};
|
|
37
|
+
const dateFields = [
|
|
38
|
+
"job_created_date",
|
|
39
|
+
"due_date",
|
|
40
|
+
"pickup_date",
|
|
41
|
+
"invoice_date"
|
|
42
|
+
];
|
|
43
|
+
const editableDateFields = dateFields.filter((key) => key !== "invoice_date");
|
|
44
|
+
const jobFields = [
|
|
45
|
+
...editableDateFields,
|
|
46
|
+
"job_number",
|
|
47
|
+
"logistic_type",
|
|
48
|
+
"logistics_note",
|
|
49
|
+
"supplier_id",
|
|
50
|
+
"supplier_name",
|
|
51
|
+
"supplier_state",
|
|
52
|
+
"supplier_sub_name",
|
|
53
|
+
"supplier_phone",
|
|
54
|
+
"supplier_email",
|
|
55
|
+
"company_contact",
|
|
56
|
+
"lead_source",
|
|
57
|
+
"task_category_id",
|
|
58
|
+
"payment_term_id",
|
|
59
|
+
"payment_term_days",
|
|
60
|
+
"terms_note"
|
|
61
|
+
];
|
|
62
|
+
const dateText = (value) => value && (0, dayjs.default)(value).isValid() ? (0, dayjs.default)(value).format("YYYY-MM-DD") : "";
|
|
63
|
+
const displayStatus = (job, today = dateText((0, dayjs.default)())) => {
|
|
64
|
+
const due = dateText(job.due_date);
|
|
65
|
+
return due && due < today && !["complete", "cancel"].includes(job.status) ? "delayed" : displayStatuses.includes(job.status) ? job.status : "create";
|
|
66
|
+
};
|
|
67
|
+
function jobStyle(job, today) {
|
|
68
|
+
const status = displayStatus(job, today);
|
|
69
|
+
return {
|
|
70
|
+
background: statusColors[status],
|
|
71
|
+
color: statusTextColors[status],
|
|
72
|
+
textDecoration: status === "cancel" ? "line-through" : "none"
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const hasInvoice = (job) => job.status === "invoice" || !!job.invoice_date;
|
|
76
|
+
const companyName = (job) => [job.supplier_name, job.supplier_sub_name].filter(Boolean).join(" · ");
|
|
77
|
+
/** 选择供应商时生成 Job 快照;缺失值置空,避免混入上一个供应商的联络信息。 */
|
|
78
|
+
const supplierSnapshot = (supplier) => ({
|
|
79
|
+
supplier_name: supplier.name || "",
|
|
80
|
+
supplier_state: supplier.state || "",
|
|
81
|
+
supplier_sub_name: supplier.sub_name || "",
|
|
82
|
+
supplier_phone: supplier.phone || "",
|
|
83
|
+
supplier_email: supplier.email || "",
|
|
84
|
+
company_contact: supplier.contact_name || "",
|
|
85
|
+
lead_source: supplier.lead_source || ""
|
|
86
|
+
});
|
|
87
|
+
function jobLineGroups(job) {
|
|
88
|
+
const group = (rows = []) => ({
|
|
89
|
+
scheduled: rows.filter((row) => row.deleted_at == null && row.item_status !== "confirmed"),
|
|
90
|
+
confirmed: rows.filter((row) => row.deleted_at == null && row.item_status === "confirmed")
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
materials: group(job.job_materials),
|
|
94
|
+
products: group(job.job_items)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function jobRange(job) {
|
|
98
|
+
const due = dateText(job.due_date);
|
|
99
|
+
if (!due) return null;
|
|
100
|
+
const start = dateText(job.pickup_date) || due;
|
|
101
|
+
return {
|
|
102
|
+
kind: "date",
|
|
103
|
+
start,
|
|
104
|
+
endExclusive: (0, dayjs.default)(due < start ? start : due).add(1, "day").format("YYYY-MM-DD")
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function scheduleText(job) {
|
|
108
|
+
const range = jobRange(job);
|
|
109
|
+
if (!range) return "—";
|
|
110
|
+
const end = (0, dayjs.default)(range.endExclusive).subtract(1, "day").format("YYYY-MM-DD");
|
|
111
|
+
return range.start === end ? end : `${range.start} – ${end}`;
|
|
112
|
+
}
|
|
113
|
+
function calendarItems(jobs) {
|
|
114
|
+
return jobs.flatMap((job) => {
|
|
115
|
+
const range = jobRange(job);
|
|
116
|
+
return range ? [{
|
|
117
|
+
id: String(job.id),
|
|
118
|
+
title: job.job_number || companyName(job),
|
|
119
|
+
range,
|
|
120
|
+
data: job
|
|
121
|
+
}] : [];
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function jobsOnDate(jobs, date, period) {
|
|
125
|
+
return jobs.filter((job) => {
|
|
126
|
+
const range = jobRange(job);
|
|
127
|
+
return period ? range && range.start <= date && date < range.endExclusive : dateText(job.due_date) === date;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function paymentTerm(job, base) {
|
|
131
|
+
const term = base.paymentTerms.find((row) => String(row.id) === String(job.payment_term_id));
|
|
132
|
+
return (term === null || term === void 0 ? void 0 : term.name) || (term === null || term === void 0 ? void 0 : term.title) || "";
|
|
133
|
+
}
|
|
134
|
+
function filterJobs(jobs, filters, base = emptyBase, today) {
|
|
135
|
+
const q = (filters.search || "").trim().toLowerCase();
|
|
136
|
+
return jobs.filter((job) => {
|
|
137
|
+
const text = [
|
|
138
|
+
job.job_number,
|
|
139
|
+
companyName(job),
|
|
140
|
+
job.supplier_name,
|
|
141
|
+
job.supplier_state,
|
|
142
|
+
job.supplier_sub_name,
|
|
143
|
+
job.company_contact,
|
|
144
|
+
job.supplier_phone,
|
|
145
|
+
job.supplier_email,
|
|
146
|
+
job.lead_source,
|
|
147
|
+
paymentTerm(job, base),
|
|
148
|
+
...(job.job_materials || []).filter((row) => row.deleted_at == null).flatMap((row) => [row.description, row.material_name]),
|
|
149
|
+
...(job.job_items || []).filter((row) => row.deleted_at == null).flatMap((row) => [row.description, row.product_name])
|
|
150
|
+
].filter(Boolean).join(" ").toLowerCase();
|
|
151
|
+
return (!q || text.includes(q)) && (!filters.due || dateText(job.due_date) === filters.due) && (!filters.status || displayStatus(job, today) === filters.status);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function nextJobCode(state, name, jobs) {
|
|
155
|
+
if (!state || !(name === null || name === void 0 ? void 0 : name.trim())) return "";
|
|
156
|
+
const prefix = `${state}_${name.trim().replace(/[^a-zA-Z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase() || "SUPPLIER"}_`;
|
|
157
|
+
const max = jobs.reduce((n, job) => {
|
|
158
|
+
var _job$job_number;
|
|
159
|
+
const suffix = ((_job$job_number = job.job_number) === null || _job$job_number === void 0 ? void 0 : _job$job_number.startsWith(prefix)) ? job.job_number.slice(prefix.length) : "";
|
|
160
|
+
return /^\d{5,}$/.test(suffix) ? Math.max(n, Number(suffix)) : n;
|
|
161
|
+
}, 0);
|
|
162
|
+
return prefix + String(max + 1).padStart(5, "0");
|
|
163
|
+
}
|
|
164
|
+
let rowSequence = 0;
|
|
165
|
+
const newLine = (row = {}) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
|
|
166
|
+
price_unit: "piece",
|
|
167
|
+
item_status: "scheduled"
|
|
168
|
+
}, row), {}, { _key: `line-${++rowSequence}` });
|
|
169
|
+
function draftFor(job, date = dateText((0, dayjs.default)()), duplicate = false) {
|
|
170
|
+
const draft = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
|
|
171
|
+
status: "create",
|
|
172
|
+
supplier_state: "QLD",
|
|
173
|
+
job_created_date: date,
|
|
174
|
+
due_date: date
|
|
175
|
+
}, job), {}, {
|
|
176
|
+
materials: ((job === null || job === void 0 ? void 0 : job.job_materials) || []).filter((row) => row.deleted_at == null).map((row) => newLine(duplicate ? linePayload(row, "materials") : require_objectSpread2._objectSpread2({ job_id: job === null || job === void 0 ? void 0 : job.id }, row))),
|
|
177
|
+
products: ((job === null || job === void 0 ? void 0 : job.job_items) || []).filter((row) => row.deleted_at == null).map((row) => newLine(duplicate ? linePayload(row, "products") : require_objectSpread2._objectSpread2({ job_id: job === null || job === void 0 ? void 0 : job.id }, row)))
|
|
178
|
+
});
|
|
179
|
+
if (duplicate) Object.assign(draft, {
|
|
180
|
+
id: void 0,
|
|
181
|
+
job_number: "",
|
|
182
|
+
status: "create",
|
|
183
|
+
invoice_date: null
|
|
184
|
+
});
|
|
185
|
+
dateFields.forEach((key) => {
|
|
186
|
+
draft[key] = draft[key] ? (0, dayjs.default)(draft[key]) : null;
|
|
187
|
+
});
|
|
188
|
+
return draft;
|
|
189
|
+
}
|
|
190
|
+
const sessionFor = (draft) => ({
|
|
191
|
+
id: draft.id,
|
|
192
|
+
materials: new Map(draft.materials.filter((row) => row.id != null).map((row) => [row._key, require_objectSpread2._objectSpread2({}, row)])),
|
|
193
|
+
products: new Map(draft.products.filter((row) => row.id != null).map((row) => [row._key, require_objectSpread2._objectSpread2({}, row)]))
|
|
194
|
+
});
|
|
195
|
+
function pick(row, fields) {
|
|
196
|
+
return Object.fromEntries(fields.map((key) => {
|
|
197
|
+
const value = typeof row[key] === "string" ? row[key].trim() : row[key];
|
|
198
|
+
return [key, value === "" || value === void 0 ? null : value];
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
function jobPayload(draft) {
|
|
202
|
+
const data = pick(draft, jobFields);
|
|
203
|
+
editableDateFields.forEach((key) => {
|
|
204
|
+
data[key] = dateText(draft[key]) || null;
|
|
205
|
+
});
|
|
206
|
+
return data;
|
|
207
|
+
}
|
|
208
|
+
/** 流转至 Invoice 时记录首次开票日期;其他流转保留已发生的开票记录。 */
|
|
209
|
+
function statusPayload(job, status, today = dateText((0, dayjs.default)())) {
|
|
210
|
+
if (!statuses.includes(status)) throw new Error("pisell2.panpacific.task.invalidStatus");
|
|
211
|
+
return require_objectSpread2._objectSpread2({ status }, status === "invoice" && !job.invoice_date ? { invoice_date: today } : {});
|
|
212
|
+
}
|
|
213
|
+
function jobLineText(row, kind, base) {
|
|
214
|
+
var _base$kind$find, _row$quantity;
|
|
215
|
+
const name = row[kind === "materials" ? "material_name" : "product_name"] || ((_base$kind$find = base[kind].find((item) => String(item.id) === String(row[kind === "materials" ? "material_item_id" : "product_id"]))) === null || _base$kind$find === void 0 ? void 0 : _base$kind$find.name) || row.description || "—";
|
|
216
|
+
const price = row.unit_price == null || row.unit_price === "" ? "" : ` @ ${row.unit_price}/${row.price_unit || "piece"}`;
|
|
217
|
+
return `${name} ×${(_row$quantity = row.quantity) !== null && _row$quantity !== void 0 ? _row$quantity : "—"}${price}`;
|
|
218
|
+
}
|
|
219
|
+
const linePayload = (row, kind) => {
|
|
220
|
+
var _payload$description;
|
|
221
|
+
const payload = pick(row, [
|
|
222
|
+
"description",
|
|
223
|
+
"quantity",
|
|
224
|
+
"unit_price",
|
|
225
|
+
"price_unit",
|
|
226
|
+
"item_status",
|
|
227
|
+
...kind === "materials" ? ["material_item_id", "material_name"] : ["product_id", "product_name"]
|
|
228
|
+
]);
|
|
229
|
+
return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, payload), {}, { description: (_payload$description = payload.description) !== null && _payload$description !== void 0 ? _payload$description : "" });
|
|
230
|
+
};
|
|
231
|
+
function validateDraft(draft) {
|
|
232
|
+
var _draft$job_number;
|
|
233
|
+
if (!((_draft$job_number = draft.job_number) === null || _draft$job_number === void 0 ? void 0 : _draft$job_number.trim()) || !dateText(draft.job_created_date) || !dateText(draft.due_date)) throw new Error("pisell2.panpacific.task.required");
|
|
234
|
+
if (editableDateFields.some((key) => draft[key] && !dateText(draft[key]))) throw new Error("pisell2.panpacific.task.invalidDate");
|
|
235
|
+
if (dateText(draft.due_date) < (dateText(draft.pickup_date) || dateText(draft.job_created_date))) throw new Error("pisell2.panpacific.task.invalidRange");
|
|
236
|
+
for (const kind of ["materials", "products"]) {
|
|
237
|
+
const keys = /* @__PURE__ */ new Set();
|
|
238
|
+
for (const row of draft[kind]) {
|
|
239
|
+
if (!row._key || keys.has(row._key)) throw new Error("pisell2.panpacific.task.invalidRows");
|
|
240
|
+
keys.add(row._key);
|
|
241
|
+
if (kind === "materials" && (row.material_item_id == null || row.quantity == null || row.quantity === "")) throw new Error("pisell2.panpacific.task.materialRequired");
|
|
242
|
+
if (["quantity", "unit_price"].some((key) => row[key] != null && (!Number.isFinite(Number(row[key])) || Number(row[key]) < 0))) throw new Error("pisell2.panpacific.task.invalidNumber");
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function shiftDates(job, after, action) {
|
|
247
|
+
const before = jobRange(job);
|
|
248
|
+
if (!before) throw new Error("pisell2.panpacific.task.invalidDate");
|
|
249
|
+
if (!dateText(after.start) || !dateText(after.endExclusive) || after.start >= after.endExclusive) throw new Error("pisell2.panpacific.task.invalidRange");
|
|
250
|
+
const due = (0, dayjs.default)(after.endExclusive).subtract(1, "day").format("YYYY-MM-DD");
|
|
251
|
+
if (action === "resize-start") return { pickup_date: after.start };
|
|
252
|
+
if (action === "resize-end") return { due_date: due };
|
|
253
|
+
const delta = (0, dayjs.default)(after.start).diff((0, dayjs.default)(before.start), "day");
|
|
254
|
+
return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, dateText(job.pickup_date) ? { pickup_date: (0, dayjs.default)(job.pickup_date).add(delta, "day").format("YYYY-MM-DD") } : {}), {}, { due_date: (0, dayjs.default)(job.due_date).add(delta, "day").format("YYYY-MM-DD") });
|
|
255
|
+
}
|
|
256
|
+
const nextStatus = (current) => ({
|
|
257
|
+
create: "collected",
|
|
258
|
+
collected: "invoice",
|
|
259
|
+
invoice: "complete"
|
|
260
|
+
})[current];
|
|
261
|
+
//#endregion
|
|
262
|
+
exports.calendarItems = calendarItems;
|
|
263
|
+
exports.companyName = companyName;
|
|
264
|
+
exports.dateText = dateText;
|
|
265
|
+
exports.displayStatus = displayStatus;
|
|
266
|
+
exports.displayStatuses = displayStatuses;
|
|
267
|
+
exports.draftFor = draftFor;
|
|
268
|
+
exports.emptyBase = emptyBase;
|
|
269
|
+
exports.filterJobs = filterJobs;
|
|
270
|
+
exports.hasInvoice = hasInvoice;
|
|
271
|
+
exports.jobLineGroups = jobLineGroups;
|
|
272
|
+
exports.jobLineText = jobLineText;
|
|
273
|
+
exports.jobPayload = jobPayload;
|
|
274
|
+
exports.jobRange = jobRange;
|
|
275
|
+
exports.jobStyle = jobStyle;
|
|
276
|
+
exports.jobsOnDate = jobsOnDate;
|
|
277
|
+
exports.linePayload = linePayload;
|
|
278
|
+
exports.newLine = newLine;
|
|
279
|
+
exports.nextJobCode = nextJobCode;
|
|
280
|
+
exports.nextStatus = nextStatus;
|
|
281
|
+
exports.paymentTerm = paymentTerm;
|
|
282
|
+
exports.scheduleText = scheduleText;
|
|
283
|
+
exports.sessionFor = sessionFor;
|
|
284
|
+
exports.shiftDates = shiftDates;
|
|
285
|
+
exports.statusColors = statusColors;
|
|
286
|
+
exports.statusPayload = statusPayload;
|
|
287
|
+
exports.statuses = statuses;
|
|
288
|
+
exports.supplierSnapshot = supplierSnapshot;
|
|
289
|
+
exports.validateDraft = validateDraft;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
+
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
+
const require_model = require("./model.js");
|
|
4
|
+
const require_serve = require("./serve.js");
|
|
5
|
+
const require_tenant = require("./tenant.js");
|
|
6
|
+
//#region src/plus/panpacificTask/saveJob.ts
|
|
7
|
+
function requireTenantId(tenantId) {
|
|
8
|
+
if (require_tenant.isTenantId(tenantId)) return tenantId;
|
|
9
|
+
throw new require_serve.JobRequestError("pisell2.panpacific.task.missingTenant");
|
|
10
|
+
}
|
|
11
|
+
/** 新建一次提交关联明细;编辑按记录保存并维护重试检查点。 */
|
|
12
|
+
function saveJob(_x, _x2, _x3, _x4) {
|
|
13
|
+
return _saveJob.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
function _saveJob() {
|
|
16
|
+
_saveJob = require_asyncToGenerator._asyncToGenerator(function* (request, draft, session, tenantId) {
|
|
17
|
+
if (session.createdId != null) return session.createdId;
|
|
18
|
+
if (session.uncertain) throw new require_serve.JobRequestError("pisell2.panpacific.task.uncertain");
|
|
19
|
+
require_model.validateDraft(draft);
|
|
20
|
+
const createTenantId = session.id == null || ["materials", "products"].some((kind) => draft[kind].some((row) => !session[kind].has(row._key))) ? requireTenantId(tenantId) : void 0;
|
|
21
|
+
try {
|
|
22
|
+
if (session.id == null) {
|
|
23
|
+
const created = yield require_serve.createJob(request, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_model.jobPayload(draft)), {}, {
|
|
24
|
+
tenant_id: createTenantId,
|
|
25
|
+
status: "create",
|
|
26
|
+
invoice_date: null,
|
|
27
|
+
job_materials: draft.materials.map((row) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_model.linePayload(row, "materials")), {}, { tenant_id: createTenantId })),
|
|
28
|
+
job_items: draft.products.map((row) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_model.linePayload(row, "products")), {}, { tenant_id: createTenantId }))
|
|
29
|
+
}));
|
|
30
|
+
session.createdId = created.id;
|
|
31
|
+
return created.id;
|
|
32
|
+
}
|
|
33
|
+
yield require_serve.updateJob(request, session.id, require_model.jobPayload(draft));
|
|
34
|
+
for (const kind of ["materials", "products"]) {
|
|
35
|
+
const create = kind === "materials" ? require_serve.createJobMaterial : require_serve.createJobProduct;
|
|
36
|
+
const update = kind === "materials" ? require_serve.updateJobMaterial : require_serve.updateJobProduct;
|
|
37
|
+
const remove = kind === "materials" ? require_serve.removeJobMaterial : require_serve.removeJobProduct;
|
|
38
|
+
const checkpoint = session[kind];
|
|
39
|
+
const wanted = new Set(draft[kind].map((row) => row._key));
|
|
40
|
+
for (const row of draft[kind]) {
|
|
41
|
+
const previous = checkpoint.get(row._key);
|
|
42
|
+
const payload = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_model.linePayload(row, kind)), {}, { job_id: session.id });
|
|
43
|
+
if (previous) {
|
|
44
|
+
if (String(previous.job_id) !== String(session.id)) throw new Error("Invalid job line ownership");
|
|
45
|
+
if (JSON.stringify(require_model.linePayload(previous, kind)) !== JSON.stringify(require_model.linePayload(row, kind))) yield update(request, previous.id, payload);
|
|
46
|
+
checkpoint.set(row._key, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, row), payload), {}, { id: previous.id }));
|
|
47
|
+
} else {
|
|
48
|
+
const created = yield create(request, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, payload), {}, { tenant_id: createTenantId }));
|
|
49
|
+
checkpoint.set(row._key, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, row), payload), {}, { id: created.id }));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (const [key, previous] of checkpoint) {
|
|
53
|
+
if (wanted.has(key)) continue;
|
|
54
|
+
if (String(previous.job_id) !== String(session.id)) throw new Error("Invalid job line ownership");
|
|
55
|
+
yield remove(request, previous.id);
|
|
56
|
+
checkpoint.delete(key);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return session.id;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error === null || error === void 0 ? void 0 : error.uncertainCreate) session.uncertain = true;
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return _saveJob.apply(this, arguments);
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
exports.saveJob = saveJob;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
const require_defineProperty = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js");
|
|
2
|
+
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
|
+
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
4
|
+
const require_attachments = require("./attachments.js");
|
|
5
|
+
//#region src/plus/panpacificTask/serve.ts
|
|
6
|
+
const URL_MAP = {
|
|
7
|
+
job: "/api/prs_job",
|
|
8
|
+
material: "/api/prs_job_material",
|
|
9
|
+
product: "/api/prs_job_item",
|
|
10
|
+
payment: "/api/prs_job_payment",
|
|
11
|
+
photo: "/api/prs_job_pickup_photo",
|
|
12
|
+
suppliers: "/api/prs_supplier",
|
|
13
|
+
materials: "/api/prs_material_item",
|
|
14
|
+
products: "/api/prs_product",
|
|
15
|
+
paymentTerms: "/api/prs_payment_term",
|
|
16
|
+
categories: "/api/prs_task_category"
|
|
17
|
+
};
|
|
18
|
+
const requestConfig = () => ({
|
|
19
|
+
isNocobase: true,
|
|
20
|
+
headers: { "x-data-source": "pisell2" },
|
|
21
|
+
fullResult: true,
|
|
22
|
+
timeout: 6e4,
|
|
23
|
+
skipErrorHandler: true,
|
|
24
|
+
customToast: () => {}
|
|
25
|
+
});
|
|
26
|
+
var JobRequestError = class extends Error {
|
|
27
|
+
constructor(..._args) {
|
|
28
|
+
super(..._args);
|
|
29
|
+
require_defineProperty._defineProperty(this, "definiteFailure", false);
|
|
30
|
+
require_defineProperty._defineProperty(this, "uncertainCreate", false);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function responseErrors(value) {
|
|
34
|
+
var _ref, _value$response$data, _value$response;
|
|
35
|
+
const body = (_ref = (_value$response$data = value === null || value === void 0 || (_value$response = value.response) === null || _value$response === void 0 ? void 0 : _value$response.data) !== null && _value$response$data !== void 0 ? _value$response$data : value === null || value === void 0 ? void 0 : value.data) !== null && _ref !== void 0 ? _ref : value;
|
|
36
|
+
return [
|
|
37
|
+
value === null || value === void 0 ? void 0 : value.errors,
|
|
38
|
+
body === null || body === void 0 ? void 0 : body.errors,
|
|
39
|
+
value,
|
|
40
|
+
body
|
|
41
|
+
].find((items) => Array.isArray(items) && items.length && items.every((item) => typeof (item === null || item === void 0 ? void 0 : item.message) === "string" && item.id == null)) || [];
|
|
42
|
+
}
|
|
43
|
+
function errorMessage(error) {
|
|
44
|
+
var _error$response, _error$data;
|
|
45
|
+
return [...new Set(responseErrors(error).map((item) => item.message))].join("; ") || (error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message) || (error === null || error === void 0 || (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message) || (error === null || error === void 0 ? void 0 : error.message) || (typeof (error === null || error === void 0 ? void 0 : error.error) === "string" ? error.error : "") || (typeof error === "string" ? error : "") || "pisell2.panpacific.task.requestFailed";
|
|
46
|
+
}
|
|
47
|
+
const isJobCodeConflict = (error) => {
|
|
48
|
+
const message = errorMessage(error);
|
|
49
|
+
return message === "pisell2.panpacific.task.jobCodeConflict" || /\bprs_job_tenant_job_number_unique\b/i.test(message) && /must be unique|duplicate|unique constraint|unique violation/i.test(message);
|
|
50
|
+
};
|
|
51
|
+
const errorText = (error) => isJobCodeConflict(error) ? "pisell2.panpacific.task.jobCodeConflict" : errorMessage(error);
|
|
52
|
+
/** 查询参数放入 URL,避免由不同宿主客户端重复序列化 filter/appends。 */
|
|
53
|
+
function buildUrl(url, action, query = {}) {
|
|
54
|
+
const params = new URLSearchParams();
|
|
55
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
56
|
+
if (value === void 0) return;
|
|
57
|
+
if (Array.isArray(value)) value.forEach((item) => params.append(`${key}[]`, String(item)));
|
|
58
|
+
else params.set(key, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
59
|
+
});
|
|
60
|
+
const suffix = params.toString();
|
|
61
|
+
return `${url}:${action}${suffix ? `?${suffix}` : ""}`;
|
|
62
|
+
}
|
|
63
|
+
function checkResponse(result) {
|
|
64
|
+
if (responseErrors(result).length || (result === null || result === void 0 ? void 0 : result.status) === false) {
|
|
65
|
+
const error = new JobRequestError(errorText(result));
|
|
66
|
+
error.definiteFailure = true;
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
if (result == null) throw new JobRequestError("pisell2.panpacific.task.requestFailed");
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
const responseData = (response) => response && Object.prototype.hasOwnProperty.call(response, "data") ? response.data : response;
|
|
73
|
+
const responseRecord = (response) => {
|
|
74
|
+
const data = responseData(response);
|
|
75
|
+
return Array.isArray(data) ? data[0] : data;
|
|
76
|
+
};
|
|
77
|
+
/** 保留 NocoBase meta,分页失败时不返回不完整的列表。 */
|
|
78
|
+
function getAll(_x, _x2) {
|
|
79
|
+
return _getAll.apply(this, arguments);
|
|
80
|
+
}
|
|
81
|
+
function _getAll() {
|
|
82
|
+
_getAll = require_asyncToGenerator._asyncToGenerator(function* (request, url, query = {}) {
|
|
83
|
+
const rows = [];
|
|
84
|
+
for (let page = 1; page <= 100; page++) {
|
|
85
|
+
var _result$meta, _result$meta2;
|
|
86
|
+
const result = checkResponse(yield request.get(buildUrl(url, "list", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, query), {}, {
|
|
87
|
+
page,
|
|
88
|
+
pageSize: 200,
|
|
89
|
+
sort: ["id"],
|
|
90
|
+
filter: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, query.filter), {}, { deleted_at: null })
|
|
91
|
+
})), {}, requestConfig()));
|
|
92
|
+
const batch = responseData(result);
|
|
93
|
+
if (!Array.isArray(batch)) throw new Error(`Invalid list response: ${url}`);
|
|
94
|
+
rows.push(...batch);
|
|
95
|
+
if (((_result$meta = result.meta) === null || _result$meta === void 0 ? void 0 : _result$meta.totalPage) != null ? page >= Number(result.meta.totalPage) : ((_result$meta2 = result.meta) === null || _result$meta2 === void 0 ? void 0 : _result$meta2.count) != null ? rows.length >= Number(result.meta.count) || !batch.length : batch.length < 200) return rows;
|
|
96
|
+
}
|
|
97
|
+
throw new Error("Too many jobs; narrow the collection query");
|
|
98
|
+
});
|
|
99
|
+
return _getAll.apply(this, arguments);
|
|
100
|
+
}
|
|
101
|
+
function createRecord(_x3, _x4, _x5) {
|
|
102
|
+
return _createRecord.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
function _createRecord() {
|
|
105
|
+
_createRecord = require_asyncToGenerator._asyncToGenerator(function* (request, url, data) {
|
|
106
|
+
try {
|
|
107
|
+
const created = responseRecord(checkResponse(yield request.post(buildUrl(url, "create"), data, requestConfig())));
|
|
108
|
+
if ((created === null || created === void 0 ? void 0 : created.id) == null) throw new Error("Create response has no ID");
|
|
109
|
+
return created;
|
|
110
|
+
} catch (cause) {
|
|
111
|
+
var _cause$response;
|
|
112
|
+
const status = (cause === null || cause === void 0 ? void 0 : cause.status) || (cause === null || cause === void 0 || (_cause$response = cause.response) === null || _cause$response === void 0 ? void 0 : _cause$response.status);
|
|
113
|
+
const error = new JobRequestError(errorText(cause));
|
|
114
|
+
error.uncertainCreate = !(url === URL_MAP.job && isJobCodeConflict(cause) || (cause === null || cause === void 0 ? void 0 : cause.definiteFailure) || status >= 400 && status < 500 && status !== 408);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return _createRecord.apply(this, arguments);
|
|
119
|
+
}
|
|
120
|
+
function updateRecord(_x6, _x7, _x8, _x9) {
|
|
121
|
+
return _updateRecord.apply(this, arguments);
|
|
122
|
+
}
|
|
123
|
+
function _updateRecord() {
|
|
124
|
+
_updateRecord = require_asyncToGenerator._asyncToGenerator(function* (request, url, id, data) {
|
|
125
|
+
return checkResponse(yield request.post(buildUrl(url, "update", { filterByTk: id }), data, requestConfig()));
|
|
126
|
+
});
|
|
127
|
+
return _updateRecord.apply(this, arguments);
|
|
128
|
+
}
|
|
129
|
+
function removeRecord(_x10, _x11, _x12) {
|
|
130
|
+
return _removeRecord.apply(this, arguments);
|
|
131
|
+
}
|
|
132
|
+
function _removeRecord() {
|
|
133
|
+
_removeRecord = require_asyncToGenerator._asyncToGenerator(function* (request, url, id) {
|
|
134
|
+
const result = checkResponse(yield request.post(buildUrl(url, "destroy", { filterByTk: id }), {}, requestConfig()));
|
|
135
|
+
const count = responseData(result);
|
|
136
|
+
if (count === 0 || count === "0") {
|
|
137
|
+
const error = new JobRequestError("pisell2.panpacific.task.lineDeleteFailed");
|
|
138
|
+
error.definiteFailure = true;
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
});
|
|
143
|
+
return _removeRecord.apply(this, arguments);
|
|
144
|
+
}
|
|
145
|
+
function getJobs(_x13) {
|
|
146
|
+
return _getJobs.apply(this, arguments);
|
|
147
|
+
}
|
|
148
|
+
function _getJobs() {
|
|
149
|
+
_getJobs = require_asyncToGenerator._asyncToGenerator(function* (request) {
|
|
150
|
+
return (yield getAll(request, URL_MAP.job, { appends: ["job_materials", "job_items"] })).map((job) => {
|
|
151
|
+
var _job$job_materials, _job$job_items;
|
|
152
|
+
return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, job), {}, {
|
|
153
|
+
job_materials: (_job$job_materials = job.job_materials) === null || _job$job_materials === void 0 ? void 0 : _job$job_materials.filter((row) => row.deleted_at == null),
|
|
154
|
+
job_items: (_job$job_items = job.job_items) === null || _job$job_items === void 0 ? void 0 : _job$job_items.filter((row) => row.deleted_at == null)
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
return _getJobs.apply(this, arguments);
|
|
159
|
+
}
|
|
160
|
+
function getJobDetail(_x14, _x15) {
|
|
161
|
+
return _getJobDetail.apply(this, arguments);
|
|
162
|
+
}
|
|
163
|
+
function _getJobDetail() {
|
|
164
|
+
_getJobDetail = require_asyncToGenerator._asyncToGenerator(function* (request, id) {
|
|
165
|
+
const job = responseRecord(checkResponse(yield request.get(buildUrl(URL_MAP.job, "get", {
|
|
166
|
+
filterByTk: id,
|
|
167
|
+
appends: ["job_materials", "job_items"]
|
|
168
|
+
}), {}, requestConfig())));
|
|
169
|
+
if (!job || String(job.id) !== String(id)) throw new Error("Job not found");
|
|
170
|
+
if (!Array.isArray(job.job_materials) || !Array.isArray(job.job_items)) throw new Error("Job relations are missing");
|
|
171
|
+
return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, job), {}, {
|
|
172
|
+
job_materials: job.job_materials.filter((row) => row.deleted_at == null),
|
|
173
|
+
job_items: job.job_items.filter((row) => row.deleted_at == null)
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
return _getJobDetail.apply(this, arguments);
|
|
177
|
+
}
|
|
178
|
+
function getJobBaseData(_x16) {
|
|
179
|
+
return _getJobBaseData.apply(this, arguments);
|
|
180
|
+
}
|
|
181
|
+
function _getJobBaseData() {
|
|
182
|
+
_getJobBaseData = require_asyncToGenerator._asyncToGenerator(function* (request) {
|
|
183
|
+
const keys = [
|
|
184
|
+
"suppliers",
|
|
185
|
+
"materials",
|
|
186
|
+
"products",
|
|
187
|
+
"paymentTerms",
|
|
188
|
+
"categories"
|
|
189
|
+
];
|
|
190
|
+
const results = yield Promise.allSettled(keys.map((key) => getAll(request, URL_MAP[key])));
|
|
191
|
+
const base = {};
|
|
192
|
+
results.forEach((result, index) => {
|
|
193
|
+
if (result.status === "fulfilled") base[keys[index]] = result.value;
|
|
194
|
+
else console.warn("[PanpacificTask] Base data load failed", result.reason);
|
|
195
|
+
});
|
|
196
|
+
return base;
|
|
197
|
+
});
|
|
198
|
+
return _getJobBaseData.apply(this, arguments);
|
|
199
|
+
}
|
|
200
|
+
function getJobRelated(_x17, _x18) {
|
|
201
|
+
return _getJobRelated.apply(this, arguments);
|
|
202
|
+
}
|
|
203
|
+
function _getJobRelated() {
|
|
204
|
+
_getJobRelated = require_asyncToGenerator._asyncToGenerator(function* (request, id) {
|
|
205
|
+
const query = { filter: { job_id: { $eq: id } } };
|
|
206
|
+
const results = yield Promise.allSettled([getAll(request, URL_MAP.payment, query), getAll(request, URL_MAP.photo, query)]);
|
|
207
|
+
results.forEach((result) => {
|
|
208
|
+
if (result.status === "rejected") console.warn("[PanpacificTask] Related load failed", result.reason);
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
payments: results[0].status === "fulfilled" ? results[0].value : void 0,
|
|
212
|
+
photos: results[1].status === "fulfilled" ? results[1].value : void 0
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
return _getJobRelated.apply(this, arguments);
|
|
216
|
+
}
|
|
217
|
+
const createJob = (request, data) => createRecord(request, URL_MAP.job, data);
|
|
218
|
+
const updateJob = (request, id, data) => updateRecord(request, URL_MAP.job, id, data);
|
|
219
|
+
/** 与 registry 的 deleteGroup 一致,更新 deleted_at 软删除。 */
|
|
220
|
+
const removeJob = (request, id) => updateJob(request, id, { deleted_at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
221
|
+
const createJobMaterial = (request, data) => createRecord(request, URL_MAP.material, data);
|
|
222
|
+
const updateJobMaterial = (request, id, data) => updateRecord(request, URL_MAP.material, id, data);
|
|
223
|
+
const removeJobMaterial = (request, id) => removeRecord(request, URL_MAP.material, id);
|
|
224
|
+
const createJobProduct = (request, data) => createRecord(request, URL_MAP.product, data);
|
|
225
|
+
const updateJobProduct = (request, id, data) => updateRecord(request, URL_MAP.product, id, data);
|
|
226
|
+
const removeJobProduct = (request, id) => removeRecord(request, URL_MAP.product, id);
|
|
227
|
+
const createJobPayment = (request, data) => createRecord(request, URL_MAP.payment, data);
|
|
228
|
+
const createJobPickupPhoto = (request, data) => createRecord(request, URL_MAP.photo, data);
|
|
229
|
+
/** JSON 字段可能包含多张图片;仅移除选中附件,最后一张删除后软删除照片记录。 */
|
|
230
|
+
function removeJobPickupPhoto(_x19, _x20, _x21) {
|
|
231
|
+
return _removeJobPickupPhoto.apply(this, arguments);
|
|
232
|
+
}
|
|
233
|
+
function _removeJobPickupPhoto() {
|
|
234
|
+
_removeJobPickupPhoto = require_asyncToGenerator._asyncToGenerator(function* (request, row, index) {
|
|
235
|
+
const photos = require_attachments.attachments(row.photo);
|
|
236
|
+
if (row.id == null || !Number.isInteger(index) || index < 0 || index >= photos.length) throw new Error("pisell2.panpacific.task.requestFailed");
|
|
237
|
+
const remaining = photos.filter((_, i) => i !== index);
|
|
238
|
+
yield updateRecord(request, URL_MAP.photo, row.id, remaining.length ? { photo: remaining } : { deleted_at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
239
|
+
});
|
|
240
|
+
return _removeJobPickupPhoto.apply(this, arguments);
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
exports.JobRequestError = JobRequestError;
|
|
244
|
+
exports.createJob = createJob;
|
|
245
|
+
exports.createJobMaterial = createJobMaterial;
|
|
246
|
+
exports.createJobPayment = createJobPayment;
|
|
247
|
+
exports.createJobPickupPhoto = createJobPickupPhoto;
|
|
248
|
+
exports.createJobProduct = createJobProduct;
|
|
249
|
+
exports.errorText = errorText;
|
|
250
|
+
exports.getJobBaseData = getJobBaseData;
|
|
251
|
+
exports.getJobDetail = getJobDetail;
|
|
252
|
+
exports.getJobRelated = getJobRelated;
|
|
253
|
+
exports.getJobs = getJobs;
|
|
254
|
+
exports.removeJob = removeJob;
|
|
255
|
+
exports.removeJobMaterial = removeJobMaterial;
|
|
256
|
+
exports.removeJobPickupPhoto = removeJobPickupPhoto;
|
|
257
|
+
exports.removeJobProduct = removeJobProduct;
|
|
258
|
+
exports.updateJob = updateJob;
|
|
259
|
+
exports.updateJobMaterial = updateJobMaterial;
|
|
260
|
+
exports.updateJobProduct = updateJobProduct;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/plus/panpacificTask/tenant.ts
|
|
2
|
+
function isTenantId(value) {
|
|
3
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 || typeof value === "string" && /^[1-9]\d*$/.test(value);
|
|
4
|
+
}
|
|
5
|
+
/** saas_shop 将首次 /tenant/core 响应存入 store;tenant.tenant_id 指向上级租户。 */
|
|
6
|
+
function getCurrentTenantId(store) {
|
|
7
|
+
try {
|
|
8
|
+
var _store$getState;
|
|
9
|
+
const tenantId = store === null || store === void 0 || (_store$getState = store.getState) === null || _store$getState === void 0 || (_store$getState = _store$getState.call(store)) === null || _store$getState === void 0 || (_store$getState = _store$getState.core) === null || _store$getState === void 0 || (_store$getState = _store$getState.core) === null || _store$getState === void 0 || (_store$getState = _store$getState.tenant) === null || _store$getState === void 0 ? void 0 : _store$getState.id;
|
|
10
|
+
return isTenantId(tenantId) ? tenantId : void 0;
|
|
11
|
+
} catch (_unused) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.getCurrentTenantId = getCurrentTenantId;
|
|
17
|
+
exports.isTenantId = isTenantId;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/plus/panpacificTask/types.d.ts
|
|
4
|
+
type Id = string | number;
|
|
5
|
+
type Row = Record<string, any>;
|
|
6
|
+
interface Attachment extends Row {
|
|
7
|
+
url: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
}
|
|
10
|
+
interface PanpacificTaskProps {
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
defaultTab?: 'calendar' | 'timeline' | 'list';
|
|
14
|
+
/** 可选的附件上传扩展;默认使用宿主 mediaUploadUrl / getHeaders 直传媒体接口。 */
|
|
15
|
+
uploadPhoto?: (file: File) => Promise<Attachment>;
|
|
16
|
+
onJobChange?: (jobId: Id) => void;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Attachment, PanpacificTaskProps };
|