diff --git a/src/layout/components/Navbar/index.vue b/src/layout/components/Navbar/index.vue index 7d551ec..b483436 100644 --- a/src/layout/components/Navbar/index.vue +++ b/src/layout/components/Navbar/index.vue @@ -7,7 +7,7 @@
@@ -146,7 +146,7 @@ export default { isMenuScroll: false, scrollOffset: 0, scrollMaxWidth: 0, - isEnvTest: (process.env.ENV === 'staging' || process.env.NODE_ENV === 'development'), + brandImg: (process.env.ENV === 'staging' || process.env.NODE_ENV === 'development') ? require('@/assets/title.png') : require('@/assets/title1.png'), zIndex: PopupManager.nextZIndex(), isFullscreen: false, isShowMenuMobile: false, diff --git a/src/views/system/DashboardComponents/toDo.vue b/src/views/system/DashboardComponents/toDo.vue index 4f164fb..87cd985 100644 --- a/src/views/system/DashboardComponents/toDo.vue +++ b/src/views/system/DashboardComponents/toDo.vue @@ -134,7 +134,7 @@ export default { }, created() { this.getNotices(true) - setInterval(this.getNotices, 5000) + this.timer = setInterval(this.getNotices, 5000) }, beforeDestroy() { clearInterval(this.timer) diff --git a/src/views/system/components/BatchUser.vue b/src/views/system/components/BatchUser.vue index 74c6d75..5df1725 100644 --- a/src/views/system/components/BatchUser.vue +++ b/src/views/system/components/BatchUser.vue @@ -28,6 +28,8 @@ :column-config="{ resizable: true }" :checkbox-config="{ trigger: 'row', highlight: true, reserve: true }" :data="tableData" + @checkbox-change="checkboxChange" + @checkbox-all="checkAll" > @@ -95,8 +97,11 @@ export default { }, computed: {}, watch: { - 'form.user_ids': function(val, oldVal) { - this.setSelectRow() + 'form.user_ids': { + handler() { + this.setSelectRow() + }, + deep: true }, isShow(newVal) { if (newVal) { @@ -130,6 +135,31 @@ export default { } }) }, + checkboxChange({ checked, row }) { + if (!checked) { + const index = this.form.user_ids.indexOf(row.id) + if (index !== -1) { + this.form.user_ids.splice(index, 1) + } + } + this.setFormUserIds() + }, + checkAll({ checked }) { + if (!checked) { + const ids = this.tableData.map(i => i.id) + ids.forEach(id => { + const index = this.form.user_ids.indexOf(id) + if (index !== -1) { + this.form.user_ids.splice(index, 1) + } + }) + } + this.setFormUserIds() + }, + setFormUserIds() { + const selectRecords = this.$refs['table'].getCheckboxRecords() + this.form.user_ids = Array.from(new Set([...selectRecords.map(row => row.id), ...this.form.user_ids])).filter(i => !!i) + }, async getUsers() { this.tableLoading = true @@ -138,6 +168,7 @@ export default { this.tableData = res.data this.total = res.total this.tableLoading = false + this.setSelectRow() } catch (err) { this.tableLoading = false } @@ -158,11 +189,10 @@ export default { async submit() { if (this.$refs['table']) { this.loading = true - const selectRecords = this.$refs['table'].getCheckboxRecords() try { batchUser({ id: this.form.id, - user_ids: Array.from(new Set([...selectRecords.map(row => row.id), ...this.form.user_ids])).filter(i => !!i) + user_ids: this.form.user_ids }) // 接口中角色信息有延迟 setTimeout(() => { diff --git a/src/views/system/components/ModuleBatchUsers.vue b/src/views/system/components/ModuleBatchUsers.vue index c6d3a32..3fa3009 100644 --- a/src/views/system/components/ModuleBatchUsers.vue +++ b/src/views/system/components/ModuleBatchUsers.vue @@ -28,6 +28,8 @@ :column-config="{ resizable: true }" :checkbox-config="{ trigger: 'row', highlight: true, reserve: true }" :data="tableData" + @checkbox-change="checkboxChange" + @checkbox-all="checkAll" > @@ -104,8 +106,11 @@ export default { }, computed: {}, watch: { - 'form.user_ids': function(val, oldVal) { - this.setSelectRow() + 'form.user_ids': { + handler() { + this.setSelectRow() + }, + deep: true }, isShow(newVal) { if (newVal) { @@ -140,6 +145,31 @@ export default { } }) }, + checkboxChange({ checked, row }) { + if (!checked) { + const index = this.form.user_ids.indexOf(row.id) + if (index !== -1) { + this.form.user_ids.splice(index, 1) + } + } + this.setFormUserIds() + }, + checkAll({ checked }) { + if (!checked) { + const ids = this.tableData.map(i => i.id) + ids.forEach(id => { + const index = this.form.user_ids.indexOf(id) + if (index !== -1) { + this.form.user_ids.splice(index, 1) + } + }) + } + this.setFormUserIds() + }, + setFormUserIds() { + const selectRecords = this.$refs['table'].getCheckboxRecords() + this.form.user_ids = Array.from(new Set([...selectRecords.map(row => row.id), ...this.form.user_ids])).filter(i => !!i) + }, async getUsers() { this.tableLoading = true @@ -148,6 +178,7 @@ export default { this.tableData = res.data this.total = res.total this.tableLoading = false + this.setSelectRow() } catch (err) { this.tableLoading = false } @@ -169,12 +200,11 @@ export default { async submit() { if (this.$refs['table']) { this.loading = true - const selectRecords = this.$refs['table'].getCheckboxRecords() try { batchRoles({ ...this.form, module_id: this.moduleId, - user_ids: Array.from(new Set([...selectRecords.map(row => row.id), ...this.form.user_ids])).filter(i => !!i) + user_ids: this.form.user_ids }) // 接口中角色信息有延迟 setTimeout(() => { diff --git a/vue.config.js b/vue.config.js index 9612a45..150877b 100644 --- a/vue.config.js +++ b/vue.config.js @@ -14,7 +14,6 @@ const name = defaultSettings.title || 'vue Admin Template' // page title // You can change the port by the following methods: // port = 9528 npm run dev OR npm run dev --port = 9528 const port = process.env.port || process.env.npm_config_port || 9528 // dev port - // All configuration item explanations can be find in https://cli.vuejs.org/config/ module.exports = { /**