src/mixins/draftSave.js
@@ -23,7 +23,8 @@
  methods: {
    // 打开弹窗、表单填好后调用;有未保存草稿则自动恢复
    // bizKey:全局唯一业务名;formField:表单字段名(如 'form');recordId:编辑传记录id、新增传上下文;visibleField:弹窗显隐字段(如 'dialogVisible')
    draftRestore(bizKey, formField, recordId, visibleField) {
    // isDraftUsable:可选,草稿校验函数,返回 false 时丢弃该草稿
    draftRestore(bizKey, formField, recordId, visibleField, isDraftUsable) {
      const old = this.draftStates[bizKey]
      if (old) {
        this.draftTeardown(old)
@@ -56,6 +57,10 @@
      if (raw) {
        try {
          const draft = JSON.parse(raw)
          if (typeof isDraftUsable === 'function' && !isDraftUsable(draft)) {
            cache.local.remove(state.key)
            return
          }
          const target = this[formField]
          if (Array.isArray(target) && Array.isArray(draft)) {
            target.splice(0, target.length, ...draft)