ci-plus 1.1.7 → 1.1.9

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.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "ci组件库",
5
5
  "main": "./index.ts",
6
6
  "scripts": {
@@ -21,7 +21,8 @@
21
21
  "sortablejs": "^1.15.1",
22
22
  "vite-plugin-svg-icons": "^2.0.1",
23
23
  "jsbarcode": "^3.11.6",
24
- "dayjs": "^1.11.9"
24
+ "dayjs": "^1.11.9",
25
+ "vue-draggable-plus": "^0.4.0"
25
26
  },
26
27
  "devDependencies": {},
27
28
  "peerDependencies": {},
@@ -30,10 +30,11 @@
30
30
  defineOptions({ name: 'ci-seeFile' })
31
31
  import { ref, watch } from 'vue'
32
32
  import axios from 'axios'
33
+ import apis from '../utils/baseApi'
33
34
  import { ElMessage } from 'element-plus'
34
35
 
35
36
  interface Props {
36
- url?: string[] // 传入要显示的附件地址数组
37
+ url: string[] // 传入要显示的附件地址数组
37
38
  baseUrl?: string // 图片展示的基础路径
38
39
  }
39
40
 
@@ -76,12 +77,13 @@ const fileArr = (url: string, pathArr: string[]) => {
76
77
  }
77
78
  }
78
79
  }
79
-
80
+ const { storageModule } = apis
81
+ let fileURL = new URL(storageModule).origin + '/' // 附件的地址前缀
80
82
  const emits = defineEmits(['onClick'])
81
83
  const pathArr = ref<any[]>([])
82
84
  // 对数组中的每个字符串应用处理函数
83
85
  // @ts-ignore
84
- pathArr.value = setFilePath(props.url, props.baseUrl || 'http://10.20.72.231:9999/')
86
+ pathArr.value = setFilePath(props.url, props.baseUrl || fileURL)
85
87
 
86
88
  // 监听props.url的变化
87
89
  watch(
@@ -89,7 +91,7 @@ watch(
89
91
  (newVal) => {
90
92
  // 对新值进行处理
91
93
  // @ts-ignore
92
- pathArr.value = setFilePath(newVal, props.baseUrl || 'http://10.20.72.231:9999/')
94
+ pathArr.value = setFilePath(newVal, props.baseUrl || fileURL)
93
95
  },
94
96
  {
95
97
  immediate: true, // 是否立即执行
@@ -190,11 +190,13 @@
190
190
  <td colspan="2">{{ item.r3c2 }}</td>
191
191
  </tr>
192
192
  <tr>
193
- <td>客户名称</td>
193
+ <!-- 供应商 -->
194
+ <td>{{ item.r4c1 }}</td>
194
195
  <td colspan="2">{{ item.r4c2 }}</td>
195
196
  </tr>
196
197
  <tr>
197
- <td>流转批号</td>
198
+ <!-- 材料厂商 -->
199
+ <td>{{ item.r5c1 }}</td>
198
200
  <td colspan="2">{{ item.r5c2 }}</td>
199
201
  <td colspan="2" class="content">
200
202
  {{ item.r5c4 }}
@@ -232,6 +234,11 @@
232
234
  {{ item.r9c4 }}
233
235
  </td>
234
236
  </tr>
237
+ <tr>
238
+ <!-- 批次号 -->
239
+ <td>{{ item.r10c1 }}</td>
240
+ <td colspan="3">{{ item.r10c2 }}</td>
241
+ </tr>
235
242
  <tr>
236
243
  <td>备注</td>
237
244
  <td colspan="3">{{ item.r12c2 }}</td>
@@ -417,11 +424,13 @@
417
424
  <td colspan="2">{{ item.r3c2 }}</td>
418
425
  </tr>
419
426
  <tr>
420
- <td>客户名称</td>
427
+ <!-- 供应商 -->
428
+ <td>{{ item.r4c1 }}</td>
421
429
  <td colspan="2">{{ item.r4c2 }}</td>
422
430
  </tr>
423
431
  <tr>
424
- <td>流转批号</td>
432
+ <!-- 材料厂商 -->
433
+ <td>{{ item.r5c1 }}</td>
425
434
  <td colspan="2">{{ item.r5c2 }}</td>
426
435
  <td colspan="2" class="content">
427
436
  {{ item.r5c4 }}
@@ -472,15 +481,21 @@
472
481
  </td>
473
482
  </tr>
474
483
  <tr>
475
- <td>备注</td>
484
+ <!-- 批次号 -->
485
+ <td>{{ item.r12c1 }}</td>
476
486
  <td colspan="3">{{ item.r12c2 }}</td>
477
487
  </tr>
488
+ <tr>
489
+ <!-- 备注 -->
490
+ <td>{{ item.r13c1 }}</td>
491
+ <td colspan="3">{{ item.r13c2 }}</td>
492
+ </tr>
478
493
  <tr>
479
494
  <td colspan="4">
480
495
  <div class="b2bcode" style="margin: 1px">
481
496
  <bar-code
482
497
  :key="item + new Date()"
483
- :value="item.r13c1"
498
+ :value="item.r14c1"
484
499
  :maxWidth="myWidth"
485
500
  :newClass="index"
486
501
  ></bar-code>
@@ -531,7 +546,7 @@
531
546
  <td colspan="2">{{ item.r3c2 }}</td>
532
547
  </tr>
533
548
  <tr>
534
- <td>流转批号</td>
549
+ <td>批次号</td>
535
550
  <td colspan="2">{{ item.r4c2 }}</td>
536
551
  </tr>
537
552
  <tr>
@@ -1125,7 +1140,7 @@
1125
1140
  <td colspan="2">{{ item.r3c2 }}</td>
1126
1141
  </tr>
1127
1142
  <tr>
1128
- <td>流转批号</td>
1143
+ <td>批次号</td>
1129
1144
  <td colspan="2">{{ item.r4c2 }}</td>
1130
1145
  </tr>
1131
1146
  <tr>
@@ -1,44 +1,7 @@
1
- <!-- @format -->
2
-
3
1
  <template>
4
2
  <div style="display: flex; align-items: center; justify-content: center">
5
3
  <span>{{ text }}</span>
6
-
7
4
  <div class="myporpove" id="myinputs">
8
- <!-- <el-button @click.stop="handleButtonClick"> </el-button> -->
9
-
10
- <!-- <el-popover
11
- ref="popover"
12
- :title="text"
13
- content="这是一段内容,这是一段内容。"
14
- :visible="visible"
15
- >
16
- <template #reference>
17
- <div style="width: 23px; height: 16px">
18
- <svg-icon
19
- name="mysearch"
20
- size="15"
21
- :color="value ? '#2C93FF' : ''"
22
- @click="toggle"
23
- />
24
- </div>
25
- </template>
26
- <el-select
27
- v-model="operator"
28
- class="m-2 input-select"
29
- placeholder="请选择查询类型"
30
- size="default"
31
- clearable
32
- >
33
- <el-option
34
- v-for="item in options"
35
- :key="item.value"
36
- :label="item.label"
37
- :value="item.value"
38
- />
39
- </el-select>
40
- </el-popover> -->
41
-
42
5
  <header-popover
43
6
  :popperStyle="PopperStyle"
44
7
  :trigger="trigger"
@@ -172,11 +135,10 @@
172
135
  <script setup lang="ts">
173
136
  defineOptions({ name: 'ci-headerInput' })
174
137
  import SvgIcon from '@/components/SvgIcon.vue'
175
- import { computed, ref, watch, toRefs } from 'vue'
138
+ import { computed, ref, watch } from 'vue'
176
139
  import lodash from 'lodash'
177
140
  import headerPopover from './utils/headerPopover.vue'
178
141
  import { TooltipTriggerType } from 'element-plus'
179
- const popover = ref()
180
142
 
181
143
  // 定义 props 的类型
182
144
  interface SelectConfig {
@@ -440,17 +402,19 @@ if (props.type !== 'date') {
440
402
  watch(operator, (newVal, oldVal) => {
441
403
  console.log('operator.value: ', newVal, oldVal)
442
404
  if (newVal == 'between' || oldVal == 'between') {
405
+ console.log('重置value的值')
443
406
  value.value = ''
444
407
  }
445
408
  })
446
409
 
447
410
  // 返回面板数据
448
411
  const confirm = (closeF?: Function) => {
449
- if (props.selectConfig.selectMultiple) {
450
- operator.value = 'in'
412
+ // 下拉列表框选值的时候处理最终值
413
+ if (props.type === 'select' && props.selectConfig.selectMultiple) {
414
+ operator.value = 'in' // 多选
451
415
  value.value = selectValue.value?.join(',') || ''
452
- } else {
453
- operator.value = '='
416
+ } else if (props.type === 'select' && !props.selectConfig.selectMultiple) {
417
+ operator.value = '=' // 单选
454
418
  value.value = selectValue.value
455
419
  }
456
420
  // 将当前参数的值放到对象中
@@ -469,6 +433,13 @@ const confirm = (closeF?: Function) => {
469
433
 
470
434
  // 清除按钮:清空输入框和发送请求
471
435
  const clear = () => {
436
+ // 如果是select下拉框,就清空select的值
437
+ if (props.type === 'select' && props.selectConfig.selectMultiple) {
438
+ selectValue.value = []
439
+ } else if (props.type === 'select' && !props.selectConfig.selectMultiple) {
440
+ selectValue.value = void 0
441
+ }
442
+
472
443
  value.value = void 0
473
444
  confirm()
474
445
  }
@@ -478,67 +449,7 @@ const close = () => {}
478
449
  const open = () => {
479
450
  emits('open')
480
451
  }
481
- /*
482
- const handleShow = () => {
483
- console.log('打开')
484
- visible.value = true
485
- document.addEventListener('mousedown', handleDocumentClick)
486
- }
487
- const handleHide = () => {
488
- console.log('关闭')
489
- visible.value = false
490
- document.removeEventListener('mousedown', handleDocumentClick)
491
- }
492
-
493
- const handleDocumentClick = (e: any) => {
494
- // 查找所有的class名称为 is-light 的元素
495
- // const el1 = document.querySelector('.is-light')
496
- // console.log('el1: ', el1)
497
-
498
- const elements = document.querySelectorAll('[id^="el-popper-container-"]')
499
- console.log('elements: ', elements)
500
-
501
- if (elements && elements.length > 0) {
502
- for (let i = 0; i < elements.length; i++) {
503
- const element = elements[i]
504
- console.log('element: ', element)
505
- if (element?.contains(e.target)) {
506
- return
507
- }
508
- }
509
- }
510
-
511
- // 通过自定义属性 aria-label 查找元素
512
- const el = document.querySelector(`[aria-label="${props.text}"]`)
513
- console.dir('el: ', el)
514
- // 获取 el 的class为.is-light的兄弟元素
515
- const el2 = el?.parentElement?.querySelector('.el-select__popper')
516
- console.dir('el2: ', el2)
517
- console.log('是否包含: ', el?.contains(e.target))
518
- // 获取class为 porpove的元素;
519
-
520
- // 判断点击的元素是否是是e的子元素
521
- if (el?.contains(e.target)) {
522
- return
523
- }
524
- if (!popover.value.$el.contains(e.target)) {
525
- console.log(22222)
526
- handleHide()
527
- }
528
- }
529
452
 
530
- const visible = ref(false)
531
- // const toggle = () => {
532
- // console.log('visible', visible.value)
533
- // if (visible.value) {
534
- // // visible.value = false
535
- // } else {
536
- // visible.value = true
537
- // document.addEventListener('mousedown', handleDocumentClick)
538
- // lodash.debounce(() => handleShow(), 500)
539
- // }
540
- // }
541
- */
542
453
  // 排序
543
454
  const orderChangtop = (val: string) => {
544
455
  console.log('升序', ordersVal.value)
@@ -0,0 +1,221 @@
1
+ <template>
2
+ <el-table v-bind="table || {}" :data="data" :header-cell-class-name="setClass" ref="elTableRef">
3
+ <slot></slot>
4
+ <sortable-table-column-cell
5
+ v-if="props.modelValue"
6
+ v-for="v in rowValue"
7
+ :key="v.id"
8
+ :data="v"
9
+ />
10
+ </el-table>
11
+ </template>
12
+ <script setup lang="ts">
13
+ defineOptions({ name: 'ci-table' })
14
+ import { CellCls, ElTable } from 'element-plus'
15
+ import Sortable from 'sortablejs'
16
+ import { computed, onBeforeMount, onMounted, ref } from 'vue'
17
+ import { SortableTableIns, SortColumn } from './utils/interface'
18
+ import sortableTableColumnCell from './index/sortableTableColumnCell'
19
+ import { cloneDeep } from 'lodash'
20
+ let props = defineProps<SortableTableIns>()
21
+ const elTableRef = ref<InstanceType<typeof ElTable>>()
22
+ const emits = defineEmits(['update:modelValue', 'update:data'])
23
+ const rowValue = computed({
24
+ get() {
25
+ return props.modelValue
26
+ },
27
+ set(value) {
28
+ emits('update:modelValue', value)
29
+ }
30
+ })
31
+ const data = computed({
32
+ get() {
33
+ return props.data
34
+ },
35
+ set(value) {
36
+ emits('update:data', value)
37
+ }
38
+ })
39
+
40
+ onBeforeMount(() => {})
41
+ onMounted(() => {
42
+ columnDrop(elTableRef.value?.$el)
43
+ })
44
+ const columnDrop = (elem?: HTMLTableElement) => {
45
+ // 如果没有传入elem,则返回
46
+ if (!elem) return
47
+ // 获取表格的表头元素
48
+ const header = elem.querySelector('.el-table__header-wrapper')
49
+ // 如果没有表头元素,则返回
50
+ if (!header) return
51
+ // 设置延时执行函数
52
+ setTimeout(() => {
53
+ // 获取表头中的所有行元素
54
+ const trs = header.querySelectorAll('thead > tr')
55
+ // 遍历行元素
56
+ trs.forEach((v) => {
57
+ let tr = v as HTMLElement
58
+ // 创建拖拽排序对象
59
+ Sortable.create(tr, {
60
+ // 动画时间
61
+ animation: 180,
62
+ // 延迟时间
63
+ delay: 0,
64
+ // 拖拽元素
65
+ draggable: '.sortable',
66
+ // 过滤器
67
+ filter: (evt, item) => !getLocation(item),
68
+ // 拖拽排序时触发的函数
69
+ onMove: ({ dragged, related }) => {
70
+ // 获取拖拽元素的排序位置
71
+ let location = getLocation(dragged)
72
+ // 如果没有排序位置,则返回false
73
+ if (!location) return false
74
+ // 获取排序位置的数组
75
+ const locationArr = location.split('_').slice(1).map(Number)
76
+ // 判断拖拽元素是否在相关元素之前
77
+ return inChildren(locationArr[0], getIndex(tr, dragged), getIndex(tr, related))
78
+ },
79
+ // 拖拽排序后的函数
80
+ onUpdate({ oldIndex, newIndex }) {
81
+ // 如果没有排序值,则返回
82
+ if (!rowValue.value) return
83
+ // 如果没有旧的索引和新的索引,则返回
84
+ if (oldIndex === void 0 || newIndex === void 0) return
85
+ // 获取旧的th元素
86
+ let oldTh = tr.children[oldIndex]
87
+ // 获取新的th元素
88
+ let newTh = tr.children[newIndex]
89
+ // 获取旧的排序位置
90
+ let oldLocation = getLocation(oldTh)
91
+ // 获取新的排序位置
92
+ let newLocation = getLocation(newTh)
93
+ // 如果没有旧的排序位置或者新的排序位置,则返回false
94
+ if (!oldLocation || !newLocation) return false
95
+ // 获取旧的排序位置的数组
96
+ let oldLocationArr = oldLocation.split('_').slice(1).map(Number)
97
+ // 如果旧的排序位置的第一个元素为1,则减去count
98
+ if (oldLocationArr[0] === 1) {
99
+ let count = tr.querySelectorAll('.el-table-fixed-column--left').length
100
+ newIndex -= count
101
+ oldIndex -= count
102
+ }
103
+ // 获取新的排序位置的数组
104
+ let newLocationArr = newLocation.split('_').slice(1).map(Number)
105
+ // 获取旧的路径
106
+ let oldPath = getPath(oldLocationArr[0], oldIndex)
107
+ // 获取新的路径
108
+ let newPath = getPath(newLocationArr[0], newIndex)
109
+ // 如果没有旧的路径或者新的路径,则返回false
110
+ if (!oldPath || !newPath) return false
111
+ // 克隆排序值
112
+ let tem = cloneDeep(rowValue.value)
113
+ // 设置新的路径和新的排序值
114
+ setValue(cloneDeep(getValue(oldPath)), newPath, tem)
115
+ // 设置旧的路径和旧的排序值
116
+ setValue(cloneDeep(getValue(newPath)), oldPath, tem)
117
+ // 设置新的排序值
118
+ rowValue.value = tem
119
+ }
120
+ })
121
+ })
122
+ })
123
+ }
124
+ const getIndex = (father: HTMLElement, child: HTMLElement) =>
125
+ Array.from(father.children).indexOf(child)
126
+ // 获取元素的路径
127
+ const getLocation = (dom: Element) => dom && dom.className.match(/sortable_[0-9]+_[0-9]+/g)?.[0]
128
+ // 判断当前元素是否在当前行中
129
+ const inChildren = (level: number, from: number, to: number) => {
130
+ if (!rowValue.value) return false
131
+ if (level === 1) return true
132
+ let item = levelFlat(level - 1).filter((v) => !v.hide)
133
+ return getColumnFatherIndex(item, from) === getColumnFatherIndex(item, to)
134
+ }
135
+ // 获取当前元素的父级元素的索引
136
+ const getColumnFatherIndex = (item: SortColumn[], end: number) => {
137
+ let i = 0
138
+ while (end >= 0) {
139
+ const v = item[i]
140
+ i++
141
+ if (v.hide) continue
142
+ let children = v.children
143
+ if (!children) return false
144
+ end -= children.length
145
+ }
146
+ return i
147
+ }
148
+ // 获取当前元素的路径
149
+ const getPath = (level: number, end: number) => {
150
+ if (!rowValue.value) return
151
+ end += hideCount(level, end)
152
+ if (level === 1) return [end]
153
+ let path = Array.from({ length: level }).map((v) => 0)
154
+ if (!end) {
155
+ f(rowValue.value, 0)
156
+ path[level - 1] = 0
157
+ } else
158
+ while (end > 0) {
159
+ f(rowValue.value, 0)
160
+ end--
161
+ }
162
+ function f(data: SortColumn[], depth: number) {
163
+ let flag = 0
164
+ for (let i = 0; i < data.length; i++) {
165
+ let v = data[i]
166
+ if (depth === level - 1) {
167
+ if (flag !== i) {
168
+ flag = i
169
+ path[depth] = 0
170
+ }
171
+ path[depth] += 1
172
+ } else if (v.children) return f(v.children, depth + 1)
173
+ else path[depth] += 1
174
+ }
175
+ }
176
+ return path
177
+ }
178
+ // 获取当前元素的值
179
+ const getValue = (
180
+ path: number[],
181
+ parent?: boolean,
182
+ data: SortColumn[] = rowValue.value
183
+ ): SortColumn => {
184
+ if (!path.length) path[0] = 0
185
+ if (path.length <= (parent ? 2 : 1)) return data[path[0]]
186
+ return getValue(path.slice(1), parent, data[path[0]].children)
187
+ }
188
+ // 设置当前元素的值
189
+ const setValue = (data: SortColumn, path: number[], value: SortColumn[]): SortColumn[] => {
190
+ if (path.length) {
191
+ let tem = value[path[0]]
192
+ if (path.length === 1) value[path[0]] = data
193
+ else if (tem.children) value[path[0]].children = setValue(data, path.slice(1), tem.children)
194
+ }
195
+ return value
196
+ }
197
+ // 计算当前元素的隐藏数量
198
+ const hideCount = (level: number, index: number) =>
199
+ levelFlat(level)
200
+ .slice(0, index + 1)
201
+ .filter((v) => v.hide).length
202
+ // 获取当前行的数据
203
+ const levelFlat = (level: number, data = rowValue.value): SortColumn[] => {
204
+ if (level > 1)
205
+ return levelFlat(
206
+ level - 1,
207
+ data.filter((v) => v.children).flatMap((v) => v.children) as SortColumn[]
208
+ )
209
+ return data
210
+ }
211
+ // 设置当前元素的类名
212
+ const setClass: CellCls<typeof props.data> = ({ column }) => {
213
+ let className = props.table?.headerCellClassName || ''
214
+ if (!column.fixed && column.id) {
215
+ className += ` sortable sortable_${column.level}_${column.no}`
216
+ }
217
+ return className as string
218
+ }
219
+ defineExpose({ table: elTableRef })
220
+ </script>
221
+ <style scoped></style>