agilebuilder-ui 1.1.13-tmp4 → 1.1.13-tmp6

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.
@@ -1,146 +1,155 @@
1
- /** @jsxImportSource vue */
2
- import { defineComponent, ref, computed, watch, onMounted } from 'vue';
3
- import { ElCard, ElTag, ElButton, ElIcon, ElCheckbox } from 'element-plus';
4
- import { Bottom, Tickets } from '@element-plus/icons-vue';
5
- import Scrollbar from '../Scrollbar';
6
- // import { $emit, $off, $on } from '@/utils/gogocodeTransfer'
7
-
8
- export default defineComponent({
9
- name: 'CardView',
10
- components: {
11
- Scrollbar
12
- },
13
- props: {
14
- // 当前行数据
15
- form: {
16
- type: Object,
17
- default: () => {}
18
- },
19
- // 当前序号
20
- no: {
21
- type: [Number, String,undefined],
22
- default: () => undefined
23
- },
24
- // 是否选中
25
- isChecked: {
26
- type: Boolean,
27
- default: () => false
28
- },
29
- // 是否展示多选
30
- isCheck: {
31
- type: Boolean,
32
- default: () => false
33
- },
34
- // 是否展示子表按钮
35
- isSubTable: {
36
- type: Boolean,
37
- default: () => false
38
- },
39
- // 是否展示更多按钮
40
- isShowDetailsMore: {
41
- type: Boolean,
42
- default: () => false
43
- },
44
- setMaxHeight: {
45
- type: [Function, undefined],
46
- default: () => undefined
47
- },
48
- setHeight: {
49
- type: [Function, undefined],
50
- default: () => undefined
51
- },
52
- },
53
- setup(props, { attrs, emit, slots }) {
54
- console.log('*card-view.jsx**********************************************=>', props, attrs, slots)
55
- const isMore = ref(props.isShowDetailsMore)
56
-
57
- const scrollHeight = ref(undefined);
58
-
59
- const scrollbarRef = ref(null);
60
-
61
- // 点击了卡片事件
62
- const onChecked = () => {
63
- emit('checked')
64
- }
65
- const getSlotHtml = (slotFun) => {
66
- const datas = {...props, isMore: isMore.value }
67
- return ['function'].includes(typeof slotFun) ? slotFun(datas) : slotFun
68
- }
69
-
70
- const footerSlot = computed(() => {
71
- return getSlotHtml(slots.footerSlot).filter(item => item?.children) ?? []
72
- });
73
-
74
- const setMaxHeight = data => {
75
- if (props.setMaxHeight) return props.setMaxHeight(data)
76
- if (data?.windowHeight) {
77
- // const height = data?.windowHeight - 200
78
- if (data.windowHeight * 0.4 <= scrollHeight.value) return 300
79
- return scrollHeight.value && scrollHeight.value >= 300 ? scrollHeight : 300
80
- }
81
- }
82
-
83
- watch(() => props.isShowDetailsMore, (newValue) => {
84
- isMore.value = newValue
85
- });
86
-
87
- onMounted(() => {
88
- const scrollElement = scrollbarRef.value?.$el?.querySelector?.('.el-scrollbar__view');
89
- if (scrollElement) {
90
- scrollHeight.value = scrollElement.clientHeight
91
- }
92
- })
93
-
94
- // 点击事件
95
- const onClick = (event) => {
96
- onChecked()
97
- emit('rowClick', event)
98
- }
99
-
100
- // 双击事件
101
- const onDblclick = (event) => {
102
- emit('rowDblclick', event)
103
- }
104
-
105
-
106
- return () => (
107
- <ElCard key={`card_${props.form?.$rowDataGuId || `${props.form?.id}_${props.no}`}`} header-padding body-padding shadow="hover" class={{ 'yx-card-main': true, 'is-checked': props.isChecked}} v-slots={{
108
- header: () => (
109
- <div class="yx-flex-wrap" justify='space-between' align='center' onClick={onClick} onDblclick={onDblclick}>
110
- <div class="yx-flex-wrap" align='center' style={{gap: '10px' , flex: '1 1 auto',maxWidth: 'calc(100% - 80px)'}}>
111
- { props.no && <ElTag type="primary" size='small'>{props.no}</ElTag>}
112
- <div layout-title class='ellipsis'>{ getSlotHtml(slots.titleSlot) }</div>
113
- </div>
114
- <div class="yx-flex-wrap" align='center' style={{gap: '10px'}}>
115
- { getSlotHtml(slots.headerRightSlot) }
116
- { props.isSubTable && <ElButton text icon={<ElIcon><Tickets /></ElIcon>} onClick={event => {
117
- event.stopPropagation()
118
- emit('showSubTable', props.form)
119
- }} /> }
120
- { props.isCheck && <ElCheckbox model-value={props.isChecked} disabled={!!props.form.$editing} style="height: auto;" onClick={(event) => {
121
- event.stopPropagation()
122
- }} onChange={onChecked} /> }
123
- </div>
124
- </div>
125
- ),
126
- ...(footerSlot.value.length > 0 ? {
127
- footer: footerSlot.value
128
- } : {})
129
- }}>
130
- <div class="yx-flex-wrap" vertical style={{gap: '0', height: '100%'}} onClick={onClick} onDblclick={onDblclick}>
131
- <Scrollbar ref={scrollbarRef} scrollable-main max-height={!isMore.value ? '50vh' : '100%'} set-max-height={setMaxHeight} set-height={props.setHeight}>
132
- <div class='yx-card-body'>
133
- { getSlotHtml(slots.children) }
134
- </div>
135
- </Scrollbar>
136
- {
137
- props.isShowDetailsMore && (<ElButton text icon={<ElIcon>{!isMore.value ? <Top /> : <Bottom /> }</ElIcon>} onClick={(event) => {
138
- event.stopPropagation()
139
- isMore.value = !isMore.value
140
- }}>{ !isMore.value ? 'Less' : 'More'}</ElButton>)
141
- }
142
- </div>
143
- </ElCard>
144
- );
145
- }
146
- });
1
+ /** @jsxImportSource vue */
2
+ import { defineComponent, ref, computed, watch, onMounted } from 'vue';
3
+ import { ElCard, ElTag, ElButton, ElIcon, ElCheckbox } from 'element-plus';
4
+ import { Bottom, Tickets } from '@element-plus/icons-vue';
5
+ import Scrollbar from '../Scrollbar';
6
+ // import { $emit, $off, $on } from '@/utils/gogocodeTransfer'
7
+
8
+ export default defineComponent({
9
+ name: 'CardView',
10
+ components: {
11
+ Scrollbar
12
+ },
13
+ props: {
14
+ // 当前行数据
15
+ form: {
16
+ type: Object,
17
+ default: () => {}
18
+ },
19
+ // 当前序号
20
+ no: {
21
+ type: [Number, String,undefined],
22
+ default: () => undefined
23
+ },
24
+ // 是否选中
25
+ isChecked: {
26
+ type: Boolean,
27
+ default: () => false
28
+ },
29
+ // 是否展示多选
30
+ isCheck: {
31
+ type: Boolean,
32
+ default: () => false
33
+ },
34
+ // 是否展示子表按钮
35
+ isSubTable: {
36
+ type: Boolean,
37
+ default: () => false
38
+ },
39
+ // 是否展示更多按钮
40
+ isShowDetailsMore: {
41
+ type: Boolean,
42
+ default: () => false
43
+ },
44
+ // 是否收起
45
+ isMore: {
46
+ type: Boolean,
47
+ default: () => true
48
+ },
49
+ setMaxHeight: {
50
+ type: [Function, undefined],
51
+ default: () => undefined
52
+ },
53
+ setHeight: {
54
+ type: [Function, undefined],
55
+ default: () => undefined
56
+ },
57
+ },
58
+ setup(props, { attrs, emit, slots }) {
59
+ console.log('*card-view.jsx**********************************************=>', props, attrs, slots)
60
+ const isMore = ref(props.isShowDetailsMore)
61
+
62
+ const scrollHeight = ref(undefined);
63
+
64
+ const scrollbarRef = ref(null);
65
+
66
+ // 点击了卡片事件
67
+ const onChecked = () => {
68
+ emit('checked')
69
+ }
70
+ const getSlotHtml = (slotFun) => {
71
+ const datas = {...props, isMore: isMore.value }
72
+ return ['function'].includes(typeof slotFun) ? slotFun(datas) : slotFun
73
+ }
74
+
75
+ const footerSlot = computed(() => {
76
+ return getSlotHtml(slots.footerSlot).filter(item => item?.children) ?? []
77
+ });
78
+
79
+ const setMaxHeight = data => {
80
+ if (props.setMaxHeight) return props.setMaxHeight(data)
81
+ if (data?.windowHeight) {
82
+ // const height = data?.windowHeight - 200
83
+ if (data.windowHeight * 0.4 <= scrollHeight.value) return 300
84
+ return scrollHeight.value && scrollHeight.value >= 300 ? scrollHeight : 300
85
+ }
86
+ }
87
+
88
+ watch(() => props.isShowDetailsMore, (newValue) => {
89
+ isMore.value = newValue
90
+ });
91
+
92
+ watch(() => props.isMore, (newValue) => {
93
+ isMore.value = newValue
94
+ });
95
+
96
+ onMounted(() => {
97
+ const scrollElement = scrollbarRef.value?.$el?.querySelector?.('.el-scrollbar__view');
98
+ if (scrollElement) {
99
+ scrollHeight.value = scrollElement.clientHeight
100
+ }
101
+ })
102
+
103
+ // 点击事件
104
+ const onClick = (event) => {
105
+ onChecked()
106
+ emit('rowClick', event)
107
+ }
108
+
109
+ // 双击事件
110
+ const onDblclick = (event) => {
111
+ emit('rowDblclick', event)
112
+ }
113
+
114
+
115
+ return () => (
116
+ <ElCard key={`card_${props.form?.$rowDataGuId || `${props.form?.id}_${props.no}`}`} header-padding body-padding shadow="hover" class={{ 'yx-card-main': true, 'is-checked': props.isChecked}} v-slots={{
117
+ header: () => (
118
+ <div class="yx-flex-wrap" justify='space-between' align='center' onClick={onClick} onDblclick={onDblclick}>
119
+ <div class="yx-flex-wrap" align='center' style={{gap: '10px' , flex: '1 1 auto',maxWidth: 'calc(100% - 80px)'}}>
120
+ { props.no && <ElTag type="primary" size='small'>{props.no}</ElTag>}
121
+ <div layout-title class='ellipsis'>{ getSlotHtml(slots.titleSlot) }</div>
122
+ </div>
123
+ <div class="yx-flex-wrap" align='center' style={{gap: '10px'}}>
124
+ { getSlotHtml(slots.headerRightSlot) }
125
+ { props.isSubTable && <ElButton text icon={<ElIcon><Tickets /></ElIcon>} onClick={event => {
126
+ event.stopPropagation()
127
+ emit('showSubTable', props.form)
128
+ }} /> }
129
+ { props.isCheck && <ElCheckbox model-value={props.isChecked} disabled={!!props.form.$editing} style="height: auto;" onClick={(event) => {
130
+ event.stopPropagation()
131
+ }} onChange={onChecked} /> }
132
+ </div>
133
+ </div>
134
+ ),
135
+ ...(footerSlot.value.length > 0 ? {
136
+ footer: footerSlot.value
137
+ } : {})
138
+ }}>
139
+ <div class="yx-flex-wrap" vertical style={{gap: '0', height: '100%'}} onClick={onClick} onDblclick={onDblclick}>
140
+ <Scrollbar ref={scrollbarRef} scrollable-main max-height={!isMore.value ? '50vh' : '100%'} set-max-height={setMaxHeight} set-height={props.setHeight}>
141
+ <div class='yx-card-body'>
142
+ { getSlotHtml(slots.children) }
143
+ </div>
144
+ </Scrollbar>
145
+ {
146
+ props.isShowDetailsMore && (<ElButton text icon={<ElIcon>{!isMore.value ? <Top /> : <Bottom /> }</ElIcon>} onClick={(event) => {
147
+ event.stopPropagation()
148
+ isMore.value = !isMore.value
149
+ }}>{ !isMore.value ? 'Less' : 'More'}</ElButton>)
150
+ }
151
+ </div>
152
+ </ElCard>
153
+ );
154
+ }
155
+ });