@fewangsit/wangsvue-fats 1.0.1-alpha.51 → 1.0.1-alpha.52

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.
@@ -3,11 +3,73 @@ import { DisposalReason } from '@tagsamurai/fats-api-services/src/types/disposal
3
3
 
4
4
  import { ClassComponent } from '../ts-helpers';
5
5
 
6
+ type Option = {
7
+ label?: string;
8
+ value?: string;
9
+ };
10
+
6
11
  export interface DisposalReportProps {
7
12
  router: Router;
8
13
  reason: DisposalReason;
14
+ from: 'damage' | 'missing';
15
+ }
16
+
17
+ /**
18
+ * Type of the selected data, it refers to data response from Asset API.
19
+ */
20
+ export interface Asset {
21
+ _id?: string;
22
+ asset?: string;
23
+ name?: {
24
+ _id: string;
25
+ nameWithSequence: string;
26
+ name: string;
27
+ key: number;
28
+ };
29
+ assetName?: {
30
+ _id: string;
31
+ nameWithSequence: string;
32
+ name: string;
33
+ key: number;
34
+ };
35
+ tagType?: string;
36
+ status?: string;
37
+ category?: {
38
+ _id?: string;
39
+ name?: string;
40
+ key?: number;
41
+ };
42
+ group?: {
43
+ _id?: string;
44
+ name?: string;
45
+ key?: number;
46
+ };
47
+ assetGroup?: {
48
+ _id?: string;
49
+ name?: string;
50
+ key?: number;
51
+ };
52
+ assetBrand?: {
53
+ _id: string;
54
+ name: string;
55
+ key: number;
56
+ };
57
+ assetModel?: {
58
+ _id: string;
59
+ name: string;
60
+ key: number;
61
+ };
62
+ assetImage?: string;
63
+ damageImage?: string;
9
64
  }
10
65
 
66
+ export type FilterOptions = {
67
+ assetNameOptions?: Option[];
68
+ assetBrandOptions?: Option[];
69
+ assetModelOptions?: Option[];
70
+ assetGroupOptions?: Option[];
71
+ };
72
+
11
73
  export default class DisposalReport extends ClassComponent<
12
74
  DisposalReportProps,
13
75
  unknown,
@@ -1,26 +1,29 @@
1
- import { defineComponent as s, createBlock as a, openBlock as r, withCtx as n, createElementVNode as e, createVNode as p, toDisplayString as i, unref as c, normalizeProps as l, guardReactiveProps as _ } from "vue";
2
- import { u as m } from "../plugins/basei18n.es.js";
1
+ import { defineComponent as r, createBlock as a, openBlock as n, withCtx as p, createElementVNode as o, createVNode as i, toDisplayString as l, unref as e, normalizeProps as c, guardReactiveProps as m } from "vue";
2
+ import { u as _ } from "../plugins/basei18n.es.js";
3
+ import { a as f } from "../utils/role.util.es.js";
4
+ import "../event-bus/index.es.js";
3
5
  import { _ as d } from "../card/index.es.js";
4
- import { _ as f } from "../disposalreporttable/index.es.js";
5
- const u = {
6
+ import { _ as u } from "../disposalreporttable/index.es.js";
7
+ const g = {
6
8
  class: "flex flex-col gap-3",
7
9
  "data-ts-name": "disposalreport"
8
- }, g = {
10
+ }, x = {
9
11
  class: "text-general-800 font-bold text-base leading-[21.86px] tracking-[0.02em]",
10
12
  "data-ts-section": "pagetitle"
11
- }, v = /* @__PURE__ */ s({
13
+ }, v = /* @__PURE__ */ r({
12
14
  __name: "DisposalReport",
13
15
  props: {
14
16
  router: {},
15
- reason: {}
17
+ reason: {},
18
+ from: {}
16
19
  },
17
- setup(x) {
18
- const { t } = m();
19
- return (o, h) => (r(), a(d, null, {
20
- content: n(() => [
21
- e("div", u, [
22
- e("h2", g, i(c(t)("Asset Disposal")), 1),
23
- p(f, l(_(o.$props)), null, 16)
20
+ setup(h) {
21
+ const { t } = _();
22
+ return (s, D) => (n(), a(d, null, {
23
+ content: p(() => [
24
+ o("div", g, [
25
+ o("h2", x, l(e(f)() === "Basic" ? e(t)("Report Disposal") : e(t)("Asset Disposal")), 1),
26
+ i(u, c(m(s.$props)), null, 16)
24
27
  ])
25
28
  ]),
26
29
  _: 1
@@ -0,0 +1,238 @@
1
+ import { defineComponent as M, mergeModels as b, useModel as $, shallowRef as v, ref as I, computed as d, createBlock as z, openBlock as G, withCtx as h, createElementVNode as l, createVNode as o, toDisplayString as T, withDirectives as J, vShow as j } from "vue";
2
+ import { AssetServices as y } from "@tagsamurai/fats-api-services";
3
+ import { e as R } from "../event-bus/index.es.js";
4
+ import "../utils/role.util.es.js";
5
+ import { u as V } from "../utils/toast.util.es.js";
6
+ import { _ as m } from "../badge/index.es.js";
7
+ import { _ as g } from "../button/index.es.js";
8
+ import { _ as E } from "../buttonfilter/index.es.js";
9
+ import { _ as P } from "../buttonsearch/index.es.js";
10
+ import { D as U } from "../datatable/index.es.js";
11
+ import { _ as q } from "../dialog/index.es.js";
12
+ import { _ as H } from "../image/index.es.js";
13
+ import { _ as K } from "../filtercontainer/index.es.js";
14
+ const L = { class: "flex justify-between items-center" }, W = {
15
+ class: "flex gap-1 items-center justify-end",
16
+ "data-ts-section": "button-group"
17
+ }, Y = { class: "flex flex-col gap-1" }, Q = {
18
+ class: "text-xs text-red-600",
19
+ "data-ts-section": "message-validator"
20
+ }, X = { class: "flex items-center justify-end gap-1" }, me = /* @__PURE__ */ M({
21
+ __name: "DisposalReportDialogSelectAsset",
22
+ props: /* @__PURE__ */ b({
23
+ selectedAssets: {},
24
+ excludedKey: {},
25
+ header: {},
26
+ size: {},
27
+ assetStatus: {},
28
+ fetchFunction: { type: Function },
29
+ fetchOptionFunction: { type: Function }
30
+ }, {
31
+ visible: { type: Boolean, default: !1 },
32
+ visibleModifiers: {}
33
+ }),
34
+ emits: /* @__PURE__ */ b(["select"], ["update:visible"]),
35
+ setup(p, { emit: _ }) {
36
+ const t = p, O = _, r = $(p, "visible"), S = V(), n = v("select-asset-table"), c = v(!1), i = I([]), x = d(() => [
37
+ {
38
+ field: "assetImage",
39
+ header: "Photo",
40
+ style: "min-width: 72px",
41
+ bodyComponent: (s) => ({
42
+ component: H,
43
+ props: {
44
+ src: s.assetImage ?? s.damageImage,
45
+ size: "small"
46
+ }
47
+ })
48
+ },
49
+ {
50
+ field: "assetName.nameWithSequence",
51
+ header: "Name",
52
+ sortable: !0
53
+ },
54
+ {
55
+ field: "assetId",
56
+ header: "Asset ID",
57
+ sortable: !0
58
+ },
59
+ {
60
+ field: "assetBrand.name",
61
+ header: "Brand",
62
+ sortable: !0,
63
+ bodyComponent: (s) => {
64
+ var e;
65
+ return {
66
+ component: m,
67
+ props: {
68
+ label: (e = s.assetBrand) == null ? void 0 : e.name,
69
+ severity: "dark"
70
+ }
71
+ };
72
+ }
73
+ },
74
+ {
75
+ field: "assetModel.name",
76
+ header: "Model/Type",
77
+ sortable: !0,
78
+ bodyComponent: (s) => {
79
+ var e;
80
+ return {
81
+ component: m,
82
+ props: {
83
+ label: (e = s.assetModel) == null ? void 0 : e.name,
84
+ severity: "dark"
85
+ }
86
+ };
87
+ }
88
+ },
89
+ {
90
+ field: "assetGroup.name",
91
+ header: "Group",
92
+ sortable: !0,
93
+ bodyComponent: (s) => {
94
+ var e;
95
+ return {
96
+ component: m,
97
+ props: {
98
+ label: (e = s.assetGroup) == null ? void 0 : e.name
99
+ }
100
+ };
101
+ }
102
+ }
103
+ ]), A = d(() => [
104
+ {
105
+ label: "Name",
106
+ field: "assetName",
107
+ placeholder: "Select name",
108
+ type: "multiselect",
109
+ fetchOptionFn: () => t.fetchOptionFunction ? t.fetchOptionFunction("assetNameOptions") : u("nameOptions")
110
+ },
111
+ {
112
+ label: "Brand",
113
+ field: "assetBrand",
114
+ placeholder: "Select brand",
115
+ type: "multiselect",
116
+ fetchOptionFn: () => t.fetchOptionFunction ? t.fetchOptionFunction("assetBrandOptions") : u("brandOptions")
117
+ },
118
+ {
119
+ label: "Model/Type",
120
+ field: "assetModel",
121
+ placeholder: "Select model/type",
122
+ type: "multiselect",
123
+ fetchOptionFn: () => t.fetchOptionFunction ? t.fetchOptionFunction("assetModelOptions") : u("modelOptions")
124
+ },
125
+ {
126
+ label: "Group",
127
+ field: "assetGroup",
128
+ type: "group"
129
+ }
130
+ ]), F = d(() => {
131
+ switch (t.size) {
132
+ case "large":
133
+ return "1000px";
134
+ case "small":
135
+ return "600px";
136
+ default:
137
+ return "800px";
138
+ }
139
+ }), w = d(() => t.header ?? "Select Asset"), u = async (s) => {
140
+ var f;
141
+ const e = JSON.stringify(t.selectedAssets ?? []), a = {
142
+ [s]: !0,
143
+ excludeId: e,
144
+ status: JSON.stringify(t.assetStatus ?? ["Available"])
145
+ }, { data: C } = await y.getAllAssetsOptions(a);
146
+ return ((f = C.data) == null ? void 0 : f[s]) ?? [];
147
+ }, N = async (s) => {
148
+ const e = JSON.stringify(t.selectedAssets ?? []);
149
+ try {
150
+ const { data: a } = await y.getAllAssets({
151
+ excludeId: e,
152
+ status: JSON.stringify(t.assetStatus ?? ["Available"]),
153
+ ...s
154
+ });
155
+ return a;
156
+ } catch (a) {
157
+ console.error(a), S.add({
158
+ error: a,
159
+ message: "Error, failed to get asset list."
160
+ });
161
+ }
162
+ }, D = () => {
163
+ i.value.length === 0 ? c.value = !0 : B();
164
+ }, B = () => {
165
+ O("select", i.value), c.value = !1, r.value = !1;
166
+ }, k = () => {
167
+ i.value = [], R.emit("data-table:clear-selected-data", {
168
+ tableName: n.value
169
+ });
170
+ };
171
+ return (s, e) => (G(), z(q, {
172
+ visible: r.value,
173
+ "onUpdate:visible": e[3] || (e[3] = (a) => r.value = a),
174
+ header: w.value,
175
+ pt: { root: { style: { width: F.value } } },
176
+ onHide: k,
177
+ closable: "",
178
+ "data-ts-section": "dialogselectasset",
179
+ modal: ""
180
+ }, {
181
+ footer: h(() => [
182
+ l("div", Y, [
183
+ J(l("small", Q, " You must pick an asset ", 512), [
184
+ [j, c.value]
185
+ ]),
186
+ l("div", X, [
187
+ o(g, {
188
+ onClick: e[2] || (e[2] = (a) => r.value = !1),
189
+ "data-ts-section": "button-cancel",
190
+ label: "Cancel",
191
+ severity: "secondary",
192
+ text: ""
193
+ }),
194
+ o(g, {
195
+ onClick: D,
196
+ "data-ts-section": "button-select",
197
+ label: "Select",
198
+ severity: "success"
199
+ })
200
+ ])
201
+ ])
202
+ ]),
203
+ default: h(() => [
204
+ l("div", L, [
205
+ e[4] || (e[4] = l("span", null, "Select asset(s) to be disposed.", -1)),
206
+ l("div", W, [
207
+ o(P, { "table-name": n.value }, null, 8, ["table-name"]),
208
+ o(E, { "table-name": n.value }, null, 8, ["table-name"])
209
+ ])
210
+ ]),
211
+ o(K, {
212
+ fields: A.value,
213
+ "table-name": n.value
214
+ }, null, 8, ["fields", "table-name"]),
215
+ o(U, {
216
+ "selected-data": i.value,
217
+ "onUpdate:selectedData": e[0] || (e[0] = (a) => i.value = a),
218
+ columns: x.value,
219
+ "fetch-function": t.fetchFunction ?? N,
220
+ rows: 10,
221
+ "table-name": n.value,
222
+ "use-option": !1,
223
+ onRowSelect: e[1] || (e[1] = (a) => c.value = !1),
224
+ "data-key": "_id",
225
+ "data-ts-section": "dialog-select-asset-table",
226
+ lazy: "",
227
+ "selection-type": "checkbox",
228
+ "use-paginator": ""
229
+ }, null, 8, ["selected-data", "columns", "fetch-function", "table-name"]),
230
+ l("pre", null, T(t.selectedAssets), 1)
231
+ ]),
232
+ _: 1
233
+ }, 8, ["visible", "header", "pt"]));
234
+ }
235
+ });
236
+ export {
237
+ me as _
238
+ };