浏览代码

Add:类别管理更新参数添加oldNew字段

OnePsycho 2 年之前
父节点
当前提交
b2647b399f
共有 1 个文件被更改,包括 30 次插入1 次删除
  1. 30 1
      TEAMModelOS/ClientApp/src/view/research-center/ResearchMgt.vue

+ 30 - 1
TEAMModelOS/ClientApp/src/view/research-center/ResearchMgt.vue

@@ -230,6 +230,8 @@ export default {
       subjectIndexArr: [],
       tagIndexArr: [],
       tagList: [],
+      apiTags: [],
+      oldNewTags: [],
       analysisArr: [vm.$t('lessonRecord.count1'), vm.$t('lessonRecord.count2'), vm.$t('lessonRecord.count3'), vm.$t('lessonRecord.count4'), vm.$t('lessonRecord.count5'), vm.$t('lessonRecord.count6'), vm.$t('lessonRecord.count7')],
       analysisCount: [],
       isEdit: false,
@@ -694,6 +696,7 @@ export default {
           this.$nextTick(() => {
             this.$refs.baseForm.tags = res.setting.lessonTag
             this.tagList = res.setting.lessonTag
+            this.apiTags = this._.cloneDeep(this.tagList)
           })
         }
       })
@@ -948,11 +951,34 @@ export default {
         this.$Message.warning(this.$t('lessonRecord.tagTip2'))
         return
       }
+      let oldVal = this.tags[this.curEditIndex]
+      let newVal = this.curEditTag
+      if (oldVal) {
+        if (this.oldNewTags.find(i => i._new === oldVal)) {
+          this.oldNewTags.find(i => i._new === oldVal)._new = newVal
+        } else {
+          this.oldNewTags.push({
+            _old: oldVal,
+            _new: newVal
+          })
+        }
+      }
       this.tags[this.curEditIndex] = this.curEditTag
       this.curEditIndex = -1
     },
     /* 删除类别 */
     onDeleteTag(item, index) {
+      if (this.apiTags.includes(item)) {
+        if (this.oldNewTags.find(i => i._new === item)) {
+          this.oldNewTags.find(i => i._new === item)._new = null
+        } else {
+          this.oldNewTags.push({
+            _old: item,
+            _new: null
+          })
+        }
+      }
+
       this.tags.splice(index, 1)
       this.curEditIndex = -1
     },
@@ -973,12 +999,15 @@ export default {
       this.$api.lessonRecord.setLessonTags({
         schoolId: this.$store.state.userInfo.schoolCode,
         opt: 'UpsertLessonTag',
-        lessonTag: saveTags
+        lessonTag: saveTags,
+        old_new: this.oldNewTags
       }).then(res => {
         if (!res.error) {
           this.$Message.success(this.$t('lessonRecord.saveSuc'))
           this.tagLoading = false
           this.categoryModal = false
+          this.apiTags = res.setting.lessonTag
+          this.oldNewTags = []
         }
       })
     }