vue 弹窗

按钮

 <div class="xe-addbtn-panel">
    <el-button type="primary" @click="addCapacity">新增运力池</el-button>
 </div>
 <el-button @click.native.prevent="edit(scope.row)" type="text" size="small">编辑</el-button>

点击按钮显示窗口

addCapacity() {
   this.formVisible = true;
    this.dialogTitle = '新增运力池';
},
edit(scope) {
    let id = scope.id;
    this.dialogTitle = '编辑运力池';
    let _this = this;
    _this.$http({
        method: 'POST',
        url: getHomeProjectLink().rmcApiBaseUrl + `/page/rmc/transpool/main/xxxx/${id}`
    }).then((res) => {
        console.log(res);
        _this.formVisible = true;
        _this.capacityForm = {
            'name': res.result.name,
            'effectiveTime': res.result.effectiveTime,
            'description': res.result.description,
            'id': id
        };
    }).catch((err) => {
        console.log(err);
    });
},
submitCapacity(form) {
this.$refs[form].validate((valid) => {
    if (valid) {
        let _this = this;
        if (_this.capacityForm.id === '') {
            _this.$http({
                method: 'POST',
                url: getHomeProjectLink().rmcApiBaseUrl + '/page/rmc/transpool/add/xxx',
                data: _this.capacityForm
            }).then((res) => {
                _this.formVisible = false;
                _this.queryData();
            }).catch((err) => {
                console.log(err);
            });
        } else {
            _this.$http({
                method: 'POST',
                url: getHomeProjectLink().rmcApiBaseUrl + '/page/rmc/transpool/modify/xxxx',
                data: _this.capacityForm
            }).then((res) => {
                _this.formVisible = false;
                _this.queryData();
            }).catch((err) => {
                console.log(err);
            });
        }
    }
});

窗体 html

<el-dialog title="窗口名称" :visible.sync="formVisible" @close="resetCapacity('capacityForm')" class="capacity">
            <el-form :model="capacityForm" :label-width="xeLabelWidth" ref="capacityForm" :rules="capacityRules">
                <el-form-item label="运力池" prop="name">
                    <el-input v-model.trim="capacityForm.name" class="xe-input3-col3"></el-input>
                </el-form-item>
                <el-form-item label="锁定时间(分钟)" prop="effectiveTime">
                    <el-input v-model.trim="capacityForm.effectiveTime" class="xe-input3-col3"></el-input>
                </el-form-item>
                <el-form-item label="描述信息" prop="description">
                    <el-input type="textarea" v-model.trim="capacityForm.description" class="xe-input3-col3"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="formVisible = false">取 消</el-button>
                <el-button type="primary" @click="submitCapacity('capacityForm')">确 定</el-button>
            </div>
        </el-dialog>

备注

visible.sync 为true 就显示窗口 false关闭窗口 
@close="resetCapacity('capacityForm')"  关闭的时候要重置表单
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值