|
|
@@ -3,8 +3,8 @@
|
|
|
* 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal
|
|
|
* data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除
|
|
|
*/
|
|
|
-import {filterObj} from '@/utils/util'
|
|
|
-import {postAction, getAction, deleteAction} from '@/api/request'
|
|
|
+import { filterObj } from '@/utils/util'
|
|
|
+import { postAction, getAction, deleteAction, downFile } from '@/api/request'
|
|
|
import store from '@/store'
|
|
|
|
|
|
export const listMixin = {
|
|
|
@@ -50,17 +50,13 @@ export const listMixin = {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- if (!this.disableMixinCreated) {
|
|
|
- console.log(' -- mixin created -- ')
|
|
|
- this.loadData()
|
|
|
- // 初始化字典配置 在自己页面定义
|
|
|
- this.initDictConfig()
|
|
|
- }
|
|
|
+ console.log(' -- mixin created -- ')
|
|
|
+ this.loadData()
|
|
|
},
|
|
|
computed: {
|
|
|
// token header
|
|
|
tokenHeader() {
|
|
|
- const head = {'Authorization': store.getters.token}
|
|
|
+ const head = { 'Authorization': store.getters.token }
|
|
|
return head
|
|
|
}
|
|
|
},
|
|
|
@@ -93,9 +89,6 @@ export const listMixin = {
|
|
|
this.loading = false
|
|
|
})
|
|
|
},
|
|
|
- initDictConfig() {
|
|
|
- console.log('--这是一个假的方法!')
|
|
|
- },
|
|
|
handleSuperQuery(params, matchType) {
|
|
|
// 高级查询方法
|
|
|
if (!params) {
|
|
|
@@ -124,7 +117,7 @@ export const listMixin = {
|
|
|
getQueryField() {
|
|
|
// TODO 字段权限控制
|
|
|
var str = 'id,'
|
|
|
- this.columns.forEach(function (value) {
|
|
|
+ this.columns.forEach(function(value) {
|
|
|
str += ',' + value.dataIndex
|
|
|
})
|
|
|
return str
|
|
|
@@ -148,7 +141,7 @@ export const listMixin = {
|
|
|
this.queryParam = {}
|
|
|
this.loadData(1)
|
|
|
},
|
|
|
- batchDel: function () {
|
|
|
+ batchDel: function() {
|
|
|
if (!this.url.delete) {
|
|
|
this.$message.error('请设置url.deleteBatch属性!')
|
|
|
return
|
|
|
@@ -165,7 +158,7 @@ export const listMixin = {
|
|
|
this.$confirm({
|
|
|
title: '确认删除',
|
|
|
content: '是否删除选中数据?',
|
|
|
- onOk: function () {
|
|
|
+ onOk: function() {
|
|
|
that.loading = true
|
|
|
deleteAction(that.url.delete, ids).then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
@@ -184,7 +177,7 @@ export const listMixin = {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- handleDelete: function (id) {
|
|
|
+ handleDelete: function(id) {
|
|
|
if (!this.url.delete) {
|
|
|
this.$message.error('请设置url.delete属性!')
|
|
|
return
|
|
|
@@ -212,15 +205,15 @@ export const listMixin = {
|
|
|
}
|
|
|
console.log('currentIndex', currentIndex)
|
|
|
},
|
|
|
- handleEdit: function (record) {
|
|
|
+ handleEdit: function(record) {
|
|
|
this.$refs.modalForm.edit(record)
|
|
|
this.$refs.modalForm.title = '编辑'
|
|
|
this.$refs.modalForm.disableSubmit = false
|
|
|
},
|
|
|
- handleAdd: function () {
|
|
|
- console.log(this.$refs);
|
|
|
+ handleAdd: function() {
|
|
|
+ console.log(this.$refs)
|
|
|
debugger
|
|
|
- console.log(this.$refs.modalForm);
|
|
|
+ console.log(this.$refs.modalForm)
|
|
|
this.$refs.modalForm.add()
|
|
|
this.$refs.modalForm.title = '新增'
|
|
|
this.$refs.modalForm.disableSubmit = false
|
|
|
@@ -249,7 +242,7 @@ export const listMixin = {
|
|
|
// 清空列表选中
|
|
|
this.onClearSelected()
|
|
|
},
|
|
|
- handleDetail: function (record) {
|
|
|
+ handleDetail: function(record) {
|
|
|
this.$refs.modalForm.edit(record)
|
|
|
this.$refs.modalForm.title = '详情'
|
|
|
this.$refs.modalForm.disableSubmit = true
|
|
|
@@ -257,7 +250,7 @@ export const listMixin = {
|
|
|
/* 导出 */
|
|
|
handleExportXls2() {
|
|
|
const paramsStr = encodeURI(JSON.stringify(this.getQueryParams()))
|
|
|
- const url = ``
|
|
|
+ const url = `${process.env.VUE_APP_BASE_API}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`
|
|
|
window.location.href = url
|
|
|
},
|
|
|
handleExportXls(fileName) {
|
|
|
@@ -275,9 +268,9 @@ export const listMixin = {
|
|
|
return
|
|
|
}
|
|
|
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
|
|
- window.navigator.msSaveBlob(new Blob([data], {type: 'application/vnd.ms-excel'}), fileName + '.xls')
|
|
|
+ window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
|
|
|
} else {
|
|
|
- const url = window.URL.createObjectURL(new Blob([data], {type: 'application/vnd.ms-excel'}))
|
|
|
+ const url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
|
|
|
const link = document.createElement('a')
|
|
|
link.style.display = 'none'
|
|
|
link.href = url
|
|
|
@@ -300,16 +293,16 @@ export const listMixin = {
|
|
|
if (info.file.response.success) {
|
|
|
// this.$message.success(`${info.file.name} 文件上传成功`);
|
|
|
if (info.file.response.code === 201) {
|
|
|
- const {message, result: {msg, fileUrl, fileName}} = info.file.response
|
|
|
+ const { message, result: { msg, fileUrl, fileName }} = info.file.response
|
|
|
const href = fileUrl
|
|
|
this.$warning({
|
|
|
- title: message,
|
|
|
- content: ( < div >
|
|
|
- < span > {msg} < /span><br/ >
|
|
|
- < span > 具体详情请 < a href = {href} target = '_blank' download = {fileName} > 点击下载 < /a> </span >
|
|
|
+ title: message,
|
|
|
+ content: (< div >
|
|
|
+ < span > {msg} < /span><br/ >
|
|
|
+ < span > 具体详情请 < a href = {href} target = '_blank' download = {fileName} > 点击下载 < /a> </span >
|
|
|
< /div>
|
|
|
- )
|
|
|
- })
|
|
|
+ )
|
|
|
+ })
|
|
|
} else {
|
|
|
this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`)
|
|
|
}
|
|
|
@@ -329,7 +322,7 @@ export const listMixin = {
|
|
|
okText: '重新登录',
|
|
|
mask: false,
|
|
|
onOk: () => {
|
|
|
- store.dispatch('Logout').then(() => {
|
|
|
+ store.dispatch('user/logout').then(() => {
|
|
|
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
|
|
})
|
|
|
}
|