|
@@ -26,6 +26,16 @@
|
|
|
v-hasPermi="['knowledge:entityRelation:add']"
|
|
|
>新增</el-button>
|
|
|
</el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="handleAddByClass"
|
|
|
+ v-hasPermi="['knowledge:entityRelation:add']"
|
|
|
+ >根据类新增</el-button>
|
|
|
+ </el-col>
|
|
|
<el-col :span="1.5">
|
|
|
<el-button
|
|
|
type="success"
|
|
@@ -126,13 +136,61 @@
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <el-dialog :title="title" :visible.sync="openByClass" width="500px" append-to-body>
|
|
|
+ <el-form ref="formClass" :model="formByClass" :rules="rulesByClass" label-width="100px">
|
|
|
+ <el-form-item label="起点实体类" prop="subEntityClassId">
|
|
|
+ <el-select v-model="formByClass.subEntityClassId" placeholder="请选择起点实体" value-key="id" filterable @change="getEntityClassRelationOption">
|
|
|
+ <el-option
|
|
|
+ v-for="item in entityClassOption"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="终点实体类" prop="objEntityClassId">
|
|
|
+ <el-select v-model="formByClass.objEntityClassId" placeholder="请选择终点实体" value-key="id" filterable @change="getEntityClassRelationOption">
|
|
|
+ <el-option
|
|
|
+ v-for="item in entityClassOption"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="实体关系类" prop="entityClassRelId">
|
|
|
+ <el-select v-model="formByClass.entityClassRelId" placeholder="请选实体关系类" value-key="id" filterable clearable >
|
|
|
+ <el-option
|
|
|
+ v-for="item in entityClassRelationOption"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="起点实体" prop="subEntity">
|
|
|
+ <el-input v-model="formByClass.subEntity" placeholder="请输入起点实体" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="终点实体" prop="objEntity">
|
|
|
+ <el-input v-model="formByClass.objEntity" placeholder="请输入终点实体" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitFormByClass(1)">提交并继续添加</el-button>
|
|
|
+ <el-button type="primary" @click="submitFormByClass(0)">提交并关闭</el-button>
|
|
|
+ <el-button @click="cancelByClass">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { listEntityRelation, getEntityRelation, delEntityRelation, addEntityRelation, updateEntityRelation } from "@/api/knowledge/entityRelation";
|
|
|
import { findAll } from "@/api/knowledge/entity";
|
|
|
-import {bit2Info} from '@/utils/validate'
|
|
|
+import { getEntityClassOption } from "@/api/neo4j/class"
|
|
|
+import { getClassRelationOptionByClassId, addEntityAndRelation } from "@/api/neo4j/class_relation"
|
|
|
+import { bit2Info } from '@/utils/validate'
|
|
|
|
|
|
export default {
|
|
|
name: "EntityRelation",
|
|
@@ -164,15 +222,48 @@ export default {
|
|
|
},
|
|
|
// 表单参数
|
|
|
form: {},
|
|
|
+ formByClass: {},
|
|
|
// 表单校验
|
|
|
rules: {
|
|
|
+ name: [
|
|
|
+ {required: true, message: '实体关系名称不能为空', trigger: 'blur'},
|
|
|
+ ],
|
|
|
+ startNode: [
|
|
|
+ {required: true, message: '起点实体不能为空', trigger: 'blur'},
|
|
|
+ ],
|
|
|
+ endNode: [
|
|
|
+ {required: true, message: '终点实体不能为空', trigger: 'blur'},
|
|
|
+ ],
|
|
|
},
|
|
|
- entityList: []
|
|
|
+ rulesByClass: {
|
|
|
+ subEntityClassId: [
|
|
|
+ {required: true, message: '起点实体类不能为空', trigger: 'blur'},
|
|
|
+ ],
|
|
|
+ objEntityClassId: [
|
|
|
+ {required: true, message: '终点实体类不能为空', trigger: 'blur'},
|
|
|
+ ],
|
|
|
+ entityClassRelId: [
|
|
|
+ {required: true, message: '实体关系类不能为空', trigger: 'blur'},
|
|
|
+ ],
|
|
|
+ subEntity: [
|
|
|
+ {required: true, message: '起点实体不能为空', trigger: 'blur'},
|
|
|
+ ],
|
|
|
+ objEntity: [
|
|
|
+ {required: true, message: '终点实体不能为空', trigger: 'blur'},
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ entityList: [],
|
|
|
+ entityClassOption: [],
|
|
|
+ entityClassRelationOption: [],
|
|
|
+ openByClass: false,
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
this.getList();
|
|
|
- this.findAllEntity();
|
|
|
+ this.getOption();
|
|
|
+ },
|
|
|
+ activated(){
|
|
|
+ this.getOption();
|
|
|
},
|
|
|
methods: {
|
|
|
/** 查询实体关系管理列表 */
|
|
@@ -268,12 +359,58 @@ export default {
|
|
|
...this.queryParams
|
|
|
}, `entityRelation_${new Date().getTime()}.xlsx`)
|
|
|
},
|
|
|
- findAllEntity(){
|
|
|
+ getOption(){
|
|
|
findAll().then(resp => {
|
|
|
this.entityList = resp
|
|
|
- console.info(resp)
|
|
|
})
|
|
|
- }
|
|
|
+ getEntityClassOption().then(resp => {
|
|
|
+ this.entityClassOption = resp.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getEntityClassRelationOption(){
|
|
|
+ delete this.formByClass.entityClassRelId;
|
|
|
+ if(this.formByClass.subEntityClassId && this.formByClass.objEntityClassId) {
|
|
|
+ getClassRelationOptionByClassId(this.formByClass.subEntityClassId, this.formByClass.objEntityClassId).then(resp => {
|
|
|
+ this.entityClassRelationOption = resp.data;
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.entityClassRelationOption = []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleAddByClass(){
|
|
|
+ this.resetClass();
|
|
|
+ this.openByClass = true;
|
|
|
+ this.title = "添加实体及实体关系";
|
|
|
+ },
|
|
|
+ resetClass(){
|
|
|
+ this.formByClass = {
|
|
|
+ // name: null,
|
|
|
+ // content: null,
|
|
|
+ // startNode: null,
|
|
|
+ // endNode: null,
|
|
|
+ };
|
|
|
+ this.resetForm("formClass");
|
|
|
+ },
|
|
|
+ cancelByClass(){
|
|
|
+ this.openByClass = false;
|
|
|
+ this.resetClass();
|
|
|
+ },
|
|
|
+ submitFormByClass(type){
|
|
|
+ this.$refs["formClass"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ addEntityAndRelation(this.formByClass).then(reps => {
|
|
|
+ this.$modal.msgSuccess("提交成功");
|
|
|
+ if(type) {
|
|
|
+ this.handleAddByClass()
|
|
|
+ } else {
|
|
|
+ this.openByClass = false;
|
|
|
+ this.getList();
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|