| | |
| | | <el-button size="mini" type="danger" icon="el-icon-delete" @click="delCondition(index)" style="padding: 7px 8px"></el-button> |
| | | </div> |
| | | </div> |
| | | <div v-else style="height: 220px;text-align: left"> |
| | | <avue-tree ref="tree" @node-drop="handleDrop" style="height: 220px" :data="treeData" :option="treeOption" @node-click="nodeClick" node-key="value"></avue-tree> |
| | | <div v-else @drop="drop" @dragover.prevent style="height: 220px;text-align: left"> |
| | | <avue-tree ref="tree" @node-drag-end="handleDragEnd" @node-drag-leave="handleDragLeave" @node-drag-over="handleDragOver" |
| | | style="height: 220px" :data="treeData" :option="treeOption" @node-click="nodeClick" node-key="value"></avue-tree> |
| | | </div> |
| | | <div style="text-align: right;margin-top: 10px;"> |
| | | <el-button v-if="radioForm==1" plain size="mini" type="primary" @click="addHandler">增加逻辑</el-button> |
| | |
| | | <el-button plain size="mini" type="primary" @click="">取消</el-button> |
| | | </div> |
| | | |
| | | <!--修改条件--> |
| | | <el-dialog v-dialogDrag |
| | | :title="dialog.title" |
| | | :visible.sync="dialog.showDialog" |
| | |
| | | import basicOption from "@/util/basic-option"; |
| | | import {getAllQTs} from "@/api/queryTemplate/queryDefine"; |
| | | import {getCriteria} from "@/api/queryTemplate/linkTypeQuery"; |
| | | |
| | | import {dateFormat} from "@/util/date" |
| | | export default { |
| | | name: "formQueryDialog", |
| | | props: { |
| | |
| | | nodeChild.forEach((item,index)=>{ |
| | | that.treeIndex++; |
| | | if(item.column !=null && item.column != undefined){ |
| | | const values= item.column.split(' '); |
| | | let inputValue=''; |
| | | let operator=''; |
| | | let showLabel='' |
| | | if(item.column.indexOf('not in')!=-1){ |
| | | operator='not in'; |
| | | if(values.length>3){ |
| | | inputValue=values[3]; |
| | | } |
| | | }else{ |
| | | if(values.length>1){ |
| | | operator=values[1]; |
| | | if(values.length>2){ |
| | | inputValue=values[2]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(values[0].indexOf('.')!=-1){ |
| | | const labels=values[0].split('.') |
| | | showLabel=labels[labels.length-1]; |
| | | }else { |
| | | showLabel=values[0]; |
| | | } |
| | | children.push({ |
| | | label:item.column, |
| | | value:item.column+that.treeIndex, |
| | | type:item.type, |
| | | valueIndex:'v'+that.treeIndex |
| | | valueIndex:'v'+that.treeIndex, |
| | | inputValue:inputValue, |
| | | operator:operator, |
| | | showLabel:showLabel |
| | | }) |
| | | }else { |
| | | children.push({ |
| | |
| | | } |
| | | params.type=data.atttributes.vtDataType; |
| | | this.conditionList.push(params) |
| | | }else {debugger; |
| | | }else { |
| | | if (this.clickNode.label != '并且' && this.clickNode.label != '或者') { |
| | | this.$message.error('请选中逻辑条件添加查询项'); |
| | | return; |
| | | } |
| | | this.treeIndex++; |
| | | this.$refs.tree.append({ |
| | | label: data.value, |
| | | value: data.value + this.treeIndex, |
| | | valueIndex: 'v' + this.treeIndex, |
| | | children: [] |
| | | }, this.clickNode); |
| | | this.$refs.tree.append(this.initItem(data), this.clickNode); |
| | | } |
| | | }, |
| | | handleDrop(draggingNode, dropNode, dropType, ev) { |
| | | initItem(data){ |
| | | this.treeIndex++; |
| | | let item={ |
| | | label: data.value, |
| | | value: data.value + this.treeIndex, |
| | | valueIndex: 'v' + this.treeIndex, |
| | | type:data.vtDataType, |
| | | children: [], |
| | | inputValue:data.value, |
| | | operator:'=', |
| | | showLabel:data.value |
| | | }; |
| | | let showLabel=''; |
| | | if(data.value.indexOf('.')!=-1){ |
| | | const labels=data.value.split('.') |
| | | showLabel=labels[labels.length-1]; |
| | | }else { |
| | | showLabel=data.value; |
| | | } |
| | | item.showLabel=showLabel; |
| | | return item |
| | | }, |
| | | handleDragEnd(draggingNode, dropNode, dropType, ev) { |
| | | debugger; |
| | | console.log('tree drop: ', dropNode.label, dropType); |
| | | console.log('tree drag end: ', dropNode && dropNode.label, dropType); |
| | | }, |
| | | handleDragOver({event}) { |
| | | // 阻止默认事件,允许放置 |
| | | event.preventDefault(); |
| | | }, |
| | | handleDragLeave({event}) { |
| | | // 清除放置效果 |
| | | event.preventDefault(); |
| | | }, |
| | | //删除普通查询条件 |
| | | delCondition(index) { |
| | |
| | | if(node.children){ |
| | | this.clearTreeValue(node.children) |
| | | }else { |
| | | let values=node.label.split(' '); |
| | | if(values.length>2){ |
| | | node.label=values[0]+' '+values[1]; |
| | | if(node.label.indexOf('not in')!=-1){ |
| | | node.label=node.label.split(' ')[0]+' not in' |
| | | }else { |
| | | let values = node.label.split(' '); |
| | | if (values.length > 2) { |
| | | node.label = values[0] + ' ' + values[1]; |
| | | } |
| | | } |
| | | } |
| | | }) |
| | |
| | | } else if (this.clickNode.label == '或者') { |
| | | this.clickNode.label = '并且' |
| | | } else { |
| | | const values= this.clickNode.label.split(' '); |
| | | this.clickNode.inputValue=''; |
| | | if(values.length>1){ |
| | | this.clickNode.operator=values[1]; |
| | | if(values.length>2){ |
| | | if(['VTDateTime','VTDate','VTTime'].includes(this.clickNode.type)){ |
| | | this.clickNode.inputValue=new Date(values[2]); |
| | | }else { |
| | | this.clickNode.inputValue=values[2]; |
| | | } |
| | | } |
| | | } |
| | | if(values[0].indexOf('.')!=-1){ |
| | | const labels=values[0].split('.') |
| | | this.clickNode.showLabel=labels[labels.length-1]; |
| | | }else { |
| | | this.clickNode.showLabel=values[0]; |
| | | } |
| | | this.dialog.showDialog = true; |
| | | } |
| | | } else { |
| | |
| | | submitDialog() { |
| | | const values= this.clickNode.label.split(' '); |
| | | this.clickNode.label = values[0]+' '+this.clickNode.operator+' '+this.clickNode.inputValue; |
| | | try{ |
| | | if(['VTDateTime'].includes(this.clickNode.type)){ |
| | | this.clickNode.label = values[0]+' '+this.clickNode.operator+' '+dateFormat(this.clickNode.inputValue); |
| | | }else if(['VTDate'].includes(this.clickNode.type)){ |
| | | this.clickNode.label = values[0]+' '+this.clickNode.operator+' '+dateFormat(this.clickNode.inputValue ,'yyyy-MM-dd'); |
| | | }else if(['VTTime'].includes(this.clickNode.type)){ |
| | | this.clickNode.label = values[0]+' '+this.clickNode.operator+' '+dateFormat(this.clickNode.inputValue ,'hh:mm:ss'); |
| | | } |
| | | }catch (e) { |
| | | |
| | | } |
| | | |
| | | this.dialog.showDialog = false; |
| | | }, |
| | | //获取查询模板列表 |