@fewangsit/wangsvue-fats 1.0.1-alpha.56 → 1.0.1-alpha.57

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