Vue2.0 multi-condition Search Component Usage Details, vue2.0 component Usage Details

Source: Internet
Author: User

Vue2.0 multi-condition Search Component Usage Details, vue2.0 component Usage Details

This article shares with you how to implement the vue2.0 multi-condition Search Component for your reference. The details are as follows:

The search condition is dead data. select multiple conditions from the select drop-down list. You can click the plus sign to add search conditions and click the minus sign to reduce search conditions;

Templete

<Template> <div class = "retrievalmian"> <div class = "retrievaltitle"> <a class = "btn-default tabbtn" @ click = "seniorsearch ('')": class = "[tabbtn = ''? 'Checked': '']"> Advanced Search </a> <a class = "btn-default tabbtn" @ click = "seniorsearch ('author ')": class = "[tabbtn = 'author '? 'Checked ': '']"> search by author </a> </div> <div class = "retrievalbar"> <div class = "formbody"> <div class = "formoperate"> <span class = "tipsicon addplus" @ click = "addplus" v-show = "formtips. length <12 "> </span> <span class =" tipsicon removeminus "@ click =" removeminus "v-show =" formtips. length >=4 "> </span> </div> <div class =" formline "> <div class =" formtips "v-for =" (item, index) in formtips "> <div class =" formgroup "> <select Class = "formcontrol" v-model = "item. titletype "> <option v-for =" typeselect in titletype "v-if =" tabbtn = ''": value = "typeselect. value "> {typeselect. text }}</option> <option v-for = "typeselect in titletypeAuthor" v-if = "tabbtn = 'author '&&! (Index % 2) ": value =" typeselect. value "> {typeselect. text }}</option> <option v-for = "typeselect in titletypeAuthor2" v-if = "tabbtn = 'author' & (index % 2 )": value = "typeselect. value "> {typeselect. text }}</option> </select> </div> <div class = "formgroup"> <input type = "text" class = "forminp" v-model =" item. typeindium "> </div> <div class =" formgroup "> <select class =" formcontrol "> <option v-for =" accuracy in accuracys ": value =" accuracy. value "> {accuracy. text }}</option> </select> </div> <div class = "formgroup"> <select class = "formcontrol" v-model = "item. containlist "> <option v-for =" containlist in containlists ": value =" containlist. value "> {containlist. text }}</option> </select> </div> <div class = "formline"> <div class = "formgroup"> <div class = "catalog" @ click = "catalogshow"> document category directory </div> <div class = "cataloghint"> <ul class = "cataloglist" v-show =" iscataloglist "> <li> <div class =" checkbox "> <label> <input type =" checkbox "v-model =" cataloglist "value =" Nuclear Industry "> nuclear industry </ label> </div> </li> <div class = "checkbox"> <label> <input type = "checkbox" v-model = "cataloglist" value = "Aerospace Industry"> aerospace industry </label> </div> </li> <div class = "checkbox"> <label> <input type = "checkbox" v-model = "cataloglist" value = "Aviation Industry"> aviation industry </label> </div> </li> <div class = "checkbox"> <label> <input type = "checkbox" v-model = "cataloglist" value = "shipbuilding industry"> shipbuilding industry </label> </div> </li> <li> <div class = "checkbox"> <label> <input type = "checkbox" v-model = "cataloglist" value = "Weapon Industry"> weapon industry </label> </ div> </li> <div class = "checkbox"> <label> <input type = "checkbox" v-model = "cataloglist" value = ""> military electronics </label> </div> </li> <div class = "checkbox"> <label> <input type = "checkbox" v-model = "cataloglist" value = "defense comprehensive"> defense comprehensive </label> </div> </li> <div class = "checkbox"> <label> <input type = "checkbox" v-model = "cataloglist" value = ""> others </label> </div> </li> </ul> </div> </div> <div class = "formline"> <div class = "formgroup"> <select class = "formcontrollarg" v-model = "timestart"> <option v-for = "startlist in timestarts ": value = "startlist. value "> {startlist. text }}</option> </select> <span> -- </span> <select class = "formcontrollarg" v-model = "timeend"> <option v-for = "endlist in timeends ": value = "endlist. value "> {endlist. text }}</option> </select> </div> <div class = "formsearch"> <button type = "button" class = "retrievalsearch btn -primary "@ click =" retrievalsearch "> Search </button> </div> </template>

Script

<Script> import $ from 'jquery 'import conf from '. /.. /Conf '; export default {data () {return {formtips: [], tabbtn: '', // switch cataloglist: [] for search, // iscataloglist: false, titletype: [{text: 'title', value: 'title'}, {text: 'body', value: 'text'}, {text: 'project ', value: 'project'}, {text: 'personnel ', value: 'person'}, {text: 'authorization', value: 'organization'}, {text: 'tech', value: 'tech '}, {text: 'region', v Alue: 'locaton'}, {text: 'state', value: 'country'}], titletypeAuthor: [{text: 'author ', value: 'author'}], titletypeAuthor2: [{text: 'authorization', value: 'authoruint'}], accuracys: [{text: 'authorization', value: 'accurate'}, {text: 'fuzzy', value: 'blur'}], containlists: [{text: 'and contain', value: 'andwidth'}, {text: 'or inclusion', value: 'orwidth'}, {text: '', value: 'nowidth'},], timestart: 'nolimit', // Search Start Time timeend: '200 ', // search End Time timest Arts: [], // select the array timeends: [] for the start time, // select the array for the end time }}, watch :{}, created: function () {this. init () ;}, methods: {init: function () {this. formtips = [{titletype: 'title', typedrop: '', accuracy: 'accurate', containlist: 'andwidth',}, {titletype: 'title', typedrop: '', accuracy: 'accurate', containlist: 'andwidth',}, {titletype: 'title', typedrop:'', accuracy: 'accurate', containlist: 'andwidth' ,}, {titletype: 'ti Tle ', type6b: '', accuracy: 'accurate', containlist: 'andwidth',}]; this. timestarts = [{text: 'unlimited ', value: 'nolimit'}, {text: '000000', value: '000000'}, {text: '000000', value: '000000'}, {text: '000000', value: '000000'}, {text: '000000', value: '000000'}, {text: '000000 ', value: '000000'}, {text: '000000', value: '000000'},]; this. timeends = [{text: '000000', value: '000000'}, {text: '000000', value: '000000'}, {text: '000000', value: '000000'}, {text: '000000' 4', value: '000000'}, {text: '000000', value: '000000'}, {text: '000000', value: '000000 '}, {text: '000000', value: '000000'},]}, addplus: function () {if (this. tabbtn = '') {this. formtips. push ({titletype: 'title', typeindium: '', accuracy: 'accurate', containlist: 'andwidth',}); this. formtips. push ({titletype: 'title', typeindium: '', accuracy: 'accurate', containlist: 'andwidth',});} else {this. formtips. push ({titletype: 'author ', Typeindium: '', accuracy: 'accurate', containlist: 'andwidth',}); this. formtips. push ({titletype: 'authoruint', typeindium: '', accuracy: 'accurate', containlist: 'andwidth',}) ;}, removeminus: function () {this. formtips. splice (-2) ;}, seniorsearch: function (str) {if (this. tabbtn! = Str) {this. tabbtn = str; if (this. tabbtn = '') {this. formtips = [{titletype: 'title', typedrop: '', accuracy: 'accurate', containlist: 'andwidth',}, {titletype: 'title', typedrop: '', accuracy: 'accurate', containlist: 'andwidth',}, {titletype: 'title', typedrop:'', accuracy: 'accurate', containlist: 'andwidth' ,}, {titletype: 'title', typedrop: '', accuracy: 'accurate', containlist: 'andwidth',}];} else {this. Formtips = [{titletype: 'autor', typeindium: '', accuracy: 'accurate', containlist: 'andwidth',}, {titletype: 'authoruint', typeindium: '', accuracy: 'accurate', containlist: 'andwidth',}, {titletype: 'autor', typeindium:'', accuracy: 'accurate', containlist: 'andwidth' ,}, {titletype: 'authoruint', typeindium: '', accuracy: 'accurate', containlist: 'andwidth',}] }}, catalogshow: function () {this. iscataloglist =! This. iscataloglist; console. log (this. cataloglist) ;}, retrievalsearch: function () {let body = {formtips: this. formtips, cataloglist: this. cataloglist, timestart: this. timestart, timeend: this. timeend} // click to retrieve the data console. log (body) ;}},}</script>

Css

<Style scoped>/* temporary style */. retrievalmian {margin: 20px; width: 75% ;}/**//*. retrievaltitle {* // * background: # FCFCFC ;*//*}*/. retrievaltitle. tabbtn: first-child {margin-right:-5px ;}. retrievaltitle. tabbtn: hover {text-decoration: none ;}. retrievaltitle. tabbtn {padding: 2px 8px; background: # FBFBFB; border: 1px solid # DFDFDF; margin-bottom:-1px ;}. retrievaltitle. tabbtn. checked {color: # E50F10; padding-top: 8px; border-bottom: 1px solid # FBFBFB ;}. retrievalbar {border: 1px solid # E5E5E5; background: # FCFCFC ;}. formbody {position: relative; margin: 10px 0px ;}. formoperate {position: absolute; top: 10px; right: 20px ;}. formoperate. tipsicon {color: #59A4D2; display: inline-block; line-height: 15px; cursor: pointer; margin-left: 15px; width: 20px; height: 20px ;}. formoperate. addplus {background: url (.. /static/img/addplusicon.png) no-repeat center ;}. formoperate. removeminus {background: url (.. /static/img/removeicon.png) no-repeat center ;}. formline {padding: 5px 30px ;}. formtips {display: inline-block; margin-bottom: 10px; margin-right: 10px ;}. formgroup {display: inline-block ;}. formcontrol {border: 1px solid #999; width: 80px; height: 22px ;}. forminp {border: 1px solid #146AC4; width: 120px; height: 22px ;}. formcontrollarg {width: 120px; height: 25px ;}. formsearch {position: absolute; bottom: 10px; right: 20px ;}. retrievalsearch {padding: 5px 20px ;}. formgroup. catalog {border: 1px solid #999; width: 120px; height: 22px; cursor: pointer; background: url (.. /static/img/dropdown.png) no-repeat; background-position: 95% 45% ;}. cataloghint {position: relative ;}. cataloglist {position: absolute; top:-1px; left: 0; padding: 0; border: 1px solid #999; background: # fff; z-index: 10; width: 120px ;}. cataloglist li {padding: 2px 5px ;}. cataloglist li: hover {background: # 1e90ff ;}. checkbox {margin: 0px ;}</style>

1. To ensure that the v-model of the select label displayed by clicking the plus sign is different, bind the v-model to the item of v-;<Divclass = "formtips" v-for = "(item, index) in formtips">
<Selectclass = "formcontrol" v-model = "item. titletype">

2. When you click the minus sign so that only one column is left in the search condition, the minus sign disappears. <SpanClass ="Tipsicon removeminus"@ Click ="Removeminus"V-show ="Formtips. length> = 4" > </Span>; Similarly, a condition is added to the plus sign. Based on the length judgment, a maximum of six columns are allowed for the added search condition, and the plus sign disappears.

3. Click search to make the selected Search Condition pass

let body={ formtips:this.formtips, cataloglist:this.cataloglist, timestart:this.timestart, timeend:this.timeend}

Body Transfer
Default

Advanced Search

Search by author

Click minus sign

Filter condition columns, click to search

Console output, click to retrieve the value body

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.