新功能: tableSelector组件

This commit is contained in:
猿小天
2023-02-17 00:51:54 +08:00
parent 4d832b5e68
commit e34445d655
3 changed files with 145 additions and 24 deletions

View File

@@ -2,7 +2,8 @@ import * as api from "./api";
import {dict, compute, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions,} from "@fast-crud/fast-crud";
import {request} from "/@/utils/service";
import {dictionary} from "/@/utils/dictionary";
import tableSelector from "/@/components/tableSelector/index.vue"
import {shallowRef} from "vue";
interface CreateCrudOptionsTypes {
crudOptions: CrudOptions;
}
@@ -30,22 +31,7 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos
delRequest
},
columns: {
_index: {
title: '序号',
form: {show: false},
column: {
//type: 'index',
align: 'center',
width: '70px',
columnSetDisabled: true, //禁止在列设置中选择
formatter: (context) => {
//计算序号,你可以自定义计算规则,此处为翻页累加
let index = context.index ?? 1;
let pagination = crudExpose.crudBinding.value.pagination;
return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1;
},
},
},
id: {
title: 'id',
form: {
@@ -117,7 +103,6 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos
disabled: true
},
width: 130,
type: 'table-selector',
disabled: true,
dict: dict({
cache: false,
@@ -126,6 +111,24 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos
label: 'name', // 数据字典中label字段的属性名
}),
form: {
component:{
name: shallowRef(tableSelector),
vModel: "modelValue",
label:'name',
value:'date',
tableConfig:{
isMultiple:true,
data:[{
date: '2016-05-03',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
},{
date: '2016-05-01',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
},]
}
},
show:compute(({ form })=>{
return form.target_type === 0
}),
@@ -232,7 +235,7 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos
config: {},
uploader: {
type: "form",
buildUrl(res) {
buildUrl(res:any) {
return res.url;
}
}