vue2-client 1.7.0 → 1.7.1

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.
Files changed (126) hide show
  1. package/.env +15 -15
  2. package/CHANGELOG.md +31 -1
  3. package/Components.md +60 -0
  4. package/index.js +39 -30
  5. package/package.json +4 -2
  6. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +316 -316
  7. package/src/base-client/components/common/CitySelect/CitySelect.vue +247 -247
  8. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -667
  9. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +735 -733
  10. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +466 -468
  11. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +510 -508
  12. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +144 -146
  13. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +165 -165
  14. package/src/base-client/components/common/JSONToTree/jsontotree.vue +275 -275
  15. package/src/base-client/components/common/Upload/Upload.vue +168 -168
  16. package/src/base-client/components/common/XAddForm/XAddForm.vue +72 -325
  17. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +365 -279
  18. package/src/base-client/components/common/XAddNativeForm/index.md +96 -56
  19. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  20. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -0
  21. package/src/base-client/components/common/XDataDrawer/index.js +3 -0
  22. package/src/base-client/components/common/XDataDrawer/index.md +41 -0
  23. package/src/base-client/components/common/XForm/XForm.vue +178 -180
  24. package/src/base-client/components/common/XForm/XFormItem.vue +521 -513
  25. package/src/base-client/components/common/XForm/XTreeSelect.vue +184 -184
  26. package/src/base-client/components/common/XFormCol/XFormCol.vue +38 -38
  27. package/src/base-client/components/common/XFormTable/XFormTable.vue +356 -344
  28. package/src/base-client/components/common/XFormTable/index.md +97 -97
  29. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +132 -132
  30. package/src/base-client/components/common/XTable/XTable.vue +519 -506
  31. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +111 -111
  32. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +231 -231
  33. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  34. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +807 -807
  35. package/src/base-client/components/ticket/TicketDetailsView/index.md +29 -29
  36. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +260 -260
  37. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  38. package/src/base-client/components/ticket/TicketSubmitSuccessView/index.md +29 -29
  39. package/src/base-client/plugins/AppData.js +76 -76
  40. package/src/base-client/plugins/GetLoginInfoService.js +179 -179
  41. package/src/base-client/plugins/PagedList.js +177 -177
  42. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  43. package/src/base-client/plugins/i18n-extend.js +32 -32
  44. package/src/components/Ellipsis/Ellipsis.vue +65 -65
  45. package/src/components/Ellipsis/index.md +38 -38
  46. package/src/components/NumberInfo/index.md +43 -43
  47. package/src/components/STable/README.md +341 -341
  48. package/src/components/STable/index.js +318 -318
  49. package/src/components/Trend/index.md +45 -45
  50. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  51. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  52. package/src/components/exception/ExceptionPage.vue +70 -70
  53. package/src/components/form/FormRow.vue +52 -52
  54. package/src/components/index.js +36 -36
  55. package/src/components/menu/SideMenu.vue +62 -62
  56. package/src/components/menu/menu.js +273 -273
  57. package/src/components/page/header/index.less +40 -40
  58. package/src/components/setting/Setting.vue +235 -235
  59. package/src/components/table/StandardTable.vue +141 -141
  60. package/src/components/table/advance/ActionColumns.vue +158 -158
  61. package/src/components/table/advance/SearchArea.vue +355 -355
  62. package/src/components/tool/AStepItem.vue +60 -60
  63. package/src/components/tool/AvatarList.vue +68 -68
  64. package/src/components/tool/Drawer.vue +142 -142
  65. package/src/components/tool/TagSelect.vue +83 -83
  66. package/src/components/transition/PageToggleTransition.vue +97 -97
  67. package/src/config/CreateQueryConfig.js +307 -307
  68. package/src/config/default/admin.config.js +18 -18
  69. package/src/config/default/setting.config.js +3 -1
  70. package/src/config/replacer/resolve.config.js +67 -67
  71. package/src/layouts/CommonLayout.vue +42 -42
  72. package/src/layouts/ComponentLayoutOne.vue +47 -47
  73. package/src/layouts/PageLayout.vue +151 -151
  74. package/src/layouts/SinglePageView.vue +116 -116
  75. package/src/layouts/footer/PageFooter.vue +49 -49
  76. package/src/layouts/header/AdminHeader.vue +134 -134
  77. package/src/layouts/header/HeaderAvatar.vue +64 -64
  78. package/src/layouts/header/HeaderNotice.vue +176 -176
  79. package/src/layouts/header/HeaderSearch.vue +67 -67
  80. package/src/layouts/header/InstitutionDetail.vue +181 -181
  81. package/src/layouts/header/index.less +92 -92
  82. package/src/layouts/tabs/TabsHead.vue +190 -190
  83. package/src/layouts/tabs/TabsView.vue +379 -379
  84. package/src/mock/goods/index.js +108 -108
  85. package/src/pages/CreateQueryPage.vue +84 -84
  86. package/src/pages/login/Login.vue +369 -369
  87. package/src/pages/report/ReportTable.js +124 -124
  88. package/src/pages/report/ReportTableHome.vue +28 -28
  89. package/src/pages/resourceManage/orgListManage.vue +98 -98
  90. package/src/pages/system/dictionary/index.vue +43 -43
  91. package/src/pages/system/file/index.vue +317 -317
  92. package/src/pages/system/monitor/loginInfor/index.vue +36 -36
  93. package/src/pages/system/monitor/operLog/index.vue +36 -36
  94. package/src/pages/system/settings/index.vue +126 -126
  95. package/src/pages/system/settings/modifyPassword.vue +109 -109
  96. package/src/router/async/config.async.js +28 -28
  97. package/src/router/async/router.map.js +66 -66
  98. package/src/router/guards.js +52 -12
  99. package/src/router/index.js +27 -27
  100. package/src/services/api/DictionaryDetailsViewApi.js +6 -6
  101. package/src/services/api/LogDetailsViewApi.js +10 -10
  102. package/src/services/api/QueryParamsDetailsViewApi.js +6 -6
  103. package/src/services/api/TicketDetailsViewApi.js +34 -34
  104. package/src/services/api/cas.js +79 -79
  105. package/src/services/api/common.js +137 -137
  106. package/src/services/api/commonTempTable.js +10 -10
  107. package/src/services/api/index.js +17 -17
  108. package/src/services/api/logininfor/index.js +6 -6
  109. package/src/services/api/manage.js +8 -8
  110. package/src/services/apiService.js +14 -14
  111. package/src/services/user.js +67 -67
  112. package/src/store/modules/index.js +4 -4
  113. package/src/theme/default/nprogress.less +76 -76
  114. package/src/theme/default/style.less +58 -58
  115. package/src/utils/EncryptUtil.js +53 -53
  116. package/src/utils/colors.js +107 -107
  117. package/src/utils/excel/Blob.js +180 -180
  118. package/src/utils/excel/Export2Excel.js +141 -141
  119. package/src/utils/formatter.js +68 -68
  120. package/src/utils/i18n.js +80 -80
  121. package/src/utils/login.js +138 -0
  122. package/src/utils/map-utils.js +37 -37
  123. package/src/utils/theme-color-replacer-extend.js +91 -91
  124. package/src/utils/themeUtil.js +100 -100
  125. package/src/utils/util.js +230 -230
  126. package/vue.config.js +106 -106
@@ -1,506 +1,519 @@
1
- <template>
2
- <div v-show="tableColumns.length > 0">
3
- <a-row :gutter="48">
4
- <a-col>
5
- <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
6
- <a-space>
7
- <a-button v-if="!buttonState || buttonState.add" type="primary" @click="add">
8
- <a-icon :style="iconStyle" type="plus"/>新增
9
- </a-button>
10
- <a-button
11
- v-if="!buttonState || buttonState.edit"
12
- :disabled="!isModify"
13
- :loading="editLoading"
14
- class="btn-success"
15
- type="dashed"
16
- @click="edit()">
17
- <a-icon :style="iconStyle" type="edit"/>修改
18
- </a-button>
19
- <a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
20
- <a-icon :style="iconStyle" type="delete"/>删除
21
- </a-button>
22
- <a-button v-if="!buttonState || buttonState.import" type="dashed" @click="importData">
23
- <a-icon :style="iconStyle" type="import" />导入
24
- </a-button>
25
- <a-dropdown v-if="!buttonState || buttonState.export">
26
- <a-menu slot="overlay">
27
- <a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon :style="iconStyle" type="ordered-list" />导出选中数据</a-menu-item>
28
- <a-menu-item key="2" @click="handleExport(false)"><a-icon :style="iconStyle" type="snippets" />导出本页数据</a-menu-item>
29
- <a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download" />导出所有符合条件的数据</a-menu-item>
30
- </a-menu>
31
- <a-button>导出 <a-icon type="down" /> </a-button>
32
- </a-dropdown>
33
- <slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
34
- </a-space>
35
- </span>
36
- </a-col>
37
- <a-col>
38
- <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
39
- <a-button-group>
40
- <slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
41
- <a-button @click="refresh(true)">
42
- <a-icon :style="iconStyle" type="reload" />
43
- </a-button>
44
- <table-setting v-if="columnSelectLoaded" v-model="tableColumns" />
45
- </a-button-group>
46
- </span>
47
- </a-col>
48
- </a-row>
49
- <s-table
50
- ref="table"
51
- :alert="true"
52
- :columns="tableColumns"
53
- :data="loadData"
54
- :rowKey="rowKey"
55
- :rowSelection="rowSelection"
56
- :scroll="{ x: scrollXWidth, y: scrollYHeight }"
57
- :showPagination="showPagination"
58
- size="default"
59
- >
60
- <template
61
- v-for="(item, index) in tableColumns"
62
- :slot="item.dataIndex"
63
- slot-scope="text, record">
64
- <!-- 文本溢出省略(ellipsis) -->
65
- <span v-if="item.slotType === 'ellipsis'" :key="index">
66
- <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
67
- </span>
68
- <!-- 徽标(badge) -->
69
- <span v-else-if="item.slotType === 'badge'" :key="index">
70
- <x-badge v-if="text !== null && text !== undefined" :badge-key="item.slotKeyMap" :value="text" />
71
- </span>
72
- <!-- 日期(date) -->
73
- <span v-else-if="item.slotType === 'date'" :key="index">
74
- {{ format(text,'yyyy-MM-dd') }}
75
- </span>
76
- <!-- 日期时间(datetime) -->
77
- <span v-else-if="item.slotType === 'dateTime'" :key="index">
78
- {{ format(text,'yyyy-MM-dd hh:mm:ss') }}
79
- </span>
80
- <!-- 操作列(action) -->
81
- <span v-else-if="item.slotType === 'action'" :key="index">
82
- <a @click="action(record, item.dataIndex)">{{ item.slotValue }}</a>
83
- </span>
84
- </template>
85
- <template slot="footer">
86
- <slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
87
- </template>
88
- </s-table>
89
- <!-- 上传文件 -->
90
- <x-import-excel
91
- ref="importExcel"
92
- @ok="refresh(true)"
93
- :title="title"
94
- :service-name="serviceName"
95
- :query-params-name="queryParamsName"
96
- />
97
- </div>
98
- </template>
99
- <script>
100
- import { Ellipsis, STable } from '@vue2-client/components'
101
- import { formatDate } from '@vue2-client/utils/util'
102
- import XBadge from '@vue2-client/base-client/components/common/XBadge'
103
- import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
104
- import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
105
- import { exportData, query, queryWithResource, remove } from '@vue2-client/services/api/common'
106
- import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
107
- import { Modal } from 'ant-design-vue'
108
- import { post } from '@vue2-client/services/api'
109
- import { CommonTempTable } from '@vue2-client/services/api/commonTempTable'
110
-
111
- export default {
112
- name: 'XTable',
113
- components: {
114
- TableSetting,
115
- STable,
116
- Ellipsis,
117
- XBadge,
118
- XImportExcel
119
- },
120
- data () {
121
- return {
122
- // 筛选列加载状态
123
- columnSelectLoaded: false,
124
- // 预览模式
125
- viewMode: false,
126
- // 加载数据方法 必须为 Promise 对象
127
- loadData: parameter => {
128
- // 取到表格携带的表单参数
129
- const requestParameters = Object.assign({}, parameter)
130
- // 取到父组件传入的表单参数
131
- const conditionParams = Object.assign(this.form, this.fixedQueryForm)
132
- // 如果传了燃气公司字段,则进行数据处理
133
- if (conditionParams.orgName) {
134
- requestParameters.orgName = conditionParams.orgName
135
- delete conditionParams.orgName
136
- }
137
- requestParameters.conditionParams = conditionParams
138
- requestParameters.queryParamsName = this.queryParamsName
139
- requestParameters.queryParams = this.queryParams
140
- // 加载数据
141
- return this.loadTableData(requestParameters)
142
- },
143
- rowKey: undefined,
144
- // x滚动条宽度
145
- scrollXWidth: 1600,
146
- // y滚动条高度
147
- scrollYHeight: 437,
148
- // 表格选择列Key集合
149
- selectedRowKeys: [],
150
- // 表格选择Row集合
151
- selectedRows: [],
152
- // 业务标题
153
- title: '',
154
- // 数据列
155
- tableColumns: [],
156
- // 查询用表单
157
- form: {},
158
- // 是否允许修改
159
- isModify: false,
160
- // 是否允许删除
161
- isDelete: false,
162
- // 服务名称
163
- serviceName: 'system',
164
- // 选中用于修改的id
165
- selectId: undefined,
166
- // 是否为临时表
167
- isTableTemp: false,
168
- // 是否显示展示列抽屉
169
- visible: false,
170
- // 编辑按钮加载状态
171
- editLoading: false,
172
- // 按钮状态
173
- buttonState: {},
174
- // 图标样式
175
- iconStyle: {
176
- position: 'relative',
177
- top: '1px'
178
- }
179
- }
180
- },
181
- props: {
182
- // 查询配置文件名
183
- queryParamsName: {
184
- type: String,
185
- default: () => {
186
- return ''
187
- }
188
- },
189
- // 查询配置文件Json
190
- queryParamsJson: {
191
- type: Object,
192
- default: null
193
- },
194
- // 固定查询表单
195
- fixedQueryForm: {
196
- type: Object,
197
- default: () => {
198
- return {}
199
- }
200
- },
201
- // 数据只有一页时是否展示分页,true:展示,auto:隐藏
202
- showPagination: {
203
- type: Boolean,
204
- default: true
205
- }
206
- },
207
- computed: {
208
- rowSelection () {
209
- return {
210
- selectedRowKeys: this.selectedRowKeys,
211
- onChange: this.onSelectChange
212
- }
213
- }
214
- },
215
- mounted () {},
216
- methods: {
217
- /**
218
- * 初始化表格参数
219
- */
220
- init (params) {
221
- const {
222
- // 查询参数对象, 用于没有对应查询配置文件名时
223
- queryParams,
224
- tableColumns,
225
- buttonState,
226
- title,
227
- serviceName = 'system',
228
- viewMode
229
- } = params
230
- this.queryParams = queryParams
231
- this.tableColumns = JSON.parse(JSON.stringify(tableColumns))
232
- if (this.tableColumns.length === 0) {
233
- return
234
- }
235
- this.buttonState = buttonState
236
- this.title = title
237
- this.serviceName = serviceName
238
- this.viewMode = viewMode
239
- this.rowKey = this.tableColumns[0].dataIndex
240
- let totalWidth = 0
241
- // 设置表格宽度
242
- for (let i = 0; i < this.tableColumns.length; i++) {
243
- const item = this.tableColumns[i]
244
- if (item.slotType === 'action') {
245
- item.fixed = 'right'
246
- item.width = 70
247
- }
248
- if (item.width) {
249
- totalWidth = totalWidth + item.width
250
- } else {
251
- totalWidth = totalWidth + 180
252
- }
253
- }
254
- // 设置表格高度
255
- const height = document.documentElement.clientHeight
256
- if (height >= 1070) {
257
- this.scrollYHeight = 'calc(100vh - 526px)'
258
- } else {
259
- this.scrollYHeight = 'calc(100vh - 398px)'
260
- }
261
- // 横向滚动长度大于所有宽度,才能实现固定表头
262
- this.scrollXWidth = totalWidth
263
- // 加载筛选列完成
264
- this.columnSelectLoaded = true
265
- this.setQueryForm({})
266
- },
267
- /**
268
- * 加载表格数据
269
- * @param requestParameters 请求参数
270
- */
271
- loadTableData (requestParameters) {
272
- let result = {}
273
- if (this.queryParamsJson) {
274
- if (this.queryParamsJson.tableName.startsWith('##')) {
275
- this.isTableTemp = true
276
- result = this.initTempTable(requestParameters)
277
- }
278
- }
279
- if (!this.isTableTemp) {
280
- result = query(requestParameters, this.serviceName)
281
- }
282
- this.clearRowKeys()
283
- this.$emit('afterQuery', result, requestParameters.conditionParams)
284
- return result
285
- },
286
- action (record, actionType) {
287
- this.$emit('action', record, record[this.getPrimaryKeyName()], actionType)
288
- },
289
- onSelectChange (selectedRowKeys, selectedRows) {
290
- this.selectedRowKeys = selectedRowKeys
291
- this.selectedRows = selectedRows
292
- this.isModify = this.selectedRowKeys.length === 1
293
- this.isDelete = this.selectedRowKeys.length > 0
294
- this.$emit('selectRow', selectedRowKeys, selectedRows)
295
- },
296
- /**
297
- * 清除表格选中项
298
- */
299
- clearRowKeys () {
300
- this.$refs.table.clearSelected()
301
- },
302
- /**
303
- * 为表格附加查询条件
304
- */
305
- setQueryForm (form = {}) {
306
- this.form = form
307
- this.refresh(true)
308
- },
309
- /**
310
- * 表格重新加载方法
311
- * 如果参数为 true, 则强制刷新到第一页
312
- */
313
- refresh (bool) {
314
- this.$refs.table.refresh(bool)
315
- },
316
- format (date, format) {
317
- return formatDate(date, format)
318
- },
319
- showDrawer () {
320
- this.visible = true
321
- },
322
- /**
323
- * 获取主键列名称
324
- */
325
- getPrimaryKeyName () {
326
- return this.tableColumns[0].dataIndex
327
- },
328
- // 导出选中或本页数据
329
- handleExport (isSelected) {
330
- const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
331
- const filterVal = this.tableColumns.map(res => res.dataIndex)
332
- let exportData
333
- if (isSelected) {
334
- exportData = this.selectedRows
335
- } else {
336
- exportData = this.$refs.table.localDataSource
337
- }
338
- const data = this.formatJson(filterVal, exportData)
339
- exportJson(tHeader, data, this.title + `数据_${new Date().toLocaleString()}`)
340
- },
341
- // 导出符合条件的数据
342
- handleExportByQuery () {
343
- const that = this
344
- const conditionParams = Object.assign(that.form, that.fixedQueryForm)
345
- this.$confirm({
346
- title: '是否确认导出?',
347
- content: '此操作将导出当前条件下所有数据而非选中数据',
348
- onOk () {
349
- exportData({
350
- queryParamsName: that.queryParamsName,
351
- queryParams: that.queryParams,
352
- form: conditionParams
353
- }, that.serviceName).then(res => {
354
- window.open('/res/excel/export/' + res.value)
355
- })
356
- },
357
- onCancel () {}
358
- })
359
- },
360
- // 新增业务
361
- add () {
362
- this.$emit('add')
363
- },
364
- // 编辑业务
365
- edit (id) {
366
- this.editLoading = true
367
- // 组织被编辑数据
368
- const requestParameters = {
369
- queryParamsName: this.queryParamsName,
370
- queryParams: this.queryParams,
371
- conditionParams: {},
372
- pageNo: 1,
373
- pageSize: 1
374
- }
375
- if (!id) {
376
- this.selectId = this.selectedRowKeys[0]
377
- } else {
378
- this.selectId = id
379
- }
380
- const primaryKeyName = this.getPrimaryKeyName()
381
- requestParameters.conditionParams[primaryKeyName] = this.selectId
382
- requestParameters.f_businessid = this.selectId
383
- if (this.isTableTemp) {
384
- this.$emit('tempTableEdit', requestParameters)
385
- return
386
- }
387
- queryWithResource(requestParameters, this.serviceName).then(res => {
388
- // 将更新需要的主键值加入到primaryKeyData中
389
- const primaryKeyData = {}
390
- primaryKeyData[primaryKeyName] = this.selectId
391
- const modifyModelData = { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
392
- this.$emit('edit', modifyModelData)
393
- this.editLoading = false
394
- })
395
- },
396
- // 删除业务
397
- deleteItem () {
398
- if (this.viewMode) {
399
- this.$message.info('预览模式禁止删除')
400
- return
401
- }
402
- Modal.confirm({
403
- title: '提示',
404
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
405
- zIndex: 1001,
406
- onOk: () => {
407
- return new Promise((resolve, reject) => {
408
- const requestParameters = {
409
- queryParamsName: this.queryParamsName,
410
- idList: this.selectedRowKeys
411
- }
412
- remove(requestParameters, this.serviceName).then(res => {
413
- resolve(res)
414
- this.$message.success('删除成功!')
415
- this.refresh(true)
416
- // afterDelete
417
- this.$emit('afterDelete', requestParameters)
418
- }).catch(e => {
419
- reject(e)
420
- this.$message.error('删除失败!')
421
- })
422
- })
423
- },
424
- onCancel () {}
425
- })
426
- },
427
- // 导入业务
428
- importData () {
429
- this.$refs.importExcel.importExcelHandleOpen()
430
- },
431
- formatJson (filterVal, jsonData) {
432
- return jsonData.map(v => filterVal.map(j => v[j]))
433
- },
434
- // 初始化临时表
435
- async initTempTable (json) {
436
- await this.createTempTable(this.queryParamsJson)
437
- await this.insertTempTableData(this.queryParamsJson)
438
- let result = {}
439
- await post(CommonTempTable.initApplySubTable, {
440
- define: json
441
- }).then(res => {
442
- console.log('子表临时表已创建')
443
- result = res
444
- })
445
- return result
446
- },
447
- // 创建临时表sql生成
448
- createTempTable (defineJson) {
449
- const tableName = defineJson.tableName
450
- const define = defineJson.column
451
- return post(CommonTempTable.createTempTable, {
452
- define: define,
453
- tableName: tableName
454
- }).then(res => {
455
- return res
456
- }, err => {
457
- console.log(err)
458
- })
459
- },
460
- // 插入临时表数据sql生成
461
- insertTempTableData (defineJson) {
462
- const tableName = defineJson.tableName
463
- const params = {}
464
- params.define = defineJson.column
465
- params.applyId = defineJson.applyId
466
- params.stepName = defineJson.stepName
467
- params.tableName = tableName
468
- return post(CommonTempTable.insertDataToTempTable, {
469
- tempTableData: params
470
- }).then(res => {
471
- return res
472
- })
473
- }
474
- }
475
- }
476
- </script>
477
- <style lang="less" scoped>
478
- .btn-success {
479
- color: #ffffff;
480
- }
481
- .btn-success:enabled:hover {
482
- background-color: #85CE61 !important;
483
- border-color: #85CE61 !important;
484
- }
485
- .btn-success:enabled {
486
- background-color: #67c23a;
487
- border-color: #67c23a;
488
- }
489
- .btn-success:disabled {
490
- color: rgba(0, 0, 0, 0.25);
491
- }
492
- .btn-warn {
493
- color: #ffffff;
494
- }
495
- .btn-warn:enabled:hover {
496
- background-color: #ffc833 !important;
497
- border-color: #ffc833 !important;
498
- }
499
- .btn-warn:enabled {
500
- background-color: #ffba00;
501
- border-color: #ffba00;
502
- }
503
- .btn-warn:disabled {
504
- color: rgba(0, 0, 0, 0.25);
505
- }
506
- </style>
1
+ <template>
2
+ <div v-show="tableColumns.length > 0">
3
+ <a-row :gutter="48">
4
+ <a-col>
5
+ <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
6
+ <a-space>
7
+ <slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
8
+ <a-button v-if="!buttonState || buttonState.add" type="primary" @click="add">
9
+ <a-icon :style="iconStyle" type="plus"/>新增
10
+ </a-button>
11
+ <a-button
12
+ v-if="!buttonState || buttonState.edit"
13
+ :disabled="!isModify"
14
+ :loading="editLoading"
15
+ class="btn-success"
16
+ type="dashed"
17
+ @click="edit()">
18
+ <a-icon :style="iconStyle" type="edit"/>修改
19
+ </a-button>
20
+ <a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
21
+ <a-icon :style="iconStyle" type="delete"/>删除
22
+ </a-button>
23
+ <a-button v-if="!buttonState || buttonState.import" type="dashed" @click="importData">
24
+ <a-icon :style="iconStyle" type="import" />导入
25
+ </a-button>
26
+ <a-dropdown v-if="!buttonState || buttonState.export">
27
+ <a-menu slot="overlay">
28
+ <a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon :style="iconStyle" type="ordered-list" />导出选中数据</a-menu-item>
29
+ <a-menu-item key="2" @click="handleExport(false)"><a-icon :style="iconStyle" type="snippets" />导出本页数据</a-menu-item>
30
+ <a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download" />导出所有符合条件的数据</a-menu-item>
31
+ </a-menu>
32
+ <a-button>导出 <a-icon type="down" /> </a-button>
33
+ </a-dropdown>
34
+ <slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
35
+ </a-space>
36
+ </span>
37
+ </a-col>
38
+ <a-col>
39
+ <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
40
+ <a-button-group>
41
+ <slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
42
+ <a-button @click="refresh(true)">
43
+ <a-icon :style="iconStyle" type="reload" />
44
+ </a-button>
45
+ <table-setting v-if="columnSelectLoaded" v-model="tableColumns" />
46
+ </a-button-group>
47
+ </span>
48
+ </a-col>
49
+ </a-row>
50
+ <s-table
51
+ ref="table"
52
+ :alert="true"
53
+ :columns="tableColumns"
54
+ :data="loadData"
55
+ :rowKey="rowKey"
56
+ :rowSelection="rowSelection"
57
+ :scroll="{ x: scrollXWidth, y: scrollYHeight }"
58
+ :showPagination="showPagination"
59
+ size="default"
60
+ >
61
+ <template
62
+ v-for="(item, index) in tableColumns"
63
+ :slot="item.dataIndex"
64
+ slot-scope="text, record">
65
+ <!-- 文本溢出省略(ellipsis) -->
66
+ <span v-if="item.slotType === 'ellipsis'" :key="index">
67
+ <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
68
+ </span>
69
+ <!-- 徽标(badge) -->
70
+ <span v-else-if="item.slotType === 'badge'" :key="index">
71
+ <x-badge v-if="text !== null && text !== undefined" :badge-key="item.slotKeyMap" :value="text" />
72
+ </span>
73
+ <!-- 日期(date) -->
74
+ <span v-else-if="item.slotType === 'date'" :key="index">
75
+ {{ format(text,'yyyy-MM-dd') }}
76
+ </span>
77
+ <!-- 日期时间(datetime) -->
78
+ <span v-else-if="item.slotType === 'dateTime'" :key="index">
79
+ {{ format(text,'yyyy-MM-dd hh:mm:ss') }}
80
+ </span>
81
+ <!-- 操作列(action) -->
82
+ <span v-else-if="item.slotType === 'action'" :key="index">
83
+ <a @click="action(record, item.dataIndex)">{{ item.slotValue }}</a>
84
+ </span>
85
+ </template>
86
+ <template slot="footer">
87
+ <slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
88
+ </template>
89
+ </s-table>
90
+ <!-- 上传文件 -->
91
+ <x-import-excel
92
+ ref="importExcel"
93
+ @ok="refresh(true)"
94
+ :title="title"
95
+ :service-name="serviceName"
96
+ :query-params-name="queryParamsName"
97
+ />
98
+ </div>
99
+ </template>
100
+ <script>
101
+ import { Ellipsis, STable } from '@vue2-client/components'
102
+ import { formatDate } from '@vue2-client/utils/util'
103
+ import XBadge from '@vue2-client/base-client/components/common/XBadge'
104
+ import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
105
+ import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
106
+ import { exportData, query, queryWithResource, remove } from '@vue2-client/services/api/common'
107
+ import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
108
+ import { Modal } from 'ant-design-vue'
109
+ import { post } from '@vue2-client/services/api'
110
+ import { CommonTempTable } from '@vue2-client/services/api/commonTempTable'
111
+
112
+ export default {
113
+ name: 'XTable',
114
+ components: {
115
+ TableSetting,
116
+ STable,
117
+ Ellipsis,
118
+ XBadge,
119
+ XImportExcel
120
+ },
121
+ data () {
122
+ return {
123
+ // 筛选列加载状态
124
+ columnSelectLoaded: false,
125
+ // 预览模式
126
+ viewMode: false,
127
+ // 加载数据方法 必须为 Promise 对象
128
+ loadData: parameter => {
129
+ // 取到表格携带的表单参数
130
+ const requestParameters = Object.assign({}, parameter)
131
+ // 取到父组件传入的表单参数
132
+ const conditionParams = Object.assign(this.form, this.fixedQueryForm)
133
+ // 如果传了燃气公司字段,则进行数据处理
134
+ if (conditionParams.orgName) {
135
+ requestParameters.orgName = conditionParams.orgName
136
+ delete conditionParams.orgName
137
+ }
138
+ requestParameters.conditionParams = conditionParams
139
+ requestParameters.queryParamsName = this.queryParamsName
140
+ requestParameters.queryParams = this.queryParams
141
+ // 加载数据
142
+ return this.loadTableData(requestParameters)
143
+ },
144
+ rowKey: undefined,
145
+ // x滚动条宽度
146
+ scrollXWidth: 1600,
147
+ // y滚动条高度
148
+ scrollYHeight: 437,
149
+ // 表格选择列Key集合
150
+ selectedRowKeys: [],
151
+ // 表格选择Row集合
152
+ selectedRows: [],
153
+ // 业务标题
154
+ title: '',
155
+ // 数据列
156
+ tableColumns: [],
157
+ // 查询用表单
158
+ form: {},
159
+ // 是否允许修改
160
+ isModify: false,
161
+ // 是否允许删除
162
+ isDelete: false,
163
+ // 服务名称
164
+ serviceName: 'system',
165
+ // 选中用于修改的id
166
+ selectId: undefined,
167
+ // 是否为临时表
168
+ isTableTemp: false,
169
+ // 是否显示展示列抽屉
170
+ visible: false,
171
+ // 编辑按钮加载状态
172
+ editLoading: false,
173
+ // 按钮状态
174
+ buttonState: {},
175
+ // 图标样式
176
+ iconStyle: {
177
+ position: 'relative',
178
+ top: '1px'
179
+ }
180
+ }
181
+ },
182
+ props: {
183
+ // 查询配置文件名
184
+ queryParamsName: {
185
+ type: String,
186
+ default: () => {
187
+ return ''
188
+ }
189
+ },
190
+ // 查询配置文件Json
191
+ queryParamsJson: {
192
+ type: Object,
193
+ default: null
194
+ },
195
+ // 固定查询表单
196
+ fixedQueryForm: {
197
+ type: Object,
198
+ default: () => {
199
+ return {}
200
+ }
201
+ },
202
+ // 数据只有一页时是否展示分页,true:展示,auto:隐藏
203
+ showPagination: {
204
+ type: Boolean,
205
+ default: true
206
+ }
207
+ },
208
+ computed: {
209
+ rowSelection () {
210
+ return {
211
+ selectedRowKeys: this.selectedRowKeys,
212
+ onChange: this.onSelectChange
213
+ }
214
+ }
215
+ },
216
+ mounted () {},
217
+ methods: {
218
+ /**
219
+ * 初始化表格参数
220
+ */
221
+ init (params) {
222
+ const {
223
+ // 查询参数对象, 用于没有对应查询配置文件名时
224
+ queryParams,
225
+ tableColumns,
226
+ buttonState,
227
+ title,
228
+ serviceName = 'system',
229
+ viewMode
230
+ } = params
231
+ this.queryParams = queryParams
232
+ this.tableColumns = JSON.parse(JSON.stringify(tableColumns))
233
+ if (this.tableColumns.length === 0) {
234
+ return
235
+ }
236
+ this.buttonState = buttonState
237
+ this.title = title
238
+ this.serviceName = serviceName
239
+ this.viewMode = viewMode
240
+ this.rowKey = this.tableColumns[0].dataIndex
241
+ let totalWidth = 0
242
+ // 设置表格宽度
243
+ for (let i = 0; i < this.tableColumns.length; i++) {
244
+ const item = this.tableColumns[i]
245
+ if (item.slotType === 'action') {
246
+ item.fixed = 'right'
247
+ item.width = 70
248
+ }
249
+ if (item.width) {
250
+ totalWidth = totalWidth + item.width
251
+ } else {
252
+ totalWidth = totalWidth + 180
253
+ }
254
+ }
255
+ // 设置表格高度
256
+ const height = document.documentElement.clientHeight
257
+ if (height >= 1070) {
258
+ this.scrollYHeight = 'calc(100vh - 526px)'
259
+ } else {
260
+ this.scrollYHeight = 'calc(100vh - 398px)'
261
+ }
262
+ // 横向滚动长度大于所有宽度,才能实现固定表头
263
+ this.scrollXWidth = totalWidth
264
+ // 加载筛选列完成
265
+ this.columnSelectLoaded = true
266
+ this.setQueryForm({})
267
+ },
268
+ /**
269
+ * 加载表格数据
270
+ * @param requestParameters 请求参数
271
+ */
272
+ loadTableData (requestParameters) {
273
+ let result = {}
274
+ if (this.queryParamsJson) {
275
+ if (this.queryParamsJson.tableName.startsWith('##')) {
276
+ this.isTableTemp = true
277
+ result = this.initTempTable(requestParameters)
278
+ }
279
+ }
280
+ if (!this.isTableTemp) {
281
+ result = query(requestParameters, this.serviceName)
282
+ }
283
+ this.clearRowKeys()
284
+ this.$emit('afterQuery', result, requestParameters.conditionParams)
285
+ return result
286
+ },
287
+ /**
288
+ * 操作列事件
289
+ * @param record 本条数据
290
+ * @param actionType 操作类型
291
+ */
292
+ action (record, actionType) {
293
+ this.$emit('action', record, record[this.getPrimaryKeyName()], actionType)
294
+ },
295
+ /**
296
+ * 选择列事件
297
+ * @param selectedRowKeys 被选择的列Key集合
298
+ * @param selectedRows 被选择的列集合
299
+ */
300
+ onSelectChange (selectedRowKeys, selectedRows) {
301
+ this.selectedRowKeys = selectedRowKeys
302
+ this.selectedRows = selectedRows
303
+ this.isModify = this.selectedRowKeys.length === 1
304
+ this.isDelete = this.selectedRowKeys.length > 0
305
+ this.$emit('selectRow', selectedRowKeys, selectedRows)
306
+ },
307
+ /**
308
+ * 清除表格选中项
309
+ */
310
+ clearRowKeys () {
311
+ this.$refs.table.clearSelected()
312
+ },
313
+ /**
314
+ * 为表格附加查询条件
315
+ */
316
+ setQueryForm (form = {}) {
317
+ this.form = form
318
+ this.refresh(true)
319
+ },
320
+ /**
321
+ * 表格重新加载方法
322
+ * 如果参数为 true, 则强制刷新到第一页
323
+ */
324
+ refresh (bool) {
325
+ this.$refs.table.refresh(bool)
326
+ },
327
+ /**
328
+ * 格式化日期
329
+ * @param date 日期字符串
330
+ * @param format 格式化方式
331
+ */
332
+ format (date, format) {
333
+ return formatDate(date, format)
334
+ },
335
+ /**
336
+ * 获取主键列名称
337
+ */
338
+ getPrimaryKeyName () {
339
+ return this.tableColumns[0].dataIndex
340
+ },
341
+ // 导出选中或本页数据
342
+ handleExport (isSelected) {
343
+ const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
344
+ const filterVal = this.tableColumns.map(res => res.dataIndex)
345
+ let exportData
346
+ if (isSelected) {
347
+ exportData = this.selectedRows
348
+ } else {
349
+ exportData = this.$refs.table.localDataSource
350
+ }
351
+ exportJson(tHeader, exportData.map(v => filterVal.map(j => v[j])), this.title + `数据_${new Date().toLocaleString()}`)
352
+ },
353
+ // 导出符合条件的数据
354
+ handleExportByQuery () {
355
+ const that = this
356
+ const conditionParams = Object.assign(that.form, that.fixedQueryForm)
357
+ this.$confirm({
358
+ title: '是否确认导出?',
359
+ content: '此操作将导出当前条件下所有数据而非选中数据',
360
+ onOk () {
361
+ exportData({
362
+ queryParamsName: that.queryParamsName,
363
+ queryParams: that.queryParams,
364
+ form: conditionParams
365
+ }, that.serviceName).then(res => {
366
+ window.open('/res/excel/export/' + res.value)
367
+ })
368
+ },
369
+ onCancel () {}
370
+ })
371
+ },
372
+ // 新增业务
373
+ add () {
374
+ this.$emit('add')
375
+ },
376
+ // 编辑业务
377
+ edit (id) {
378
+ this.editLoading = true
379
+ this.getEditData(id).then(modifyModelData => {
380
+ this.$emit('edit', modifyModelData)
381
+ this.editLoading = false
382
+ })
383
+ },
384
+ // 获取被编辑的数据
385
+ getEditData (id) {
386
+ const requestParameters = {
387
+ queryParamsName: this.queryParamsName,
388
+ queryParams: this.queryParams,
389
+ conditionParams: {},
390
+ pageNo: 1,
391
+ pageSize: 1
392
+ }
393
+ if (!id) {
394
+ this.selectId = this.selectedRowKeys[0]
395
+ } else {
396
+ this.selectId = id
397
+ }
398
+ const primaryKeyName = this.getPrimaryKeyName()
399
+ requestParameters.conditionParams[primaryKeyName] = this.selectId
400
+ requestParameters.f_businessid = this.selectId
401
+ if (this.isTableTemp) {
402
+ this.$emit('tempTableEdit', requestParameters)
403
+ return
404
+ }
405
+ return queryWithResource(requestParameters, this.serviceName).then(res => {
406
+ // 将更新需要的主键值加入到primaryKeyData中
407
+ const primaryKeyData = {}
408
+ primaryKeyData[primaryKeyName] = this.selectId
409
+ return { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
410
+ })
411
+ },
412
+ // 删除业务
413
+ deleteItem () {
414
+ if (this.viewMode) {
415
+ this.$message.info('预览模式禁止删除')
416
+ return
417
+ }
418
+ Modal.confirm({
419
+ title: '提示',
420
+ content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
421
+ zIndex: 1001,
422
+ onOk: () => {
423
+ return new Promise((resolve, reject) => {
424
+ const requestParameters = {
425
+ queryParamsName: this.queryParamsName,
426
+ idList: this.selectedRowKeys
427
+ }
428
+ remove(requestParameters, this.serviceName).then(res => {
429
+ resolve(res)
430
+ this.$message.success('删除成功!')
431
+ this.refresh(true)
432
+ // afterDelete
433
+ this.$emit('afterDelete', requestParameters)
434
+ }).catch(e => {
435
+ reject(e)
436
+ this.$message.error('删除失败!')
437
+ })
438
+ })
439
+ },
440
+ onCancel () {}
441
+ })
442
+ },
443
+ // 导入业务
444
+ importData () {
445
+ this.$refs.importExcel.importExcelHandleOpen()
446
+ },
447
+ // 初始化临时表
448
+ async initTempTable (json) {
449
+ await this.createTempTable(this.queryParamsJson)
450
+ await this.insertTempTableData(this.queryParamsJson)
451
+ let result = {}
452
+ await post(CommonTempTable.initApplySubTable, {
453
+ define: json
454
+ }).then(res => {
455
+ console.log('子表临时表已创建')
456
+ result = res
457
+ })
458
+ return result
459
+ },
460
+ // 创建临时表sql生成
461
+ createTempTable (defineJson) {
462
+ const tableName = defineJson.tableName
463
+ const define = defineJson.column
464
+ return post(CommonTempTable.createTempTable, {
465
+ define: define,
466
+ tableName: tableName
467
+ }).then(res => {
468
+ return res
469
+ }, err => {
470
+ console.log(err)
471
+ })
472
+ },
473
+ // 插入临时表数据sql生成
474
+ insertTempTableData (defineJson) {
475
+ const tableName = defineJson.tableName
476
+ const params = {}
477
+ params.define = defineJson.column
478
+ params.applyId = defineJson.applyId
479
+ params.stepName = defineJson.stepName
480
+ params.tableName = tableName
481
+ return post(CommonTempTable.insertDataToTempTable, {
482
+ tempTableData: params
483
+ }).then(res => {
484
+ return res
485
+ })
486
+ }
487
+ }
488
+ }
489
+ </script>
490
+ <style lang="less" scoped>
491
+ .btn-success {
492
+ color: #ffffff;
493
+ }
494
+ .btn-success:enabled:hover {
495
+ background-color: #85CE61 !important;
496
+ border-color: #85CE61 !important;
497
+ }
498
+ .btn-success:enabled {
499
+ background-color: #67c23a;
500
+ border-color: #67c23a;
501
+ }
502
+ .btn-success:disabled {
503
+ color: rgba(0, 0, 0, 0.25);
504
+ }
505
+ .btn-warn {
506
+ color: #ffffff;
507
+ }
508
+ .btn-warn:enabled:hover {
509
+ background-color: #ffc833 !important;
510
+ border-color: #ffc833 !important;
511
+ }
512
+ .btn-warn:enabled {
513
+ background-color: #ffba00;
514
+ border-color: #ffba00;
515
+ }
516
+ .btn-warn:disabled {
517
+ color: rgba(0, 0, 0, 0.25);
518
+ }
519
+ </style>