Commit f643176b by 胡悦

添加草稿验证

1 parent b83b455b
......@@ -32,10 +32,13 @@
<SelectProduct ref="productFrom" :roleType="true" title=""></SelectProduct>
</div>
<div style="height: 84px"></div>
<div class="fixed_bottom" :style="{
<div
class="fixed_bottom"
:style="{
left: footerLeft + 'px',
width: footerWidth + 'px',
}">
width: footerWidth + 'px'
}"
>
<el-button v-if="pageType == 'create'" type="primary" @click="toCreateRole(1)">草稿</el-button>
<div class="wrap_driver">
<el-button type="primary" @click="toCreateRole(0)">确定</el-button>
......@@ -94,9 +97,9 @@ export default {
const { session } = this.$globalState
this.accountLevel = session.accountLevel
},
mounted(){
this.footerLeft = document.querySelector(".base-container-right").offsetLeft;
this.footerWidth = document.documentElement.clientWidth - this.footerLeft;
mounted() {
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
},
methods: {
// 获取角色信息
......@@ -110,12 +113,13 @@ export default {
merchantId: res.merchantId
}
this.getMerchantTree(id, res.responseList)
this.$refs.productFrom.accountTypeSearchRequest({id:res.merchantId }, 'edit')
this.$refs.productFrom.accountTypeSearchRequest({ id: res.merchantId }, 'edit')
})
},
// 获取商户树
getMerchantTree(id, list) {
this.$apis.role.roleTreeDataById({ id }).then(res => {
console.log(res)
for (let i = 0; i < list.length; i++) {
for (let j = 0; j < res.length; j++) {
if (res[j].accounttypeId == list[i].accounttypeId) {
......@@ -145,11 +149,11 @@ export default {
},
// 选择商户----获取权限
async selectMerchant(id) {
let res = await this.$refs.productFrom.accountTypeSearchRequest({ id }, 'create')
let res = await this.$refs.productFrom.accountTypeSearchRequest({ id }, 'create')
this.accountList = res.map(item => {
item.select = true
return item
})
item.select = true
return item
})
},
// 选择商户权限
selectCurAccount(item, index) {
......@@ -168,31 +172,48 @@ export default {
// 确定按钮---处理参数---提交数据---创建为0---草稿为1
toCreateRole(delFlag) {
let { merchantId, roleDesc, roleName } = this.ruleForm
if (!merchantId) {
this.$message.error('请选择所属商户')
return
}
if (!roleName) {
this.$message.error('请输入角色名称')
return
}
if (this.$refs.productFrom.getSelectInfo().length == 0) {
this.$message.error('请选择产品')
return
}
let accountTypes = JSON.stringify(this.$refs.productFrom.getSelectInfo())
let para = {
merchantId: merchantId,
roleName: roleName,
roleDescription: roleDesc,
delFlag,
requestList: accountTypes
}
if (this.pageType == 'edit') {
para.id = this.editId
this.updateRole(para)
if (delFlag == 1) {
if (!merchantId) {
this.$refs.ruleForm.validateField('merchantId')
return
}
if (!roleName || this.$refs.productFrom.getSelectInfo().length == 0) {
this.$message.error('角色和权限至少选择一项')
return
}
let accountTypes = JSON.stringify(this.$refs.productFrom.getSelectInfo())
let para = {
merchantId: merchantId,
roleName: roleName,
roleDescription: roleDesc,
delFlag,
requestList: accountTypes
}
if (this.pageType == 'edit') {
para.id = this.editId
this.updateRole(para)
} else {
this.insertRole(para)
}
} else {
this.insertRole(para)
this.$refs.ruleForm.validate(valid => {
if (valid) {
let accountTypes = JSON.stringify(this.$refs.productFrom.getSelectInfo())
let para = {
merchantId: merchantId,
roleName: roleName,
roleDescription: roleDesc,
delFlag,
requestList: accountTypes
}
if (this.pageType == 'edit') {
para.id = this.editId
this.updateRole(para)
} else {
this.insertRole(para)
}
}
})
}
},
insertRole(para) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!