添加描述

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

View File

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

View File

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