vue的模糊查询和下拉菜单修改信息------------学习记录

HTML代码<div id="box">        <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">            <div class="modal-header">                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>                <h3 id="myModalLabel">选择信息</h3>            </div>                <div class="modal-body">                    <select v-model="clselected"                            onselect="clselected" id="cn">   //:value可以设置上value 一定要写: onselect可以将选择的value获取 绑定一个v-model通过watch监视值得改变                        <option value="">请选择科室</option>                        <option v-for="clinic in clinics" :value="clinic.clId">                            {{clinic.clName}}                        </option>                    </select>                        <select v-if="doname" v-model="doselected" onselect="doselected" id="dn">                            <option value="">请选医生</option>                            <option v-for="doctor in doctors" :value="doctor.doId">                                {{doctor.doName}}                            </option>                        </select>    <div class="modal-footer">        <button class="btn" type="button" data-dismiss="modal" aria-hidden="true">关闭</button>        <button class="btn btn-primary" type="button" @click="saved" >确定</button>    </div>                </div>        </div>    <input type="text" v-model="input_value"/> //模糊查询 绑定属性通过watch来监视input里得值变化    <table class="table table-striped">        <thead>        <th>            <tr>                <td>ID</td>                <td>姓名</td>                <td>年龄</td>                <td>性别</td>                <td>医生姓名</td>                <td>科室</td>                <td>时间</td>                <td>操作</td>            </tr>        </th>        </thead>        <tbody>        <tr v-show="you" v-for="guahao in entities">            <td>{{guahao.id}}</td>            <td>{{guahao.guaName}}</td>            <td>{{guahao.guaAge}}</td>            <td>{{guahao.guaSex}}</td>            <td>{{guahao.doctorEntity.doName}}</td>            <td>{{guahao.clinicEntity.clName}}</td>            <td>{{guahao.guaTime}}</td>            <td>                <button class="btn btn-primary btn-sm" @click="modify(guahao)"  //返回当前的guahao数据                        data-toggle="modal" data-target="#myModal">修改                </button>            </td>        </tr>        <td v-show="!you">无信息</td>        </tbody>    </table>

</div>JS代码:
<script>
var vm = new Vue({    el: "#box",    data: {        guahao:"",        clinics: [],        doctors: [],        clselected: "",        doselected:"",        you: false,        doname: false,        input_value: "",        entities: [{            id: "",            guaName: "",            guaAge: "",            guaSex: "",            doctorEntity: [{doName: ""}],            clinicEntity: [{clName: ""}],            guaTime: ""        }]    },    watch: {        input_value: function (data) {            if(typeof data===‘string‘)                if(data.trim().length!==0){                    this.search(data)                }        },        clselected: function (data) {            this.change(data)        }    },    methods: {        search: function (resdata) {            var that = this;  //作用域不同要写that            var guaName = resdata;            $.ajax({                url: "findbyname.action",                data: {name: guaName},                dataType: "json",                type: "post",                success: function (res) {                    console.log(res.guahaodanEntities);                    if (res.guahaodanEntities.length == 0) {                        that.$data.you = false;                    } else {                        that.$data.you = true;                        that.$data.entities = res.guahaodanEntities;                    }                },                error: function () {                    alert("zzzz")                }            })        },        modify: function (guahao) {            console.log(guahao);            var that = this;            this.guahao = guahao;            $.ajax({                url: "findclinic.action",                data: {},                dataType: ‘json‘,                error: function (e) {                    alert("1111")                    console.log(e)                },                success: function (data) {                    console.log(data);                    data = data.clinicEntities;                    that.$data.clinics = data;

                },                type: ‘POST‘            });        },        change: function (selected) {            console.log(selected);            this.$data.doname = true;            var that = this;            $.ajax({                url: "modfd.action",                data: {"findclinicID": selected},                dataType: ‘json‘,                error: function (e) {                    alert("1111")                    console.log(e)                },                success: function (data) {                    console.log(data);                    data = data.doctorEntities;                    that.$data.doctors = data;                },                type: ‘POST‘            });        },        saved:function () {            var that = this;            console.log(this.clselected);            console.log(this.doselected);            $.ajax({                url: "modghd2.action",                data: {                    "guahaodanEntity.id":that.$data.guahao.id,                    "clinicEntity.clId":that.$data.clselected,                    "doctorEntity.doId":that.$data.doselected                },                dataType: ‘json‘,                error: function (e) {                    alert("1111");                    console.log(e)                },                success: function (data) {                    console.log(data)                    that.guahao.doctorEntity.doName=data.doctorEntity.doName;                    that.guahao.clinicEntity.clName=data.clinicEntity.clName;

                },                type: ‘POST‘            });        }    }})
</script>

原文地址:https://www.cnblogs.com/King-Jin/p/10987487.html

时间: 2024-11-07 04:53:15

vue的模糊查询和下拉菜单修改信息------------学习记录的相关文章

jQuery 异步模糊查询 实现下拉搜索功能

<style>            .bdsug {                background: none repeat scroll 0 0 #fff;                border: 1px solid #ccc;                box-shadow: 1px 1px 3px #ededed;                display: none;                position: absolute;              

模糊查询的下拉框

css部分: <style type="text/css"> #demo-wrap{position:relative;margin:20px;width:260px;overflow:hidden;border:1px solid #DDD;} #demo-wrap .product-head p{font-size:14px;font-family:Arial,Helvetica,sans-serif;margin:5px 3px 5px;padding:0 0 5px

有模糊查询的下拉框

1.引用(引入是有顺序的) <link href="jquery.searchableSelect.css" rel="stylesheet" type="text/css"> <script src="jquery-1.11.1.min.js"></script> <script src="jquery.searchableSelect.js"></s

vue的jsonp百度下拉菜单

通过vue的jsonp实现百度下拉菜单的请求,vue的版本是2.9.2 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 <script src="vue.min.js"></script> 7 <scri

Bootstrap入门(十)组件4:按钮组与下拉菜单结合

先引入本地的CSS文件和JS文件(注:1.bootstrap是需要jQuery支持的.2.需要在<body>当中添加) <link href="css/bootstrap.min.css" rel="stylesheet"> <script src="jquery-3.1.0.min.js" type="text/javascript"></script> <script

使用NGUI制作关联下拉菜单(查询全国天气)

关联菜单,在我们浏览网页时经常见到,它极大的方便了我们的操作,在游戏中,偶尔也会用到关联下拉菜单.下面,我们使用关联下拉菜单来查询下全国的天气. 首先,老规矩我们搭建基本的UI界面.我们就不自己去制作UI组件了,直接使用NGUI封装好的UI组件. 我们先创建于一个Sprite,重命名为BgSprite,为其选择图集和精灵. 在菜单中选择NGUI,选择Open,打开Prefab Toolbar,拖一个PopupList,重命名为ProvincePopupList.这里,我们要注意, 我们导入支持中

对于数据量庞大的下拉菜单建立对应的联想查询

*效果展示:[如图左边为项目信息的下拉菜单,在其右边有一个输入框.实现效果在右边输入框的位置,输入"A",在昨天的下拉框信息中值显示"A"对应的信息] *功能实现: [jsp页面功能实现:] 获取你要的所有项目信息 <% List project_list = (List)request.getAttribute("project_list"); %> js组装成信息数组 <SCRIPT LANGUAGE="JavaS

使用vue来开发一个下拉菜单组件(1)

一.新建demo工程 vue init webpack-simple demo 添加src/mixins/emitter.js文件(见前几篇博文) 安装font-awesome字体库: cnpm install font-awesome --save 配置webpack.config.js,引入字体文件: { test: /\.(otf|eot|ttf|woff|woff2)$/, loader: 'file-loader' } 在src/main.js中引入font-awesome: impo

html 下拉菜单套件 autocomplete 可模糊搜寻套 API数据

一个html 下拉套件菜单 ,可套API拉JSON数据....迷糊搜寻菜单数据 之类的.... http://www.runoob.com/jqueryui/example-autocomplete.html 原文:大专栏  html 下拉菜单套件 autocomplete 可模糊搜寻套 API数据 原文地址:https://www.cnblogs.com/chinatrump/p/11496835.html