vue前端调取数据接口方法:接口为地址时(二)

1.获取数据列表,在mounted()中调用此方法: this.getIndustrialUserList()

  getIndustrialUserList(callback){
          //分页
          this.queryParams.pageNum=this.pagination.current
          this.queryParams.pageSize=this.pagination.size
          request({
            url: '/system/industrialUser/list',
            method: 'get',
            params: this.queryParams
          }).then(res=>{
           /* debugger*/
            this.rTableData= res.rows;
            this.pagination.total=res.total
            console.log(res)
            if(callback)
              callback();
          });
         },

2.增、删、改、查

<el-table-column slot="action" label="操作" width="150">
     <template slot-scope="scope">
            <el-button  type="text" size="small" @click="checkInUser(scope.row)"  class="qgreen">查看</el-button>
            <el-button  type="text" size="small" @click="editInUser(scope.row)"  class="qgreen">编辑</el-button>
            <el-button type="text" size="small" @click="delInUser(scope.row.industrialUserId)"  class="orange">删除</el-button>
     </template>
 </el-table-column>
 //新增
        addIndustrialUser(){
          this.oprateType='add'
          this.editDialogVisible = true
          this.isShow = true
          this.isDisable = false
        },
        //查看
        checkInUser(data){
          this.oprateType='check'
          this.editDialogVisible = true
          this.formData = data
          this.isShow = false
          this.isDisable = true
        //编辑、修改
        editInUser(data){
          this.oprateType='edit'
          this.editDialogVisible = true
          this.isShow = true
          this.isDisable = false
          this.formData = data
        },
        //保存
        saveUpdate(data){
          this.$refs.formDataRef.validate( (valid) =>{
            if(valid){
              //新增
              if(this.oprateType =='add'){
                request({
                  url:'/system/industrialUser/saveUpdateCngGisIndustrialUser',
                  method:'post',
                  data:this.formData
                }).then(res=>{
                  this.editDialogVisible = false
                  this.getIndustrialUserList()
                  this.$message.success("新增成功!")
                })
                this.resetForm()
              }else {
                //编辑、修改
                request({
                  url:'/system/industrialUser/saveUpdateCngGisIndustrialUser',
                  method:'post',
                  data:this.formData
                }).then(res =>{
                  this.getIndustrialUserList()
                  this.editDialogVisible = false
                  this.$message.success("编辑成功!")
                  console.log(res)
                })
                this.resetForm()
              }
            }
          })

        },
        //删除
        delInUser(data){
          const self = this;
           this.$confirm('此操作将永久删除该信息, 是否删除?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            self.delClick(data);
          });
        },
        delClick(data){
          const self = this;
           request({
            url: '/system/industrialUser/removeCngGisIndustrialUser/' + data,
            method: 'post',
            data: data
          }).then(res=>{
            self.getIndustrialUserList();
             this.$message.success("删除成功!")
          }).catch((e)=>{})
        },
        //清空表单
        resetForm(){
          this.formData={
            projectId:'用户档案',
            lat:'',
            lng:'',
            elevationGround:'',
            addr:''
          }
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值