接口的使用

解口文档

参数名参数说明备注
:id分类 ID不能为空携带在url中
attr_name参数名称不能为空
attr_sel[only,many]不能为空
attr_vals如果是 many 就需要填写值的选项,以逗号分隔【可选参数】
### 添加动态参数或者静态属性

- 请求路径:categories/:id/attributes
- 请求方法:post
- 请求参数



响应数据
{
    "data": {
        "attr_id": 44,
        "attr_name": "测试参数",
        "cat_id": "1",
        "attr_sel": "many",
        "attr_write": "list",
        "attr_vals": "a,b,c"
    },
    "meta": {
        "msg": "创建成功",
        "status": 201
    }
}

分装解口

//4.0.0   分类参数页面
// 获取级联数据
export function getParamsJiL(params){
    return request({
        url: "categories",
        method: "GET",
        params
    })
}

// 4.0.1 -分类参数管理   参数列表    huoqv 
export function getOnlyMoneyAPI(id,params){
    return request({
        url: `categories/${id}/attributes`,
        method: "get",  
        params
    })
}

// 4.0.2 -分类参数管理   参数列表    添加动静态属性
export function addParamsAPI(id,data) {
    return request({
        url: `categories/${id}/attributes`,
        method: "post",
        data 
    })
}
// 4.0.3   删除
export function delParamsAPI(id,attrid) {
    return request({
        url: `categories/${id}/attributes/${attrid}`,
        method: "delete", 
    })
}

// 4.0.4  编辑
export function editParamsAPI(id, attrid,data) {
    return request({
        url: `categories/${id}/attributes/${attrid}`,
        method: "put",
        data
    })
}

vue页面

  // ----------静态点击事件----------------
    //4.0.4  静态编辑
    handleEditOnly(row) {
      // console.log("我要编辑:",row);
      this.isEditOnlyTCK = true;
      this.editRowArr = row;
      // console.log("我要看edit数组:",this.edit);
      this.edit.name = row.attr_name;
    },
    // 静态编辑的弹出框的确定按钮
    async handleEditOnlyBtn() {
      // console.log("编辑按钮弹出框的信息呀:",this.edit.name);
      // console.log(this.editRowArr);
      // console.log(this.edit.attr_id);
      const res = await editParamsAPI(
        this.editRowArr.cat_id,
        this.editRowArr.attr_id,
        {
          attr_name: this.edit.name,
          attr_sel: this.editRowArr.attr_sel,
        }
      );
      // console.log("编辑按钮打印的res:",res);
      this.getHaha();
      this.isEditOnlyTCK = false;
    },

    // 4.0.3  静态删除删除按钮  删除this.getHaha列表
    async handleDeleteOnly(row) {
      // console.log("删除按钮呀handleDeleteOnly:", row);
      // console.log(row.cat_id);
      // console.log(row.attr_id);
      const res = await delParamsAPI(row.cat_id, row.attr_id);
      // console.log("我要删除:", res);
      this.getHaha();
    },

    //4.0.2  静态添加 添加动态参数或者静态属性添加按钮弹出框
    isOnlyAdd() {
      this.isOnlyTCK = true;
      // console.log(this.getLastID);
    },
    async isOnlyTCKBtn() {
      // console.log(this.form.name);
      const res = await addParamsAPI(this.getLastID, {
        attr_name: this.form.name,
        attr_sel: this.fenlei,
      });
      // console.log("那你:", res);
      this.getHaha();
      this.isOnlyTCK = false;
      this.edit.name = "";
    },
    4.01  获取列表信息
    async getJiLianArr() {
      //   获取级联列表内容
      const res = await getParamsJiL();
      console.log("这个是级联的鸭:", res);
      this.jiLianArr = res;
      console.log("是级联、Arr", this.jiLianArr);
    },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值