@tripup-company/element-ui-extended 0.0.6 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tripup-company/element-ui-extended",
3
- "version": "0.0.6",
3
+ "version": "0.0.10",
4
4
  "main": "./dist/element-ui-extended.umd.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -48,7 +48,13 @@
48
48
  },
49
49
  "files": [
50
50
  "dist/*",
51
- "src/**/*.vue"
51
+ "src/**/*.vue",
52
+ "src/services/*",
53
+ "src/models/*",
54
+ "src/lang/*",
55
+ "src/types/*",
56
+ "src/filters.js",
57
+ "src/filters-top.js"
52
58
  ],
53
59
  "description": "## Project setup ``` npm install ```",
54
60
  "repository": {
package/src/App.vue CHANGED
@@ -1,6 +1,12 @@
1
1
  <template>
2
2
  <div id="app">
3
- <composite-table :fields="fields" :filters="filters" :filters-top="filtersTop" :repository="repository"></composite-table>
3
+ <composite-table
4
+ :storageKey="'Project_name'"
5
+ :fields="fields"
6
+ :filters="filters"
7
+ :top-filter="topFilter"
8
+ :repository="repository"
9
+ ></composite-table>
4
10
  <img alt="Vue logo" src="./assets/logo.png" />
5
11
  </div>
6
12
  </template>
@@ -9,35 +15,39 @@
9
15
  import { Component, Vue } from "vue-property-decorator";
10
16
  import CompositeTable from "@/components/CompositeTable/index.vue";
11
17
  import filters from "./filters";
12
- import filtersTop from "./filters-top";
18
+ import topFilter from "./topFilter";
13
19
  import repository from "./repositories/contacts-repository";
14
20
  @Component({
15
21
  components: { CompositeTable },
16
22
  data: function () {
17
- let repo = new repository('', '/test', null);
23
+ let repo = new repository("", "/test", null);
18
24
  return {
19
25
  filters: filters,
20
- filtersTop: filtersTop,
26
+ topFilter: topFilter,
21
27
  repository: repo,
22
28
  fields: [
23
- {
24
- prop: 'full_name', label: 'Full Name',
25
- formatter: row => {
26
- return row.first_name + ' ' + row.last_name;
29
+ {
30
+ prop: "full_name",
31
+ label: "Full Name",
32
+ formatter: (row) => {
33
+ return row.first_name + " " + row.last_name;
34
+ },
27
35
  },
28
- },
29
- {
30
- prop: 'email', label: 'Email',
31
- },
32
- {
33
- prop: 'phone', label: 'Phone',
34
- },
35
- {
36
- prop: 'created_at', label: 'Created at',
37
- },
38
- ],
39
- }
40
- }
36
+ {
37
+ prop: "email",
38
+ label: "Email",
39
+ },
40
+ {
41
+ prop: "phone",
42
+ label: "Phone",
43
+ },
44
+ {
45
+ prop: "created_at",
46
+ label: "Created at",
47
+ },
48
+ ],
49
+ };
50
+ },
41
51
  })
42
52
  export default class App extends Vue {}
43
53
  </script>
@@ -1,18 +1,17 @@
1
1
  <template>
2
2
  <div v-loading="loading" class="composite-table">
3
3
  <slot>
4
- <slot name="top-filter" v-bind="{ filtersTop, search }">
5
- <generic-top-filter
6
- v-if="filtersTop.length"
7
- :filters="filtersTop"
8
- :search="search"
9
- @apply:filter="handleApplyFilter"
10
- @reset:filter="handleResetFilter"
11
- />
12
- </slot>
13
-
14
4
  <el-row :gutter="20">
15
5
  <el-col :span="18">
6
+ <slot name="quick-search-filter" v-bind="{ topFilter, search }">
7
+ <quick-search-filter
8
+ v-if="topFilter"
9
+ :filter="topFilter"
10
+ :search="topSearch"
11
+ @apply:filter="handleApplyTopFilter"
12
+ @reset:filter="handleResetTopFilter"
13
+ />
14
+ </slot>
16
15
  <slot name="table" v-bind="{ fields, data }">
17
16
  <generic-table
18
17
  :fields="fields"
@@ -58,10 +57,11 @@ import GenericTable from "@/components/GenericTable";
58
57
  import ListQueryService from "@/services/list-query-service";
59
58
  import { LocalStorageService } from "@/services/local-storage-service";
60
59
  import MetaModel from "@/models/meta-model";
61
- import GenericTopFilter from "@/components/GenericFilters/GenericTopFilter";
60
+ import QuickSearchFilter from "@/components/GenericFilters/QuickSearchFilter";
61
+ import FilterConverter from "../GenericFilters/filter-convertor";
62
62
  export default {
63
63
  components: {
64
- GenericTopFilter,
64
+ QuickSearchFilter,
65
65
  GenericFilter,
66
66
  GenericTable,
67
67
  GenericPaginator,
@@ -82,40 +82,56 @@ export default {
82
82
  default: () => [],
83
83
  type: Array,
84
84
  },
85
- filtersTop: {
86
- default: () => [],
87
- type: Array,
85
+ topFilter: {
86
+ default() {
87
+ return {};
88
+ },
89
+ type: Object,
88
90
  },
89
91
  filters: {
90
92
  default: () => [],
91
93
  type: Array,
92
94
  },
95
+ includes: {
96
+ default: "--",
97
+ type: String,
98
+ },
99
+ storageKey: {
100
+ default: "storage.key",
101
+ type: String,
102
+ },
93
103
  },
94
104
  data: function () {
95
- const localStorage = new LocalStorageService();
105
+ const localStorage = new LocalStorageService(this.storageKey);
96
106
  const listQueryService = new ListQueryService(
97
107
  this.$route ? this.$route.name : "storage.key",
98
108
  localStorage
99
109
  );
110
+ const filterConvertor = new FilterConverter();
100
111
  let search = {};
112
+ let topSearch = {};
101
113
  for (const column of this.filters) {
102
114
  search[column.name] = {
103
115
  operator: "",
104
116
  value: "",
105
117
  };
106
118
  }
107
- for (const column of this.filtersTop) {
108
- search[column.name] = {
109
- position: "top",
119
+ if (this.topFilter) {
120
+ topSearch[this.topFilter.name] = {
110
121
  value: "",
122
+ operator: this.topFilter.operator,
111
123
  };
112
124
  }
125
+
113
126
  search = Object.assign(search, listQueryService.getListQuery().search);
127
+ topSearch = Object.assign(topSearch, listQueryService.getListQuery().topSearch);
114
128
  return {
115
129
  loading: false,
116
130
  filter: {},
117
131
  data: [],
118
132
  search: search,
133
+ topSearch: topSearch,
134
+ filterConvertor: filterConvertor,
119
135
  meta: Object.assign(
120
136
  new MetaModel(),
121
137
  listQueryService.getListQuery().meta
@@ -124,6 +140,19 @@ export default {
124
140
  };
125
141
  },
126
142
  computed: {
143
+ queryFilter() {
144
+ const meta = this.listQueryService.getListQuery().meta;
145
+ const query = {
146
+ page: this.meta?.pagination?.current_page
147
+ ? this.meta.pagination.current_page
148
+ : meta.page,
149
+ limit: this.meta?.pagination?.per_page
150
+ ? this.meta.pagination.per_page
151
+ : meta.limit,
152
+ };
153
+ const filter = this.filterConvertor.applyFilter({ ...this.search, ...this.topSearch });
154
+ return { ...query, ...filter };
155
+ },
127
156
  currentPage() {
128
157
  if (this.data.meta?.pagination) {
129
158
  return this.data.meta.pagination.current_page;
@@ -154,7 +183,8 @@ export default {
154
183
  this.loading = true;
155
184
  try {
156
185
  const response = await this.repository.all(
157
- this.listQueryService.getListQuery()
186
+ this.queryFilter,
187
+ this.includes
158
188
  );
159
189
  this.data = response.data;
160
190
  Vue.set(this.data, "meta", response.meta);
@@ -174,7 +204,7 @@ export default {
174
204
  page: this.listQueryService.getListQuery().meta.page,
175
205
  },
176
206
  });
177
- this.meta.pagination.per_page = val;
207
+ Vue.set(this.data, "meta.per_page.current_page", val);
178
208
  this.fetch();
179
209
  },
180
210
  handleCurrentChange(val) {
@@ -184,34 +214,40 @@ export default {
184
214
  limit: this.listQueryService.getListQuery().meta.limit,
185
215
  },
186
216
  });
187
- this.meta.pagination.current_page = val;
217
+ Vue.set(this.data, "meta.pagination.current_page", val);
188
218
  this.fetch();
189
219
  },
190
- handleFilterChange(val) {
191
- this.filter = val;
192
- this.meta.pagination.current_page = 1;
220
+ handleFilterChange() {
221
+ Vue.set(this.data, "meta.pagination.current_page", 1);
193
222
  this.fetch();
194
223
  },
195
- handleApplyFilter(filters) {
224
+ handleApplyFilter() {
196
225
  this.listQueryService.updateListQuery({ search: this.search });
197
- this.handleFilterChange(filters);
226
+ this.handleFilterChange();
198
227
  },
199
228
  handleResetFilter() {
200
229
  for (const column in this.search) {
201
- if (this.search[column].position === "top") {
202
- this.search[column] = Object.assign(this.search[column], {
203
- value: "",
204
- });
205
- } else {
206
- this.search[column] = Object.assign(this.search[column], {
207
- operator: "",
208
- value: "",
209
- });
210
- }
230
+ this.search[column] = Object.assign(this.search[column], {
231
+ operator: "",
232
+ value: "",
233
+ });
211
234
  }
212
235
  this.listQueryService.updateListQuery({ search: {} });
213
236
  this.handleFilterChange({});
214
237
  },
238
+ handleApplyTopFilter() {
239
+ this.listQueryService.updateListQuery({ topSearch: this.topSearch });
240
+ this.handleFilterChange();
241
+ },
242
+ handleResetTopFilter() {
243
+ for (const column in this.topSearch) {
244
+ this.topSearch[column] = Object.assign(this.topSearch[column], {
245
+ value: "",
246
+ });
247
+ }
248
+ this.listQueryService.updateListQuery({ topSearch: {} });
249
+ this.handleFilterChange({});
250
+ },
215
251
  },
216
252
  };
217
253
  </script>
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <el-row class="m-b-20">
3
+ <el-col v-if="filter">
4
+ <el-input
5
+ v-if="filter.type === 'string'"
6
+ v-model="search[filter.name].value"
7
+ clearable
8
+ @clear="resetFilter"
9
+ @keyup.enter.native="applyFilter"
10
+ />
11
+ </el-col>
12
+ </el-row>
13
+ </template>
14
+
15
+ <script>
16
+ export default {
17
+ name: "QuickSearchFilter",
18
+ props: {
19
+ filter: {
20
+ type: Object,
21
+ default: () => {
22
+ return {};
23
+ },
24
+ },
25
+ search: {
26
+ type: Object,
27
+ default: () => {
28
+ return {};
29
+ },
30
+ },
31
+ },
32
+ methods: {
33
+ applyFilter() {
34
+ this.$emit("apply:filter");
35
+ },
36
+ resetFilter() {
37
+ this.$emit("reset:filter");
38
+ },
39
+ },
40
+ };
41
+ </script>
@@ -42,7 +42,6 @@ export default {
42
42
  },
43
43
  methods: {
44
44
  pageChange (val) {
45
- debugger;
46
45
  this.$emit('page:change', val);
47
46
  },
48
47
  sizeChange(val) {
@@ -3,14 +3,36 @@
3
3
  <el-table :data="data" border @sort-change="sortChange">
4
4
  <template v-for="field in fields">
5
5
  <template v-if="field.callback">
6
- <el-table-column :key="field.prop" v-slot="context" :prop="field.prop" :label="field.label" :width="field.width ? field.width : null" sortable="custom">
7
- <el-link @click="field.callback(field.prop, context.$index, context.row)">
8
- {{ typeof field.formatter === 'function' ? field.formatter(context.row) : context.row[field.prop] }}
6
+ <el-table-column
7
+ :key="field.prop"
8
+ v-slot="context"
9
+ :prop="field.prop"
10
+ :label="field.label"
11
+ :width="field.width ? field.width : null"
12
+ :sortable="field.sortable ? field.sortable : null"
13
+ >
14
+ <el-link
15
+ @click="field.callback(field.prop, context.$index, context.row)"
16
+ >
17
+ {{
18
+ typeof field.formatter === "function"
19
+ ? field.formatter(context.row)
20
+ : context.row[field.prop]
21
+ }}
9
22
  </el-link>
10
23
  </el-table-column>
11
24
  </template>
12
25
  <template v-else>
13
- <el-table-column :formatter="typeof field.formatter === 'function' ? field.formatter : null" :key="field.prop" :prop="field.prop" :label="field.label" :width="field.width ? field.width : null" sortable="custom" />
26
+ <el-table-column
27
+ :formatter="
28
+ typeof field.formatter === 'function' ? field.formatter : null
29
+ "
30
+ :key="field.prop"
31
+ :prop="field.prop"
32
+ :label="field.label"
33
+ :width="field.width ? field.width : null"
34
+ :sortable="field.sortable ? field.sortable : null"
35
+ />
14
36
  </template>
15
37
  </template>
16
38
  </el-table>
@@ -18,7 +40,6 @@
18
40
  </template>
19
41
 
20
42
  <script>
21
-
22
43
  export default {
23
44
  name: "GenericTable",
24
45
  props: {
@@ -44,8 +65,8 @@ export default {
44
65
  },
45
66
  methods: {
46
67
  sortChange(data) {
47
- this.$emit('sort:change', data);
48
- }
49
- }
68
+ this.$emit("sort:change", data);
69
+ },
70
+ },
50
71
  };
51
72
  </script>
package/src/filters.js ADDED
@@ -0,0 +1,64 @@
1
+ export default [
2
+ {
3
+ name: 'title',
4
+ label: 'Title',
5
+ type: 'string',
6
+ },
7
+ {
8
+ name: 'first_name',
9
+ label: 'First Name',
10
+ type: 'string',
11
+ },
12
+ {
13
+ name: 'last_name',
14
+ label: 'Last Name',
15
+ type: 'string',
16
+ },
17
+ {
18
+ name: 'email',
19
+ label: 'Email',
20
+ type: 'string',
21
+ },
22
+ {
23
+ name: 'phone',
24
+ label: 'Phone',
25
+ type: 'string',
26
+ },
27
+ {
28
+ name: 'mobile',
29
+ label: 'Mobile',
30
+ type: 'string',
31
+ },
32
+ {
33
+ name: 'position',
34
+ label: 'Position',
35
+ type: 'string',
36
+ },
37
+ {
38
+ name: 'street',
39
+ label: 'Street',
40
+ type: 'string',
41
+ },
42
+ {
43
+ name: 'zip_code',
44
+ label: 'Zip Code',
45
+ type: 'string',
46
+ },
47
+ {
48
+ name: 'city',
49
+ label: 'City',
50
+ type: 'string',
51
+ },
52
+ {
53
+ name: 'state',
54
+ label: 'State',
55
+ type: 'string',
56
+ },
57
+
58
+ {
59
+ name: 'created_at',
60
+ label: 'Created at',
61
+ type: 'date',
62
+ operator: 'between_date',
63
+ },
64
+ ];
package/src/lang/en.js ADDED
@@ -0,0 +1,167 @@
1
+ export default {
2
+ common: {
3
+ back: 'Back',
4
+ return: 'Return',
5
+ },
6
+ route: {
7
+ dashboard: 'Dashboard',
8
+ introduction: 'Introduction',
9
+ documentation: 'Documentation',
10
+ guide: 'Guide',
11
+ permission: 'Permission',
12
+ pagePermission: 'Page Permission',
13
+ directivePermission: 'Directive Permission',
14
+ icons: 'Icons',
15
+ components: 'Components',
16
+ componentIndex: 'Introduction',
17
+ tinymce: 'Tinymce',
18
+ markdown: 'Markdown',
19
+ jsonEditor: 'JSON Editor',
20
+ dndList: 'Dnd List',
21
+ splitPane: 'SplitPane',
22
+ avatarUpload: 'Avatar Upload',
23
+ dropzone: 'Dropzone',
24
+ sticky: 'Sticky',
25
+ countTo: 'CountTo',
26
+ componentMixin: 'Mixin',
27
+ backToTop: 'BackToTop',
28
+ dragDialog: 'Drag Dialog',
29
+ dragSelect: 'Drag Select',
30
+ dragKanban: 'Drag Kanban',
31
+ charts: 'Charts',
32
+ keyboardChart: 'Keyboard Chart',
33
+ lineChart: 'Line Chart',
34
+ mixChart: 'Mix Chart',
35
+ example: 'Example',
36
+ nested: 'Nested Routes',
37
+ menu1: 'Menu 1',
38
+ 'menu1-1': 'Menu 1-1',
39
+ 'menu1-2': 'Menu 1-2',
40
+ 'menu1-2-1': 'Menu 1-2-1',
41
+ 'menu1-2-2': 'Menu 1-2-2',
42
+ 'menu1-3': 'Menu 1-3',
43
+ menu2: 'Menu 2',
44
+ Table: 'Table',
45
+ dynamicTable: 'Dynamic Table',
46
+ dragTable: 'Drag Table',
47
+ inlineEditTable: 'Inline Edit',
48
+ complexTable: 'Complex Table',
49
+ treeTable: 'Tree Table',
50
+ customTreeTable: 'Custom TreeTable',
51
+ tab: 'Tab',
52
+ form: 'Form',
53
+ createArticle: 'Create Article',
54
+ editArticle: 'Edit Article',
55
+ articleList: 'Article List',
56
+ errorPages: 'Error Pages',
57
+ page401: '401',
58
+ page404: '404',
59
+ errorLog: 'Error Log',
60
+ excel: 'Excel',
61
+ exportExcel: 'Export Excel',
62
+ selectExcel: 'Export Selected',
63
+ uploadExcel: 'Upload Excel',
64
+ zip: 'Zip',
65
+ exportZip: 'Export Zip',
66
+ theme: 'Theme',
67
+ clipboardDemo: 'Clipboard',
68
+ i18n: 'I18n',
69
+ externalLink: 'External Link',
70
+ },
71
+ navbar: {
72
+ logOut: 'Log Out',
73
+ dashboard: 'Dashboard',
74
+ github: 'Github',
75
+ screenfull: 'Screenfull',
76
+ theme: 'Theme',
77
+ size: 'Global Size',
78
+ },
79
+ login: {
80
+ title: 'Laravel Vue Admin',
81
+ logIn: 'Log in',
82
+ username: 'Username',
83
+ email: 'Email',
84
+ password: 'Password',
85
+ any: 'any',
86
+ thirdparty: 'Or connect with',
87
+ thirdpartyTips: 'Can not be simulated on local, so please combine you own business simulation! ! !',
88
+ },
89
+ documentation: {
90
+ documentation: 'Documentation',
91
+ github: 'Github Repository',
92
+ laravel: 'Laravel',
93
+ },
94
+ permission: {
95
+ roles: 'Your roles',
96
+ switchRoles: 'Switch roles',
97
+ tips: 'In some cases it is not suitable to use v-permission, such as element Tab component or el-table-column and other asynchronous rendering dom cases which can only be achieved by manually setting the v-if.',
98
+ pageDescription: 'This place is accessible for admin only. Switching to non-admin role will redirect to 404 page',
99
+ },
100
+ guide: {
101
+ description: 'The guide page is useful for some people who entered the project for the first time. You can briefly introduce the features of the project. Demo is based on ',
102
+ button: 'Show Guide',
103
+ },
104
+ components: {
105
+ documentation: 'Documentation',
106
+ tinymceTips: 'Rich text editor is a core part of management system, but at the same time is a place with lots of problems. In the process of selecting rich texts, I also walked a lot of detours. The common rich text editors in the market are basically used, and the finally chose Tinymce. See documentation for more detailed rich text editor comparisons and introductions.',
107
+ dropzoneTips: 'Because my business has special needs, and has to upload images to qiniu, so instead of a third party, I chose encapsulate it by myself. It is very simple, you can see the detail code in @/components/Dropzone.',
108
+ stickyTips: 'When the page is scrolled to the preset position will be sticky on the top.',
109
+ backToTopTips1: 'When the page is scrolled to the specified position, the Back to Top button appears in the lower right corner',
110
+ backToTopTips2: 'You can customize the style of the button, show / hide, height of appearance, height of the return. If you need a text prompt, you can use element-ui el-tooltip elements externally',
111
+ imageUploadTips: 'Since I was using only the vue@1 version, and it is not compatible with mockjs at the moment, I modified it myself, and if you are going to use it, it is better to use official version.',
112
+ },
113
+ table: {
114
+ dynamicTips1: 'Fixed header, sorted by header order',
115
+ dynamicTips2: 'Not fixed header, sorted by click order',
116
+ dragTips1: 'The default order',
117
+ dragTips2: 'The after dragging order',
118
+ title: 'Title',
119
+ importance: 'Imp',
120
+ type: 'Type',
121
+ remark: 'Remark',
122
+ search: 'Search',
123
+ add: 'Add',
124
+ export: 'Export',
125
+ reviewer: 'reviewer',
126
+ id: 'ID',
127
+ date: 'Date',
128
+ author: 'Author',
129
+ readings: 'Readings',
130
+ status: 'Status',
131
+ actions: 'Actions',
132
+ edit: 'Edit',
133
+ publish: 'Publish',
134
+ draft: 'Draft',
135
+ delete: 'Delete',
136
+ cancel: 'Cancel',
137
+ confirm: 'Confirm',
138
+ },
139
+ errorLog: {
140
+ tips: 'Please click the bug icon in the upper right corner',
141
+ description: 'Now the management system are basically the form of the spa, it enhances the user experience, but it also increases the possibility of page problems, a small negligence may lead to the entire page deadlock. Fortunately Vue provides a way to catch handling exceptions, where you can handle errors or report exceptions.',
142
+ documentation: 'Document introduction',
143
+ },
144
+ excel: {
145
+ export: 'Export',
146
+ selectedExport: 'Export Selected Items',
147
+ placeholder: 'Please enter the file name(default excel-list)',
148
+ },
149
+ zip: {
150
+ export: 'Export',
151
+ placeholder: 'Please enter the file name(default file)',
152
+ },
153
+ pdf: {
154
+ tips: 'Here we use window.print() to implement the feature of downloading pdf.',
155
+ },
156
+ theme: {
157
+ change: 'Change Theme',
158
+ documentation: 'Theme documentation',
159
+ tips: 'Tips: It is different from the theme-pick on the navbar is two different skinning methods, each with different application scenarios. Refer to the documentation for details.',
160
+ },
161
+ tagsView: {
162
+ refresh: 'Refresh',
163
+ close: 'Close',
164
+ closeOthers: 'Close Others',
165
+ closeAll: 'Close All',
166
+ },
167
+ };
@@ -0,0 +1,23 @@
1
+ import Vue from 'vue';
2
+ import VueI18n from 'vue-i18n';
3
+ import elementEnLocale from 'element-ui/lib/locale/lang/en'; // element-ui lang
4
+ import enLocale from './en';
5
+
6
+ Vue.use(VueI18n);
7
+
8
+ const messages = {
9
+ en: {
10
+ ...enLocale,
11
+ ...elementEnLocale,
12
+ },
13
+ };
14
+
15
+ const i18n = new VueI18n({
16
+ // set locale
17
+ // options: en | zh | vi
18
+ locale: 'en',
19
+ // set locale messages
20
+ messages,
21
+ });
22
+
23
+ export default i18n;
@@ -0,0 +1,10 @@
1
+ export class BaseModel {
2
+ constructor(data: any) {
3
+ if (data === null) {
4
+ return;
5
+ }
6
+ for (const key in data) {
7
+ this[key] = data[key];
8
+ }
9
+ }
10
+ }