@meadmin/cli 1.0.0
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/dist/commanders/crud.d.ts +2 -0
- package/dist/commanders/crud.js +543 -0
- package/dist/commanders/index.d.ts +2 -0
- package/dist/commanders/index.js +12 -0
- package/dist/commanders/sync.d.ts +2 -0
- package/dist/commanders/sync.js +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -0
- package/dist/utils/app.d.ts +5 -0
- package/dist/utils/app.js +12 -0
- package/dist/utils/db.d.ts +1 -0
- package/dist/utils/db.js +8 -0
- package/dist/utils/env.d.ts +1 -0
- package/dist/utils/env.js +20 -0
- package/dist/utils/file.d.ts +13 -0
- package/dist/utils/file.js +24 -0
- package/dist/utils/formatting.d.ts +68 -0
- package/dist/utils/formatting.js +103 -0
- package/dist/utils/log.d.ts +12 -0
- package/dist/utils/log.js +59 -0
- package/package.json +55 -0
- package/template/crud/server/controller/controller.ts.art +124 -0
- package/template/crud/server/dto/create.dto.ts.art +11 -0
- package/template/crud/server/dto/query.dto.ts.art +19 -0
- package/template/crud/server/dto/update.dto.ts.art +11 -0
- package/template/crud/server/service/service.ts.art +220 -0
- package/template/crud/view/api/api.ts.art +120 -0
- package/template/crud/view/api/class.ts.art +2 -0
- package/template/crud/view/api/searchTypes.ts.art +4 -0
- package/template/crud/view/api/type.ts.art +2 -0
- package/template/crud/view/api/valueDefault.ts.art +1 -0
- package/template/crud/view/api/valueType.ts.art +3 -0
- package/template/crud/view/views/components/addOrUp.vue.art +96 -0
- package/template/crud/view/views/components/addOrUpItem.vue.art +26 -0
- package/template/crud/view/views/components/info.vue.art +63 -0
- package/template/crud/view/views/components/rules.ts.art +5 -0
- package/template/crud/view/views/components/rulesList.ts.art +2 -0
- package/template/crud/view/views/dict.ts.art +11 -0
- package/template/crud/view/views/index.vue.art +83 -0
- package/template/crud/view/views/lang/en.json.art +4 -0
- package/template/crud/view/views/searchItem.vue.art +17 -0
- package/template/crud/view/views/tableColum.vue.art +19 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<page>
|
|
3
|
+
<template #searchForm>
|
|
4
|
+
<me-search-form :model="params" :default-all="true" class="search-form" @search="search(1)">
|
|
5
|
+
<% include('./searchItem.vue.art', {...entitySchema, entity:entity}) %>
|
|
6
|
+
</me-search-form>
|
|
7
|
+
</template>
|
|
8
|
+
<me-vxe-table
|
|
9
|
+
align="center"
|
|
10
|
+
border
|
|
11
|
+
:loading="loading"
|
|
12
|
+
:data="data?.list"
|
|
13
|
+
:pagination-options="{
|
|
14
|
+
currentPage: params.page,
|
|
15
|
+
pageSize: params.pageSize,
|
|
16
|
+
total: data?.total ?? 0,
|
|
17
|
+
layout: 'sizes, prev, pager, next, jumper, ->, total',
|
|
18
|
+
change: search,
|
|
19
|
+
}"
|
|
20
|
+
{{if adminPermission}}:onAdd="permission('{{replaceNames.roleName}}_add')?showAddOrUp:undefined"{{else}}:onAdd="showAddOrUp"{{/if}}
|
|
21
|
+
@refresh="search(1)"
|
|
22
|
+
>
|
|
23
|
+
<% include('./tableColum.vue.art', {...entitySchema, replaceNames, entity:entity, belongsToEntity:entity.belongsToEntity, belongsToManyEntity:entity.belongsToManyEntity}) %>{{if entitySchema.properties.createdAdmin}}
|
|
24
|
+
<vxe-column field="createdAdmin" :title="t('{{@ entitySchema.properties.createdAdmin.description}}')" :formatter="formatterObjectFn(obj=>`${obj.nickname}(${obj.username})`)"></vxe-column>
|
|
25
|
+
{{/if}}{{if entitySchema.properties.updatedAdmin}}<vxe-column field="updatedAdmin" :title="t('{{@ entitySchema.properties.updatedAdmin.description}}')" :formatter="formatterObjectFn(obj=>`${obj.nickname}(${obj.username})`)"></vxe-column>
|
|
26
|
+
{{/if}}<vxe-column{{if adminPermission}} v-if="permission(['{{replaceNames.roleName}}_add','{{replaceNames.roleName}}_edit','{{replaceNames.name}}_del'])"{{/if}} :title="t('操作')" fixed="right" min-width="150px">
|
|
27
|
+
<template #default="{ row }: { row: {{@ replaceNames.Name}}Info }">
|
|
28
|
+
<me-button{{if adminPermission}} v-if="permission('{{replaceNames.roleName}}_info')"{{/if}} @click="showInfo({{@ entity.pk.map(v=>`row.${v}`).join(', ')}})" link :title="t('详情')" >
|
|
29
|
+
<mel-icon-memo />
|
|
30
|
+
</me-button>
|
|
31
|
+
<me-button{{if adminPermission}} v-if="permission('{{replaceNames.roleName}}_edit')"{{/if}} @click="showAddOrUp({{@ entity.pk.map(v=>`row.${v}`).join(', ')}})" link :title="t('编辑')" >
|
|
32
|
+
<mel-icon-edit />
|
|
33
|
+
</me-button>
|
|
34
|
+
<el-popconfirm{{if adminPermission}} v-if="permission('{{replaceNames.roleName}}_del')"{{/if}} :title="t('确认删除?')" placement="left" @confirm="del({{@ entity.pk.map(v=>`row.${v}`).join(', ')}})" >
|
|
35
|
+
<template #reference>
|
|
36
|
+
<me-button :key="{{if entity.pk.length===1}}row.{{@ entity.pk[0]}}{{else}}`${<%- entity.pk.join('}__${')%>}`{{/if}}" :loading="delLoading && {{if entity.pk.length===1}}delId === row.{{@ entity.pk[0]}}{{else}}delKey=`${<%- entity.pk.join('}__${')%>}`{{/if}}" type="danger" link :title="t('删除')">
|
|
37
|
+
<mel-icon-delete />
|
|
38
|
+
</me-button>
|
|
39
|
+
</template>
|
|
40
|
+
</el-popconfirm>
|
|
41
|
+
</template>
|
|
42
|
+
</vxe-column>
|
|
43
|
+
</me-vxe-table>
|
|
44
|
+
</page>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script setup lang="ts" name="{{@ replaceNames.Name}}">
|
|
48
|
+
import { {{@ replaceNames.name}}ListApi, {{@ replaceNames.Name}}ListParam, del{{@ replaceNames.Name}}Api, {{@ replaceNames.Name}}Info } from '@/api/{{replaceNames.namePath}}';
|
|
49
|
+
import { useLocalesI18n } from '@/locales/i18n';
|
|
50
|
+
import Info from './components/info.vue';
|
|
51
|
+
import AddOrUp from './components/addOrUp.vue';
|
|
52
|
+
import { useActionModel } from '@/hooks/index.js';
|
|
53
|
+
import { formatterStr <% if( $imports.objectKeys(entitySchema.properties).some( k=>k.endsWith('At') ) ){ %>, formatterAt <%}%> ,formatterObjectFn,formatterArrFn, clearEmptyParam } from '@/utils/helper.js';
|
|
54
|
+
{{if adminPermission}}import { permission } from '@/utils/permission.js';{{/if}}
|
|
55
|
+
const {open:openInfo} = useActionModel(Info);
|
|
56
|
+
const {open:openAddOrUp} = useActionModel(AddOrUp);
|
|
57
|
+
let { t, loadRes } = useLocalesI18n({}, [(locale: string) => import(`./lang/${locale}.json`), '{{@ replaceNames.name}}']);
|
|
58
|
+
<% if( $imports.objectKeys(entitySchema.properties).some( k=>entitySchema.properties[k].enum || entitySchema.properties[k].description.includes(':') ) ){ %>import { getDict } from './dict.js';
|
|
59
|
+
const dict = getDict(t);
|
|
60
|
+
import { createformatterDictFn } from '@/utils/helper.js';
|
|
61
|
+
const formatterDict = createformatterDictFn<{{@ replaceNames.Name}}Info>(dict);<%}%>
|
|
62
|
+
const params = reactive(new {{@ replaceNames.Name}}ListParam());
|
|
63
|
+
const { loading, data, runAsync } = {{@ replaceNames.name}}ListApi();
|
|
64
|
+
const search = (page = params.page, pageSize = params.pageSize) => runAsync(Object.assign(params, { page, pageSize }));
|
|
65
|
+
const { runAsync: delRun, loading: delLoading } = del{{@ replaceNames.Name}}Api();
|
|
66
|
+
{{if entity.pk.length==1}}const delId = ref<string>();{{else}}const delKey = ref<string>();{{/if}}
|
|
67
|
+
const del = async ({{@ entity.pk.map(v=>`${v}:${entitySchema.properties[v].type}`).join(', ')}}) => {
|
|
68
|
+
{{if entity.pk.length==1}}delId.value = {{@ entity.pk[0]}};{{else}}delKey.value = `${<%- entity.pk.join('}__${')%>}`;{{/if}}
|
|
69
|
+
await delRun({{@ entity.pk.map(v=>`${v}`).join(', ')}});
|
|
70
|
+
await search(1);
|
|
71
|
+
};
|
|
72
|
+
const showInfo = ({{@ entity.pk.map(v=>`${v}?:${entitySchema.properties[v].type}`).join(', ')}}) => {
|
|
73
|
+
openInfo({<%- entity.pk.join(', ')%>});
|
|
74
|
+
};
|
|
75
|
+
const showAddOrUp = ({{@ entity.pk.map(v=>`${v}?:${entitySchema.properties[v].type}`).join(', ')}}) => {
|
|
76
|
+
openAddOrUp({<%- entity.pk.join(', ')%>, onSuccess:async ()=>{
|
|
77
|
+
await search(1);
|
|
78
|
+
}});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
await Promise.all([loadRes,search(1)]);
|
|
82
|
+
</script>
|
|
83
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{{each properties}}<% const keyInfo = $imports.getKeyInfo($value.description); %>{{if $index.endsWith('At')}}
|
|
2
|
+
<el-form-item :label="t('{{@ keyInfo.name}}')" prop="{{@ $index}}">
|
|
3
|
+
<el-date-picker v-model="params.start{{@ $imports.upFirstCase($index)}}" type="{{if $value.format === 'date-time'}}datetime{{else}}date{{/if}}" value-format="{{if $value.format === 'date-time'}}YYYY-MM-DD HH:mm:ss{{else}}YYYY-MM-DD{{/if}}" clearable /> -
|
|
4
|
+
<el-form-item prop="priceEnd">
|
|
5
|
+
<el-date-picker v-model="params.end{{@ $imports.upFirstCase($index)}}" type="{{if $value.format === 'date-time'}}datetime{{else}}date{{/if}}" value-format="{{if $value.format === 'date-time'}}YYYY-MM-DD HH:mm:ss{{else}}YYYY-MM-DD{{/if}}" clearable />
|
|
6
|
+
</el-form-item>
|
|
7
|
+
</el-form-item>{{else if ['number','string','integer'].includes($value.type)}}
|
|
8
|
+
<el-form-item :label="t('{{@ keyInfo.name}}')" prop="{{@ $index}}">
|
|
9
|
+
{{if $value.enum || keyInfo.dict}}<el-select v-model="params.{{@ $index}}" clearable >
|
|
10
|
+
<el-option v-for="val in dict.{{@ $index}}" :key="val.value" :value="val.value" :label="val.label" />
|
|
11
|
+
</el-select>
|
|
12
|
+
{{else if ['number','integer'].includes($value.type)}}
|
|
13
|
+
<el-input-number v-model="params.{{@ $index}}" clearable ></el-input-number>
|
|
14
|
+
{{else if $value.type === 'string'}}
|
|
15
|
+
<el-input v-model="params.{{@ $index}}" clearable ></el-input>
|
|
16
|
+
{{/if}}
|
|
17
|
+
</el-form-item>{{/if}}{{/each}}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{{each properties}}{{if ['createdAdmin','updatedAdmin'].includes($index)}} <% return; %>{{/if}}<% const keyInfo = $imports.getKeyInfo($value.description); %>
|
|
2
|
+
<vxe-column field="{{@ $index}}" :title="t('{{@ keyInfo.name}}')" {{if $value.$ref !== '#/components/schemas/FileInfo' && $value.items?.$ref !== '#/components/schemas/FileInfo'}}:formatter="<% if ($value.enum || $value.description.includes(':')){%>formatterDict
|
|
3
|
+
|
|
4
|
+
{{else if $index.endsWith('At')}}formatterAt
|
|
5
|
+
{{else if $value.type === 'array'}}{{if $value.items?.$ref }}<% const entityName = $value.items.$ref.replace('#/components/schemas/',''); %><% const valueEntity = belongsToManyEntity[$index] || belongsToEntity[$index]; %>
|
|
6
|
+
{{if valueEntity}}formatterArrFn('{{@ valueEntity.nameKeys?.[0] || valueEntity.pk[0]}}'){{else}}formatterArrFn{{/if}}
|
|
7
|
+
|
|
8
|
+
{{else}}formatterArrFn(){{/if}}
|
|
9
|
+
{{else if $value.$ref}}<% const entityName = $value.$ref.replace('#/components/schemas/',''); %><% const valueEntity = belongsToManyEntity[$index] || belongsToEntity[$index]; %>
|
|
10
|
+
{{if valueEntity}}formatterObjectFn('{{@ valueEntity.nameKeys?.[0] || valueEntity.pk[0]}}'){{else}}formatterStr{{/if}}
|
|
11
|
+
{{else}}formatterStr<%}%>"{{/if}}>{{if $value.$ref === '#/components/schemas/FileInfo'}}
|
|
12
|
+
<template #default="{ row }: { row: {{@ replaceNames.Name}}Info }">
|
|
13
|
+
<me-files-view :files="row.{{$index}}?[row.{{$index}}]:[]"></me-files-view>
|
|
14
|
+
</template>
|
|
15
|
+
{{else if $value.type==='array' && $value.items?.$ref === '#/components/schemas/FileInfo'}}
|
|
16
|
+
<template #default="{ row }: { row: {{@ replaceNames.Name}}Info }">
|
|
17
|
+
<me-files-view :files="row.{{$index}}"></me-files-view>
|
|
18
|
+
</template>
|
|
19
|
+
{{/if}}</vxe-column>{{/each}}
|