vue2-client 1.3.24 → 1.4.0
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 +12 -1
- package/package.json +78 -76
- package/src/base-client/components/common/CreateQuery/CreateQuery.vue +543 -551
- package/src/base-client/components/common/Upload/Upload.vue +168 -167
- package/src/base-client/components/common/XFormTable/XFormTable.vue +113 -76
- package/src/base-client/components/common/XImportExcel/XImportExcel.vue +131 -0
- package/src/base-client/components/common/XImportExcel/index.js +3 -0
- package/src/base-client/components/common/XImportExcel/index.md +38 -0
- package/src/base-client/components/common/XTable/XTable.vue +259 -278
- package/src/components/TableSetting/TableSetting.vue +143 -0
- package/src/components/TableSetting/index.js +3 -0
- package/src/pages/login/Login.vue +360 -361
- package/src/pages/system/ticket/index.vue +1 -1
- package/src/services/api/common.js +123 -58
- package/src/utils/common.js +10 -0
- package/src/utils/errorCode.js +6 -0
- package/src/base-client/components/common/CustomColumnsDrawer/CustomColumnsDrawer.vue +0 -109
- package/src/base-client/components/common/CustomColumnsDrawer/index.js +0 -3
- package/src/base-client/components/common/CustomColumnsDrawer/index.md +0 -46
|
@@ -1,167 +1,168 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<a-upload-dragger
|
|
4
|
-
v-if="model.type === 'file'"
|
|
5
|
-
:accept="model.accept.join('')"
|
|
6
|
-
:customRequest="uploadFiles"
|
|
7
|
-
:file-list="uploadedFileList"
|
|
8
|
-
:multiple="true"
|
|
9
|
-
:remove="deleteFileItem"
|
|
10
|
-
name="file">
|
|
11
|
-
<p class="ant-upload-drag-icon">
|
|
12
|
-
<a-icon type="inbox"/>
|
|
13
|
-
</p>
|
|
14
|
-
<p class="ant-upload-text">
|
|
15
|
-
点击或拖动文件到该区域上传
|
|
16
|
-
</p>
|
|
17
|
-
<p class="ant-upload-hint">
|
|
18
|
-
支持单个或多个文件
|
|
19
|
-
</p>
|
|
20
|
-
</a-upload-dragger>
|
|
21
|
-
<a-upload
|
|
22
|
-
v-if=" model.type === 'image'"
|
|
23
|
-
:accept="model.accept.join('')"
|
|
24
|
-
:customRequest="uploadFiles"
|
|
25
|
-
:file-list="uploadedFileList"
|
|
26
|
-
:remove="deleteFileItem"
|
|
27
|
-
list-type="picture-card">
|
|
28
|
-
<a-icon type="plus"/>
|
|
29
|
-
<div class="ant-upload-text">
|
|
30
|
-
Upload
|
|
31
|
-
</div>
|
|
32
|
-
</a-upload>
|
|
33
|
-
</div>
|
|
34
|
-
</template>
|
|
35
|
-
|
|
36
|
-
<script>
|
|
37
|
-
|
|
38
|
-
import { post } from '@vue2-client/services/api'
|
|
39
|
-
import { mapState } from 'vuex'
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
formData
|
|
107
|
-
formData.append('
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
formData.append('
|
|
113
|
-
formData.append('
|
|
114
|
-
formData.append('
|
|
115
|
-
formData.append('
|
|
116
|
-
formData.append('
|
|
117
|
-
formData.append('
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
// }
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
fileInfo.
|
|
135
|
-
fileInfo.
|
|
136
|
-
|
|
137
|
-
this.$
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
fileInfo.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
fileInfo.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}).
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<a-upload-dragger
|
|
4
|
+
v-if="model.type === 'file'"
|
|
5
|
+
:accept="model.accept.join('')"
|
|
6
|
+
:customRequest="uploadFiles"
|
|
7
|
+
:file-list="uploadedFileList"
|
|
8
|
+
:multiple="true"
|
|
9
|
+
:remove="deleteFileItem"
|
|
10
|
+
name="file">
|
|
11
|
+
<p class="ant-upload-drag-icon">
|
|
12
|
+
<a-icon type="inbox"/>
|
|
13
|
+
</p>
|
|
14
|
+
<p class="ant-upload-text">
|
|
15
|
+
点击或拖动文件到该区域上传
|
|
16
|
+
</p>
|
|
17
|
+
<p class="ant-upload-hint">
|
|
18
|
+
支持单个或多个文件
|
|
19
|
+
</p>
|
|
20
|
+
</a-upload-dragger>
|
|
21
|
+
<a-upload
|
|
22
|
+
v-if=" model.type === 'image'"
|
|
23
|
+
:accept="model.accept.join('')"
|
|
24
|
+
:customRequest="uploadFiles"
|
|
25
|
+
:file-list="uploadedFileList"
|
|
26
|
+
:remove="deleteFileItem"
|
|
27
|
+
list-type="picture-card">
|
|
28
|
+
<a-icon type="plus"/>
|
|
29
|
+
<div class="ant-upload-text">
|
|
30
|
+
Upload
|
|
31
|
+
</div>
|
|
32
|
+
</a-upload>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
|
|
38
|
+
import { post } from '@vue2-client/services/api'
|
|
39
|
+
import { mapState } from 'vuex'
|
|
40
|
+
import { upload } from '@/services/api/common'
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
name: 'uploads',
|
|
44
|
+
data () {
|
|
45
|
+
return {
|
|
46
|
+
uploadedFileList: [],
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
props: {
|
|
50
|
+
// 表单属性
|
|
51
|
+
model: {
|
|
52
|
+
type: Object,
|
|
53
|
+
default: () => {
|
|
54
|
+
return {}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
files: {
|
|
58
|
+
type: Array,
|
|
59
|
+
default: () => {
|
|
60
|
+
return []
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
images: {
|
|
64
|
+
type: Array,
|
|
65
|
+
default: () => {
|
|
66
|
+
return []
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
serviceName: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: 'af-system'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
computed: {
|
|
75
|
+
...mapState('account', { currUser: 'user' })
|
|
76
|
+
},
|
|
77
|
+
created () {
|
|
78
|
+
const list = this.model.type === 'file' ? [...this.files] : [...this.images]
|
|
79
|
+
if (this.model.useType) {
|
|
80
|
+
this.uploadedFileList = list.filter(item => item.f_use_type === this.model.useType)
|
|
81
|
+
} else {
|
|
82
|
+
this.uploadedFileList = list
|
|
83
|
+
}
|
|
84
|
+
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
|
|
85
|
+
},
|
|
86
|
+
methods: {
|
|
87
|
+
uploadFiles (info) {
|
|
88
|
+
if (this.uploadedFileList.length >= this.model.acceptCount) {
|
|
89
|
+
this.$message.error(`当前表单限制仅可上传 ${this.model.acceptCount} 个文件`)
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
// 初始化文件信息
|
|
93
|
+
const fileInfo = {
|
|
94
|
+
uid: info.file.uid,
|
|
95
|
+
name: info.file.name,
|
|
96
|
+
status: 'uploading',
|
|
97
|
+
response: '',
|
|
98
|
+
url: '',
|
|
99
|
+
}
|
|
100
|
+
// 放入上传列表中,以便于显示上传进度
|
|
101
|
+
this.uploadedFileList.push(fileInfo)
|
|
102
|
+
// 组装上传数据
|
|
103
|
+
const headers = {
|
|
104
|
+
'Content-Type': 'multipart/form-data',
|
|
105
|
+
}
|
|
106
|
+
const formData = new FormData()
|
|
107
|
+
formData.append('avatar', info.file)
|
|
108
|
+
formData.append('resUploadMode', this.model.resUploadMode ?? 'server')
|
|
109
|
+
if (this.model.pathKey) {
|
|
110
|
+
formData.append('pathKey', this.model.pathKey ?? 'Default')
|
|
111
|
+
}
|
|
112
|
+
// formData.append('stockAlias', this.model.stockAlias)
|
|
113
|
+
formData.append('formType', this.model.type)
|
|
114
|
+
formData.append('useType', this.model.useType ?? 'Default')
|
|
115
|
+
formData.append('resUploadStock', this.model.resUploadStock)
|
|
116
|
+
formData.append('filename', info.file.name)
|
|
117
|
+
formData.append('filesize', (info.file.size / 1024 / 1024).toFixed(4))
|
|
118
|
+
formData.append('f_operator', this.currUser ? this.currUser.username : '')
|
|
119
|
+
|
|
120
|
+
// const url = '/api/af-system/resource'
|
|
121
|
+
// if (process.env.NODE_ENV === 'production') {
|
|
122
|
+
// url = `/${this.model.stockAlias}/af-system/resource`
|
|
123
|
+
// }
|
|
124
|
+
upload(formData, this.serviceName, { headers, timeout: 60 * 1000 }).then(res => {
|
|
125
|
+
// 根据服务端返回的结果判断成功与否,设置文件条目的状态
|
|
126
|
+
if (res.success) {
|
|
127
|
+
fileInfo.status = 'done'
|
|
128
|
+
let dataObj
|
|
129
|
+
if (typeof res.data === 'string') {
|
|
130
|
+
dataObj = JSON.parse(res.data)
|
|
131
|
+
} else {
|
|
132
|
+
dataObj = res.data
|
|
133
|
+
}
|
|
134
|
+
fileInfo.response = dataObj
|
|
135
|
+
fileInfo.id = dataObj.id
|
|
136
|
+
fileInfo.url = dataObj.f_downloadpath
|
|
137
|
+
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
|
|
138
|
+
this.$message.success('上传成功!')
|
|
139
|
+
} else {
|
|
140
|
+
fileInfo.status = 'error'
|
|
141
|
+
fileInfo.response = res.data
|
|
142
|
+
this.$message.error('上传失败!')
|
|
143
|
+
}
|
|
144
|
+
}).catch((e) => {
|
|
145
|
+
fileInfo.status = 'error'
|
|
146
|
+
fileInfo.response = e
|
|
147
|
+
this.$message.error(`请求失败!${e}`)
|
|
148
|
+
})
|
|
149
|
+
},
|
|
150
|
+
// 删除文件
|
|
151
|
+
deleteFileItem (file) {
|
|
152
|
+
if (file.id) {
|
|
153
|
+
post('/api/' + this.serviceName + '/entity/t_files', { id: file.id, f_state: '删除' }).then(res => {
|
|
154
|
+
}).catch(e => { })
|
|
155
|
+
}
|
|
156
|
+
// 找到当前文件所在列表的索引
|
|
157
|
+
const index = this.uploadedFileList.indexOf(file)
|
|
158
|
+
// 从列表中移除该文件
|
|
159
|
+
this.uploadedFileList.splice(index, 1)
|
|
160
|
+
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
|
|
161
|
+
return true
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
</script>
|
|
166
|
+
<style lang="less" scoped>
|
|
167
|
+
|
|
168
|
+
</style>
|
|
@@ -49,31 +49,53 @@
|
|
|
49
49
|
<a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
|
|
50
50
|
<a-icon :style="iconStyle" type="delete"/>删除
|
|
51
51
|
</a-button>
|
|
52
|
+
<a-button v-if="!buttonState || buttonState.import" type="dashed" @click="$refs.importExcel.importExcelHandleOpen()">
|
|
53
|
+
<a-icon :style="iconStyle" type="import" />导入
|
|
54
|
+
</a-button>
|
|
55
|
+
<a-dropdown v-if="!buttonState || buttonState.export">
|
|
56
|
+
<a-menu slot="overlay">
|
|
57
|
+
<a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon :style="iconStyle" type="ordered-list" />导出选中数据</a-menu-item>
|
|
58
|
+
<a-menu-item key="2" @click="handleExport"><a-icon :style="iconStyle" type="snippets" />导出本页数据</a-menu-item>
|
|
59
|
+
<a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download" />导出所有符合条件的数据</a-menu-item>
|
|
60
|
+
</a-menu>
|
|
61
|
+
<a-button>导出 <a-icon type="down" /> </a-button>
|
|
62
|
+
</a-dropdown>
|
|
52
63
|
<slot :selectedRowKeys="selectedRowKeys" name="button"></slot>
|
|
53
64
|
</a-space>
|
|
54
65
|
<slot name="expand"></slot>
|
|
55
66
|
</template>
|
|
56
67
|
</x-table>
|
|
68
|
+
<!-- 上传文件 -->
|
|
69
|
+
<x-import-excel
|
|
70
|
+
ref="importExcel"
|
|
71
|
+
@ok="refreshTable"
|
|
72
|
+
:title="title"
|
|
73
|
+
:service-name="serviceName"
|
|
74
|
+
:query-params-name="queryParamsName"
|
|
75
|
+
/>
|
|
57
76
|
</template>
|
|
58
77
|
</a-skeleton>
|
|
59
78
|
</template>
|
|
60
79
|
<script>
|
|
61
|
-
import XForm from '@vue2-client/base-client/components/common/XForm
|
|
62
|
-
import XAddForm from '@vue2-client/base-client/components/common/XAddForm
|
|
63
|
-
import XTable from '@vue2-client/base-client/components/common/XTable
|
|
64
|
-
import
|
|
80
|
+
import XForm from '@vue2-client/base-client/components/common/XForm'
|
|
81
|
+
import XAddForm from '@vue2-client/base-client/components/common/XAddForm'
|
|
82
|
+
import XTable from '@vue2-client/base-client/components/common/XTable'
|
|
83
|
+
import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
|
|
84
|
+
import { query, download, commonApi, addOrModify, remove, queryWithResource } from '@vue2-client/services/api/common'
|
|
65
85
|
import { indexedDB } from '@vue2-client/utils/indexedDB'
|
|
66
86
|
import { mapState } from 'vuex'
|
|
67
87
|
import { Modal } from 'ant-design-vue'
|
|
68
88
|
import { post } from '@vue2-client/services/api/restTools'
|
|
69
89
|
import { CommonTempTable } from '@vue2-client/services/api/commonTempTable'
|
|
90
|
+
import { exportJson } from '@/utils/excel/Export2Excel'
|
|
70
91
|
|
|
71
92
|
export default {
|
|
72
93
|
name: 'XFormTable',
|
|
73
94
|
components: {
|
|
74
95
|
XTable,
|
|
75
96
|
XForm,
|
|
76
|
-
XAddForm
|
|
97
|
+
XAddForm,
|
|
98
|
+
XImportExcel
|
|
77
99
|
},
|
|
78
100
|
data () {
|
|
79
101
|
return {
|
|
@@ -117,11 +139,7 @@ export default {
|
|
|
117
139
|
// 被修改数据加载状态
|
|
118
140
|
editDataLoading: false,
|
|
119
141
|
// 是否为临时表
|
|
120
|
-
isTableTemp: false
|
|
121
|
-
// 自定义新增修改接口
|
|
122
|
-
customAoM: undefined,
|
|
123
|
-
// 自定义查询接口
|
|
124
|
-
customQuery: undefined
|
|
142
|
+
isTableTemp: false
|
|
125
143
|
}
|
|
126
144
|
},
|
|
127
145
|
computed: {
|
|
@@ -177,11 +195,6 @@ export default {
|
|
|
177
195
|
return false
|
|
178
196
|
}
|
|
179
197
|
},
|
|
180
|
-
// 动态创建子表需要的定义
|
|
181
|
-
tempTableData: {
|
|
182
|
-
type: Object,
|
|
183
|
-
default: null
|
|
184
|
-
},
|
|
185
198
|
// 数据只有一页时是否展示分页,true:展示,auto:隐藏
|
|
186
199
|
showPagination: {
|
|
187
200
|
type: Boolean,
|
|
@@ -227,18 +240,18 @@ export default {
|
|
|
227
240
|
this.formItems = res.formJson
|
|
228
241
|
this.buttonState = res.buttonState
|
|
229
242
|
this.serviceName = res.serviceName
|
|
230
|
-
this.customAoM = res.customAoM
|
|
231
|
-
this.customQuery = res.customQuery
|
|
232
243
|
this.mainLoading = false
|
|
233
244
|
this.loaded = true
|
|
234
245
|
},
|
|
235
246
|
getColumnsJson () {
|
|
247
|
+
this.form = {}
|
|
236
248
|
this.mainLoading = true
|
|
237
249
|
indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
|
|
238
250
|
this.setParams(ret)
|
|
239
251
|
})
|
|
240
252
|
},
|
|
241
253
|
getColumnsJsonBySource () {
|
|
254
|
+
this.form = {}
|
|
242
255
|
this.mainLoading = true
|
|
243
256
|
post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
|
|
244
257
|
this.queryParams = res
|
|
@@ -267,7 +280,7 @@ export default {
|
|
|
267
280
|
// 新增/修改数据表单提交
|
|
268
281
|
onAddOrModify (res) {
|
|
269
282
|
if (this.viewMode) {
|
|
270
|
-
this.$message.info('
|
|
283
|
+
this.$message.info('预览模式禁止新增和修改')
|
|
271
284
|
return false
|
|
272
285
|
}
|
|
273
286
|
// 如果是临时表
|
|
@@ -276,39 +289,35 @@ export default {
|
|
|
276
289
|
return
|
|
277
290
|
}
|
|
278
291
|
if (res.valid) {
|
|
279
|
-
this.loading = true
|
|
280
|
-
const requestParameters = {
|
|
281
|
-
queryParamsName: this.queryParamsName,
|
|
282
|
-
form: {}
|
|
283
|
-
}
|
|
284
|
-
if (this.businessType === '修改') {
|
|
285
|
-
const rowKeyValue = this.selectedRowKeys[0]
|
|
286
|
-
const key = this.tableColumns[0].dataIndex
|
|
287
|
-
const realKey = key.substring(key.indexOf('_') + 1)
|
|
288
|
-
requestParameters.form[realKey] = rowKeyValue
|
|
289
|
-
}
|
|
290
|
-
for (const key of Object.keys(res.form)) {
|
|
291
|
-
const realKey = key.substring(key.indexOf('_') + 1)
|
|
292
|
-
requestParameters.form[realKey] = res.form[key]
|
|
293
|
-
}
|
|
294
|
-
if (!this.customAoM || this.customAoM?.length === 0) {
|
|
295
|
-
this.customAoM = undefined
|
|
296
|
-
}
|
|
297
|
-
addOrModify(requestParameters, this.customAoM, this.serviceName).then(res => {
|
|
298
|
-
this.$message.success(this.businessType + '成功!')
|
|
299
|
-
this.loading = false
|
|
300
|
-
this.modelVisible = false
|
|
301
|
-
this.$refs.xTable.refresh(true)
|
|
302
|
-
// commit
|
|
303
|
-
this.$emit('afterSubmit', { type: this.businessType, id: res.id, form: requestParameters.form })
|
|
304
|
-
}).catch(e => {
|
|
305
|
-
this.loading = false
|
|
306
|
-
this.modelVisible = false
|
|
307
|
-
this.$message.error(this.businessType + '失败!')
|
|
308
|
-
})
|
|
309
|
-
} else {
|
|
310
292
|
return false
|
|
311
293
|
}
|
|
294
|
+
this.loading = true
|
|
295
|
+
const requestParameters = {
|
|
296
|
+
queryParamsName: this.queryParamsName,
|
|
297
|
+
form: {}
|
|
298
|
+
}
|
|
299
|
+
if (this.businessType === '修改') {
|
|
300
|
+
// 将更新需要的主键值加入到表单中
|
|
301
|
+
const key = this.tableColumns[0].dataIndex
|
|
302
|
+
const realKey = this.getRealKey(key)
|
|
303
|
+
requestParameters.form[realKey] = this.selectedRowKeys[0]
|
|
304
|
+
}
|
|
305
|
+
for (const key of Object.keys(res.form)) {
|
|
306
|
+
const realKey = this.getRealKey(key)
|
|
307
|
+
requestParameters.form[realKey] = res.form[key]
|
|
308
|
+
}
|
|
309
|
+
addOrModify(requestParameters, this.serviceName).then(res => {
|
|
310
|
+
this.$message.success(this.businessType + '成功!')
|
|
311
|
+
this.loading = false
|
|
312
|
+
this.modelVisible = false
|
|
313
|
+
this.$refs.xTable.refresh(true)
|
|
314
|
+
// commit
|
|
315
|
+
this.$emit('afterSubmit', { type: this.businessType, id: res.id, form: requestParameters.form })
|
|
316
|
+
}).catch(e => {
|
|
317
|
+
this.loading = false
|
|
318
|
+
this.modelVisible = false
|
|
319
|
+
this.$message.error(this.businessType + '失败!')
|
|
320
|
+
})
|
|
312
321
|
},
|
|
313
322
|
// 刷新加载表格数据
|
|
314
323
|
loadData (requestParameters, callback) {
|
|
@@ -320,7 +329,7 @@ export default {
|
|
|
320
329
|
}
|
|
321
330
|
}
|
|
322
331
|
if (!this.isTableTemp) {
|
|
323
|
-
result = query(requestParameters,
|
|
332
|
+
result = query(requestParameters, this.serviceName)
|
|
324
333
|
}
|
|
325
334
|
this.$emit('afterQuery', result)
|
|
326
335
|
callback(result)
|
|
@@ -329,6 +338,10 @@ export default {
|
|
|
329
338
|
action (record, id) {
|
|
330
339
|
this.$emit('action', record, id)
|
|
331
340
|
},
|
|
341
|
+
// 获取数据字段实际值
|
|
342
|
+
getRealKey (key) {
|
|
343
|
+
return key.substring(key.indexOf('_') + 1)
|
|
344
|
+
},
|
|
332
345
|
// 新增业务
|
|
333
346
|
addItem () {
|
|
334
347
|
this.businessType = '新增'
|
|
@@ -338,32 +351,24 @@ export default {
|
|
|
338
351
|
// 修改业务
|
|
339
352
|
editItem () {
|
|
340
353
|
this.businessType = '修改'
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
pageSize: 1
|
|
347
|
-
}
|
|
348
|
-
requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
|
|
349
|
-
requestParameters.f_businessid = this.selectedRowKeys[0]
|
|
350
|
-
if (this.isTableTemp) {
|
|
351
|
-
this.$emit('tempTableEdit', requestParameters)
|
|
352
|
-
return
|
|
353
|
-
}
|
|
354
|
-
this.editDataLoading = true
|
|
355
|
-
if (!this.customQuery || this.customQuery?.length === 0) {
|
|
356
|
-
this.customQuery = undefined
|
|
357
|
-
}
|
|
358
|
-
queryWithResource(requestParameters, this.customQuery, this.serviceName).then(res => {
|
|
359
|
-
this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
|
|
360
|
-
this.modelVisible = true
|
|
361
|
-
this.editDataLoading = false
|
|
362
|
-
console.warn(this.modifyModelData)
|
|
363
|
-
})
|
|
364
|
-
} else {
|
|
365
|
-
this.$message.info('预览模式禁止修改')
|
|
354
|
+
const requestParameters = {
|
|
355
|
+
queryParamsName: this.queryParamsName,
|
|
356
|
+
conditionParams: {},
|
|
357
|
+
pageNo: 1,
|
|
358
|
+
pageSize: 1
|
|
366
359
|
}
|
|
360
|
+
requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
|
|
361
|
+
requestParameters.f_businessid = this.selectedRowKeys[0]
|
|
362
|
+
if (this.isTableTemp) {
|
|
363
|
+
this.$emit('tempTableEdit', requestParameters)
|
|
364
|
+
return
|
|
365
|
+
}
|
|
366
|
+
this.editDataLoading = true
|
|
367
|
+
queryWithResource(requestParameters, this.serviceName).then(res => {
|
|
368
|
+
this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
|
|
369
|
+
this.modelVisible = true
|
|
370
|
+
this.editDataLoading = false
|
|
371
|
+
})
|
|
367
372
|
},
|
|
368
373
|
// 删除业务
|
|
369
374
|
deleteItem () {
|
|
@@ -382,7 +387,7 @@ export default {
|
|
|
382
387
|
queryParamsName: this.queryParamsName,
|
|
383
388
|
idList: this.selectedRowKeys
|
|
384
389
|
}
|
|
385
|
-
remove(requestParameters,
|
|
390
|
+
remove(requestParameters, this.serviceName).then(res => {
|
|
386
391
|
this.loading = false
|
|
387
392
|
this.$message.success('删除成功!')
|
|
388
393
|
this.$refs.xTable.clearRowKeys()
|
|
@@ -397,6 +402,38 @@ export default {
|
|
|
397
402
|
onCancel () {}
|
|
398
403
|
})
|
|
399
404
|
},
|
|
405
|
+
// 导出选中或本页数据
|
|
406
|
+
handleExport (isSelected) {
|
|
407
|
+
const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
|
|
408
|
+
const filterVal = this.tableColumns.map(res => res.dataIndex)
|
|
409
|
+
let exportData
|
|
410
|
+
if (isSelected) {
|
|
411
|
+
exportData = this.$refs.xTable.selectedRows
|
|
412
|
+
} else {
|
|
413
|
+
exportData = this.$refs.xTable.dataSource
|
|
414
|
+
}
|
|
415
|
+
const data = this.formatJson(filterVal, exportData)
|
|
416
|
+
exportJson(tHeader, data, this.title + `数据_${new Date().toLocaleString()}`)
|
|
417
|
+
},
|
|
418
|
+
formatJson (filterVal, jsonData) {
|
|
419
|
+
return jsonData.map(v => filterVal.map(j => v[j]))
|
|
420
|
+
},
|
|
421
|
+
// 导出符合条件的数据
|
|
422
|
+
handleExportByQuery () {
|
|
423
|
+
const that = this
|
|
424
|
+
this.$confirm({
|
|
425
|
+
title: '是否确认导出?',
|
|
426
|
+
content: '此操作将导出当前条件下所有数据而非选中数据',
|
|
427
|
+
onOk () {
|
|
428
|
+
download({
|
|
429
|
+
queryParamsName: that.queryParamsName,
|
|
430
|
+
form: that.form,
|
|
431
|
+
type: 'exportData'
|
|
432
|
+
}, that.title + `数据_${new Date().toLocaleString()}.xlsx`, that.serviceName)
|
|
433
|
+
},
|
|
434
|
+
onCancel () {}
|
|
435
|
+
})
|
|
436
|
+
},
|
|
400
437
|
// 查询表单部分显示/隐藏切换
|
|
401
438
|
toggleIsFormShow () {
|
|
402
439
|
this.isFormShow = !this.isFormShow
|