Commit a0aa16e2 by 蒋勇

d

parent 59bcc2bc
...@@ -40,8 +40,8 @@ class CompanyCtl extends CtlBase { ...@@ -40,8 +40,8 @@ class CompanyCtl extends CtlBase {
async giveupApp(p,q,req){ async giveupApp(p,q,req){
var comid=p.compid; var comid=p.compid;
var appid=p.appid; var appid=p.appid;
await this.service.giveupApp(comid,appid); var rtn=await this.service.giveupApp(comid,appid);
return system.getResult({}); return system.getResult(rtn);
} }
//设置当前用户选择的公司为当前公司 //设置当前用户选择的公司为当前公司
async settocompany(p,q,req){ async settocompany(p,q,req){
......
...@@ -35,10 +35,19 @@ class CompanyService extends ServiceBase { ...@@ -35,10 +35,19 @@ class CompanyService extends ServiceBase {
}); });
} }
async giveupApp(comid,appid){ async giveupApp(comid,appid){
var self=this;
return this.db.transaction(async function (t){ return this.db.transaction(async function (t){
//检查当前company_id下面是否有 //检查当前company_id下面是否有用户存在,如果已经存在就不要删除了
await this.db.models.companyapp.destroy({where:{company_id:comid,app_id:appid}}); var c=await self.db.models.user.count({where:{owner_id:comid}});
return {}; if(c>1){
return null;
}else{
if(c==1){
await self.db.models.user.destroy({where:{owner_id:comid},force: true});
}
await self.db.models.companyapp.destroy({where:{company_id:comid,app_id:appid}});
return {};
}
}); });
} }
async buyApp(p,cmid,user){ async buyApp(p,cmid,user){
......
...@@ -159,7 +159,15 @@ ...@@ -159,7 +159,15 @@
} }
if(key=="giveup"){ if(key=="giveup"){
var d= await this.$root.postReq("/web/common/companyCtl/giveupApp", {compid: this.selCompanyid,appid:row.id}); var d= await this.$root.postReq("/web/common/companyCtl/giveupApp", {compid: this.selCompanyid,appid:row.id});
this.$refs.cgrid.linkInInitQuery("company_id",this.selCompanyid); if(d.status==0){
this.$refs.cgrid.linkInInitQuery("company_id",this.selCompanyid);
}else{
this.$message({
type: 'warning',
message: '应用已经产生数据,不能解除应用'
});
}
} }
this.currow=row; this.currow=row;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment