|
@@ -1,9 +1,14 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div class="body_edit">
|
3
|
|
- <h2 style="text-align: center">特征实例编辑</h2>
|
|
3
|
+ <h2 style="text-align: center">
|
|
4
|
+ 特征实例{{ this.resultId ? "编辑" : "添加" }}
|
|
5
|
+ </h2>
|
4
|
6
|
<el-form ref="form" :model="form" label-width="150px" size="mini">
|
5
|
7
|
<el-form-item label="实例名称:">
|
6
|
|
- <el-input v-model="form.name"></el-input>
|
|
8
|
+ <el-input
|
|
9
|
+ v-model="form.name"
|
|
10
|
+ placeholder="请输入实例名(必填)"
|
|
11
|
+ ></el-input>
|
7
|
12
|
</el-form-item>
|
8
|
13
|
<el-form-item label="特征库图标:">
|
9
|
14
|
<UploadImage />
|
|
@@ -13,20 +18,46 @@
|
13
|
18
|
</el-form-item>
|
14
|
19
|
|
15
|
20
|
<el-form-item label="特征词:">
|
|
21
|
+ <el-select
|
|
22
|
+ v-model="nowList"
|
|
23
|
+ multiple
|
|
24
|
+ filterable
|
|
25
|
+ default-first-option
|
|
26
|
+ placeholder="请选择"
|
|
27
|
+ @change="handleChange"
|
|
28
|
+ >
|
|
29
|
+ <el-option
|
|
30
|
+ v-for="item in wordList"
|
|
31
|
+ :key="item.wordId"
|
|
32
|
+ :label="item.word"
|
|
33
|
+ :value="item.wordId"
|
|
34
|
+ >
|
|
35
|
+ </el-option>
|
|
36
|
+ </el-select>
|
16
|
37
|
</el-form-item>
|
17
|
38
|
<el-form-item>
|
18
|
39
|
<el-button type="primary" @click="onSubmit">确定</el-button>
|
19
|
40
|
<el-button @click="onReset">重置</el-button>
|
|
41
|
+ <el-button @click="handleClose">关闭</el-button>
|
20
|
42
|
</el-form-item>
|
21
|
43
|
</el-form>
|
22
|
44
|
</div>
|
23
|
45
|
</template>
|
24
|
46
|
<script>
|
25
|
|
-import { saveCharacterResult } from "@/api/characterLib";
|
|
47
|
+import {
|
|
48
|
+ saveCharacterResult,
|
|
49
|
+ UpdateCharacterResult,
|
|
50
|
+ getCharacterResultDetail,
|
|
51
|
+} from "@/api/characterLib";
|
26
|
52
|
import UploadImage from "@/components/UploadImage/index.vue";
|
27
|
53
|
export default {
|
28
|
|
- props:{
|
29
|
|
- libId:String
|
|
54
|
+ props: {
|
|
55
|
+ libId: String,
|
|
56
|
+ resultId: String,
|
|
57
|
+ wordList: {
|
|
58
|
+ type: Array,
|
|
59
|
+ required: true,
|
|
60
|
+ },
|
30
|
61
|
},
|
31
|
62
|
data() {
|
32
|
63
|
return {
|
|
@@ -34,35 +65,61 @@ export default {
|
34
|
65
|
name: undefined,
|
35
|
66
|
thumb: undefined,
|
36
|
67
|
desc: undefined,
|
37
|
|
- libId:undefined,
|
38
|
|
- wordList:[]
|
|
68
|
+ libId: undefined,
|
|
69
|
+ wordList: [],
|
39
|
70
|
},
|
|
71
|
+ nowList:[]
|
40
|
72
|
};
|
41
|
73
|
},
|
42
|
74
|
|
43
|
75
|
methods: {
|
44
|
76
|
onReset() {
|
45
|
|
- this.form={
|
|
77
|
+ this.form = {
|
46
|
78
|
name: undefined,
|
47
|
79
|
thumb: undefined,
|
48
|
80
|
desc: undefined,
|
49
|
|
- libId:undefined,
|
50
|
|
- wordList:[]
|
51
|
|
- }
|
|
81
|
+ libId: undefined,
|
|
82
|
+ wordList: [],
|
|
83
|
+ };
|
52
|
84
|
},
|
|
85
|
+ handleChange(val) {},
|
53
|
86
|
onSubmit() {
|
54
|
|
- this.form.libId=this.libId
|
55
|
|
- console.log(this.form)
|
56
|
|
-
|
57
|
|
- saveCharacterResult(this.form).then((res) => {
|
58
|
|
- this.$message('添加实例成功')
|
59
|
|
- console.log(res);
|
60
|
|
- });
|
61
|
|
- }
|
|
87
|
+ this.form.wordList = this.wordList.filter((item) =>
|
|
88
|
+ this.nowList.some((v) => v == item.wordId)
|
|
89
|
+ );
|
|
90
|
+ this.form.libId = this.libId;
|
|
91
|
+ if (this.form.name) {
|
|
92
|
+ if (this.resultId) {
|
|
93
|
+ UpdateCharacterResult(this.form,this.resultId).then((res) => {
|
|
94
|
+ this.$message("修改实例成功");
|
|
95
|
+ //告诉父页面实例表需要刷新并且关闭当前组件
|
|
96
|
+ this.$emit("handleRefresh", true);
|
|
97
|
+ });
|
|
98
|
+ } else {
|
|
99
|
+ saveCharacterResult(this.form).then((res) => {
|
|
100
|
+ this.$message("添加实例成功");
|
|
101
|
+ //告诉父页面实例表需要刷新并且关闭当前组件
|
|
102
|
+ this.$emit("handleRefresh", true);
|
|
103
|
+ });
|
|
104
|
+ }
|
|
105
|
+ } else {
|
|
106
|
+ this.$message("请输入实例名");
|
|
107
|
+ }
|
|
108
|
+ },
|
|
109
|
+ handleClose() {
|
|
110
|
+ this.$emit("handleClose", true);
|
|
111
|
+ },
|
62
|
112
|
},
|
63
|
113
|
//进入页面执行的方法
|
64
|
114
|
mounted: function () {
|
65
|
|
- if (this.$route?.query.row) {
|
|
115
|
+ if (this.resultId) {
|
|
116
|
+ getCharacterResultDetail(this.resultId).then((res) => {
|
|
117
|
+ this.form = res.data;
|
|
118
|
+ let list=res.data.wordList
|
|
119
|
+ list.map((item)=>{
|
|
120
|
+ this.nowList.push(item.wordId)
|
|
121
|
+ })
|
|
122
|
+ });
|
66
|
123
|
}
|
67
|
124
|
},
|
68
|
125
|
components: {
|