Vue 管理后台的增删改查

 

新建和编辑因为是用的同一个页面或同一个弹框,所以方法是一样的,需要传参区分;删除主要是让提示弹框显示,真正的删除再提示弹框的确定方法;查询可以不传参数。

查询search

searchData() {
            _this.currentPage = 1;
            _this.getList();
        },
getList() {
            _this.isShowLoading = true;
            let obj = {
                page: _this.currentPage,
                size: _this.pageSize,
                name: _this.dataSearch,
            };
            getList(obj)
                .then((res) => {
                    _this.isShowLoading = false;
                    let data = res.data;
                    _this.list = data.list || [];
                    _this.total = data.total;
                })
                .catch((error) => {});
        },

新建Add 修改edit

//页面
toAdd(index, item) {
            switch (index) {
                case 1:
                    _this.$router.push("/");
                    break;
                case 2:
                    _this.$router.push({
                        name: "/",
                        params: {
                            id: item,
                        },
                    });
                    break;
            }
        },




//弹框
addDialog(index, item) {
            _this.addType = index;
            _this.numberDialogVisible = true;
            _this.$nextTick(() => {
                _this.$refs.numberForm.resetFields();
                _this.numberForm = {
                    name: "",
                };
                switch (index) {
                    case 1:
                        _this.addMsg = "添加";
                        break;
                    case 2:
                        _this.addMsg = "修改";
                        _this.numberForm.name = item.name;
                        _this.numberForm.id = item.id;
                        break;
                }
                _this.numberForm = Object.assign({}, _this.numberForm);
            });
        },

删除Detele

deleteDialog(id) {
            _this.id = id;
            _this.deleteDialogVisible = true;
        },
delete() {
        _this.deleteDialogVisible = true;
        let obj = {
            id: _this.id,
        };
        delete(obj)
            .then(res => {
                _this.$message.success("删除成功!");
                _this.deleteDialogVisible = false;
                _this.getList();
            })
            .catch(error => {});
        },

 

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值