@simitgroup/simpleapp-generator 1.3.3-alpha → 1.3.4-alpha

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.
Files changed (67) hide show
  1. package/dist/framework.js +2 -2
  2. package/dist/framework.js.map +1 -1
  3. package/dist/generate.d.ts.map +1 -1
  4. package/dist/generate.js +7 -11
  5. package/dist/generate.js.map +1 -1
  6. package/dist/processors/jsonschemabuilder.d.ts.map +1 -1
  7. package/dist/processors/jsonschemabuilder.js +8 -0
  8. package/dist/processors/jsonschemabuilder.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/framework.ts +2 -2
  11. package/src/generate.ts +15 -12
  12. package/src/processors/jsonschemabuilder.ts +12 -1
  13. package/templates/basic/nest/controller.ts.eta +16 -5
  14. package/templates/basic/nuxt/component.select.vue.eta +35 -0
  15. package/templates/basic/nuxt/pages.form.vue.eta +5 -8
  16. package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +3 -1
  17. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +10 -9
  18. package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +2 -2
  19. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +38 -38
  20. package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +14 -9
  21. package/templates/nuxt/assets/css/style.css._eta +39 -3
  22. package/templates/nuxt/assets/primevue/passthrough.ts._eta +17 -12
  23. package/templates/nuxt/components/button/ButtonAction.vue._eta +19 -0
  24. package/templates/nuxt/components/button/ButtonDanger.vue._eta +13 -6
  25. package/templates/nuxt/components/button/ButtonDefault.vue._eta +13 -6
  26. package/templates/nuxt/components/button/ButtonMultiple.vue._eta +9 -7
  27. package/templates/nuxt/components/button/ButtonPrimary.vue._eta +13 -6
  28. package/templates/nuxt/components/button/ButtonText.vue._eta +16 -7
  29. package/templates/nuxt/components/button/ButtonWarning.vue._eta +13 -6
  30. package/templates/nuxt/components/calendar/CalendarSmall.vue.eta +83 -69
  31. package/templates/nuxt/components/chart/card.vue._eta +32 -0
  32. package/templates/nuxt/components/event/EventDocumentViewer.vue._eta +44 -21
  33. package/templates/nuxt/components/event/EventNotification.vue._eta +119 -107
  34. package/templates/nuxt/components/header/button/HeaderButtonProfile.vue.eta +129 -75
  35. package/templates/nuxt/components/list/ListView.vue.eta +44 -13
  36. package/templates/nuxt/components/mobile/MobileToolbar.vue.eta +6 -5
  37. package/templates/nuxt/components/overlay/OverlayPanelWithToolBar.vue.eta +35 -37
  38. package/templates/nuxt/components/overlay/OverlaySideBarCrud.vue.eta +3 -4
  39. package/templates/nuxt/components/renderer/RendererDate.vue.eta +3 -2
  40. package/templates/nuxt/components/renderer/RendererForeignKey.vue.eta +38 -34
  41. package/templates/nuxt/components/select/SelectTemplate.vue.eta +79 -0
  42. package/templates/nuxt/components/select/readme.md +1 -0
  43. package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +181 -35
  44. package/templates/nuxt/components/simpleApp/SimpleAppChildrenList.vue.eta +70 -0
  45. package/templates/nuxt/components/simpleApp/SimpleAppDocumentNo.vue.eta +77 -73
  46. package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +113 -111
  47. package/templates/nuxt/components/simpleApp/{SimpleAppFormToolBar.vue.eta → SimpleAppFormToolBar.vue._eta} +125 -61
  48. package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +116 -42
  49. package/templates/nuxt/components/text/TextPrimary.vue._eta +13 -0
  50. package/templates/nuxt/components/user/UserButtonCreateTenant.vue._eta +68 -0
  51. package/templates/nuxt/components/user/UserTenantPicker.vue.eta +81 -70
  52. package/templates/nuxt/composables/date.generate.ts.eta +2 -0
  53. package/templates/nuxt/composables/getDocument.generate.ts.eta +35 -2
  54. package/templates/nuxt/composables/getOpenApi.generate.ts.eta +5 -1
  55. package/templates/nuxt/composables/refreshDocumentList.generate.ts.eta +2 -1
  56. package/templates/nuxt/lang/en.ts.eta +3 -1
  57. package/templates/nuxt/nuxt.config.ts._eta +3 -0
  58. package/templates/nuxt/pages/index.vue._eta +10 -56
  59. package/templates/nuxt/pages/picktenant.vue._eta +19 -0
  60. package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +10 -2
  61. package/templates/nuxt/server/api/[xorg]/[...].ts.eta +9 -10
  62. package/templates/nuxt/types/calendar.ts.eta +2 -0
  63. package/templates/nuxt/types/events.ts.eta +3 -1
  64. package/templates/nuxt/types/simpleappinput.ts.eta +1 -0
  65. package/templates/project/lang/default._json +5 -1
  66. package/tsconfig.tsbuildinfo +1 -1
  67. package/templates/nuxt/components/user/UserButtonCreateTenant.vue.eta +0 -103
@@ -20,6 +20,7 @@
20
20
  v-model="modelValue"
21
21
  :binary="true"
22
22
  v-bind="componentProps as CheckboxProps"
23
+ @change="onChange"
23
24
  />
24
25
  <InputSwitch
25
26
  v-else-if="inputType == SimpleAppInputType.switch"
@@ -30,8 +31,9 @@
30
31
  v-model="modelValue as boolean"
31
32
  :binary="true"
32
33
  v-bind="componentProps as InputSwitchProps"
34
+ @change="onChange"
33
35
  />
34
-
36
+ <!--
35
37
  <InputText
36
38
  type="date"
37
39
  :pt="pt"
@@ -43,19 +45,24 @@
43
45
  :readonly="isReadonly"
44
46
  :placeholder="placeholder"
45
47
  v-bind="componentProps as InputTextProps"
46
- />
48
+ /> -->
47
49
  <!-- calendar component -->
48
50
  <Calendar
49
51
  type="date"
50
52
  :pt="pt"
51
- class="flex flex-col"
52
- v-else-if="SimpleAppInputType.calendar == inputType"
53
+ v-else-if="
54
+ SimpleAppInputType.calendar == inputType ||
55
+ inputType == SimpleAppInputType.date
56
+ "
53
57
  :inputId="slotprops.uuid"
54
58
  :path="setting.instancepath"
55
59
  v-model="datevalue"
56
60
  @update:modelValue="updateDate"
61
+ :touchUI="isMobile()"
62
+ showButtonBar
57
63
  :readonly="isReadonly"
58
64
  :placeholder="placeholder"
65
+ :date-format="getDateFormat()"
59
66
  v-bind="componentProps as CalendarProps"
60
67
  />
61
68
 
@@ -69,7 +76,7 @@
69
76
  @update:modelValue="updateTime"
70
77
  :inputId="slotprops.uuid"
71
78
  :path="setting.instancepath"
72
- v-model="modelValue as string"
79
+ v-model="timevalue"
73
80
  :readonly="isReadonly"
74
81
  :placeholder="placeholder"
75
82
  v-bind="componentProps as CalendarProps"
@@ -90,6 +97,7 @@
90
97
  optionValue="value"
91
98
  :placeholder="placeholder"
92
99
  v-bind="componentProps as ListboxProps"
100
+ @change="onChange"
93
101
  />
94
102
 
95
103
  <Dropdown
@@ -106,6 +114,7 @@
106
114
  optionValue="value"
107
115
  :placeholder="placeholder"
108
116
  v-bind="componentProps"
117
+ @change="onChange"
109
118
  />
110
119
 
111
120
  <!-- radio component -->
@@ -118,6 +127,7 @@
118
127
  name="smaple"
119
128
  :value="item.value"
120
129
  :readonly="isReadonly"
130
+ @change="onChange"
121
131
  />
122
132
  {{ " " }}
123
133
  <label :for="setting.key + '-' + index"> {{ item.label }} </label>
@@ -136,6 +146,8 @@
136
146
  :path="setting.instancepath"
137
147
  :readonly="isReadonly"
138
148
  :placeholder="placeholder"
149
+ :autocompleteFilter="autocompleteFilter"
150
+ @change="onChange"
139
151
  />
140
152
  <!-- v-bind:attributes="componentProps" -->
141
153
  <!-- document no input-->
@@ -149,6 +161,7 @@
149
161
  :pt="pt"
150
162
  :path="setting.instancepath"
151
163
  v-bind="componentProps as any"
164
+ @change="onChange"
152
165
  />
153
166
  <!-- use componentProps as any at the moment, no ideal yet, and for compatibility -->
154
167
 
@@ -163,6 +176,7 @@
163
176
  class="flex flex-col"
164
177
  :inputId="slotprops.uuid"
165
178
  :path="setting.instancepath"
179
+ @change="onChange"
166
180
  :placeholder="placeholder"
167
181
  v-bind="componentProps as PasswordProps"
168
182
  />
@@ -176,6 +190,7 @@
176
190
  :readonly="isReadonly"
177
191
  :inputId="slotprops.uuid"
178
192
  :path="setting.instancepath"
193
+ @change="onChange"
179
194
  v-bind="componentProps as RatingProps"
180
195
  />
181
196
 
@@ -189,10 +204,11 @@
189
204
  :inputId="slotprops.uuid"
190
205
  :path="setting.instancepath"
191
206
  :placeholder="placeholder"
207
+ @update:modelValue="onChange"
192
208
  v-bind="componentProps as ChipsProps"
193
209
  />
194
210
  <!-- simple component -->
195
-
211
+
196
212
  <InputNumber
197
213
  v-else-if="inputType == SimpleAppInputType.number"
198
214
  :type="type"
@@ -202,10 +218,27 @@
202
218
  :pt="pt"
203
219
  :class="!pt ? 'w-full flex flex-col' : ''"
204
220
  :inputId="slotprops.uuid"
221
+ @update:modelValue="onChange"
205
222
  :path="setting.instancepath"
206
223
  v-bind="componentProps as InputNumber"
207
224
  :placeholder="placeholder"
208
225
  />
226
+ <InputNumber
227
+ v-else-if="inputType == SimpleAppInputType.money"
228
+ :type="type"
229
+ v-model="modelValue as number"
230
+ @focus="setFocus"
231
+ :max-fraction-digits="2"
232
+ :min-fraction-digits="2"
233
+ :readonly="isReadonly"
234
+ :pt="pt"
235
+ :class="!pt ? 'w-full flex flex-col' : ''"
236
+ :inputId="slotprops.uuid"
237
+ :path="setting.instancepath"
238
+ @change="onChange"
239
+ v-bind="componentProps as InputNumber"
240
+ :placeholder="placeholder"
241
+ />
209
242
  <Textarea
210
243
  v-else-if="inputType == SimpleAppInputType.textarea"
211
244
  v-model="modelValue as string"
@@ -216,6 +249,7 @@
216
249
  class="w-full flex flex-col"
217
250
  :inputId="slotprops.uuid"
218
251
  :path="setting.instancepath"
252
+ @change="onChange"
219
253
  :placeholder="placeholder"
220
254
  v-bind="componentProps as TextareaProps"
221
255
  />
@@ -229,11 +263,12 @@
229
263
  :type="type"
230
264
  class="w-full flex flex-col"
231
265
  :inputId="slotprops.uuid"
266
+ @change="onChange"
232
267
  :path="setting.instancepath"
233
268
  :placeholder="placeholder"
234
269
  v-bind="componentProps as InputTextProps"
235
270
  />
236
- <!-- component require special treatment -->
271
+ <!-- component require special treatment -->
237
272
  </SimpleAppFieldContainer>
238
273
  </template>
239
274
 
@@ -267,9 +302,10 @@ import { SimpleAppInputType } from "~/types";
267
302
 
268
303
  const instancepath = ref("");
269
304
  const modelValue = defineModel({ required: true });
270
- const datevalue = ref("");
271
- const timevalue = ref<Date>();
272
305
 
306
+ const datevalue = ref<Date>();
307
+ const timevalue = ref<Date>();
308
+ let watchOnChange=0
273
309
  const props = withDefaults(
274
310
  defineProps<{
275
311
  inputType: SimpleAppInputType;
@@ -284,6 +320,7 @@ const props = withDefaults(
284
320
  autofocus?: boolean;
285
321
  pt?: any;
286
322
  placeholder?: string;
323
+ autocompleteFilter?: any;
287
324
  componentProps?:
288
325
  | InputNumberProps
289
326
  | InputSwitchProps
@@ -296,45 +333,55 @@ const props = withDefaults(
296
333
  { type: "text" },
297
334
  );
298
335
 
299
- const pt =ref(props.pt)
336
+ const pt = ref(props.pt);
300
337
 
301
338
  if (props.inputType == SimpleAppInputType.date && modelValue.value) {
302
- datevalue.value = moment(modelValue.value as string).format("YYYY-MM-DD");
339
+ datevalue.value = stringToDate(<string>modelValue.value); //.format("YYYY-MM-DD");
303
340
  } else {
304
- datevalue.value = "";
341
+ datevalue.value = undefined;
342
+ }
343
+
344
+ if (props.inputType == SimpleAppInputType.time) {
345
+ if (modelValue.value) {
346
+ timevalue.value = stringToDate(
347
+ (today() + "T" + modelValue.value) as string,
348
+ ); //.format("YYYY-MM-DD");
349
+ } else {
350
+ timevalue.value = undefined;
351
+ }
305
352
  }
306
353
 
307
354
  if (props?.instancepath) instancepath.value = props.instancepath;
308
- else if (props.setting?.instancepath)
309
- instancepath.value = props.setting.instancepath;
310
- else instancepath.value = "/unknown";
355
+ else if (props.setting?.instancepath)
356
+ instancepath.value = props.setting.instancepath;
357
+ else instancepath.value = "/unknown";
311
358
 
312
359
  watch(props.setting.errors, (newvalue, oldvalue) => {
313
- let errmsg = ''
360
+ let errmsg = "";
314
361
  if (newvalue[instancepath.value]) {
315
- const errlist: any[] = newvalue[instancepath.value];
362
+ const errlist: any[] = newvalue[instancepath.value];
316
363
  for (let i = 0; i < errlist.length; i++) {
317
364
  errmsg += errlist[i].message + ",";
318
- }
365
+ }
319
366
  } else {
320
- errmsg = "";
367
+ errmsg = "";
321
368
  }
322
- if(errmsg!=''){
323
- const errorstyle = { style:'border-color: lightcoral; color:white '}
324
- if(!pt.value)pt.value = {}
369
+ if (errmsg != "") {
370
+ const errorstyle = { style: "border-color: lightcoral; color:white " };
371
+ if (!pt.value) pt.value = {};
325
372
 
326
- if(props.inputType == SimpleAppInputType.text) pt.value={ root: errorstyle}
327
- else if(props.inputType == SimpleAppInputType.autocomplete) pt.value={ input:errorstyle}
328
- else if(props.inputType == SimpleAppInputType.number) pt.value={ input: {root:errorstyle} }
329
- else pt.value = {root: errorstyle, input:{root:errorstyle}}
373
+ if (props.inputType == SimpleAppInputType.text)
374
+ pt.value = { root: errorstyle };
375
+ else if (props.inputType == SimpleAppInputType.autocomplete)
376
+ pt.value = { input: errorstyle };
377
+ else if (props.inputType == SimpleAppInputType.number)
378
+ pt.value = { input: { root: errorstyle } };
379
+ else pt.value = { root: errorstyle, input: { root: errorstyle } };
330
380
  //some component still not working
331
-
332
- }else{
333
- pt.value=props.pt
381
+ } else {
382
+ pt.value = props.pt;
334
383
  }
335
-
336
-
337
- })
384
+ });
338
385
  const isReadonly = computed(() => {
339
386
  if (props.readonly) {
340
387
  return props.readonly;
@@ -344,15 +391,18 @@ const isReadonly = computed(() => {
344
391
  return false;
345
392
  }
346
393
  });
347
- const updateTime = () => {
348
- modelValue.value = moment(timevalue.value).format("HH:mm:ss");
394
+ const updateTime = (value: Date) => {
395
+ value.setSeconds(0);
396
+ modelValue.value = dateToTimeString(value);
397
+ onChange()
349
398
  };
350
399
  const updateDate = (value: any) => {
351
400
  if (value) {
352
- modelValue.value = moment(value).format("YYYY-MM-DD");
401
+ modelValue.value = dateToString(value);
353
402
  } else {
354
403
  modelValue.value = "";
355
404
  }
405
+ onChange()
356
406
  };
357
407
 
358
408
  const setFocus = (ev: any) => {
@@ -380,6 +430,10 @@ const emits = defineEmits([
380
430
  "update:docNoFormat",
381
431
  ]);
382
432
 
433
+ const getDateFormat = () => {
434
+ return getPrimevueCalendarDateFormat();
435
+ };
436
+
383
437
  watch(modelValue, (newvalue: any) => {
384
438
  if (
385
439
  [SimpleAppInputType.date, SimpleAppInputType.calendar].includes(
@@ -387,14 +441,21 @@ watch(modelValue, (newvalue: any) => {
387
441
  )
388
442
  ) {
389
443
  if (modelValue.value) {
390
- datevalue.value = moment(modelValue.value as string).format("YYYY-MM-DD");
444
+ datevalue.value = stringToDate(modelValue.value as string);
445
+ } else {
446
+ timevalue.value = undefined;
447
+ }
448
+ } else if (props.inputType == SimpleAppInputType.time) {
449
+ if (modelValue.value) {
450
+ timevalue.value = stringToDate(
451
+ (today() + "T" + modelValue.value) as string,
452
+ );
391
453
  } else {
392
- datevalue.value = "";
454
+ timevalue.value = undefined;
393
455
  }
394
456
  }
395
-
396
- emits("change", modelValue.value);
397
- emits("update:modelValue", modelValue.value);
457
+
458
+
398
459
  });
399
460
  onMounted(() => {
400
461
  if (
@@ -403,13 +464,26 @@ onMounted(() => {
403
464
  )
404
465
  ) {
405
466
  if (modelValue.value) {
406
- datevalue.value = moment(modelValue.value as string).format("YYYY-MM-DD");
467
+ datevalue.value = stringToDate(modelValue.value as string);
468
+ } else {
469
+ datevalue.value = undefined;
470
+ }
471
+ } else if (props.inputType == SimpleAppInputType.time) {
472
+ if (modelValue.value) {
473
+ timevalue.value = stringToDate(
474
+ (today() + "T" + modelValue.value) as string,
475
+ );
407
476
  } else {
408
- datevalue.value = "";
477
+ timevalue.value = undefined;
409
478
  }
410
479
  }
480
+
411
481
  });
412
482
 
483
+ const onChange=()=>{
484
+ emits("change", modelValue.value);
485
+ }
486
+
413
487
  /************ start autocomplete only ***************/
414
488
 
415
489
  /************ end autocomplete only ***************/
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <div class="text-base text-primary-600 dark:text-primary-500">
3
+ <slot name="default"></slot>
4
+ </div>
5
+ </template>
6
+ <script setup lang="ts">
7
+ /**
8
+ * This file was automatically generated by simpleapp generator during initialization. It is changable.
9
+ * --remove-this-line-to-prevent-override--
10
+ * last change 2024-02-22
11
+ * author: Ks Tan
12
+ */
13
+ </script>
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <div>
3
+ <div class="mt-8 md:flex justify-start md:gap-4">
4
+ <form @submit.prevent="true" class="w-full">
5
+ <div>{{ t('createNewCompany') }}</div>
6
+ <div class="p-inputgroup flex flex-row">
7
+ <InputText
8
+ class="flex-1"
9
+ :placeholder="t('yourCompanyName')"
10
+ v-model:model-value="data.tenantName"
11
+ />
12
+ <div class="p-inputgroup-addon p p-0">
13
+ <button
14
+ :label="t('create')"
15
+ class="border rounded-tl-none rounded-bl-none btn btn-primary -ml-1 h-full p-3 rounded-r-md"
16
+ @click="createTenant"
17
+ :loading="onhold"
18
+ >
19
+ {{ t("create") }}
20
+ </button>
21
+ </div>
22
+ </div>
23
+ </form>
24
+
25
+ </div>
26
+
27
+
28
+ </div>
29
+ </template>
30
+ <script setup lang="ts">
31
+ /**
32
+ * This file was automatically generated by simpleapp generator during initialization. It is changable.
33
+ * --remove-this-line-to-prevent-override--
34
+ * last change 2024-03-05
35
+ * author: Ks Tan
36
+ */
37
+ import { ref } from "vue";
38
+ import { AxiosResponse } from "axios";
39
+ const visible = ref(false);
40
+ const data = ref({ tenantName: "" });
41
+
42
+ const createtitle = ref("Create My Company");
43
+ const errCreateTenant = ref();
44
+ const onhold = ref(false);
45
+
46
+ const createTenant = async () => {
47
+ onhold.value = true;
48
+
49
+
50
+ getPorfileApi()
51
+ .createTenant(data.value)
52
+ .then((res: AxiosResponse) => {
53
+ if (res && res.status && res.status == 201) {
54
+ if (res.data && res.data["xOrg"]) {
55
+ const xorg = res.data["xOrg"];
56
+ navigateTo("/" + xorg, { external: true });
57
+ }
58
+ }
59
+ })
60
+ .catch((err) => {
61
+ errCreateTenant.value = err["message"];
62
+ console.error("errCreateTenant", err);
63
+ })
64
+ .finally(() => {
65
+ onhold.value = false;
66
+ });
67
+ };
68
+ </script>
@@ -1,61 +1,72 @@
1
1
  <template>
2
- <div v-if="alltenants" v-for="tenant in alltenants">
3
- <card :pt="{ header:{class:'text-xl text-gray-600'}}">
4
-
2
+ <div class="w-full">
3
+ <div v-if="waiting" class="p-4 w-full">
4
+ waiting..
5
+ </div>
6
+ <div v-else class="w-full p-4">
7
+
8
+ <div v-for="tenant in alltenants" class="border rounded-lg p-2 m-2">
9
+ <TextTitle>{{ tenant.tenantName }}</TextTitle>
10
+ <ListView :list="tenant.permissions" url="/" idField="xOrg">
11
+ <template #default="{item,index}">
12
+ <div class="flex flex-row w-full justify-end">
13
+ <TextPrimary class="flex-1">{{ item.orgName }}</TextPrimary>
14
+ <TextPrimary>{{ item.branchCode }}</TextPrimary>
15
+
16
+ </div>
17
+ </template>
18
+ </ListView>
19
+ </div>
20
+
21
+ <!-- <card :pt="{ header: { class: 'text-xl text-gray-600' } }">
5
22
  <template #header>
6
- {{tenant.tenantName }}
23
+ {{ tenant.tenantName }}
7
24
  </template>
8
- <template #content>
9
-
10
- <ul >
11
- <li v-for="o in getOrglist(tenant)">
12
- <h1 class="subtitle-text">{{ o.orgName }}</h1>
13
- <ul role="list" class="divide-y divide-gray-100 rounded-md border border-gray-200">
14
- <li v-for="b in getBranchlist(tenant)" class="w-full items-center justify-between py-4 pl-4 pr-4 text-sm route-link-list">
15
- <NuxtLink :href="`/${b.xOrg }`" v-if="o.orgId==b.orgId" :external="true" >
16
- <div class="flex w-full flex-1 items-center ">
17
- <!-- <i class="pi pi-sitemap"></i> -->
18
- <p class="flex-1 flex-shrink-0 font-bold text-primary-600 ">
19
- {{ b.branchCode }}
20
- </p>
21
- <p class=" text-right min-w-0 flex-1 gap-2">
22
- <span href="#" class="font-medium text-gray-600 ">{{ b.group }}</span>
23
- </p>
24
- </div>
25
- <div class=" flex-shrink-0">
26
-
27
- <span class=" font-medium text-gray-400">{{useRuntimeConfig().public.APP_URL}}/{{b.xOrg }}</span>
28
-
29
- </div>
30
-
31
- </NuxtLink>
32
- </li>
33
- </ul>
34
-
35
- </li>
36
- </ul>
37
-
38
- <!-- <ul>
39
- <li v-for="b in branches" class="border border-b-1">
40
- <NuxtLink :href="`/${b.xOrg }`" :external="true">
41
-
42
- <div class="flex flex-col">
43
- <div class="flex">
44
- <p class="flex-1">{{b.branch.branchCode}}</p>
45
- <p class="flex-1 text-right">{{b.group }}</p>
46
- </div>
47
-
48
-
49
- <p class="text-gray-500">{{useRuntimeConfig().public.APP_URL}}/{{b.xOrg }}</p>
50
-
25
+ <template #content>
26
+ <ul>
27
+ <li v-for="o in getOrglist(tenant)">
28
+ <h1 class="subtitle-text">{{ o.orgName }}</h1>
29
+ <ul
30
+ role="list"
31
+ class="divide-y divide-gray-100 rounded-md border border-gray-200"
32
+ >
33
+ <li
34
+ v-for="b in getBranchlist(tenant)"
35
+ class="w-full items-center justify-between py-4 pl-4 pr-4 text-sm route-link-list"
36
+ >
37
+ <NuxtLink
38
+ :href="`/${b.xOrg}`"
39
+ v-if="o.orgId == b.orgId"
40
+ :external="true"
41
+ >
42
+ <div class="flex w-full flex-1 items-center">
43
+ <p class="flex-1 flex-shrink-0 font-bold text-primary-600">
44
+ {{ b.branchCode }}
45
+ </p>
46
+ <p class="text-right min-w-0 flex-1 gap-2">
47
+ <span href="#" class="font-medium text-gray-600">{{
48
+ b.group
49
+ }}</span>
50
+ </p>
51
+ </div>
52
+ <div class="flex-shrink-0">
53
+ <span class="font-medium text-gray-400"
54
+ >{{ useRuntimeConfig().public.APP_URL }}/{{
55
+ b.xOrg
56
+ }}</span
57
+ >
51
58
  </div>
52
-
53
- </NuxtLink>
59
+ </NuxtLink>
60
+ </li>
61
+ </ul>
54
62
  </li>
55
- </ul> -->
63
+ </ul>
64
+
56
65
  </template>
57
- </card>
66
+ </card> -->
58
67
  </div>
68
+
69
+ </div>
59
70
  </template>
60
71
  <script setup lang="ts">
61
72
  /**
@@ -64,29 +75,29 @@
64
75
  * last change 2023-10-28
65
76
  * Author: Ks Tan
66
77
  */
67
- import _ from 'lodash'
68
- const profileapi = getAllApi().PROFILEApi;
69
- const alltenants = ref()
70
-
71
-
78
+ import _ from "lodash";
79
+ import TextPrimary from "../text/TextPrimary.vue";
80
+ const waiting = ref(true)
81
+ const alltenants = ref();
72
82
 
73
-
74
- const loadAllTenants = async () =>{
75
- const api = new profileapi(undefined,useRuntimeConfig().public.API_URL,)
76
- alltenants.value = (await api.getAllTenants()).data
77
- }
83
+ const loadAllTenants = async () => {
84
+ waiting.value=false
85
+ alltenants.value = (await getPorfileApi().getAllTenants()).data;
86
+ };
78
87
 
79
88
  // const props = defineProps<{
80
89
  // tenant:any
81
90
  // }>()
82
- const getBranchlist = (tenant:any)=>tenant.permissions
83
-
84
-
85
- const getOrglist = (tenant:any) => _.uniqBy(getBranchlist(tenant),'orgId')
86
- .map((item:any)=>({ orgId:item.orgId,orgCode:item.orgCode,orgName:item.orgName}) )
91
+ const getBranchlist = (tenant: any) => tenant.permissions;
87
92
 
93
+ const getOrglist = (tenant: any) =>
94
+ _.uniqBy(getBranchlist(tenant), "orgId").map((item: any) => ({
95
+ orgId: item.orgId,
96
+ orgCode: item.orgCode,
97
+ orgName: item.orgName,
98
+ }));
88
99
 
89
- onNuxtReady(()=>{
90
- loadAllTenants()
91
- })
92
- </script>
100
+ onNuxtReady(() => {
101
+ loadAllTenants();
102
+ });
103
+ </script>
@@ -15,6 +15,8 @@ export const getDayJs = ()=>useDayjs()
15
15
  export const lastDateOfMonth = (datestr:string) => useDayjs()(datestr).endOf('month').format('YYYY-MM-DD');
16
16
  export const today = () => useDayjs()().format('YYYY-MM-DD')
17
17
  export const dateToString = (date:Date) => useDayjs()(date).format('YYYY-MM-DD')
18
+ export const dateToTimeString = (date:Date) => useDayjs()(date).format('HH:mm:ss')
19
+ export const stringToDate = (datestr:string) => new Date(datestr)
18
20
  export const dateToDateTimeString = (date:Date)=> useDayjs()(date).format('YYYY-MM-DD HH:mm:ss')
19
21
  export const toLocalDate = (date:string | Date)=> useDayjs()(date).format(getDateFormat())
20
22
  export const getDateFormat = ():string=> 'DD-MM-YYYY'
@@ -1,10 +1,43 @@
1
1
  /**
2
2
  * This file was automatically generated by simpleapp generator. Every
3
3
  * MODIFICATION OVERRIDE BY GENERATEOR
4
- * last change 2023-10-28
4
+ * last change 2024-02-24
5
5
  * Author: Ks Tan
6
6
  */
7
7
  import {getAllDocuments} from '~/simpleapp/generate/commons/documents'
8
+ import { FormCrudEvent } from '~/types'
8
9
  export const getDocument = (docname:string) =>{
9
10
  return getAllDocuments().find((item)=>item.docName==docname) //?.docClass
10
- }
11
+ }
12
+
13
+ // (appuser: UserContext, filter: any) => Promise<void>;
14
+ export const onScreenAddDocument = <T>(docname:string,paras?:T,after?:(eventType:FormCrudEvent, data:T)=>Promise<void>)=>{
15
+ useNuxtApp().$event('ViewRecord',{
16
+ documentName: docname,
17
+ eventId:randomUUID(),
18
+ _id:'new',
19
+ paras:paras,
20
+ document: getDocument(docname)?.docClass,
21
+ viewer: getDocument(docname)?.viewer,
22
+ after: (eventType:FormCrudEvent, data: any) => {
23
+ //do nothing
24
+ if(after)after(eventType,data as T)
25
+ },
26
+ label:t(docname)
27
+
28
+ })
29
+ }
30
+ export const onScreenEditDocument = <T>(docname:string,_id:string,after?:(eventType:FormCrudEvent, data:T)=>Promise<void>)=>{
31
+ useNuxtApp().$event('ViewRecord',{
32
+ documentName: docname,
33
+ eventId:randomUUID(),
34
+ _id:_id,
35
+ document: getDocument(docname)?.docClass,
36
+ viewer: getDocument(docname)?.viewer,
37
+ after: async (eventType:FormCrudEvent, data: any) => {
38
+ //do nothing
39
+ if(after)after(eventType,data as T)
40
+ },
41
+ label:t(docname)
42
+ })
43
+ }
@@ -55,4 +55,8 @@ export const getAllApi=()=>{
55
55
  export const getWorkflowApi = () => {
56
56
  return new o.WorkflowApi(getAxiosConfig())
57
57
 
58
- }
58
+ }
59
+
60
+ export const getPorfileApi = () => {
61
+ return new o.PROFILEApi(getAxiosConfig())
62
+ }