diff --git a/vue-table/components/HeaderQuery.vue b/vue-table/components/HeaderQuery.vue new file mode 100644 index 0000000..37e5e40 --- /dev/null +++ b/vue-table/components/HeaderQuery.vue @@ -0,0 +1,108 @@ + + + + + + diff --git a/vue-table/components/Table.vue b/vue-table/components/Table.vue new file mode 100644 index 0000000..9af8a66 --- /dev/null +++ b/vue-table/components/Table.vue @@ -0,0 +1,556 @@ + + + + + + + + diff --git a/vue-table/store/index.js b/vue-table/store/index.js new file mode 100644 index 0000000..b8cd516 --- /dev/null +++ b/vue-table/store/index.js @@ -0,0 +1,27 @@ +/* + * @Author: your name + * @Date: 2020-09-07 10:17:01 + * @LastEditTime: 2021-02-18 14:51:58 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit, + * @FilePath: \dbadmin\src\store\index.js + */ +import Vue from 'vue' +import Vuex from 'vuex' +import query from './modules/query' + +Vue.use(Vuex) + +const store = new Vuex.Store({ + modules: { + app, + api, + user, + tagsView, + permission, + query + }, + getters +}) + +export default store diff --git a/vue-table/store/modules/query.js b/vue-table/store/modules/query.js new file mode 100644 index 0000000..52698e3 --- /dev/null +++ b/vue-table/store/modules/query.js @@ -0,0 +1,88 @@ +/* + * @Author: your name + * @Date: 2020-10-28 14:40:52 + * @LastEditTime: 2020-12-29 14:33:05 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit + * @FilePath: \dbadmin\src\store\modules\query.js + */ +import { Module, VuexModule, Mutation } from 'vuex-module-decorators' + +export const DEFAULT_TAG = 'default' + +function nullObj() { + return Object.create(null) +} + +@Module({ name: 'query', namespaced: true }) +class Query extends VuexModule { + data = nullObj() + + pageData = nullObj() + + fetchs = nullObj() + + @Mutation + init(data) { + let path = '' + let initData = nullObj() + let tag = DEFAULT_TAG + if (typeof data === 'string') { + path = data + } else if (typeof data === 'object') { + if (data.path) path = data.path + if (data.initData) initData = data.initData + if (data.tag) tag = data.tag + } + if (!path) throw new Error('path不能为空') + initPath.call(this, path) + if (!this.data[path][tag]) { + this.data[path][tag] = initData + } + if (!this.pageData[path][tag]) { + this.pageData[path][tag] = { + page: 1, + size: 20 + } + } + } + + @Mutation + setData({ path, data, tag = DEFAULT_TAG }) { + initPath.call(this, path) + this.data[path][tag] = data + } + + @Mutation + registerFetch({ path, func, tag = DEFAULT_TAG }) { + initPath.call(this, path) + this.fetchs[path][tag] = func + } + + @Mutation + unregisterFetch(path, tag = DEFAULT_TAG) { + initPath.call(this, path) + delete this.fetchs[path][tag] + } +} + +function initPath(path) { + if (this instanceof Window) { + throw new Error('initPath this对象没有绑定') + } + if (!this.data[path]) this.data[path] = nullObj() + if (!this.pageData[path]) this.pageData[path] = nullObj() + if (!this.fetchs[path]) this.fetchs[path] = nullObj() +} + +// function initTag(path, tag) { +// if (this instanceof Window) { +// throw new Error('initPath this对象没有绑定') +// } +// initTag.call(path) +// if (!this.data[path][tag]) this.data[path][tag] = nullObj() +// if (!this.pageData[path][tag]) this.pageData[path][tag] = nullObj() +// if (!this.fetchs[path][tag]) this.fetchs[path][tag] = nullObj() +// } + +export default Query