单的两表联查电影管理系统,下拉框回显

在这里插入图片描述

下拉框回显代码

<el-form-item label="电影类型" prop="typeid">
      <el-select v-model="userForm.typeid" placeholder="请选择角色姓名">
           <el-option v-for="item in xialaData" :key="item.id" :label="item.typename" :value="item.id">
               {{item.typename}}
           </el-option>
       </el-select>
</el-form-item>

下拉框的ajax请求的属性(数组)和方法

在这里插入图片描述

   //下拉数据
                xialaData: [],
     //下拉列表
            xiala() {
                var that = this;
                this.$http.get("/zz/type/list").then(function (resp) {
                    that.xialaData = resp.data.result;
                    console.log(resp)

                })
            },

页面代码

<template>
    <div>
        <!--        卡片-->
        <el-card class="box-card">
            <template>
                <h1> 电影管理系统 </h1>
                <el-table
                        :data="tableData"
                        border
                        style="width: 100%">
                    <el-table-column
                            prop="movieid"
                            label="编号"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="moviename"
                            label="电影名称"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="updates"
                            label="上映时间">
                    </el-table-column>
                    <el-table-column
                            prop="typename"
                            label="电影类别">

<!--                        <template slot-scope="scope">-->
<!--                            <span v-if="scope.row.typeid==1">喜剧</span>-->
<!--                            <span v-if="scope.row.typeid==2">爱情</span>-->
<!--                            <span v-if="scope.row.typeid==3">都市</span>-->
<!--                        </template>-->
                    </el-table-column>
                    <el-table-column
                            prop="movielang"
                            label="片长">
                    </el-table-column>
                    <el-table-column
                            prop="moviescore"
                            label="评分">
                    </el-table-column>
                    <el-table-column
                            prop="moviedesc"
                            label="简介">
                    </el-table-column>
                    <el-table-column  label="操作">
                        <template slot-scope="scope">
                            <el-button type="primary" @click="update(scope.row)">编辑</el-button>
                            <!--                            <el-button type="primary" @click="del(scope.row.userid)">删除</el-button>-->
                        </template>
                    </el-table-column>

                </el-table>

            </template>

        </el-card>
<!--修改弹出对话框-->
        <el-dialog
                :title="title"
                :visible.sync="dialogVisible"
                width="30%"
        >
            <el-form :inline="true" :model="userForm" ref="userFormref">
                <el-form-item label="电影名称" prop="moviename">
                    <el-input v-model="userForm.moviename"></el-input>
                </el-form-item>
                <el-form-item label="片长" prop="movielang" >
                    <el-input v-model="userForm.movielang"></el-input>
                </el-form-item>
                <el-form-item label="评分" prop="moviescore">
                    <el-input v-model="userForm.moviescore"></el-input>
                </el-form-item>

                <el-form-item label="上映时间" prop="updates">
                    <el-date-picker
                            v-model="userForm.updates"
                            align="right"
                            type="date"
                            placeholder="选择日期"
                            value-format="yyyy-MM-dd"
                            :picker-options="pickerOptions">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="电影类型" prop="typeid">
                    <el-select v-model="userForm.typeid" placeholder="请选择角色姓名">
                        <el-option v-for="item in xialaData" :key="item.id" :label="item.typename" :value="item.id">
                            {{item.typename}}
                        </el-option>
                    </el-select>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="insertOrUpdate()">提交
                </el-button>
            </div>

        </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "User",
        data() {
            return {
                //模糊查询数据
                // formDate: {},
                page: 1,
                //数据后台传来的
                tableData: [],

                //默认弹框关闭
                dialogVisible: false,
                title: "",
                //新增修改的数据
                userForm: {},
                //下拉数据
                xialaData: [],
                pickerOptions: {
                    disabledDate(time) {
                        return time.getTime() > Date.now();
                    },
                }
            }
        },
        //页面初始化加载用户信息
        created() {
            this.selectAll();
            this.xiala();
        },
        methods: {


            //查询的user结果
            selectAll() {
                var that = this;
                this.$http.post("/zz/movie/list/").then(function (resp) {
                    //将返回的数据赋值给tableData
                    that.tableData = resp.data.result;
                    // that.total = resp.data.result.total;
                    console.log(resp)
                })
            },

            //修改的方法
            update(row) {
                //把当前行数据赋值给表单数据  表示深拷贝,如果直接赋值的话,就变成了浅拷贝,
                // 复制的是地址,导致在表单中改变值的时候table中的数据也跟着改变,
                // 所以要进行深拷贝,利用json就可以了
                this.userForm = JSON.parse(JSON.stringify(row));
                this.title = "电影管理系统"
                this.dialogVisible = true;
            },
            //确认按钮
            insertOrUpdate() {
                var that = this;
                this.$http.post("/zz/movie/insertOrUpdate", this.userForm).then(function (resp) {

                    if (resp.data.code === 2000) {
                        that.dialogVisible = false;
                        that.selectAll();
                        that.$message.success(resp.data.msg);
                    } else {
                        that.$message.error(resp.data.msg);
                    }

                })
            },


            //下拉列表
            xiala() {
                var that = this;
                this.$http.get("/zz/type/list").then(function (resp) {
                    that.xialaData = resp.data.result;
                    console.log(resp)

                })
            },


        }
    }

</script>

<style scoped>

</style>

后台的两表联查的sql

    <select id="select" resultType="com.zz.zz.entity.Movie">
        SELECT m.*,t.Typename from tb_movie m join tb_type t
        on m.Typeid=t.id
    </select>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值