博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vue的模糊查询和下拉菜单修改信息------------学习记录
阅读量:5349 次
发布时间:2019-06-15

本文共 5436 字,大约阅读时间需要 18 分钟。

HTML代码 
//模糊查询 绑定属性通过watch来监视input里得值变化
ID 姓名 年龄 性别 医生姓名 科室 时间 操作
{
{guahao.id}}
{
{guahao.guaName}}
{
{guahao.guaAge}}
{
{guahao.guaSex}}
{
{guahao.doctorEntity.doName}}
{
{guahao.clinicEntity.clName}}
{
{guahao.guaTime}}
无信息
JS代码:
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' }); } } })
 

转载于:https://www.cnblogs.com/King-Jin/p/10987487.html

你可能感兴趣的文章
图片的显示隐藏(两张图片,默认的时候显示第一张,点击的时候显示另一张)...
查看>>
Docker 安装MySQL5.7(三)
查看>>
python 模块 来了 (调包侠 修炼手册一)
查看>>
关于CSS的使用方式
查看>>
分析语句执行步骤并对排出耗时比较多的语句
查看>>
原生JS轮播-各种效果的极简实现
查看>>
计数器方法使用?
查看>>
带你全面了解高级 Java 面试中需要掌握的 JVM 知识点
查看>>
sonar结合jenkins
查看>>
解决VS+QT无法生成moc文件的问题
查看>>
AngularJs练习Demo14自定义服务
查看>>
关于空想X
查看>>
CF1067C Knights 构造
查看>>
[BZOJ2938] 病毒
查看>>
webstorm修改文件,webpack-dev-server不会自动编译刷新
查看>>
Scikit-learn 库的使用
查看>>
CSS: caption-side 属性
查看>>
python 用数组实现队列
查看>>
认证和授权(Authentication和Authorization)
查看>>
Mac上安装Tomcat
查看>>