vue2-client 1.16.22 → 1.16.24

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,119 +1,119 @@
1
- <template>
2
- <div class="table-container" :style="{ height: tableHeight }">
3
- <a-table
4
- :columns="processedColumns"
5
- :dataSource="tableData"
6
- :pagination="false"
7
- :bordered="false"
8
- :rowKey="rowKey"
9
- :scroll="{ y: scrollY }"
10
- />
11
- </div>
12
- </template>
13
-
14
- <script>
15
- import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
16
-
17
- export default {
18
- props: {
19
- queryParamsName: String,
20
- rowKey: {
21
- type: String,
22
- default: 'id'
23
- },
24
- parameter: {
25
- type: Object,
26
- default: () => ({})
27
- }
28
- },
29
- data () {
30
- return {
31
- columns: [],
32
- tableData: [],
33
- tableHeight: 'auto', // 默认高度
34
- scrollY: undefined
35
- }
36
- },
37
- watch: {
38
- queryParamsName: {
39
- immediate: true,
40
- handler (val) {
41
- val && this.init(val, this.parameter)
42
- }
43
- }
44
- },
45
- computed: {
46
- processedColumns () {
47
- return this.columns.map(column => ({
48
- ...column,
49
- customHeaderCell: column.headerStyle
50
- ? () => ({ style: column.headerStyle })
51
- : undefined
52
- }))
53
- }
54
- },
55
- methods: {
56
- init (config, parameterData) {
57
- getConfigByName(config, 'af-his', res => {
58
- // 从配置中获取表格高度
59
- this.tableHeight = res.tableHeight || '400px' // 默认400px
60
- this.columns = res.columns || []
61
-
62
- runLogic(res.logicName, parameterData, 'af-his').then(result => {
63
- this.tableData = result.map((item, index) => ({
64
- ...item,
65
- key: item[this.rowKey] || `row_${index}`
66
- }))
67
-
68
- this.$nextTick(() => {
69
- this.scrollY = this.tableHeight
70
- })
71
- })
72
- })
73
- }
74
- }
75
- }
76
- </script>
77
-
78
- <style scoped>
79
- /* 表格容器 */
80
- .table-container {
81
- overflow: hidden;
82
- display: flex;
83
- flex-direction: column;
84
- }
85
-
86
- /* 基础无边框样式 */
87
- /deep/ .ant-table {
88
- border: none !important;
89
- flex: 1;
90
- display: flex;
91
- flex-direction: column;
92
- }
93
-
94
- /deep/ .ant-table-content {
95
- flex: 1;
96
- display: flex;
97
- flex-direction: column;
98
- }
99
-
100
- /deep/ .ant-table-body {
101
- flex: 1;
102
- overflow-y: auto !important;
103
- }
104
-
105
- /deep/ .ant-table-tbody > tr > td {
106
- border-bottom: none !important;
107
- padding: 6px !important;
108
- }
109
-
110
- /deep/ .ant-table-thead > tr > th {
111
- border-bottom: none !important;
112
- background: none !important;
113
- padding: 8px 6px !important;
114
- position: sticky;
115
- top: 0;
116
- z-index: 1;
117
- background-color: white !important;
118
- }
119
- </style>
1
+ <template>
2
+ <div class="table-container" :style="{ height: tableHeight }">
3
+ <a-table
4
+ :columns="processedColumns"
5
+ :dataSource="tableData"
6
+ :pagination="false"
7
+ :bordered="false"
8
+ :rowKey="rowKey"
9
+ :scroll="{ y: scrollY }"
10
+ />
11
+ </div>
12
+ </template>
13
+
14
+ <script>
15
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
16
+
17
+ export default {
18
+ props: {
19
+ queryParamsName: String,
20
+ rowKey: {
21
+ type: String,
22
+ default: 'id'
23
+ },
24
+ parameter: {
25
+ type: Object,
26
+ default: () => ({})
27
+ }
28
+ },
29
+ data () {
30
+ return {
31
+ columns: [],
32
+ tableData: [],
33
+ tableHeight: 'auto', // 默认高度
34
+ scrollY: undefined
35
+ }
36
+ },
37
+ watch: {
38
+ queryParamsName: {
39
+ immediate: true,
40
+ handler (val) {
41
+ val && this.init(val, this.parameter)
42
+ }
43
+ }
44
+ },
45
+ computed: {
46
+ processedColumns () {
47
+ return this.columns.map(column => ({
48
+ ...column,
49
+ customHeaderCell: column.headerStyle
50
+ ? () => ({ style: column.headerStyle })
51
+ : undefined
52
+ }))
53
+ }
54
+ },
55
+ methods: {
56
+ init (config, parameterData) {
57
+ getConfigByName(config, 'af-his', res => {
58
+ // 从配置中获取表格高度
59
+ this.tableHeight = res.tableHeight || '400px' // 默认400px
60
+ this.columns = res.columns || []
61
+
62
+ runLogic(res.logicName, parameterData, 'af-his').then(result => {
63
+ this.tableData = result.map((item, index) => ({
64
+ ...item,
65
+ key: item[this.rowKey] || `row_${index}`
66
+ }))
67
+
68
+ this.$nextTick(() => {
69
+ this.scrollY = this.tableHeight
70
+ })
71
+ })
72
+ })
73
+ }
74
+ }
75
+ }
76
+ </script>
77
+
78
+ <style scoped>
79
+ /* 表格容器 */
80
+ .table-container {
81
+ overflow: hidden;
82
+ display: flex;
83
+ flex-direction: column;
84
+ }
85
+
86
+ /* 基础无边框样式 */
87
+ /deep/ .ant-table {
88
+ border: none !important;
89
+ flex: 1;
90
+ display: flex;
91
+ flex-direction: column;
92
+ }
93
+
94
+ /deep/ .ant-table-content {
95
+ flex: 1;
96
+ display: flex;
97
+ flex-direction: column;
98
+ }
99
+
100
+ /deep/ .ant-table-body {
101
+ flex: 1;
102
+ overflow-y: auto !important;
103
+ }
104
+
105
+ /deep/ .ant-table-tbody > tr > td {
106
+ border-bottom: none !important;
107
+ padding: 6px !important;
108
+ }
109
+
110
+ /deep/ .ant-table-thead > tr > th {
111
+ border-bottom: none !important;
112
+ background: none !important;
113
+ padding: 8px 6px !important;
114
+ position: sticky;
115
+ top: 0;
116
+ z-index: 1;
117
+ background-color: white !important;
118
+ }
119
+ </style>
@@ -1,153 +1,200 @@
1
- <template>
2
- <div class="x-time-select">
3
- <div class="time-select-container">
4
- <div v-if="type === 'range'" class="picker-wrapper">
5
- <a-range-picker
6
- :value="dateRange"
7
- :placeholder="['开始日期', '结束日期']"
8
- separator="至"
9
- :disabled="disabled"
10
- :allowClear="allowClear"
11
- :format="format"
12
- @change="handleDateChange"
13
- />
14
- </div>
15
- <div v-if="type === 'date'" class="picker-wrapper">
16
- <a-date-picker
17
- :value="dateRange"
18
- :format="format"
19
- :disabled="disabled"
20
- :allowClear="allowClear"
21
- @change="handleDateChange"
22
- />
23
- </div>
24
-
25
- </div>
26
- </div>
27
- </template>
28
-
29
- <script>
30
- import moment from 'moment'
31
- import { getConfigByName } from '@vue2-client/services/api/common'
32
-
33
- export default {
34
- name: 'XTimeSelect',
35
- inject: ['getComponentByName'],
36
- props: {
37
- queryParamsName: {
38
- type: String,
39
- default: null
40
- },
41
- value: {
42
- type: Array,
43
- default: () => []
44
- },
45
- disabled: {
46
- type: Boolean,
47
- default: false
48
- },
49
- allowClear: {
50
- type: Boolean,
51
- default: true
52
- },
53
- format: {
54
- type: String,
55
- default: 'YYYY/MM/DD'
56
- }
57
- },
58
- data () {
59
- return {
60
- dateRange: [],
61
- type: 'range'
62
- }
63
- },
64
- watch: {
65
- value: {
66
- handler (newVal) {
67
- this.convertValueToMoment(newVal)
68
- },
69
- immediate: true,
70
- deep: true
71
- },
72
- type () {
73
- this.convertValueToMoment(this.value)
74
- }
75
-
76
- },
77
- created () {
78
- this.getData(this.queryParamsName)
79
- },
80
- methods: {
81
- convertValueToMoment (value) {
82
- if (this.type === 'range' && value?.length === 2) {
83
- this.dateRange = [
84
- value[0] ? moment(value[0]) : null,
85
- value[1] ? moment(value[1]) : null
86
- ]
87
- } else if (this.type === 'date' && value?.length === 1) {
88
- this.dateRange = [value[0] ? moment(value[0]) : null]
89
- } else {
90
- this.dateRange = []
91
- }
92
- },
93
- handleDateChange (dates, dateStrings) {
94
- this.dateRange = dates
95
- console.warn(dateStrings)
96
- this.$emit('change', dateStrings)
97
- },
98
- async getData (data) {
99
- if (data) {
100
- getConfigByName(data, 'af-his', res => {
101
- if (['date', 'range'].includes(res.type)) {
102
- this.type = res.type
103
- }
104
- this.convertValueToMoment(this.value)
105
- })
106
- }
107
- }
108
- }
109
- }
110
- </script>
111
-
112
- <style scoped>
113
- .x-time-select {
114
- position: relative;
115
- width: 100%;
116
- box-sizing: border-box;
117
- display: block;
118
- }
119
-
120
- .time-select-container {
121
- display: flex;
122
- align-items: center;
123
- }
124
-
125
-
126
- .picker-wrapper {
127
- flex: 1;
128
- }
129
-
130
- .x-time-select :deep(.ant-picker-range),
131
- .x-time-select :deep(.ant-picker) {
132
- width: 100%;
133
- height: 30px;
134
- border-radius: 7px;
135
- background: #FFFFFF;
136
- border: 1px solid #E5E9F0;
137
- }
138
- .x-time-select :deep(.ant-calendar-picker) {
139
- width: 100%;
140
- display: block;
141
- }
142
- .x-time-select :deep(.ant-calendar-picker-input) {
143
- width: 100%;
144
- height: 30px;
145
- border-radius: 7px;
146
- background: #FFFFFF;
147
- border: 1px solid #E5E9F0;
148
- }
149
-
150
- .x-time-select :deep(.ant-input) {
151
- width: 100%;
152
- }
153
- </style>
1
+ <template>
2
+ <div class="x-time-select">
3
+ <div class="time-select-container">
4
+ <div v-if="type === 'range'" class="picker-wrapper">
5
+ <a-range-picker
6
+ :value="dateRange"
7
+ :placeholder="['开始日期', '结束日期']"
8
+ separator="至"
9
+ :disabled="disabled"
10
+ :allowClear="allowClear"
11
+ :format="format"
12
+ :showTime="showTime"
13
+ @change="handleDateChange"
14
+ />
15
+ </div>
16
+ <div v-if="type === 'date'" class="picker-wrapper">
17
+ <a-date-picker
18
+ :value="dateRange[0]"
19
+ :format="format"
20
+ :disabled="disabled"
21
+ :allowClear="allowClear"
22
+ :showTime="showTime"
23
+ @change="handleDateChange"
24
+ />
25
+ </div>
26
+
27
+ </div>
28
+ </div>
29
+ </template>
30
+
31
+ <script>
32
+ import moment from 'moment'
33
+ import { getConfigByName } from '@vue2-client/services/api/common'
34
+
35
+ export default {
36
+ name: 'XTimeSelect',
37
+ inject: ['getComponentByName'],
38
+ props: {
39
+ queryParamsName: {
40
+ type: String,
41
+ default: null
42
+ },
43
+ value: {
44
+ type: Array,
45
+ default: () => []
46
+ },
47
+ defaultTime: {
48
+ type: Array,
49
+ default: () => []
50
+ },
51
+ disabled: {
52
+ type: Boolean,
53
+ default: false
54
+ },
55
+ allowClear: {
56
+ type: Boolean,
57
+ default: true
58
+ },
59
+ format: {
60
+ type: String,
61
+ default: 'YYYY-MM-DD'
62
+ }
63
+ },
64
+ data () {
65
+ return {
66
+ dateRange: [],
67
+ type: 'range'
68
+ }
69
+ },
70
+ computed: {
71
+ showTime () {
72
+ // 根据format判断是否需要显示时间选择器
73
+ return this.format && (this.format.includes('HH:mm') || this.format.includes('hh:mm'))
74
+ }
75
+ },
76
+ watch: {
77
+ value: {
78
+ handler (newVal) {
79
+ this.convertValueToMoment(newVal)
80
+ },
81
+ immediate: true,
82
+ deep: true
83
+ },
84
+ defaultTime: {
85
+ handler (newVal) {
86
+ // 只有在没有传入value时才使用defaultTime
87
+ if (!this.value || this.value.length === 0) {
88
+ this.convertValueToMoment(newVal)
89
+ }
90
+ },
91
+ immediate: true,
92
+ deep: true
93
+ },
94
+ type () {
95
+ this.convertValueToMoment(this.value)
96
+ }
97
+
98
+ },
99
+ created () {
100
+ this.getData(this.queryParamsName)
101
+ },
102
+ methods: {
103
+ convertValueToMoment (value) {
104
+ // 如果没有传入value或value为空,则使用defaultTime
105
+ const timeToUse = (value && value.length > 0) ? value : this.defaultTime
106
+ if (this.type === 'range' && timeToUse?.length === 2) {
107
+ this.dateRange = [
108
+ timeToUse[0] ? moment(timeToUse[0]) : null,
109
+ timeToUse[1] ? moment(timeToUse[1]) : null
110
+ ]
111
+ } else if (this.type === 'date' && timeToUse?.length === 1) {
112
+ this.dateRange = [timeToUse[0] ? moment(timeToUse[0]) : null]
113
+ } else {
114
+ this.dateRange = []
115
+ }
116
+ },
117
+ handleDateChange (dates, dateStrings) {
118
+ if (this.type === 'date') {
119
+ // 单个日期选择器,dates是一个moment对象或null
120
+ this.dateRange = [dates]
121
+ } else {
122
+ // 范围选择器,dates是一个数组
123
+ this.dateRange = dates
124
+ }
125
+ this.$emit('change', dateStrings)
126
+ },
127
+ async getData (data) {
128
+ if (data) {
129
+ getConfigByName(data, 'af-his', res => {
130
+ if (['date', 'range'].includes(res.type)) {
131
+ this.type = res.type
132
+ }
133
+ // 处理format配置
134
+ if (res.format !== undefined) {
135
+ this.format = res.format
136
+ }
137
+ // 处理defaultTime配置
138
+ if (res.defaultTime !== undefined) {
139
+ if (res.defaultTime === 'now') {
140
+ // 如果配置为'now',设置当前时间
141
+ const now = moment().format(this.format)
142
+ if (this.type === 'range') {
143
+ this.defaultTime = [now, now]
144
+ } else if (this.type === 'date') {
145
+ this.defaultTime = [now]
146
+ }
147
+ } else if (Array.isArray(res.defaultTime)) {
148
+ // 如果配置为数组,直接使用
149
+ this.defaultTime = res.defaultTime
150
+ }
151
+ }
152
+ this.convertValueToMoment(this.value)
153
+ })
154
+ }
155
+ }
156
+ }
157
+ }
158
+ </script>
159
+
160
+ <style scoped>
161
+ .x-time-select {
162
+ position: relative;
163
+ width: 100%;
164
+ box-sizing: border-box;
165
+ display: block;
166
+ }
167
+
168
+ .time-select-container {
169
+ display: flex;
170
+ align-items: center;
171
+ }
172
+
173
+ .picker-wrapper {
174
+ flex: 1;
175
+ }
176
+
177
+ .x-time-select :deep(.ant-picker-range),
178
+ .x-time-select :deep(.ant-picker) {
179
+ width: 100%;
180
+ height: 30px;
181
+ border-radius: 7px;
182
+ background: #FFFFFF;
183
+ border: 1px solid #E5E9F0;
184
+ }
185
+ .x-time-select :deep(.ant-calendar-picker) {
186
+ width: 100%;
187
+ display: block;
188
+ }
189
+ .x-time-select :deep(.ant-calendar-picker-input) {
190
+ width: 100%;
191
+ height: 30px;
192
+ border-radius: 7px;
193
+ background: #FFFFFF;
194
+ border: 1px solid #E5E9F0;
195
+ }
196
+
197
+ .x-time-select :deep(.ant-input) {
198
+ width: 100%;
199
+ }
200
+ </style>