el-plus-crud 0.1.20 → 0.1.21

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.
@@ -87,6 +87,8 @@ const multipleTableRef = ref()
87
87
 
88
88
  // 存储的值
89
89
  const selectData = reactive([] as ILinkItem[])
90
+ // 存储历史选中-取消后要还原
91
+ const selectOldData = reactive([] as ILinkItem[])
90
92
 
91
93
  /**
92
94
  * 处理点击事件
@@ -97,6 +99,8 @@ function handelVisibleChange(val: any) {
97
99
  selectRef.value.blur()
98
100
  isShowDialog.value = true
99
101
  selectList.value = cloneDeep(selectData.map((item) => item.dataItem))
102
+ // 这里存储一下老数据
103
+ selectOldData.splice(0, selectOldData.length, ...selectData)
100
104
  }
101
105
  }
102
106
 
@@ -149,6 +153,8 @@ function handelTagRemove(item: ILinkItem) {
149
153
  */
150
154
  function cancel() {
151
155
  isShowDialog.value = false
156
+ // 这里重置一下老数据
157
+ selectData.splice(0, selectData.length, ...selectOldData)
152
158
  }
153
159
 
154
160
  /**
@@ -204,6 +210,27 @@ watch(
204
210
  { deep: true, immediate: true }
205
211
  )
206
212
 
213
+ watch(
214
+ () => props.modelValue,
215
+ () => {
216
+ selectData.splice(0, selectData.length)
217
+ values.splice(0, values.length)
218
+ // 这里默认选中
219
+ if (props.modelValue && Array.isArray(props.modelValue)) {
220
+ const [ids, names] = props.modelValue as Array<string[]>
221
+ if (ids.length > 0 && ids.length === names.length) {
222
+ ids.map((id, i) => {
223
+ // 构建选中数据
224
+ selectData.push({ label: names[i], value: id, dataItem: { [props.desc.lkey]: names[i], [vkey.value]: id } })
225
+ values.push(id)
226
+ })
227
+ }
228
+ }
229
+ options.splice(0, options.length, ...selectData)
230
+ },
231
+ { deep: true, immediate: true }
232
+ )
233
+
207
234
  onMounted(async () => {})
208
235
  </script>
209
236
  <style lang="scss" scoped>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "el-plus-crud",
3
3
  "description": "采用Vue3 + TS,封装的element-plus数据驱动表单、列表组件",
4
4
  "author": "K.D.Jack",
5
- "version": "0.1.20",
5
+ "version": "0.1.21",
6
6
  "license": "MIT",
7
7
  "private": false,
8
8
  "main": "dist/el-plus-crud.mjs",