Commit 679a62a9 by cwq0219

表格组件-修改

1 parent f3377ffa
...@@ -7,11 +7,13 @@ function getListApi(data) { ...@@ -7,11 +7,13 @@ function getListApi(data) {
} }
function editApi(data) { function editApi(data) {
data.refreshTable = true
data.method = `${path}edit` data.method = `${path}edit`
return request(data) return request(data)
} }
function removeApi(data) { function removeApi(data) {
data.refreshTable = true
data.method = `${path}remove` data.method = `${path}remove`
return request(data) return request(data)
} }
......
...@@ -8,6 +8,7 @@ function getListApi(data) { ...@@ -8,6 +8,7 @@ function getListApi(data) {
} }
function removeApi(data) { function removeApi(data) {
data.refreshTable = true
data.method = `${path}delete` data.method = `${path}delete`
return request(data) return request(data)
} }
......
...@@ -13,6 +13,7 @@ function detailApi(data) { ...@@ -13,6 +13,7 @@ function detailApi(data) {
} }
function removeApi(data) { function removeApi(data) {
data.refreshTable = true
data.method = `${path}delete` data.method = `${path}delete`
return request(data) return request(data)
} }
......
...@@ -12,10 +12,12 @@ function getListApi(data) { ...@@ -12,10 +12,12 @@ function getListApi(data) {
} }
function editApi(data) { function editApi(data) {
data.refreshTable = true
return request(data) return request(data)
} }
function removeApi(data) { function removeApi(data) {
data.refreshTable = true
data.method = `${path}remove` data.method = `${path}remove`
return request(data) return request(data)
} }
......
/* /*
* @Author: limin * @Author: limin
* @Date: 2019-08-26 18:02:55 * @Date: 2019-08-26 18:02:55
* @Last Modified by: limin * @Last Modified by: chenwq
* @Last Modified time: 2019-09-18 20:06:38 * @Last Modified time: 2019-09-27 17:08:06
*/ */
import request from './request' import request from './request'
...@@ -31,6 +31,7 @@ export function AccountLogin(data) { ...@@ -31,6 +31,7 @@ export function AccountLogin(data) {
*/ */
export function Reg(data = {}) { export function Reg(data = {}) {
data.method = REG_URL data.method = REG_URL
data.refreshTable = true
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
...@@ -57,6 +58,7 @@ export function UserList(data = {}) { ...@@ -57,6 +58,7 @@ export function UserList(data = {}) {
* @param {*} data 参数 * @param {*} data 参数
*/ */
export function PassWordReset(data = {}) { export function PassWordReset(data = {}) {
data.refreshTable = true
data.method = `${USER_PATH}password.reset` data.method = `${USER_PATH}password.reset`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
...@@ -66,6 +68,7 @@ export function PassWordReset(data = {}) { ...@@ -66,6 +68,7 @@ export function PassWordReset(data = {}) {
* @param {*} data 参数 * @param {*} data 参数
*/ */
export function AccountModify(data = {}) { export function AccountModify(data = {}) {
data.refreshTable = true
data.method = `${USER_PATH}modify` data.method = `${USER_PATH}modify`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
...@@ -75,6 +78,7 @@ export function AccountModify(data = {}) { ...@@ -75,6 +78,7 @@ export function AccountModify(data = {}) {
* @param {*} data 参数 * @param {*} data 参数
*/ */
export function AccountIncrease(data = {}) { export function AccountIncrease(data = {}) {
data.refreshTable = true
data.method = `${USER_PATH}validity.increase` data.method = `${USER_PATH}validity.increase`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
...@@ -84,6 +88,7 @@ export function AccountIncrease(data = {}) { ...@@ -84,6 +88,7 @@ export function AccountIncrease(data = {}) {
* @param {*} data 参数 * @param {*} data 参数
*/ */
export function AccountForbidden(data = {}) { export function AccountForbidden(data = {}) {
data.refreshTable = true
data.method = `${USER_PATH}forbidden` data.method = `${USER_PATH}forbidden`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
...@@ -93,6 +98,7 @@ export function AccountForbidden(data = {}) { ...@@ -93,6 +98,7 @@ export function AccountForbidden(data = {}) {
* @param {*} data 参数 * @param {*} data 参数
*/ */
export function AccountActived(data = {}) { export function AccountActived(data = {}) {
data.refreshTable = true
data.method = `${USER_PATH}actived` data.method = `${USER_PATH}actived`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
...@@ -102,6 +108,7 @@ export function AccountActived(data = {}) { ...@@ -102,6 +108,7 @@ export function AccountActived(data = {}) {
* @param {*} data 参数 * @param {*} data 参数
*/ */
export function AccountValidate(data = {}) { export function AccountValidate(data = {}) {
data.refreshTable = true
data.method = `${USER_PATH}check` data.method = `${USER_PATH}check`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
...@@ -129,6 +136,7 @@ export function RoleAuthData(data = {}) { ...@@ -129,6 +136,7 @@ export function RoleAuthData(data = {}) {
* @param {*} data 参数 * @param {*} data 参数
*/ */
export function RoleReg(data = {}) { export function RoleReg(data = {}) {
data.refreshTable = true
data.method = `${ROLE_PATH}register` data.method = `${ROLE_PATH}register`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
...@@ -138,6 +146,7 @@ export function RoleReg(data = {}) { ...@@ -138,6 +146,7 @@ export function RoleReg(data = {}) {
* @param {*} data 参数 * @param {*} data 参数
*/ */
export function RoleModify(data = {}) { export function RoleModify(data = {}) {
data.refreshTable = true
data.method = `${ROLE_PATH}modify` data.method = `${ROLE_PATH}modify`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
......
...@@ -13,10 +13,12 @@ function getListApi(data) { ...@@ -13,10 +13,12 @@ function getListApi(data) {
function editApi(data) { function editApi(data) {
// data.method = `${path}edit` // data.method = `${path}edit`
data.refreshTable = true
return request(data) return request(data)
} }
function removeApi(data) { function removeApi(data) {
data.refreshTable = true
data.method = `${path}remove` data.method = `${path}remove`
return request(data) return request(data)
} }
......
...@@ -157,6 +157,9 @@ export default { ...@@ -157,6 +157,9 @@ export default {
this.oldValue = _.cloneDeep(val) this.oldValue = _.cloneDeep(val)
}, },
deep: true deep: true
},
'$store.state.d2admin.refreshtable.value'(val) {
this.refreshTable()
} }
}, },
...@@ -173,7 +176,6 @@ export default { ...@@ -173,7 +176,6 @@ export default {
...this.page, ...this.page,
...this.searchForm ...this.searchForm
} }
console.log('刷新--')
// console.log(params) // console.log(params)
this.getListApi(params).then(res => { this.getListApi(params).then(res => {
this.data = res[this.tableParams.listName] this.data = res[this.tableParams.listName]
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
import Qs from 'qs' import Qs from 'qs'
axios.defaults.withCredentials = true axios.defaults.withCredentials = true
const expiresMinute = 60 // 过期时间(分钟) const expiresMinute = 60 // 过期时间(分钟)
var refreshTable = false // 标记是否刷新表格
// 创建一个错误 // 创建一个错误
export function errorCreate(msg) { export function errorCreate(msg) {
const error = new Error(msg) const error = new Error(msg)
...@@ -55,6 +56,7 @@ service.interceptors.request.use( ...@@ -55,6 +56,7 @@ service.interceptors.request.use(
config => { config => {
return new Promise(async resolve => { return new Promise(async resolve => {
const { url, params } = config const { url, params } = config
params.refreshTable && (refreshTable = true)
await store.commit('d2admin/loading/set', true) await store.commit('d2admin/loading/set', true)
const uuid = util.cookies.get('uuid') const uuid = util.cookies.get('uuid')
// 如果请求链接不在排除列表 (排除列表: 登录 基础数据) 并且cookie 过期(判断是否长时间未操作) // 如果请求链接不在排除列表 (排除列表: 登录 基础数据) 并且cookie 过期(判断是否长时间未操作)
...@@ -90,12 +92,17 @@ service.interceptors.response.use( ...@@ -90,12 +92,17 @@ service.interceptors.response.use(
switch (+code) { switch (+code) {
case 0: case 0:
// [ 示例 ] code === 0 代表没有错误 // [ 示例 ] code === 0 代表没有错误
if (refreshTable) {
store.commit('d2admin/refreshtable/set', !store.state.d2admin.refreshtable.value)
refreshTable = false
}
return data return data
default: default:
// 不是正确的 code // 不是正确的 code
errorCreate(`${dataAxios.message}`) errorCreate(`${dataAxios.message}`)
break break
} }
refreshTable = false
}, },
error => { error => {
......
/*
* @Author: chenwq
* @Date: 2019-09-27 11:39:49
* @Last Modified by: chenwq
* @Last Modified time: 2019-09-27 15:27:39
*/
export default {
namespaced: true,
state: {
// 刷新表格
value: false
},
getters: {
/**
* 返回刷新表格状态
* @param {*} state
*/
refresh(state) {
return state.value
}
},
mutations: {
/**
* @description 设置表格刷新
* @param {Object} state state
* @param {Boolean} refresh refresh
*/
set(state, refresh) {
return new Promise(resolve => {
state.value = refresh
resolve(true)
})
}
},
actions: {
reset({ state }) {
state.value = false
}
}
}
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
</auth-button> </auth-button>
</d2-table-header> </d2-table-header>
<d2-table <d2-table
ref="table"
:searchForm="searchForm" :searchForm="searchForm"
:tableParams="tableParams" :tableParams="tableParams"
:getListApi="getListApi" :getListApi="getListApi"
...@@ -192,10 +191,6 @@ export default { ...@@ -192,10 +191,6 @@ export default {
/* 接口请求-start */ /* 接口请求-start */
getList() {
this.$refs.table.refreshTable()
},
delObjMutiAttr(obj, keys) { delObjMutiAttr(obj, keys) {
keys.map(key => delete obj[key]) keys.map(key => delete obj[key])
return obj return obj
...@@ -216,7 +211,6 @@ export default { ...@@ -216,7 +211,6 @@ export default {
.then(res => { .then(res => {
this.handleEditClose() this.handleEditClose()
notice.okTips() notice.okTips()
this.getList()
}) })
.catch(() => { .catch(() => {
notice.errorTips() notice.errorTips()
...@@ -274,7 +268,7 @@ export default { ...@@ -274,7 +268,7 @@ export default {
} else { } else {
notice.okTips('本次导入结果:全部成功!') notice.okTips('本次导入结果:全部成功!')
} }
this.getList() this.$store.commit('d2admin/refreshtable/set', !this.$store.state.d2admin.refreshtable.value)
document.getElementById('fileUpload').value = null document.getElementById('fileUpload').value = null
}) })
.catch(() => { .catch(() => {
...@@ -325,7 +319,7 @@ export default { ...@@ -325,7 +319,7 @@ export default {
}) })
.then(res => { .then(res => {
notice.okTips() notice.okTips()
this.getList() // this.getList()
}) })
.catch(() => { .catch(() => {
notice.errorTips() notice.errorTips()
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
</el-form> </el-form>
<d2-table-header title="作业单列表"><auth-button category="Button"></auth-button></d2-table-header> <d2-table-header title="作业单列表"><auth-button category="Button"></auth-button></d2-table-header>
<d2-table <d2-table
ref="table"
:searchForm="searchForm" :searchForm="searchForm"
:tableParams="tableParams" :tableParams="tableParams"
:getListApi="getListApi" :getListApi="getListApi"
...@@ -250,13 +249,11 @@ export default { ...@@ -250,13 +249,11 @@ export default {
watch: { watch: {
'creatTime'(value) { 'creatTime'(value) {
// !value && this.getList()
Object.assign(this.searchForm, util.formatTime(this.creatTime)) Object.assign(this.searchForm, util.formatTime(this.creatTime))
} }
}, },
mounted() { mounted() {
// this.getList()
this.loadBaseData() this.loadBaseData()
}, },
...@@ -276,10 +273,10 @@ export default { ...@@ -276,10 +273,10 @@ export default {
return Object.assign(this.searchForm, util.formatTime(this.creatTime)) return Object.assign(this.searchForm, util.formatTime(this.creatTime))
}, },
getList() { // getList() {
this.getParams() // this.getParams()
this.$refs.table.refreshTable() // this.$refs.table.refreshTable()
}, // },
exportOrder() { exportOrder() {
// const params = this.getParams() // const params = this.getParams()
exportApi(this.searchForm).then(res => { exportApi(this.searchForm).then(res => {
...@@ -300,7 +297,7 @@ export default { ...@@ -300,7 +297,7 @@ export default {
id: row.id id: row.id
}).then(res => { }).then(res => {
notice.okTips() notice.okTips()
this.getList() // this.getList()
}).catch(() => { }).catch(() => {
notice.errorTips() notice.errorTips()
}) })
......
...@@ -199,7 +199,6 @@ export default { ...@@ -199,7 +199,6 @@ export default {
orderCode: row.orderCode orderCode: row.orderCode
}).then(() => { }).then(() => {
notice.okTips() notice.okTips()
this.getList()
}).catch(() => { }).catch(() => {
notice.errorTips() notice.errorTips()
}) })
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
</el-form> </el-form>
<d2-table-header title="子系统列表"><auth-button category="Button" :data="editFormReset"></auth-button></d2-table-header> <d2-table-header title="子系统列表"><auth-button category="Button" :data="editFormReset"></auth-button></d2-table-header>
<d2-table <d2-table
ref="table"
:searchForm="searchForm" :searchForm="searchForm"
:tableParams="tableParams" :tableParams="tableParams"
:getListApi="getListApi" :getListApi="getListApi"
...@@ -195,10 +194,6 @@ export default { ...@@ -195,10 +194,6 @@ export default {
// }) // })
// }, // },
getList() {
this.$refs.table.refreshTable()
},
editSubSystem(value) { editSubSystem(value) {
// console.log(value) // console.log(value)
const params = _.cloneDeep(this.editFormReset) const params = _.cloneDeep(this.editFormReset)
...@@ -215,7 +210,6 @@ export default { ...@@ -215,7 +210,6 @@ export default {
editApi(params).then(res => { editApi(params).then(res => {
this.handleEditClose() this.handleEditClose()
notice.okTips() notice.okTips()
this.getList()
}).catch(() => { }).catch(() => {
notice.errorTips() notice.errorTips()
}) })
...@@ -248,7 +242,6 @@ export default { ...@@ -248,7 +242,6 @@ export default {
usedStatus: 2 usedStatus: 2
}).then(() => { }).then(() => {
notice.okTips() notice.okTips()
this.getList()
}).catch(() => { }).catch(() => {
notice.errorTips() notice.errorTips()
}) })
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
</el-form> </el-form>
<d2-table-header title="车辆列表"><auth-button category="Button" :data="editFormReset"></auth-button></d2-table-header> <d2-table-header title="车辆列表"><auth-button category="Button" :data="editFormReset"></auth-button></d2-table-header>
<d2-table <d2-table
ref="table"
:searchForm="searchForm" :searchForm="searchForm"
:tableParams="tableParams" :tableParams="tableParams"
:getListApi="getListApi" :getListApi="getListApi"
...@@ -134,10 +133,6 @@ export default { ...@@ -134,10 +133,6 @@ export default {
this.baseData.station = data this.baseData.station = data
}, },
getList() {
this.$refs.table.refreshTable()
},
editTraffic(value) { editTraffic(value) {
// console.log(value) // console.log(value)
const params = _.cloneDeep(this.editFormReset) const params = _.cloneDeep(this.editFormReset)
...@@ -149,7 +144,6 @@ export default { ...@@ -149,7 +144,6 @@ export default {
editApi(params).then(res => { editApi(params).then(res => {
this.handleEditClose() this.handleEditClose()
notice.okTips() notice.okTips()
this.getList()
}).catch(() => { }).catch(() => {
notice.errorTips() notice.errorTips()
}) })
...@@ -182,7 +176,6 @@ export default { ...@@ -182,7 +176,6 @@ export default {
usedStatus: 2 usedStatus: 2
}).then(res => { }).then(res => {
notice.okTips() notice.okTips()
this.getList()
}).catch(() => { }).catch(() => {
notice.errorTips() notice.errorTips()
}) })
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
</el-form> </el-form>
<d2-table-header title="登录日志列表"></d2-table-header> <d2-table-header title="登录日志列表"></d2-table-header>
<d2-table <d2-table
ref="table"
:searchForm="searchForm" :searchForm="searchForm"
:tableParams="tableParams" :tableParams="tableParams"
:getListApi="getListApi" :getListApi="getListApi"
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<d2-container class="role"> <d2-container class="role">
<d2-table-header title="角色列表"><auth-button category="action" label="创建角色"></auth-button></d2-table-header> <d2-table-header title="角色列表"><auth-button category="action" label="创建角色"></auth-button></d2-table-header>
<d2-table <d2-table
ref="table"
:tableParams="tableParams" :tableParams="tableParams"
:pagination="pagination"
:getListApi="getListApi" :getListApi="getListApi"
> >
<auth-button <auth-button
...@@ -63,7 +63,6 @@ export default { ...@@ -63,7 +63,6 @@ export default {
// this.fetchData() // this.fetchData()
this.$event.$on('e-role-dialog-close', async isReload => { this.$event.$on('e-role-dialog-close', async isReload => {
if (isReload) { if (isReload) {
this.getList()
const { roles } = await RoleList() const { roles } = await RoleList()
this.set({ name: BaseData.ROLE.KEY, value: roles }) this.set({ name: BaseData.ROLE.KEY, value: roles })
} }
...@@ -74,9 +73,6 @@ export default { ...@@ -74,9 +73,6 @@ export default {
methods: { methods: {
...mapActions('d2admin/base', ['set']), ...mapActions('d2admin/base', ['set']),
getList() {
this.$refs.table.refreshTable()
},
async handleEdit(row) { async handleEdit(row) {
this.editData = row && await RoleDetail({ roleId: row.roleId }) this.editData = row && await RoleDetail({ roleId: row.roleId })
this.editVisible = true this.editVisible = true
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
</el-form> </el-form>
<d2-table-header title="用户列表"><auth-button category="action" label="创建用户"></auth-button></d2-table-header> <d2-table-header title="用户列表"><auth-button category="action" label="创建用户"></auth-button></d2-table-header>
<d2-table <d2-table
ref="table"
:searchForm="searchForm" :searchForm="searchForm"
:tableParams="tableParams" :tableParams="tableParams"
:getListApi="getListApi" :getListApi="getListApi"
...@@ -209,7 +208,7 @@ export default { ...@@ -209,7 +208,7 @@ export default {
this.fetchData() this.fetchData()
this.$event.$on('e-reg-dialog-close', isReload => { this.$event.$on('e-reg-dialog-close', isReload => {
this.registerDialogVisible = false this.registerDialogVisible = false
isReload && this.getUserList() // isReload && this.getUserList()
}) })
}, },
...@@ -228,10 +227,6 @@ export default { ...@@ -228,10 +227,6 @@ export default {
Object.freeze(this.baseData) Object.freeze(this.baseData)
}, },
/* 接口请求-start */ /* 接口请求-start */
getUserList() {
// Object.assign(this.searchForm, util.formatTime(this.searchTimes))
this.$refs.table.refreshTable()
},
filterTag(value, row) { filterTag(value, row) {
return row.status === value return row.status === value
}, },
...@@ -244,9 +239,6 @@ export default { ...@@ -244,9 +239,6 @@ export default {
} }
this.openDialog(row) this.openDialog(row)
}, },
// async handleSearch() {
// this.getUserList()
// },
handleEdit(row) { handleEdit(row) {
row = util.deepClone(row) row = util.deepClone(row)
row.data = { row.data = {
...@@ -269,13 +261,12 @@ export default { ...@@ -269,13 +261,12 @@ export default {
}, },
// ------------ // ------------
// 列表各种操作 // 列表各种操作
async handleOperation({ row, e }) { async handleOperation(row, e) {
const _actionText = e.target.innerText const _actionText = e.target.innerText
const res = await this.apiMapping[_actionText]({ userId: row.userId }) const res = await this.apiMapping[_actionText]({ userId: row.userId })
const { operateStatus } = res const { operateStatus } = res
if (operateStatus) { if (operateStatus) {
notice.okTips(`${_actionText}成功!`) notice.okTips(`${_actionText}成功!`)
this.getUserList()
} else { } else {
notice.errorTips(`${_actionText}失败!`) notice.errorTips(`${_actionText}失败!`)
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!