优化节点DNS线路选择组件

This commit is contained in:
刘祥超
2023-08-25 17:30:21 +08:00
parent b408996e72
commit c547837ae3

View File

@@ -70,6 +70,9 @@ Vue.component("dns-route-selector", {
this.routes.$removeIf(function (k, v) { this.routes.$removeIf(function (k, v) {
return v.code + "@" + v.domainId == route.code + "@" + route.domainId return v.code + "@" + v.domainId == route.code + "@" + route.domainId
}) })
},
clearKeyword: function () {
this.keyword = ""
} }
}, },
watch: { watch: {
@@ -103,16 +106,22 @@ Vue.component("dns-route-selector", {
<tr> <tr>
<td class="title">所有线路</td> <td class="title">所有线路</td>
<td> <td>
<select class="ui dropdown auto-width" v-model="routeCode"> <span v-if="keyword.length > 0 && searchingRoutes.length == 0">没有和关键词“{{keyword}}”匹配的线路</span>
<option value="" v-if="keyword.length == 0">[请选择]</option> <span v-show="keyword.length == 0 || searchingRoutes.length > 0">
<option v-for="route in searchingRoutes" :value="route.code + '@' + route.domainId">{{route.name}}{{route.code}}/{{route.domainName}}</option> <select class="ui dropdown" v-model="routeCode">
</select> <option value="" v-if="keyword.length == 0">[请选择]</option>
<option v-for="route in searchingRoutes" :value="route.code + '@' + route.domainId">{{route.name}}{{route.code}}/{{route.domainName}}</option>
</select>
</span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>搜索</td> <td>搜索线路</td>
<td> <td>
<input type="text" placeholder="搜索..." size="10" style="width: 10em" v-model="keyword" ref="keywordRef" @keyup.enter="confirm" @keypress.enter.prevent="1"/> <div class="ui input" :class="{'right labeled':keyword.length > 0}">
<input type="text" placeholder="线路名称或代号..." size="10" style="width: 10em" v-model="keyword" ref="keywordRef" @keyup.enter="confirm" @keypress.enter.prevent="1"/>
<a class="ui label" v-if="keyword.length > 0" @click.prevent="clearKeyword" href=""><i class="icon remove small blue"></i></a>
</div>
</td> </td>
</tr> </tr>
</table> </table>