123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <template>
- <div class="bf-organization">
- <!-- 上级组织 -->
- <div class="left">
- <div class="paren_header">
- <p>{{ title }}</p>
- <div class="column" v-show="vice">
- <div :class="active == index ? 'column_childs' : 'column_child'" v-for="(item, index) in colType" :key="index" @click="upStart(index)">
- {{ item.name }}
- </div>
- </div>
- </div>
- <div class="paren_content">
- <div class="dptBox" v-show="active == 0">
- <el-scrollbar style="height: 100%">
- <el-tree :data="data" :check-strictly="true" show-checkbox @node-click="nodeClick" @check-change="currentChange" :props="defaultProps" default-expand-all :default-checked-keys="checkedKeys" :expand-on-click-node="false" :node-key="nodekey" ref="tree" highlight-current>
- </el-tree>
- </el-scrollbar>
- </div>
- <div class="dptBox" v-show="active == 1">
- <Rolelist :type="true" @radioChange="radioChange" :radioCheck="radioCheck" :number="8" :active="true" class="lessData" :mainData="mainData" />
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Rolelist from '@/components/rolelist'
- export default {
- props: {
- title: {
- type: String,
- default: "",
- },
- vice: {
- type: Boolean,
- default: false,
- },
- data: {
- type: Array,
- default: () => [],
- },
- nodekey: {
- type: String,
- default: "",
- },
- defaultProps: {
- type: Object,
- default: () => { },
- },
- checkedKeys: {
- //已选中
- type: Array,
- default: () => [],
- },
- lessData: {
- //副岗
- type: Array,
- default: () => [],
- },
- mainData: {
- //主岗
- type: Array,
- default: () => [],
- },
- radioCheck: {
- type: Number,
- default: 0,
- },
- checkBoxList: {
- type: Array,
- default: () => [],
- },
- },
- components: { Rolelist },
- data () {
- return {
- active: 0,
- colType: [
- {
- name: "组织",
- },
- {
- name: "岗位",
- }
- ],
- checkedDatas: [],
- checkedId: null,
- checkedList: [], //选中的列表,
- nodekeys: "nodekey",
- };
- },
- watch: {
- checkedKeys: {
- handler (val) {
- this.checkedList = val;
- this.$refs.tree.setCheckedKeys(val)
- },
- deep: true,
- },
- },
- mounted () {
- if(this.data!=null){
- this.data = this.formatData(this.data)
- }
- },
- methods: {
- //点击选择
- upStart (index) {
- this.active = index;
- this.$emit("getTreeindex", index)
- },
- formatData (params) {
- let data = params;
- data.map((item) => {
- if (item.hasOwnProperty('children')) {
- item.disabled = true;
- this.formatData(item.children)
- }
- });
- return data;
- },
- currentChange (data, isChecked) {
- const { OrganId } = data
- this.$emit("getTreeData", this.$refs.tree.getCheckedNodes())
- if (isChecked) {
- const checked = [OrganId]
- this.$refs.tree.setCheckedKeys(checked)
- }
- },
- // 选中后设置初始数据
- setDataObj (arr) {
- arr.forEach((item) => {
- if (!item.children) {
- item.children = {
- OrganId: item.OrganId,
- ValidBegin: "",
- ValidEnd: "",
- Action: "",
- QueryRow: "",
- QueryCol: "",
- NewCol: "",
- EditRow: "",
- EditCol: "",
- DeleteRow: "",
- };
- }
- });
- this.$emit("getTreeData", arr)
- },
- nodeClick (data) {
- this.$emit("getTreeDatas", data)
- this.checkedId = data.nodekey
- },
- radioChange (val) {
- this.$emit('radioChange', val)
- },
- //多选框
- checkChange (arr) {
- this.$emit("checkChange", arr)
- },
- checkClick (item) {
- this.$emit("checkClick", item)
- }
- },
- };
- </script>
- <style lang="scss">
- @import "./organization.scss";
- .DBox {
- cursor: not-allowed;
- }
- .dptBox {
- height: 100%;
- }
- </style>
|