vue2-client 1.4.6 → 1.4.7

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,262 +1,262 @@
1
- <template>
2
- <div>
3
- <a-row :gutter="48">
4
- <a-col>
5
- <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
6
- <slot name="expand"></slot>
7
- </span>
8
- </a-col>
9
- <a-col>
10
- <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
11
- <a-button-group>
12
- <a-button @click="toggleIsFormShow">
13
- <a-icon :style="iconStyle" type="vertical-align-top"/>
14
- </a-button>
15
- <a-button @click="refresh(true)">
16
- <a-icon :style="iconStyle" type="reload" />
17
- </a-button>
18
- <table-setting v-model="tableColumns" />
19
- </a-button-group>
20
- </span>
21
- </a-col>
22
- </a-row>
23
- <s-table
24
- ref="table"
25
- :alert="true"
26
- :columns="tableColumns"
27
- :data="loadData"
28
- :rowKey="rowKey"
29
- :rowSelection="rowSelection"
30
- :scroll="{ x: scrollXWidth, y: scrollYWidth }"
31
- :showPagination="showPagination"
32
- size="default"
33
- >
34
- <template
35
- v-for="(item, index) in tableColumns"
36
- :slot="item.dataIndex"
37
- slot-scope="text, record">
38
- <!-- 文本溢出省略(ellipsis) -->
39
- <span v-if="item.slotType === 'ellipsis'" :key="index">
40
- <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
41
- </span>
42
- <!-- 徽标(badge) -->
43
- <span v-else-if="item.slotType === 'badge'" :key="index">
44
- <x-badge :badge-key="item.slotKeyMap" :value="text" />
45
- </span>
46
- <!-- 日期(date) -->
47
- <span v-else-if="item.slotType === 'date'" :key="index">
48
- {{ format(text,'yyyy-MM-dd') }}
49
- </span>
50
- <!-- 日期时间(datetime) -->
51
- <span v-else-if="item.slotType === 'dateTime'" :key="index">
52
- {{ format(text,'yyyy-MM-dd hh:mm:ss') }}
53
- </span>
54
- <!-- 操作列(action) -->
55
- <span v-else-if="item.slotType === 'action'" :key="index">
56
- <a @click="action(record)">{{ item.slotValue }}</a>
57
- </span>
58
- </template>
59
- <template slot="footer">
60
- <slot name="footer"></slot>
61
- </template>
62
- </s-table>
63
- </div>
64
- </template>
65
- <script>
66
- import { Ellipsis, STable } from '@vue2-client/components'
67
- import { formatDate } from '@vue2-client/utils/util'
68
- import XBadge from '@vue2-client/base-client/components/common/XBadge'
69
- import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
70
-
71
- export default {
72
- name: 'XTable',
73
- components: {
74
- TableSetting,
75
- STable,
76
- Ellipsis,
77
- XBadge
78
- },
79
- data () {
80
- return {
81
- // 加载数据方法 必须为 Promise 对象
82
- loadData: parameter => {
83
- // 取到表格携带的表单参数
84
- const requestParameters = Object.assign({}, parameter)
85
- // 取到父组件传入的表单参数
86
- const conditionParams = Object.assign(this.fixedQueryForm, this.form)
87
- // 如果适用了综合筛选表单,则进行数据处理
88
- if (conditionParams.rowIdName) {
89
- const rowIdName = conditionParams.rowIdName
90
- const rowIdValue = conditionParams.rowIdValue
91
- delete conditionParams.rowIdName
92
- delete conditionParams.rowIdValue
93
- if (rowIdValue) {
94
- conditionParams[rowIdName] = rowIdValue
95
- }
96
- }
97
- // 如果传了燃气公司字段,则进行数据处理
98
- if (conditionParams.orgName) {
99
- requestParameters.orgName = conditionParams.orgName
100
- delete conditionParams.orgName
101
- }
102
- requestParameters.conditionParams = conditionParams
103
- requestParameters.queryParamsName = this.queryParamsName
104
- requestParameters.queryParams = this.queryParams
105
- // 加载数据
106
- return this.loadTableData(requestParameters)
107
- },
108
- rowKey: undefined,
109
- scrollXWidth: 1600,
110
- scrollYWidth: 437,
111
- selectedRowKeys: [],
112
- selectedRows: [],
113
- // 数据列
114
- tableColumns: this.jsonData,
115
- // 是否显示展示列抽屉
116
- visible: false,
117
- loading: false,
118
- dataSource: [],
119
- // 图标样式
120
- iconStyle: {
121
- position: 'relative',
122
- top: '1px'
123
- }
124
- }
125
- },
126
- watch: {
127
- form (rel) {
128
- this.form = rel
129
- this.refresh(true)
130
- },
131
- jsonData () {
132
- this.initTableParams()
133
- }
134
- },
135
- props: {
136
- jsonData: {
137
- type: Array,
138
- default: () => {
139
- return []
140
- }
141
- },
142
- queryParamsName: {
143
- type: String,
144
- default: () => {
145
- return ''
146
- }
147
- },
148
- // 查询参数对象, 用于没有对应查询配置文件名时
149
- queryParams: {
150
- type: Object,
151
- default: null
152
- },
153
- form: {
154
- type: Object,
155
- default: () => {
156
- return {}
157
- }
158
- },
159
- // 固定查询表单
160
- fixedQueryForm: {
161
- type: Object,
162
- default: () => {
163
- return {}
164
- }
165
- },
166
- // 按钮
167
- buttonState: {
168
- type: Object,
169
- default: () => {
170
- return undefined
171
- }
172
- },
173
- // 数据只有一页时是否展示分页,true:展示,auto:隐藏
174
- showPagination: {
175
- type: Boolean,
176
- default: true
177
- }
178
- },
179
- computed: {
180
- rowSelection () {
181
- return {
182
- selectedRowKeys: this.selectedRowKeys,
183
- onChange: this.onSelectChange
184
- }
185
- }
186
- },
187
- mounted () {
188
- this.initTableParams()
189
- },
190
- methods: {
191
- badgeFilter (key, value) {
192
- return this.$appdata.getParam(key, value)
193
- },
194
- initTableParams () {
195
- let totalWidth = 0
196
- this.rowKey = this.tableColumns[0].dataIndex
197
- for (let i = 0; i < this.tableColumns.length; i++) {
198
- const item = this.tableColumns[i]
199
- if (item.dataIndex === 'action') {
200
- item.fixed = 'right'
201
- item.width = 70
202
- }
203
- if (item.width) {
204
- totalWidth = totalWidth + item.width
205
- } else {
206
- totalWidth = totalWidth + 180
207
- }
208
- }
209
- const width = document.documentElement.clientWidth
210
- if (width >= 1600) {
211
- this.scrollYWidth = 429
212
- } else if (width >= 1200) {
213
- this.scrollYWidth = 390
214
- } else {
215
- this.scrollYWidth = 343
216
- }
217
- // 横向滚动长度大于所有宽度,才能实现固定表头
218
- this.scrollXWidth = totalWidth
219
- },
220
- loadTableData (requestParameters) {
221
- let data = []
222
- this.$emit('loadData', requestParameters, val => {
223
- data = val
224
- })
225
- const _this = this
226
- data.then(res => {
227
- _this.dataSource = res.data
228
- })
229
- return data
230
- },
231
- action (record) {
232
- this.$emit('action', record, record[this.jsonData[0].dataIndex])
233
- },
234
- onSelectChange (selectedRowKeys, selectedRows) {
235
- this.selectedRowKeys = selectedRowKeys
236
- this.selectedRows = selectedRows
237
- this.$emit('selectRow', selectedRowKeys)
238
- },
239
- clearRowKeys () {
240
- this.$refs.table.clearSelected()
241
- },
242
- /**
243
- * 表格重新加载方法
244
- * 如果参数为 true, 则强制刷新到第一页
245
- */
246
- refresh (bool) {
247
- this.$refs.table.refresh(bool)
248
- },
249
- format (date, format) {
250
- return formatDate(date, format)
251
- },
252
- showDrawer () {
253
- this.visible = true
254
- },
255
- toggleIsFormShow () {
256
- this.$emit('toggleIsFormShow')
257
- }
258
- }
259
- }
260
- </script>
261
- <style lang="less" scoped>
262
- </style>
1
+ <template>
2
+ <div>
3
+ <a-row :gutter="48">
4
+ <a-col>
5
+ <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
6
+ <slot name="expand"></slot>
7
+ </span>
8
+ </a-col>
9
+ <a-col>
10
+ <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
11
+ <a-button-group>
12
+ <a-button @click="toggleIsFormShow">
13
+ <a-icon :style="iconStyle" type="vertical-align-top"/>
14
+ </a-button>
15
+ <a-button @click="refresh(true)">
16
+ <a-icon :style="iconStyle" type="reload" />
17
+ </a-button>
18
+ <table-setting v-model="tableColumns" />
19
+ </a-button-group>
20
+ </span>
21
+ </a-col>
22
+ </a-row>
23
+ <s-table
24
+ ref="table"
25
+ :alert="true"
26
+ :columns="tableColumns"
27
+ :data="loadData"
28
+ :rowKey="rowKey"
29
+ :rowSelection="rowSelection"
30
+ :scroll="{ x: scrollXWidth, y: scrollYWidth }"
31
+ :showPagination="showPagination"
32
+ size="default"
33
+ >
34
+ <template
35
+ v-for="(item, index) in tableColumns"
36
+ :slot="item.dataIndex"
37
+ slot-scope="text, record">
38
+ <!-- 文本溢出省略(ellipsis) -->
39
+ <span v-if="item.slotType === 'ellipsis'" :key="index">
40
+ <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
41
+ </span>
42
+ <!-- 徽标(badge) -->
43
+ <span v-else-if="item.slotType === 'badge'" :key="index">
44
+ <x-badge :badge-key="item.slotKeyMap" :value="text" />
45
+ </span>
46
+ <!-- 日期(date) -->
47
+ <span v-else-if="item.slotType === 'date'" :key="index">
48
+ {{ format(text,'yyyy-MM-dd') }}
49
+ </span>
50
+ <!-- 日期时间(datetime) -->
51
+ <span v-else-if="item.slotType === 'dateTime'" :key="index">
52
+ {{ format(text,'yyyy-MM-dd hh:mm:ss') }}
53
+ </span>
54
+ <!-- 操作列(action) -->
55
+ <span v-else-if="item.slotType === 'action'" :key="index">
56
+ <a @click="action(record)">{{ item.slotValue }}</a>
57
+ </span>
58
+ </template>
59
+ <template slot="footer">
60
+ <slot name="footer"></slot>
61
+ </template>
62
+ </s-table>
63
+ </div>
64
+ </template>
65
+ <script>
66
+ import { Ellipsis, STable } from '@vue2-client/components'
67
+ import { formatDate } from '@vue2-client/utils/util'
68
+ import XBadge from '@vue2-client/base-client/components/common/XBadge'
69
+ import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
70
+
71
+ export default {
72
+ name: 'XTable',
73
+ components: {
74
+ TableSetting,
75
+ STable,
76
+ Ellipsis,
77
+ XBadge
78
+ },
79
+ data () {
80
+ return {
81
+ // 加载数据方法 必须为 Promise 对象
82
+ loadData: parameter => {
83
+ // 取到表格携带的表单参数
84
+ const requestParameters = Object.assign({}, parameter)
85
+ // 取到父组件传入的表单参数
86
+ const conditionParams = Object.assign(this.fixedQueryForm, this.form)
87
+ // 如果适用了综合筛选表单,则进行数据处理
88
+ if (conditionParams.rowIdName) {
89
+ const rowIdName = conditionParams.rowIdName
90
+ const rowIdValue = conditionParams.rowIdValue
91
+ delete conditionParams.rowIdName
92
+ delete conditionParams.rowIdValue
93
+ if (rowIdValue) {
94
+ conditionParams[rowIdName] = rowIdValue
95
+ }
96
+ }
97
+ // 如果传了燃气公司字段,则进行数据处理
98
+ if (conditionParams.orgName) {
99
+ requestParameters.orgName = conditionParams.orgName
100
+ delete conditionParams.orgName
101
+ }
102
+ requestParameters.conditionParams = conditionParams
103
+ requestParameters.queryParamsName = this.queryParamsName
104
+ requestParameters.queryParams = this.queryParams
105
+ // 加载数据
106
+ return this.loadTableData(requestParameters)
107
+ },
108
+ rowKey: undefined,
109
+ scrollXWidth: 1600,
110
+ scrollYWidth: 437,
111
+ selectedRowKeys: [],
112
+ selectedRows: [],
113
+ // 数据列
114
+ tableColumns: this.jsonData,
115
+ // 是否显示展示列抽屉
116
+ visible: false,
117
+ loading: false,
118
+ dataSource: [],
119
+ // 图标样式
120
+ iconStyle: {
121
+ position: 'relative',
122
+ top: '1px'
123
+ }
124
+ }
125
+ },
126
+ watch: {
127
+ form (rel) {
128
+ this.form = rel
129
+ this.refresh(true)
130
+ },
131
+ jsonData () {
132
+ this.initTableParams()
133
+ }
134
+ },
135
+ props: {
136
+ jsonData: {
137
+ type: Array,
138
+ default: () => {
139
+ return []
140
+ }
141
+ },
142
+ queryParamsName: {
143
+ type: String,
144
+ default: () => {
145
+ return ''
146
+ }
147
+ },
148
+ // 查询参数对象, 用于没有对应查询配置文件名时
149
+ queryParams: {
150
+ type: Object,
151
+ default: null
152
+ },
153
+ form: {
154
+ type: Object,
155
+ default: () => {
156
+ return {}
157
+ }
158
+ },
159
+ // 固定查询表单
160
+ fixedQueryForm: {
161
+ type: Object,
162
+ default: () => {
163
+ return {}
164
+ }
165
+ },
166
+ // 按钮
167
+ buttonState: {
168
+ type: Object,
169
+ default: () => {
170
+ return undefined
171
+ }
172
+ },
173
+ // 数据只有一页时是否展示分页,true:展示,auto:隐藏
174
+ showPagination: {
175
+ type: Boolean,
176
+ default: true
177
+ }
178
+ },
179
+ computed: {
180
+ rowSelection () {
181
+ return {
182
+ selectedRowKeys: this.selectedRowKeys,
183
+ onChange: this.onSelectChange
184
+ }
185
+ }
186
+ },
187
+ mounted () {
188
+ this.initTableParams()
189
+ },
190
+ methods: {
191
+ badgeFilter (key, value) {
192
+ return this.$appdata.getParam(key, value)
193
+ },
194
+ initTableParams () {
195
+ let totalWidth = 0
196
+ this.rowKey = this.tableColumns[0].dataIndex
197
+ for (let i = 0; i < this.tableColumns.length; i++) {
198
+ const item = this.tableColumns[i]
199
+ if (item.dataIndex === 'action') {
200
+ item.fixed = 'right'
201
+ item.width = 70
202
+ }
203
+ if (item.width) {
204
+ totalWidth = totalWidth + item.width
205
+ } else {
206
+ totalWidth = totalWidth + 180
207
+ }
208
+ }
209
+ const width = document.documentElement.clientWidth
210
+ if (width >= 1600) {
211
+ this.scrollYWidth = 429
212
+ } else if (width >= 1200) {
213
+ this.scrollYWidth = 390
214
+ } else {
215
+ this.scrollYWidth = 343
216
+ }
217
+ // 横向滚动长度大于所有宽度,才能实现固定表头
218
+ this.scrollXWidth = totalWidth
219
+ },
220
+ loadTableData (requestParameters) {
221
+ let data = []
222
+ this.$emit('loadData', requestParameters, val => {
223
+ data = val
224
+ })
225
+ const _this = this
226
+ data.then(res => {
227
+ _this.dataSource = res.data
228
+ })
229
+ return data
230
+ },
231
+ action (record) {
232
+ this.$emit('action', record, record[this.jsonData[0].dataIndex])
233
+ },
234
+ onSelectChange (selectedRowKeys, selectedRows) {
235
+ this.selectedRowKeys = selectedRowKeys
236
+ this.selectedRows = selectedRows
237
+ this.$emit('selectRow', selectedRowKeys)
238
+ },
239
+ clearRowKeys () {
240
+ this.$refs.table.clearSelected()
241
+ },
242
+ /**
243
+ * 表格重新加载方法
244
+ * 如果参数为 true, 则强制刷新到第一页
245
+ */
246
+ refresh (bool) {
247
+ this.$refs.table.refresh(bool)
248
+ },
249
+ format (date, format) {
250
+ return formatDate(date, format)
251
+ },
252
+ showDrawer () {
253
+ this.visible = true
254
+ },
255
+ toggleIsFormShow () {
256
+ this.$emit('toggleIsFormShow')
257
+ }
258
+ }
259
+ }
260
+ </script>
261
+ <style lang="less" scoped>
262
+ </style>