mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-12 13:42:50 +00:00
1
This commit is contained in:
parent
76a2ac05be
commit
b84785f5e6
2385
build/cool/eps.d.ts
vendored
2385
build/cool/eps.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
export const proxy = {
|
||||
"/dev/": {
|
||||
// target: "http://127.0.0.1:9009",
|
||||
target: "http://192.168.0.112:8001",
|
||||
target: "http://127.0.0.1:8001",
|
||||
// target: "http://192.168.0.112:8001",
|
||||
// target: "https://dev-admin.cool-js.cloud",
|
||||
changeOrigin: true,
|
||||
rewrite: (path: string) => path.replace(/^\/dev/, "")
|
||||
|
||||
@ -289,17 +289,31 @@ export function useCode() {
|
||||
});
|
||||
}
|
||||
|
||||
console.log(table.columns);
|
||||
// 筛选
|
||||
const clFilter = fieldEq
|
||||
.map((field) => {
|
||||
const item = table.columns.find((e) => e.prop == field);
|
||||
|
||||
return item
|
||||
? `<!-- 筛选${item.label} -->\n<cl-filter label="${
|
||||
item.label
|
||||
}">\n<cl-select options="${item.dict || []}" prop="${field}" />\n</cl-filter>`
|
||||
: "";
|
||||
if (item) {
|
||||
if (!item.dict) {
|
||||
item.dict = [];
|
||||
}
|
||||
|
||||
if (item.component?.name == "cl-switch") {
|
||||
item.dict = [
|
||||
{ label: "是", value: 1 },
|
||||
{ label: "否", value: 0 }
|
||||
];
|
||||
}
|
||||
|
||||
return `<!-- 筛选${item.label} -->\n<cl-filter label="${
|
||||
item.label
|
||||
}">\n<cl-select prop="${field}" :options='${toCodeString(
|
||||
item.dict
|
||||
)}' />\n</cl-filter>`;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
|
||||
@ -52,6 +52,8 @@ export function useMenu() {
|
||||
};
|
||||
});
|
||||
|
||||
console.log(data);
|
||||
|
||||
// 批量插入权限
|
||||
service.base.sys.menu.add(perms).then(() => {
|
||||
resolve(() => {
|
||||
|
||||
@ -387,6 +387,7 @@ const code = reactive({
|
||||
data: {
|
||||
router: "",
|
||||
prefix: "",
|
||||
fileName: "",
|
||||
columns: [] as EpsColumn[],
|
||||
fieldEq: [],
|
||||
keyWordLikeFields: [],
|
||||
@ -502,7 +503,7 @@ const code = reactive({
|
||||
|
||||
code.data.router = entityData.path.replace("/admin", "");
|
||||
code.data.prefix = entityData.path;
|
||||
code.data.columns = entityData.columns || [];
|
||||
code.data.fileName = entityData.fileName;
|
||||
|
||||
code.tips("Service 代码生成中");
|
||||
|
||||
@ -549,15 +550,17 @@ const code = reactive({
|
||||
|
||||
code.loading = false;
|
||||
|
||||
ElMessageBox.confirm("编码完成,是否创建文件?", "提示", {
|
||||
type: "success",
|
||||
confirmButtonText: "开始创建",
|
||||
cancelButtonText: "稍后再看"
|
||||
})
|
||||
.then(() => {
|
||||
createFile();
|
||||
if (isDev) {
|
||||
ElMessageBox.confirm("编码完成,是否创建文件?", "提示", {
|
||||
type: "success",
|
||||
confirmButtonText: "开始创建",
|
||||
cancelButtonText: "稍后再看"
|
||||
})
|
||||
.catch(() => null);
|
||||
.then(() => {
|
||||
createFile();
|
||||
})
|
||||
.catch(() => null);
|
||||
}
|
||||
},
|
||||
|
||||
// 创建vue
|
||||
@ -568,15 +571,24 @@ const code = reactive({
|
||||
|
||||
assign(code.data, form);
|
||||
|
||||
code.tips("Vue 代码生成中");
|
||||
code.tips("Vue 代码开始生成");
|
||||
|
||||
code.tips("AI 分析中");
|
||||
|
||||
await ai
|
||||
.invokeFlow("comm-parse-entity-column", {
|
||||
entity: code.getContent("node-entity")
|
||||
})
|
||||
.then((res) => {
|
||||
code.data.columns = res.columns || [];
|
||||
});
|
||||
|
||||
// ai分析
|
||||
await ai
|
||||
.invokeFlow("comm-parse-column", {
|
||||
entity: code.getContent("node-entity")
|
||||
})
|
||||
.then((res) => {
|
||||
(code.data.columns as EpsColumn[]).forEach((e) => {
|
||||
code.data.columns.forEach((e) => {
|
||||
e.component = res[e.propertyName];
|
||||
});
|
||||
});
|
||||
@ -692,6 +704,7 @@ const code = reactive({
|
||||
|
||||
// 保存
|
||||
save() {
|
||||
console.log(code);
|
||||
storage.set("ai-code.list", code.list);
|
||||
storage.set("ai-code.data", code.data);
|
||||
storage.set("ai-code.form", form);
|
||||
@ -796,7 +809,7 @@ const desc = reactive({
|
||||
// 创建文件
|
||||
function createFile() {
|
||||
if (!isDev) {
|
||||
return ElMessage.error("只有在开发环境下才有效");
|
||||
return ElMessage.error("只有在开发环境下才能创建文件");
|
||||
}
|
||||
|
||||
Form.value?.open({
|
||||
@ -859,13 +872,12 @@ function createFile() {
|
||||
submit(data, { close }) {
|
||||
code.tips("创建 Vue 文件中,过程可能会发生页面及服务重启");
|
||||
|
||||
close();
|
||||
|
||||
// 添加菜单、权限
|
||||
menu.create({
|
||||
code: code.getContent("vue"),
|
||||
...code.data,
|
||||
...data
|
||||
...data,
|
||||
name: form.entity
|
||||
})
|
||||
.then((create) => {
|
||||
// 创建后端文件
|
||||
@ -894,6 +906,8 @@ function createFile() {
|
||||
}, 3000);
|
||||
})
|
||||
.catch(() => null);
|
||||
|
||||
close();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -920,8 +934,14 @@ onMounted(() => {
|
||||
|
||||
if (step.value == "coding") {
|
||||
code.list = storage.get("ai-code.list") || [];
|
||||
code.data = storage.get("ai-code.data") || [];
|
||||
assign(form, storage.get("ai-code.form") || {});
|
||||
|
||||
if (storage.get("ai-code.data")) {
|
||||
code.data = storage.get("ai-code.data");
|
||||
}
|
||||
|
||||
if (storage.get("ai-code.form")) {
|
||||
assign(form, storage.get("ai-code.form"));
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
149
src/modules/user/views/info.vue
Normal file
149
src/modules/user/views/info.vue
Normal file
@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<cl-crud ref="Crud">
|
||||
<cl-row>
|
||||
<!-- 刷新按钮 -->
|
||||
<cl-refresh-btn />
|
||||
<!-- 新增按钮 -->
|
||||
<cl-add-btn />
|
||||
<!-- 删除按钮 -->
|
||||
<cl-multi-delete-btn />
|
||||
<!-- 筛选类型 -->
|
||||
<cl-filter label="类型">
|
||||
<cl-select
|
||||
prop="type"
|
||||
:options="[
|
||||
{ label: '普通', value: 0 },
|
||||
{ label: '会员', value: 1 },
|
||||
{ label: '超级会员', value: 2 }
|
||||
]"
|
||||
/>
|
||||
</cl-filter>
|
||||
<!-- 筛选状态 -->
|
||||
<cl-filter label="状态">
|
||||
<cl-select
|
||||
prop="status"
|
||||
:options="[
|
||||
{ label: '是', value: 1 },
|
||||
{ label: '否', value: 0 }
|
||||
]"
|
||||
/>
|
||||
</cl-filter>
|
||||
<cl-flex1 />
|
||||
<!-- 关键字搜索 -->
|
||||
<cl-search-key placeholder="搜索标题" />
|
||||
</cl-row>
|
||||
|
||||
<cl-row>
|
||||
<!-- 数据表格 -->
|
||||
<cl-table ref="Table" />
|
||||
</cl-row>
|
||||
|
||||
<cl-row>
|
||||
<cl-flex1 />
|
||||
<!-- 分页控件 -->
|
||||
<cl-pagination />
|
||||
</cl-row>
|
||||
|
||||
<!-- 新增、编辑 -->
|
||||
<cl-upsert ref="Upsert" />
|
||||
</cl-crud>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="user-info" setup>
|
||||
import { useCrud, useTable, useUpsert } from "@cool-vue/crud";
|
||||
import { useCool } from "/@/cool";
|
||||
|
||||
const { service } = useCool();
|
||||
|
||||
// cl-upsert
|
||||
const Upsert = useUpsert({
|
||||
items: [
|
||||
{
|
||||
label: "标题",
|
||||
prop: "title",
|
||||
component: { name: "el-input", props: { clearable: true } },
|
||||
required: true
|
||||
},
|
||||
{
|
||||
label: "折扣",
|
||||
prop: "discount",
|
||||
component: { name: "el-input", props: { clearable: true } },
|
||||
required: true
|
||||
},
|
||||
{
|
||||
label: "有效期",
|
||||
prop: "validity",
|
||||
component: { name: "el-input", props: { clearable: true } },
|
||||
required: true
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
flex: false,
|
||||
component: { name: "cl-switch" },
|
||||
required: true
|
||||
},
|
||||
{
|
||||
label: "类型",
|
||||
prop: "type",
|
||||
component: {
|
||||
name: "el-radio-group",
|
||||
options: [
|
||||
{ label: "普通", value: 0 },
|
||||
{ label: "会员", value: 1 },
|
||||
{ label: "超级会员", value: 2 }
|
||||
]
|
||||
},
|
||||
value: 0,
|
||||
required: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// cl-table
|
||||
const Table = useTable({
|
||||
columns: [
|
||||
{ type: "selection" },
|
||||
{ label: "标题", prop: "title", minWidth: 140 },
|
||||
{ label: "折扣", prop: "discount", minWidth: 140 },
|
||||
{ label: "有效期", prop: "validity", minWidth: 140 },
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
minWidth: 100,
|
||||
component: { name: "cl-switch" },
|
||||
dict: [
|
||||
{ label: "是", value: 1 },
|
||||
{ label: "否", value: 0 }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "类型",
|
||||
prop: "type",
|
||||
dict: [
|
||||
{ label: "普通", value: 0 },
|
||||
{ label: "会员", value: 1 },
|
||||
{ label: "超级会员", value: 2 }
|
||||
],
|
||||
dictColor: true,
|
||||
minWidth: 120
|
||||
},
|
||||
{ type: "op", buttons: ["edit", "delete"] }
|
||||
]
|
||||
});
|
||||
|
||||
// cl-crud
|
||||
const Crud = useCrud(
|
||||
{
|
||||
service: service.user.info
|
||||
},
|
||||
(app) => {
|
||||
app.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
// 刷新
|
||||
function refresh(params?: any) {
|
||||
Crud.value?.refresh(params);
|
||||
}
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user