Baoqi
6 years ago
7 changed files with 357 additions and 55 deletions
@ -0,0 +1,42 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package cn.escheduler.common.task.sql; |
||||
|
||||
import cn.escheduler.common.process.Property; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Used to contains both prepared sql string and its to-be-bind parameters |
||||
*/ |
||||
public class SqlBinds { |
||||
private final String sql; |
||||
private final Map<Integer, Property> paramsMap; |
||||
|
||||
public SqlBinds(String sql, Map<Integer, Property> paramsMap) { |
||||
this.sql = sql; |
||||
this.paramsMap = paramsMap; |
||||
} |
||||
|
||||
public String getSql() { |
||||
return sql; |
||||
} |
||||
|
||||
public Map<Integer, Property> getParamsMap() { |
||||
return paramsMap; |
||||
} |
||||
} |
@ -0,0 +1,143 @@
|
||||
<template> |
||||
<div class="statement-list-model"> |
||||
<div class="select-listpp" |
||||
v-for="(item,$index) in localStatementList" |
||||
:key="item.id" |
||||
@click="_getIndex($index)"> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
type="textarea" |
||||
resize="none" |
||||
:autosize="{minRows:1}" |
||||
v-model="localStatementList[$index]" |
||||
@on-blur="_verifProp()" |
||||
style="width: 525px;"> |
||||
</x-input> |
||||
<span class="lt-add"> |
||||
<a href="javascript:" style="color:red;" @click="!isDetails && _removeStatement($index)" > |
||||
<i class="iconfont" :class="_isDetails" data-toggle="tooltip" :title="$t('delete')" ></i> |
||||
</a> |
||||
</span> |
||||
<span class="add" v-if="$index === (localStatementList.length - 1)"> |
||||
<a href="javascript:" @click="!isDetails && _addStatement()" > |
||||
<i class="iconfont" :class="_isDetails" data-toggle="tooltip" :title="$t('Add')"></i> |
||||
</a> |
||||
</span> |
||||
</div> |
||||
<span class="add" v-if="!localStatementList.length"> |
||||
<a href="javascript:" @click="!isDetails && _addStatement()" > |
||||
<i class="iconfont" :class="_isDetails" data-toggle="tooltip" :title="$t('Add')"></i> |
||||
</a> |
||||
</span> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import _ from 'lodash' |
||||
import i18n from '@/module/i18n' |
||||
import disabledState from '@/module/mixin/disabledState' |
||||
export default { |
||||
name: 'user-def-statements', |
||||
data () { |
||||
return { |
||||
// Increased data |
||||
localStatementList: [], |
||||
// Current execution index |
||||
localStatementIndex: null |
||||
} |
||||
}, |
||||
mixins: [disabledState], |
||||
props: { |
||||
statementList: Array |
||||
}, |
||||
methods: { |
||||
/** |
||||
* Current index |
||||
*/ |
||||
_getIndex (index) { |
||||
this.localStatementIndex = index |
||||
}, |
||||
/** |
||||
* delete item |
||||
*/ |
||||
_removeStatement (index) { |
||||
this.localStatementList.splice(index, 1) |
||||
this._verifProp('value') |
||||
}, |
||||
/** |
||||
* add |
||||
*/ |
||||
_addStatement () { |
||||
this.localStatementList.push('') |
||||
}, |
||||
/** |
||||
* blur verification |
||||
*/ |
||||
_handleValue () { |
||||
this._verifProp('value') |
||||
}, |
||||
/** |
||||
* Verify that the value exists or is empty |
||||
*/ |
||||
_verifProp (type) { |
||||
let arr = [] |
||||
let flag = true |
||||
_.map(this.localStatementList, v => { |
||||
arr.push(v) |
||||
if (!v) { |
||||
flag = false |
||||
} |
||||
}) |
||||
if (!flag) { |
||||
if (!type) { |
||||
this.$message.warning(`${i18n.$t('Statement cannot be empty')}`) |
||||
} |
||||
return false |
||||
} |
||||
|
||||
this.$emit('on-statement-list', _.cloneDeep(this.localStatementList)) |
||||
return true |
||||
} |
||||
}, |
||||
watch: { |
||||
// Monitor data changes |
||||
statementList () { |
||||
this.localStatementList = this.statementList |
||||
} |
||||
}, |
||||
created () { |
||||
this.localStatementList = this.statementList |
||||
}, |
||||
mounted () { |
||||
}, |
||||
components: { } |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" rel="stylesheet/scss"> |
||||
.statement-list-model { |
||||
.select-listpp { |
||||
margin-bottom: 6px; |
||||
.lt-add { |
||||
padding-left: 4px; |
||||
a { |
||||
.iconfont { |
||||
font-size: 18px; |
||||
vertical-align: middle; |
||||
margin-bottom: -2px; |
||||
display: inline-block; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.add { |
||||
a { |
||||
.iconfont { |
||||
font-size: 18px; |
||||
vertical-align: middle; |
||||
display: inline-block; |
||||
margin-top: 1px; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
Loading…
Reference in new issue