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

记住查询条件

parent 2f999c92
......@@ -27,8 +27,10 @@
</template>
<script>
export default {
import setParams from './setParams'
export default {
name: 'client-form',
mixins: [setParams],
data () {
return {
clientForm: {
......@@ -60,8 +62,10 @@
},
watch: {
'filter' (val) {
this.setInitParams((ret) => {
val.forEach(item => {
this.$set(this.clientForm, item.key, '')
this.$set(this.clientForm, item.key, ret[item.key] || '')
})
})
},
'clientForm': {
......@@ -71,7 +75,7 @@
deep: true
}
}
}
}
</script>
<style scoped>
......
......@@ -28,8 +28,10 @@
</template>
<script>
export default {
import setParams from './setParams'
export default {
name: 'client-header',
mixins: [setParams],
data () {
return {
search: {}
......@@ -44,14 +46,25 @@
}
},
props: ['title', 'searchKey', 'addTitle'],
created () {
this.setInitParams((ret) => {
this.$set(this.search, this.searchKey + '[keyword]', ret[this.searchKey + '[keyword]'])
})
},
watch: {
'searchKey' (val) {
this.$set(this.search, val + '[keyword]', '')
},
'search': {
handler (val) {
this.$emit('update:headerParams', this.search)
},
deep: true
}
}
}
}
</script>
<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 @@
:search-key="'ClientSearch'"
:add-title="'新建待办事项'"
@update:headerSearch="search => searchKeyword(search)"
@update:headerParams="param => paramsFormat(param)"
@update:headerAdd="() => addSch()">
</search-header>
<search-form
......@@ -53,12 +54,15 @@ import ScheduleModal from '../schedule/scheduleModal'
import LeaveMessage from '../common/leaveMessage'
import Pagenation from './schedulePagenation'
import clickOutside from '@/lib/bind'
import SetParams from '../common/setParams'
import {
requestAPI,
api
} from '@/lib/commonMixin'
export default {
name: '',
name: 'scheduleHome',
mixins: [SetParams],
components: {
SearchHeader,
......@@ -145,20 +149,32 @@ export default {
methods: {
init () {
this.getFilter()
this.getScheduleList()
},
paramsFormat (param) {
this.setParams({
...this.form,
page: this.pagenation.thispage
}, param)
},
searchKeyword (search) {
this.updateForm(search)
this.getScheduleList()
},
updateForm (search) {
Object.assign(this.form, search)
this.setParams({
...this.form,
page: this.pagenation.thispage
}, search)
this.getScheduleList()
},
updatePage (pager) {
Object.assign(this.pagenation, pager)
this.setParams({
...this.form,
page: this.pagenation.thispage
}, pager)
this.getScheduleList()
},
......@@ -206,6 +222,8 @@ export default {
},
getScheduleList () {
// 查询条件
requestAPI(api.getScheduleList, {
...this.form,
page: this.pagenation.thispage
......
......@@ -33,7 +33,7 @@ export default {
},
created () {
this.$emit('update:pager', this.pager)
// this.$emit('update:pager', this.pager)
},
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