worsoft-frontend-codegen-local-mcp 0.1.2 → 0.1.3
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.
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
{{FORM_FIELDS}}
|
|
10
10
|
</el-row>
|
|
11
11
|
<el-row :gutter="24">
|
|
12
|
-
<sc-form-table v-model="form.{{CHILD_LIST_NAME}}" :addTemplate="childTemp" @delete="deleteChild" placeholder="
|
|
12
|
+
<sc-form-table v-model="form.{{CHILD_LIST_NAME}}" :addTemplate="childTemp" @delete="deleteChild" placeholder="暂无数据">
|
|
13
13
|
{{CHILD_TABLE_COLUMNS}}
|
|
14
14
|
</sc-form-table>
|
|
15
15
|
</el-row>
|
|
16
16
|
</el-form>
|
|
17
17
|
<div class="dialog-footer" style="text-align: right; margin-top: 18px;">
|
|
18
|
-
<el-button @click="handleBack"
|
|
19
|
-
<el-button type="primary" @click="onSubmit" :disabled="loading"
|
|
18
|
+
<el-button @click="handleBack">取消</el-button>
|
|
19
|
+
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
|
20
20
|
</div>
|
|
21
21
|
</el-card>
|
|
22
22
|
</div>
|
|
@@ -55,7 +55,7 @@ const get{{CLASS_NAME}}Data = async (id: string) => {
|
|
|
55
55
|
const { data } = await getObj({ {{PK_ATTR}}: id });
|
|
56
56
|
Object.assign(form, data[0] || {});
|
|
57
57
|
} catch (error) {
|
|
58
|
-
useMessage().error('
|
|
58
|
+
useMessage().error('获取数据失败');
|
|
59
59
|
} finally {
|
|
60
60
|
loading.value = false;
|
|
61
61
|
}
|
|
@@ -104,10 +104,10 @@ const onSubmit = async () => {
|
|
|
104
104
|
|
|
105
105
|
try {
|
|
106
106
|
form.{{PK_ATTR}} ? await putObj(form) : await addObj(form);
|
|
107
|
-
useMessage().success(form.{{PK_ATTR}} ? '
|
|
107
|
+
useMessage().success(form.{{PK_ATTR}} ? '修改成功' : '添加成功');
|
|
108
108
|
closeCurrentPage();
|
|
109
109
|
} catch (err: any) {
|
|
110
|
-
useMessage().error(err.msg || '
|
|
110
|
+
useMessage().error(err.msg || '提交失败');
|
|
111
111
|
} finally {
|
|
112
112
|
loading.value = false;
|
|
113
113
|
}
|
|
@@ -117,9 +117,9 @@ const deleteChild = async (obj: { {{CHILD_PK_ATTR}}: string }) => {
|
|
|
117
117
|
if (obj.{{CHILD_PK_ATTR}}) {
|
|
118
118
|
try {
|
|
119
119
|
await delChildObj([obj.{{CHILD_PK_ATTR}}]);
|
|
120
|
-
useMessage().success('
|
|
120
|
+
useMessage().success('删除成功');
|
|
121
121
|
} catch (err: any) {
|
|
122
|
-
useMessage().error(err.msg || '
|
|
122
|
+
useMessage().error(err.msg || '删除失败');
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
};
|
package/mcp_server.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
7
|
const SERVER_NAME = 'worsoft-codegen-local';
|
|
8
|
-
const SERVER_VERSION = '0.1.
|
|
8
|
+
const SERVER_VERSION = '0.1.3';
|
|
9
9
|
const PROTOCOL_VERSION = '2024-11-05';
|
|
10
10
|
const TOOL_NAME = 'worsoft_codegen_local_generate_frontend';
|
|
11
11
|
const TEMPLATE_LIBRARY_ROOT = path.resolve(__dirname, '..', 'template');
|
|
@@ -634,8 +634,9 @@ function buildModel(safeArgs) {
|
|
|
634
634
|
const fields = normalizeFields(mainParsed);
|
|
635
635
|
const visibleFields = fields.filter((field) => field.fieldName !== mainParsed.pkField.fieldName && !field.isAudit);
|
|
636
636
|
const gridFields = visibleFields.slice(0, 8);
|
|
637
|
-
const dictTypes = [...new Set(visibleFields.map((field) => field.dictType).filter(Boolean))];
|
|
638
637
|
const child = buildChildModel(sourceDocument, safeArgs, mainParsed);
|
|
638
|
+
const childDictTypes = child ? child.visibleFields.map((field) => field.dictType).filter(Boolean) : [];
|
|
639
|
+
const dictTypes = [...new Set([...visibleFields.map((field) => field.dictType).filter(Boolean), ...childDictTypes])];
|
|
639
640
|
|
|
640
641
|
return {
|
|
641
642
|
sourceFile: sourceDocument.path,
|
|
@@ -739,11 +740,26 @@ function renderTableColumn(field) {
|
|
|
739
740
|
|
|
740
741
|
function renderChildTableColumn(field, childListName) {
|
|
741
742
|
const label = field.comment.replace(/'/g, "\\'");
|
|
743
|
+
const rules = field.notNull ? ` :rules="[{ required: true, trigger: 'blur' }]"` : '';
|
|
744
|
+
|
|
745
|
+
let control = ` <el-input v-model="row.${field.attrName}" />`;
|
|
746
|
+
if (field.formType === 'select' && field.dictType) {
|
|
747
|
+
control = [
|
|
748
|
+
` <el-select v-model="row.${field.attrName}" placeholder="请选择${label}" style="width: 100%">`,
|
|
749
|
+
` <el-option v-for="item in ${field.dictType}" :key="item.value" :label="item.label" :value="Number(item.value)" />`,
|
|
750
|
+
' </el-select>',
|
|
751
|
+
].join('\n');
|
|
752
|
+
} else if (field.formType === 'number') {
|
|
753
|
+
const max = field.comment.includes('%') || field.comment.includes('比例') ? ' :max="100"' : '';
|
|
754
|
+
const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
|
|
755
|
+
control = ` <el-input-number v-model="row.${field.attrName}" :min="0"${max}${precision} style="width: 100%" />`;
|
|
756
|
+
}
|
|
757
|
+
|
|
742
758
|
return [
|
|
743
759
|
` <el-table-column label="${label}" prop="${field.attrName}">`,
|
|
744
760
|
' <template #default="{ row, $index }">',
|
|
745
|
-
` <el-form-item :prop="\`${childListName}.\${$index}.${field.attrName}\`"
|
|
746
|
-
|
|
761
|
+
` <el-form-item :prop="\`${childListName}.\${$index}.${field.attrName}\`"${rules}>`,
|
|
762
|
+
control,
|
|
747
763
|
' </el-form-item>',
|
|
748
764
|
' </template>',
|
|
749
765
|
' </el-table-column>',
|
package/package.json
CHANGED