mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-24 19:06:35 +08:00
实现基本的匹配条件管理
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3 v-if="!isUpdating">添加子条件</h3>
|
||||
<h3 v-if="isUpdating">修改子条件</h3>
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">选择条件类型</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="condType" v-model="condType">
|
||||
<option v-for="c in components" :value="c.type">{{c.name}}</option>
|
||||
</select>
|
||||
{$ range .components}
|
||||
<p class="comment" v-if="condType == '{$ .Type}'">{$ .Description}</p>
|
||||
{$ end}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>设置条件参数</td>
|
||||
<td>
|
||||
{$ range .components}
|
||||
<{$ .Component} v-if="condType == '{$ .Type}'" :v-cond="cond"></{$ .Component}>
|
||||
{$ end}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
@@ -0,0 +1,14 @@
|
||||
Tea.context(function () {
|
||||
this.isUpdating = false
|
||||
this.cond = null
|
||||
|
||||
this.success = NotifyPopup
|
||||
this.condType = (this.components.length > 0) ? this.components[0].type : ""
|
||||
|
||||
// 是否正在修改
|
||||
if (window.parent.UPDATING_COND != null) {
|
||||
this.isUpdating = true
|
||||
this.condType = window.parent.UPDATING_COND.type
|
||||
this.cond = window.parent.UPDATING_COND
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,58 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>添加条件</h3>
|
||||
|
||||
<form class="ui form" data-tea-success="success" data-tea-action="$">
|
||||
<input type="hidden" name="condGroupJSON" :value="JSON.stringify(group)"/>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">子条件列表</td>
|
||||
<td>
|
||||
<div v-if="group.conds.length > 0">
|
||||
<var v-for="(cond, index) in group.conds" style="font-style: normal;display: inline-block; margin-bottom:0.5em">
|
||||
<span class="ui label small">
|
||||
<var v-if="cond.type.length == 0" style="font-style: normal">{{cond.param}} <var>{{cond.operator}}</var></var>
|
||||
<var v-if="cond.type.length > 0" style="font-style: normal">{{typeName(cond)}}: </var>
|
||||
{{cond.value}}
|
||||
<a href="" title="修改" @click.prevent="updateCond(index, cond)"><i class="icon pencil small"></i></a> <a href="" title="删除" @click.prevent="removeCond(index)"><i class="icon remove"></i></a> </span>
|
||||
<var v-if="index < group.conds.length - 1"> {{group.connector}} </var>
|
||||
</var>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<button class="ui button tiny" type="button" @click.prevent="addCond()">+</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
<tbody v-if="moreOptionsVisible">
|
||||
<tr>
|
||||
<td>子条件之间关系</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" v-model="group.connector">
|
||||
<option value="and">和</option>
|
||||
<option value="or">或</option>
|
||||
</select>
|
||||
<p class="comment" v-if="group.connector == 'and'">必须满足所有条件才能成立。</p>
|
||||
<p class="comment" v-if="group.connector == 'or'">只要满足其中一个条件即可成立。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>补充说明</td>
|
||||
<td>
|
||||
<textarea rows="3" v-model="group.description" maxlength="100"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>是否启用</td>
|
||||
<td>
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" v-model="group.isOn"/>
|
||||
<label></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
@@ -0,0 +1,66 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyPopup
|
||||
|
||||
this.group = {
|
||||
connector: "or",
|
||||
description: "",
|
||||
isReverse: false,
|
||||
conds: [],
|
||||
isOn: true
|
||||
}
|
||||
|
||||
// 是否在修改
|
||||
this.$delay(function () {
|
||||
if (window.parent.UPDATING_COND_GROUP != null) {
|
||||
this.group = window.parent.UPDATING_COND_GROUP
|
||||
}
|
||||
})
|
||||
|
||||
// 条件类型名称
|
||||
this.typeName = function (cond) {
|
||||
let c = this.components.$find(function (k, v) {
|
||||
return v.type == cond.type
|
||||
})
|
||||
if (c != null) {
|
||||
return c.name;
|
||||
}
|
||||
return cond.param + " " + cond.operator
|
||||
}
|
||||
|
||||
// 添加条件
|
||||
this.addCond = function () {
|
||||
window.UPDATING_COND = null
|
||||
|
||||
let that = this
|
||||
|
||||
teaweb.popup("/servers/server/settings/conds/addCondPopup", {
|
||||
width: "32em",
|
||||
height: "22em",
|
||||
callback: function (resp) {
|
||||
that.group.conds.push(resp.data.cond)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 删除条件
|
||||
this.removeCond = function (condIndex) {
|
||||
let that = this
|
||||
teaweb.confirm("确定要删除此条件?", function () {
|
||||
that.group.conds.$remove(condIndex)
|
||||
})
|
||||
}
|
||||
|
||||
// 修改条件
|
||||
this.updateCond = function (condIndex, cond) {
|
||||
window.UPDATING_COND = cond
|
||||
let that = this
|
||||
|
||||
teaweb.popup("/servers/server/settings/conds/addCondPopup", {
|
||||
width: "32em",
|
||||
height: "22em",
|
||||
callback: function (resp) {
|
||||
that.group.conds[condIndex] = resp.data.cond
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -7,7 +7,7 @@
|
||||
<input type="hidden" name="webId" :value="webId"/>
|
||||
<input type="hidden" name="gzipId" :value="gzipConfig.id"/>
|
||||
|
||||
<http-gzip-box :v-gzip-config="gzipConfig"></http-gzip-box>
|
||||
<http-gzip-box :v-gzip-ref="gzipRef" :v-gzip-config="gzipConfig"></http-gzip-box>
|
||||
|
||||
<div class="margin"></div>
|
||||
<submit-btn></submit-btn>
|
||||
|
||||
Reference in New Issue
Block a user