ci-plus 1.4.4 → 1.4.6

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": "ci-plus",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "ci组件库",
5
5
  "main": "./index.ts",
6
6
  "scripts": {
@@ -21,7 +21,7 @@
21
21
  "license": "ISC",
22
22
  "dependencies": {},
23
23
  "devDependencies": {
24
- "lodash": "^4.17.21",
24
+ "lodash-es": "^4.17.21",
25
25
  "sortablejs": "^1.15.1",
26
26
  "jsbarcode": "^3.11.4",
27
27
  "@types/jsbarcode": "^3.11.4",
@@ -41,7 +41,11 @@
41
41
  </div>
42
42
  </template>
43
43
  </el-select-v2>
44
- <span class="l_increase" @click.stop="openTable">
44
+ <span
45
+ class="l_increase"
46
+ :class="props.disabled ? 'l_increase-disabled' : ''"
47
+ @click.stop="!props.disabled ? openTable() : ''"
48
+ >
45
49
  <el-icon>
46
50
  <Operation />
47
51
  </el-icon>
@@ -471,6 +475,15 @@ defineExpose({ otherChangeTo })
471
475
  width: 32px;
472
476
  z-index: 1;
473
477
  }
478
+ .l_increase:hover {
479
+ background-color: #bbe7ff;
480
+ color: #222;
481
+ }
482
+ .l_increase-disabled:hover {
483
+ background-color: var(--el-fill-color-light);
484
+ color: var(--el-text-color-regular);
485
+ cursor: no-drop;
486
+ }
474
487
 
475
488
  .el-select__wrapper {
476
489
  border-top-right-radius: unset;
@@ -10,6 +10,7 @@
10
10
  @clear="clear"
11
11
  @close="close"
12
12
  @open="open"
13
+ @getFocus="getFocus"
13
14
  >
14
15
  <template #reference="{ toggle }">
15
16
  <div style="width: 40px; height: 30px; line-height: 30px; display: flex">
@@ -49,12 +50,16 @@
49
50
  :colorh="'#2C93FF'"
50
51
  @click="toggle"
51
52
  />
53
+ <!-- <filter-icon-vue
54
+ @click="toggle"
55
+ :color="hasValue ? '#2C93FF' : ''"
56
+ /> -->
52
57
  </div>
53
58
  </div>
54
59
  </template>
55
60
  <template #default="{ closeF }">
56
61
  <el-select
57
- v-if="props.type !== 'select'"
62
+ v-if="props.type !== 'select' && props.showConnector"
58
63
  v-model="operator"
59
64
  class="m-2 input-select"
60
65
  placeholder="请选择查询类型"
@@ -76,6 +81,8 @@
76
81
  :placeholder="placeholder"
77
82
  @keydown.enter="confirm(closeF)"
78
83
  clearable
84
+ ref="numberInputRef"
85
+ type="number"
79
86
  />
80
87
  <el-input
81
88
  v-else-if="!props.type || props.type === 'text'"
@@ -83,22 +90,46 @@
83
90
  :placeholder="placeholder"
84
91
  @keydown.enter="confirm(closeF)"
85
92
  clearable
93
+ ref="textInputRef"
86
94
  />
87
95
  <el-select-v2
88
96
  v-else-if="props.type === 'select'"
89
97
  v-model="selectValue"
90
98
  :placeholder="placeholder || _selectConfig.placeholder"
91
99
  :size="_selectConfig.selectSize || 'default'"
92
- :options="_selectConfig.options"
100
+ :options="OptiosSelect"
93
101
  :clearable="_selectConfig.clearable"
94
- :filterable="_selectConfig.filterable"
95
102
  :multiple="_selectConfig.selectMultiple"
96
103
  :collapse-tags-tooltip="_selectConfig.collapseTagsTooltip"
97
104
  :collapse-tags="_selectConfig.collapseTags"
98
105
  :allow-create="_selectConfig.allowCreate"
99
106
  :default-first-option="_selectConfig.defaultFirstOption"
100
107
  :popper-class="_selectConfig.popperClass"
101
- />
108
+ :props="_selectConfig.props"
109
+ :filterable="_selectConfig.filterable"
110
+ :remote="myRemote"
111
+ :remote-method="myRemote ? remoteMethod : () => {}"
112
+ :loading="loading"
113
+ >
114
+ <template #footer v-if="props.selectConfig?.getOptions">
115
+ <el-pagination
116
+ v-model:current-page="currentPage"
117
+ v-model:page-size="pageSize"
118
+ :page-sizes="[20, 30, 50, 100, 500]"
119
+ small
120
+ :background="background"
121
+ layout=" prev, pager, next, jumper,total"
122
+ :total="selectOptionTotal"
123
+ @size-change="handleSizeChange"
124
+ @current-change="handleCurrentChange"
125
+ />
126
+ </template>
127
+ <template #loading v-if="props.selectConfig?.getOptions">
128
+ <svg class="circular" viewBox="0 0 50 50">
129
+ <circle class="path" cx="25" cy="25" r="20" fill="none" />
130
+ </svg>
131
+ </template>
132
+ </el-select-v2>
102
133
  <div class="date-picker" v-if="props.type === 'date'">
103
134
  <el-date-picker
104
135
  v-if="props.type === 'date' && operator === 'between'"
@@ -134,11 +165,11 @@
134
165
 
135
166
  <script setup lang="ts">
136
167
  defineOptions({ name: 'ci-headerInput' })
137
- // import SvgIcon from '@/components/SvgIcon.vue'
138
168
  import SvgIcon from '../svgIcon/svgicon.vue'
139
- import { computed, ref, watch } from 'vue'
140
- import lodash from 'lodash'
169
+ import { computed, ref, watch, PropType, onMounted } from 'vue'
170
+ import lodash, { debounce } from 'lodash-es'
141
171
  import headerPopover from './utils/headerPopover.vue'
172
+ import filterIconVue from './utils/filterIcon.vue'
142
173
  import { TooltipTriggerType } from 'element-plus'
143
174
 
144
175
  // 定义 props 的类型
@@ -161,6 +192,10 @@ interface SelectConfig {
161
192
  selectAllPlaceholder?: string
162
193
  optionValue?: string
163
194
  optionLabel?: string
195
+ props?: { label: string; value: string }
196
+ getOptions: (val: { page: number; limit: number; search?: string | string[] }) => Promise<any[]>
197
+ page?: number // 分页
198
+ limit?: number // 分页每页大小
164
199
  }
165
200
  // 定义排序的类型
166
201
  interface OrdersConfig {
@@ -181,34 +216,97 @@ interface Props {
181
216
  ordersConfig?: OrdersConfig // 排序的配置项
182
217
  }
183
218
 
219
+ interface PopperStyle {
220
+ [key: string]: string
221
+ }
222
+
223
+ type SType = 'text' | 'number' | 'select' | 'date' // 输入框类型
224
+
184
225
  // 使用 defineProps 和 withDefaults 来声明 props 并设置默认值
185
226
 
186
- const props = withDefaults(defineProps<Props>(), {
187
- type: 'text',
188
- initValue: '',
189
- disableFilter: false,
190
- // storePar: () => {},
191
- popperStyle: () => ({ width: '240px', height: '100px' }),
192
- selectConfig: (): SelectConfig => ({
193
- placeholder: '请选择', // 输入框的placeholder提示
194
- selectSize: 'default', // 输入框的大小
195
- selectDisabled: false, // 输入框的disabled属性
196
- clearable: true, // 是否有清除按钮
197
- filterable: true, // 是否可搜索
198
- collapseTags: true, // 是否折叠tag
199
- collapseTagsTooltip: true, // 是否显示tag的tooltip提示
200
- selectMultiple: false, // 是否多选
201
- allowCreate: false, // 是否允许创建新条目
202
- defaultFirstOption: true, // 是否默认高亮第一个选项
203
- popperClass: '', // popper的class类名
204
- selectStyle: '', // 输入框的style样式
205
- selectAll: false, // 是否显示全选按钮
206
- selectAllLabel: '全选', // 全选按钮的文本
207
- selectAllPlaceholder: '请选择', // 全选按钮的placeholder提示
208
- options: [], //select下拉选项时的 列表数据
209
- optionValue: 'value', // 选项的默认value值
210
- optionLabel: 'label' // 选项的默认label值
211
- })
227
+ const props = defineProps({
228
+ column: {
229
+ type: String,
230
+ // required: true,
231
+ default: ''
232
+ },
233
+ type: {
234
+ type: String as PropType<SType>,
235
+ default: 'text'
236
+ },
237
+ text: {
238
+ type: String,
239
+ required: true,
240
+ default: ''
241
+ },
242
+ storePar: {
243
+ type: Object,
244
+ // required: true,
245
+ default: () => {}
246
+ },
247
+
248
+ placeholder: {
249
+ type: String,
250
+ default: ''
251
+ },
252
+ initValue: {
253
+ type: [String, Number],
254
+ default: ''
255
+ },
256
+ disableFilter: {
257
+ type: Boolean,
258
+ default: false
259
+ },
260
+ popperStyle: {
261
+ type: Object as PropType<PopperStyle>,
262
+ default: () => ({ width: '240px', height: '100px' })
263
+ },
264
+ trigger: {
265
+ type: String as PropType<TooltipTriggerType>,
266
+ default: 'hover'
267
+ },
268
+ selectConfig: {
269
+ type: Object as PropType<SelectConfig>,
270
+ default: () => ({
271
+ placeholder: '请选择', // 输入框的placeholder提示
272
+ selectSize: 'default', // 输入框的大小
273
+ selectDisabled: false, // 输入框的disabled属性
274
+ clearable: true, // 是否有清除按钮
275
+ filterable: true, // 是否可搜索
276
+ collapseTags: true, // 是否折叠tag
277
+ collapseTagsTooltip: true, // 是否显示tag的tooltip提示
278
+ selectMultiple: false, // 是否多选
279
+ allowCreate: false, // 是否允许创建新条目
280
+ defaultFirstOption: true, // 是否默认高亮第一个选项
281
+ popperClass: '', // popper的class类名
282
+ selectStyle: '', // 输入框的style样式
283
+ selectAll: false, // 是否显示全选按钮
284
+ selectAllLabel: '全选', // 全选按钮的文本
285
+ selectAllPlaceholder: '请选择', // 全选按钮的placeholder提示
286
+ options: [], //select下拉选项时的 列表数据
287
+ optionValue: 'value', // 选项的默认value值
288
+ optionLabel: 'label', // 选项的默认label值
289
+ props: { label: 'label', value: 'value' },
290
+ page: 1, // 分页
291
+ limit: 8 // 分页每页大小
292
+ // getOptions: {
293
+ // type: Function,
294
+ // default: null,
295
+ // }, // 如果使用内置获取数据方法 () => Promise<any[]>
296
+ })
297
+ },
298
+ ordersConfig: {
299
+ type: Object as PropType<OrdersConfig>,
300
+ default: () => ({
301
+ enableOrder: false, // 是否开启排序 默认false 关闭的
302
+ initOrder: '' // 默认是否升序排序 默认''
303
+ })
304
+ },
305
+ // 是否使用连接符输入框
306
+ showConnector: {
307
+ type: Boolean,
308
+ default: true
309
+ }
212
310
  })
213
311
 
214
312
  // console.log('props表头', props)
@@ -232,11 +330,19 @@ const _selectConfig = computed((): SelectConfig => {
232
330
  selectAllPlaceholder: '请选择', // 全选按钮的placeholder提示
233
331
  options: [], //select下拉选项时的 列表数据
234
332
  optionValue: 'value', // 选项的默认value值
235
- optionLabel: 'label' // 选项的默认label值
333
+ optionLabel: 'label', // 选项的默认label值
334
+ props: { label: 'label', value: 'value' }, // 指定显示字段和值字段
335
+ page: 1, // 分页
336
+ limit: 8 // 分页每页大小
236
337
  }
237
338
  return lodash.assign(obj, props.selectConfig || {})
238
339
  })
239
340
 
341
+ // 根据是否传递远程获取下拉列表函数,判断是否需要开启远程搜索功能
342
+ const myRemote = computed(() => {
343
+ return props.selectConfig?.getOptions ? true : false
344
+ })
345
+
240
346
  // 根据传参重置排序配置参数的默认值
241
347
  const _ordersConfig = computed((): OrdersConfig => {
242
348
  let obj = {
@@ -283,6 +389,7 @@ const operatorOptions = ref<
283
389
  label: '不等于'
284
390
  },
285
391
  {
392
+ // 数组的第8个元素必须是介于,后面再日期的时候会禁用第8个
286
393
  value: 'between',
287
394
  label: '介于'
288
395
  }
@@ -328,7 +435,7 @@ if (props.type === 'select') {
328
435
  // 将面板宽度调整宽一些
329
436
  // 判断props.popperStyle的宽度是否为小于300px,如果是就修改为300px
330
437
  if (props.popperStyle.width && parseInt(props.popperStyle.width.replace('px', '')) < 300) {
331
- updatePopperStyle({ width: '300px' })
438
+ updatePopperStyle({ width: '460px' })
332
439
  }
333
440
  }
334
441
 
@@ -427,9 +534,14 @@ const confirm = (closeF?: Function) => {
427
534
  }
428
535
 
429
536
  // 判断input输入框中的值是否为空
430
-
431
- emits('change', obj)
432
- closeF && closeF()
537
+ if (props.showConnector) {
538
+ emits('change', obj)
539
+ closeF && closeF()
540
+ } else {
541
+ // 如果是隐藏了条件连接符下拉选择框,就只返回输入的值
542
+ emits('change', value.value)
543
+ closeF && closeF()
544
+ }
433
545
  }
434
546
 
435
547
  // 清除按钮:清空输入框和发送请求
@@ -444,13 +556,66 @@ const clear = () => {
444
556
  value.value = void 0
445
557
  confirm()
446
558
  }
447
-
559
+ const loading = ref(false)
448
560
  // 关闭面板
449
561
  const close = () => {}
450
562
  const open = () => {
563
+ if (props.selectConfig?.getOptions) {
564
+ console.log('打开', props)
565
+ // getOptins()
566
+ }
567
+ // if (props.type === 'select' && props.initValue) {
568
+ // search.value = props.initValue
569
+ // value.value = props.initValue
570
+ // getOptins()
571
+ // }
451
572
  emits('open')
452
573
  }
453
574
 
575
+ // 请求下拉列表函数
576
+ const getOptins = () => {
577
+ loading.value = true
578
+ props.selectConfig
579
+ ?.getOptions({
580
+ page: currentPage.value,
581
+ limit: pageSize.value,
582
+ search: search.value
583
+ })
584
+ .then((val: any) => {
585
+ console.log('val: ', val)
586
+ if (val.code === 200 && val.data.length > 0) {
587
+ OptiosSelect.value = val.data
588
+ // lodash.uniqBy( [...OptiosSelect.value, ...val.data], (item) => JSON.stringify(item), )
589
+ selectOptionTotal.value = val.count // 总数
590
+ } else {
591
+ OptiosSelect.value = []
592
+ selectOptionTotal.value = 0
593
+ console.log('列表数据获取失败或者为空', val.msg)
594
+ }
595
+ })
596
+ .catch((err) => {
597
+ console.log('err: ', err)
598
+ loading.value = false
599
+ })
600
+ .finally(() => {
601
+ loading.value = false
602
+ })
603
+ }
604
+
605
+ // 开启远程搜索函数
606
+ const remoteMethod = (query: string) => {
607
+ console.log('query: ', query, OptiosSelect.value.length)
608
+ if (OptiosSelect.value.length < 1 || query) {
609
+ let setQuery = (q: string) => {
610
+ search.value = q
611
+ getOptins()
612
+ }
613
+ // 防抖
614
+ let myDebounce = debounce(() => setQuery(query), 1000)
615
+ myDebounce()
616
+ }
617
+ }
618
+
454
619
  // 排序
455
620
  const orderChangtop = (val: string) => {
456
621
  console.log('升序', ordersVal.value)
@@ -492,17 +657,30 @@ const orderChangbot = (val: string) => {
492
657
  }
493
658
 
494
659
  // 监听 props.storePar 的filters 和 orders属性 然对应按钮颜色是否改变
660
+ // 如果props.showConnector为true,就监听 props.storePar 变化,如果为false就监听props.initValue 的变化
495
661
  watch(
496
- () => props.storePar,
662
+ () => {
663
+ if (props.showConnector) {
664
+ return props.storePar
665
+ } else {
666
+ return props.initValue
667
+ }
668
+ },
497
669
  (newVal, oldVal) => {
498
- // console.log('监听props.storePar', newVal, oldVal)
499
- if (newVal.filters) {
670
+ // console.log('监听输入框中值(store.params.value)变化', newVal, oldVal)
671
+ // 判断newVal是否为字符串还是对象
672
+ if (newVal && typeof newVal == 'string') {
673
+ hasValue.value = true
674
+ } else {
675
+ hasValue.value = false
676
+ }
677
+ if (newVal?.filters) {
500
678
  // 判断是否是当前列的筛选条件
501
679
  const filter = newVal.filters.find((item: any) => item.column == props.column)
502
680
  if (filter) {
503
681
  // console.log('filter: ', filter.value)
504
682
  // 判断是否是当前列的筛选条件
505
- if (filter.value) {
683
+ if (filter.value || filter) {
506
684
  hasValue.value = true
507
685
  } else {
508
686
  hasValue.value = false
@@ -511,7 +689,7 @@ watch(
511
689
  hasValue.value = false
512
690
  }
513
691
  }
514
- if (newVal.orders) {
692
+ if (newVal?.orders) {
515
693
  // 判断是否是当前列的筛选条件
516
694
  const order = newVal.orders.find((item: any) => item.column == props.column)
517
695
  if (order) {
@@ -535,6 +713,75 @@ watch(
535
713
  immediate: true
536
714
  }
537
715
  )
716
+ watch(
717
+ () => props.initValue,
718
+ (newVal, oldVal) => {
719
+ // console.log('监听props.initValue变化', newVal, oldVal)
720
+ // 判断newVal是否为字符串还是对象
721
+ if (newVal && typeof newVal == 'string') {
722
+ hasValue.value = true
723
+ } else {
724
+ hasValue.value = false
725
+ }
726
+ },
727
+ {
728
+ deep: true,
729
+ immediate: true
730
+ }
731
+ )
732
+
733
+ // 获取焦点相关代码
734
+ const textInputRef = ref()
735
+ const numberInputRef = ref()
736
+ let getFocus = () => void 0
737
+
738
+ onMounted(() => {
739
+ if (textInputRef.value) {
740
+ getFocus = () => {
741
+ textInputRef.value.focus()
742
+ }
743
+ }
744
+ if (numberInputRef.value) {
745
+ getFocus = () => {
746
+ numberInputRef.value.focus()
747
+ }
748
+ }
749
+ })
750
+ const currentPage = computed(() => {
751
+ return props.selectConfig.page || 1
752
+ })
753
+ const pageSize = computed(() => {
754
+ return props.selectConfig.limit || 8
755
+ })
756
+ const search = ref('')
757
+ const small = ref(false)
758
+ const background = ref(false) // 是否为圆角
759
+ const selectOptionTotal = ref(0)
760
+
761
+ const OptiosSelect = ref<any[]>([])
762
+ watch(
763
+ () => _selectConfig.value.options,
764
+ (newVal, oldVal) => {
765
+ OptiosSelect.value = newVal
766
+ }
767
+ )
768
+ watch(
769
+ () => props.selectConfig?.options,
770
+ (newVal, oldVal) => {
771
+ if (newVal) {
772
+ OptiosSelect.value = newVal
773
+ }
774
+ },
775
+ { deep: true, immediate: true }
776
+ )
777
+
778
+ const handleSizeChange = (val: number) => {
779
+ console.log(`${val} items per page`)
780
+ }
781
+ const handleCurrentChange = (val: number) => {
782
+ console.log(`current page: ${val}`)
783
+ getOptins()
784
+ }
538
785
  </script>
539
786
 
540
787
  <style scoped lang="scss">
@@ -16,7 +16,7 @@ import Sortable from 'sortablejs'
16
16
  import { computed, onBeforeMount, onMounted, ref } from 'vue'
17
17
  import { SortableTableIns, SortColumn } from './utils/interface'
18
18
  import sortableTableColumnCell from './index/sortableTableColumnCell'
19
- import { cloneDeep } from 'lodash'
19
+ import { cloneDeep } from 'lodash-es'
20
20
  let props = defineProps<SortableTableIns>()
21
21
  const elTableRef = ref<InstanceType<typeof ElTable>>()
22
22
  const emits = defineEmits(['update:modelValue', 'update:data'])
@@ -27,7 +27,7 @@ import Sortable from 'sortablejs'
27
27
  import { VNode, computed, ref } from 'vue'
28
28
  import { SortableTableIns, SortColumn } from './utils/interface'
29
29
  import sortableTableColumnCell from './index/sortableTableColumnCell'
30
- import { cloneDeep } from 'lodash'
30
+ import { cloneDeep } from 'lodash-es'
31
31
  let props = defineProps<SortableTableIns>()
32
32
  const elTableRef = ref<InstanceType<typeof ElTable>>()
33
33
  const emits = defineEmits(['update:modelValue', 'update:data'])
@@ -1,5 +1,3 @@
1
- <!-- @format -->
2
-
3
1
  <template>
4
2
  <svg
5
3
  t="1702537913405"
@@ -16,11 +14,7 @@
16
14
  :fill="color || '#b3b3b3'"
17
15
  p-id="1521"
18
16
  ></path>
19
- <path
20
- d="M614.4 409.6h409.6v102.4h-409.6z"
21
- :fill="color || '#b3b3b3'"
22
- p-id="1522"
23
- ></path>
17
+ <path d="M614.4 409.6h409.6v102.4h-409.6z" :fill="color || '#b3b3b3'" p-id="1522"></path>
24
18
  </svg>
25
19
  </template>
26
20
  <script lang="ts" setup>
@@ -1,5 +1,3 @@
1
- <!-- @format -->
2
-
3
1
  <template>
4
2
  <filterVue style="cursor: pointer" />
5
3
  </template>
@@ -1,5 +1,3 @@
1
- <!-- @format -->
2
-
3
1
  <template>
4
2
  <el-popover
5
3
  ref="popoverRef"
@@ -316,7 +316,7 @@ export const cardPrint = (
316
316
  r9c1: '材料厂家', // 建
317
317
  r9c2: item.center_data[0]?.material_manufacturer,
318
318
  r9c3: '材料牌号', // 建
319
- r9c4: '', // 责任人
319
+ r9c4: item.center_data[0]?.material_mark,
320
320
  r10c1: '总箱数', // 建
321
321
  r10c2: item.total_row,
322
322
  r10c3: '单重',
@@ -486,8 +486,10 @@ export const cardPrint = (
486
486
  r8c4: item.center_data[0]?.consignee, // 值
487
487
  r9c1: '材料厂家', // 建
488
488
  r9c2: item.center_data[0]?.material_manufacturer,
489
- r9c3: '抽检结果', // 建
490
- r9c4: '', // 责任人
489
+ // r9c3: '抽检结果', // 建
490
+ // r9c4: '',
491
+ r9c3: '材料牌号', // 建
492
+ r9c4: item.center_data[0]?.material_mark,
491
493
  r10c1: '返工工序',
492
494
  r10c2: item.rework_process_names,
493
495
  r10c3: '返工总数',
@@ -783,8 +785,8 @@ export const cardPrint = (
783
785
  r8c4: item.center_data[0]?.consignee, // 值
784
786
  r9c1: '材料厂商',
785
787
  r9c2: item.center_data[0]?.material_manufacturer,
786
- r9c3: '材料品牌',
787
- r9c4: '',
788
+ r9c3: '材料牌号',
789
+ r9c4: item.center_data[0]?.material_mark,
788
790
  r10c1: '总箱数',
789
791
  r10c2: item.total_row,
790
792
  r10c3: '单重',