项目的第二个界面的技术点

这个点都是比较常规的操作,增删改查,以及批量删除,

删除:把选中用户的id传过去就行了,因为后端要的数据不是json格式的,所以我let了一个变量存起来,然后用qs去转换的

//删除单个
async delBtn(id){
    let data= {id:id}
    const confirmResult = await this.$confirm('请确认是否删除用户',{
        confirmButtonText:'确定',
        cancelButtonText:'取消',
        type:'waring'
    }).catch(err=>err)
    if (confirmResult ==='confirm'){
        this.$axios.post(this.$api.wage.deleteList,this.$qs.stringify(data)).then((response)=>{
            let result =  response.data
            if (result.code==200){
            }else {
                this.$message.error('数据库出错')
            }
        }).catch(()=>{
        })
    }else{
        this.message.info('删除失败')
    }

批量删除,就是把多个id用逗号隔开,然后传过去就好了

  // 操作复选框
        handleselectionChange(val) {
            this.batchDeleteArr = val
        },
        //批量删除
        deleteAll() {
            let ids = this.batchDeleteArr.map(item => item.id).join()  //把选中的id传到
            let Ids={ids:ids}
          this.$axios.post("/formulateWage/deleteAll",this.$qs.stringify(Ids)).then(()=>{
              let result =  response.data
              if (result.code==200){

              }else {
                  this.$message.error('数据库出错')
              }
          }).catch(()=>{

          })
            this.wageshow()

},

新增就直接把新增模态框的那个表单传给后端就可以了,

addBtnsure(){
    this.$axios.post("/formulateWage/insert", this.addForm).then((response) => {
        let result = response.data;
        if (result.code == 200) {
            this.wageshow();
            this.$message({
                message: '新增成功',
                type: 'success'
            });
            this.$nextTick(()=>{
                this.$ref.addForm.resetFields();
            })

        } else {
            this.$message.error('新增失败');
        }
    })
    this.dialogFormVisible=false
},

修改重要的就是获取到表格里面原有用户的信息,然后还是一个表单传到后端就行了

//修改
xiugai(obj){
    this.modification=true
    this.editForm.id = obj.id
    this.editForm.years=obj.years
    this.editForm.formulateTime=obj.formulateTime
    this.editForm.formulatePorson = obj.formulatePorson
    this.editForm.formulateWageApprover = obj.formulateWageApprover
},
xiugaisure(){

    this.$axios.post("/formulateWage/updateById", this.editForm, {
        headers: {
            'Content-Type': 'application/json'
        }
    }).then((res) => {
        let result = res.data;
        if (result.code == 200) {
            this.wageshow();
            this.$message({
                message: '修改成功',
                type: 'success'
            });
        } else {
            this.$message.error('修改失败');
        }
    })
    this.modification= false
},
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值