Commit d0a10db2 authored by huai.li's avatar huai.li

记住查询条件

parent 2f999c92
...@@ -27,8 +27,10 @@ ...@@ -27,8 +27,10 @@
</template> </template>
<script> <script>
export default { import setParams from './setParams'
export default {
name: 'client-form', name: 'client-form',
mixins: [setParams],
data () { data () {
return { return {
clientForm: { clientForm: {
...@@ -60,8 +62,10 @@ ...@@ -60,8 +62,10 @@
}, },
watch: { watch: {
'filter' (val) { 'filter' (val) {
this.setInitParams((ret) => {
val.forEach(item => { val.forEach(item => {
this.$set(this.clientForm, item.key, '') this.$set(this.clientForm, item.key, ret[item.key] || '')
})
}) })
}, },
'clientForm': { 'clientForm': {
...@@ -71,7 +75,7 @@ ...@@ -71,7 +75,7 @@
deep: true deep: true
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
......
...@@ -28,8 +28,10 @@ ...@@ -28,8 +28,10 @@
</template> </template>
<script> <script>
export default { import setParams from './setParams'
export default {
name: 'client-header', name: 'client-header',
mixins: [setParams],
data () { data () {
return { return {
search: {} search: {}
...@@ -44,14 +46,25 @@ ...@@ -44,14 +46,25 @@
} }
}, },
props: ['title', 'searchKey', 'addTitle'], props: ['title', 'searchKey', 'addTitle'],
created () { created () {
this.setInitParams((ret) => {
this.$set(this.search, this.searchKey + '[keyword]', ret[this.searchKey + '[keyword]'])
})
}, },
watch: { watch: {
'searchKey' (val) { 'searchKey' (val) {
this.$set(this.search, val + '[keyword]', '') this.$set(this.search, val + '[keyword]', '')
},
'search': {
handler (val) {
this.$emit('update:headerParams', this.search)
},
deep: true
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
......
export default {
methods: {
setInitParams (cb) {
let ret = null
let parentName = this.$parent.$options && this.$parent.$options.name
if (window.localStorage && parentName) {
let l = window.localStorage
ret = JSON.parse(l.getItem(parentName))
}
if (ret) {
cb && cb(ret)
}
},
setParams (obj, param) {
let key = this.$options && this.$options.name
let l = this.isHasLocalStorage()
let value = {}
if (l && key) {
if (l.getItem(key)) {
value = JSON.parse(l.getItem(key))
} else {
value = obj
}
}
let ret = Object.assign(value, param)
l.setItem(key, JSON.stringify(ret))
return ret
},
isHasLocalStorage () {
return window.localStorage
}
}
}
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
:search-key="'ClientSearch'" :search-key="'ClientSearch'"
:add-title="'新建待办事项'" :add-title="'新建待办事项'"
@update:headerSearch="search => searchKeyword(search)" @update:headerSearch="search => searchKeyword(search)"
@update:headerParams="param => paramsFormat(param)"
@update:headerAdd="() => addSch()"> @update:headerAdd="() => addSch()">
</search-header> </search-header>
<search-form <search-form
...@@ -53,12 +54,15 @@ import ScheduleModal from '../schedule/scheduleModal' ...@@ -53,12 +54,15 @@ import ScheduleModal from '../schedule/scheduleModal'
import LeaveMessage from '../common/leaveMessage' import LeaveMessage from '../common/leaveMessage'
import Pagenation from './schedulePagenation' import Pagenation from './schedulePagenation'
import clickOutside from '@/lib/bind' import clickOutside from '@/lib/bind'
import SetParams from '../common/setParams'
import { import {
requestAPI, requestAPI,
api api
} from '@/lib/commonMixin' } from '@/lib/commonMixin'
export default { export default {
name: '', name: 'scheduleHome',
mixins: [SetParams],
components: { components: {
SearchHeader, SearchHeader,
...@@ -145,20 +149,32 @@ export default { ...@@ -145,20 +149,32 @@ export default {
methods: { methods: {
init () { init () {
this.getFilter() this.getFilter()
this.getScheduleList() },
paramsFormat (param) {
this.setParams({
...this.form,
page: this.pagenation.thispage
}, param)
}, },
searchKeyword (search) { searchKeyword (search) {
this.updateForm(search) this.getScheduleList()
}, },
updateForm (search) { updateForm (search) {
Object.assign(this.form, search) this.setParams({
...this.form,
page: this.pagenation.thispage
}, search)
this.getScheduleList() this.getScheduleList()
}, },
updatePage (pager) { updatePage (pager) {
Object.assign(this.pagenation, pager) this.setParams({
...this.form,
page: this.pagenation.thispage
}, pager)
this.getScheduleList() this.getScheduleList()
}, },
...@@ -206,6 +222,8 @@ export default { ...@@ -206,6 +222,8 @@ export default {
}, },
getScheduleList () { getScheduleList () {
// 查询条件
requestAPI(api.getScheduleList, { requestAPI(api.getScheduleList, {
...this.form, ...this.form,
page: this.pagenation.thispage page: this.pagenation.thispage
......
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
}, },
created () { created () {
this.$emit('update:pager', this.pager) // this.$emit('update:pager', this.pager)
}, },
methods: { methods: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment