Commit f643176b by 胡悦

添加草稿验证

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