eztech-core-components 1.0.39 → 1.0.41

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.
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <el-select
3
+ v-model="modelValue"
4
+ placeholder="Бүгд"
5
+ >
6
+ <el-option :value="null" label="Бүгд" />
7
+ <el-option :value="true" label="Тийм" />
8
+ <el-option :value="false" label="Үгүй" />
9
+ </el-select>
10
+ </template>
11
+ <script>
12
+ export default {
13
+ name: 'CoreBooleanSelect',
14
+ props: {
15
+ value: { type: Boolean, default: null }
16
+ },
17
+ computed: {
18
+ modelValue: {
19
+ get () { return this.value },
20
+ set (val) { this.$emit('input', val) }
21
+ }
22
+ }
23
+ }
24
+ </script>
@@ -7,6 +7,7 @@
7
7
  :format="format"
8
8
  :value-format="valueFormat"
9
9
  class="w-full"
10
+ style="width: 100%;"
10
11
  />
11
12
  </template>
12
13
  <script>
@@ -30,6 +30,8 @@
30
30
  :read-only="isReadonly"
31
31
  :is-sub="true"
32
32
  :statuses="statuses"
33
+ :filters="filters"
34
+ :filter="filter"
33
35
  :status-count="statusCount"
34
36
  @load="handleRefreshList"
35
37
  @excel="handleExcel"
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <div class="flex gap-1 items-center">
3
+ <el-input
4
+ v-model.number="val1"
5
+ placeholder="Эхлэх"
6
+ clearable
7
+ @clear="onClear(0)"
8
+ />
9
+ <span class="mx-1">—</span>
10
+ <el-input
11
+ v-model.number="val2"
12
+ placeholder="Дуусах"
13
+ clearable
14
+ @clear="onClear(1)"
15
+ />
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ export default {
21
+ name: 'CoreNumberRange',
22
+ props: {
23
+ value: {
24
+ type: Array,
25
+ default: () => null
26
+ }
27
+ },
28
+ computed: {
29
+ val1: {
30
+ get () {
31
+ return Array.isArray(this.value) ? this.value[0] : null
32
+ },
33
+ set (val) {
34
+ this.updateValue(0, val)
35
+ }
36
+ },
37
+ val2: {
38
+ get () {
39
+ return Array.isArray(this.value) ? this.value[1] : null
40
+ },
41
+ set (val) {
42
+ this.updateValue(1, val)
43
+ }
44
+ }
45
+ },
46
+ methods: {
47
+ updateValue (index, val) {
48
+ const normalized = (val === '' || val === undefined) ? null : val
49
+ let next = Array.isArray(this.value) ? [...this.value] : [null, null]
50
+ next[index] = normalized
51
+
52
+ // Хоёулаа null бол бүхэлдээ null болгоно
53
+ if (next[0] == null && next[1] == null) {
54
+ next = null
55
+ }
56
+
57
+ this.$emit('input', next)
58
+ this.$emit('change', next)
59
+ },
60
+ onClear (index) {
61
+ this.updateValue(index, null)
62
+ }
63
+ }
64
+ }
65
+ </script>
@@ -19,7 +19,7 @@
19
19
  @keydown.native.enter="$emit('keydown-enter')"
20
20
  @keydown="$emit('keydown', $event)"
21
21
  >
22
- <div class="text-center">
22
+ <div v-if="!notEdit" class="text-center">
23
23
  <el-button type="text" :loading="loadingVisible" @click="handleVisible()">
24
24
  Шинээр нэмэх
25
25
  </el-button>
@@ -48,7 +48,7 @@
48
48
  <span>{{ item.pos_name }} {{ item.expert_num }} {{ item.phone_num }}</span>
49
49
  </div>
50
50
  </div>
51
- <button class="text-xs text-corePrimaryText hover:bg-white rounded px-2 p-1" @click.stop.prevent="handleVisible(item._id, item.tid)">
51
+ <button v-if="!notEdit" class="text-xs text-corePrimaryText hover:bg-white rounded px-2 p-1" @click.stop.prevent="handleVisible(item._id, item.tid)">
52
52
  <i class="el-icon-edit" />
53
53
  </button>
54
54
  </div>
@@ -116,7 +116,8 @@ export default {
116
116
  disabled: { type: Boolean, default: false },
117
117
  size: { type: String, default: null },
118
118
  isSearch: { type: Boolean, default: false },
119
- placeholder: { type: String, default: 'Сонгох' }
119
+ placeholder: { type: String, default: 'Сонгох' },
120
+ notEdit: { type: Boolean, default: false }
120
121
  },
121
122
  data () {
122
123
  return {
@@ -70,7 +70,8 @@
70
70
  >
71
71
  Дахин ачаалах
72
72
  </el-button>
73
- <!-- <el-button
73
+ <el-button
74
+ v-if="!!filters?.length"
74
75
  icon="el-icon-search"
75
76
  :plain="plainButton"
76
77
  :size="sizeButton || defaultSize"
@@ -78,7 +79,7 @@
78
79
  @click="visibleSearch = true"
79
80
  >
80
81
  Дэлгэрэнгүй хайлт
81
- </el-button> -->
82
+ </el-button>
82
83
  <el-button
83
84
  v-if="buttons.textExport"
84
85
  icon="el-icon-download"
@@ -151,6 +152,37 @@
151
152
  </div>
152
153
  <!-- :highlight-current-row="selectable" -->
153
154
  <!-- @current-change="handleCurrentRowChange" -->
155
+ <div v-if="filter" class="flex flex-row flex-wrap gap-2 text-sm">
156
+ <div
157
+ v-for="item in filters.filter(c => {
158
+ const val = filter[c.field]
159
+ if (val === null || val === undefined) {
160
+ return false
161
+ }
162
+ if (typeof val === 'string' && val.trim() === '') {
163
+ return false
164
+ }
165
+ return true
166
+ })"
167
+ :key="item.field"
168
+ class="bg-white px-2 py-1 rounded flex flex-row items-center gap-2"
169
+ >
170
+ <div>
171
+ <span class="text-coreRegularText">{{ item.title }}: </span>
172
+ <span v-if="item.type === 'string'">{{ filter[item.field] }}</span>
173
+ <span v-else-if="item.type === 'boolean'">{{ filter[item.field] ? 'Тийм' : 'Үгүй' }}</span>
174
+ <span v-else-if="item.type === 'manyToOne'">{{ filter[item.field][item.props.ref_column] }}</span>
175
+ <span v-else-if="item.type === 'date'">{{ $moment(filter[item.field][0]).format('YYYY-MM-DD') }}/{{ $moment(filter[item.field][1]).format('YYYY-MM-DD') }}</span>
176
+ <span v-else-if="item.type === 'number'">{{ filter[item.field][0] }}-{{ filter[item.field][1] }}</span>
177
+ </div>
178
+ <div
179
+ class="cursor-pointer bg-coreBgHover rounded-full size-5 flex items-center justify-center text-sm text-coreSecondaryText hover:text-coreRegularText"
180
+ @click="filter[item.field] = null; handleSearch()"
181
+ >
182
+ <i class="el-icon-close" />
183
+ </div>
184
+ </div>
185
+ </div>
154
186
  <el-table
155
187
  ref="tableMain"
156
188
  v-loading="loading"
@@ -234,7 +266,7 @@
234
266
  @detail="handleDetail"
235
267
  @sort-change="$emit('sort-change', $event)"
236
268
  @search-input="$emit('search-input', $event)"
237
- @search="$emit('search')"
269
+ @search="handleSearch()"
238
270
  @change-cell-value="($event) => $emit('change-cell-value', $event)"
239
271
  />
240
272
  <!-- <el-table-column
@@ -283,7 +315,7 @@
283
315
  </div>
284
316
  </div>
285
317
  <div>
286
- <el-button v-if="search && !noSearch" icon="el-icon-search" size="mini" @click="$emit('search')" />
318
+ <el-button v-if="search && !noSearch" icon="el-icon-search" size="mini" @click="handleSearch()" />
287
319
  </div>
288
320
  </template>
289
321
  <template slot-scope="scope">
@@ -412,6 +444,10 @@
412
444
  :api-id="api_id"
413
445
  :table-id="table_id"
414
446
  :table-name="table_name"
447
+ :filters="filters"
448
+ :filter="filter"
449
+ @search="handleSearch"
450
+ @refresh="handleRefresh"
415
451
  />
416
452
  </div>
417
453
  </template>
@@ -475,6 +511,8 @@ export default {
475
511
  cellClassName: { type: Function, default: null },
476
512
  rowClassName: { type: Function, default: null },
477
513
  statuses: { type: Array, default: () => { return [] } },
514
+ filters: { type: Array, default: () => { return [] } },
515
+ filter: { type: Object, default: () => { return null } },
478
516
  statusCount: { type: Object, default: () => { return null } },
479
517
  editFields: { type: Array, default: () => { return [] } },
480
518
  totalDurationMs: { type: Number, default: () => { return null } },
@@ -496,6 +534,9 @@ export default {
496
534
  ...mapGetters('settings', ['tablePageSizes', 'windowHeight', 'ignoreTableConfig']),
497
535
  ...mapGetters('user', ['isLocked']),
498
536
  ...mapGetters(['user_position_id']),
537
+ isDevelopment () {
538
+ return process.env.NODE_ENV === 'development'
539
+ },
499
540
  isDisabled () {
500
541
  return false // this.isLocked
501
542
  },
@@ -677,6 +718,9 @@ export default {
677
718
  await this.$nextTick()
678
719
  this.$emit('load', { pageSize: this.getPageSize() })
679
720
  },
721
+ handleSearch () {
722
+ this.$emit('search')
723
+ },
680
724
  handleRefresh () {
681
725
  this.currentRow = null
682
726
  this.currentRows = []
@@ -5,27 +5,21 @@
5
5
  :width="dialogWidth"
6
6
  >
7
7
  <div v-loading="loading" class="p-4 bg-white rounded">
8
+ <!-- h-[400px] overflow-y-auto -->
8
9
  <el-form class="core-form grid grid-cols-3 gap-x-2 label-position-top" label-position="top">
9
10
  <el-form-item
10
- v-for="item in list"
11
- :key="item._id"
12
- :label="item.col_title"
13
- :class="[{
14
- 'col-span-full': item.col_type === 'manyToOne' && !item.ref_table?.startsWith('ref_')
15
- }]"
11
+ v-for="item in filters"
12
+ :key="item.field"
13
+ :label="item.title"
16
14
  >
17
- <span slot="label" class="leading-3">
18
- {{ item.col_title }}
19
- </span>
20
- <div
21
- v-if="item.col_type === 'manyToOne' && !item.ref_table?.startsWith('ref_')"
22
- class="core-form grid grid-cols-3"
23
- >
24
- <div v-for="col of item.list" :key="col._id">
25
- {{ col.col_title }}
26
- </div>
27
- </div>
28
- <el-input v-else />
15
+ <component
16
+ :value="getValue(item.field)"
17
+ :is="item.component"
18
+ v-bind="item.props"
19
+ :parent-temp="getParentTemp(item)"
20
+ clearable
21
+ @input="setValue(item.field, $event)"
22
+ />
29
23
  </el-form-item>
30
24
  </el-form>
31
25
  </div>
@@ -33,6 +27,9 @@
33
27
  <el-button type="primary" icon="el-icon-search" @click="handleSearch">
34
28
  Хайх
35
29
  </el-button>
30
+ <el-button icon="el-icon-refresh" @click="handleRefreshSearch">
31
+ Цэвэрлэх
32
+ </el-button>
36
33
  <el-button icon="el-icon-close" @click="modelVisible = false">
37
34
  Буцах
38
35
  </el-button>
@@ -40,6 +37,7 @@
40
37
  </el-dialog>
41
38
  </template>
42
39
  <script>
40
+ import { get, set } from 'lodash'
43
41
  export default {
44
42
  name: 'CoreTableSearchDetail',
45
43
  props: {
@@ -47,12 +45,15 @@ export default {
47
45
  projectId: { type: [String, Number], default: '5' },
48
46
  tableName: { type: String, default: '' },
49
47
  apiId: { type: String, default: null },
50
- tableId: { type: String, default: null }
48
+ tableId: { type: String, default: null },
49
+ filters: { type: Array, default: () => { return [] } },
50
+ filter: { type: Object, default: () => { return null } }
51
51
  },
52
52
  data () {
53
53
  return {
54
54
  loading: false,
55
- list: []
55
+ list: [],
56
+ itemValue: null
56
57
  }
57
58
  },
58
59
  computed: {
@@ -63,10 +64,29 @@ export default {
63
64
  },
64
65
  watch: {
65
66
  modelVisible () {
66
- this.handleRefresh()
67
+ // this.handleRefresh()
67
68
  }
68
69
  },
69
70
  methods: {
71
+ getParentTemp (item) {
72
+ if (['CoreSelect', 'CoreSelectOrgEmp'].includes(item.component)) {
73
+ return this.filter
74
+ }
75
+ },
76
+ handleSearch () {
77
+ this.$emit('search')
78
+ this.modelVisible = false
79
+ },
80
+ handleRefreshSearch () {
81
+ this.$emit('refresh')
82
+ this.modelVisible = false
83
+ },
84
+ getValue (field) {
85
+ return get(this.filter, field)
86
+ },
87
+ setValue (field, value) {
88
+ return set(this.filter, field, value)
89
+ },
70
90
  async handleRefresh () {
71
91
  try {
72
92
  if (!this.modelVisible) {
@@ -80,9 +100,6 @@ export default {
80
100
  } finally {
81
101
  this.loading = false
82
102
  }
83
- },
84
- handleSearch () {
85
- // console.log('search')
86
103
  }
87
104
  }
88
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eztech-core-components",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -140,6 +140,15 @@ export const tableComputed = {
140
140
  }
141
141
  return `search_${this.tableName}`
142
142
  },
143
+ localKeyFilter () {
144
+ if (this.noCache) {
145
+ return ''
146
+ }
147
+ if (!['service_', 'config_'].some(c => this.tableName?.includes(c))) {
148
+ return ''
149
+ }
150
+ return `filter_${this.tableName}`
151
+ },
143
152
  localKeyPageSize () {
144
153
  if (this.noCache) {
145
154
  return ''
@@ -160,6 +169,7 @@ export const tableData = {
160
169
  downloadingProfile: false,
161
170
  saving: false,
162
171
  search: null,
172
+ filter: null,
163
173
  visible: false,
164
174
  defaultTemp: null,
165
175
  temp: null,
@@ -795,6 +805,13 @@ export const tableMethods = {
795
805
  this.currentRow = row
796
806
  }
797
807
  },
808
+ resetFilter () {
809
+ const filter = {}
810
+ this.filters?.forEach((r) => {
811
+ filter[r.field] = null
812
+ })
813
+ this.filter = filter
814
+ },
798
815
  resetSearch () {
799
816
  const search = {}
800
817
  const setSearch = (columns, parentKeys = [], currentIndex = 0) => {
@@ -1154,6 +1171,22 @@ export const tableMethods = {
1154
1171
  }
1155
1172
  }
1156
1173
  }
1174
+ const filter = {}
1175
+ for (const filterKey in this.filter) {
1176
+ const item = this.filters.find(c => c.field === filterKey)
1177
+ const val = this.filter[filterKey]
1178
+ if (val === null || val === undefined) {
1179
+ continue
1180
+ }
1181
+ if (typeof val === 'string' && val.trim() === '') {
1182
+ continue
1183
+ }
1184
+ if (item.type === 'manyToOne') {
1185
+ filter[filterKey] = val._id
1186
+ } else {
1187
+ filter[filterKey] = val
1188
+ }
1189
+ }
1157
1190
  if (this.textWhere) {
1158
1191
  const trigger_fields = getTriggerFields(this.textWhere)
1159
1192
  for (const { localKey, localVal, operation, type } of trigger_fields) {
@@ -1172,6 +1205,7 @@ export const tableMethods = {
1172
1205
  pageSize: this.pageSize || '20',
1173
1206
  currentPage: this.currentPage,
1174
1207
  qstatus: this.qstatus,
1208
+ filter: JSON.stringify(filter),
1175
1209
  search: JSON.stringify(search),
1176
1210
  sorts: JSON.stringify(this.sorts),
1177
1211
  locale_id: this.localeId,
@@ -1196,6 +1230,9 @@ export const tableMethods = {
1196
1230
  if (this.localKeySearch) {
1197
1231
  localStorage.setItem(this.localKeySearch, JSON.stringify(this.search))
1198
1232
  }
1233
+ if (this.localKeyFilter) {
1234
+ localStorage.setItem(this.localKeyFilter, JSON.stringify(this.filter))
1235
+ }
1199
1236
  if (this.currentPage === 1) {
1200
1237
  this.handleRefreshList()
1201
1238
  } else {
@@ -1212,6 +1249,7 @@ export const tableMethods = {
1212
1249
  }
1213
1250
  const localSorts = localStorage.getItem(this.localKeySort)
1214
1251
  const localSearch = localStorage.getItem(this.localKeySearch)
1252
+ const localFilter = localStorage.getItem(this.localKeyFilter)
1215
1253
  // const localPageSize = localStorage.getItem(this.localKeyPageSize)
1216
1254
  if (localSorts && this.localKeySort) {
1217
1255
  try {
@@ -1227,6 +1265,13 @@ export const tableMethods = {
1227
1265
  localStorage.removeItem(this.localKeySearch)
1228
1266
  }
1229
1267
  }
1268
+ if (localFilter && this.localKeyFilter) {
1269
+ try {
1270
+ this.filter = { ...this.filter, ...JSON.parse(localFilter) }
1271
+ } catch (_) {
1272
+ localStorage.removeItem(this.localKeyFilter)
1273
+ }
1274
+ }
1230
1275
  // if (localPageSize && this.localKeyPageSize) {
1231
1276
  // try {
1232
1277
  // this.pageSize = Number(localPageSize)
@@ -1255,7 +1300,9 @@ export const tableMethods = {
1255
1300
  },
1256
1301
  handleRefresh () {
1257
1302
  localStorage.removeItem(this.localKeySearch)
1303
+ localStorage.removeItem(this.localKeyFilter)
1258
1304
  this.resetSearch()
1305
+ this.resetFilter()
1259
1306
  if (!this.onlyList) {
1260
1307
  this.resetTemp()
1261
1308
  }
@@ -1326,6 +1373,7 @@ export const getAsyncData = async ({
1326
1373
  const { data } = await $axios.get(configUrl, { params: { sub, id, apiName, reApi } })
1327
1374
  if (!data) {
1328
1375
  return {
1376
+ filters: null,
1329
1377
  configProjectId: null, project: null, table: null,
1330
1378
  columns: [], configTableName: null,
1331
1379
  configColFields: [], hasPassword: null, refColumns: [],
@@ -1351,7 +1399,8 @@ export const getAsyncData = async ({
1351
1399
  locales,
1352
1400
  isXypLog,
1353
1401
  columnUsers,
1354
- statuses
1402
+ statuses,
1403
+ filters
1355
1404
  } = data
1356
1405
  // console.log('data', data)
1357
1406
  if (!level && checkPermission) {
@@ -1599,6 +1648,7 @@ export const getAsyncData = async ({
1599
1648
  formReadonly,
1600
1649
  isXypLog,
1601
1650
  customExtraFields,
1602
- statuses
1651
+ statuses,
1652
+ filters
1603
1653
  }
1604
1654
  }