workflow-editor 0.0.87-up-sit1 → 0.0.87-up

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,7 +1,7 @@
1
1
  {
2
2
  "name": "workflow-editor",
3
3
  "private": false,
4
- "version": "0.0.87-up-sit1",
4
+ "version": "0.0.87-up",
5
5
  "type": "module",
6
6
  "main": "./lib/workflow-editor.js",
7
7
  "scripts": {
@@ -16,12 +16,13 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@vitejs/plugin-vue": "^4.2.3",
19
- "agilebuilder-ui": "1.1.92-sit1",
19
+ "agilebuilder-ui": "1.1.92",
20
20
  "axios": "^1.5.1",
21
21
  "element-plus": "^2.4.1",
22
22
  "font-awesome": "^4.7.0",
23
23
  "nprogress": "^0.2.0",
24
24
  "sass": "^1.69.4",
25
+ "sortablejs": "^1.15.2",
25
26
  "vite": "^4.4.5",
26
27
  "vite-plugin-svg-icons": "^2.0.1",
27
28
  "vue": "^3.3.4",
@@ -5,6 +5,7 @@
5
5
  v-for="(tag, index) in dynamicTags"
6
6
  :key="tag"
7
7
  :data-index="index"
8
+ :data-tag-key="tag"
8
9
  :type="getType(tag)"
9
10
  closable
10
11
  :disable-transitions="false"
@@ -80,22 +81,23 @@ export default {
80
81
  mounted() {
81
82
  this._sortable = Sortable.create(this.$refs.tagContainer, {
82
83
  animation: 150,
83
- onEnd: ({ oldIndex, newIndex }) => {
84
- if (oldIndex === newIndex) return
85
- // 先将 Sortable 物理移动的 DOM 还原到原始顺序,再让 Vue 响应式更新,否则会导致所有标签都闪烁一下刷新
84
+ draggable: '.el-tag',
85
+ dragClass: 'wf-tag-drag',
86
+ onEnd: () => {
86
87
  const container = this.$refs.tagContainer
87
- const children = Array.from(container.children)
88
- const item = children[newIndex]
89
- if (newIndex < oldIndex) {
90
- container.insertBefore(item, children[oldIndex + 1] || null)
91
- } else {
92
- container.insertBefore(item, children[oldIndex])
93
- }
94
- const tags = [...this.dynamicTags]
95
- const moved = tags.splice(oldIndex, 1)[0]
96
- tags.splice(newIndex, 0, moved)
97
- this.dynamicTags = tags
98
- this.$emit('update:modelValue', this.dynamicTags.join(''))
88
+ if (!container) return
89
+ // 从 DOM 当前真实顺序读取 tag 值,彻底避免索引偏移问题
90
+ const newOrder = Array.from(container.querySelectorAll('.el-tag[data-tag-key]')).map((el) =>
91
+ el.getAttribute('data-tag-key')
92
+ )
93
+ // 还原 Sortable 对 DOM 的移动,交由 Vue 重新渲染
94
+ container.querySelectorAll('.el-tag[data-tag-key]').forEach((el, i) => {
95
+ const original = this.dynamicTags[i]
96
+ const originalEl = container.querySelector(`.el-tag[data-tag-key="${original}"]`)
97
+ if (originalEl) container.appendChild(originalEl)
98
+ })
99
+ this.dynamicTags = newOrder
100
+ this.$emit('update:modelValue', newOrder.join(''))
99
101
  }
100
102
  })
101
103
  },
@@ -206,3 +208,14 @@ select {
206
208
  line-height: 32px;
207
209
  }
208
210
  </style>
211
+
212
+ <!-- 非 scoped:覆盖 Sortable 追加到 body 的拖拽克隆元素样式 -->
213
+ <style>
214
+ .wf-tag-drag {
215
+ display: inline-flex !important;
216
+ pointer-events: auto !important;
217
+ opacity: 0.85;
218
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
219
+ background: #fff;
220
+ }
221
+ </style>