diff --git a/src/views/manage_system/customer/components/company-detail.vue b/src/views/manage_system/customer/components/company-detail.vue index 544b9cfb..0e3cfbce 100644 --- a/src/views/manage_system/customer/components/company-detail.vue +++ b/src/views/manage_system/customer/components/company-detail.vue @@ -3,7 +3,7 @@ @@ -389,6 +417,15 @@ export default { selectProvinceId() { return this.nodeDetailFormData.proviceID; }, + isServiceProvider() { + return this.nodeDetailData.serviceProviderStatus === 1; + }, + canAccessTemplateConsole() { + return this.nodeDetailData.templateConsoleStatus === 1; + }, + canAccessTemplateProxy() { + return this.nodeDetailData.templateProxyStatus === 1; + } }, watch: { editing(v) { @@ -401,12 +438,12 @@ export default { } }, node(nextNode) { + this.nodeDetailFormData = {}; + this.nodeDetailData = {}; if (nextNode && nextNode.id) { this.editing = false; this.loadCompanyInfo(nextNode.id); } else { - this.nodeDetailFormData = {}; - this.nodeDetailData = {}; this.editing = true; } }, @@ -470,7 +507,6 @@ export default { */ updateCompanyInfo() { this.$refs["form"].validate(async (valid) => { - console.log("valid", valid); if (!valid) return; this.nodeDetailFormData.modifyUserID = sessionStorage.userId; const res = await services.updateCompany(this.nodeDetailFormData); @@ -488,19 +524,14 @@ export default { duration: 2500, }); this.loadCompanyInfo(); - this.nodeDetailData = this.nodeDetailFormData; - // this.initCompanyRecord = {...this.nodeDetailFormData};//保存之后信息得同步 否则取消的时候回出问题 - // this.el_formLabelcolor = "textlabelgray"; - // this.editButtonGroup = 1; + this.nodeDetailData = { ...this.nodeDetailFormData }; this.editing = false; - // this.rightTitle = this.nodeDetailFormData.companyName; }); }, /** * 新建企业,保存数据 */ createCompany() { - debugger; this.$refs["form"].validate(async (valid) => { if (!valid) return; this.nodeDetailFormData.createUserID = sessionStorage.userId; @@ -616,6 +647,48 @@ export default { }) .catch(() => {}); }, + /** + * 服务商权限/控制台访问/模块代理控制 勾选项 + */ + toggleAccess(field) { + const nextFlag = !this.nodeDetailFormData[field]; + const [positiveText, negativeText] = (() => { + if (field === "serviceProviderStatus") { + return ["允许成为服务商", "取消服务商资质"]; + } + if (field === "templateConsoleStatus") { + return ["允许访问模板控制台", "取消模板控台的访问权限"]; + } + if (field === "templateProxyStatus") { + return ["允许代理模板", "取消代理模板的权限"]; + } + return []; + })(); + this.$confirm(`确认${nextFlag ? positiveText : negativeText}?`, "", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }).then(async () => { + this.nodeDetailFormData.modifyUserID = sessionStorage.userId; + this.nodeDetailFormData[field] = nextFlag ? 1 : 0; + const res = await services.updateCompany(this.nodeDetailFormData); + // todo + const flag = res.Code === 0; + if (!flag) { + this.$notify({ + message: res.Msg, + type: ["warning"], + }); + return; + } + this.$notify({ + message: `变更成功。`, + type: ["success"], + duration: 2500, + }); + this.nodeDetailData = {...this.nodeDetailFormData}; + }); + }, }, }; @@ -627,6 +700,7 @@ export default { padding: 0 24px; } &-body { + position: relative; padding: 0 24px; } .form { @@ -645,6 +719,24 @@ export default { width: 50%; padding-right: 20px; } + .company-access { + &:before { + content: ""; + position: absolute; + left: 0; + right: 0; + height: 1px; + background-color: rgba(#000, 0.2); + } + .node-form-field { + display: inline-flex; + justify-content: space-between; + flex-direction: row; + height: 40px; + line-height: 40px; + align-items: center; + } + } } .dropdown-button { diff --git a/src/views/manage_system/customer/services.js b/src/views/manage_system/customer/services.js index 76aa3976..5501ca48 100644 --- a/src/views/manage_system/customer/services.js +++ b/src/views/manage_system/customer/services.js @@ -69,6 +69,9 @@ export async function fetchCompanyDetail(companyId) { disable: resData.company.Disable, ipfsApi: resData.company.IpfsApi, ipfsBootstrap: resData.company.IpfsBootstrap, + serviceProviderStatus: resData.company.ServiceProviderStatus, + templateConsoleStatus: resData.company.TemplateConsoleStatus, + templateProxyStatus: resData.company.TemplateProxyStatus, cnName: userData.CnName, email: userData.Email, phone: userData.Phone, @@ -79,7 +82,6 @@ export async function fetchCompanyDetail(companyId) { userCount: resData.userNum, deptCount: resData.deptNum, - }; return outputData; } @@ -111,7 +113,10 @@ export async function createCompany(data) { Remark: data.remark, Telphone: data.telphone, IpfsApi: data.ipfsApi, - IpfsBootstrap: data.ipfsBootstrap, + IpfsBootstrap: data.ipfsBootstrap, + ServiceProviderStatus: 0, + TemplateConsoleStatus: 0, + TemplateProxyStatus: 0, } const resData = await fetchApi('company/addCompany', { company: fixedData, user: userData }); @@ -148,7 +153,10 @@ export async function updateCompany(data) { Telphone: data.telphone, Id: data.companyID, IpfsApi: data.ipfsApi, - IpfsBootstrap: data.ipfsBootstrap, + IpfsBootstrap: data.ipfsBootstrap, + ServiceProviderStatus: data.serviceProviderStatus, + TemplateConsoleStatus: data.templateConsoleStatus, + TemplateProxyStatus: data.templateProxyStatus, } const resData = await fetchApi('company/updateCompanyById', { company: fixedData, user: userData });