Commit 1d70ea65 by xiaohai

stay up

parent c7edba39
...@@ -101,6 +101,10 @@ ...@@ -101,6 +101,10 @@
default() { default() {
return []; return [];
} }
},
changed: {
type: String,
default: ""
} }
}, },
data() { data() {
...@@ -111,34 +115,13 @@ ...@@ -111,34 +115,13 @@
label: 'label', label: 'label',
disabled: "disabled" disabled: "disabled"
}, },
menusObj: {},
menuData: [], menuData: [],
defaultOpen: [], defaultOpen: [],
selectedList: [] selectedList: []
}; };
}, },
methods: { methods: {
/**
* 获取分组架构
*/
// getGroupData() {
// let _this = this;
// let params = {
// isStoreGroup: 0
// };
// getRequest("/haoban-manage-web/dept/deptListForCompany", params)
// .then(res => {
// let treeData = [];
// let personData = [];
// if (res.data.errorCode == 1) {
// treeData = res.data.result.departmentList || [];
// personData = res.data.result.searchList || []
// }
// _this.formatGroupData(treeData, personData);
// })
// .catch(e => {
// console.log(e, "error");
// });
// },
formatGroupData(data, employees = []) { formatGroupData(data, employees = []) {
let copyData = data.slice(0); let copyData = data.slice(0);
let _this = this; let _this = this;
...@@ -188,6 +171,7 @@ ...@@ -188,6 +171,7 @@
arr.push(person); arr.push(person);
allClerks.push(person); allClerks.push(person);
} }
_this.menusObj[person.id] = person;
}); });
if (arr.length > 0) group.childrens = arr; if (arr.length > 0) group.childrens = arr;
group.allClerks = allClerks; group.allClerks = allClerks;
...@@ -207,6 +191,7 @@ ...@@ -207,6 +191,7 @@
_this.defaultOpen.push(group.id); _this.defaultOpen.push(group.id);
} }
} }
_this.menusObj[group.id] = group;
}); });
}, },
/** /**
...@@ -267,15 +252,24 @@ ...@@ -267,15 +252,24 @@
this.treeSet.dialogVisible = false; this.treeSet.dialogVisible = false;
} }
}, },
// beforeMount() {
// this.getGroupData();
// },
watch: { watch: {
searchText(newK, old) { searchText(newK, old) {
this.$refs.tree.filter(newK); this.$refs.tree.filter(newK);
}, },
treeData(newData) { treeData(newData) {
this.formatGroupData(newData.treeData, newData.personData); this.formatGroupData(newData.treeData, newData.personData);
},
defaultSelection(list) {
this.$nextTick(() => {
this.selectedList = list;
this.$refs.tree.setCheckedNodes(list);
list.forEach(li => {
this.defaultOpen.push(this.menusObj[li.id].parentId);
});
});
},
changed() {
this.formatGroupData(this.treeData.treeData, this.treeData.personData);
} }
} }
}; };
......
<template>
<div>
<el-form
class="department-info-form"
label-position="right"
:rules="rules"
:model="departInfo"
ref="departForm"
label-width="120px">
<el-form-item label="部门名称" prop="name">
<el-input v-model="departInfo.name"></el-input>
</el-form-item>
<el-form-item label="部门排序调整" prop="parentId">
<el-input :disabled="disabled" v-model="departInfo.parentName" @focus="callGroupSelector" suffix-icon="el-icon-arrow-down"></el-input>
</el-form-item>
</el-form>
<vue-select-employee ref="parentSelector" :treeSet="treeSet" @handleSelectedList="handleSelectedList" :treeData="treeData"></vue-select-employee>
</div>
</template>
<script>
import vueSelectEmployee from "components/common/vueSelectEmployee";
export default {
name: "departInfo",
components: {
vueSelectEmployee
},
props: {
departInfo: {
type: Object,
default() {
return {
name: "",
parentName: "",
parentId: ""
};
}
},
treeData: {
type: [Array, Object],
default() {
return {}
}
}
},
data() {
return {
rules: {
name: [
{ required: true, message: '请输入部门名称', trigger: 'blur' },
{ min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }
],
parentId: [
{ required: true, message: '请选择父级部门', trigger: 'change' }
]
},
disabled: true,
treeSet: {
isSelectPerson: false,
dialogVisible: false,
isSingle: true // 是否单选
}
}
},
methods: {
handleSelectedList() {
console.log(group);
this.departInfo.parentId = group ? group.id : "";
this.departInfo.parentName = group ? group.label : "";
},
callGroupSelector() {
this.treeSet.dialogVisible = true;
}
},
watch: {
treeData() {
this.disabled = false;
}
}
}
</script>
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
inactive-color="#DCDFE6"> inactive-color="#DCDFE6">
</el-switch> </el-switch>
<div class="particular-setting" v-if="visibleThere"> <div class="particular-setting" v-if="visibleThere">
<select-area :treeData="treeData"></select-area> <select-area @callPerSelector="callPerSelector" :treeData="treeData"></select-area>
</div> </div>
</div> </div>
<div class="only-visivble-self permission-div"> <div class="only-visivble-self permission-div">
...@@ -68,6 +68,9 @@ ...@@ -68,6 +68,9 @@
*/ */
switchPermission(val, _this, _there) { switchPermission(val, _this, _there) {
val && (this[_there] = !val); val && (this[_there] = !val);
},
callPerSelector(type, list) {
this.$emit("callPerSelector", type, list);
} }
}, },
computed: { computed: {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<i class="el-icon-circle-close" @click="delCurrent(li, 'butList')"></i> <i class="el-icon-circle-close" @click="delCurrent(li, 'butList')"></i>
</li> </li>
</template> </template>
<li class="item J_add-btn" @click="$refs.butSelector.treeSet.dialogVisible = true;"><i class="el-icon-plus"></i></li> <li class="item J_add-btn" @click="callSelector('but', butList)"><i class="el-icon-plus"></i></li>
</ul> </ul>
<div class="setting-name"> <div class="setting-name">
允许指定部门/人员可见 允许指定部门/人员可见
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
<i class="el-icon-circle-close" @click="delCurrent(li, 'vipList')"></i> <i class="el-icon-circle-close" @click="delCurrent(li, 'vipList')"></i>
</li> </li>
</template> </template>
<li class="item J_add-btn" @click="$refs.butSelector.treeSet.dialogVisible = true;"><i class="el-icon-plus"></i></li> <li class="item J_add-btn" @click="callSelector"><i class="el-icon-plus"></i></li>
</ul> </ul>
<vue-select-employee ref="butSelector" :treeSet="treeSet" @handleSelectedList="handleSelectedList" :treeData="groupData"></vue-select-employee> <!-- <vue-select-employee ref="butSelector" :treeSet="treeSet" @handleSelectedList="handleSelectedList" :treeData="groupData"></vue-select-employee> -->
</div> </div>
</template> </template>
<script> <script>
...@@ -86,6 +86,12 @@ export default { ...@@ -86,6 +86,12 @@ export default {
handleSelectedList(list) { handleSelectedList(list) {
console.log(list); console.log(list);
this.butList = list; this.butList = list;
},
/**
* 唤起选人插件
*/
callSelector(type, list) {
this.$emit("callPerSelector", type, list);
} }
}, },
watch: { watch: {
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<div class="setting-cell" v-if="$route.query.addnew != 1"> <div class="setting-cell" v-if="!isAddNew">
<p class="title">权限设置</p> <p class="title">权限设置</p>
<permission-setting :visibleApartList="testList" :visibleSpecialLsit="testList" :onlySelfApartList="testList" :treeData="treeData"></permission-setting> <permission-setting @callPerSelector="callPerSelector" :visibleApartList="testList" :visibleSpecialLsit="testList" :onlySelfApartList="testList" :treeData="treeData"></permission-setting>
</div> </div>
<div class="setting-cell"> <div class="setting-cell">
<div class="btn-area"> <div class="btn-area">
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<el-button @click="cancel">取消</el-button> <el-button @click="cancel">取消</el-button>
</div> </div>
</div> </div>
<vue-select-employee :treeSet="treeSet" @handleSelectedList="handleSelectedList" :treeData="treeData"></vue-select-employee> <vue-select-employee :changed="changed" :defaultSelection="defaultSelection" :treeSet="treeSet" @handleSelectedList="handleSelectedList" :treeData="treeData"></vue-select-employee>
</div> </div>
</template> </template>
<script> <script>
...@@ -64,15 +64,79 @@ ...@@ -64,15 +64,79 @@
] ]
}, },
treeData: {}, treeData: {},
disabled: true disabled: true,
defaultSelection: [],
defaultParent: [],
selectorType: "parent",
changed: "parent"
}; };
}, },
methods: { methods: {
/** /**
* 获取部门信息
*/
getDepartInfo() {
let that = this;
let params = {
groupId: that.$route.query.departmentId
};
getRequest("/haoban-manage-web/dept/findDeptById", params)
.then(res => {
if (res.data.errorCode == 1) {
that.departInfo.name = res.data.result.name;
that.departInfo.parentId = res.data.result.parentId;
let chain = res.data.result.chainName.split("/");
let len = chain.length;
if (len == 1) {
that.departInfo.parentName = ""
} else {
that.departInfo.parentName = chain[len - 2];
}
that.defaultParent = [{
label: that.departInfo.parentName,
id: res.data.result.parentId,
groupId: res.data.result.parentId
}];
} else {
that.$message.error({
duration: 1000,
message: res.data.message
});
}
})
.catch(e => {
that.$message.error({
duration: 1000,
message: e.message
});
})
},
/**
* 唤起部门选择器 * 唤起部门选择器
*/ */
callGroupSelector() { callGroupSelector() {
this.treeSet.dialogVisible = true; this.selectorType = "parent";
this.defaultSelection = this.defaultParent;
this.onlyPerson = false;
this.onlyGroup = [];
this.changed = "parent";
this.treeSet = {
dialogVisible: true,
isSingle: true,
isSelectPerson: false
};
},
callPerSelector(type, list) {
this.selectorType = type;
this.defaultSelection = list;
this.onlyPerson = true;
this.onlyGroup = [this.$route.query.departmentId];
this.changed = type;
this.treeSet = {
dialogVisible: true,
isSingle: false,
isSelectPerson: true
};
}, },
/** /**
* 处理已选部门 * 处理已选部门
...@@ -163,6 +227,14 @@ ...@@ -163,6 +227,14 @@
}, },
beforeMount() { beforeMount() {
this.getGroupData(); this.getGroupData();
if (!this.isAddNew) {
this.getDepartInfo();
}
},
computed: {
isAddNew() {
return !!(this.$route.query.addnew == 1);
}
} }
}; };
</script> </script>
......
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