constraintsearchdialog finished

This commit is contained in:
leap 2024-06-27 17:33:18 +08:00
parent 069766f873
commit a197d646ae
3 changed files with 194 additions and 140 deletions

2
.gitignore vendored
View File

@ -2,7 +2,7 @@
node_modules
/dist
/node_modules.zip
.vscode
# local env files
.env.local

View File

@ -1,16 +1,21 @@
<!--
@brief: 添加约束条件的对话框
@date: 2024年6月27日
@author: myz
-->
<template>
<el-container>
<!-- 其中@click.stop很重要 -->
<el-dialog
v-model = 'dialogVisible'
draggable="true"
align-center = 'true'
:draggable= 'true'
:align-center = "true"
@close = handleClose
@click.stop
>
<!-- 表头添加约束条件按钮 -->
<template #header>
<el-button class = 'btnAdd'>
<el-icon><Plus/></el-icon>
</el-button>
<el-text>条件查找</el-text>
<el-text>条件查找约束条件添加</el-text>
</template>
<!-- 表单用于选择约束条件 -->
<el-form
@ -26,27 +31,49 @@
</el-select>
</el-form-item>
<!-- 约束列 -->
<el-form-item label = '约束列'></el-form-item>
<el-form-item label = '约束列'>
<el-select v-model = 'form.col_id'>
<el-option
v-for = "item in colData"
:key = 'item.col_id'
:label = 'item.col_name'
:value = 'item.col_id'/>
</el-select>
</el-form-item>
<!-- 数据类型 -->
<el-form-item label = '数据类型'></el-form-item>
<el-select v-model = 'form.type'>
<el-option label = 'INT' value = 'INT' />
<el-option label = 'STRING' value = 'STRING' />
<el-option label = 'DATE' value = 'DATE' />
<el-option label = '实数' value = 'double' />
<el-option label = '字符串' value = 'string' />
<el-option label = '日期' value = 'date' />
</el-select>
<!-- 上限 -->
<el-form-item label = '上限'></el-form-item>
<el-form-item v-show = "max_limit_visible" label = '上限'>
<el-input v-model = 'form.max_limit' />
</el-form-item>
<!-- 下限 -->
<el-form-item label = '下限'></el-form-item>
<el-form-item v-show = "min_limit_visible" label = '下限'>
<el-input v-model = 'form.min_limit' />
</el-form-item>
<el-form-item v-show = "continuous_time_visible" label = '连续持续时间'>
<el-date-picker
v-model = "form.continuous_time"
type = "daterange"
range-sperator = "至"
start-placeholder = "起始日期"
end-placeholder = '终止日期'
value-format = 'DD.MM.YYYY' />
</el-form-item>
<el-form-item v-show = "search_string_visible" label = '搜索字符串'>
<el-input v-model = 'form.search_string' />
</el-form-item>
</el-form>
<!-- 控制关闭和确认按钮 -->
<template #footer>
<el-button class = 'btnConfirm'>
<el-button class = 'btnConfirm' @click = handleConfirm>
确认
</el-button>
<el-button class = 'btnClose' @click = 'dialogVisible = false'>
<el-button class = 'btnClose' @click = handleClose>
关闭
</el-button>
</template>
@ -54,26 +81,125 @@
</el-container>
</template>
<script>
export default{
<script lang = 'ts'>
import { defineComponent, ref, watch } from 'vue';
//
interface ColData{
col_id: string,
col_name: string
}
export default defineComponent({
name: 'ConstraintSearchDialog',
props: {
colData: {
type: Array,
default: () => []
}
},
data(){
return{
form:{
logic: '',
col_id: '',
type: '',
max_limit: '',
min_limit: '',
},
dialogVisible: true
// col_id id col_name
colData: {
type: Array as ()=>ColData[],
required: true
},
isVisible: Boolean
},
emits: ['update:isVisible','confirm'],
setup(props, {emit}){
const dialogVisible = ref(false);
//
const max_limit_visible = ref(false);
const min_limit_visible = ref(false);
const continuous_time_visible = ref(false);
const search_string_visible = ref(false);
const form = ref({
logic : '', //
col_id: '', //
type: '', //
max_limit: '', //
min_limit: '', //
continuous_time: '', //
search_string: '', //
});
// 使()=>props.isVisible propsprops.isVisible
watch(()=>props.isVisible, (newValue) =>{
dialogVisible.value = newValue;
});
// type
watch(()=>form.value.type, (newValue) =>{
if(newValue == 'double')
{
max_limit_visible.value = true;
min_limit_visible.value = true;
}
else if( newValue == 'string')
{
search_string_visible.value = true;
}
else if( newValue == 'date')
{
continuous_time_visible.value = true;
}
else{
max_limit_visible.value = false;
min_limit_visible.value = false;
continuous_time_visible.value = false;
search_string_visible.value = false;
}
});
const handleClose = ()=>{
//
form.value.logic = '';
form.value.col_id = '';
form.value.type = '';
form.value.max_limit = '';
form.value.min_limit = '';
//
dialogVisible.value = false;
// isVisible
emit('update:isVisible',false);
};
//
const handleConfirm_Preprocessing = ()=>
{
if(form.value.type != ''
&& form.value.logic != ''
&& form.value.col_id != ''
)
{
if(form.value.type == 'double'
&& form.value.max_limit != ''
&& form.value.min_limit != ''
)
return true;
else if(form.value.type == 'date'
&& form.value.continuous_time != ''
)
return true;
else if(form.value.type == 'string'
&& form.value.search_string != ''
)
return true;
}
return false;
}
const handleConfirm = ()=>{
//
if(handleConfirm_Preprocessing())
emit('confirm',form.value);
handleClose();
};
return {
dialogVisible,
form,
handleClose,
handleConfirm,
max_limit_visible,
min_limit_visible,
continuous_time_visible,
search_string_visible,
}
}
}
})
</script>

View File

@ -10,7 +10,7 @@
</el-header>
<el-main class ='container_Tools_Main'>
<!-- 折叠版存放约束条件显示 -->
<!-- <el-container class = 'containerConstraints'>
<el-container class = 'containerConstraints'>
<el-collapse v-model = 'activeNames'>
<el-collapse-item name = '1'>
<div class = 'divConstraintView' v-for="(i,index) in Constraints" :key="index">
@ -19,29 +19,9 @@
</div>
</el-collapse-item>
</el-collapse>
</el-container> -->
</el-container>
<!-- 工具栏 -->
<el-header class ='containerTools'>
<div v-show = show_choose>
<select v-model="choose_merge">
<option disabled value="">请选择逻辑关系</option>
<option v-for="(i,index) in Merges" :value="i" :key="index">{{ i }}</option>
</select>
<select v-model="choose_col" v-show="if_show_col">
<option disabled value="">请选择需要约束的列</option>
<option v-for="(i,index) in clueCols" :value="i.col_id" :key="index">{{ i.col_name }}</option>
</select>
<select v-model="choose_type" v-show="if_show_type">
<option disabled value="">请选择数据类型</option>
<option v-for="(i,index) in Types" :value="i" :key="index">{{ i }}</option>
</select>
<input type="number" v-model="choose_up" placeholder="请输入上限可为INF" v-show = "if_show_updown">
<input type="number" v-model="choose_down" placeholder="请输入下限可为INF" v-show = "if_show_updown">
<VueDatePicker v-model="choose_date" v-show="if_show_date" placeholder = "请选择持续时间" model-type="dd.MM.yyyy" :range="{ partialRange: false }"></VueDatePicker>
<input type="text" v-model="choose_inside" placeholder="请输入连续字串" v-show = "if_show_inside">
<button @click="constraint_add" v-show = "if_show_ok">确定</button>
</div>
<el-button class = 'btnDelete'>
<el-tooltip content = '删除所有'>
<el-icon><Delete /></el-icon>
@ -51,13 +31,17 @@
<el-tooltip content = '条件查找'>
<el-icon><Search /></el-icon>
</el-tooltip>
<!-- 条件查找对应的对话框 -->
<el-dialog
v-model = 'searchDialogVisible'
>
<ConstraintSearchDialog />
</el-dialog>
<!-- 条件查找对应的对话框 -->
<!-- @author myz
@brief: 自实现的对话框用于提交约束条件添加
@params: colDate 表头属性的数据
@v-model:isVisible 控制对话框可见的v-model
@confirm: @confirm 处理子部件的confirm事件 -->
<ConstraintSearchDialog
:colData = 'clueCols'
v-model:isVisible = 'searchDialogVisible'
@confirm = 'handleSearchDialogConfirm'
/>
</el-button>
<el-button class = 'btnMore' @click="dochart">
<el-tooltip content = '更多'>
@ -171,28 +155,12 @@ export default{
//
searchDialogVisible : false,
//
show_choose : false,
"Constraints":[//
{"merge":"AND","col_id":"3","type":"double","down":"0","up":"INF","inside":"","date":""}, // 1_30
{"merge":"AND","col_id":"2","type":"date","down":"","up":"","inside":"","date":"03.06.2024,30.06.2024"}, // !_22024/1/1
{"merge":"OR","col_id":"4","type":"string","down":"","up":"","inside":"AAA","date":""} // 1_4(),AAA
],
"Merges":["AND","OR","NOR"],
"Types":["日期","实数","字符串"],
choose_merge: '',
if_show_col:false,
choose_col:'',
if_show_type:false,
choose_type:'',
if_show_updown:false,
choose_up:'',
choose_down:'',
if_show_inside:false,
choose_inside:'',
if_show_ok:false,
if_show_date:false,
choose_date:"",
//
pageTitle,
clueId,
chart:false,
@ -202,8 +170,22 @@ export default{
clueData: generateMockData(clueCols, 20), // 20 , clueData:[]
}
},
methods:{
//
methods:{
// confirm
handleSearchDialogConfirm(form){
console.log("提交约束条件", form);
const newConstraint = {
"merge": form.logic,
"col_id": form.col_id,
"type": form.type,
"inside": form.search_string,
"up": form.max_limit,
"down": form.min_limit,
"date": form.continuous_time[0] + ',' + form.continuous_time[1],
}
this.Constraints.push(newConstraint);
},
// id
search_clu_name(aa){
for (let col of this.clueCols) {
if(aa == col.col_id)
@ -232,28 +214,6 @@ export default{
show_choose_col(){
return false;
},
constraint_add(){
let newConstraint = {
"merge":this.choose_merge, // AND
"col_id":this.choose_col, // 5ID
"type":"",
"inside":"",
"up":"",
"down":"",
"date":""
};
if(this.choose_type == "字符串")newConstraint.type = "string";
if(this.choose_type == "实数")newConstraint.type = "double";
if(this.choose_type == "日期")newConstraint.type = "date";
if(this.choose_inside) newConstraint.inside = this.choose_inside;
if(this.choose_up) newConstraint.up = this.choose_up;
if(this.choose_down) newConstraint.down = this.choose_down;
if(this.choose_date) newConstraint.date = this.choose_date;
this.Constraints.push(newConstraint);
this.if_show_date = this.if_show_col = this.if_show_inside = this.if_show_ok = this.if_show_type = this.if_show_updown = false;
this.choose_col = this.choose_down = this.choose_inside = this.choose_merge = this.choose_type = this.choose_up = "";
this.show_choose = false;
},
constraint_delete(index){
this.Constraints.splice(index, 1);
},
@ -396,45 +356,13 @@ export default{
}
},
watch: {
//
searchDialogVisible(newValue){
console.log(newValue);
},
Constraints(newv,oldv){
console.log(newv);
},
choose_merge(newv,oldv){
if(newv == '')this.if_show_col = false;
else this.if_show_col = true;
},
choose_col(newv,oldv){
if(newv == '')this.if_show_type = false;
else this.if_show_type = true;
},
choose_type(newv,oldv){
if(newv == "")this.if_show_inside = false,this.if_show_updown = false;
else{
if(newv == "字符串")this.if_show_updown = false,this.if_show_inside = true,this.if_show_date = false;
if(newv == "日期")this.if_show_updown = false,this.if_show_inside = false,this.if_show_date = true;
if(newv == "实数")this.if_show_updown = true,this.if_show_inside = false,this.if_show_date = false;
}
},
choose_inside(newv,oldv){
if((this.choose_type == "字符串" && newv != "") || ((this.choose_type == "实数") && this.choose_down!="" && this.choose_up!="") || (this.choose_type == "日期" && this.choose_date != ""))
this.if_show_ok = true;
else this.if_show_ok = false;
},
choose_up(newv,oldv){
if((this.choose_type == "字符串" && this.choose_inside != "") || ((this.choose_type == "实数") && this.choose_down!="" && newv!="") || (this.choose_type == "日期" && this.choose_date != ""))
this.if_show_ok = true;
else this.if_show_ok = false;
},
choose_down(newv,oldv){
if((this.choose_type == "字符串" && this.choose_inside != "") || ((this.choose_type == "实数") && newv != "" && this.choose_up!="") || (this.choose_type == "日期" && this.choose_date != ""))
this.if_show_ok = true;
else this.if_show_ok = false;
},
choose_date(newv,oldv){
if((this.choose_type == "字符串" && this.choose_inside != "") || ((this.choose_type == "实数") && this.choose_down != "" && this.choose_up!="") || (this.choose_type == "日期" && this.newv != ""))
this.if_show_ok = true;
else this.if_show_ok = false;
},
},
//
beforeMount() {
@ -525,6 +453,6 @@ export default{
margin: 0;
}
.containerConstraints{
height: 2%;
height: auto;
}
</style>