添加描述

This commit is contained in:
icssoa 2023-06-13 22:15:50 +08:00
parent 96a7aa0939
commit 1de5b338ae
3 changed files with 104 additions and 49 deletions

View File

@ -5,7 +5,7 @@
<cl-dialog v-model="visible" title="自定义列"> <cl-dialog v-model="visible" title="自定义列">
<div class="cl-column-custom__dialog"> <div class="cl-column-custom__dialog">
<div class="left"> <div class="left">
<draggable v-model="list"> <draggable item-key="prop" v-model="list">
<template #item="{ element: item }"> <template #item="{ element: item }">
<el-checkbox border v-model="item.checked">{{ <el-checkbox border v-model="item.checked">{{
item.label item.label
@ -34,6 +34,10 @@ import { isBoolean, orderBy } from "lodash-es";
export default defineComponent({ export default defineComponent({
name: "cl-column-custom", name: "cl-column-custom",
components: {
Draggable
},
props: { props: {
name: String, name: String,
columns: { columns: {
@ -43,10 +47,6 @@ export default defineComponent({
} }
}, },
components: {
Draggable
},
setup(props) { setup(props) {
// //
const visible = ref(false); const visible = ref(false);

View File

@ -1,4 +1,6 @@
import { Merge, ModuleConfig } from "/@/cool"; import { Merge, ModuleConfig } from "/@/cool";
// npm
import Crud from "@cool-vue/crud"; import Crud from "@cool-vue/crud";
import "@cool-vue/crud/dist/index.css"; import "@cool-vue/crud/dist/index.css";

View File

@ -15,6 +15,7 @@
<!-- 筛选 --> <!-- 筛选 -->
<cl-filter label="状态筛选"> <cl-filter label="状态筛选">
<!-- 配置props选择后会自动过滤列表 -->
<cl-select :options="options.status" prop="status" /> <cl-select :options="options.status" prop="status" />
</cl-filter> </cl-filter>
@ -85,14 +86,18 @@
<script lang="tsx" name="demo-crud" setup> <script lang="tsx" name="demo-crud" setup>
import { useCrud, useUpsert, useTable, useAdvSearch, setFocus } from "@cool-vue/crud"; import { useCrud, useUpsert, useTable, useAdvSearch, setFocus } from "@cool-vue/crud";
import { useDict } from "/$/dict"; import { useDict } from "/$/dict";
import FormBtn from "../components/form-btn.vue";
import { reactive } from "vue"; import { reactive } from "vue";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import { useCool } from "/@/cool";
import FormBtn from "../components/form-btn.vue";
//
const { service } = useCool();
// //
const { dict } = useDict(); const { dict } = useDict();
// // options
const options = reactive({ const options = reactive({
status: [ status: [
{ {
@ -110,13 +115,22 @@ const options = reactive({
// crud // crud
const Crud = useCrud( const Crud = useCrud(
{ {
// service.demo.goodsservice.base.sys.user
service: "test" service: "test"
}, },
(app) => { (app) => {
app.refresh(); // Crud
app.refresh({
// status: 1 //
});
} }
); );
//
function refresh(params?: any) {
Crud.value?.refresh(params);
}
// //
const Upsert = useUpsert({ const Upsert = useUpsert({
items: [ items: [
@ -153,13 +167,13 @@ const Upsert = useUpsert({
name: "el-input" name: "el-input"
} }
}, },
// mode //
() => { () => {
return { return {
label: "密码", label: "密码",
group: "base", group: "base",
prop: "password", prop: "password",
hidden: Upsert.value?.mode == "update", hidden: Upsert.value?.mode == "update", // mode
component: { component: {
name: "el-input", name: "el-input",
props: { props: {
@ -168,18 +182,34 @@ const Upsert = useUpsert({
} }
}; };
}, },
// {
() => { prop: "user",
return { group: "base",
label: "姓名", component: {
prop: "name", name: "cl-form-card",
required: true, props: {
group: "base", label: "用户信息(多层级展示)"
component: {
name: "el-input"
} }
}; },
children: [
{
label: "姓名",
prop: "name",
required: true,
component: {
name: "el-input"
}
},
{
label: "年龄",
prop: "age",
component: {
name: "el-input-number"
}
}
]
}, },
{ {
label: "省市区", label: "省市区",
prop: "pca", prop: "pca",
@ -188,14 +218,7 @@ const Upsert = useUpsert({
name: "cl-distpicker" name: "cl-distpicker"
} }
}, },
{
label: "年龄",
group: "base",
prop: "age",
component: {
name: "el-input-number"
}
},
{ {
label: "职业", label: "职业",
prop: "occupation", prop: "occupation",
@ -225,14 +248,20 @@ const Upsert = useUpsert({
// //
plugins: [ plugins: [
// //
setFocus("name") setFocus("account")
], ],
// //
onInfo(data, { next, done }) { onInfo(data, { next, done }) {
// info // info
// next({ // next({
// id: data.id // id: data.id,
// status: 1
// });
// 使
// service.demo.goods.info({ id: data.id }).then((res) => {
// done(res);
// }); // });
// //
@ -244,9 +273,28 @@ const Upsert = useUpsert({
console.log("onSubmit", data); console.log("onSubmit", data);
// update/add // update/add
next(data); next(data);
//
// service.demo.goods
// .update(data)
// .then(() => {
// ElMessage.success("");
// //
// refresh();
// //
// close();
// })
// .catch((err) => {
// ElMessage.error(err.message);
// //
// done();
// });
}, },
// // onInfo
onOpened(data) { onOpened(data) {
if (Upsert.value?.mode != "info") { if (Upsert.value?.mode != "info") {
ElMessage.success("编辑中"); ElMessage.success("编辑中");
@ -281,12 +329,11 @@ const Table = useTable({
type: "selection", type: "selection",
width: 60 width: 60
}, },
() => { //
return { {
label: "#", label: "#",
type: "expand", type: "expand",
prop: "detail" prop: "detail"
};
}, },
{ {
label: "姓名", label: "姓名",
@ -307,22 +354,28 @@ const Table = useTable({
label: "创建时间", label: "创建时间",
orderNum: 1, orderNum: 1,
prop: "createTime", prop: "createTime",
sortable: "desc" sortable: "desc" //
}, },
{ {
type: "op", type: "op",
width: 350, width: 350,
buttons: [ //
"info", // buttons: ["info", "edit", "delete"],
"edit", //
"delete", buttons({ scope }) {
{ return [
label: "自定义按钮", "info",
onClick({ scope }) { "edit",
ElMessage.success(scope.row.name + "正常"); "delete",
{
label: "自定义按钮",
hidden: !scope.row.status,
onClick({ scope }) {
ElMessage.success(scope.row.name + "正常");
}
} }
} ];
] }
} }
] ]
}); });