|
|
@@ -3,9 +3,8 @@
|
|
|
* 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal
|
|
|
* data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除
|
|
|
*/
|
|
|
-import Vue from 'vue'
|
|
|
-import { filterObj } from '@/utils/util'
|
|
|
-import { postAction, getAction } from '@/api/request'
|
|
|
+import {filterObj} from '@/utils/util'
|
|
|
+import {postAction, getAction, deleteAction} from '@/api/request'
|
|
|
import store from '@/store'
|
|
|
|
|
|
export const listMixin = {
|
|
|
@@ -61,7 +60,7 @@ export const listMixin = {
|
|
|
computed: {
|
|
|
// token header
|
|
|
tokenHeader() {
|
|
|
- const head = { 'Authorization': store.getters.token }
|
|
|
+ const head = {'Authorization': store.getters.token}
|
|
|
return head
|
|
|
}
|
|
|
},
|
|
|
@@ -77,18 +76,18 @@ export const listMixin = {
|
|
|
}
|
|
|
var params = this.getQueryParams()// 查询条件
|
|
|
this.loading = true
|
|
|
- postAction(this.url.list, params).then((res) => {
|
|
|
- if (res.success) {
|
|
|
+ getAction(this.url.list, params).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
// update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
|
|
- this.dataSource = res.result.records || res.result
|
|
|
- if (res.result.total) {
|
|
|
- this.ipagination.total = res.result.total
|
|
|
+ this.dataSource = res.rows
|
|
|
+ if (res.total) {
|
|
|
+ this.ipagination.total = res.total
|
|
|
} else {
|
|
|
this.ipagination.total = 0
|
|
|
}
|
|
|
// update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
|
|
} else {
|
|
|
- this.$message.warning(res.message)
|
|
|
+ this.$message.warning(res.msg)
|
|
|
}
|
|
|
}).finally(() => {
|
|
|
this.loading = false
|
|
|
@@ -116,16 +115,16 @@ export const listMixin = {
|
|
|
sqp['superQueryParams'] = encodeURI(this.superQueryParams)
|
|
|
sqp['superQueryMatchType'] = this.superQueryMatchType
|
|
|
}
|
|
|
- var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters)
|
|
|
- param.field = this.getQueryField()
|
|
|
- param.pageNo = this.ipagination.current
|
|
|
+ var param = Object.assign(sqp, this.queryParam)
|
|
|
+ // param.field = this.getQueryField()
|
|
|
+ param.pageNum = this.ipagination.current
|
|
|
param.pageSize = this.ipagination.pageSize
|
|
|
return filterObj(param)
|
|
|
},
|
|
|
getQueryField() {
|
|
|
// TODO 字段权限控制
|
|
|
var str = 'id,'
|
|
|
- this.columns.forEach(function(value) {
|
|
|
+ this.columns.forEach(function (value) {
|
|
|
str += ',' + value.dataIndex
|
|
|
})
|
|
|
return str
|
|
|
@@ -149,8 +148,8 @@ export const listMixin = {
|
|
|
this.queryParam = {}
|
|
|
this.loadData(1)
|
|
|
},
|
|
|
- batchDel: function() {
|
|
|
- if (!this.url.deleteBatch) {
|
|
|
+ batchDel: function () {
|
|
|
+ if (!this.url.delete) {
|
|
|
this.$message.error('请设置url.deleteBatch属性!')
|
|
|
return
|
|
|
}
|
|
|
@@ -166,17 +165,17 @@ export const listMixin = {
|
|
|
this.$confirm({
|
|
|
title: '确认删除',
|
|
|
content: '是否删除选中数据?',
|
|
|
- onOk: function() {
|
|
|
+ onOk: function () {
|
|
|
that.loading = true
|
|
|
- postAction(that.url.deleteBatch, { ids: ids }).then((res) => {
|
|
|
- if (res.success) {
|
|
|
+ deleteAction(that.url.delete, ids).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
// 重新计算分页问题
|
|
|
that.reCalculatePage(that.selectedRowKeys.length)
|
|
|
- that.$message.success(res.message)
|
|
|
+ that.$message.success(res.msg)
|
|
|
that.loadData()
|
|
|
that.onClearSelected()
|
|
|
} else {
|
|
|
- that.$message.warning(res.message)
|
|
|
+ that.$message.warning(res.msg)
|
|
|
}
|
|
|
}).finally(() => {
|
|
|
that.loading = false
|
|
|
@@ -185,20 +184,20 @@ export const listMixin = {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- handleDelete: function(id) {
|
|
|
+ handleDelete: function (id) {
|
|
|
if (!this.url.delete) {
|
|
|
this.$message.error('请设置url.delete属性!')
|
|
|
return
|
|
|
}
|
|
|
var that = this
|
|
|
- deleteAction(that.url.delete, { id: id }).then((res) => {
|
|
|
- if (res.success) {
|
|
|
+ deleteAction(that.url.delete, id).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
// 重新计算分页问题
|
|
|
that.reCalculatePage(1)
|
|
|
- that.$message.success(res.message)
|
|
|
+ that.$message.success(res.msg)
|
|
|
that.loadData()
|
|
|
} else {
|
|
|
- that.$message.warning(res.message)
|
|
|
+ that.$message.warning(res.msg)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
@@ -213,12 +212,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() {
|
|
|
+ handleAdd: function () {
|
|
|
+ console.log(this.$refs);
|
|
|
+ debugger
|
|
|
+ console.log(this.$refs.modalForm);
|
|
|
this.$refs.modalForm.add()
|
|
|
this.$refs.modalForm.title = '新增'
|
|
|
this.$refs.modalForm.disableSubmit = false
|
|
|
@@ -247,7 +249,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
|
|
|
@@ -273,9 +275,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
|
|
|
@@ -298,16 +300,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>
|
|
|
- </div>
|
|
|
- )
|
|
|
- })
|
|
|
+ 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} 文件上传成功`)
|
|
|
}
|
|
|
@@ -328,8 +330,7 @@ export const listMixin = {
|
|
|
mask: false,
|
|
|
onOk: () => {
|
|
|
store.dispatch('Logout').then(() => {
|
|
|
- Vue.ls.remove(ACCESS_TOKEN)
|
|
|
- window.location.reload()
|
|
|
+ this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
|
|
})
|
|
|
}
|
|
|
})
|