diff --git a/package.json b/package.json index 21be7df..e8dd90b 100755 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ "dependencies": { "@element-plus/icons-vue": "^2.0.9", "@smallwei/avue": "^3.2.12", + "@wangeditor/editor": "^5.1.23", + "@wangeditor/editor-for-vue": "^5.1.12", "animate.css": "^4.1.1", "axios": "^0.21.1", "crypto-js": "^4.1.1", diff --git a/src/components/avue-ueditor/main.vue b/src/components/avue-ueditor/main.vue new file mode 100644 index 0000000..81d8f5e --- /dev/null +++ b/src/components/avue-ueditor/main.vue @@ -0,0 +1,55 @@ + + + + + \ No newline at end of file diff --git a/src/mac/index.vue b/src/mac/index.vue index 770aeb8..894769d 100644 --- a/src/mac/index.vue +++ b/src/mac/index.vue @@ -126,8 +126,10 @@ export default { location.reload(); }, logout () { + this.$store.commit('SET_THEME_NAME', '') this.$store.dispatch("LogOut").then(() => { this.$router.push({ path: "/login" }); + location.reload(); }); }, startTimer () { diff --git a/src/main.js b/src/main.js index d4d1be9..619db0e 100755 --- a/src/main.js +++ b/src/main.js @@ -14,6 +14,7 @@ import crudCommon from '@/mixins/crud.js' import { getScreen } from './utils/util' import './permission'; import error from './error'; +import avueUeditor from 'components/avue-Ueditor/main.vue' import basicBlock from 'components/basic-block/main.vue' import basicContainer from 'components/basic-container/main.vue' import thirdRegister from './components/third-register/main.vue'; @@ -31,6 +32,7 @@ const app = createApp(App) for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } +app.component('avueUeditor', avueUeditor) app.component('basicContainer', basicContainer) app.component('basicBlock', basicBlock) app.component('thirdRegister', thirdRegister); diff --git a/src/mixins/crud.js b/src/mixins/crud.js index 5fac6fb..639588c 100644 --- a/src/mixins/crud.js +++ b/src/mixins/crud.js @@ -1,3 +1,4 @@ +import { mapGetters } from "vuex"; export default (app, option = {}) => { let optionObj = import.meta.glob(`../option/**/**`)[`../option/${option.name}.js`] let apiObj = import.meta.glob(`../api/**/**`)[`../api/${option.name}.js`] @@ -14,13 +15,21 @@ export default (app, option = {}) => { } }, created () { - optionObj().then(mode => this.option = mode.default(this)) + optionObj().then(mode => this.option = mode.default) apiObj().then(mode => { this.api = mode this.getList() }) }, computed: { + ...mapGetters(['userInfo', 'permission', 'roles']), + ids () { + const ids = []; + this.selectionList.forEach(ele => { + ids.push(ele[this.rowKey]); + }); + return ids.join(","); + }, bindVal () { return { ref: 'crud', @@ -49,12 +58,8 @@ export default (app, option = {}) => { getList () { const callback = () => { this.loading = true; - let pageParams = {} - pageParams[option.pageNumber || 'pageNumber'] = this.page.currentPage - pageParams[option.pageSize || 'pageSize'] = this.page.pageSize - const data = Object.assign(pageParams, this.params) this.data = []; - this.api[option.list || 'list'](data).then(res => { + this.api[option.list || 'getList'](this.page.currentPage, this.page.pageSize, this.params).then(res => { this.loading = false; let data; if (option.res) { @@ -63,12 +68,10 @@ export default (app, option = {}) => { data = res.data.data } this.page.total = data[option.total || 'total']; - const result = data[option.data || 'data']; + const result = data[option.data || 'records']; this.data = result; if (this.listAfter) { this.listAfter(data) - } else { - this.$message.success('获取成功') } }) } @@ -85,7 +88,7 @@ export default (app, option = {}) => { if (this.addAfter) { this.addAfter(data) } else { - this.$message.success('新增成功') + this.$message.success('新增成功'); } done(); }).catch(() => { @@ -100,12 +103,12 @@ export default (app, option = {}) => { rowUpdate (row, index, done, loading) { const callback = () => { delete this.form.params; - this.api[option.update || 'update'](row[this.rowKey], this.form, index).then((data) => { + this.api[option.update || 'update'](this.form).then((data) => { this.getList(); if (this.updateAfter) { this.updateAfter(data) } else { - this.$message.success('更新成功') + this.$message.success('更新成功'); } done() }).catch(() => { @@ -124,7 +127,7 @@ export default (app, option = {}) => { if (this.delAfter) { this.delAfter(data, row, index) } else { - this.$message.success('删除成功') + this.$message.success('删除成功'); } }) } @@ -132,21 +135,60 @@ export default (app, option = {}) => { this.delBefore() callback() } else { - this.$confirm(`此操作将永久删除序号【${index}】的数据, 是否继续?`, '提示', { + this.$confirm('确定将选择数据删除?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { - callback() + callback(); }) } }, + handleDelete () { + if (this.selectionList.length === 0) { + this.$message.warning("请选择至少一条数据"); + return; + } + this.$confirm("确定将选择数据删除?", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }) + .then(() => { + this.api[option.del || 'remove'](this.ids).then((data) => { + this.getList(); + if (this.delMultiAfter) { + this.delMultiAfter(data, this.ids); + } else { + this.$message.success('删除成功'); + } + }); + }); + }, searchChange (params, done) { if (done) done(); this.params = params; this.page.currentPage = 1; this.getList(); }, + dateChange (date) { + if (date) { + this.params.createTime_dategt = date[0]; + this.params.createTime_datelt = date[1]; + } else { + delete this.params.createTime_dategt; + delete this.params.createTime_datelt; + } + this.page.currentPage = 1; + this.getList(); + }, + selectionChange (list) { + this.selectionList = list; + }, + selectionClear () { + this.selectionList = []; + this.$refs.crud.toggleSelection(); + }, refreshChange () { this.getList(); }, diff --git a/src/page/index/top/top-menu.vue b/src/page/index/top/top-menu.vue index 6f6c797..7f46998 100755 --- a/src/page/index/top/top-menu.vue +++ b/src/page/index/top/top-menu.vue @@ -4,18 +4,22 @@ mode="horizontal" text-color="#333"> - - - + + + -