@dt-frames/ui 1.0.8 → 1.0.11

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.
Files changed (84) hide show
  1. package/es/components/curd/src/components/dialog.d.ts +1 -0
  2. package/es/components/forms/src/components/formIcon.d.ts +1 -1
  3. package/es/components/forms/src/types/form.type.d.ts +3 -3
  4. package/es/components/index.d.ts +3 -2
  5. package/es/components/modal/src/types/modal.type.d.ts +1 -1
  6. package/es/components/source/src/hooks/useFetch.d.ts +2 -2
  7. package/es/components/source/src/hooks/useSource.d.ts +8 -8
  8. package/es/components/source/src/types/table.type.d.ts +1 -1
  9. package/es/components/table/src/components/TableActions.d.ts +2 -2
  10. package/es/components/table/src/components/TableHeader.d.ts +2 -2
  11. package/es/components/table/src/components/editable/CellComponent.d.ts +14 -0
  12. package/es/components/table/src/components/editable/EditTableCell.d.ts +88 -0
  13. package/es/components/table/src/components/editable/componentMap.d.ts +4 -0
  14. package/es/components/table/src/components/editable/index.d.ts +9 -0
  15. package/es/components/table/src/components/setting/Download.d.ts +2 -2
  16. package/es/components/table/src/components/setting/Size.d.ts +2 -2
  17. package/es/components/table/src/index.d.ts +9 -5
  18. package/es/components/table/src/props.d.ts +1 -1
  19. package/es/components/table/src/types/table.type.d.ts +16 -0
  20. package/es/components/tree/index.d.ts +2 -0
  21. package/es/components/tree/src/hooks/useTree.d.ts +14 -0
  22. package/es/components/tree/src/props.d.ts +101 -0
  23. package/es/components/tree/src/type/tree.d.ts +85 -0
  24. package/es/components/tree/src/utils/tree.d.ts +5 -0
  25. package/es/components/upload/index.d.ts +3 -0
  26. package/es/components/upload/src/helper.d.ts +4 -0
  27. package/es/components/upload/src/index.d.ts +2788 -0
  28. package/es/components/upload/src/props.d.ts +40 -0
  29. package/es/components/upload/src/upload.d.ts +1634 -0
  30. package/es/index.js +2035 -308
  31. package/es/style/components/table/index.less +8 -2
  32. package/es/style/components/tree/index.less +41 -0
  33. package/es/style/components/upload/index.less +43 -0
  34. package/es/style/theme/header/index.less +1 -1
  35. package/es/theme/sider/components/basic-menu/basic-menu.d.ts +3 -3
  36. package/es/theme/tabs/components/TabContent.d.ts +2 -2
  37. package/package.json +2 -1
  38. package/src/components/curd/src/components/dialog.vue +4 -2
  39. package/src/components/curd/src/hooks/useCurd.tsx +1 -1
  40. package/src/components/forms/src/components/formItem.vue +15 -2
  41. package/src/components/forms/src/hooks/useFormEvents.ts +4 -3
  42. package/src/components/forms/src/hooks/useFormValues.ts +1 -1
  43. package/src/components/forms/src/types/form.type.ts +3 -3
  44. package/src/components/index.ts +9 -3
  45. package/src/components/modal/src/hooks/useModal.ts +5 -3
  46. package/src/components/modal/src/index.vue +2 -2
  47. package/src/components/modal/src/types/modal.type.ts +1 -1
  48. package/src/components/source/src/hooks/useFetch.ts +10 -6
  49. package/src/components/source/src/hooks/useSource.ts +32 -11
  50. package/src/components/source/src/types/table.type.ts +1 -1
  51. package/src/components/table/index.less +8 -2
  52. package/src/components/table/src/components/TableHeader.vue +2 -2
  53. package/src/components/table/src/components/TableRender.vue +1 -3
  54. package/src/components/table/src/components/editable/CellComponent.ts +57 -0
  55. package/src/components/table/src/components/editable/EditTableCell.vue +181 -0
  56. package/src/components/table/src/components/editable/componentMap.ts +18 -0
  57. package/src/components/table/src/components/editable/index.ts +58 -0
  58. package/src/components/table/src/hooks/useColumns.ts +15 -8
  59. package/src/components/table/src/hooks/useDataSource.ts +0 -13
  60. package/src/components/table/src/hooks/useTableHeader.ts +2 -2
  61. package/src/components/table/src/index.vue +6 -1
  62. package/src/components/table/src/props.ts +1 -1
  63. package/src/components/table/src/types/table.type.ts +28 -1
  64. package/src/components/tree/index.less +41 -0
  65. package/src/components/tree/index.ts +5 -0
  66. package/src/components/tree/src/components/TreeHeader.vue +97 -0
  67. package/src/components/tree/src/hooks/useTree.ts +239 -0
  68. package/src/components/tree/src/index.vue +392 -0
  69. package/src/components/tree/src/props.ts +133 -0
  70. package/src/components/tree/src/type/tree.ts +105 -0
  71. package/src/components/tree/src/utils/tree.ts +73 -0
  72. package/src/components/upload/index.less +43 -0
  73. package/src/components/upload/index.ts +7 -0
  74. package/src/components/upload/src/helper.ts +32 -0
  75. package/src/components/upload/src/index.vue +38 -0
  76. package/src/components/upload/src/props.ts +48 -0
  77. package/src/components/upload/src/upload.vue +166 -0
  78. package/src/theme/header/helper/menu-tree.ts +2 -2
  79. package/src/theme/header/index.less +1 -1
  80. package/src/theme/sider/helper/split-menu.ts +2 -2
  81. package/es/components/dialog/index.d.ts +0 -2
  82. package/es/components/dialog/src/hooks/useDialog.d.ts +0 -3
  83. package/src/components/dialog/index.ts +0 -5
  84. package/src/components/dialog/src/hooks/useDialog.ts +0 -85
@@ -77,8 +77,8 @@
77
77
  display: inline-block;
78
78
  vertical-align: middle;
79
79
  cursor: pointer;
80
- svg{
81
- display: flex;
80
+ i{
81
+ color: @primary-color;
82
82
  }
83
83
  }
84
84
 
@@ -171,3 +171,9 @@
171
171
  color: #333;
172
172
  }
173
173
  }
174
+
175
+ .edit-cell-rule-popover .ant-popover-inner-content{
176
+ padding: 4px 8px;
177
+ color: #ed6f6f;
178
+ border-radius: 2px;
179
+ }
@@ -0,0 +1,41 @@
1
+ .dt-tree{
2
+ display: flex;
3
+ flex-direction: column;
4
+ height: 100%;
5
+
6
+ .dt-tree-header{
7
+ .headerTitle{
8
+ text-align: center;
9
+ line-height: 32px;
10
+ font-weight: bolder;
11
+ }
12
+
13
+ .dt-tree-search{
14
+ display: flex;
15
+ padding: 0 0 10px 10px;
16
+ border-bottom: 1px solid #e7e7e7;
17
+ &>i{
18
+ width: 24px;
19
+ display: block;
20
+ text-align: center;
21
+ cursor: pointer;
22
+ }
23
+ .dt-tree-search-input{
24
+ flex: 1;
25
+ input{
26
+ font-size: 12px;
27
+ }
28
+ }
29
+ }
30
+ }
31
+
32
+ .ant-spin-nested-loading{
33
+ flex: 1;
34
+ overflow-y: auto;
35
+ padding: 10px 0;
36
+
37
+ .tree-title{
38
+ font-size: 12px;
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,43 @@
1
+ .dt-upload-wrap{
2
+ height: 350px;
3
+ padding: 10px 20px;
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
+ }
12
+ }
13
+ }
14
+
15
+ .file-header{
16
+ display: flex;
17
+ flex-direction: row;
18
+ justify-content: space-between;
19
+ &>div{
20
+ display: flex;
21
+ flex-direction: row;
22
+ button{
23
+ margin-right: 10px;
24
+ }
25
+ }
26
+ }
27
+
28
+ .file-type-tips{
29
+ line-height: 24px;
30
+ padding: 5px 10px;
31
+ font-size: 12px;
32
+ display: flex;
33
+ margin: 10px 0;
34
+ border: 1px dashed @primary-color;
35
+ cursor: inherit;
36
+ span i{
37
+ color: @primary-color;
38
+ margin-right: 7px;
39
+ }
40
+ i{
41
+ color: #666;
42
+ }
43
+ }
@@ -417,7 +417,7 @@
417
417
  margin-bottom: 20px;
418
418
 
419
419
  .select-item{
420
- width: 130px;
420
+ width: 130px !important;
421
421
  }
422
422
  }
423
423
 
@@ -125,7 +125,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
125
125
  'onUpdate:openKeys': import("vue").PropType<(keys: import("ant-design-vue/lib/_util/type").Key[]) => void>;
126
126
  'onUpdate:selectedKeys': import("vue").PropType<(keys: import("ant-design-vue/lib/_util/type").Key[]) => void>;
127
127
  'onUpdate:activeKey': import("vue").PropType<(key: import("ant-design-vue/lib/_util/type").Key) => void>;
128
- }>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "mode" | "theme" | "multiple" | "inlineCollapsed" | "disabledOverflow" | "forceSubMenuRender" | "selectable" | "inlineIndent" | "subMenuOpenDelay" | "subMenuCloseDelay" | "triggerSubMenuAction">;
128
+ }>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "mode" | "multiple" | "selectable" | "inlineCollapsed" | "disabledOverflow" | "forceSubMenuRender" | "theme" | "inlineIndent" | "subMenuOpenDelay" | "subMenuCloseDelay" | "triggerSubMenuAction">;
129
129
  $attrs: {
130
130
  [x: string]: unknown;
131
131
  };
@@ -742,10 +742,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
742
742
  }, {
743
743
  type: string;
744
744
  mode: MenuMode;
745
- theme: import("@dt-frames/core").Theme;
746
- isHorizontal: boolean;
747
745
  inlineCollapsed: boolean;
746
+ theme: import("@dt-frames/core").Theme;
748
747
  inlineIndent: number;
748
+ isHorizontal: boolean;
749
749
  collapsedShowTitle: boolean;
750
750
  mixSider: boolean;
751
751
  }>;
@@ -64,7 +64,7 @@ declare const _sfc_main: import("vue").DefineComponent<{}, {
64
64
  'onUpdate:visible': {
65
65
  type: import("vue").PropType<(val: boolean) => void>;
66
66
  };
67
- }>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "visible" | "overlayStyle" | "disabled" | "forceRender" | "arrow" | "minOverlayWidthMatchTrigger" | "destroyPopupOnHide">;
67
+ }>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "visible" | "overlayStyle" | "disabled" | "arrow" | "forceRender" | "minOverlayWidthMatchTrigger" | "destroyPopupOnHide">;
68
68
  $attrs: {
69
69
  [x: string]: unknown;
70
70
  };
@@ -501,7 +501,7 @@ declare const _sfc_main: import("vue").DefineComponent<{}, {
501
501
  'onUpdate:openKeys': import("vue").PropType<(keys: import("ant-design-vue/lib/_util/type").Key[]) => void>;
502
502
  'onUpdate:selectedKeys': import("vue").PropType<(keys: import("ant-design-vue/lib/_util/type").Key[]) => void>;
503
503
  'onUpdate:activeKey': import("vue").PropType<(key: import("ant-design-vue/lib/_util/type").Key) => void>;
504
- }>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "mode" | "theme" | "multiple" | "inlineCollapsed" | "disabledOverflow" | "forceSubMenuRender" | "selectable" | "inlineIndent" | "subMenuOpenDelay" | "subMenuCloseDelay" | "triggerSubMenuAction">;
504
+ }>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "mode" | "multiple" | "selectable" | "inlineCollapsed" | "disabledOverflow" | "forceSubMenuRender" | "theme" | "inlineIndent" | "subMenuOpenDelay" | "subMenuCloseDelay" | "triggerSubMenuAction">;
505
505
  $attrs: {
506
506
  [x: string]: unknown;
507
507
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dt-frames/ui",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "keywords": [
5
5
  "ui",
6
6
  "dt-ui"
@@ -32,6 +32,7 @@
32
32
  "@vueuse/core": "^7.5.2",
33
33
  "lodash-es": "^4.17.21",
34
34
  "sortablejs": "^1.15.0",
35
+ "spark-md5": "^3.0.2",
35
36
  "vue": "^3.2.25",
36
37
  "vue-router": "^4.0.12",
37
38
  "xlsx": "^0.18.5"
@@ -26,7 +26,7 @@
26
26
  }
27
27
  } )
28
28
 
29
- const [registerDialog] = useModal({
29
+ const [registerDialog, { closeModal }] = useModal({
30
30
  ...omit(toRaw(props), [
31
31
  'actions',
32
32
  'curd',
@@ -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>
@@ -16,7 +16,7 @@ export function useCurd(curdOpt: CrudOptType) {
16
16
  <DtModal
17
17
  { ...curdOpt }
18
18
  formsVal = { formsVal }
19
- formProps = { curdOpt.formProps }
19
+ formProps = { curdOpt.formProps as any }
20
20
  onRegister = { register }
21
21
  ></DtModal>
22
22
  </div>
@@ -2,7 +2,7 @@
2
2
  import { defineComponent, PropType, Ref, toRefs, unref, computed } from "vue"
3
3
  import { Col, Tooltip, Divider, Form, FormItem } from 'ant-design-vue'
4
4
  import { upperFirst, cloneDeep } from 'lodash-es'
5
- import { isFunction, isBoolean, isNull, Recordable, useSlots, useAppStore, isString, isArray } from "@dt-frames/core"
5
+ import { isFunction, isBoolean, isNull, Recordable, useSlots, useAppStore, isString, isArray, error } from "@dt-frames/core"
6
6
  import type { ValidationRule } from 'ant-design-vue/lib/form/Form'
7
7
 
8
8
  import { useLabelWidth } from "../hooks/useLabelWidth"
@@ -377,7 +377,7 @@
377
377
  * 3、否则通过属性去动态设置渲染条目
378
378
  */
379
379
  return () => {
380
- const { colSlot, renderCol, colProps } = props.schema
380
+ const { colSlot, renderCol, colProps, component, render } = props.schema as FormSchema
381
381
  const { colProps: gColProps, mode } = props.formProps as FormProps
382
382
 
383
383
  let _colProps = colProps
@@ -388,6 +388,19 @@
388
388
 
389
389
  const values = unref(getValues)
390
390
 
391
+ if( !component ) {
392
+ if( !render ) {
393
+ error('请配置render函数')
394
+ return
395
+ }
396
+
397
+ return (
398
+ <Col span={24}>
399
+ { render() }
400
+ </Col>
401
+ )
402
+ }
403
+
391
404
  const getContent = () => {
392
405
  return colSlot
393
406
  ? getSlot(slots, colSlot, values)
@@ -1,8 +1,9 @@
1
- import { dateFormat, deepMerge, isObject, isString, Recordable } from "@dt-frames/core"
1
+ import { deepMerge, isObject, isString, Recordable } from "@dt-frames/core"
2
2
  import { ComputedRef, nextTick, Ref, toRaw, unref } from "vue"
3
3
  import { uniqBy, cloneDeep } from 'lodash-es'
4
4
  import { FormActionType, FormProps, FormSchema } from "../types/form.type"
5
5
  import { handleInputNumberValue } from "./helper"
6
+ import dayjs from 'dayjs'
6
7
 
7
8
  /** =================================
8
9
  * 定义表单的事件
@@ -166,7 +167,7 @@ export function useFormEvents({
166
167
  if (Array.isArray(value)) {
167
168
  const arr: any[] = [];
168
169
  for (const ele of value) {
169
- arr.push(ele ? dateFormat(ele) : null);
170
+ arr.push(ele ? dayjs(ele) : null);
170
171
  }
171
172
  formModel[key] = arr;
172
173
  } else {
@@ -177,7 +178,7 @@ export function useFormEvents({
177
178
  if (typeof props === 'function') {
178
179
  _props = props({ formModel });
179
180
  }
180
- formModel[key] = value ? (_props?.valueFormat ? value : dateFormat(value)) : null
181
+ formModel[key] = value ? (_props?.valueFormat ? value : dayjs(value)) : null
181
182
  }
182
183
  } else {
183
184
  formModel[key] = value
@@ -57,7 +57,7 @@ export function useFormValues({
57
57
  * 设置初始化的formModel值
58
58
  */
59
59
  function initDefault() {
60
- const schema = unref( getSchema )
60
+ const schema = unref( getSchema ).filter(it => it.component )
61
61
  const obj: Recordable = {}
62
62
 
63
63
  schema.forEach( item => {
@@ -155,7 +155,7 @@ export type FormProps = {
155
155
  // 表单当个元素配置项
156
156
  export type FormSchema = {
157
157
  // 表单绑定的属性,亦作为name属性,用于后期自动化测试
158
- name: string | string[]
158
+ name?: string | string[]
159
159
  // 值发生变化触发的函数名
160
160
  changeEvent?: string
161
161
  // 绑定v-model的值
@@ -176,7 +176,7 @@ export type FormSchema = {
176
176
  // tooltip 配置信息
177
177
  toolTipProps?: ToolTipProps
178
178
  // 表单控件类型
179
- component: ComponentType
179
+ component?: ComponentType
180
180
  // 表单控件参数
181
181
  props?:
182
182
  | ((opt: {
@@ -205,7 +205,7 @@ export type FormSchema = {
205
205
  show?: boolean | ( ( parms: FormCallBackParams ) => boolean )
206
206
 
207
207
  // 渲染item
208
- render?: (parms: FormCallBackParams) => VNode | VNode[] | string
208
+ render?: (parms?: FormCallBackParams) => VNode | VNode[] | string
209
209
 
210
210
  // 渲染col
211
211
  renderCol?: (parms: FormCallBackParams) => VNode | VNode[] | string
@@ -8,7 +8,8 @@ import { useSource } from './source'
8
8
  import { useCurd } from './curd'
9
9
  import { export2Excel } from './excel'
10
10
  import { DtIframe } from './iframe'
11
- import { useDialog } from './dialog';
11
+ import { DtUpload, DtUploadModal } from './upload'
12
+ import { DtTree } from './tree'
12
13
 
13
14
  const dtComponents = [
14
15
  { name: 'dt-base-router', component: DtBaseRouter },
@@ -16,6 +17,9 @@ const dtComponents = [
16
17
  { name: 'dt-pick-icon', component: DtPickIcon },
17
18
  { name: 'dt-modal', component: DtModal },
18
19
  { name: 'dt-form', component: DtForm },
20
+ { name: 'dt-upload', component: DtUpload },
21
+ { name: 'dt-upload-modal', component: DtUploadModal },
22
+ { name: 'dt-tree', component: DtTree },
19
23
  ];
20
24
 
21
25
 
@@ -37,12 +41,14 @@ export {
37
41
  DtTable,
38
42
  FormButtons,
39
43
  DtIframe,
44
+ DtUpload,
45
+ DtUploadModal,
46
+ DtTree,
40
47
  useForm,
41
48
  useTable,
42
49
  useSource,
43
50
  useCurd,
44
51
  useModal,
45
52
  useModalOut,
46
- export2Excel,
47
- useDialog
53
+ export2Excel
48
54
  }
@@ -155,10 +155,11 @@ export function useModal(props?: Partial<ModalProps>,callbackFn?: Function): Use
155
155
  getVisible: computed(() => visibleData[~~unref(uidRef)]),
156
156
 
157
157
  // 关闭弹框进行回调
158
- closeModal: (rsp: Recordable) => {
159
- cbTransfer[unref(uidRef)](rsp)
160
- getInstance()?.setModalProps({ visible: false });
158
+ closeModal: (rsp?: Recordable) => {
159
+ if(cbTransfer[unref(uidRef)]) cbTransfer[unref(uidRef)](rsp)
160
+ getInstance()?.setModalProps({ visible: false })
161
161
  },
162
+
162
163
  openModal: <T = any>(visable = true, data?: T, openOnSet = true) => {
163
164
  getInstance()?.setModalProps({
164
165
  visible: visable
@@ -178,6 +179,7 @@ export function useModal(props?: Partial<ModalProps>,callbackFn?: Function): Use
178
179
  dataTransfer[id] = toRaw(data);
179
180
  }
180
181
  },
182
+
181
183
  setModalProps: (props: Partial<ModalProps>) => {
182
184
  getInstance()?.setModalProps(props);
183
185
  },
@@ -80,7 +80,7 @@
80
80
  }
81
81
 
82
82
  const { getWrapClassName, toggleFullScreen, fullScreenRef } = useFullScreen({
83
- wrapClassName: computed(() => (unref(propsRef) as any).wrapClassName),
83
+ wrapClassName: computed(() => (unref(propsRef) as any)?.wrapClassName),
84
84
  extHeightRef,
85
85
  modalWrapperRef
86
86
  });
@@ -148,7 +148,7 @@
148
148
  // 弹框保存
149
149
  function handleSave() {
150
150
  emits('save')
151
- handleCancel()
151
+ // handleCancel()
152
152
  }
153
153
 
154
154
  // 弹框关闭
@@ -15,7 +15,7 @@ export interface ReturnMethods extends ModalMethods{
15
15
 
16
16
  export interface ReturnInnerMethods extends ModalMethods {
17
17
  openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void
18
- closeModal: (rsp: Recordable) => void
18
+ closeModal: (rsp?: Recordable) => void
19
19
  changeLoading: (loading: boolean) => void
20
20
  getVisible?: ComputedRef<boolean>
21
21
  redoModalHeight: () => void
@@ -1,23 +1,27 @@
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: Recordable = { }) {
9
- let type = 'post', header = { }, model = {}, _api = ''
8
+ function fetch(params: any) {
9
+ let type, header = { }, model = {}
10
10
  if(isString( api )) {
11
- _api = baseUrl + api
11
+ api = baseUrl + api
12
12
  } else {
13
13
  type = api.type
14
- _api = baseUrl + api.api
14
+ if( api.api.indexOf(baseUrl) === -1 ) {
15
+ api.api = `${baseUrl}${api.api}`
16
+ }
15
17
  header = api.header
16
18
  model = api.model
17
19
  }
18
20
 
19
21
  return new Promise(( resolve, reject ) => {
20
- http[type]( _api, Object.assign({}, model, params), {
22
+ let param = isObject(params) ? Object.assign({}, model, params) : params
23
+
24
+ http[type || 'post']( api, param, {
21
25
  ...header,
22
26
  ...{ onlyData: false }
23
27
  }).then(
@@ -19,11 +19,22 @@ export function useSource(opt: SourceType) {
19
19
 
20
20
  const { message } = useMessage()
21
21
  const apiFul: Recordable = {}
22
+ const apiPath: Recordable = {}
22
23
 
23
24
  // 定义加载状态
24
25
  for( let it in api ) {
25
26
  loading['on' + it.slice(0,1).toUpperCase() + it.slice(1).toLowerCase()] = ref(false)
26
- apiFul[it] = baseUrl + (isString(api[it]) ? api[it] : (api[it] as ApiType).api)
27
+
28
+ if( isString(api[it] )) {
29
+ apiFul[it] = baseUrl + api[it]
30
+ } else {
31
+ apiFul[it] = {
32
+ ...(api[it] as ApiType),
33
+ api: baseUrl + (api[it] as ApiType).api
34
+ }
35
+ }
36
+
37
+ apiPath[it] = baseUrl + (isString(api[it]) ? api[it] : (api[it] as ApiType).api)
27
38
  }
28
39
 
29
40
  // 定义分页数据
@@ -48,7 +59,7 @@ export function useSource(opt: SourceType) {
48
59
  /**
49
60
  * 分页查询
50
61
  */
51
- function onSearch(model: Recordable) {
62
+ function onSearch(model: Recordable = {}) {
52
63
  baseData.entityDTO = { ...model }
53
64
  baseData.pageDTO.pageNo = 0
54
65
  loading.onSearch.value = true
@@ -71,15 +82,23 @@ export function useSource(opt: SourceType) {
71
82
  * 如果为首次 则为数据初始化 不需要查询
72
83
  */
73
84
  function onTableChange( params: TableParamsType, needSearch: boolean = true ) {
74
- const { pagination, showBtnLoading, sort = [], filter } = params
85
+ const { pagination, showBtnLoading, sort, filter } = params
75
86
 
76
87
  baseData.pageDTO = {
77
88
  pageNo: pagination.current - 1,
78
89
  pageSize: pagination.pageSize
79
90
  }
80
91
 
81
- // baseData.orderDTOs = sort.length ?? null
82
- baseData.orderDTOs = []
92
+ const { field, order } = sort
93
+
94
+ if( field ) {
95
+ baseData.orderDTOs = [{
96
+ propertyName: field,
97
+ dir: order === 'ascend' ? 'asc' : 'desc'
98
+ }]
99
+ } else {
100
+ baseData.orderDTOs = []
101
+ }
83
102
 
84
103
  if( needSearch ) search()
85
104
  }
@@ -115,7 +134,7 @@ export function useSource(opt: SourceType) {
115
134
  function onAdd(model: Recordable) {
116
135
  const { fetch } = useFetch(add, baseUrl)
117
136
 
118
- fetch(model).then( (rsp: any) => {
137
+ return fetch(model).then( (rsp: any) => {
119
138
  message.success('新增成功')
120
139
  search()
121
140
  } )
@@ -132,7 +151,7 @@ export function useSource(opt: SourceType) {
132
151
  // 修改
133
152
  function onUpdate(model: Recordable) {
134
153
  const { fetch } = useFetch(update, baseUrl)
135
- fetch(model).then( (rsp: any) => {
154
+ return fetch(model).then( (rsp: any) => {
136
155
  message.success('更新数据成功')
137
156
  search()
138
157
  } )
@@ -143,7 +162,8 @@ export function useSource(opt: SourceType) {
143
162
  function onDeletes(ids: any) {
144
163
  const { fetch } = useFetch(deletes, baseUrl)
145
164
 
146
- fetch(ids).then( (rsp: any) => {
165
+ fetch(toRaw(ids)).then( (rsp: any) => {
166
+ message.success(`${ ids.length > 1 ? '批量' : '' } 删除成功!`)
147
167
  search()
148
168
  } )
149
169
  }
@@ -176,8 +196,8 @@ export function useSource(opt: SourceType) {
176
196
  }
177
197
 
178
198
  return {
179
- api,
180
- apiFul,
199
+ api: apiFul,
200
+ apiPath,
181
201
  form,
182
202
  table,
183
203
  curd,
@@ -188,6 +208,7 @@ export function useSource(opt: SourceType) {
188
208
  onUpdate,
189
209
  onTableChange,
190
210
  onDownload,
191
- onSearch
211
+ onSearch,
212
+
192
213
  }
193
214
  }
@@ -3,6 +3,6 @@ import { Recordable } from "@dt-frames/core";
3
3
  export type TableParamsType = {
4
4
  pagination: any,
5
5
  showBtnLoading: boolean,
6
- sort: Recordable[],
6
+ sort: Recordable,
7
7
  filter: any
8
8
  }
@@ -77,8 +77,8 @@
77
77
  display: inline-block;
78
78
  vertical-align: middle;
79
79
  cursor: pointer;
80
- svg{
81
- display: flex;
80
+ i{
81
+ color: @primary-color;
82
82
  }
83
83
  }
84
84
 
@@ -171,3 +171,9 @@
171
171
  color: #333;
172
172
  }
173
173
  }
174
+
175
+ .edit-cell-rule-popover .ant-popover-inner-content{
176
+ padding: 4px 8px;
177
+ color: #ed6f6f;
178
+ border-radius: 2px;
179
+ }
@@ -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 as PropType<TableSetting | boolean>
46
46
  },
47
47
  toolbar: {
48
48
  type: Array as PropType<BtnsType[]>,
@@ -1,11 +1,9 @@
1
1
  <script lang="tsx">
2
2
  import { getDictValueByCode, isFunction, isObject, Recordable, formatNumber, isVnode } from '@dt-frames/core'
3
3
  import dayjs from 'dayjs'
4
- import { defineComponent, PropType, unref, ref, h, toRaw, render as render1, resolveComponent, resolveDynamicComponent, createVNode } from 'vue'
4
+ import { defineComponent, PropType, unref, ref, render as render1, createVNode, computed } from 'vue'
5
5
  import { BasicColumn } from '../types/table.type'
6
6
 
7
- import { Switch } from 'ant-design-vue'
8
-
9
7
  export default defineComponent({
10
8
  name: 'TableFormat',
11
9
  props: {
@@ -0,0 +1,57 @@
1
+ import { Recordable } from "@dt-frames/core"
2
+ import { Popover } from "ant-design-vue"
3
+ import { DefineComponent, FunctionalComponent, h, Ref } from "vue"
4
+ import { ComponentType } from "../../types/table.type"
5
+ import { componentMap } from "./componentMap"
6
+
7
+
8
+ type ComponentProps = {
9
+ component: ComponentType
10
+ rule: boolean
11
+ popoverVisible: boolean
12
+ ruleMessage: string
13
+ getPopupContainer?: any
14
+ }
15
+
16
+ export type EditRecordRow<T = Recordable> = Partial<
17
+ {
18
+ onEdit: (editable: boolean, submit?: boolean) => Promise<boolean>;
19
+ onValid: () => Promise<boolean>;
20
+ editable: boolean;
21
+ onCancel: Function;
22
+ onSubmit: Function;
23
+ submitCbs: Function[];
24
+ cancelCbs: Function[];
25
+ validCbs: Function[];
26
+ editValueRefs: Recordable<Ref>;
27
+ } & T
28
+ >
29
+
30
+ export const CellComponent: FunctionalComponent = ({
31
+ component = 'Input',
32
+ rule = true,
33
+ ruleMessage,
34
+ popoverVisible,
35
+ getPopupContainer
36
+ }: ComponentProps,
37
+ { attrs }
38
+ ) => {
39
+ const Comp = componentMap.get(component) as DefineComponent
40
+
41
+ const DefaultComp = h(Comp, attrs)
42
+
43
+ if (!rule) return DefaultComp
44
+
45
+ return h(
46
+ Popover,
47
+ {
48
+ overlayClassName: 'edit-cell-rule-popover',
49
+ visible: !!popoverVisible,
50
+ ...(getPopupContainer ? { getPopupContainer } : {}),
51
+ },
52
+ {
53
+ default: () => DefaultComp,
54
+ content: () => ruleMessage,
55
+ },
56
+ )
57
+ }