首页 > 其他分享 >Element-常用组件-表格-表单-对话框-分页工具条

Element-常用组件-表格-表单-对话框-分页工具条

时间:2023-07-04 19:23:23浏览次数:41  
标签:console val 对话框 工具条 Element 华为 brandName ordered row

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <!--格式-->
    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }
    </style>
</head>
<body>

<div id="app">
    <!--搜索表格-->
    <el-form :inline="true" :model="brand" class="demo-form-inline">

        <el-form-item label="当前状态">
            <el-select v-model="brand.status" placeholder="当前状态">
                <el-option label="启用" value="1"></el-option>
                <el-option label="禁用" value="0"></el-option>
            </el-select>
        </el-form-item>

        <el-form-item label="企业名称">
            <el-input v-model="brand.companyName" placeholder="企业名称"></el-input>
        </el-form-item>

        <el-form-item label="品牌名称">
            <el-input v-model="brand.brandName" placeholder="品牌名称"></el-input>
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
    </el-form>

    <!--按钮-->
    <div style="margin: 20px 0">
        <el-button type="danger" plain>批量删除</el-button>
        <el-button type="primary" @click="dialogVisible = true" plain>新增</el-button>
    </div>

    <!--添加数据弹出的对话框表单-->
    <el-dialog
            title="编辑表单"
            :visible.sync="dialogVisible"
            width="30%"
            >

        <!-- 表单内容-->
        <el-form ref="form" :model="brand" label-width="80px">
            <el-form-item label="品牌名称">
                <el-input v-model="brand.brandName"></el-input>
            </el-form-item>

            <el-form-item label="企业名称">
                <el-input v-model="brand.companyName"></el-input>
            </el-form-item>

            <el-form-item label="排序">
                <el-input v-model="brand.ordered"></el-input>
            </el-form-item>

            <el-form-item label="备注">
                <el-input type="textarea" v-model="brand.description"></el-input>
            </el-form-item>

            <el-form-item label="状态">
                <el-switch v-model="brand.status"
                    active-value="1"
                    inactive-value="0"
                ></el-switch>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="addBrand">提交</el-button>
                <el-button @click="dialogVisible = false">取消</el-button>
            </el-form-item>
        </el-form>

    </el-dialog>

    <!--表格-->
    <template>
        <el-table
                :data="tableData2"
                style="width: 100%"
                :row-class-name="tableRowClassName">
            @selection-change="handleSelectionChange">
            <el-table-column
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column
                    type="index"
                    width="50">
            </el-table-column>
            <!--align="center"居中对齐-->
            <el-table-column
                    prop="brandName"
                    label="品牌名称"
                    align="center"
                    >
            </el-table-column>
            <el-table-column
                    prop="companyName"
                    label="企业名称"
                    align="center"
                    >
            </el-table-column>
            <el-table-column
                    prop="ordered"
                    label="排序"
                    align="center"
            >
            </el-table-column>
            <el-table-column
                    prop="status"
                    label="当前状态"
                    align="center"
            >
            </el-table-column>
            <el-table-column

                    label="操作"
                    align="center"
            >
                <el-button type="primary">修改</el-button>
                <el-button type="danger">删除</el-button>

            </el-table-column>
        </el-table>
    </template>

    <!--分页工具条-->
    <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="5"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400">
    </el-pagination>

</div>

<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">

<script>


    new Vue({
        el:"#app",
        methods: {
            tableRowClassName({row, rowIndex}) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            }
        },

        // 复选框选中后执行的方法
        handleSelectionChange(val) {
            this.multipleSelection = val;
            console.log(this.multipleSelection)
        },

        // 查询方法
        onSubmit() {
            console.log(this.brand);
        },

        // 添加数据
        addBrand(){
            console.log(this.brand);
        },

        // 分页
        methods: {
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            }
        },

        data() {
            return {
                // 当前页码
                currentPage: 4,

                // 添加数据对话框是否展示的标记,初始为false
                dialogVisible: false,

                // 品牌模型数据
                brand: {
                    status: '',
                    brandName: '',
                    companyName: '',
                    id:"",
                    ordered:"",
                    description:""
                },

                // 复选框选中的数据集合
                multipleSelection: [],//模型数组

                // 表格数据
                tableData2: [{
                    brandName: '华为',
                    companyName: '华为科技有限公司',
                    ordered: '100',
                    status:"1"
                }, {
                    brandName: '华为',
                    companyName: '华为科技有限公司',
                    ordered: '100',
                    status:"1"
                }, {
                    brandName: '华为',
                    companyName: '华为科技有限公司',
                    ordered: '100',
                    status:"1"
                }, {
                    brandName: '华为',
                    companyName: '华为科技有限公司',
                    ordered: '100',
                    status:"1"
                }]
            }
        }
    })
</script>
</body>
</html>

 

标签:console,val,对话框,工具条,Element,华为,brandName,ordered,row
From: https://www.cnblogs.com/Karl-hut/p/17526778.html

相关文章

  • Element select表单必填验证
    特别注意:如第一段代码这里的区别是prop和v-model绑定的值不一样,这样的话是不行的,他们两个的值必须一样!!!!!而且还有一种情况,就是roleStatus必须要放在form里面,而且还必须是一个数组!!!!错误写法prop和v-model不一致<el-formlabel-width="300px":rules="rules":model="changeSourceDa......
  • element-ui表格多选
    <template><el-tablesize="medium"v-loading="tableLoading":data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"stripeheight="100%&q......
  • Element-布局
     Layout布局<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><style>.el-row{margin-bottom:20px;}.el-col......
  • Element-快速入门
     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title></head><body><divid="app"><div><el-button>默认按钮......
  • element-ui弹出框模板
    <el-dialogwidth="650px"append-to-body:show-close="false":modal="false":visible.sync="dialogRegisterVisible"><el-formv-show="!isLogin"ref......
  • element-ui表格模板
    <template><divclass="container"><divclass="breadcrumb"><el-breadcrumbseparator-class="el-icon-arrow-right"><el-breadcrumb-item>个人中心</el-breadcrumb-item>&......
  • vue+element-ui 实现可编辑表格、动态渲染表头和表格数据、列向数据合计(每行末尾合计
    HTML部分代码<template> <div>  <el-container>   <el-header>Header</el-header>   <el-main>    <div>     //表格数据在这里::data="tableData"     <el-table      border    ......
  • elementui 手动上传文件 post 请求
    //上传图片校验  fileChange(file){   constisJPG=file.raw.type==='image/jpeg'   constisPNG=file.raw.type==='image/png'   constisLt2M=file.raw.size/1024/1024<0.2   if(!isPNG&&!isJPG){   ......
  • vue+elementui实现树形结构表格且合并同一个children的单元格
    1、实现效果2、结构代码(给table添加classname)3、通过设置css实现合并同一个children的单元格.nonRelationalDatabase{//去除横向边框::v-deep.el-table__row{  td{   border-bottom:none!important;  } }//......
  • vue element admin 环境搭建
    安装node.js及npm参考官网node-vnpm-v项目下载#克隆项目gitclonehttps://github.com/PanJiaChen/vue-element-admin.git#安装依赖npminstall#设置淘宝仓库npminstall--registry=https://registry.npm.taobao.org#启动服务npmrundev......