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

记住查询条件

parent 2f999c92
...@@ -27,51 +27,55 @@ ...@@ -27,51 +27,55 @@
</template> </template>
<script> <script>
export default { import setParams from './setParams'
name: 'client-form', export default {
data () { name: 'client-form',
return { mixins: [setParams],
clientForm: { data () {
} return {
clientForm: {
} }
}, }
props: ['filter'], },
methods: { props: ['filter'],
setSortIcon () { methods: {
if (this.clientForm['Filter[sort]'] === '') { setSortIcon () {
return 'fa-sort-amount-desc' if (this.clientForm['Filter[sort]'] === '') {
} else if (this.clientForm['Filter[sort]'] === 'DESC') { return 'fa-sort-amount-desc'
return 'fa-sort-amount-desc' } else if (this.clientForm['Filter[sort]'] === 'DESC') {
} else { return 'fa-sort-amount-desc'
return 'fa-sort-amount-asc' } else {
} return 'fa-sort-amount-asc'
},
timeSort () {
if (this.clientForm['Filter[sort]'] === '') {
this.clientForm['Filter[sort]'] = 'ASC'
} else if (this.clientForm['Filter[sort]'] === 'ASC') {
this.clientForm['Filter[sort]'] = 'DESC'
} else {
this.clientForm['Filter[sort]'] = 'ASC'
}
} }
}, },
created () { timeSort () {
}, if (this.clientForm['Filter[sort]'] === '') {
watch: { this.clientForm['Filter[sort]'] = 'ASC'
'filter' (val) { } else if (this.clientForm['Filter[sort]'] === 'ASC') {
this.clientForm['Filter[sort]'] = 'DESC'
} else {
this.clientForm['Filter[sort]'] = 'ASC'
}
}
},
created () {
},
watch: {
'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': {
handler (val) {
this.$emit('update:clientList', val)
}, },
'clientForm': { deep: true
handler (val) {
this.$emit('update:clientList', val)
},
deep: true
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -28,30 +28,43 @@ ...@@ -28,30 +28,43 @@
</template> </template>
<script> <script>
export default { import setParams from './setParams'
name: 'client-header', export default {
data () { name: 'client-header',
return { mixins: [setParams],
search: {} data () {
} return {
}, search: {}
methods: { }
searchKeyword () { },
this.$emit('update:headerSearch', this.search) methods: {
}, searchKeyword () {
addNew () { this.$emit('update:headerSearch', this.search)
this.$emit('update:headerAdd')
}
}, },
props: ['title', 'searchKey', 'addTitle'], addNew () {
created () { this.$emit('update:headerAdd')
}
},
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]', '')
}, },
watch: {
'searchKey' (val) { 'search': {
this.$set(this.search, val + '[keyword]', '') 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