vue2-client 1.16.22 → 1.16.23

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,192 @@
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
+ @change="handleDateChange"
13
+ />
14
+ </div>
15
+ <div v-if="type === 'date'" class="picker-wrapper">
16
+ <a-date-picker
17
+ :value="dateRange[0]"
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
+ defaultTime: {
46
+ type: Array,
47
+ default: () => []
48
+ },
49
+ disabled: {
50
+ type: Boolean,
51
+ default: false
52
+ },
53
+ allowClear: {
54
+ type: Boolean,
55
+ default: true
56
+ },
57
+ format: {
58
+ type: String,
59
+ default: 'YYYY/MM/DD'
60
+ }
61
+ },
62
+ data () {
63
+ return {
64
+ dateRange: [],
65
+ type: 'range'
66
+ }
67
+ },
68
+ watch: {
69
+ value: {
70
+ handler (newVal) {
71
+ this.convertValueToMoment(newVal)
72
+ },
73
+ immediate: true,
74
+ deep: true
75
+ },
76
+ defaultTime: {
77
+ handler (newVal) {
78
+ // 只有在没有传入value时才使用defaultTime
79
+ if (!this.value || this.value.length === 0) {
80
+ this.convertValueToMoment(newVal)
81
+ }
82
+ },
83
+ immediate: true,
84
+ deep: true
85
+ },
86
+ type () {
87
+ this.convertValueToMoment(this.value)
88
+ }
89
+
90
+ },
91
+ created () {
92
+ this.getData(this.queryParamsName)
93
+ },
94
+ methods: {
95
+ convertValueToMoment (value) {
96
+ // 如果没有传入value或value为空,则使用defaultTime
97
+ const timeToUse = (value && value.length > 0) ? value : this.defaultTime
98
+ if (this.type === 'range' && timeToUse?.length === 2) {
99
+ this.dateRange = [
100
+ timeToUse[0] ? moment(timeToUse[0]) : null,
101
+ timeToUse[1] ? moment(timeToUse[1]) : null
102
+ ]
103
+ } else if (this.type === 'date' && timeToUse?.length === 1) {
104
+ this.dateRange = [timeToUse[0] ? moment(timeToUse[0]) : null]
105
+ } else {
106
+ this.dateRange = []
107
+ }
108
+ },
109
+ handleDateChange (dates, dateStrings) {
110
+ if (this.type === 'date') {
111
+ // 单个日期选择器,dates是一个moment对象或null
112
+ this.dateRange = [dates]
113
+ } else {
114
+ // 范围选择器,dates是一个数组
115
+ this.dateRange = dates
116
+ }
117
+ this.$emit('change', dateStrings)
118
+ },
119
+ async getData (data) {
120
+ if (data) {
121
+ getConfigByName(data, 'af-his', res => {
122
+ if (['date', 'range'].includes(res.type)) {
123
+ this.type = res.type
124
+ }
125
+ // 处理format配置
126
+ if (res.format !== undefined) {
127
+ this.format = res.format
128
+ }
129
+ // 处理defaultTime配置
130
+ if (res.defaultTime !== undefined) {
131
+ if (res.defaultTime === 'now') {
132
+ // 如果配置为'now',设置当前时间
133
+ const now = moment().format(this.format)
134
+ if (this.type === 'range') {
135
+ this.defaultTime = [now, now]
136
+ } else if (this.type === 'date') {
137
+ this.defaultTime = [now]
138
+ }
139
+ } else if (Array.isArray(res.defaultTime)) {
140
+ // 如果配置为数组,直接使用
141
+ this.defaultTime = res.defaultTime
142
+ }
143
+ }
144
+ this.convertValueToMoment(this.value)
145
+ })
146
+ }
147
+ }
148
+ }
149
+ }
150
+ </script>
151
+
152
+ <style scoped>
153
+ .x-time-select {
154
+ position: relative;
155
+ width: 100%;
156
+ box-sizing: border-box;
157
+ display: block;
158
+ }
159
+
160
+ .time-select-container {
161
+ display: flex;
162
+ align-items: center;
163
+ }
164
+
165
+ .picker-wrapper {
166
+ flex: 1;
167
+ }
168
+
169
+ .x-time-select :deep(.ant-picker-range),
170
+ .x-time-select :deep(.ant-picker) {
171
+ width: 100%;
172
+ height: 30px;
173
+ border-radius: 7px;
174
+ background: #FFFFFF;
175
+ border: 1px solid #E5E9F0;
176
+ }
177
+ .x-time-select :deep(.ant-calendar-picker) {
178
+ width: 100%;
179
+ display: block;
180
+ }
181
+ .x-time-select :deep(.ant-calendar-picker-input) {
182
+ width: 100%;
183
+ height: 30px;
184
+ border-radius: 7px;
185
+ background: #FFFFFF;
186
+ border: 1px solid #E5E9F0;
187
+ }
188
+
189
+ .x-time-select :deep(.ant-input) {
190
+ width: 100%;
191
+ }
192
+ </style>