|
@@ -1,73 +1,88 @@
|
|
|
<template>
|
|
|
<div class="AdvancedQuery">
|
|
|
<div class="AdvancedQuery_from">
|
|
|
- <el-form ref="paramsForm" class="query-params" :model="paramsForm" :rules="paramsForm.validateRules">
|
|
|
- <el-row class="query-params-wrapper">
|
|
|
- <el-col v-for="(row, rowIndex) in paramsForm.params" class="query-params-wrapper-list flex-wrap" :key="rowIndex" :span="24">
|
|
|
- <el-form-item v-for="(col, colIndex) in paramsTableCols" :key="colIndex" :prop="'params.' + rowIndex + '.' + col.prop" :rules="paramsForm.validateRules[col.prop]">
|
|
|
- <template v-if="
|
|
|
+ <el-scrollbar style="height: 100%" :horizontal="false">
|
|
|
+ <el-form ref="paramsForm" class="query-params" :model="paramsForm" :rules="paramsForm.validateRules">
|
|
|
+ <el-row class="query-params-wrapper">
|
|
|
+ <el-col v-for="(row, rowIndex) in paramsForm.params" class="query-params-wrapper-list flex-wrap" :key="rowIndex" :span="24">
|
|
|
+ <el-form-item v-for="(col, colIndex) in paramsTableCols" :key="colIndex" :prop="'params.' + rowIndex + '.' + col.prop" :rules="paramsForm.validateRules[col.prop]">
|
|
|
+ <template v-if="
|
|
|
col.prop === 'comparisonOperator' ||
|
|
|
col.inputType[rowIndex] === 'select'
|
|
|
">
|
|
|
- <el-select style="width: 120px;" v-model="row[col.prop]" placeholder="请选择" @change="
|
|
|
+ <el-select style="width: 120px;" v-model="row[col.prop]" placeholder="请选择" @change="
|
|
|
value => {
|
|
|
selectChangeHandler(value, rowIndex, colIndex)
|
|
|
}
|
|
|
">
|
|
|
- <el-option v-for="(option, i) in col.options[rowIndex]" :key="i" :value="option.value" :label="option.label" />
|
|
|
- </el-select>
|
|
|
- </template>
|
|
|
- <template v-else-if="col.inputType === 'select'">
|
|
|
- <el-select v-model="row[col.prop]" placeholder="请选择" @change="
|
|
|
+ <el-option v-for="(option, i) in col.options[rowIndex]" :key="i" :value="option.value" :label="option.label" />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="col.inputType === 'select'">
|
|
|
+ <el-select style="width: 130px;" v-model="row[col.prop]" placeholder="请选择" @change="
|
|
|
value => {
|
|
|
selectChangeHandler(value, rowIndex, colIndex)
|
|
|
}
|
|
|
">
|
|
|
- <el-option v-for="(option, i) in col.options" :key="i" :value="option.value" :label="option.label" />
|
|
|
- </el-select>
|
|
|
- </template>
|
|
|
- <template v-else-if="
|
|
|
+ <el-option v-for="(option, i) in col.options" :key="i" :value="option.value" :label="option.label" />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="
|
|
|
['varchar', 'text', 'longtext'].includes(
|
|
|
col.inputType[rowIndex]
|
|
|
)
|
|
|
">
|
|
|
- <el-input v-model="row[col.prop]" placeholder="请输入" :disabled="
|
|
|
+ <el-input v-model="row[col.prop]" placeholder="请输入" :disabled="
|
|
|
col.prop === 'paramValue' && paramsForm.disabled[rowIndex]
|
|
|
" />
|
|
|
- </template>
|
|
|
- <template v-else-if="col.inputType[rowIndex] === 'number'">
|
|
|
- <el-input v-model="row[col.prop]" placeholder="请输入" :disabled="
|
|
|
+ </template>
|
|
|
+ <template v-else-if="col.inputType[rowIndex] === 'number'">
|
|
|
+ <el-input v-model="row[col.prop]" placeholder="请输入" :disabled="
|
|
|
col.prop === 'paramValue' && paramsForm.disabled[rowIndex]
|
|
|
" @keydown.native="inputHold(row[col.prop])" @input="inputLimit(row[col.prop], rowIndex)" @blur="inputFix(row[col.prop], rowIndex)" />
|
|
|
- </template>
|
|
|
- <template v-else-if="col.inputType[rowIndex] === 'date'">
|
|
|
- <el-date-picker v-model="row[col.prop]" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="请选择" :clearable="false" />
|
|
|
- </template>
|
|
|
- <template v-else-if="col.inputType[rowIndex] === 'datetime'">
|
|
|
- <el-date-picker v-model="row[col.prop]" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择" :clearable="false" />
|
|
|
- </template>
|
|
|
- <template v-else-if="col.inputType === 'delete'">
|
|
|
- <i class="clickable-delete el-icon-error" @click="deleteParam(rowIndex)" />
|
|
|
- </template>
|
|
|
- <template v-else-if="col.inputType === 'connector'">
|
|
|
- <div v-if="row.connector" class="clickable-toggle" @click="toggle(rowIndex)">
|
|
|
- {{ row.connector === 'and' ? '并且' : '或者' }}
|
|
|
- </div>
|
|
|
- <div v-else class="clickable-add" @click="addParamsHandler">
|
|
|
- <span class="el-icon-circle-plus-outline"></span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-form>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="col.inputType[rowIndex] === 'date'">
|
|
|
+ <el-date-picker v-model="row[col.prop]" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="请选择" :clearable="false" />
|
|
|
+ </template>
|
|
|
+ <template v-else-if="col.inputType[rowIndex] === 'datetime'">
|
|
|
+ <el-date-picker v-model="row[col.prop]" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择" :clearable="false" />
|
|
|
+ </template>
|
|
|
+ <template v-else-if="col.inputType === 'delete'">
|
|
|
+ <i class="clickable-delete el-icon-error" @click="deleteParam(rowIndex)" />
|
|
|
+ </template>
|
|
|
+ <template v-else-if="col.inputType === 'connector'">
|
|
|
+ <div v-if="row.connector" class="clickable-toggle" @click="toggle(rowIndex)">
|
|
|
+ {{ row.connector === 'and' ? '并且' : '或者' }}
|
|
|
+ </div>
|
|
|
+ <div v-else class="clickable-add" @click="addParamsHandler">
|
|
|
+ <span class="el-icon-circle-plus-outline"></span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ </el-scrollbar>
|
|
|
+ </div>
|
|
|
+ <div class="AdvancedQuery_list">
|
|
|
+ <el-scrollbar style="height: 100%" :horizontal="false">
|
|
|
+ <div v-for="(item,index) in catchOptions" :key="index">
|
|
|
+ <div style="cursor: pointer;" class="flex">
|
|
|
+ <span class="AdvancedQuery_list_text">{{ item.itemKey }}</span>
|
|
|
+ <el-popconfirm :title="'确定删除'+item.itemKey+'吗?'">
|
|
|
+ <span slot="reference" class="el-icon-error"></span>
|
|
|
+ </el-popconfirm>
|
|
|
+ </div>
|
|
|
+ <el-divider v-if="catchOptions.length != index+1"></el-divider>
|
|
|
+ </div>
|
|
|
+ </el-scrollbar>
|
|
|
</div>
|
|
|
- <div class="AdvancedQuery_list"></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { parseTime } from '@/utils/index'
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
const comparisonOperatorOptions = [
|
|
|
{
|
|
|
label: '小于等于',
|
|
@@ -108,9 +123,17 @@ const comparisonOperatorOptions = [
|
|
|
]
|
|
|
export default {
|
|
|
name: 'AdvancedQueryForm',
|
|
|
+ props: {
|
|
|
+ selectOptions: {
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ }
|
|
|
+ },
|
|
|
data () {
|
|
|
return {
|
|
|
queryContent: [],
|
|
|
+ catchOptions: JSON.parse(localStorage.getItem('catchOptions')) || [],
|
|
|
+ catchOptionsAll: [],
|
|
|
flightDate: new Array(2).fill(parseTime(new Date(), '{y}-{m}-{d}')),
|
|
|
paramsForm: {
|
|
|
params: [],
|
|
@@ -167,10 +190,36 @@ export default {
|
|
|
columnSet: {},
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(['authMsg']),
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ 'paramsForm.params': {
|
|
|
+ handler (params) {
|
|
|
+ const { length } = params
|
|
|
+ params[length - 1].connector = ''
|
|
|
+ if (params[length - 2] && !params[length - 2].connector) {
|
|
|
+ params[length - 2].connector = 'and'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
mounted () {
|
|
|
- this.addParamsHandler()
|
|
|
+ this.queryHandler()
|
|
|
},
|
|
|
methods: {
|
|
|
+ queryHandler () {
|
|
|
+ const colDatas = this.authMsg
|
|
|
+ console.log(colDatas)
|
|
|
+ if (colDatas?.length) {
|
|
|
+ const columns = colDatas.filter(item => item.isdisplay != 0)
|
|
|
+ const datas = _.orderBy(columns, ['displaynumber'], ['asc', 'desc'])
|
|
|
+ this.getColumnSet(datas)
|
|
|
+ }
|
|
|
+ if (!this.paramsForm.params.length) {
|
|
|
+ this.addParamsHandler()
|
|
|
+ }
|
|
|
+ },
|
|
|
advancedQueryHandler () {
|
|
|
try {
|
|
|
this.$refs['paramsForm'].validate(valid => {
|
|
@@ -302,17 +351,58 @@ export default {
|
|
|
this.paramsForm.params[rowIndex].connector =
|
|
|
connector === 'and' ? 'or' : 'and'
|
|
|
},
|
|
|
+ getColumnSet (columnSet) {
|
|
|
+ const reflect = {}
|
|
|
+ columnSet.forEach(async item => {
|
|
|
+ if (!this.columnSet[item.columncode]) {
|
|
|
+ this.columnSet[item.columncode] = item
|
|
|
+
|
|
|
+ this.paramsTableCols[0].options.push({
|
|
|
+ label: item.columnname,
|
|
|
+ value: item.columncode,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //收藏
|
|
|
+ advancedQueryCollect () {
|
|
|
+ this.advancedQueryHandler()
|
|
|
+ if (!this.queryContent.length) return
|
|
|
+ this.$prompt('请输入收藏标题', '收藏', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ inputPattern: /^.+$/,
|
|
|
+ inputErrorMessage: '请输入收藏标题'
|
|
|
+ }).then(({ value }) => {
|
|
|
+ this.catchOptionsAll.push(this.queryContent)
|
|
|
+ const catchItem = {
|
|
|
+ itemKey: value,
|
|
|
+ itemVal: this.catchOptionsAll?.at(-1)
|
|
|
+ }
|
|
|
+ this.catchOptions.push(catchItem)
|
|
|
+ localStorage.setItem('catchOptions', JSON.stringify(this.catchOptions))
|
|
|
+ }).catch((err) => {
|
|
|
+ console.log(err)
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '取消输入'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
.AdvancedQuery {
|
|
|
- height: 100%;
|
|
|
+ height: calc(100vh - 172px);
|
|
|
position: relative;
|
|
|
width: 100%;
|
|
|
&_from {
|
|
|
- height: 65%;
|
|
|
+ height: 80%;
|
|
|
+ }
|
|
|
+ &_list {
|
|
|
+ height: 20%;
|
|
|
}
|
|
|
.query-params-wrapper-list {
|
|
|
.el-form-item {
|