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
......@@ -4,7 +4,9 @@ const Routers = [
name: 'SelfRegulating',
meta: {
title: '自律规则',
isLogin: false
isLogin: false,
keepAlive: true,
keepAlivePage: ['SelfRegulatingSearch']
},
component: () => import(/* webpackChunkName: "SelfRegulating" */ '@/views/selfregulating/index.vue') // 自律规则
},
......
......@@ -3,6 +3,7 @@ const Types = {
Home: { size: 10 },
RegIssue: { size: 10 },
InfoDisclosure: { size: 10 },
SelfRegulating: { size: 10 }
}
import utils from '@/utils/index'
......@@ -11,53 +12,54 @@ export default {
state: {
Home: [],
RegIssue: [],
InfoDisclosure: []
InfoDisclosure: [],
SelfRegulating: []
},
mutations: {
MSetHistoryDatas(state, { key, datas }) {
MSetHistoryDatas (state, { key, datas }) {
state[key] = datas
},
MSetHomeHistory(state, datas) {
MSetHomeHistory (state, datas) {
state.Home = datas
},
MSetRegIssueHistory(state, datas) {
MSetRegIssueHistory (state, datas) {
state.RegIssue = datas
},
MSetInfoDisclosureHistory(state, datas) {
MSetInfoDisclosureHistory (state, datas) {
state.InfoDisclosure = datas
},
MCleanHistory(state, stateKey) {
MCleanHistory (state, stateKey) {
state[stateKey] = []
}
},
actions: {
ACleanHistory({ commit }, stateKey) {
ACleanHistory ({ commit }, stateKey) {
commit('MCleanHistory', stateKey)
},
APushSearchValue({ state, commit }, param = {}) {
APushSearchValue ({ state, commit }, param = {}) {
const { stateKey, value } = param
if (Object.hasOwnProperty.call(Types, stateKey)) {
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)
commit('MSetHomeHistory', newDatas)
},
APushRegIssueSearchValue({ state, commit }, val) {
APushRegIssueSearchValue ({ state, commit }, val) {
const newDatas = pushSearchValue(state.RegIssue, val, Types.RegIssue.size)
commit('MSetRegIssueHistory', newDatas)
},
APushInfoDisclosureSearchValue({ state, commit }, val) {
APushInfoDisclosureSearchValue ({ state, commit }, val) {
const newDatas = pushSearchValue(state.InfoDisclosure, val, Types.InfoDisclosure.size)
commit('MSetInfoDisclosureHistory', newDatas)
},
......@@ -67,7 +69,7 @@ export default {
}
function pushSearchValue(datas, value, size) {
function pushSearchValue (datas, value, size) {
const newDatas = [...datas]
if (!utils.isNull(value) && newDatas.indexOf(value) === -1) {
......
......@@ -21,13 +21,19 @@ export default {
tab: {
type: Object,
default: () => { return {} }
}
},
keyword: String
},
data () {
return {
isRefresh: false,
}
},
watch: {
keyword (val) {
this.isRefresh = true
}
},
methods: {
handleLoad (param) {
return new Promise(resolve => {
......@@ -46,7 +52,7 @@ export default {
}
]
})
}, 2000);
}, 1000);
})
}
}
......
......@@ -2,32 +2,35 @@
<div class="self-regulating">
<nafm-header navClass="nafmii-head-bg3">
<template slot="bottom">
<SearchInput :placeholder="$t('home.searchPlaceholder')" />
<SearchInput v-model="keyword" readonly @click="handleSearch" :placeholder="$t('home.searchPlaceholder')" />
<div class="nav-placeholder"></div>
</template>
</nafm-header>
<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">
<DataListLayout :tab="item" />
<DataListLayout :keyword="keyword" :tab="item" />
</van-tab>
</van-tabs>
</div>
</template>
<script>
import mixinKeepAlive from '@/mixins/mixinKeepAlive'
import { KeywordBus } from '@/utils/eventBus'
import SearchInput from '@/components/SearchInput'
import DataListLayout from './components/DataListLayout'
export default {
name: 'SelfRegulating',
mixins: [mixinKeepAlive],
components: { SearchInput, DataListLayout },
data () {
return {
active: 0,
keyword: null,
tabs: []
}
},
methods: {
handleTabs () {
setTimeout(() => {
this.tabs = [
......@@ -39,10 +42,23 @@ export default {
{ id: 6, name: '其他' },
]
}, 100);
},
handleSearch () {
this.$router.push({ name: 'SelfRegulatingSearch' })
},
initKeywordListener () {
KeywordBus.on((val) => {
this.keyword = val
})
}
},
mounted () {
this.handleTabs()
this.initKeywordListener()
},
destroyed () {
KeywordBus.off()
}
}
</script>
......
<template>
<ModuleSearchLayout @onSearch="handleSearch" stateKey="SelfRegulating" />
</template>
<script>
import { KeywordBus } from '@/utils/eventBus'
import ModuleSearchLayout from '@/components/ModuleSearchLayout'
export default {
name: 'SelfRegulatingSearch'
name: 'SelfRegulatingSearch',
components: { ModuleSearchLayout },
data () {
return {
}
},
methods: {
handleSearch (val) {
KeywordBus.emit(val)
this.$router.back();
}
}
}
</script>
\ 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!