【二】鸡汤来咯开发学习笔记-37

前端 · 2024-07-29

1.在edit页面中,在不同状态下,显示各种组件是否激活使用

    以此类推<input :disabled="disabled || statusDisabled"   //以前那个disabled是判断提交后的属性之前设置的,所以这里使用或

方法if(formDate.value.status !==2) statusDisabled.value=true;

2.判断id是否存在,存在就更新内容,不存在就新增加//考虑到变量作用域问题,这里就不用解构,直接用变量
使用doc指明是哪个id的数据

if(id){
        
        res= await db.collection("soup-chicken").doc(id).update(formDate.value)
    }else{
        res = await db.collection("soup-chicken").add(formDate.value)
    }
    errCode=res.result.errCode;

3.由于发送更新请求的时候,不能发送id,我们只修改需要的内容,于是改变为下面的代码//last_modify_date:Date.now()修改最后发布的时间用Date.now()来进行获取当前时间,status修改后就改变状态为审核中

 let errCode,res;
            let {soup_type,status,content,from}=formDate.value;
            let _formDate={soup_type,status:0,content,from,last_modify_date:Date.now()}
            if(id){
                
                res= await db.collection("soup-chicken").doc(id).update(_formDate)
            }else{
                res = await db.collection("soup-chicken").add(formDate.value)
            }
            errCode=res.result.errCode;

Theme Jasmine by Kent Liao