소스 검색

特征库1.0

李志伟 3 년 전
부모
커밋
7d283a4978
5개의 변경된 파일217개의 추가작업 그리고 54개의 파일을 삭제
  1. 46
    0
      src/api/characterWord.js
  2. 18
    15
      src/components/CharacterResult/edit.vue
  3. 28
    12
      src/components/TagComponents/index.vue
  4. 61
    23
      src/views/characterLibManage/add.vue
  5. 64
    4
      src/views/characterLibManage/edit.vue

+ 46
- 0
src/api/characterWord.js 파일 보기

1
+import request from '@/utils/request'
2
+
3
+/**
4
+* 保存特征词
5
+* @param {*} data 
6
+* @returns 
7
+*/
8
+export const saveCharacterWord = (data) => request({
9
+  url: '/admin/character-word',
10
+  method: 'post',
11
+  data
12
+})
13
+
14
+/**
15
+ * 特征词列表
16
+ * @param {*} params 
17
+ * @returns 
18
+ */
19
+export const getCharacterWordList = (params) => request({
20
+  url: '/admin/character-word', params
21
+})
22
+
23
+/**
24
+ * 删除特征词
25
+ * @param {*} data 
26
+ * @returns 
27
+ */
28
+export const deleteCharacterWord = (id) => request({
29
+  url: `/admin/character-word/${id}`, method: 'delete'
30
+})
31
+/**
32
+ * 更新特征词
33
+ * @param {*} data 
34
+ * @returns 
35
+ */
36
+export const UpdateCharacterWord = (data, id) => request({
37
+  url: `/admin/character-word/${id}`, method: 'put', data
38
+})
39
+/**
40
+ * 查询特征词详情
41
+ * @param {*} params 
42
+ * @returns 
43
+ */
44
+export const getCharacterWordDetail = (id) => request({
45
+  url: `/admin/character-word/${id}`
46
+})

+ 18
- 15
src/components/CharacterResult/edit.vue 파일 보기

1
 <template>
1
 <template>
2
   <div class="body_edit">
2
   <div class="body_edit">
3
-    <h2 style="text-align: center">题目编辑</h2>
3
+    <h2 style="text-align: center">特征实例编辑</h2>
4
     <el-form ref="form" :model="form" label-width="150px" size="mini">
4
     <el-form ref="form" :model="form" label-width="150px" size="mini">
5
       <el-form-item label="实例名称:">
5
       <el-form-item label="实例名称:">
6
         <el-input v-model="form.name"></el-input>
6
         <el-input v-model="form.name"></el-input>
13
       </el-form-item>
13
       </el-form-item>
14
 
14
 
15
       <el-form-item label="特征词:">
15
       <el-form-item label="特征词:">
16
-        <TagComponents :value='value' @change='handleChange'/>
17
       </el-form-item>
16
       </el-form-item>
18
       <el-form-item>
17
       <el-form-item>
19
         <el-button type="primary" @click="onSubmit">确定</el-button>
18
         <el-button type="primary" @click="onSubmit">确定</el-button>
23
   </div>
22
   </div>
24
 </template>
23
 </template>
25
 <script>
24
 <script>
26
-import { saveQuestion } from "@/api/question";
25
+import { saveCharacterResult } from "@/api/characterLib";
27
 import UploadImage from "@/components/UploadImage/index.vue";
26
 import UploadImage from "@/components/UploadImage/index.vue";
28
-import TagComponents from '../TagComponents/index.vue'
29
 export default {
27
 export default {
28
+  props:{
29
+    libId:String
30
+  },
30
   data() {
31
   data() {
31
     return {
32
     return {
32
-      value:[],
33
       form: {
33
       form: {
34
         name: undefined,
34
         name: undefined,
35
         thumb: undefined,
35
         thumb: undefined,
42
 
42
 
43
   methods: {
43
   methods: {
44
     onReset() {
44
     onReset() {
45
-
45
+      this.form={
46
+        name: undefined,
47
+        thumb: undefined,
48
+        desc: undefined,
49
+        libId:undefined,
50
+        wordList:[]
51
+      }
46
     },
52
     },
47
     onSubmit() {
53
     onSubmit() {
48
-      console.log(this.value)
54
+      this.form.libId=this.libId
55
+      console.log(this.form)
49
       
56
       
50
-      // this.form.option = this.rightList.toString();
51
-      // saveQuestion(this.form).then((res) => {
52
-      //   console.log(res);
53
-      // });
54
-    },
55
-    handleChange(val){
56
-      console.log(val)
57
+      saveCharacterResult(this.form).then((res) => {
58
+        this.$message('添加实例成功')
59
+        console.log(res);
60
+      });
57
     }
61
     }
58
   },
62
   },
59
   //进入页面执行的方法
63
   //进入页面执行的方法
63
   },
67
   },
64
   components: {
68
   components: {
65
     UploadImage,
69
     UploadImage,
66
-    TagComponents
67
   },
70
   },
68
 };
71
 };
69
 </script>
72
 </script>

+ 28
- 12
src/components/TagComponents/index.vue 파일 보기

20
     >
20
     >
21
     </el-input>
21
     </el-input>
22
     <el-button v-else class="button-new-tag" size="small" @click="showInput"
22
     <el-button v-else class="button-new-tag" size="small" @click="showInput"
23
-      >添加修饰词</el-button
23
+      >添加特征词</el-button
24
     >
24
     >
25
   </div>
25
   </div>
26
 </template>
26
 </template>
35
   },
35
   },
36
   data() {
36
   data() {
37
     return {
37
     return {
38
-      dynamicTags: [],
39
       inputVisible: false,
38
       inputVisible: false,
40
       inputValue: "",
39
       inputValue: "",
41
     };
40
     };
42
   },
41
   },
42
+  computed: {
43
+    dynamicTags() {
44
+      let tags = [];
45
+      this.value.map((item) => {
46
+        tags.push(item.word);
47
+      });
48
+      return tags;
49
+    },
50
+  },
43
   methods: {
51
   methods: {
52
+    //删除特征词
44
     handleClose(tag) {
53
     handleClose(tag) {
45
-      this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
54
+      if (this.value && this.value[0].wordId) {
55
+        this.$confirm("确认删除该修饰词?", {
56
+          showCancelButton: true,
57
+          confirmButtonText: "确定",
58
+          cancelButtonText: "取消",
59
+        })
60
+          .then((_) => {
61
+            this.$emit("handleDelete", tag);
62
+            this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
63
+          })
64
+          .catch((_) => {});
65
+      } else {
66
+        this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
67
+        this.$emit("handleDelete", tag);
68
+      }
46
     },
69
     },
47
 
70
 
48
     showInput() {
71
     showInput() {
51
         this.$refs.saveTagInput.$refs.input.focus();
74
         this.$refs.saveTagInput.$refs.input.focus();
52
       });
75
       });
53
     },
76
     },
54
-
77
+    //添加特征词
55
     handleInputConfirm() {
78
     handleInputConfirm() {
56
       let inputValue = this.inputValue;
79
       let inputValue = this.inputValue;
57
       if (inputValue) {
80
       if (inputValue) {
58
         this.dynamicTags.push(inputValue);
81
         this.dynamicTags.push(inputValue);
82
+        this.$emit("handleAdd", inputValue);
59
       }
83
       }
60
       this.inputVisible = false;
84
       this.inputVisible = false;
61
       this.inputValue = "";
85
       this.inputValue = "";
62
-    }
63
-  },
64
-  watch: {
65
-    dynamicTags() {
66
-      this.$emit("change", this.dynamicTags);
67
     },
86
     },
68
   },
87
   },
69
-  mounted(){
70
-    this.dynamicTags=this.value
71
-  }
72
 };
88
 };
73
 </script>
89
 </script>
74
 <style>
90
 <style>

+ 61
- 23
src/views/characterLibManage/add.vue 파일 보기

1
 <template>
1
 <template>
2
   <div class="body_edit">
2
   <div class="body_edit">
3
     <h2 style="text-align: center">特征库新增</h2>
3
     <h2 style="text-align: center">特征库新增</h2>
4
-    <el-form ref="form" :model="form" label-width="150px" size="mini">
5
-      <el-form-item label="特征库名称:">
6
-        <el-input v-model="form.name"></el-input>
7
-      </el-form-item>
8
-      <el-form-item label="特征库图标:">
9
-        <UploadImage />
10
-      </el-form-item>
11
-      <el-form-item label="特征库描述:">
12
-        <el-input type="textarea" v-model="form.remark"></el-input>
13
-      </el-form-item>
14
-      <el-form-item>
15
-        <el-button type="primary" @click="onSubmit">添加</el-button>
16
-        <el-button @click="onCancel">取消</el-button>
17
-      </el-form-item>
18
-    </el-form>
4
+    <el-row :gutter="20">
5
+      <el-col :span="15">
6
+        <el-form
7
+          ref="form"
8
+          :model="characterLib"
9
+          label-width="150px"
10
+          size="mini"
11
+        >
12
+          <el-form-item label="特征库名称:">
13
+            <el-input v-model="characterLib.name"></el-input>
14
+          </el-form-item>
15
+          <el-form-item label="特征库图标:">
16
+            <UploadImage />
17
+          </el-form-item>
18
+          <el-form-item label="特征库描述:">
19
+            <el-input type="textarea" v-model="characterLib.remark"></el-input>
20
+          </el-form-item>
21
+
22
+          <el-form-item>
23
+            <el-button type="primary" @click="onSubmit">添加</el-button>
24
+            <el-button @click="onCancel">取消</el-button>
25
+          </el-form-item>
26
+        </el-form>
27
+      </el-col>
28
+      <el-col :span="5">
29
+        特征词列表
30
+        <TagComponents
31
+          :value="characterLib.wordList"
32
+          @handleDelete="handleDelete"
33
+          @handleAdd="handleAdd"
34
+        />
35
+      </el-col>
36
+    </el-row>
19
   </div>
37
   </div>
20
 </template>
38
 </template>
21
 <script>
39
 <script>
22
 import { saveCharacterLib } from "@/api/characterLib";
40
 import { saveCharacterLib } from "@/api/characterLib";
23
-import UploadImage from '@/components/UploadImage/index.vue'
41
+import UploadImage from "@/components/UploadImage/index.vue";
42
+import TagComponents from "@/components/TagComponents/index.vue";
24
 export default {
43
 export default {
25
   data() {
44
   data() {
26
     return {
45
     return {
27
-      form: {
46
+      characterLib: {
28
         name: undefined,
47
         name: undefined,
29
         icon: undefined,
48
         icon: undefined,
30
-        remark:undefined
49
+        remark: undefined,
50
+        wordList: [],
31
       },
51
       },
32
     };
52
     };
33
   },
53
   },
37
       this.$router.go(-1);
57
       this.$router.go(-1);
38
     },
58
     },
39
     onSubmit() {
59
     onSubmit() {
40
-      saveCharacterLib(this.form).then((res) => {
41
-        this.$message('保存成功');
60
+      saveCharacterLib(this.characterLib).then((res) => {
61
+        this.$message("保存成功");
42
         this.$router.go(-1);
62
         this.$router.go(-1);
43
       });
63
       });
44
     },
64
     },
65
+    handleDelete(val) {
66
+      this.characterLib.wordList.map((item) => {
67
+        if (item.word === val) {
68
+          this.characterLib.wordList.splice(
69
+            this.characterLib.wordList.indexOf(item),
70
+            1
71
+          );
72
+        }
73
+      });
74
+    },
75
+    handleAdd(val) {
76
+      this.characterLib.wordList.push({
77
+        libId: undefined,
78
+        word: val,
79
+        wordId: undefined,
80
+      });
81
+    },
82
+  },
83
+  components: {
84
+    UploadImage,
85
+    TagComponents,
45
   },
86
   },
46
-  components:{
47
-    UploadImage
48
-  }
49
 };
87
 };
50
 </script>
88
 </script>
51
 <style>
89
 <style>

+ 64
- 4
src/views/characterLibManage/edit.vue 파일 보기

25
           </el-form-item>
25
           </el-form-item>
26
         </el-form>
26
         </el-form>
27
       </el-col>
27
       </el-col>
28
-      <el-col :span="5"> 特征词列表 </el-col>
28
+      <el-col :span="5">
29
+        特征词列表
30
+        <TagComponents
31
+          :value="characterLib.wordList"
32
+          @handleDelete="handleDelete"
33
+          @handleAdd="handleAdd"
34
+        />
35
+      </el-col>
29
     </el-row>
36
     </el-row>
30
     <el-row :gutter="20">
37
     <el-row :gutter="20">
31
       <el-col :span="10">
38
       <el-col :span="10">
32
         <CharacterResult />
39
         <CharacterResult />
33
       </el-col>
40
       </el-col>
34
-      <el-col :span="10"> 实例详情 
35
-        <CharacterResultEdit />
41
+      <el-col :span="10">
42
+        实例详情
43
+        <CharacterResultEdit :libId="characterLib.libId" />
36
       </el-col>
44
       </el-col>
37
     </el-row>
45
     </el-row>
38
   </div>
46
   </div>
39
 </template>
47
 </template>
40
 <script>
48
 <script>
41
 import { UpdateCharacterLib, getCharacterLibDetail } from "@/api/characterLib";
49
 import { UpdateCharacterLib, getCharacterLibDetail } from "@/api/characterLib";
50
+import { deleteCharacterWord, saveCharacterWord } from "@/api/characterWord";
42
 import UploadImage from "@/components/UploadImage/index.vue";
51
 import UploadImage from "@/components/UploadImage/index.vue";
43
 import CharacterResult from "@/components/CharacterResult/index.vue";
52
 import CharacterResult from "@/components/CharacterResult/index.vue";
44
 import CharacterResultEdit from "@/components/CharacterResult/edit.vue";
53
 import CharacterResultEdit from "@/components/CharacterResult/edit.vue";
54
+import TagComponents from "@/components/TagComponents/index.vue";
55
+
45
 export default {
56
 export default {
46
   data() {
57
   data() {
47
     return {
58
     return {
66
         }
77
         }
67
       );
78
       );
68
     },
79
     },
80
+    handleDelete(val) {
81
+      if (this.characterLib.libId) {
82
+        let nowWordId = undefined;
83
+        this.characterLib.wordList.map((item) => {
84
+          if (item.word === val) {
85
+            nowWordId = item.wordId;
86
+          }
87
+        });
88
+        // 调用删除接口
89
+        deleteCharacterWord(nowWordId).then(() => {
90
+          this.characterLib.wordList.map((item) => {
91
+            if (item.word === val) {
92
+              this.characterLib.wordList.splice(
93
+                this.characterLib.wordList.indexOf(item),
94
+                1
95
+              );
96
+            }
97
+          });
98
+        });
99
+      } else {
100
+        // 直接删除当前项
101
+        this.characterLib.wordList.map((item) => {
102
+          if (item.word === val) {
103
+            this.characterLib.wordList.splice(
104
+              this.characterLib.wordList.indexOf(item),
105
+              1
106
+            );
107
+          }
108
+        });
109
+      }
110
+    },
111
+    handleAdd(val) {
112
+      if (this.characterLib.libId) {
113
+        saveCharacterWord({
114
+          libId: this.characterLib.libId,
115
+          word: val,
116
+          wordId: undefined,
117
+        }).then((res) => {
118
+          this.characterLib.wordList.push(res.data);
119
+        });
120
+      } else {
121
+        this.characterLib.wordList.push({
122
+          libId: this.characterLib.libId,
123
+          word: val,
124
+          wordId: undefined,
125
+        });
126
+      }
127
+    },
69
   },
128
   },
70
   //进入页面执行的方法
129
   //进入页面执行的方法
71
   mounted: function () {
130
   mounted: function () {
78
   components: {
137
   components: {
79
     UploadImage,
138
     UploadImage,
80
     CharacterResult,
139
     CharacterResult,
81
-    CharacterResultEdit
140
+    CharacterResultEdit,
141
+    TagComponents,
82
   },
142
   },
83
 };
143
 };
84
 </script>
144
 </script>