优化缓存条件设置,支持不缓存条件设置,支持条件排序等

This commit is contained in:
刘祥超
2021-06-08 22:46:08 +08:00
parent 9de66f080d
commit a8030fa045
17 changed files with 319 additions and 115 deletions

View File

@@ -1,10 +1,11 @@
{$layout "layout_popup"}
<h3>添加缓存设置</h3>
<h3 v-if="!isReverse">添加缓存设置</h3>
<h3 v-if="isReverse">添加不缓存设置</h3>
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<table class="ui table definition selectable">
<tbody is="http-cache-ref-box" :v-cache-ref="cacheRef"></tbody>
</table>
<submit-btn>确定</submit-btn>
<table class="ui table definition selectable">
<tbody is="http-cache-ref-box" :v-cache-ref="cacheRef" :v-is-reverse="isReverse"></tbody>
</table>
<p class="comment">如果请求满足当前添加的条件,则不缓存。</p>
<submit-btn>确定</submit-btn>
</form>

View File

@@ -4,5 +4,6 @@ Tea.context(function () {
if (window.parent.UPDATING_CACHE_REF != null) {
this.cacheRef = window.parent.UPDATING_CACHE_REF
this.isReverse = this.cacheRef.isReverse
}
})

View File

@@ -7,7 +7,7 @@
<tr>
<td class="title">选择条件类型</td>
<td>
<select class="ui dropdown auto-width" name="condType" v-model="condType">
<select class="ui dropdown auto-width" name="condType" v-model="condType" @change="changeCondType">
<option v-for="c in components" :value="c.type">{{c.name}}</option>
</select>
{$ range .components}
@@ -16,7 +16,7 @@
</td>
</tr>
<tr>
<td>设置条件参数</td>
<td>{{paramsTitle}}</td>
<td>
{$ range .components}
<{$ .Component} v-if="condType == '{$ .Type}'" :v-cond="cond"></{$ .Component}>

View File

@@ -1,6 +1,7 @@
Tea.context(function () {
this.isUpdating = false
this.cond = null
this.paramsTitle = ""
this.success = NotifyPopup
this.condType = (this.components.length > 0) ? this.components[0].type : ""
@@ -11,4 +12,20 @@ Tea.context(function () {
this.condType = window.parent.UPDATING_COND.type
this.cond = window.parent.UPDATING_COND
}
this.changeCondType = function () {
let that = this
let c = this.components.$find(function (k, v) {
return v.type == that.condType
})
if (c == null || c.paramsTitle.length == 0) {
that.paramsTitle = "条件参数"
} else {
that.paramsTitle = c.paramsTitle
}
}
this.$delay(function () {
this.changeCondType()
})
})

View File

@@ -1,7 +1,7 @@
{$layout "layout_popup"}
<h3>添加条件</h3>
<h3 v-if="!isUpdating">添加条件分组</h3>
<h3 v-if="isUpdating">修改条件分组</h3>
<form method="post" 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">
@@ -22,21 +22,21 @@
<button class="ui button tiny" type="button" @click.prevent="addCond()">+</button>
</td>
</tr>
<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 colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="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>

View File

@@ -9,10 +9,13 @@ Tea.context(function () {
isOn: true
}
this.isUpdating = false
// 是否在修改
this.$delay(function () {
if (window.parent.UPDATING_COND_GROUP != null) {
this.group = window.parent.UPDATING_COND_GROUP
this.isUpdating = true
} else if (this.group.conds.length == 0) {
// 如果尚未有条件,则自动弹出添加界面
this.addCond()
@@ -62,7 +65,7 @@ Tea.context(function () {
width: "32em",
height: "22em",
callback: function (resp) {
that.group.conds[condIndex] = resp.data.cond
Vue.set(that.group.conds, condIndex, resp.data.cond)
}
})
}