<template>
    <el-drawer :append-to-body="true" title="发起人" :visible.sync="$store.state.flowPath.promoterDrawer" direction="rtl" class="set_promoter" size="550px" :before-close="savePromoter"> 
        <div class="demo-drawer__content">
            <div class="promoter_content drawer_content">
                <!-- <p v-if="$func.arrToStr(flowPermission)">{{$func.arrToStr(flowPermission)?$func.arrToStr(flowPermission):'所有人'}}</p> -->
				<p v-if="!$func.arrToStr(flowPermission)">{{'所有人'}}</p>
				<p class="selected_list" v-else>
					<span v-for="(item,index) in flowPermission" :key="index">{{item.name}}
					    <img src="@/assets/images/add-close1.png" @click="$func.removeEle(flowPermission,item,'targetId')">
					</span>
				</p>
				<!-- <p class="selected_list">
				    <span v-for="(item,index) in copyerConfig.nodeUserList" :key="index">{{item.name}}
				        <img src="@/assets/images/add-close1.png" @click="$func.removeEle(copyerConfig.nodeUserList,item,'targetId')">
				    </span>
				    <a v-if="copyerConfig.nodeUserList&&copyerConfig.nodeUserList.length!=0" @click="copyerConfig.nodeUserList=[]">清除</a>
				</p> -->
				
                <el-button type="primary" @click="addPromoter">添加/修改发起人</el-button>
            </div>
            <div class="demo-drawer__footer clear">
                <el-button type="primary" @click="savePromoter">确 定</el-button>
                <el-button @click="closeDrawer">取 消</el-button>
            </div>
            <employees-dialog 
                :isDepartment="true"
                :visible.sync="promoterVisible"
                :data.sync="checkedList"
                @change="surePromoter"
            />
        </div>
    </el-drawer>
</template>
<script>
import employeesDialog from '../dialog/employeesDialog.vue'
export default {
  components: { employeesDialog },
    data(){
        return {
            flowPermission: [],
            promoterVisible: false,
            checkedList: [],
        }
    },
    computed:{
        flowPermission1(){ //* 所选回写
            // eslint-disable-next-line no-
            // 
            return this.$store.state.flowPath.flowPermission.value
        }
    },
    watch:{
        flowPermission1(val){ //* 所选回写
            // eslint-disable-next-line no-
            // 
            this.flowPermission = val
        }
    },
    methods:{
        addPromoter() { //* 添加/修改发起人
            this.checkedList = this.flowPermission
            this.promoterVisible = true;
        },
        surePromoter(data) {
            // eslint-disable-next-line no-
            
            this.flowPermission = data;
            this.promoterVisible = false;
        },
        savePromoter() {
            // eslint-disable-next-line no-
            
            this.$store.commit('updateFlowPermission',{
                value:this.flowPermission,
                flag:true,
                id:this.$store.state.flowPath.flowPermission.id
            })
            this.closeDrawer()
        },
        closeDrawer(){
            this.$store.commit('updatePromoter',false)
        }
    }
}
</script>
<style src="../../css/override-element-ui.css" scoped>
</style>
<style scoped lang="less">
// @import '../../css/override-element-ui.css';
.set_promoter{
    .promoter_content {
        padding: 0 20px;
        .el-button{
            margin-bottom: 20px;
        }
        p {
            padding: 18px 0;
            font-size: 14px;
            line-height: 20px;
            color: #000000;
        }
    }
}
</style>