@dt-frames/ui 1.0.10 → 1.0.13
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.
- package/es/components/curd/src/components/dialog.d.ts +28 -18
- package/es/components/curd/src/components/props.d.ts +4 -4
- package/es/components/curd/src/types/curd.type.d.ts +3 -2
- package/es/components/forms/src/components/formIcon.d.ts +11 -6
- package/es/components/forms/src/components/formInputUseDialog.d.ts +903 -0
- package/es/components/forms/src/types/form.type.d.ts +3 -1
- package/es/components/index.d.ts +1 -1
- package/es/components/modal/src/components/modal.d.ts +2 -2
- package/es/components/modal/src/components/modalFooter.d.ts +9 -4
- package/es/components/modal/src/index.d.ts +10 -5
- package/es/components/modal/src/props.d.ts +2 -1
- package/es/components/modal/src/types/modal.type.d.ts +5 -2
- package/es/components/source/src/hooks/useFetch.d.ts +2 -2
- package/es/components/source/src/hooks/useSource.d.ts +4 -4
- package/es/components/table/src/components/TableHeader.d.ts +2 -2
- package/es/components/table/src/components/editable/CellComponent.d.ts +14 -0
- package/es/components/table/src/components/editable/EditTableCell.d.ts +88 -0
- package/es/components/table/src/components/editable/componentMap.d.ts +4 -0
- package/es/components/table/src/components/editable/index.d.ts +9 -0
- package/es/components/table/src/hooks/useCustomRow.d.ts +19 -0
- package/es/components/table/src/hooks/useTable.d.ts +2 -2
- package/es/components/table/src/index.d.ts +27 -4
- package/es/components/table/src/props.d.ts +5 -1
- package/es/components/table/src/types/table.type.d.ts +18 -2
- package/es/components/upload/index.d.ts +1 -2
- package/es/components/upload/src/helper.d.ts +1 -0
- package/es/components/upload/src/index.d.ts +40 -13
- package/es/components/upload/src/props.d.ts +4 -1
- package/es/components/upload/src/upload.d.ts +45 -10
- package/es/index.js +589 -212
- package/es/style/components/forms/index.less +23 -0
- package/es/style/components/table/index.less +6 -0
- package/es/style/components/upload/index.less +3 -11
- package/es/style/theme/header/index.less +1 -1
- package/package.json +1 -1
- package/src/components/curd/src/components/dialog.vue +7 -5
- package/src/components/curd/src/components/props.ts +4 -4
- package/src/components/curd/src/hooks/useCurd.tsx +1 -1
- package/src/components/curd/src/types/curd.type.ts +3 -2
- package/src/components/forms/index.less +23 -0
- package/src/components/forms/src/componentMap.ts +2 -0
- package/src/components/forms/src/components/formInputUseDialog.vue +43 -0
- package/src/components/forms/src/components/formItem.vue +10 -10
- package/src/components/forms/src/types/form.type.ts +6 -0
- package/src/components/index.ts +1 -2
- package/src/components/modal/src/components/modalFooter.vue +10 -2
- package/src/components/modal/src/hooks/useModal.ts +12 -4
- package/src/components/modal/src/index.vue +19 -8
- package/src/components/modal/src/props.ts +3 -2
- package/src/components/modal/src/types/modal.type.ts +5 -2
- package/src/components/source/src/hooks/useFetch.ts +6 -4
- package/src/components/source/src/hooks/useSource.ts +5 -4
- package/src/components/table/index.less +6 -0
- package/src/components/table/src/components/TableHeader.vue +2 -2
- package/src/components/table/src/components/editable/CellComponent.ts +57 -0
- package/src/components/table/src/components/editable/EditTableCell.vue +181 -0
- package/src/components/table/src/components/editable/componentMap.ts +18 -0
- package/src/components/table/src/components/editable/index.ts +58 -0
- package/src/components/table/src/hooks/useColumns.ts +15 -8
- package/src/components/table/src/hooks/useCustomRow.ts +86 -0
- package/src/components/table/src/hooks/useRowSelection.ts +1 -1
- package/src/components/table/src/hooks/useTable.ts +1 -1
- package/src/components/table/src/hooks/useTableHeader.ts +1 -1
- package/src/components/table/src/index.vue +20 -3
- package/src/components/table/src/props.ts +4 -1
- package/src/components/table/src/types/table.type.ts +30 -3
- package/src/components/upload/index.less +3 -11
- package/src/components/upload/index.ts +0 -2
- package/src/components/upload/src/helper.ts +29 -1
- package/src/components/upload/src/props.ts +4 -1
- package/src/components/upload/src/upload.vue +88 -63
- package/src/theme/header/index.less +1 -1
- package/src/components/upload/src/index.vue +0 -38
|
@@ -80,5 +80,28 @@
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
.input-with-dialog{
|
|
84
|
+
position: relative;
|
|
85
|
+
span{
|
|
86
|
+
background: none;
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
i{
|
|
91
|
+
position: absolute;
|
|
92
|
+
right: 15px;
|
|
93
|
+
top: 0;
|
|
94
|
+
bottom: 0;
|
|
95
|
+
margin: auto;
|
|
96
|
+
line-height: 32px;
|
|
97
|
+
opacity: 0.3;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ant-input{
|
|
102
|
+
color: #333;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
83
106
|
|
|
84
107
|
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
.dt-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
|
|
7
|
-
.ant-table-wrapper{
|
|
8
|
-
flex: 1;
|
|
9
|
-
.ant-table-body{
|
|
10
|
-
border-bottom: 1px solid #e7e7e7;
|
|
11
|
-
}
|
|
1
|
+
.dt-file {
|
|
2
|
+
td.orange{
|
|
3
|
+
color: orange;
|
|
12
4
|
}
|
|
13
5
|
}
|
|
14
6
|
|
package/package.json
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
...{
|
|
19
19
|
onRegister: { type: Function },
|
|
20
20
|
formProps: {
|
|
21
|
-
type: Object as PropType<
|
|
21
|
+
type: Object as PropType<Partial<FormProps>>,
|
|
22
|
+
default: () => ({})
|
|
22
23
|
},
|
|
23
24
|
formsVal: {
|
|
24
25
|
type: Object as PropType<Ref<Recordable>>
|
|
@@ -26,9 +27,8 @@
|
|
|
26
27
|
}
|
|
27
28
|
} )
|
|
28
29
|
|
|
29
|
-
const [registerDialog] = useModal({
|
|
30
|
+
const [registerDialog, { closeModal }] = useModal({
|
|
30
31
|
...omit(toRaw(props), [
|
|
31
|
-
'actions',
|
|
32
32
|
'curd',
|
|
33
33
|
'formProps',
|
|
34
34
|
'formsVal',
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
const [ registerForm, { getFormValues, setFormValues } ] = useForm({
|
|
42
|
-
...( props.formProps
|
|
42
|
+
...( props.formProps || {} ),
|
|
43
43
|
schemas: props.schemas,
|
|
44
44
|
mode: 'dialog'
|
|
45
45
|
})
|
|
@@ -63,9 +63,11 @@
|
|
|
63
63
|
getFormValues()
|
|
64
64
|
)
|
|
65
65
|
|
|
66
|
-
obj.id
|
|
66
|
+
let pro = obj.id
|
|
67
67
|
? props.curd.onUpdate( obj )
|
|
68
68
|
: props.curd.onAdd( obj )
|
|
69
|
+
|
|
70
|
+
pro.then( rsp => closeModal() )
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormSchema, ButtonProps } from "../../../forms";
|
|
2
|
-
import { PropType } from "vue";
|
|
2
|
+
import { PropType, VNodeChild } from "vue";
|
|
3
3
|
|
|
4
4
|
export const basicProps = {
|
|
5
5
|
title: {
|
|
@@ -14,9 +14,9 @@ export const basicProps = {
|
|
|
14
14
|
type: Array as PropType<FormSchema[]>,
|
|
15
15
|
default: []
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
type: Array as PropType<ButtonProps[]>,
|
|
19
|
-
default:
|
|
17
|
+
footer: {
|
|
18
|
+
type: Array as PropType<VNodeChild | JSX.Element | ButtonProps[]>,
|
|
19
|
+
default: undefined
|
|
20
20
|
},
|
|
21
21
|
canFullscreen: {
|
|
22
22
|
type: Boolean,
|
|
@@ -7,7 +7,7 @@ import { CrudOptType } from "../types/curd.type";
|
|
|
7
7
|
|
|
8
8
|
export function useCurd(curdOpt: CrudOptType) {
|
|
9
9
|
const formsVal = ref<Recordable>()
|
|
10
|
-
const [register, {
|
|
10
|
+
const [register, { openModal }] = useModalOut()
|
|
11
11
|
const { confirm } = useMessage()
|
|
12
12
|
|
|
13
13
|
const DtCurdModal = () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Recordable } from "@dt-frames/core"
|
|
2
|
-
import {
|
|
2
|
+
import { VNodeChild } from "vue"
|
|
3
|
+
import { FormSchema, FormProps, ButtonProps } from "../../../forms/src/types/form.type"
|
|
3
4
|
|
|
4
5
|
export type CrudOptType = {
|
|
5
6
|
// 标题
|
|
@@ -9,7 +10,7 @@ export type CrudOptType = {
|
|
|
9
10
|
// 条目
|
|
10
11
|
schemas: FormSchema[]
|
|
11
12
|
// 操作栏
|
|
12
|
-
|
|
13
|
+
footer?: VNodeChild | JSX.Element | ButtonProps[]
|
|
13
14
|
// 是否显示全屏
|
|
14
15
|
showFullscreen?: boolean
|
|
15
16
|
// 是否显示关闭按钮
|
|
@@ -80,5 +80,28 @@
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
.input-with-dialog{
|
|
84
|
+
position: relative;
|
|
85
|
+
span{
|
|
86
|
+
background: none;
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
i{
|
|
91
|
+
position: absolute;
|
|
92
|
+
right: 15px;
|
|
93
|
+
top: 0;
|
|
94
|
+
bottom: 0;
|
|
95
|
+
margin: auto;
|
|
96
|
+
line-height: 32px;
|
|
97
|
+
opacity: 0.3;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ant-input{
|
|
102
|
+
color: #333;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
83
106
|
|
|
84
107
|
|
|
@@ -3,10 +3,12 @@ import { Component } from "vue"
|
|
|
3
3
|
import { Input, Select, Radio, Checkbox, AutoComplete, Cascader, DatePicker, InputNumber, Switch, TimePicker, TreeSelect, Slider, Rate, Divider } from 'ant-design-vue'
|
|
4
4
|
import RadioButtonGroup from './components/radioButton.vue'
|
|
5
5
|
import FormIcon from './components/formIcon.vue'
|
|
6
|
+
import formInputUseDialog from './components/formInputUseDialog.vue'
|
|
6
7
|
import { ComponentType } from "./types/form.type"
|
|
7
8
|
|
|
8
9
|
const components = {
|
|
9
10
|
Input,
|
|
11
|
+
InputWithDialog: formInputUseDialog,
|
|
10
12
|
InputTextArea: Input.TextArea,
|
|
11
13
|
InputSearch: Input.Search,
|
|
12
14
|
InputGroup: Input.Group,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="input-with-dialog">
|
|
3
|
+
<div @click="onClickInput">
|
|
4
|
+
<Input v-bind="bindProps"></Input>
|
|
5
|
+
</div>
|
|
6
|
+
<i class="i mdi:close-circle" @click="clearProps"></i>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import { computed, useAttrs } from 'vue'
|
|
12
|
+
import { Input } from 'ant-design-vue'
|
|
13
|
+
import { omit } from 'lodash-es'
|
|
14
|
+
import { error, isFunction } from '@dt-frames/core'
|
|
15
|
+
|
|
16
|
+
const attrs = useAttrs()
|
|
17
|
+
|
|
18
|
+
const bindProps = computed(() => {
|
|
19
|
+
return {
|
|
20
|
+
...omit(attrs, [
|
|
21
|
+
'formValues'
|
|
22
|
+
]),
|
|
23
|
+
disabled: true
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
function onClickInput() {
|
|
28
|
+
const { model, schema = { } } = attrs.formValues as any
|
|
29
|
+
|
|
30
|
+
if( !schema.openDialog || !isFunction(schema.openDialog) ) {
|
|
31
|
+
error('openDialog必须是函数')
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
schema.openDialog( model )
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function clearProps() {
|
|
39
|
+
const { model, schema = { } } = attrs.formValues as any
|
|
40
|
+
[...schema.linkProps, schema.name].forEach( it => model[it] = null )
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
</script>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
const { defaultValues, formModel, schema } = props;
|
|
33
33
|
|
|
34
34
|
return {
|
|
35
|
-
name: schema.name,
|
|
35
|
+
name: (schema as FormSchema).name,
|
|
36
36
|
model: formModel,
|
|
37
37
|
values: {
|
|
38
38
|
...defaultValues,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
|
|
45
45
|
// 是否显示当前条目
|
|
46
46
|
const getShow = computed(() => {
|
|
47
|
-
const { show = true, isAdvanced = true } = props.schema
|
|
47
|
+
const { show = true, isAdvanced = true } = props.schema as FormSchema
|
|
48
48
|
|
|
49
49
|
// 是否处于收缩状态
|
|
50
50
|
if( !isAdvanced ) {
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
// 设置表单绑定的特殊属性,如前后缀、禁用启用、日期格式等
|
|
62
62
|
const getComponentProps = computed(() => {
|
|
63
63
|
const { schema, formModel, formActionType } = props
|
|
64
|
-
let { props: cProps = {} } = schema
|
|
64
|
+
let { props: cProps = {} } = schema as FormSchema
|
|
65
65
|
|
|
66
66
|
if (isFunction(cProps)) {
|
|
67
67
|
cProps = cProps( { schema, formModel, formActionType } ) ?? {}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
if (schema.component === 'Divider') {
|
|
70
|
+
if ((schema as FormSchema).component === 'Divider') {
|
|
71
71
|
cProps = Object.assign({ type: 'horizontal' }, cProps, {
|
|
72
72
|
orientation: 'left',
|
|
73
73
|
plain: true,
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
* 支持的类型参照 ../types/form.type.ts 中 ComponentType
|
|
84
84
|
*/
|
|
85
85
|
function renderItem() {
|
|
86
|
-
const { component, props: cProps, slot, render, name, colon = appConf.ui.form.colon, suffix } = props.schema
|
|
86
|
+
const { component, props: cProps, slot, render, name, colon = appConf.ui.form.colon, suffix } = props.schema as FormSchema
|
|
87
87
|
|
|
88
88
|
// 计算label的属性
|
|
89
89
|
const { labelCol, wrapperCol } = unref( useLabelWidth( schema, formProps ) )
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
* 渲染Label标签元素
|
|
140
140
|
*/
|
|
141
141
|
function renderLabel() {
|
|
142
|
-
const { label, toolTip, subLabel, toolTipProps } = props.schema
|
|
142
|
+
const { label, toolTip, subLabel, toolTipProps } = props.schema as FormSchema
|
|
143
143
|
|
|
144
144
|
const renderLabel
|
|
145
145
|
= subLabel
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
*/
|
|
165
165
|
function renderFormItem() {
|
|
166
166
|
const { schema, formModel, formActionType } = props
|
|
167
|
-
const { component, name, changeEvent = 'change', valueField, renderComponent, props: sProps } = props.schema
|
|
167
|
+
const { component, name, changeEvent = 'change', valueField, renderComponent, props: sProps } = props.schema as FormSchema
|
|
168
168
|
|
|
169
169
|
const isCheck = component && ['Switch', 'Checkbox'].includes(component)
|
|
170
170
|
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
// 设置表单禁用启用
|
|
217
217
|
const getDisable = computed(() => {
|
|
218
218
|
const { disabled: gDisabled } = props.formProps as FormProps
|
|
219
|
-
const { dynamicDisabled } = props.schema
|
|
219
|
+
const { dynamicDisabled } = props.schema as FormSchema
|
|
220
220
|
const { disabled: itemDisabled = false } = unref( getComponentProps )
|
|
221
221
|
|
|
222
222
|
let disabled = !!gDisabled || itemDisabled
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
/**
|
|
262
262
|
* 所有属性汇总,包括方法、属性及值的绑定
|
|
263
263
|
*/
|
|
264
|
-
|
|
264
|
+
let compAttr: Recordable = {
|
|
265
265
|
...itemProps,
|
|
266
266
|
...bindValue,
|
|
267
267
|
...on
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
* 处理验证规则
|
|
289
289
|
*/
|
|
290
290
|
function handleRules(): ValidationRule[] {
|
|
291
|
-
const { rules: defaultRules = [], component, label, dynamicRules, required } = props.schema
|
|
291
|
+
const { rules: defaultRules = [], component, label, dynamicRules, required } = props.schema as FormSchema
|
|
292
292
|
|
|
293
293
|
// 1、如果为动态规则,则直接返回rules
|
|
294
294
|
if( isFunction( dynamicRules ) ) {
|
|
@@ -19,6 +19,7 @@ export type FormCallBackParams = {
|
|
|
19
19
|
// 组件的类型
|
|
20
20
|
export type ComponentType =
|
|
21
21
|
| 'Input'
|
|
22
|
+
| 'InputWithDialog'
|
|
22
23
|
| 'InputGroup'
|
|
23
24
|
| 'InputPassword'
|
|
24
25
|
| 'InputSearch'
|
|
@@ -236,6 +237,11 @@ export type FormSchema = {
|
|
|
236
237
|
|
|
237
238
|
// 是否处于收缩状态 仅在 search 模式下使用
|
|
238
239
|
isAdvanced?: boolean
|
|
240
|
+
|
|
241
|
+
// 只有当类型为inputWithDialog 是否才有此属性
|
|
242
|
+
openDialog?: (parms: Recordable) => void
|
|
243
|
+
// 点击删除按钮需要清空的属性
|
|
244
|
+
linkProps?: string[]
|
|
239
245
|
}
|
|
240
246
|
|
|
241
247
|
|
package/src/components/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { useSource } from './source'
|
|
|
8
8
|
import { useCurd } from './curd'
|
|
9
9
|
import { export2Excel } from './excel'
|
|
10
10
|
import { DtIframe } from './iframe'
|
|
11
|
-
import { DtUpload
|
|
11
|
+
import { DtUpload } from './upload'
|
|
12
12
|
import { DtTree } from './tree'
|
|
13
13
|
|
|
14
14
|
const dtComponents = [
|
|
@@ -18,7 +18,6 @@ const dtComponents = [
|
|
|
18
18
|
{ name: 'dt-modal', component: DtModal },
|
|
19
19
|
{ name: 'dt-form', component: DtForm },
|
|
20
20
|
{ name: 'dt-upload', component: DtUpload },
|
|
21
|
-
{ name: 'dt-upload-modal', component: DtUploadModal },
|
|
22
21
|
{ name: 'dt-tree', component: DtTree },
|
|
23
22
|
];
|
|
24
23
|
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
<slot name="appendFooter"></slot>
|
|
3
3
|
<FormButtons
|
|
4
4
|
:mode="'dialog'"
|
|
5
|
-
:buttonList="
|
|
5
|
+
:buttonList="buttonList"
|
|
6
6
|
@handle-method="handleMethod($event)"
|
|
7
7
|
></FormButtons>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
|
-
import {
|
|
11
|
+
import { PropType, computed } from 'vue'
|
|
12
|
+
import { FormButtons, ButtonProps } from '../../../forms'
|
|
12
13
|
|
|
13
14
|
const emits = defineEmits([
|
|
14
15
|
'handleSave',
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
])
|
|
17
18
|
|
|
18
19
|
const props = defineProps({
|
|
20
|
+
buttons: Object as PropType<ButtonProps[]>,
|
|
19
21
|
showSave: {
|
|
20
22
|
type: Boolean,
|
|
21
23
|
default: true
|
|
@@ -27,6 +29,12 @@
|
|
|
27
29
|
{ name: '关闭', preIcon: 'mdi:close', flag: 'CANCEL' },
|
|
28
30
|
]
|
|
29
31
|
|
|
32
|
+
const buttonList = computed(() => {
|
|
33
|
+
if( props.buttons && props.buttons.length ) return props.buttons
|
|
34
|
+
|
|
35
|
+
return buttonActions
|
|
36
|
+
})
|
|
37
|
+
|
|
30
38
|
// 处理按钮点击事件
|
|
31
39
|
function handleMethod(item: ButtonProps) {
|
|
32
40
|
switch( item.flag ) {
|
|
@@ -61,7 +61,13 @@ export function useModalOut(): UseModalReturnType{
|
|
|
61
61
|
getInstance()?.redoModalHeight?.()
|
|
62
62
|
},
|
|
63
63
|
|
|
64
|
-
openModal: (
|
|
64
|
+
openModal: (
|
|
65
|
+
params?: {
|
|
66
|
+
data?: Recordable,
|
|
67
|
+
afterClose?: ( data: Recordable ) => void
|
|
68
|
+
},
|
|
69
|
+
openOnSet = true
|
|
70
|
+
) => {
|
|
65
71
|
getInstance()?.setModalProps({
|
|
66
72
|
visible: true
|
|
67
73
|
})
|
|
@@ -155,10 +161,11 @@ export function useModal(props?: Partial<ModalProps>,callbackFn?: Function): Use
|
|
|
155
161
|
getVisible: computed(() => visibleData[~~unref(uidRef)]),
|
|
156
162
|
|
|
157
163
|
// 关闭弹框进行回调
|
|
158
|
-
closeModal: (rsp
|
|
159
|
-
cbTransfer[unref(uidRef)](rsp)
|
|
160
|
-
getInstance()?.setModalProps({ visible: false })
|
|
164
|
+
closeModal: (rsp?: Recordable) => {
|
|
165
|
+
if(cbTransfer[unref(uidRef)]) cbTransfer[unref(uidRef)](rsp)
|
|
166
|
+
getInstance()?.setModalProps({ visible: false })
|
|
161
167
|
},
|
|
168
|
+
|
|
162
169
|
openModal: <T = any>(visable = true, data?: T, openOnSet = true) => {
|
|
163
170
|
getInstance()?.setModalProps({
|
|
164
171
|
visible: visable
|
|
@@ -178,6 +185,7 @@ export function useModal(props?: Partial<ModalProps>,callbackFn?: Function): Use
|
|
|
178
185
|
dataTransfer[id] = toRaw(data);
|
|
179
186
|
}
|
|
180
187
|
},
|
|
188
|
+
|
|
181
189
|
setModalProps: (props: Partial<ModalProps>) => {
|
|
182
190
|
getInstance()?.setModalProps(props);
|
|
183
191
|
},
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
<template #title v-if="!$slots.title">
|
|
13
13
|
{{ getMergeProps.title }}
|
|
14
14
|
</template>
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
<template #footer v-if="!$slots.footer">
|
|
17
17
|
<!-- 默认的footer内容 -->
|
|
18
|
-
<ModalFooter :showSave="getBindValue.showSave" @handle-save="handleSave" @handle-cancel="handleCancel">
|
|
18
|
+
<ModalFooter :buttons="(propsRef.footer as any)" :showSave="getBindValue.showSave" @handle-save="handleSave" @handle-cancel="handleCancel">
|
|
19
19
|
<template #[item]="data" v-for="item in Object.keys($slots)">
|
|
20
20
|
<slot :name="item" v-bind="data || {}"></slot>
|
|
21
21
|
</template>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
:minHeight="getBindValue.minHeight"
|
|
33
33
|
:height="getWrapperHeight"
|
|
34
34
|
:visible="visibleRef"
|
|
35
|
-
:modalFooterHeight="
|
|
35
|
+
:modalFooterHeight="modalFooterHeight"
|
|
36
36
|
v-bind="omit(getBindValue.wrapperProps, 'visible', 'height', 'modalFooterHeight')"
|
|
37
37
|
@ext-height="handleExtHeight"
|
|
38
38
|
@height-change="handleHeightChange"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
import ModalFooter from './components/modalFooter.vue'
|
|
57
57
|
|
|
58
58
|
import CloseIcon from './components/close-icon.vue';
|
|
59
|
-
import { isFunction, deepMerge, ModalProps, ModalMethods } from '@dt-frames/core';
|
|
59
|
+
import { isFunction, deepMerge, ModalProps, ModalMethods, isArray } from '@dt-frames/core';
|
|
60
60
|
|
|
61
61
|
const visibleRef = ref(false);
|
|
62
62
|
const propsRef = ref<Partial<ModalProps>>();
|
|
@@ -66,6 +66,12 @@
|
|
|
66
66
|
const props = defineProps( basicProps );
|
|
67
67
|
const emits = defineEmits(['visible-change', 'height-change', 'cancel', 'save', 'register', 'update:visible'])
|
|
68
68
|
|
|
69
|
+
const modalFooterHeight = computed(() => {
|
|
70
|
+
if( isArray(props.footer) ) {
|
|
71
|
+
return (unref(propsRef).footer as any).length ? 0 : undefined
|
|
72
|
+
}
|
|
73
|
+
return props.footer !== undefined && !props.footer ? 0 : undefined
|
|
74
|
+
})
|
|
69
75
|
|
|
70
76
|
const modalMethods: ModalMethods = {
|
|
71
77
|
setModalProps,
|
|
@@ -97,10 +103,16 @@
|
|
|
97
103
|
...unref(getMergeProps),
|
|
98
104
|
...(unref(propsRef) as any),
|
|
99
105
|
visible: unref(visibleRef),
|
|
100
|
-
wrapClassName: unref(getWrapClassName)
|
|
106
|
+
wrapClassName: unref(getWrapClassName)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let omitArr = unref(fullScreenRef) ? ['height', 'title'] : ['title']
|
|
110
|
+
|
|
111
|
+
if( isArray( unref(propsRef).footer ) ) {
|
|
112
|
+
omitArr.push( 'footer' )
|
|
101
113
|
}
|
|
102
114
|
|
|
103
|
-
return omit(bindValue,
|
|
115
|
+
return omit(bindValue, omitArr);
|
|
104
116
|
});
|
|
105
117
|
|
|
106
118
|
const getWrapperHeight = computed(() => {
|
|
@@ -132,7 +144,6 @@
|
|
|
132
144
|
extHeightRef.value = height;
|
|
133
145
|
}
|
|
134
146
|
|
|
135
|
-
|
|
136
147
|
function setModalProps(props: Partial<ModalProps>) {
|
|
137
148
|
|
|
138
149
|
propsRef.value = deepMerge(unref(propsRef) || ({} as any), props);
|
|
@@ -148,7 +159,7 @@
|
|
|
148
159
|
// 弹框保存
|
|
149
160
|
function handleSave() {
|
|
150
161
|
emits('save')
|
|
151
|
-
handleCancel()
|
|
162
|
+
// handleCancel()
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
// 弹框关闭
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CSSProperties, PropType, VNodeChild } from "vue"
|
|
1
|
+
import { CSSProperties, PropType, VNodeChild } from "vue"
|
|
2
|
+
import { ButtonProps } from "../../forms"
|
|
2
3
|
|
|
3
4
|
// 支持设置的属性
|
|
4
5
|
const modalProps = {
|
|
@@ -33,7 +34,7 @@ export const basicProps = Object.assign({}, modalProps, {
|
|
|
33
34
|
keyboard : { type: Boolean, default: true },
|
|
34
35
|
maskStyle : Object as PropType<CSSProperties>,
|
|
35
36
|
|
|
36
|
-
footer : Object as PropType<VNodeChild | JSX.Element>,
|
|
37
|
+
footer : Object as PropType<VNodeChild | JSX.Element | ButtonProps[]>,
|
|
37
38
|
|
|
38
39
|
bodyStyle : Object as PropType<CSSProperties>,
|
|
39
40
|
|
|
@@ -8,14 +8,17 @@ export type ModalMethods = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface ReturnMethods extends ModalMethods{
|
|
11
|
-
openModal:
|
|
11
|
+
openModal: (data?: {
|
|
12
|
+
data?: Recordable,
|
|
13
|
+
afterClose?: ( data: Recordable ) => void
|
|
14
|
+
}, openOnSet?: boolean) => void
|
|
12
15
|
closeModal: () => void
|
|
13
16
|
getVisible?: ComputedRef<boolean>
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export interface ReturnInnerMethods extends ModalMethods {
|
|
17
20
|
openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void
|
|
18
|
-
closeModal: (rsp
|
|
21
|
+
closeModal: (rsp?: Recordable) => void
|
|
19
22
|
changeLoading: (loading: boolean) => void
|
|
20
23
|
getVisible?: ComputedRef<boolean>
|
|
21
24
|
redoModalHeight: () => void
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { http, isString, JsonResult, Recordable, ApiType } from "@dt-frames/core";
|
|
1
|
+
import { http, isString, JsonResult, Recordable, ApiType, isObject } from "@dt-frames/core";
|
|
2
2
|
|
|
3
3
|
export function useFetch(api: string | ApiType, baseUrl: string = '') {
|
|
4
4
|
/**
|
|
5
5
|
* 发送请求
|
|
6
6
|
* handleParams 记录返回的值
|
|
7
7
|
*/
|
|
8
|
-
function fetch(params:
|
|
9
|
-
let type, header = { }, model = {}
|
|
8
|
+
function fetch(params: any) {
|
|
9
|
+
let type, header = { }, model = {}
|
|
10
10
|
if(isString( api )) {
|
|
11
11
|
api = baseUrl + api
|
|
12
12
|
} else {
|
|
@@ -19,7 +19,9 @@ export function useFetch(api: string | ApiType, baseUrl: string = '') {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
return new Promise(( resolve, reject ) => {
|
|
22
|
-
|
|
22
|
+
let param = isObject(params) ? Object.assign({}, model, params) : params
|
|
23
|
+
|
|
24
|
+
http[type || 'post']( api, param, {
|
|
23
25
|
...header,
|
|
24
26
|
...{ onlyData: false }
|
|
25
27
|
}).then(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, reactive, toRaw, Ref } from 'vue'
|
|
2
|
-
import { isString, Recordable, useMessage } from "@dt-frames/core"
|
|
2
|
+
import { isFunction, isString, Recordable, useMessage } from "@dt-frames/core"
|
|
3
3
|
import { BaseDataType, SourceType } from "../types/source.type"
|
|
4
4
|
import { useFetch } from './useFetch'
|
|
5
5
|
import { TableParamsType } from '../types/table.type'
|
|
@@ -134,7 +134,7 @@ export function useSource(opt: SourceType) {
|
|
|
134
134
|
function onAdd(model: Recordable) {
|
|
135
135
|
const { fetch } = useFetch(add, baseUrl)
|
|
136
136
|
|
|
137
|
-
fetch(model).then( (rsp: any) => {
|
|
137
|
+
return fetch(model).then( (rsp: any) => {
|
|
138
138
|
message.success('新增成功')
|
|
139
139
|
search()
|
|
140
140
|
} )
|
|
@@ -151,7 +151,7 @@ export function useSource(opt: SourceType) {
|
|
|
151
151
|
// 修改
|
|
152
152
|
function onUpdate(model: Recordable) {
|
|
153
153
|
const { fetch } = useFetch(update, baseUrl)
|
|
154
|
-
fetch(model).then( (rsp: any) => {
|
|
154
|
+
return fetch(model).then( (rsp: any) => {
|
|
155
155
|
message.success('更新数据成功')
|
|
156
156
|
search()
|
|
157
157
|
} )
|
|
@@ -162,7 +162,8 @@ export function useSource(opt: SourceType) {
|
|
|
162
162
|
function onDeletes(ids: any) {
|
|
163
163
|
const { fetch } = useFetch(deletes, baseUrl)
|
|
164
164
|
|
|
165
|
-
fetch(ids).then( (rsp: any) => {
|
|
165
|
+
fetch(toRaw(ids)).then( (rsp: any) => {
|
|
166
|
+
message.success(`${ ids.length > 1 ? '批量' : '' } 删除成功!`)
|
|
166
167
|
search()
|
|
167
168
|
} )
|
|
168
169
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<slot name="toolbar"></slot>
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
|
-
<div class="dt-table-header-actions__right">
|
|
12
|
+
<div class="dt-table-header-actions__right" v-if="tableTools">
|
|
13
13
|
<TableSettinCom
|
|
14
14
|
:setting="tableTools"
|
|
15
15
|
@columns-change="handleColumnChange"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
props: {
|
|
44
44
|
tableTools: {
|
|
45
|
-
type: Object as PropType<TableSetting>
|
|
45
|
+
type: [Object, Boolean] as PropType<TableSetting | boolean>
|
|
46
46
|
},
|
|
47
47
|
toolbar: {
|
|
48
48
|
type: Array as PropType<BtnsType[]>,
|