xyvcard-goods 0.0.15 → 0.0.17

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.
@@ -1,558 +0,0 @@
1
- import { defineComponent as j, ref as g, watchEffect as O, computed as W, resolveComponent as p, openBlock as D, createElementBlock as L, Fragment as Z, createVNode as e, withCtx as u, createElementVNode as y, reactive as A, watch as J, unref as t, createBlock as K, createCommentVNode as Q, createTextVNode as X } from "vue";
2
- import { ElMessageBox as Y, ElMessage as F } from "element-plus";
3
- import { fileApi as k, routerUtil as P } from "jmash-core";
4
- import { useI18n as G } from "vue-i18n";
5
- import { _ as x } from "./skuTable-YDBH_oRN.mjs";
6
- import { useRouter as ee, useRoute as le } from "vue-router";
7
- import { D as m, C as oe } from "./index-DZJVaUh3.mjs";
8
- import { goodsSpuApi as B } from "./index.mjs";
9
- import { g as te } from "./index-BHmGYIuc.mjs";
10
- import { WangEditor as se } from "xyvcard-cms";
11
- import ae from "./skuForm-B7yYjwdJ.mjs";
12
- const ue = ["src"], re = /* @__PURE__ */ j({
13
- __name: "ImageUpload",
14
- props: {
15
- modelValue: {
16
- type: String,
17
- default: () => ""
18
- },
19
- listType: {
20
- type: String,
21
- default: "picture"
22
- },
23
- limit: {
24
- type: Number,
25
- default: 1e3
26
- }
27
- },
28
- emits: ["update:modelValue"],
29
- setup(b, { emit: i }) {
30
- const { t: h } = G(), c = g(k.uploadUrl()), v = g(k.authHeader()), l = g(), V = g(!1), T = g(""), q = b, f = g([]);
31
- O(() => {
32
- f.value = q.modelValue.split(",").filter(Boolean);
33
- });
34
- const U = W(
35
- () => f.value.map((a) => ({ url: k.imageUrl(a), status: "success", uid: a }))
36
- ), C = (a) => {
37
- T.value = a.url, V.value = !0;
38
- }, $ = (a) => {
39
- const r = a.size / 1024 / 1024 < 2;
40
- ["image/jpeg", "image/png", "image/gif", "image/jpg"].includes(a.type) && !r && Y.confirm(h("file.imageLtRequired"), h("file.warning"), {
41
- confirmButtonText: h("common.confirm"),
42
- cancelButtonText: h("common.cancel"),
43
- type: "warning"
44
- }).then(async () => {
45
- }).catch(() => (f.value.splice(-1, 1), n(), !1));
46
- }, R = (a) => {
47
- f.value = f.value.filter((r) => k.imageUrl(r) !== a.url), n();
48
- }, s = (a) => {
49
- f.value.push(a.fileSrc), n();
50
- }, o = i, n = () => {
51
- o("update:modelValue", f.value.join(","));
52
- };
53
- return (a, r) => {
54
- const _ = p("Plus"), w = p("el-icon"), S = p("el-upload"), E = p("el-dialog");
55
- return D(), L(Z, null, [
56
- e(S, {
57
- ref_key: "uploadImageRef",
58
- ref: l,
59
- "file-list": U.value,
60
- "onUpdate:fileList": r[0] || (r[0] = (I) => U.value = I),
61
- action: c.value,
62
- headers: v.value,
63
- limit: b.limit,
64
- "list-type": b.listType,
65
- "on-preview": C,
66
- "before-upload": $,
67
- "on-success": s,
68
- "on-remove": R
69
- }, {
70
- default: u(() => [
71
- e(w, null, {
72
- default: u(() => [
73
- e(_)
74
- ]),
75
- _: 1
76
- })
77
- ]),
78
- _: 1
79
- }, 8, ["file-list", "action", "headers", "limit", "list-type"]),
80
- e(E, {
81
- modelValue: V.value,
82
- "onUpdate:modelValue": r[1] || (r[1] = (I) => V.value = I),
83
- fullscreen: !0
84
- }, {
85
- default: u(() => [
86
- y("img", {
87
- src: T.value,
88
- alt: ""
89
- }, null, 8, ue)
90
- ]),
91
- _: 1
92
- }, 8, ["modelValue"])
93
- ], 64);
94
- };
95
- }
96
- }), de = /* @__PURE__ */ x(re, [["__scopeId", "data-v-f10f6f7e"]]), ne = { class: "app-container" }, pe = { class: "search-container" }, ie = { class: "image-card" }, ve = /* @__PURE__ */ j({
97
- __name: "edit",
98
- setup(b) {
99
- var R;
100
- const { t: i } = G(), h = ee(), c = le(), v = g();
101
- m.shopInfoBizDict.useValues(), m.goodsCategoryListBizLayDict.useValues();
102
- let l = A({
103
- requestId: Math.random() * 10 + "",
104
- updateMask: "shopId,spuName,categoryId,spuCode,freightType,freightAmount,picUrls,shelf,saleNum,sellPoint,specType,description",
105
- skuSpecValues: [],
106
- freightType: m.freightTypeEnum.values[0].key,
107
- freightAmount: 0,
108
- shelf: m.shelfDict.values[0].key,
109
- specType: m.specTypeEnum.values[0].key,
110
- shopId: (R = m.shopInfoBizDict.values[0]) == null ? void 0 : R.key
111
- });
112
- const V = (s, o, n) => {
113
- var r;
114
- const a = (r = l.picUrls) == null ? void 0 : r.split(",").filter(Boolean);
115
- if (a != null && a.length) {
116
- if ((a == null ? void 0 : a.length) < 3)
117
- return n(new Error(i("goodsSpu.imageListsError")));
118
- n();
119
- } else return n(new Error(i("goodsSpu.picUrlsRequired")));
120
- }, T = A({
121
- shopId: [
122
- {
123
- required: !0,
124
- message: i("goodsSpu.shopIdRequired"),
125
- trigger: "change"
126
- }
127
- ],
128
- spuName: [
129
- {
130
- required: !0,
131
- message: i("goodsSpu.spuNameRequired"),
132
- trigger: "blur"
133
- }
134
- ],
135
- categoryId: [
136
- {
137
- required: !0,
138
- message: i("goodsSpu.categoryIdRequired"),
139
- trigger: "change"
140
- }
141
- ],
142
- spuCode: [
143
- {
144
- required: !0,
145
- message: i("goodsSpu.spuCodeRequired"),
146
- trigger: "change"
147
- }
148
- ],
149
- freightType: [
150
- {
151
- required: !0,
152
- message: i("goodsSpu.freightTypeRequired"),
153
- trigger: "change"
154
- }
155
- ],
156
- freightAmount: [
157
- {
158
- required: !0,
159
- message: i("goodsSpu.freightAmountRequired"),
160
- trigger: "blur"
161
- }
162
- ],
163
- picUrls: [
164
- {
165
- validator: V,
166
- trigger: "change"
167
- }
168
- ],
169
- shelf: [
170
- {
171
- required: !0,
172
- message: i("goodsSpu.shelfRequired"),
173
- trigger: "change"
174
- }
175
- ],
176
- specType: [
177
- {
178
- required: !0,
179
- message: i("goodsSpu.specTypeRequired"),
180
- trigger: "change"
181
- }
182
- ]
183
- }), q = g(!1);
184
- J(
185
- () => l.shopId,
186
- (s) => s,
187
- {
188
- deep: !0,
189
- immediate: !0
190
- }
191
- );
192
- function f(s) {
193
- l.skuSpecValues.push(s), l.skuSpecValues = l.skuSpecValues.slice(-1);
194
- }
195
- function U(s) {
196
- s.forEach((o) => {
197
- var n;
198
- l.specId = (n = o.specValues) == null ? void 0 : n.map((a) => a.specId), l.skuSpecValues.push(o);
199
- }), l.skuSpecValues = l.skuSpecValues.slice(-s.length);
200
- }
201
- c.query.spuId && B.findById({ spuId: c.query.spuId }).then(({ data: s }) => {
202
- Object.assign(l, s), q.value = !0, te.findById({ spuId: c.query.spuId }).then(({ data: o }) => {
203
- l.ensureIds = o.ensures;
204
- });
205
- });
206
- const C = async () => {
207
- var s;
208
- await ((s = v.value) == null ? void 0 : s.validate((o) => {
209
- o && (c.query.spuId ? B.update(l).then((n) => {
210
- n.status === 200 && (F({
211
- message: i("common.submitSuccess"),
212
- type: "success"
213
- }), P.closeTagView(c.fullPath, h, !1));
214
- }) : B.create(l).then((n) => {
215
- n.status === 200 && (F({
216
- message: i("common.submitSuccess"),
217
- type: "success"
218
- }), P.closeTagView(c.fullPath, h, !1));
219
- }));
220
- }));
221
- };
222
- function $(s) {
223
- s === "FREIGHT_FREE" && (l.freightAmount = 0);
224
- }
225
- return (s, o) => {
226
- const n = p("jmash-select"), a = p("el-form-item"), r = p("el-col"), _ = p("el-input"), w = p("el-tree-select"), S = p("jmash-enum-radio"), E = p("el-input-number"), I = de, z = p("jmash-dict-checkbox"), N = p("el-row"), M = p("el-button"), H = p("el-form");
227
- return D(), L("div", ne, [
228
- y("div", pe, [
229
- e(H, {
230
- ref_key: "goodsSpuFormRef",
231
- ref: v,
232
- model: t(l),
233
- "label-width": "120px",
234
- rules: T
235
- }, {
236
- default: u(() => [
237
- o[15] || (o[15] = y("div", { class: "title-content" }, "基本信息", -1)),
238
- e(N, null, {
239
- default: u(() => [
240
- e(r, { span: 12 }, {
241
- default: u(() => [
242
- e(a, {
243
- label: s.$t("goodsSpu.shopId"),
244
- prop: "shopId"
245
- }, {
246
- default: u(() => [
247
- e(n, {
248
- modelValue: t(l).shopId,
249
- "onUpdate:modelValue": o[0] || (o[0] = (d) => t(l).shopId = d),
250
- placeholder: s.$t("goodsSpu.shopIdRequired"),
251
- data: t(m).shopInfoBizDict.values,
252
- filterable: "",
253
- class: "w-full"
254
- }, null, 8, ["modelValue", "placeholder", "data"])
255
- ]),
256
- _: 1
257
- }, 8, ["label"])
258
- ]),
259
- _: 1
260
- }),
261
- e(r, { span: 12 }, {
262
- default: u(() => [
263
- e(a, {
264
- label: s.$t("goodsSpu.spuName"),
265
- prop: "spuName"
266
- }, {
267
- default: u(() => [
268
- e(_, {
269
- modelValue: t(l).spuName,
270
- "onUpdate:modelValue": o[1] || (o[1] = (d) => t(l).spuName = d),
271
- placeholder: s.$t("goodsSpu.spuNameRequired"),
272
- maxlength: "60",
273
- "show-word-limit": "",
274
- clearable: ""
275
- }, null, 8, ["modelValue", "placeholder"])
276
- ]),
277
- _: 1
278
- }, 8, ["label"])
279
- ]),
280
- _: 1
281
- }),
282
- e(r, { span: 12 }, {
283
- default: u(() => [
284
- e(a, {
285
- label: s.$t("goodsSpu.categoryId"),
286
- prop: "categoryId"
287
- }, {
288
- default: u(() => [
289
- e(w, {
290
- modelValue: t(l).categoryId,
291
- "onUpdate:modelValue": o[2] || (o[2] = (d) => t(l).categoryId = d),
292
- data: t(m).goodsCategoryListBizLayDict.values,
293
- filterable: "",
294
- clearable: "",
295
- "check-strictly": "",
296
- "render-after-expand": !1,
297
- placeholder: s.$t("goodsSpu.categoryIdRequired"),
298
- class: "w-full"
299
- }, null, 8, ["modelValue", "data", "placeholder"])
300
- ]),
301
- _: 1
302
- }, 8, ["label"])
303
- ]),
304
- _: 1
305
- }),
306
- e(r, { span: 12 }, {
307
- default: u(() => [
308
- e(a, {
309
- label: s.$t("goodsSpu.spuCode"),
310
- prop: "spuCode"
311
- }, {
312
- default: u(() => [
313
- e(_, {
314
- modelValue: t(l).spuCode,
315
- "onUpdate:modelValue": o[3] || (o[3] = (d) => t(l).spuCode = d),
316
- placeholder: s.$t("goodsSpu.spuCodeRequired"),
317
- maxlength: "15",
318
- "show-word-limit": "",
319
- clearable: ""
320
- }, null, 8, ["modelValue", "placeholder"])
321
- ]),
322
- _: 1
323
- }, 8, ["label"])
324
- ]),
325
- _: 1
326
- }),
327
- e(r, { span: 12 }, {
328
- default: u(() => [
329
- e(a, {
330
- label: s.$t("goodsSpu.freightType"),
331
- prop: "freightType"
332
- }, {
333
- default: u(() => [
334
- e(S, {
335
- modelValue: t(l).freightType,
336
- "onUpdate:modelValue": o[4] || (o[4] = (d) => t(l).freightType = d),
337
- data: t(m).freightTypeEnum.values,
338
- onChange: $
339
- }, null, 8, ["modelValue", "data"])
340
- ]),
341
- _: 1
342
- }, 8, ["label"])
343
- ]),
344
- _: 1
345
- }),
346
- e(r, { span: 12 }, {
347
- default: u(() => [
348
- e(a, {
349
- label: s.$t("goodsSpu.freightAmount"),
350
- prop: "freightAmount"
351
- }, {
352
- default: u(() => [
353
- e(E, {
354
- modelValue: t(l).freightAmount,
355
- "onUpdate:modelValue": o[5] || (o[5] = (d) => t(l).freightAmount = d),
356
- readonly: t(l).freightType === "FREIGHT_FREE",
357
- precision: 2,
358
- step: 0.1,
359
- controls: !1,
360
- min: 0,
361
- placeholder: s.$t("goodsSpu.freightAmountRequired"),
362
- class: "w-full"
363
- }, null, 8, ["modelValue", "readonly", "placeholder"])
364
- ]),
365
- _: 1
366
- }, 8, ["label"])
367
- ]),
368
- _: 1
369
- }),
370
- e(r, { span: 24 }, {
371
- default: u(() => [
372
- e(a, {
373
- label: s.$t("goodsSpu.picUrls"),
374
- prop: "picUrls"
375
- }, {
376
- default: u(() => [
377
- y("div", ie, [
378
- e(I, {
379
- modelValue: t(l).picUrls,
380
- "onUpdate:modelValue": o[6] || (o[6] = (d) => t(l).picUrls = d),
381
- limit: 6,
382
- "list-type": "picture-card"
383
- }, null, 8, ["modelValue"]),
384
- o[13] || (o[13] = y("div", { class: "red-color" }, " 推荐尺寸:100*100或同比例图片,最少上传3张 ", -1))
385
- ])
386
- ]),
387
- _: 1
388
- }, 8, ["label"])
389
- ]),
390
- _: 1
391
- }),
392
- e(r, { span: 12 }, {
393
- default: u(() => [
394
- e(a, {
395
- label: s.$t("goodsSpu.shelf"),
396
- prop: "shelf"
397
- }, {
398
- default: u(() => [
399
- e(S, {
400
- modelValue: t(l).shelf,
401
- "onUpdate:modelValue": o[7] || (o[7] = (d) => t(l).shelf = d),
402
- data: t(m).shelfDict.values
403
- }, null, 8, ["modelValue", "data"])
404
- ]),
405
- _: 1
406
- }, 8, ["label"])
407
- ]),
408
- _: 1
409
- }),
410
- e(r, { span: 12 }, {
411
- default: u(() => [
412
- e(a, {
413
- label: s.$t("goodsSpu.saleNum"),
414
- prop: "saleNum"
415
- }, {
416
- default: u(() => [
417
- e(E, {
418
- modelValue: t(l).saleNum,
419
- "onUpdate:modelValue": o[8] || (o[8] = (d) => t(l).saleNum = d),
420
- placeholder: s.$t("goodsSpu.saleNumRequired"),
421
- class: "w-full",
422
- min: 0,
423
- controls: !1,
424
- precision: 0
425
- }, null, 8, ["modelValue", "placeholder"])
426
- ]),
427
- _: 1
428
- }, 8, ["label"])
429
- ]),
430
- _: 1
431
- }),
432
- e(r, { span: 24 }, {
433
- default: u(() => [
434
- e(a, {
435
- label: s.$t("goodsSpu.sellPoint"),
436
- prop: "sellPoint"
437
- }, {
438
- default: u(() => [
439
- e(_, {
440
- modelValue: t(l).sellPoint,
441
- "onUpdate:modelValue": o[9] || (o[9] = (d) => t(l).sellPoint = d),
442
- placeholder: s.$t("goodsSpu.sellPointRequired"),
443
- maxlength: "250",
444
- "show-word-limit": "",
445
- clearable: "",
446
- rows: 4,
447
- type: "textarea"
448
- }, null, 8, ["modelValue", "placeholder"])
449
- ]),
450
- _: 1
451
- }, 8, ["label"])
452
- ]),
453
- _: 1
454
- }),
455
- e(r, { span: 24 }, {
456
- default: u(() => [
457
- e(a, {
458
- label: s.$t("goodsSpu.ensureIds"),
459
- prop: "ensureIds"
460
- }, {
461
- default: u(() => [
462
- e(z, {
463
- modelValue: t(l).ensureIds,
464
- "onUpdate:modelValue": o[10] || (o[10] = (d) => t(l).ensureIds = d),
465
- "type-code": t(oe).DICT_GOODS_ENSURE
466
- }, null, 8, ["modelValue", "type-code"])
467
- ]),
468
- _: 1
469
- }, 8, ["label"])
470
- ]),
471
- _: 1
472
- })
473
- ]),
474
- _: 1
475
- }),
476
- o[16] || (o[16] = y("div", { class: "title-content" }, "商品规格", -1)),
477
- e(N, null, {
478
- default: u(() => [
479
- e(r, { span: 24 }, {
480
- default: u(() => [
481
- e(a, {
482
- label: s.$t("goodsSpu.specType"),
483
- prop: "specType"
484
- }, {
485
- default: u(() => [
486
- e(S, {
487
- modelValue: t(l).specType,
488
- "onUpdate:modelValue": o[11] || (o[11] = (d) => t(l).specType = d),
489
- data: t(m).specTypeEnum.values
490
- }, null, 8, ["modelValue", "data"])
491
- ]),
492
- _: 1
493
- }, 8, ["label"])
494
- ]),
495
- _: 1
496
- }),
497
- !t(c).query.spuId || q.value ? (D(), K(ae, {
498
- key: 0,
499
- "spec-type": t(l).specType,
500
- form: t(l),
501
- isDisabled: !t(l).shopId,
502
- onGetGoodsSku: f,
503
- onGetFormData: U
504
- }, null, 8, ["spec-type", "form", "isDisabled"])) : Q("", !0)
505
- ]),
506
- _: 1
507
- }),
508
- o[17] || (o[17] = y("div", { class: "title-content" }, "商品详情", -1)),
509
- e(N, null, {
510
- default: u(() => [
511
- e(r, { span: 24 }, {
512
- default: u(() => [
513
- e(a, {
514
- label: s.$t("goodsSpu.description"),
515
- prop: "description"
516
- }, {
517
- default: u(() => [
518
- e(t(se), {
519
- modelValue: t(l).description,
520
- "onUpdate:modelValue": o[12] || (o[12] = (d) => t(l).description = d),
521
- style: { width: "100%" }
522
- }, null, 8, ["modelValue"])
523
- ]),
524
- _: 1
525
- }, 8, ["label"])
526
- ]),
527
- _: 1
528
- }),
529
- e(a, null, {
530
- default: u(() => [
531
- e(M, {
532
- type: "primary",
533
- onClick: C
534
- }, {
535
- default: u(() => o[14] || (o[14] = [
536
- X("保存")
537
- ])),
538
- _: 1,
539
- __: [14]
540
- })
541
- ]),
542
- _: 1
543
- })
544
- ]),
545
- _: 1
546
- })
547
- ]),
548
- _: 1,
549
- __: [15, 16, 17]
550
- }, 8, ["model", "rules"])
551
- ])
552
- ]);
553
- };
554
- }
555
- });
556
- export {
557
- ve as default
558
- };