Commit e245e3ec by amateur

自律规则

1 parent 3d3125d2
<template>
<section class="module-search-layout">
<nafm-header :navClass="navClass || 'nafmii-head-bg3'">
<template slot="bottom">
<SearchInput v-model="keyword" @search="handleSearch" :placeholder="placeholder || $t('home.searchPlaceholder')" />
</template>
</nafm-header>
<main>
<SearchHistory :stateKey="stateKey" @jumpPage="handleSearch" />
</main>
</section>
</template>
<script>
import SearchInput from './SearchInput'
import SearchHistory from './SearchHistory'
export default {
name: 'ModuleSearchLayout',
components: { SearchInput, SearchHistory },
props: {
navClass: String,
placeholder: String,
stateKey: String,
defKeyword: String
},
data () {
return {
keyword: this.defKeyword
}
},
methods: {
handleSearch (val) {
const param = { stateKey: this.stateKey, value: val }
this.$store.dispatch('search/APushSearchValue', param)
this.$emit('onSearch', val)
}
},
}
</script>
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,9 @@ const Routers = [ ...@@ -4,7 +4,9 @@ const Routers = [
name: 'SelfRegulating', name: 'SelfRegulating',
meta: { meta: {
title: '自律规则', title: '自律规则',
isLogin: false isLogin: false,
keepAlive: true,
keepAlivePage: ['SelfRegulatingSearch']
}, },
component: () => import(/* webpackChunkName: "SelfRegulating" */ '@/views/selfregulating/index.vue') // 自律规则 component: () => import(/* webpackChunkName: "SelfRegulating" */ '@/views/selfregulating/index.vue') // 自律规则
}, },
......
...@@ -3,6 +3,7 @@ const Types = { ...@@ -3,6 +3,7 @@ const Types = {
Home: { size: 10 }, Home: { size: 10 },
RegIssue: { size: 10 }, RegIssue: { size: 10 },
InfoDisclosure: { size: 10 }, InfoDisclosure: { size: 10 },
SelfRegulating: { size: 10 }
} }
import utils from '@/utils/index' import utils from '@/utils/index'
...@@ -11,53 +12,54 @@ export default { ...@@ -11,53 +12,54 @@ export default {
state: { state: {
Home: [], Home: [],
RegIssue: [], RegIssue: [],
InfoDisclosure: [] InfoDisclosure: [],
SelfRegulating: []
}, },
mutations: { mutations: {
MSetHistoryDatas(state, { key, datas }) { MSetHistoryDatas (state, { key, datas }) {
state[key] = datas state[key] = datas
}, },
MSetHomeHistory(state, datas) { MSetHomeHistory (state, datas) {
state.Home = datas state.Home = datas
}, },
MSetRegIssueHistory(state, datas) { MSetRegIssueHistory (state, datas) {
state.RegIssue = datas state.RegIssue = datas
}, },
MSetInfoDisclosureHistory(state, datas) { MSetInfoDisclosureHistory (state, datas) {
state.InfoDisclosure = datas state.InfoDisclosure = datas
}, },
MCleanHistory(state, stateKey) { MCleanHistory (state, stateKey) {
state[stateKey] = [] state[stateKey] = []
} }
}, },
actions: { actions: {
ACleanHistory({ commit }, stateKey) { ACleanHistory ({ commit }, stateKey) {
commit('MCleanHistory', stateKey) commit('MCleanHistory', stateKey)
}, },
APushSearchValue({ state, commit }, param = {}) { APushSearchValue ({ state, commit }, param = {}) {
const { stateKey, value } = param const { stateKey, value } = param
if (Object.hasOwnProperty.call(Types, stateKey)) { if (Object.hasOwnProperty.call(Types, stateKey)) {
const newDatas = pushSearchValue(state[stateKey], value, Types[stateKey].size) const newDatas = pushSearchValue(state[stateKey], value, Types[stateKey].size)
commit('MSetHistoryDatas', { key: stateKey, value: newDatas }) commit('MSetHistoryDatas', { key: stateKey, datas: newDatas })
} }
}, },
APushHomeSearchValue({ state, commit }, val) { APushHomeSearchValue ({ state, commit }, val) {
const newDatas = pushSearchValue(state.Home, val, Types.Home.size) const newDatas = pushSearchValue(state.Home, val, Types.Home.size)
commit('MSetHomeHistory', newDatas) commit('MSetHomeHistory', newDatas)
}, },
APushRegIssueSearchValue({ state, commit }, val) { APushRegIssueSearchValue ({ state, commit }, val) {
const newDatas = pushSearchValue(state.RegIssue, val, Types.RegIssue.size) const newDatas = pushSearchValue(state.RegIssue, val, Types.RegIssue.size)
commit('MSetRegIssueHistory', newDatas) commit('MSetRegIssueHistory', newDatas)
}, },
APushInfoDisclosureSearchValue({ state, commit }, val) { APushInfoDisclosureSearchValue ({ state, commit }, val) {
const newDatas = pushSearchValue(state.InfoDisclosure, val, Types.InfoDisclosure.size) const newDatas = pushSearchValue(state.InfoDisclosure, val, Types.InfoDisclosure.size)
commit('MSetInfoDisclosureHistory', newDatas) commit('MSetInfoDisclosureHistory', newDatas)
}, },
...@@ -67,7 +69,7 @@ export default { ...@@ -67,7 +69,7 @@ export default {
} }
function pushSearchValue(datas, value, size) { function pushSearchValue (datas, value, size) {
const newDatas = [...datas] const newDatas = [...datas]
if (!utils.isNull(value) && newDatas.indexOf(value) === -1) { if (!utils.isNull(value) && newDatas.indexOf(value) === -1) {
......
...@@ -21,13 +21,19 @@ export default { ...@@ -21,13 +21,19 @@ export default {
tab: { tab: {
type: Object, type: Object,
default: () => { return {} } default: () => { return {} }
} },
keyword: String
}, },
data () { data () {
return { return {
isRefresh: false, isRefresh: false,
} }
}, },
watch: {
keyword (val) {
this.isRefresh = true
}
},
methods: { methods: {
handleLoad (param) { handleLoad (param) {
return new Promise(resolve => { return new Promise(resolve => {
...@@ -46,7 +52,7 @@ export default { ...@@ -46,7 +52,7 @@ export default {
} }
] ]
}) })
}, 2000); }, 1000);
}) })
} }
} }
......
...@@ -2,32 +2,35 @@ ...@@ -2,32 +2,35 @@
<div class="self-regulating"> <div class="self-regulating">
<nafm-header navClass="nafmii-head-bg3"> <nafm-header navClass="nafmii-head-bg3">
<template slot="bottom"> <template slot="bottom">
<SearchInput :placeholder="$t('home.searchPlaceholder')" /> <SearchInput v-model="keyword" readonly @click="handleSearch" :placeholder="$t('home.searchPlaceholder')" />
<div class="nav-placeholder"></div> <div class="nav-placeholder"></div>
</template> </template>
</nafm-header> </nafm-header>
<van-tabs v-model="active" animated scrollspy swipe-threshold="3" class="data-tabs"> <van-tabs v-model="active" animated scrollspy swipe-threshold="3" class="data-tabs">
<van-tab :title="item.name" v-for="(item,idx) in tabs" :key="idx"> <van-tab :title="item.name" v-for="(item,idx) in tabs" :key="idx">
<DataListLayout :tab="item" /> <DataListLayout :keyword="keyword" :tab="item" />
</van-tab> </van-tab>
</van-tabs> </van-tabs>
</div> </div>
</template> </template>
<script> <script>
import mixinKeepAlive from '@/mixins/mixinKeepAlive'
import { KeywordBus } from '@/utils/eventBus'
import SearchInput from '@/components/SearchInput' import SearchInput from '@/components/SearchInput'
import DataListLayout from './components/DataListLayout' import DataListLayout from './components/DataListLayout'
export default { export default {
name: 'SelfRegulating', name: 'SelfRegulating',
mixins: [mixinKeepAlive],
components: { SearchInput, DataListLayout }, components: { SearchInput, DataListLayout },
data () { data () {
return { return {
active: 0, active: 0,
keyword: null,
tabs: [] tabs: []
} }
}, },
methods: { methods: {
handleTabs () { handleTabs () {
setTimeout(() => { setTimeout(() => {
this.tabs = [ this.tabs = [
...@@ -39,10 +42,23 @@ export default { ...@@ -39,10 +42,23 @@ export default {
{ id: 6, name: '其他' }, { id: 6, name: '其他' },
] ]
}, 100); }, 100);
},
handleSearch () {
this.$router.push({ name: 'SelfRegulatingSearch' })
},
initKeywordListener () {
KeywordBus.on((val) => {
this.keyword = val
})
} }
}, },
mounted () { mounted () {
this.handleTabs() this.handleTabs()
this.initKeywordListener()
},
destroyed () {
KeywordBus.off()
} }
} }
</script> </script>
......
<template> <template>
<ModuleSearchLayout @onSearch="handleSearch" stateKey="SelfRegulating" />
</template> </template>
<script> <script>
import { KeywordBus } from '@/utils/eventBus'
import ModuleSearchLayout from '@/components/ModuleSearchLayout'
export default { export default {
name: 'SelfRegulatingSearch' name: 'SelfRegulatingSearch',
components: { ModuleSearchLayout },
data () {
return {
}
},
methods: {
handleSearch (val) {
KeywordBus.emit(val)
this.$router.back();
}
}
} }
</script> </script>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!