|
@@ -36,11 +36,7 @@
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item
|
|
|
- label="关键字段权限"
|
|
|
- prop="private_field"
|
|
|
- label-width="110px"
|
|
|
- >
|
|
|
+ <el-form-item label="关键字段权限" prop="private_field" label-width="110px">
|
|
|
<el-checkbox-group
|
|
|
v-model="ruleForm.private_field"
|
|
|
:disabled="isDetail"
|
|
@@ -55,7 +51,11 @@
|
|
|
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="是否允许查看价格" label-width="130px">
|
|
|
- <el-select v-model="ruleForm.is_allow_see_price" :disabled="isDetail" placeholder="是否允许查看价格">
|
|
|
+ <el-select
|
|
|
+ v-model="ruleForm.is_allow_see_price"
|
|
|
+ :disabled="isDetail"
|
|
|
+ placeholder="是否允许查看价格"
|
|
|
+ >
|
|
|
<el-option value="1" label="允许" />
|
|
|
<el-option value="0" label="不允许" />
|
|
|
</el-select>
|
|
@@ -83,7 +83,8 @@
|
|
|
|
|
|
<div class="quanxian-main">
|
|
|
<div class="quanxian-title">
|
|
|
- <span style="color: #ff8888">*</span><span
|
|
|
+ <span style="color: #ff8888">*</span
|
|
|
+ ><span
|
|
|
style="
|
|
|
font-size: 14px;
|
|
|
color: #606266;
|
|
@@ -91,7 +92,8 @@
|
|
|
padding: 0 12px 0 0;
|
|
|
font-weight: 700;
|
|
|
"
|
|
|
- >功能权限</span>
|
|
|
+ >功能权限</span
|
|
|
+ >
|
|
|
</div>
|
|
|
<div class="rule-view">
|
|
|
<div class="rule-list">
|
|
@@ -127,9 +129,7 @@
|
|
|
<span class="_h2">{{ subItem.menu_name }}</span>
|
|
|
<el-radio-group
|
|
|
v-if="
|
|
|
- subItem &&
|
|
|
- subItem.private &&
|
|
|
- subItem.private.length === 2
|
|
|
+ subItem && subItem.private && subItem.private.length === 2
|
|
|
"
|
|
|
v-model="subItem.is_private_change"
|
|
|
style="margin: 0 0 0 20px"
|
|
@@ -141,7 +141,8 @@
|
|
|
:key="radioN.label + ri"
|
|
|
:disabled="isDetail"
|
|
|
:label="String(radioN.id)"
|
|
|
- >{{ radioN.label }}</el-radio-button>
|
|
|
+ >{{ radioN.label }}</el-radio-button
|
|
|
+ >
|
|
|
</el-radio-group>
|
|
|
</div>
|
|
|
<div
|
|
@@ -154,26 +155,17 @@
|
|
|
:disabled="isDetail"
|
|
|
:indeterminate="indeterminateCheck(subItem)"
|
|
|
@change="
|
|
|
- handleCheckAllChange(
|
|
|
- $event,
|
|
|
- index,
|
|
|
- item,
|
|
|
- subIndex
|
|
|
- )
|
|
|
+ handleCheckAllChange($event, index, item, subIndex)
|
|
|
"
|
|
|
- >功能全选</el-checkbox>
|
|
|
+ >功能全选</el-checkbox
|
|
|
+ >
|
|
|
</div>
|
|
|
<div class="checkItem">
|
|
|
<el-checkbox-group
|
|
|
v-model="subItem.checkList"
|
|
|
:disabled="isDetail"
|
|
|
@change="
|
|
|
- handleCheckedGroupChange(
|
|
|
- $event,
|
|
|
- index,
|
|
|
- item,
|
|
|
- subIndex
|
|
|
- )
|
|
|
+ handleCheckedGroupChange($event, index, item, subIndex)
|
|
|
"
|
|
|
>
|
|
|
<template v-for="children in subItem.action">
|
|
@@ -190,16 +182,14 @@
|
|
|
item
|
|
|
)
|
|
|
"
|
|
|
- >{{ children.action_name }}</el-checkbox>
|
|
|
+ >{{ children.action_name }}</el-checkbox
|
|
|
+ >
|
|
|
</template>
|
|
|
</el-checkbox-group>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div
|
|
|
- v-if="
|
|
|
- subItem.action_data &&
|
|
|
- subItem.action_data.length > 0
|
|
|
- "
|
|
|
+ v-if="subItem.action_data && subItem.action_data.length > 0"
|
|
|
class="sfield"
|
|
|
>
|
|
|
<div class="checkAll">
|
|
@@ -208,31 +198,20 @@
|
|
|
:disabled="isDetail"
|
|
|
:indeterminate="indeterminateField(subItem)"
|
|
|
@change="
|
|
|
- handleFieldAllChange(
|
|
|
- $event,
|
|
|
- index,
|
|
|
- item,
|
|
|
- subIndex
|
|
|
- )
|
|
|
+ handleFieldAllChange($event, index, item, subIndex)
|
|
|
"
|
|
|
- >字段全选</el-checkbox>
|
|
|
+ >字段全选</el-checkbox
|
|
|
+ >
|
|
|
</div>
|
|
|
<div class="checkItem">
|
|
|
<el-checkbox-group
|
|
|
v-model="subItem.fieldList"
|
|
|
:disabled="isDetail"
|
|
|
@change="
|
|
|
- handleFieldGroupChange(
|
|
|
- $event,
|
|
|
- index,
|
|
|
- item,
|
|
|
- subIndex
|
|
|
- )
|
|
|
+ handleFieldGroupChange($event, index, item, subIndex)
|
|
|
"
|
|
|
>
|
|
|
- <template
|
|
|
- v-for="children in subItem.action_data"
|
|
|
- >
|
|
|
+ <template v-for="children in subItem.action_data">
|
|
|
<el-checkbox
|
|
|
:key="'FieldItem' + children.id"
|
|
|
:label="String(children.id)"
|
|
@@ -246,7 +225,8 @@
|
|
|
item
|
|
|
)
|
|
|
"
|
|
|
- >{{ children.field_name }}</el-checkbox>
|
|
|
+ >{{ children.field_name }}</el-checkbox
|
|
|
+ >
|
|
|
</template>
|
|
|
</el-checkbox-group>
|
|
|
</div>
|
|
@@ -261,12 +241,8 @@
|
|
|
</div>
|
|
|
</el-form>
|
|
|
<el-col :span="24" style="text-align: right">
|
|
|
- <el-button
|
|
|
- v-if="!isDetail"
|
|
|
- type="primary"
|
|
|
- :size="'mini'"
|
|
|
- @click="submitForm"
|
|
|
- >保 存
|
|
|
+ <el-button v-if="!isDetail" type="primary" :size="'mini'" @click="submitForm"
|
|
|
+ >保 存
|
|
|
</el-button>
|
|
|
<el-button :size="'mini'" @click="showModelThis = false">{{
|
|
|
isDetail ? "关 闭" : "取 消"
|
|
@@ -277,48 +253,48 @@
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import asyncRequest from '@/apis/service/interest/role'
|
|
|
-import roleLevel from '@/assets/js/roleLevel'
|
|
|
-import { isChinese, isEmoticon } from '@/utils/validate'
|
|
|
-import resToken from '@/mixins/resToken'
|
|
|
-import { mapState } from 'vuex'
|
|
|
+import asyncRequest from "@/apis/service/interest/role";
|
|
|
+import roleLevel from "@/assets/js/roleLevel";
|
|
|
+import { isChinese, isEmoticon } from "@/utils/validate";
|
|
|
+import resToken from "@/mixins/resToken";
|
|
|
+import { mapState, mapGetters } from "vuex";
|
|
|
export default {
|
|
|
- name: 'Role',
|
|
|
+ name: "Role",
|
|
|
mixins: [resToken],
|
|
|
- props: ['showModel', 'id', 'isDetail'],
|
|
|
+ props: ["showModel", "id", "isDetail"],
|
|
|
data() {
|
|
|
const validatename = (rule, value, callback) => {
|
|
|
- if (value === '') {
|
|
|
- callback(new Error('角色名称不能为空!'))
|
|
|
+ if (value === "") {
|
|
|
+ callback(new Error("角色名称不能为空!"));
|
|
|
} else {
|
|
|
if (value.lenght < 2 || value.lenght > 10) {
|
|
|
- callback(new Error('角色名称规则为2~10位汉字!'))
|
|
|
+ callback(new Error("角色名称规则为2~10位汉字!"));
|
|
|
} else if (!isChinese(value)) {
|
|
|
- callback(new Error('角色名称规则为2~10位汉字!'))
|
|
|
+ callback(new Error("角色名称规则为2~10位汉字!"));
|
|
|
} else if (isEmoticon(value)) {
|
|
|
- callback(new Error('角色名称规则为2~10位汉字!'))
|
|
|
+ callback(new Error("角色名称规则为2~10位汉字!"));
|
|
|
} else {
|
|
|
- callback()
|
|
|
+ callback();
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
return {
|
|
|
loading: false,
|
|
|
- title: '添加角色',
|
|
|
+ title: "添加角色",
|
|
|
private_data: [], // 私有数据菜单ID
|
|
|
showModelThis: this.showModel,
|
|
|
roleLevel: roleLevel,
|
|
|
ruleForm: {
|
|
|
- role_name: '',
|
|
|
- level: '3',
|
|
|
+ role_name: "",
|
|
|
+ level: "3",
|
|
|
private_field: [],
|
|
|
- is_allow_see_price: ''
|
|
|
+ is_allow_see_price: "",
|
|
|
},
|
|
|
action_data: [], // 字段数据
|
|
|
action: [], // 功能数据
|
|
|
// 当前角色
|
|
|
roleActive: {
|
|
|
- rules: []
|
|
|
+ rules: [],
|
|
|
},
|
|
|
// 角色列表
|
|
|
roleList: [],
|
|
@@ -330,133 +306,141 @@ export default {
|
|
|
rules: {
|
|
|
private_field: [
|
|
|
{
|
|
|
- type: 'array',
|
|
|
+ type: "array",
|
|
|
required: true,
|
|
|
- message: '请选择关键字段权限',
|
|
|
- trigger: 'change'
|
|
|
- }
|
|
|
+ message: "请选择关键字段权限",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
],
|
|
|
role_name: [
|
|
|
{
|
|
|
required: true,
|
|
|
validator: validatename,
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
// level: [
|
|
|
// { required: true, message: '请选择角色等级', trigger: 'change' }
|
|
|
// ]
|
|
|
- }
|
|
|
- }
|
|
|
+ },
|
|
|
+ };
|
|
|
},
|
|
|
+
|
|
|
computed: {
|
|
|
+ ...mapGetters(["is_super_admin_ids"]),
|
|
|
...mapState({
|
|
|
- currentCompany: (state) => state.user.currentCompany
|
|
|
+ currentCompany: (state) => state.user.currentCompany,
|
|
|
}),
|
|
|
indeterminateCheck() {
|
|
|
return (item) => {
|
|
|
// 选中子节点的数量
|
|
|
const selectItemLength = item.action.filter(
|
|
|
(filitem) =>
|
|
|
- item.checkList.findIndex((finditem) => String(finditem) === String(filitem.id)) > -1
|
|
|
- ).length
|
|
|
+ item.checkList.findIndex(
|
|
|
+ (finditem) => String(finditem) === String(filitem.id)
|
|
|
+ ) > -1
|
|
|
+ ).length;
|
|
|
// 未选中子节点的数量
|
|
|
const noSlectItemLength = item.action.filter(
|
|
|
(filitem) =>
|
|
|
- item.checkList.findIndex((finditem) => String(finditem) === String(filitem.id)) ==
|
|
|
- -1
|
|
|
- ).length
|
|
|
+ item.checkList.findIndex(
|
|
|
+ (finditem) => String(finditem) === String(filitem.id)
|
|
|
+ ) == -1
|
|
|
+ ).length;
|
|
|
// // 当前节点的index
|
|
|
// 存在选中子节点且存在未选中子节点为中间态
|
|
|
- return selectItemLength > 0 && noSlectItemLength > 0
|
|
|
- }
|
|
|
+ return selectItemLength > 0 && noSlectItemLength > 0;
|
|
|
+ };
|
|
|
},
|
|
|
indeterminateField() {
|
|
|
return (item) => {
|
|
|
// 选中子节点的数量
|
|
|
const selectItemLength = item.action_data.filter(
|
|
|
(filitem) =>
|
|
|
- item.fieldList.findIndex((finditem) => String(finditem) === String(filitem.id)) > -1
|
|
|
- ).length
|
|
|
+ item.fieldList.findIndex(
|
|
|
+ (finditem) => String(finditem) === String(filitem.id)
|
|
|
+ ) > -1
|
|
|
+ ).length;
|
|
|
// 未选中子节点的数量
|
|
|
const noSlectItemLength = item.action_data.filter(
|
|
|
(filitem) =>
|
|
|
- item.fieldList.findIndex((finditem) => String(finditem) === String(filitem.id)) ==
|
|
|
- -1
|
|
|
- ).length
|
|
|
+ item.fieldList.findIndex(
|
|
|
+ (finditem) => String(finditem) === String(filitem.id)
|
|
|
+ ) == -1
|
|
|
+ ).length;
|
|
|
// // 当前节点的index
|
|
|
// 存在选中子节点且存在未选中子节点为中间态
|
|
|
- return selectItemLength > 0 && noSlectItemLength > 0
|
|
|
- }
|
|
|
- }
|
|
|
+ return selectItemLength > 0 && noSlectItemLength > 0;
|
|
|
+ };
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
- showModel: function(val) {
|
|
|
- this.showModelThis = val
|
|
|
+ showModel: function (val) {
|
|
|
+ this.showModelThis = val;
|
|
|
if (val) {
|
|
|
- this.initForm()
|
|
|
+ this.initForm();
|
|
|
}
|
|
|
},
|
|
|
showModelThis(val) {
|
|
|
if (!val) {
|
|
|
- this.$emit('cancel')
|
|
|
+ this.$emit("cancel");
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
// 全选/全不选
|
|
|
handleCheckAllChange(checkAll, index, item, subIndex) {
|
|
|
- this.actionList[index].child[subIndex].checkAll = checkAll
|
|
|
- this.$set(this.actionList, index, item)
|
|
|
+ this.actionList[index].child[subIndex].checkAll = checkAll;
|
|
|
+ this.$set(this.actionList, index, item);
|
|
|
this.actionList[index].child[subIndex].action.forEach((element) => {
|
|
|
- const findindex = this.actionList[index].child[
|
|
|
- subIndex
|
|
|
- ].checkList.findIndex((findItem) => String(findItem) === String(element.id))
|
|
|
+ const findindex = this.actionList[index].child[subIndex].checkList.findIndex(
|
|
|
+ (findItem) => String(findItem) === String(element.id)
|
|
|
+ );
|
|
|
if (checkAll && findindex == -1) {
|
|
|
- this.actionList[index].child[subIndex].checkList.push(String(element.id))
|
|
|
+ this.actionList[index].child[subIndex].checkList.push(String(element.id));
|
|
|
} else if (!checkAll && findindex > -1) {
|
|
|
- this.actionList[index].child[subIndex].checkList.splice(findindex, 1)
|
|
|
+ this.actionList[index].child[subIndex].checkList.splice(findindex, 1);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
// 全选/全不选
|
|
|
handleFieldAllChange(fieldAll, index, item, subIndex) {
|
|
|
- this.actionList[index].child[subIndex].fieldAll = fieldAll
|
|
|
- this.$set(this.actionList, index, item)
|
|
|
+ this.actionList[index].child[subIndex].fieldAll = fieldAll;
|
|
|
+ this.$set(this.actionList, index, item);
|
|
|
this.actionList[index].child[subIndex].action_data.forEach((element) => {
|
|
|
- const findindex = this.actionList[index].child[
|
|
|
- subIndex
|
|
|
- ].fieldList.findIndex((findItem) => String(findItem) === String(element.id))
|
|
|
+ const findindex = this.actionList[index].child[subIndex].fieldList.findIndex(
|
|
|
+ (findItem) => String(findItem) === String(element.id)
|
|
|
+ );
|
|
|
if (fieldAll && findindex == -1) {
|
|
|
- this.actionList[index].child[subIndex].fieldList.push(String(element.id))
|
|
|
+ this.actionList[index].child[subIndex].fieldList.push(String(element.id));
|
|
|
} else if (!fieldAll && findindex > -1) {
|
|
|
- this.actionList[index].child[subIndex].fieldList.splice(findindex, 1)
|
|
|
+ this.actionList[index].child[subIndex].fieldList.splice(findindex, 1);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
// 复选框组内的选中/不选中
|
|
|
handleCheckedGroupChange(event, index, item, subIndex) {
|
|
|
- this.actionList[index].child[subIndex].checkAll = this.actionList[
|
|
|
- index
|
|
|
- ].child[subIndex].action.every(
|
|
|
+ this.actionList[index].child[subIndex].checkAll = this.actionList[index].child[
|
|
|
+ subIndex
|
|
|
+ ].action.every(
|
|
|
(evitem) =>
|
|
|
this.actionList[index].child[subIndex].checkList.findIndex(
|
|
|
(finditem) => String(finditem) === String(evitem.id)
|
|
|
) > -1
|
|
|
- )
|
|
|
- this.$set(this.actionList, index, item)
|
|
|
+ );
|
|
|
+ this.$set(this.actionList, index, item);
|
|
|
},
|
|
|
// 复选框组内的选中/不选中
|
|
|
handleFieldGroupChange(event, index, item, subIndex) {
|
|
|
- this.actionList[index].child[subIndex].fieldAll = this.actionList[
|
|
|
- index
|
|
|
- ].child[subIndex].action_data.every(
|
|
|
+ this.actionList[index].child[subIndex].fieldAll = this.actionList[index].child[
|
|
|
+ subIndex
|
|
|
+ ].action_data.every(
|
|
|
(evitem) =>
|
|
|
this.actionList[index].child[subIndex].fieldList.findIndex(
|
|
|
(finditem) => String(finditem) === String(evitem.id)
|
|
|
) > -1
|
|
|
- )
|
|
|
- this.$set(this.actionList, index, item)
|
|
|
+ );
|
|
|
+ this.$set(this.actionList, index, item);
|
|
|
},
|
|
|
|
|
|
// 单项复选框选中/不选中
|
|
@@ -466,17 +450,17 @@ export default {
|
|
|
if (checked) {
|
|
|
// 选中时检查pid的选中状态
|
|
|
this.actionList[index].child[subIndex].checkList.indexOf(id) == -1 &&
|
|
|
- this.actionList[index].child[subIndex].checkList.push(id)
|
|
|
+ this.actionList[index].child[subIndex].checkList.push(id);
|
|
|
} else {
|
|
|
const find = this.actionList[index].child[subIndex].checkList.findIndex(
|
|
|
(e) => String(e) == String(id)
|
|
|
- )
|
|
|
+ );
|
|
|
if (find > -1) {
|
|
|
- this.actionList[index].child[subIndex].checkList.splice(find, 1)
|
|
|
+ this.actionList[index].child[subIndex].checkList.splice(find, 1);
|
|
|
}
|
|
|
- this.actionList[index].child[subIndex].checkAll = false
|
|
|
+ this.actionList[index].child[subIndex].checkAll = false;
|
|
|
}
|
|
|
- this.$set(this.actionList, index, item)
|
|
|
+ this.$set(this.actionList, index, item);
|
|
|
},
|
|
|
// 单项复选框选中/不选中
|
|
|
handleFieldChange(checked, id, index, subIndex, item) {
|
|
@@ -484,269 +468,282 @@ export default {
|
|
|
if (checked) {
|
|
|
// 选中时检查pid的选中状态
|
|
|
this.actionList[index].child[subIndex].fieldList.indexOf(id) == -1 &&
|
|
|
- this.actionList[index].child[subIndex].fieldList.push(id)
|
|
|
+ this.actionList[index].child[subIndex].fieldList.push(id);
|
|
|
} else {
|
|
|
const find = this.actionList[index].child[subIndex].fieldList.findIndex(
|
|
|
(e) => e == id
|
|
|
- )
|
|
|
+ );
|
|
|
if (find > -1) {
|
|
|
- this.actionList[index].child[subIndex].fieldList.splice(find, 1)
|
|
|
+ this.actionList[index].child[subIndex].fieldList.splice(find, 1);
|
|
|
}
|
|
|
- this.actionList[index].child[subIndex].fieldAll = false
|
|
|
+ this.actionList[index].child[subIndex].fieldAll = false;
|
|
|
}
|
|
|
- this.$set(this.actionList, index, item)
|
|
|
+ this.$set(this.actionList, index, item);
|
|
|
// console.log(this.actionList[index].child[subIndex]);
|
|
|
},
|
|
|
|
|
|
async initForm() {
|
|
|
- this.loading = true
|
|
|
- if (this.id === 'add') {
|
|
|
- this.title = '添加角色'
|
|
|
+ this.loading = true;
|
|
|
+ if (this.id === "add") {
|
|
|
+ this.title = "添加角色";
|
|
|
// this.ruleForm.isAdmin = 0;
|
|
|
- this.rulesThis = this.rules
|
|
|
- await this.resetForm()
|
|
|
- await this.initActionList()
|
|
|
- this.loading = false
|
|
|
+ this.rulesThis = this.rules;
|
|
|
+ await this.resetForm();
|
|
|
+ await this.initActionList();
|
|
|
+ this.loading = false;
|
|
|
} else {
|
|
|
if (this.isDetail) {
|
|
|
- this.title = '角色'
|
|
|
- this.rulesThis = {}
|
|
|
+ this.title = "角色";
|
|
|
+ this.rulesThis = {};
|
|
|
} else {
|
|
|
- this.title = '修改角色'
|
|
|
- this.rulesThis = this.rules
|
|
|
+ this.title = "修改角色";
|
|
|
+ this.rulesThis = this.rules;
|
|
|
}
|
|
|
- await this.resetForm()
|
|
|
- await this.initActionList()
|
|
|
- await this.initData()
|
|
|
- this.loading = false
|
|
|
+ await this.resetForm();
|
|
|
+ await this.initActionList();
|
|
|
+ await this.initData();
|
|
|
+ this.loading = false;
|
|
|
}
|
|
|
},
|
|
|
async initData() {
|
|
|
- const res = await asyncRequest.detail({ roleid: this.id })
|
|
|
+ const res = await asyncRequest.detail({ roleid: this.id });
|
|
|
if (res && res.code === 0 && res.data) {
|
|
|
- const resD = res.data
|
|
|
+ const resD = res.data;
|
|
|
|
|
|
- resD.private_field = !resD.private_field ? [] : resD.private_field.split(',')
|
|
|
+ resD.private_field = !resD.private_field ? [] : resD.private_field.split(",");
|
|
|
|
|
|
- this.ruleForm = resD
|
|
|
+ this.ruleForm = resD;
|
|
|
|
|
|
- this.ruleForm.level = '3'
|
|
|
+ this.ruleForm.level = "3";
|
|
|
|
|
|
if (resD.action && resD.action.length > 0) {
|
|
|
- this.action = resD.action
|
|
|
+ this.action = resD.action;
|
|
|
} else {
|
|
|
- this.action = []
|
|
|
+ this.action = [];
|
|
|
}
|
|
|
if (resD.action_data && resD.action_data.length > 0) {
|
|
|
- this.action_data = resD.action_data
|
|
|
+ this.action_data = resD.action_data;
|
|
|
} else {
|
|
|
- this.action_data = []
|
|
|
+ this.action_data = [];
|
|
|
}
|
|
|
- if (resD.private_data === '') {
|
|
|
- resD.private_data = []
|
|
|
+ if (resD.private_data === "") {
|
|
|
+ resD.private_data = [];
|
|
|
}
|
|
|
if (resD.private_data && resD.private_data.length > 0) {
|
|
|
- this.private_data = resD.private_data
|
|
|
+ this.private_data = resD.private_data;
|
|
|
} else {
|
|
|
- this.private_data = []
|
|
|
+ this.private_data = [];
|
|
|
}
|
|
|
|
|
|
- this.ruleForm.is_allow_see_price = String(resD.is_allow_see_price)
|
|
|
+ this.ruleForm.is_allow_see_price = String(resD.is_allow_see_price);
|
|
|
|
|
|
- const arr = JSON.parse(JSON.stringify(this.actionList))
|
|
|
+ const arr = JSON.parse(JSON.stringify(this.actionList));
|
|
|
arr.map((x) => {
|
|
|
if (x.child && x.child.length > 0) {
|
|
|
x.child.map((y) => {
|
|
|
if (y.action && y.action.length > 0) {
|
|
|
y.action.map((z) => {
|
|
|
- const Aindex = this.action.findIndex((a) => String(a) === String(z.id))
|
|
|
+ const Aindex = this.action.findIndex((a) => String(a) === String(z.id));
|
|
|
if (Aindex !== -1) {
|
|
|
- y.checkList.push(this.action[Aindex])
|
|
|
+ y.checkList.push(this.action[Aindex]);
|
|
|
}
|
|
|
- return z
|
|
|
- })
|
|
|
+ return z;
|
|
|
+ });
|
|
|
if (y.action.length === y.checkList.length) {
|
|
|
- y.checkAll = true
|
|
|
+ y.checkAll = true;
|
|
|
}
|
|
|
}
|
|
|
if (y.action_data && y.action_data.length > 0) {
|
|
|
y.action_data.map((z) => {
|
|
|
- const Bindex = this.action_data.findIndex((a) => String(a) === String(z.id))
|
|
|
+ const Bindex = this.action_data.findIndex(
|
|
|
+ (a) => String(a) === String(z.id)
|
|
|
+ );
|
|
|
if (Bindex !== -1) {
|
|
|
- y.fieldList.push(this.action_data[Bindex])
|
|
|
+ y.fieldList.push(this.action_data[Bindex]);
|
|
|
}
|
|
|
- return z
|
|
|
- })
|
|
|
+ return z;
|
|
|
+ });
|
|
|
if (y.action_data.length === y.fieldList.length) {
|
|
|
- y.fieldAll = true
|
|
|
+ y.fieldAll = true;
|
|
|
}
|
|
|
}
|
|
|
if (y.private && y.private.length === 2) {
|
|
|
- const Cindex = this.private_data.findIndex((a) => String(a) === String(y.id))
|
|
|
+ const Cindex = this.private_data.findIndex(
|
|
|
+ (a) => String(a) === String(y.id)
|
|
|
+ );
|
|
|
if (Cindex !== -1) {
|
|
|
- y.is_private_change = '1'
|
|
|
+ y.is_private_change = "1";
|
|
|
} else {
|
|
|
- y.is_private_change = '0'
|
|
|
+ y.is_private_change = "0";
|
|
|
}
|
|
|
} else {
|
|
|
- y.is_private_change = '0'
|
|
|
+ y.is_private_change = "0";
|
|
|
}
|
|
|
- return y
|
|
|
- })
|
|
|
+ return y;
|
|
|
+ });
|
|
|
}
|
|
|
- return x
|
|
|
- })
|
|
|
+ return x;
|
|
|
+ });
|
|
|
|
|
|
- if (!this.ruleForm.private_field) this.ruleForm.private_field = []
|
|
|
+ if (!this.ruleForm.private_field) this.ruleForm.private_field = [];
|
|
|
|
|
|
- this.actionList = arr
|
|
|
+ this.actionList = arr;
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout()
|
|
|
+ await this.logout();
|
|
|
} else {
|
|
|
- this.$message.warning(res.message)
|
|
|
+ this.$message.warning(res.message);
|
|
|
}
|
|
|
},
|
|
|
recursionFilterActionList(list) {
|
|
|
- const _list = []
|
|
|
+ const _list = [];
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
- const item = list[i]
|
|
|
+ const item = list[i];
|
|
|
|
|
|
- if (item.level !== 1) _list.push(item)
|
|
|
- if (item.child && item.child.length > 0) item.child = this.recursionFilterActionList(item.child)
|
|
|
+ if (item.level !== 1) _list.push(item);
|
|
|
+ if (item.child && item.child.length > 0)
|
|
|
+ item.child = this.recursionFilterActionList(item.child);
|
|
|
}
|
|
|
- return _list
|
|
|
+ return _list;
|
|
|
},
|
|
|
|
|
|
async initActionList() {
|
|
|
- const res = await asyncRequest.actionList({ level: '0,3' })
|
|
|
+ const res = await asyncRequest.actionList({ level: "0,3" });
|
|
|
|
|
|
if (res && res.code === 0) {
|
|
|
- const list = res.data
|
|
|
- console.log(this.recursionFilterActionList(list))
|
|
|
-
|
|
|
- let arr = list.filter((item) => item.child && item.child.length > 0)
|
|
|
+ const list = res.data;
|
|
|
+ let arr = list.filter((item) => item.child && item.child.length > 0);
|
|
|
+ if (!this.is_super_admin_ids) {
|
|
|
+ arr = arr.filter((v) => {
|
|
|
+ if (String(v.id) === "54") {
|
|
|
+ v.child.filter((v2) => {
|
|
|
+ v2.action = v2.action.filter((v3) => v3.action_code === "001");
|
|
|
+ console.log(v2.action);
|
|
|
+ return v2;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return v;
|
|
|
+ });
|
|
|
+ }
|
|
|
arr = arr.map((x) => {
|
|
|
x.child.map((y) => {
|
|
|
- y.checkAll = false
|
|
|
- y.checkList = []
|
|
|
- y.fieldAll = false
|
|
|
- y.fieldList = []
|
|
|
- y.is_private_change = '0'
|
|
|
- if (y.is_private === '0') {
|
|
|
- y.private = []
|
|
|
+ y.checkAll = false;
|
|
|
+ y.checkList = [];
|
|
|
+ y.fieldAll = false;
|
|
|
+ y.fieldList = [];
|
|
|
+ y.is_private_change = "0";
|
|
|
+ if (y.is_private === "0") {
|
|
|
+ y.private = [];
|
|
|
} else {
|
|
|
y.private = [
|
|
|
{
|
|
|
- id: '0',
|
|
|
- label: '公有数据'
|
|
|
+ id: "0",
|
|
|
+ label: "公有数据",
|
|
|
},
|
|
|
{
|
|
|
- id: '1',
|
|
|
- label: '私有数据'
|
|
|
- }
|
|
|
- ]
|
|
|
+ id: "1",
|
|
|
+ label: "私有数据",
|
|
|
+ },
|
|
|
+ ];
|
|
|
}
|
|
|
- return y
|
|
|
- })
|
|
|
- return x
|
|
|
- })
|
|
|
+ return y;
|
|
|
+ });
|
|
|
+ return x;
|
|
|
+ });
|
|
|
|
|
|
- this.actionList = arr
|
|
|
+ this.actionList = arr;
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout()
|
|
|
+ await this.logout();
|
|
|
} else {
|
|
|
- this.$message.warning(res.message)
|
|
|
+ this.$message.warning(res.message);
|
|
|
}
|
|
|
},
|
|
|
async resetForm() {
|
|
|
// 重置
|
|
|
await this.$nextTick(() => {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
- this.$refs.ruleForm.resetFields()
|
|
|
- this.$refs.ruleForm.clearValidate()
|
|
|
+ this.$refs.ruleForm.resetFields();
|
|
|
+ this.$refs.ruleForm.clearValidate();
|
|
|
|
|
|
this.ruleForm = {
|
|
|
- role_name: '',
|
|
|
+ role_name: "",
|
|
|
private_field: [],
|
|
|
- is_allow_see_price: '',
|
|
|
- level: '3'
|
|
|
- }
|
|
|
+ is_allow_see_price: "",
|
|
|
+ level: "3",
|
|
|
+ };
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
async submitForm() {
|
|
|
- await this.$refs.ruleForm.validate(async(valid) => {
|
|
|
+ await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
if (this.loading) {
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
- this.action_data = [] // 字段数据
|
|
|
- this.action = [] // 功能数据
|
|
|
- const arr = []
|
|
|
+ this.action_data = []; // 字段数据
|
|
|
+ this.action = []; // 功能数据
|
|
|
+ const arr = [];
|
|
|
this.actionList.forEach((x) => {
|
|
|
x.child.forEach((y) => {
|
|
|
- this.action_data.push(...y.fieldList)
|
|
|
- this.action.push(...y.checkList)
|
|
|
- if (y.is_private_change === '1') {
|
|
|
- arr.push(y.id)
|
|
|
+ this.action_data.push(...y.fieldList);
|
|
|
+ this.action.push(...y.checkList);
|
|
|
+ if (y.is_private_change === "1") {
|
|
|
+ arr.push(y.id);
|
|
|
}
|
|
|
- })
|
|
|
- })
|
|
|
+ });
|
|
|
+ });
|
|
|
// this.action_data.length === 0 ||和字段
|
|
|
if (this.action.length === 0) {
|
|
|
- this.$message.warning('请选择功能!')
|
|
|
+ this.$message.warning("请选择功能!");
|
|
|
} else {
|
|
|
- this.loading = true
|
|
|
+ this.loading = true;
|
|
|
|
|
|
const model = {
|
|
|
roleid: this.id,
|
|
|
role_name: this.ruleForm.role_name,
|
|
|
- private_field: JSON.parse(
|
|
|
- JSON.stringify(this.ruleForm.private_field)
|
|
|
- ),
|
|
|
+ private_field: JSON.parse(JSON.stringify(this.ruleForm.private_field)),
|
|
|
level: this.ruleForm.level,
|
|
|
action: this.action,
|
|
|
action_data: this.action_data,
|
|
|
private_data: arr,
|
|
|
- is_allow_see_price: this.ruleForm.is_allow_see_price
|
|
|
- }
|
|
|
+ is_allow_see_price: this.ruleForm.is_allow_see_price,
|
|
|
+ };
|
|
|
|
|
|
- let res = {}
|
|
|
- if (this.id === 'add') {
|
|
|
- delete model['roleid']
|
|
|
- model.companyNo = this.currentCompany
|
|
|
- res = await asyncRequest.add(model)
|
|
|
+ let res = {};
|
|
|
+ if (this.id === "add") {
|
|
|
+ delete model["roleid"];
|
|
|
+ model.companyNo = this.currentCompany;
|
|
|
+ res = await asyncRequest.add(model);
|
|
|
} else {
|
|
|
- model.companyNo = this.ruleForm.companyNo
|
|
|
- res = await asyncRequest.update(model)
|
|
|
+ model.companyNo = this.ruleForm.companyNo;
|
|
|
+ res = await asyncRequest.update(model);
|
|
|
}
|
|
|
- this.loading = false
|
|
|
+ this.loading = false;
|
|
|
if (res && res.code === 0) {
|
|
|
- const title = this.id === 'add' ? '添加成功' : '修改成功'
|
|
|
+ const title = this.id === "add" ? "添加成功" : "修改成功";
|
|
|
this.$notify.success({
|
|
|
title,
|
|
|
- message: ''
|
|
|
- })
|
|
|
- this.showModelThis = false
|
|
|
+ message: "",
|
|
|
+ });
|
|
|
+ this.showModelThis = false;
|
|
|
// 刷新
|
|
|
- this.$emit('refresh')
|
|
|
+ this.$emit("refresh");
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout()
|
|
|
+ await this.logout();
|
|
|
} else {
|
|
|
- this.$message.warning(res.message)
|
|
|
+ this.$message.warning(res.message);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- console.log('error submit!!')
|
|
|
- return false
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
- <style lang="scss" scoped>
|
|
|
+<style lang="scss" scoped>
|
|
|
.role {
|
|
|
.quanxian-main {
|
|
|
width: 100%;
|