2019-10-24 16:01:11 +08:00
|
|
|
/*
|
|
|
|
* @Author: Volankey@gmail.com
|
|
|
|
* @Company: Tusimple
|
2019-10-25 19:28:04 +08:00
|
|
|
* @Date: 2019-10-25 11:31:12
|
2019-12-18 18:07:22 +08:00
|
|
|
* @LastEditors : Jiwen.bai
|
|
|
|
* @LastEditTime : 2019-12-18 17:46:19
|
2019-10-24 16:01:11 +08:00
|
|
|
*/
|
2019-10-25 19:28:04 +08:00
|
|
|
let Vue = null
|
|
|
|
export class Store {
|
|
|
|
constructor (options = {}) {
|
|
|
|
const store = this
|
|
|
|
store._vm = new Vue({
|
|
|
|
data: {
|
|
|
|
$$state: {
|
2019-11-08 12:06:03 +08:00
|
|
|
currentHoverRow: 1,
|
2019-12-10 18:49:06 +08:00
|
|
|
currentTableEl: null,
|
|
|
|
selectedAllChecked: false
|
2019-10-25 19:28:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
get state () {
|
|
|
|
return this._vm._data.$$state
|
|
|
|
}
|
|
|
|
commit (type, payload) {
|
|
|
|
Vue.set(this._vm._data.$$state, type, payload)
|
|
|
|
// this.state[type] = payload
|
|
|
|
}
|
|
|
|
}
|
2019-10-24 16:01:11 +08:00
|
|
|
|
2019-10-25 19:28:04 +08:00
|
|
|
function vuexInit () {
|
|
|
|
const options = this.$options
|
|
|
|
const _Vue = options.Vue
|
|
|
|
if (_Vue) {
|
|
|
|
Vue = _Vue
|
|
|
|
}
|
|
|
|
// store injection
|
2019-12-18 18:07:22 +08:00
|
|
|
if (options.parent && options.parent.$tableStore) {
|
|
|
|
this.$tableStore = options.parent.$tableStore
|
|
|
|
} else if (!this.$tableStore) {
|
|
|
|
this.$tableStore = new Store()
|
2019-10-24 16:01:11 +08:00
|
|
|
}
|
|
|
|
}
|
2019-10-25 19:28:04 +08:00
|
|
|
export const storageMixin = {
|
|
|
|
beforeCreate: vuexInit
|
|
|
|
}
|