vue2-client 1.2.67 → 1.2.68

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.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Change Log
2
2
  > 所有关于本项目的变化都在该文档里。
3
3
 
4
- **1.2.66 - 1.2.67 -2022-06-08 @江超**
4
+ **1.2.66 - 1.2.68 -2022-06-08 @江超**
5
5
  - 功能修改:
6
6
  - 设备类型详情页新增设备查询配置
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.2.67",
3
+ "version": "1.2.68",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -1,225 +1,225 @@
1
- <template>
2
- <div class="certain-category-search-wrapper">
3
- <a-auto-complete
4
- :disabled="!mapAutocomplete"
5
- :dropdown-match-select-width="false"
6
- :dropdown-style="{ width: '400px' }"
7
- class="certain-category-search"
8
- dropdown-class-name="certain-category-search-dropdown"
9
- option-label-prop="value"
10
- placeholder="输入地址关键字搜索"
11
- @search="fetchFunction"
12
- @select="onSelect"
13
- >
14
- <a-spin v-if="searching" slot="notFoundContent" size="small" />
15
- <template slot="dataSource">
16
- <a-select-opt-group v-for="group in option" :key="group.title">
17
- <span
18
- slot="label">
19
- <a-icon type="bank" /> {{ group.title }}
20
- </span>
21
- <a-select-option v-for="address in group.children" :key="address.label + ' (' + address.value + ')'">
22
- <p class="addressName"><a-icon type="environment" /> <span v-html="highLight(address.label, address.word)">{{ address.label }}</span></p>
23
- <p v-if="address.address !== '[]'" class="addressRemark">
24
- {{ address.address }}
25
- </p>
26
- </a-select-option>
27
- </a-select-opt-group>
28
- </template>
29
- <a-input>
30
- <a-icon slot="suffix" class="certain-category-icon" type="search"/>
31
- </a-input>
32
- </a-auto-complete>
33
- </div>
34
- </template>
35
- <script>
36
-
37
- import { post } from '@vue2-client/services/api'
38
- import { GetGDMap } from '@vue2-client/utils/map-utils'
39
- import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
40
-
41
- export default {
42
- name: 'AddressSearchCombobox',
43
- data () {
44
- // 检索去抖
45
- this.fetchFunction = debounce(this.fetchFunction, 300)
46
- return {
47
- // 地址搜索联想
48
- mapAutocomplete: undefined,
49
- // 检索结果
50
- option: [],
51
- // 最后检索版本
52
- lastFetchId: 0,
53
- // 检索中
54
- searching: false
55
- }
56
- },
57
- model: {
58
- prop: 'searchResult',
59
- event: 'onSelect'
60
- },
61
- props: {
62
- searchResult: {
63
- type: String,
64
- default: undefined
65
- },
66
- // 返回数据格式
67
- searchResultType: {
68
- type: String,
69
- default: 'Default'
70
- // default: 'Array'
71
- // default: 'Object'
72
- },
73
- // Object 返回格式时 可以自定义key
74
- resultKeys: {
75
- type: Object,
76
- default: () => { return { address: 'address', coords: 'coords' } }
77
- }
78
- },
79
- created () {
80
- },
81
- mounted () {
82
- GetGDMap().then(aMap => {
83
- this.mapAutocomplete = new (aMap).Autocomplete({})
84
- })
85
- },
86
- methods: {
87
- onSelect (value) {
88
- let result
89
- if (this.searchResultType !== 'Default') {
90
- const _arr = value.replace(')', '').split('(')
91
- if (this.searchResultType === 'Array') {
92
- result = _arr
93
- } else {
94
- result = {}
95
- result[this.resultKeys.address] = _arr[0]
96
- result[this.resultKeys.coords] = _arr[1]
97
- }
98
- }
99
- this.$emit('onSelect', JSON.stringify(result) || value)
100
- // this.$emit('onClick', result || value)
101
- },
102
- // 懒加载检索方法
103
- fetchFunction (value) {
104
- if (value && this.mapAutocomplete) {
105
- this.searching = true
106
- this.lastFetchId += 1
107
- const fetchId = this.lastFetchId
108
- this.mapAutocomplete.search(value, (status, result) => {
109
- if (fetchId !== this.lastFetchId) {
110
- return
111
- }
112
- if (status === 'complete') {
113
- this.option = []
114
- const addressMap = {}
115
- result.tips.forEach((res) => {
116
- if (res.location) {
117
- if (!addressMap.hasOwnProperty(res.district)) {
118
- addressMap[res.district] = []
119
- }
120
- addressMap[res.district].push({
121
- label: res.name,
122
- value: res.location.lat + ',' + res.location.lng,
123
- address: res.address + '',
124
- word: value
125
- })
126
- }
127
- })
128
- for (const key of Object.keys(addressMap)) {
129
- this.option.push({
130
- title: key,
131
- children: addressMap[key]
132
- })
133
- }
134
- }
135
- this.searching = false
136
- })
137
- }
138
- },
139
- // 获取数据
140
- getData (value, callback) {
141
- if (value !== '') {
142
- const logicName = this.attr.keyName
143
- const logic = logicName.substring(6)
144
- post('/webmeterapi/' + logic, value).then(res => {
145
- callback(res)
146
- })
147
- }
148
- },
149
- // 关键字高亮
150
- highLight (value, word) {
151
- // 如果标题中包含,关键字就替换一下
152
- if (value.includes(word)) {
153
- value = value.replace(word,
154
- // 这里是替换成html格式的数据,最好再加一个样式权重,保险一点
155
- '<span style="color:red!important;">' + word + '</span>'
156
- )
157
- return value
158
- // eslint-disable-next-line brace-style
159
- }
160
- // 不包含的话还用这个
161
- else {
162
- return value
163
- }
164
- }
165
- }
166
- }
167
- </script>
168
-
169
- <style>
170
- .certain-category-search-dropdown .ant-select-dropdown-menu-item-group-title {
171
- color: #666;
172
- font-weight: bold;
173
- font-size: 14px;
174
- }
175
-
176
- .certain-category-search-dropdown .ant-select-dropdown-menu-item-group {
177
- border-bottom: 1px solid #f6f6f6;
178
- }
179
-
180
- .certain-category-search-dropdown .ant-select-dropdown-menu-item {
181
- padding-left: 16px;
182
- }
183
-
184
- .certain-category-search-dropdown .ant-select-dropdown-menu-item.show-all {
185
- text-align: center;
186
- cursor: default;
187
- }
188
-
189
- .certain-category-search-dropdown .ant-select-dropdown-menu {
190
- max-height: 300px;
191
- }
192
- </style>
193
- <style scoped>
194
- .certain-category-search-wrapper
195
- >>> .certain-category-search.ant-select-auto-complete
196
- .ant-input-affix-wrapper
197
- .ant-input-suffix {
198
- right: 12px;
199
- }
200
- .certain-category-search-wrapper >>> .certain-search-item-count {
201
- position: absolute;
202
- color: #999;
203
- right: 16px;
204
- }
205
- .certain-category-search-wrapper >>> .certain-category-search.ant-select-focused,
206
- .certain-category-icon {
207
- color: #108ee9;
208
- }
209
- .certain-category-search-wrapper >>> .certain-category-icon {
210
- color: #6e6e6e;
211
- transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
212
- font-size: 16px;
213
- }
214
-
215
- .addressName {
216
- margin-bottom: 0;
217
- font-size: 14px;
218
- font-weight: bold;
219
- }
220
-
221
- .addressRemark {
222
- margin-bottom: 0;
223
- font-size: 12px;
224
- }
225
- </style>
1
+ <template>
2
+ <div class="certain-category-search-wrapper">
3
+ <a-auto-complete
4
+ :disabled="!mapAutocomplete"
5
+ :dropdown-match-select-width="false"
6
+ :dropdown-style="{ width: '400px' }"
7
+ class="certain-category-search"
8
+ dropdown-class-name="certain-category-search-dropdown"
9
+ option-label-prop="value"
10
+ placeholder="输入地址关键字搜索"
11
+ @search="fetchFunction"
12
+ @select="onSelect"
13
+ >
14
+ <a-spin v-if="searching" slot="notFoundContent" size="small" />
15
+ <template slot="dataSource">
16
+ <a-select-opt-group v-for="group in option" :key="group.title">
17
+ <span
18
+ slot="label">
19
+ <a-icon type="bank" /> {{ group.title }}
20
+ </span>
21
+ <a-select-option v-for="address in group.children" :key="address.label + ' (' + address.value + ')'">
22
+ <p class="addressName"><a-icon type="environment" /> <span v-html="highLight(address.label, address.word)">{{ address.label }}</span></p>
23
+ <p v-if="address.address !== '[]'" class="addressRemark">
24
+ {{ address.address }}
25
+ </p>
26
+ </a-select-option>
27
+ </a-select-opt-group>
28
+ </template>
29
+ <a-input>
30
+ <a-icon slot="suffix" class="certain-category-icon" type="search"/>
31
+ </a-input>
32
+ </a-auto-complete>
33
+ </div>
34
+ </template>
35
+ <script>
36
+
37
+ import { post } from '@vue2-client/services/api'
38
+ import { GetGDMap } from '@vue2-client/utils/map-utils'
39
+ import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
40
+
41
+ export default {
42
+ name: 'AddressSearchCombobox',
43
+ data () {
44
+ // 检索去抖
45
+ this.fetchFunction = debounce(this.fetchFunction, 300)
46
+ return {
47
+ // 地址搜索联想
48
+ mapAutocomplete: undefined,
49
+ // 检索结果
50
+ option: [],
51
+ // 最后检索版本
52
+ lastFetchId: 0,
53
+ // 检索中
54
+ searching: false
55
+ }
56
+ },
57
+ model: {
58
+ prop: 'searchResult',
59
+ event: 'onSelect'
60
+ },
61
+ props: {
62
+ searchResult: {
63
+ type: String,
64
+ default: undefined
65
+ },
66
+ // 返回数据格式
67
+ searchResultType: {
68
+ type: String,
69
+ default: 'Default'
70
+ // default: 'Array'
71
+ // default: 'Object'
72
+ },
73
+ // Object 返回格式时 可以自定义key
74
+ resultKeys: {
75
+ type: Object,
76
+ default: () => { return { address: 'address', coords: 'coords' } }
77
+ }
78
+ },
79
+ created () {
80
+ },
81
+ mounted () {
82
+ GetGDMap().then(aMap => {
83
+ this.mapAutocomplete = new (aMap).Autocomplete({})
84
+ })
85
+ },
86
+ methods: {
87
+ onSelect (value) {
88
+ let result
89
+ if (this.searchResultType !== 'Default') {
90
+ const _arr = value.replace(')', '').split('(')
91
+ if (this.searchResultType === 'Array') {
92
+ result = _arr
93
+ } else {
94
+ result = {}
95
+ result[this.resultKeys.address] = _arr[0]
96
+ result[this.resultKeys.coords] = _arr[1]
97
+ }
98
+ }
99
+ this.$emit('onSelect', JSON.stringify(result) || value)
100
+ // this.$emit('onClick', result || value)
101
+ },
102
+ // 懒加载检索方法
103
+ fetchFunction (value) {
104
+ if (value && this.mapAutocomplete) {
105
+ this.searching = true
106
+ this.lastFetchId += 1
107
+ const fetchId = this.lastFetchId
108
+ this.mapAutocomplete.search(value, (status, result) => {
109
+ if (fetchId !== this.lastFetchId) {
110
+ return
111
+ }
112
+ if (status === 'complete') {
113
+ this.option = []
114
+ const addressMap = {}
115
+ result.tips.forEach((res) => {
116
+ if (res.location) {
117
+ if (!addressMap.hasOwnProperty(res.district)) {
118
+ addressMap[res.district] = []
119
+ }
120
+ addressMap[res.district].push({
121
+ label: res.name,
122
+ value: res.location.lng + ',' + res.location.lat + ',',
123
+ address: res.address + '',
124
+ word: value
125
+ })
126
+ }
127
+ })
128
+ for (const key of Object.keys(addressMap)) {
129
+ this.option.push({
130
+ title: key,
131
+ children: addressMap[key]
132
+ })
133
+ }
134
+ }
135
+ this.searching = false
136
+ })
137
+ }
138
+ },
139
+ // 获取数据
140
+ getData (value, callback) {
141
+ if (value !== '') {
142
+ const logicName = this.attr.keyName
143
+ const logic = logicName.substring(6)
144
+ post('/webmeterapi/' + logic, value).then(res => {
145
+ callback(res)
146
+ })
147
+ }
148
+ },
149
+ // 关键字高亮
150
+ highLight (value, word) {
151
+ // 如果标题中包含,关键字就替换一下
152
+ if (value.includes(word)) {
153
+ value = value.replace(word,
154
+ // 这里是替换成html格式的数据,最好再加一个样式权重,保险一点
155
+ '<span style="color:red!important;">' + word + '</span>'
156
+ )
157
+ return value
158
+ // eslint-disable-next-line brace-style
159
+ }
160
+ // 不包含的话还用这个
161
+ else {
162
+ return value
163
+ }
164
+ }
165
+ }
166
+ }
167
+ </script>
168
+
169
+ <style>
170
+ .certain-category-search-dropdown .ant-select-dropdown-menu-item-group-title {
171
+ color: #666;
172
+ font-weight: bold;
173
+ font-size: 14px;
174
+ }
175
+
176
+ .certain-category-search-dropdown .ant-select-dropdown-menu-item-group {
177
+ border-bottom: 1px solid #f6f6f6;
178
+ }
179
+
180
+ .certain-category-search-dropdown .ant-select-dropdown-menu-item {
181
+ padding-left: 16px;
182
+ }
183
+
184
+ .certain-category-search-dropdown .ant-select-dropdown-menu-item.show-all {
185
+ text-align: center;
186
+ cursor: default;
187
+ }
188
+
189
+ .certain-category-search-dropdown .ant-select-dropdown-menu {
190
+ max-height: 300px;
191
+ }
192
+ </style>
193
+ <style scoped>
194
+ .certain-category-search-wrapper
195
+ >>> .certain-category-search.ant-select-auto-complete
196
+ .ant-input-affix-wrapper
197
+ .ant-input-suffix {
198
+ right: 12px;
199
+ }
200
+ .certain-category-search-wrapper >>> .certain-search-item-count {
201
+ position: absolute;
202
+ color: #999;
203
+ right: 16px;
204
+ }
205
+ .certain-category-search-wrapper >>> .certain-category-search.ant-select-focused,
206
+ .certain-category-icon {
207
+ color: #108ee9;
208
+ }
209
+ .certain-category-search-wrapper >>> .certain-category-icon {
210
+ color: #6e6e6e;
211
+ transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
212
+ font-size: 16px;
213
+ }
214
+
215
+ .addressName {
216
+ margin-bottom: 0;
217
+ font-size: 14px;
218
+ font-weight: bold;
219
+ }
220
+
221
+ .addressRemark {
222
+ margin-bottom: 0;
223
+ font-size: 12px;
224
+ }
225
+ </style>
@@ -22,7 +22,7 @@
22
22
  },
23
23
  // 需要渲染的点位数据
24
24
  markers: {
25
- type: Object,
25
+ type: String,
26
26
  default: null // lng:经度值 lat:纬度值
27
27
  },
28
28
  // 渲染点位的图片
@@ -81,11 +81,13 @@
81
81
  },
82
82
  initData (aMap) {
83
83
  // 创建一个 Marker 实例:
84
- if (this.markers && this.markers.lng && this.markers.lat) {
85
- const that = this
84
+ if (this.markers) {
85
+ const lngLat = this.markers.split(',')
86
+ const lng = lngLat[0]
87
+ const lat = lngLat[1]
86
88
  const marker = new (aMap).Marker({
87
89
  // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
88
- position: new (aMap).LngLat(this.markers.lng, this.markers.lat),
90
+ position: new (aMap).LngLat(lng, lat),
89
91
  title: '北京',
90
92
  icon: new (aMap).Icon({
91
93
  // 图标大小
@@ -1,269 +1,271 @@
1
- <template>
2
- <div>
3
- <custom-columns-drawer
4
- :visible.sync="visible"
5
- :columns.sync="tableColumns"
6
- :columns-meta="jsonData"/>
7
- <a-row :gutter="48">
8
- <a-col>
9
- <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
10
- <slot name="expand"></slot>
11
- </span>
12
- </a-col>
13
- <a-col>
14
- <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
15
- <a-button-group>
16
- <a-button @click="toggleIsFormShow">
17
- <a-icon :style="iconStyle" type="vertical-align-top"/>
18
- </a-button>
19
- <a-button @click="refresh(true)">
20
- <a-icon :style="iconStyle" type="reload" />
21
- </a-button>
22
- <a-button @click="showDrawer">
23
- <a-icon :style="iconStyle" type="table" />
24
- </a-button>
25
- <a-button @click="exports" v-if="!buttonState || buttonState.export">
26
- <a-icon :style="iconStyle" type="cloud-download"/>
27
- </a-button>
28
- </a-button-group>
29
- </span>
30
- </a-col>
31
- </a-row>
32
- <s-table
33
- ref="table"
34
- size="default"
35
- :rowKey="rowKey"
36
- :columns="tableColumns"
37
- :data="loadData"
38
- :alert="true"
39
- :rowSelection="rowSelection"
40
- showPagination="auto"
41
- :scroll="{ x: scrollXWidth, y: scrollYWidth }"
42
- >
43
- <template
44
- v-for="(item, index) in tableColumns"
45
- :slot="item.dataIndex"
46
- slot-scope="text, record">
47
- <!-- 文本溢出省略(ellipsis) -->
48
- <span :key="index" v-if="item.slotType === 'ellipsis'">
49
- <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
50
- </span>
51
- <!-- 徽标(badge) -->
52
- <span :key="index" v-else-if="item.slotType === 'badge'">
53
- <x-badge :badge-key="item.slotKeyMap" :value="text" />
54
- </span>
55
- <!-- 日期(date) -->
56
- <span :key="index" v-else-if="item.slotType === 'date'">
57
- {{ format(text,'yyyy-MM-dd') }}
58
- </span>
59
- <!-- 日期时间(datetime) -->
60
- <span :key="index" v-else-if="item.slotType === 'dateTime'">
61
- {{ format(text,'yyyy-MM-dd hh:mm:ss') }}
62
- </span>
63
- <!-- 操作列(action) -->
64
- <span :key="index" v-else-if="item.slotType === 'action'">
65
- <a @click="action(record)">{{ item.slotValue }}</a>
66
- </span>
67
- </template>
68
- </s-table>
69
- </div>
70
- </template>
71
- <script>
72
- import { Ellipsis, STable } from '@vue2-client/components'
73
- import { formatDate } from '@vue2-client/utils/util'
74
- import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
75
-
76
- export default {
77
- name: 'XTable',
78
- components: {
79
- STable,
80
- Ellipsis
81
- },
82
- data () {
83
- return {
84
- // 加载数据方法 必须为 Promise 对象
85
- loadData: parameter => {
86
- // 取到表格携带的表单参数
87
- const requestParameters = Object.assign({}, parameter)
88
- // 取到父组件传入的表单参数
89
- const conditionParams = Object.assign(this.fixedQueryForm, this.form)
90
- // 如果适用了综合筛选表单,则进行数据处理
91
- if (conditionParams.rowIdName) {
92
- const rowIdName = conditionParams.rowIdName
93
- const rowIdValue = conditionParams.rowIdValue
94
- delete conditionParams.rowIdName
95
- delete conditionParams.rowIdValue
96
- if (rowIdValue) {
97
- conditionParams[rowIdName] = rowIdValue
98
- }
99
- }
100
- // 如果传了燃气公司字段,则进行数据处理
101
- if (conditionParams.orgName) {
102
- requestParameters.orgName = conditionParams.orgName
103
- delete conditionParams.orgName
104
- }
105
- requestParameters.conditionParams = conditionParams
106
- requestParameters.queryParamsName = this.queryParamsName
107
- requestParameters.queryParams = this.queryParams
108
- // 加载数据
109
- return this.loadTableData(requestParameters)
110
- },
111
- rowKey: undefined,
112
- scrollXWidth: 1600,
113
- scrollYWidth: 437,
114
- selectedRowKeys: [],
115
- selectedRows: [],
116
- // 数据列
117
- tableColumns: this.jsonData,
118
- // 是否显示展示列抽屉
119
- visible: false,
120
- dataSource: [],
121
- // 图标样式
122
- iconStyle: {
123
- position: 'relative',
124
- top: '1px'
125
- }
126
- }
127
- },
128
- watch: {
129
- form (rel) {
130
- this.form = rel
131
- this.refresh(true)
132
- },
133
- jsonData () {
134
- this.initTableParams()
135
- }
136
- },
137
- props: {
138
- jsonData: {
139
- type: Array,
140
- default: () => {
141
- return []
142
- }
143
- },
144
- queryParamsName: {
145
- type: String,
146
- default: () => {
147
- return ''
148
- }
149
- },
150
- // 查询参数对象, 用于没有对应查询配置文件名时
151
- queryParams: {
152
- type: Object,
153
- default: null
154
- },
155
- form: {
156
- type: Object,
157
- default: () => {
158
- return {}
159
- }
160
- },
161
- // 固定查询表单
162
- fixedQueryForm: {
163
- type: Object,
164
- default: () => {
165
- return {}
166
- }
167
- },
168
- // 按钮
169
- buttonState: {
170
- type: Object,
171
- default: () => {
172
- return undefined
173
- }
174
- }
175
- },
176
- computed: {
177
- rowSelection () {
178
- return {
179
- selectedRowKeys: this.selectedRowKeys,
180
- onChange: this.onSelectChange
181
- }
182
- }
183
- },
184
- mounted () {
185
- this.initTableParams()
186
- },
187
- methods: {
188
- exports () {
189
- const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
190
- const filterVal = this.tableColumns.map(res => res.dataIndex)
191
- const list = this.dataSource
192
- const data = this.formatJson(filterVal, list)
193
- exportJson(tHeader, data, new Date())
194
- },
195
- formatJson (filterVal, jsonData) {
196
- return jsonData.map(v => filterVal.map(j => v[j]))
197
- },
198
- badgeFilter (key, value) {
199
- return this.$appdata.getParam(key, value)
200
- },
201
- initTableParams () {
202
- let totalWidth = 0
203
- this.rowKey = this.tableColumns[0].dataIndex
204
- for (let i = 0; i < this.tableColumns.length; i++) {
205
- const item = this.tableColumns[i]
206
- if (item.dataIndex === 'action') {
207
- item.fixed = 'right'
208
- item.width = 70
209
- }
210
- if (item.width) {
211
- totalWidth = totalWidth + item.width
212
- } else {
213
- totalWidth = totalWidth + 180
214
- }
215
- }
216
- const width = document.documentElement.clientWidth
217
- if (width >= 1600) {
218
- this.scrollYWidth = 429
219
- } else if (width >= 1200) {
220
- this.scrollYWidth = 390
221
- } else {
222
- this.scrollYWidth = 343
223
- }
224
- // 横向滚动长度大于所有宽度,才能实现固定表头
225
- this.scrollXWidth = totalWidth
226
- },
227
- loadTableData (requestParameters) {
228
- let data = []
229
- this.$emit('loadData', requestParameters, val => {
230
- data = val
231
- })
232
- const _this = this
233
- data.then(res => {
234
- _this.dataSource = res.data
235
- })
236
- return data
237
- },
238
- action (record) {
239
- this.$emit('action', record, record[this.jsonData[0].dataIndex])
240
- },
241
- onSelectChange (selectedRowKeys, selectedRows) {
242
- this.selectedRowKeys = selectedRowKeys
243
- this.selectedRows = selectedRows
244
- this.$emit('selectRow', selectedRowKeys)
245
- },
246
- clearRowKeys () {
247
- this.$refs.table.clearSelected()
248
- },
249
- /**
250
- * 表格重新加载方法
251
- * 如果参数为 true, 则强制刷新到第一页
252
- */
253
- refresh (bool) {
254
- this.$refs.table.refresh(bool)
255
- },
256
- format (date, format) {
257
- return formatDate(date, format)
258
- },
259
- showDrawer () {
260
- this.visible = true
261
- },
262
- toggleIsFormShow () {
263
- this.$emit('toggleIsFormShow')
264
- }
265
- }
266
- }
267
- </script>
268
- <style lang="less" scoped>
269
- </style>
1
+ <template>
2
+ <div>
3
+ <custom-columns-drawer
4
+ :columns-meta="jsonData"
5
+ :columns.sync="tableColumns"
6
+ :visible.sync="visible"/>
7
+ <a-row :gutter="48">
8
+ <a-col>
9
+ <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
10
+ <slot name="expand"></slot>
11
+ </span>
12
+ </a-col>
13
+ <a-col>
14
+ <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
15
+ <a-button-group>
16
+ <a-button @click="toggleIsFormShow">
17
+ <a-icon :style="iconStyle" type="vertical-align-top"/>
18
+ </a-button>
19
+ <a-button @click="refresh(true)">
20
+ <a-icon :style="iconStyle" type="reload" />
21
+ </a-button>
22
+ <a-button @click="showDrawer">
23
+ <a-icon :style="iconStyle" type="table" />
24
+ </a-button>
25
+ <a-button v-if="!buttonState || buttonState.export" @click="exports">
26
+ <a-icon :style="iconStyle" type="cloud-download"/>
27
+ </a-button>
28
+ </a-button-group>
29
+ </span>
30
+ </a-col>
31
+ </a-row>
32
+ <s-table
33
+ ref="table"
34
+ :alert="true"
35
+ :columns="tableColumns"
36
+ :data="loadData"
37
+ :rowKey="rowKey"
38
+ :rowSelection="rowSelection"
39
+ :scroll="{ x: scrollXWidth, y: scrollYWidth }"
40
+ showPagination="auto"
41
+ size="default"
42
+ >
43
+ <template
44
+ v-for="(item, index) in tableColumns"
45
+ :slot="item.dataIndex"
46
+ slot-scope="text, record">
47
+ <!-- 文本溢出省略(ellipsis) -->
48
+ <span v-if="item.slotType === 'ellipsis'" :key="index">
49
+ <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
50
+ </span>
51
+ <!-- 徽标(badge) -->
52
+ <span v-else-if="item.slotType === 'badge'" :key="index">
53
+ <x-badge :badge-key="item.slotKeyMap" :value="text" />
54
+ </span>
55
+ <!-- 日期(date) -->
56
+ <span v-else-if="item.slotType === 'date'" :key="index">
57
+ {{ format(text,'yyyy-MM-dd') }}
58
+ </span>
59
+ <!-- 日期时间(datetime) -->
60
+ <span v-else-if="item.slotType === 'dateTime'" :key="index">
61
+ {{ format(text,'yyyy-MM-dd hh:mm:ss') }}
62
+ </span>
63
+ <!-- 操作列(action) -->
64
+ <span v-else-if="item.slotType === 'action'" :key="index">
65
+ <a @click="action(record)">{{ item.slotValue }}</a>
66
+ </span>
67
+ </template>
68
+ </s-table>
69
+ </div>
70
+ </template>
71
+ <script>
72
+ import { Ellipsis, STable } from '@vue2-client/components'
73
+ import { formatDate } from '@vue2-client/utils/util'
74
+ import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
75
+
76
+ export default {
77
+ name: 'XTable',
78
+ components: {
79
+ STable,
80
+ Ellipsis
81
+ },
82
+ data () {
83
+ return {
84
+ // 加载数据方法 必须为 Promise 对象
85
+ loadData: parameter => {
86
+ // 取到表格携带的表单参数
87
+ const requestParameters = Object.assign({}, parameter)
88
+ // 取到父组件传入的表单参数
89
+ const conditionParams = Object.assign(this.fixedQueryForm, this.form)
90
+ // 如果适用了综合筛选表单,则进行数据处理
91
+ if (conditionParams.rowIdName) {
92
+ const rowIdName = conditionParams.rowIdName
93
+ const rowIdValue = conditionParams.rowIdValue
94
+ delete conditionParams.rowIdName
95
+ delete conditionParams.rowIdValue
96
+ if (rowIdValue) {
97
+ conditionParams[rowIdName] = rowIdValue
98
+ }
99
+ }
100
+ // 如果传了燃气公司字段,则进行数据处理
101
+ if (conditionParams.orgName) {
102
+ requestParameters.orgName = conditionParams.orgName
103
+ delete conditionParams.orgName
104
+ }
105
+ requestParameters.conditionParams = conditionParams
106
+ requestParameters.queryParamsName = this.queryParamsName
107
+ requestParameters.queryParams = this.queryParams
108
+ // 加载数据
109
+ return this.loadTableData(requestParameters)
110
+ },
111
+ rowKey: undefined,
112
+ scrollXWidth: 1600,
113
+ scrollYWidth: 437,
114
+ selectedRowKeys: [],
115
+ selectedRows: [],
116
+ // 数据列
117
+ tableColumns: this.jsonData,
118
+ // 是否显示展示列抽屉
119
+ visible: false,
120
+ dataSource: [],
121
+ // 图标样式
122
+ iconStyle: {
123
+ position: 'relative',
124
+ top: '1px'
125
+ }
126
+ }
127
+ },
128
+ watch: {
129
+ form (rel) {
130
+ this.form = rel
131
+ this.refresh(true)
132
+ },
133
+ jsonData () {
134
+ this.initTableParams()
135
+ }
136
+ },
137
+ props: {
138
+ jsonData: {
139
+ type: Array,
140
+ default: () => {
141
+ return []
142
+ }
143
+ },
144
+ queryParamsName: {
145
+ type: String,
146
+ default: () => {
147
+ return ''
148
+ }
149
+ },
150
+ // 查询参数对象, 用于没有对应查询配置文件名时
151
+ queryParams: {
152
+ type: Object,
153
+ default: null
154
+ },
155
+ form: {
156
+ type: Object,
157
+ default: () => {
158
+ return {}
159
+ }
160
+ },
161
+ // 固定查询表单
162
+ fixedQueryForm: {
163
+ type: Object,
164
+ default: () => {
165
+ return {}
166
+ }
167
+ },
168
+ // 按钮
169
+ buttonState: {
170
+ type: Object,
171
+ default: () => {
172
+ return undefined
173
+ }
174
+ }
175
+ },
176
+ computed: {
177
+ rowSelection () {
178
+ return {
179
+ selectedRowKeys: this.selectedRowKeys,
180
+ onChange: this.onSelectChange
181
+ }
182
+ }
183
+ },
184
+ mounted () {
185
+ this.initTableParams()
186
+ },
187
+ methods: {
188
+ exports () {
189
+ const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
190
+ const filterVal = this.tableColumns.map(res => res.dataIndex)
191
+ const list = this.dataSource
192
+ const data = this.formatJson(filterVal, list)
193
+ exportJson(tHeader, data, new Date())
194
+ },
195
+ formatJson (filterVal, jsonData) {
196
+ return jsonData.map(v => filterVal.map(j => v[j]))
197
+ },
198
+ badgeFilter (key, value) {
199
+ return this.$appdata.getParam(key, value)
200
+ },
201
+ initTableParams () {
202
+ let totalWidth = 0
203
+ this.rowKey = this.tableColumns[0].dataIndex
204
+ for (let i = 0; i < this.tableColumns.length; i++) {
205
+ const item = this.tableColumns[i]
206
+ if (item.dataIndex === 'action') {
207
+ item.fixed = 'right'
208
+ item.width = 70
209
+ } else {
210
+ item.sorter = true
211
+ }
212
+ if (item.width) {
213
+ totalWidth = totalWidth + item.width
214
+ } else {
215
+ totalWidth = totalWidth + 180
216
+ }
217
+ }
218
+ const width = document.documentElement.clientWidth
219
+ if (width >= 1600) {
220
+ this.scrollYWidth = 429
221
+ } else if (width >= 1200) {
222
+ this.scrollYWidth = 390
223
+ } else {
224
+ this.scrollYWidth = 343
225
+ }
226
+ // 横向滚动长度大于所有宽度,才能实现固定表头
227
+ this.scrollXWidth = totalWidth
228
+ },
229
+ loadTableData (requestParameters) {
230
+ let data = []
231
+ this.$emit('loadData', requestParameters, val => {
232
+ data = val
233
+ })
234
+ const _this = this
235
+ data.then(res => {
236
+ _this.dataSource = res.data
237
+ })
238
+ return data
239
+ },
240
+ action (record) {
241
+ this.$emit('action', record, record[this.jsonData[0].dataIndex])
242
+ },
243
+ onSelectChange (selectedRowKeys, selectedRows) {
244
+ this.selectedRowKeys = selectedRowKeys
245
+ this.selectedRows = selectedRows
246
+ this.$emit('selectRow', selectedRowKeys)
247
+ },
248
+ clearRowKeys () {
249
+ this.$refs.table.clearSelected()
250
+ },
251
+ /**
252
+ * 表格重新加载方法
253
+ * 如果参数为 true, 则强制刷新到第一页
254
+ */
255
+ refresh (bool) {
256
+ this.$refs.table.refresh(bool)
257
+ },
258
+ format (date, format) {
259
+ return formatDate(date, format)
260
+ },
261
+ showDrawer () {
262
+ this.visible = true
263
+ },
264
+ toggleIsFormShow () {
265
+ this.$emit('toggleIsFormShow')
266
+ }
267
+ }
268
+ }
269
+ </script>
270
+ <style lang="less" scoped>
271
+ </style>
@@ -190,7 +190,7 @@ export default {
190
190
  },
191
191
  props: {
192
192
  brandId: {
193
- type: String || Number,
193
+ type: Number,
194
194
  required: true
195
195
  },
196
196
  visible: {
@@ -96,8 +96,7 @@ export default {
96
96
  { key: '2', tab: '抄表' },
97
97
  { key: '3', tab: '指令' },
98
98
  { key: '4', tab: '异常' },
99
- { key: '5', tab: '指令操作' },
100
- { key: '6', tab: '设备位置' }
99
+ { key: '5', tab: '指令操作' }
101
100
  ],
102
101
  // 设备详情加载
103
102
  loadDeviceDetails: true
@@ -119,7 +119,7 @@
119
119
  </a-col>
120
120
  <a-col :span="12">
121
121
  <a-card :bordered="false" title="设备位置" :loading="loading">
122
- <AmapPointRendering :markers="details" :describeList="describeList" :mapStyle="{width: '100%',height: '381px',border: '2px solid lightgray','border-radius': '5px'}"/>
122
+ <AmapPointRendering :markers="details.f_install_lng_lat" :describeList="describeList" :mapStyle="{width: '100%',height: '381px',border: '2px solid lightgray','border-radius': '5px'}"/>
123
123
  </a-card>
124
124
  </a-col>
125
125
  </a-row>
@@ -126,7 +126,7 @@ export default {
126
126
  },
127
127
  props: {
128
128
  typeId: {
129
- type: String || Number,
129
+ type: Number,
130
130
  required: true
131
131
  },
132
132
  visible: {