eztech-core-components 1.0.39 → 1.0.40

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.40",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -160,6 +160,7 @@ export const tableData = {
160
160
  downloadingProfile: false,
161
161
  saving: false,
162
162
  search: null,
163
+ filter: null,
163
164
  visible: false,
164
165
  defaultTemp: null,
165
166
  temp: null,
@@ -795,6 +796,13 @@ export const tableMethods = {
795
796
  this.currentRow = row
796
797
  }
797
798
  },
799
+ resetFilter () {
800
+ const filter = {}
801
+ this.filters?.forEach((r) => {
802
+ filter[r.field] = null
803
+ })
804
+ this.filter = filter
805
+ },
798
806
  resetSearch () {
799
807
  const search = {}
800
808
  const setSearch = (columns, parentKeys = [], currentIndex = 0) => {
@@ -1154,6 +1162,22 @@ export const tableMethods = {
1154
1162
  }
1155
1163
  }
1156
1164
  }
1165
+ const filter = {}
1166
+ for (const filterKey in this.filter) {
1167
+ const item = this.filters.find(c => c.field === filterKey)
1168
+ const val = this.filter[filterKey]
1169
+ if (val === null || val === undefined) {
1170
+ continue
1171
+ }
1172
+ if (typeof val === 'string' && val.trim() === '') {
1173
+ continue
1174
+ }
1175
+ if (item.type === 'manyToOne') {
1176
+ filter[filterKey] = val._id
1177
+ } else {
1178
+ filter[filterKey] = val
1179
+ }
1180
+ }
1157
1181
  if (this.textWhere) {
1158
1182
  const trigger_fields = getTriggerFields(this.textWhere)
1159
1183
  for (const { localKey, localVal, operation, type } of trigger_fields) {
@@ -1172,6 +1196,7 @@ export const tableMethods = {
1172
1196
  pageSize: this.pageSize || '20',
1173
1197
  currentPage: this.currentPage,
1174
1198
  qstatus: this.qstatus,
1199
+ filter: JSON.stringify(filter),
1175
1200
  search: JSON.stringify(search),
1176
1201
  sorts: JSON.stringify(this.sorts),
1177
1202
  locale_id: this.localeId,
@@ -1256,6 +1281,7 @@ export const tableMethods = {
1256
1281
  handleRefresh () {
1257
1282
  localStorage.removeItem(this.localKeySearch)
1258
1283
  this.resetSearch()
1284
+ this.resetFilter()
1259
1285
  if (!this.onlyList) {
1260
1286
  this.resetTemp()
1261
1287
  }
@@ -1326,6 +1352,7 @@ export const getAsyncData = async ({
1326
1352
  const { data } = await $axios.get(configUrl, { params: { sub, id, apiName, reApi } })
1327
1353
  if (!data) {
1328
1354
  return {
1355
+ filters: null,
1329
1356
  configProjectId: null, project: null, table: null,
1330
1357
  columns: [], configTableName: null,
1331
1358
  configColFields: [], hasPassword: null, refColumns: [],
@@ -1351,7 +1378,8 @@ export const getAsyncData = async ({
1351
1378
  locales,
1352
1379
  isXypLog,
1353
1380
  columnUsers,
1354
- statuses
1381
+ statuses,
1382
+ filters
1355
1383
  } = data
1356
1384
  // console.log('data', data)
1357
1385
  if (!level && checkPermission) {
@@ -1599,6 +1627,7 @@ export const getAsyncData = async ({
1599
1627
  formReadonly,
1600
1628
  isXypLog,
1601
1629
  customExtraFields,
1602
- statuses
1630
+ statuses,
1631
+ filters
1603
1632
  }
1604
1633
  }