From 27127f0ef5751ead5190a4ab276b53a067a62191 Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Tue, 1 Aug 2023 17:33:54 +0800 Subject: [PATCH] 2023-8-1 --- src/components/Reception/Search.vue | 22 +++++++++---- src/store/modules/reception.js | 16 +++++++++ src/views/reception/home/index.vue | 7 ++-- src/views/reception/list1/index.vue | 50 ++++++++++++++++++++--------- 4 files changed, 69 insertions(+), 26 deletions(-) diff --git a/src/components/Reception/Search.vue b/src/components/Reception/Search.vue index 61c6e8c..5e03533 100644 --- a/src/components/Reception/Search.vue +++ b/src/components/Reception/Search.vue @@ -93,12 +93,21 @@ export default { } }, methods: { - typeSelect (i) { - if (this.$store.state.reception.select.leixing == i.value) { - this.$store.commit('reception/SET_SELECTED',{ key: 'leixing',value: '' }) + typeSelect ({ value }) { + let leixing = this.$store.state.reception.select.leixing ? this.$store.state.reception.select.leixing.split(',') : [] + if (leixing.find(i => i == value)) { + leixing.splice(leixing.indexOf(leixing.find(i => i == value)), 1) + this.$store.commit('reception/SET_SELECTED',{ key: 'leixing',value: leixing.toString() }) } else { - this.$store.commit('reception/SET_SELECTED',{ key: 'leixing',value: i.value }) + leixing.push(value) + this.$store.commit('reception/SET_SELECTED',{ key: 'leixing',value: leixing.toString() }) + } + if (this.$route.fullPath === '/index/home') { this.$router.push('/index/list1') + return + } + if (this.$route.fullPath === '/index/list1') { + window.getMaterial() } }, @@ -120,8 +129,9 @@ export default { }, computed: { isSelectedType () { - return function (i) { - return i.value == this.$store.state.reception.select.leixing + return function ({ value }) { + let leixing = this.$store.state.reception.select.leixing ? this.$store.state.reception.select.leixing.split(',') : [] + return leixing.find(i => i == value) } }, diff --git a/src/store/modules/reception.js b/src/store/modules/reception.js index 48c7f3e..af9372e 100644 --- a/src/store/modules/reception.js +++ b/src/store/modules/reception.js @@ -23,6 +23,22 @@ const mutations = { SET_SELECTED: (state, { key, value, refresh = false }) => { if (refresh) { for(let key in state.select) { + if (key === 'page') { + state.select[key] = 1 + continue + } + if (key === 'page_size') { + state[key] = 10 + continue + } + if (key === 'table_name') { + state[key] = 'materials' + continue + } + if (key === 'sort_type') { + state[key] = 'desc' + continue + } state.select[key] = '' } } diff --git a/src/views/reception/home/index.vue b/src/views/reception/home/index.vue index f0edfe1..06704f0 100644 --- a/src/views/reception/home/index.vue +++ b/src/views/reception/home/index.vue @@ -291,13 +291,12 @@ export default { console.log(this.labelGroup); }, - toList ({ tag, dept, leixing, sort_name }) { - console.log(111, sort_name, leixing) + toList ({ tag, dept, sort_name }) { + console.log(111, sort_name) tag?.id ? this.$store.commit('reception/SET_SELECTED',{ key: 'tag_id', value: tag.id, refresh: true }) : '' dept?.id ? this.$store.commit('reception/SET_SELECTED',{ key: 'dept_id', value: dept.id, refresh: true }) : '' - leixing ? this.$store.commit('reception/SET_SELECTED',{ key: 'leixing', value: leixing }) : '' sort_name ? this.$store.commit('reception/SET_SELECTED',{ key: 'sort_name', value: sort_name, refresh: true }) : '' - this.$router.push(`/index/list1?${this.$store.getters.select}`) + this.$router.push('/index/list1') } }, computed: { diff --git a/src/views/reception/list1/index.vue b/src/views/reception/list1/index.vue index 6f18d94..b84b644 100644 --- a/src/views/reception/list1/index.vue +++ b/src/views/reception/list1/index.vue @@ -25,7 +25,10 @@
-
+
{{ i.wenjian }}【{{ i.nianfen }}】{{ i.bianhao }}号
{{ i.biaoti }}
@@ -180,20 +183,25 @@ export default { }; }, methods: { - typeSelect(i) { - if (this.$store.state.reception.select.leixing == i.value) { + typeSelect({ value }) { + let leixing = this.$store.state.reception.select.leixing + ? this.$store.state.reception.select.leixing.split(",") + : []; + if (leixing.find((i) => i == value)) { + leixing.splice(leixing.indexOf(leixing.find((i) => i == value)), 1); this.$store.commit("reception/SET_SELECTED", { key: "leixing", - value: "", + value: leixing.toString(), }); } else { + leixing.push(value); this.$store.commit("reception/SET_SELECTED", { key: "leixing", - value: i.value, + value: leixing.toString(), }); } - this.getMaterial() + this.getMaterial(); }, async getMaterial() { @@ -229,26 +237,36 @@ export default { }, computed: { isSelectedType() { - return function (i) { - return i.value == this.$store.state.reception.select.leixing; + return function ({ value }) { + let leixing = this.$store.state.reception.select.leixing + ? this.$store.state.reception.select.leixing.split(",") + : []; + return leixing.find((i) => i == value); }; }, type() { - return ( - this.formType.find( - (i) => i.value === this.$store.state.reception.select.leixing - )?.label || "全部文件" - ); + return this.formType + .filter((i) => + (this.$store.state.reception.select.leixing + ? this.$store.state.reception.select.leixing.split(",") + : [] + ).find((j) => j == i.value) + ) + .map((i) => i.label) + .toString(); }, }, mounted() { this.getMaterial(); }, + created() { + window.getMaterial = this.getMaterial; + }, beforeRouteEnter(to, from, next) { - next(vm => { - vm.getMaterial() - }) + next((vm) => { + vm.getMaterial(); + }); }, };