<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>发布短信</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- bootstrap 3.0.2 -->
<link href="<c:url value='/scripts/lib/layui/layui.css'/>" rel="stylesheet" type="text/css" />

<!-- Theme style -->
<link href="<c:url value='/styles/AdminLTE.css'/>" rel="stylesheet" type="text/css" />
<link href="<c:url value='/styles/notice/noticeMsgPublish.css?v=22222'/>" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="<c:url value='/scripts/lib/jquery-1.8.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/lib/layui/layui.js'/>"></script>
<script type="text/javascript" src="${ctx}/scripts/jquery/ajaxfileupload.js"></script>
<%-- <script type="text/javascript" src="<c:url value='/scripts/lib/layDate/laydate.dev.js'/>"></script> --%>
<script type="text/javascript" src="<c:url value='/scripts/lib/template-native.js'/>"></script>

<script src="<c:url value='/scripts/admin/notice/element/vue.js?v=1234'/>"></script>
	<link rel="stylesheet" href="//superdesk.avic-s.com/avicfile/theme/theme-chalk.css">
<script src="<c:url value='/scripts/admin/notice/element/element.js?v=1234'/>"></script>
<!-- <script src = "//cdn.polyfill.io/v2/polyfill.min.js"></script> -->
 <script src="<c:url value='/scripts/admin/notice/element/polyfill.js?v=12345555'/>"></script>
<style type="text/css">
	.selected-cell{
		color: red;
	}
	.line-top {
    border-top: 1px solid #F3F3F3;
  }
  .custom-tree-node {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding-right: 8px;
  }

  /*按钮图片组*/
  .span-button {
    line-height: 0;
    margin: 0;
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    border: 0 none;
    cursor: pointer;
    outline: none;
    background-color: transparent;
    background-repeat: no-repeat;
    background-attachment: scroll;
    background-image: url("http://wx.palmnest.com/avicfile/2019/ysf/zTreeStandard.png");
  }
  .dialog-pop{
        display: none;
    }

  /*文件夹图标*/
  .span-button.ico_open {
    background-position: -110px -16px;
  }

  /*文件图标*/
  .span-button.ico_docu {
    background-position: -110px -32px;
  }
  .type-p-t{
	margin-left: 20px;
    margin-bottom: 20px;
  }

  .btns-bottom{
	text-align: center;
    margin-right: 20%;
    margin-bottom: 30px;
    float: left;
    width: 100%;
  }
  .radio-bottom-content{
	  display: flex !important;
  }
  .radio-top-content{
	  display: flex !important;
  }
  .rd-content{
	display: flex;
    flex-flow: column;
	padding-left: 40px;
	margin-top: 10px;

  }
  .order-by-num{
	  padding-bottom: 10px;
  }
  .btn-red-choose{
	margin-left: 20px;
    margin-top: -12px;
	padding: 0;
    width: 120px;
    text-align: center;
    height: 40px;
    line-height: 40px;
	border: 1px solid #158DF6;
    color: #158DF6!important;
	background: #fff;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
  }
  .depart-pas{
	  display: flex !important;
  }
  .tv-choose-text{
	  margin-top: 20px;
  }
  .mg-lt-10{
	  margin-left: 10px;
  }
  .el-radio__inner{
	width: 20px !important;
	height: 20px !important;
  }
    .el-radio__input.is-checked .el-radio__inner::after {
      content: "";
      width: 10px;
      height: 5px;
      border: 2px solid white;
      border-top: transparent;
      border-right: transparent;
      text-align: center;
      display: block;
      position: absolute;
	    top: 4px;
      left: 3px;
      vertical-align: middle;
      transform: rotate(-45deg) !important;
      border-radius: 0px;
      background: none;
    }
	.wx-tips{
		font-size: 15px;
   		 color: #333;
    	font-weight: 600;
		margin-left: 20px;
	}
	.radio-title-name{
		font-size: 15px;
		color: #333;
		font-weight: 600;
		margin-top: 2px;
	}
	.tv-choose-content{
         margin-top:5px;
         color: #333;
        font-size: 15px;
        max-width: 600px;
        word-break:break-all;       
        word-wrap:break-word; 
        line-height: 25px;   
		margin-left: 30px;
       }
	   .el-checkbox__input.is-checked + .el-checkbox__label{
        color: #333 !important;
      }
      .cell-box{
        padding: 12px 0;
        font-size: 15px;
        color: #333;
        border-bottom: 1px solid #ddd;
      }
      .el-menu-item.is-active {
    color: #409EFF !important;
    font-size: 16px;
    font-weight: 600;
      }
      .tag-size{
        display: flex !important;
      }
      .sub-item-name{
        flex: 1;
      }
      .icon-check-item{
        font-size: 20px;
        color: #409EFF;
        font-weight: 600;
        margin-right: 20px;
      }
      .tag-css{
        margin: 5px;
      }
      .custom-tree-node{
        width: 100%;
        display: flex;
      }
      .el-tree-node-name{
        flex: 1;
		padding: 6px 0;
      }
      .search-input{
        height: 40px !important;
        line-height: 40px !important;
      }
      .img-sup-icon{
        width: 20px;
        height: 20px;
        margin-right: 10px;
      }
	  .msg-contnet-right{
		  float: left;
	  }
	  .con-clear-btn{
		  margin-left: 20px;
	  }
	  .search-rs-title{
        margin-top: 15px;
        font-size: 15px;
        color: #333;
        background: #eee;
        padding: 8px 10px;
      }
</style>
</head>
<body>
<div id="app">
	<div class="bread-wp">
				公告通知 >  发布公告消息  > 短信消息
	</div>
	<div class="right-content">
	 <input type="hidden" value="${ctx}" id="contextPath">
		<ul class="third-tabs">
	          <li class="third-tab ">
	            <a href="noticeAppPublish">公告</a>
	          </li>
	          <li class="third-tab ">
	            <a href="wxPublish">微信模板消息</a>
	          </li>
	          <li class="third-tab active">
	            <a href="msgPublish">短信消息</a>
	          </li>
	          <li class="third-tab">
	            <a href="emailPublish">邮件消息</a>
	          </li>
        </ul>
		<div class="main-content-mode-wp clearfloat">
			<div class="message-mask">
				<div class="message-tip-con">
					<div class="msg-title">温馨提示</div>
					<div class="msg-img"></div>
					<div class="msg-tip">如需使用发送短信消息功能，需先开通短信服务，具体开通事宜请联系：177 8603 0154</div>
				</div>
			</div>
			<c:if test="${fn:length(orgs) > 1}">
				<select class="select-width180 org-list" name="orgId" id="orgId" >
					<option value="">请选择项目</option>
					<c:forEach items="${orgs }"  var="org">
						<option value="${org.id }">${org.name }</option>
					</c:forEach>
				</select>
			</c:if>
			<c:if test="${fn:length(orgs) == 1}">
				<input type="hidden" name="orgId" id="orgId" value="${orgs[0].id}">
			</c:if>
			<div class="msg-con-wp clearfloat">
				<div class="part-wp approvalStyle">
					<span class="search-tips">审核类型</span>
					<select name="city" class="small-input  type-p-t" id="approvalType">
					  <option value="">请选择审核类型</option>
					</select>
				  </div>
				<span class="m-tips">短信内容</span>
				<div class="con-wp">
					<div class="message-con-wp">
						<textarea class="message-con"></textarea>
						<div class="msg-num-wp">
							<span class="num">60</span>字
							<span class="msg-num">1</span>条
						</div>
					</div>
					<div class="msg-btm-wp">
						<span class="msg-suffix-wp">
							<%--短信后缀:<span class="suffix-name">【】</span>--%>
						</span>
					</div>
					
				</div>
			</div>
			
			<div class="msg-contnet-right">
			<div class="wx-tips"> 发送对象</div>
			<el-radio-group v-model="checkRadio"  class="rd-content" @change="changeValue" >
				<el-radio :label="1" class="radio-top-content">
					<div class="radio-title-name"> 按号码发送</div>
					<div class="msg-mobile-wp clearfloat">
						<span class="m-tips">目标号码<br><span class="m-tips-kuo">(每行一个)</span></span>
						<div class="msg-wp">
							<textarea class="mobile-list"></textarea>
							
							<div class="m-white-btns">
								<button class="filter-btn btn-white-width90">重号过滤</button>
								<button class="clear-btn btn-white-width90">清空</button>
								<button class="export-btn btn-red-width90 mg-lt-10">导入</button>
							</div>
						</div>
					</div>
				</el-radio>
				<el-radio :label="2" class="radio-bottom-content">
					<div class="depart-pas">
						<div class="radio-title-name">部门分组发送</div>
					    <button class=" btn-red-choose" @click="chooseDep" >选择部门/分组</button>
					</div>
				</el-radio>
			  </el-radio-group>
			  <div class="tv-choose-content" v-if="checkRadio==2 && identityList.length>0">
				<el-tag
				class="tag-css tag-top"
				v-for="(item, index) in chooseDepList"  :key="index"
				closable
				:disable-transitions="false"
				  @close="deleteResultDepHandler(item, index)">
				{{item.name}}
			  </el-tag>
			  </div>
			</div>
			<div class="msg-btm-right btns-bottom">
				<button class="con-sure-btn btn-red-width90" @click="submitSureData">确定发送</button>
				<button class="con-clear-btn btn-white-width90">清空</button>
			</div>
		</div>
	</div>
	<div class="dialog-pop">
		<el-dialog
		:title="titleName"
		:close-on-click-modal="false"
		width="800px"
		:visible.sync="isDislagVisable"
		>
    <div style="float: left">
      <div style="float:left;width: 480px;height: 500px;">
        <div style="display: flex">
          <el-input
            class="search-input" 
            placeholder="请输入部门、分组名称搜索" clearable  @change="changeInput"
            prefix-icon="el-icon-search"
            v-model="searchText">
          </el-input>
          <el-button slot="append" icon="el-icon-search" @click="searchDeptOrSup"></el-button>
        </div>
		<div class="search-data-wrap" v-show="false">
            <div style="overflow-y: scroll;height: 440px;">
              <div v-if=" searchDataList.deptList && searchDataList.deptList.length>0">
              <div class="search-rs-title">部门</div>
              <div class="list-box click-cursor" v-for="(item, index) in searchDataList.deptList" :key="item.id" 
                :class="{'line-top': index != 0}">
                <div class="cell-box">
                  <div class="tag-size" v-on:click="searchDataHandler(item)">
                    <img src="http://wx.palmnest.com/avicfile/2019/ysf/img_docum.png" class="img-sup-icon"/>
                    <span class="sub-item-name">{{item.name}}</span>
                <span v-if="backSelectedHandler(item.id)" class="radio-icon el-icon-check icon-check-item"></span>
                  </div>
                </div>
              </div>
            </div>
              <div v-if="searchDataList.groupList&&searchDataList.groupList.length>0">
              <div class="search-rs-title" >分组</div>
              <div class="list-box click-cursor" v-for="(item, index) in searchDataList.groupList" :key="item.id" 
                :class="{'line-top': index != 0}">
                <div class="cell-box">
                  <div class="tag-size" v-on:click="searchDataHandler(item)">
                    <img src="../../../../super_service/images/admin/tag-icon.png" class="img-sup-icon"/>
                    <span class="sub-item-name">{{item.name}}</span>
                <span v-if="backSelectedHandler(item.id)" class="radio-icon el-icon-check icon-check-item"></span>
                  </div>
                </div>
              </div>
            </div>
            </div>
          </div>
		  <div class="default-data-wrap" v-show="true"> 
        <div class="tree-group-box box-top10 box-right15">
          <el-menu :default-active="activeIndex" mode="horizontal" @select="handleSelect">
            <el-menu-item index="1" v-if="indexType == 1||indexType == 0">部门</el-menu-item>
            <el-menu-item index="2" v-if="indexType == 2||indexType == 0">分组</el-menu-item>
          </el-menu>
        </div>
        <div style="overflow-y: scroll;height: 400px;" v-if="activeIndex == 1">
		 <el-tree :data="dataTree"  default-expand-all node-key="id" @node-click="handleNodeClick"
		 :filter-node-method="filterNodeHandler"  :expand-on-click-node="false"
             ref="tree" highlight-current  :props="defaultProps"> 
			 <span class="custom-tree-node" slot-scope="{node, data}">
			 <span @mouseover="showTip(data.id)" @mouseout="hideTip"  class="el-tree-node-name">
				<span v-if="data.childList&&data.childList.length>0||data.levels==0"
					  class="span-button ico_open"></span>
				<span v-else class="span-button ico_docu"></span>
				<span>{{node.label}}</span>
			  </span>
        <span v-if="backSelectedDepHandler(data.id)" class="radio-icon el-icon-check icon-check-item"></span> 
			</span>
			</el-tree>
        </div>
        <div style="overflow-y: scroll;height: 385px;" v-if="activeIndex == 2">
          <div class="list-box click-cursor" v-for="(item, index) in tagList" :key="item.id" 
		  :class="{'line-top': index != 0}">
            <div class="cell-box">
              <div class="tag-size" v-on:click="tagBtnHandler(item)">
                <img src="../../../../super_service/images/admin/tag-icon.png" class="img-sup-icon"/>
                <span class="sub-item-name">{{item.name}}</span>
				    <span v-if="backSelectedHandler(item.id)" class="radio-icon el-icon-check icon-check-item"></span>
              </div>
            </div>
          </div>
        </div>
		</div>  
      </div>
      <div style="margin-left:10px;float: left;width: 1px;height: 480px; background: #F3F3F3"></div>
      <div style="margin-left:10px;float:left;width: 250px;">
        <div style="width: 100%">已选择</div>
        <div style="width: 100%;height: 460px;overflow-y: scroll;">
          <el-tag
            class="tag-css tag-top"
            v-for="(item, index) in identityList"  :key="index"
            closable
            :disable-transitions="false"
		    	@close="deleteTagHandler(item, index)">
            {{item.name}}
          </el-tag>
        </div>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="isDislagVisable = false">返回</el-button>
        <el-button size="small" type="primary" @click="chooseDataSubmit">确定</el-button>
      </span>
     </el-dialog>
</div>
</div>
	<script type="text/javascript">
		// 在页面加载好后就初始化vue实例,也可以在外面直接初始化
		$(document).ready(function(){
			const vm = new Vue({
				el:'#app',
				data(){
					return {
						isOpenApprove:'',//判断是否开启了多级审核 1.开启了多级审核 2，没有开启多级审核
						dataForm:{
							orgId:'',
						},
						ifShowSearch:false,
						searchDataList:{},
						contextBasePath:'',
						editId:'',
						checkRadio:0,
						titleName: '请选择部门和分组',
						searchNote: '',
						activeIndex: '1',
						indexType: '0',
						isDislagVisable: false,
						identityList:[],
						chooseDepList:[],//选中的数据
						dataTree: [],
						tagList: [],
					    selectedId: '',
						searchText: '',
						defaultProps: {
						children: 'childList',
						label: 'nameinfo',
          				},
						
					}
				},
				     //监听搜索框的查询参数变化，然后进行过滤
					 watch:{
						searchText(val) {
							if(this.activeIndex==1){
							setTimeout(() => {
								this.$refs.tree.filter(val)
							}, 1000);
							}else{
							this.getSubgroupList(val)
							}
							}
						},
				methods:{
					filterNodeHandler(value, data, node) {
						if (!value) {
							return true
						}
						let level = node.level
						let _array = [] //这里使用数组存储 只是为了存储值。
						this.getReturnNode(node, _array, value)
						let result = false
						_array.forEach(item => {
							result = result || item
						})
						return result
					},
					getReturnNode(node, _array, value) {
						let isHasData = node.data && node.data.nameinfo && node.data.nameinfo.indexOf(value) !== -1
						isHasData ? _array.push(isHasData) : ''
						if (!isHasData && node.level != 1 && node.parent) {
							this.getReturnNode(node.parent, _array, value)
						}
					},
					deleteResultDepHandler(data, index){
					this.chooseDepList.splice(index, 1);
      			  },
					changeInput(value){
					if(value){
						this.ifShowSearch=true
					}else{
						this.ifShowSearch=false
					}
					},
					getQueryString: function (name) {
						var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
						var r = window.location.search.substr(1).match(reg);
						if (r != null) return unescape(r[2]);
						return null;
					},
					 //搜索选中的情况下
					 searchDataHandler(data){
						if (this.backSelectedHandler(data.id)) {
						let indexRow = this.backSelectedHandler(data.id, true);
						if (indexRow != -1) {
							this.identityList.splice(indexRow, 1);
						}
						} else {
							let newArr=[]
						let resultObj={}
						resultObj['id']=data.id
						resultObj['name']=data.name
						resultObj['type']=3
						newArr.push(resultObj)
				          this.identityList=[...this.identityList,...newArr]
						}
					},
					//提交数据
					submitSureData(){
						let _this=this
							//短信id
						var id = _this.editId
						//项目id

						var orgId = $("#orgId").val()
						if (!orgId) {
							_this.$message({message: '请选择项目!', type: 'error'});
							return false;
						};

						var approvedata= $("#approvalType").val()
						console.log("审核内容",approvedata,_this.isOpenApprove)
						if (_this.isOpenApprove==1 && !approvedata) {
							_this.$message({message: '请选择审核类型！', type: 'error'});
							return;
						}

						console.log("短信内容",$('.message-con').val())
						if ($('.message-con').val() == "") {
							_this.$message({message: '请输入短信内容!', type: 'error'});
							return;
						}
						// if (!validatePhones) {
						// 	_this.$message({message: '请输入正确的手机号码！', type: 'error'});
						// 	return;
						// }
						
						var deptGroupJson=""
						console.log("_this.checkRadio",_this.checkRadio)
						if(_this.checkRadio==0){
							_this.$message({message: '请选择发送对象类型', type: 'error'});
								return false;
						}
						if(_this.checkRadio==2){
							if(_this.identityList.length>0){
								deptGroupJson=JSON.stringify(_this.chooseDepList)
								}else {
								_this.$message({message: '请选择部门或者分组！', type: 'error'});
								return false;
							}
						}else{
							var mobiles = $('.mobile-list').val();
							console.log("手机号",mobiles)
							var	re = new RegExp("\n", "g"); //定义正则表达式
							//第一个参数是要替换掉的内容，第二个参数"g"表示替换全部（global）。
							var Newstr = mobiles.replace(re, ","); //第一个参数是正则表达式。
							if (Newstr == "") {
								_this.$message({message: '请输入目标号码！', type: 'error'});
								return;
							}

						}
						$.ajax({
							type: "post",
							url:  "/super_service/notice/phoneMessage/saveOrUpdate",
							data: {
								"orgId": orgId,
								"phones": Newstr,
								"approvalType" : $("#approvalType").val()?$("#approvalType").val():'',
								"content": $('.message-con').val(),
								"id": !!id ? id : '',
								receiveType:_this.checkRadio,
								deptGroupJson:deptGroupJson
							},
							success: function (data) {
								if (data.code == '200') {
									if (_this.editId) {
										_this.$message({message: '编辑成功！', type: 'success'});
										window.location.href =   '/super_service/notice/audit/noticeMsgVerify';
									} else {
										_this.$message({message: '发送成功！', type: 'success'});
										window.location.href =  '/super_service/notice/audit/noticeMsgVerify';
										$('.mobile-list').val("")
										$('.message-con').val("");
									}
								} else {
									_this.$message({message:data.msg, type: 'error'});
								}
								$(".con-sure-btn").attr("disabled", false)
							},
							error: function (error) {
								$(".con-sure-btn").attr("disabled", false)
							}
						});

					},
					 //弹框搜索
					 searchDeptOrSup(){
					let _this = this;
					if(_this.activeIndex==2 ){
             			 _this.getSubgroupList(_this.searchText)
         			 }	

					},
					backSelectedDepHandler(id, isIndex = false){
						let isYN = false;
						let seleIndex = -1;
						this.identityList.every((item, index) => {
						if (item.id == id) {
							seleIndex = index;
							isYN = true;
							return false;
						} else {
							return true;
						}
						})
						if (isIndex) {
						return seleIndex;
						} else {
						return isYN;
						}
					} ,  
				      // 数据根据id去重
					  unique(arr) {
							const res = new Map();
							return arr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1));
					   },
					 // 递归获取所有节点数据
					 getAllNodeId (expandedKeys, moduleDataList) {
						for (let i = 0; i < moduleDataList.length; i++) {
						expandedKeys.push({
							id: moduleDataList[i].id,
							levels: moduleDataList[i].levels,
							nameinfo: moduleDataList[i].nameinfo,
							orgInfo: moduleDataList[i].orgInfo,
							parentid: moduleDataList[i].parentid,
							rank: moduleDataList[i].rank,
							visible: moduleDataList[i].visible,
							childList: [],
						});
						if (moduleDataList[i].childList) {
							expandedKeys = this.getAllNodeId(expandedKeys, moduleDataList[i].childList)
						}
						}
						return expandedKeys
					},
					 // 处理选中数据
					 processSelectedData(data, backData) {
						let dataList = [];
						if (data.id) {
						dataList = this.getAllNodeId(dataList, [data]);
						backData(dataList)
						} else {
						backData([])
						}
					},

				handleNodeClick(data,node,inde){
					this.processSelectedData(data, backData => {
						console.log('backData', backData);
						if (this.backSelectedDepHandler(data.id)) {
						backData.forEach(item => {
							let indexRow = this.backSelectedDepHandler(item.id, true);
							this.identityList.splice(indexRow, 1);
						})
						} else {
						this.identityList = this.unique(this.identityList.concat(backData))
						}
						console.log("最后选中的列表",this.identityList)

						let newArr=[]
					for (const data of this.identityList) {
						let resultObj={}
						resultObj['id']=data.id
						resultObj['name']= data.name?data.name:data.nameinfo
						if(data.levels==0){
							resultObj['type']=1
						}else{
							resultObj['type']=2
						}
						newArr.push(resultObj)
					}
					 this.identityList=[...newArr]
					
					console.log("最后选中11111",this.identityList)
				
					});
				},
					chooseDep(){
					if(this.checkRadio==2){
						this.dataForm.orgId=$("#orgId").val()
						this.isDislagVisable=true
						this.searchText=""
						$(".dialog-pop").show();
						this.getDeptTreeList();
						this.getSubgroupList("");
						let newArr=[]
						if(this.chooseDepList && this.chooseDepList.length>0){
						for (const key in this.chooseDepList) {
						newArr.push(this.chooseDepList[key])
						 }
						}
           				 this.identityList=newArr
					}
			 	},
				getDeptTreeList(){
					var _this = this;
					if (!_this.dataForm.orgId) {
						_this.$message({message: '请选择项目!', type: 'error'});
						return false;
					};
					$.ajax({
					// url: "http://wx.palmnest.com/super_cloud/api/organisation/department/getDeptTree",
             		 url:   '/super_cloud/api/organisation/department/getDeptTree',
					type: "POST",
					dataType: "json",
					data: {
						orgId:_this.dataForm.orgId,//项目Id 
						virtId: _this.inputUser,//
					},
					success: function (data) {
						console.log("部门返回",data)
						if(data.code == 200 && data.data){
						_this.dataTree=data.data
						}else{
						_this.dataTree=[]
						}
					},
					error: function(err){

					}
					});
        		},
        //分组数据
        	getSubgroupList(val){
				var _this = this;
				if (!_this.dataForm.orgId) {
				_this.$message({message: '请选择项目!', type: 'error'});
				return false;
				};
			$.ajax({
				// url:  'http://wx.palmnest.com/super_cloud/api/organisation/subgroup/getAll',
            	url:  '/super_cloud/api/organisation/subgroup/getAll',
				type: "POST",
				dataType: "json",
				data: {
				pageSize:1,
				pageNo:100,
				"conditions['orgId']":_this.dataForm.orgId,//项目Id 以逗号分隔 最后面不要带逗号
				"conditions['name']": val,//姓名、手机号、项目名 模糊搜索，默认传""
				},
				success: function (data) {
				console.log("分组返回",data)
				if(data.code == 200 && data.data){
					_this.tagList=data.data
				}else{
					_this.tagList=[]
				}
				},
				error: function(err){

				}
			});
        	},
				changeValue(val){
					this.checkRadio=val
					if(val==1){
						this.identityList=[]
					}else {//清空手机号
						$('.mobile-list').val("");
					}
				},
					getCheckedKeys() {
        				console.log(this.$refs.tree.getCheckedKeys());
     				 },
					  setCheckedKeys() {
       					 this.$refs.tree.setCheckedKeys([3]);
      				},

					    //鼠标经过树节点时触发
					showTip() {
					},
					//鼠标离开树节点时触发
					hideTip() {
					},
				
					chooseDataSubmit(){
					console.log("已选中的数据",this.identityList)
					// console.log(this.$refs.tree.getCheckedKeys());
					// console.log(this.$refs.tree.getCheckedNodes());
					this.isDislagVisable=false
					let newArr=[]
					if(this.identityList.length>0){
						for (const key in this.identityList) {
						newArr.push(this.identityList[key])
						}
					}
					this.chooseDepList=newArr
       			 },
					
					deleteTagHandler(data, index){
						this.identityList.splice(index, 1);
					},
					handleSelect(val) {
       				 this.activeIndex = val;
						if(this.activeIndex==1){
						setTimeout(() => {
							this.$refs.tree.filter(this.searchText)
						}, 1000);
						}else{
						this.getSubgroupList(this.searchText)
						}		
      				},
					backSelectedHandler(id, isIndex = false) {
					let isYN = false;
					let seleIndex = -1;
					this.identityList.every((item, index) => {
					if (item.id == id) {
						seleIndex = index;
						isYN = true;
						return false;
					} else {
						return true;
					}
					})
					if (isIndex) {
					return seleIndex;
					} else {
					return isYN;
					}
				},  
				 // 点击选中项
				 tagBtnHandler(data) {
					if (this.backSelectedHandler(data.id)) {
						let indexRow = this.backSelectedHandler(data.id, true);
						if (indexRow != -1) {
							this.identityList.splice(indexRow, 1);
					}
				 } else {
					let newArr=[]
					let resultObj={}
					resultObj['id']=data.id
					resultObj['name']=data.name
					resultObj['type']=3
					newArr.push(resultObj)
			          this.identityList=[...this.identityList,...newArr]
					}
    			},
   		//调用项目列表接口，如果是1个的话就判断是否审核
		getProjectList(){
			let	_this = this
			$.ajax({
				type: "post",
				url:  "/super_service/admin/templ/getOrgList",
				success: function (data) {
					if (data.code == 200) {
						if(data.data.length==1){
							_this.getIfCanApproval(data.data[0].id)
						}
					}
				},
				error: function (error) {
				}
			});
		},
			//判断是否开启了审核
			getApproveTypeIsOpen(orgId){
				var _this=this
				$.ajax({
					type: "post",
					url: "/super_service/notice/approval/getApprovalSetDto",
					data: {
						"orgId": orgId
					},
					success: function (data) {
						if (data.code == 200) {
							if(data.data.isOpen==1){
								_this.isOpenApprove=1
								$(".approvalStyle").show();
								console.log("_this.isOpenApprove",_this.isOpenApprove)
							}else {
								_this.isOpenApprove=2
								$(".approvalStyle").hide();
							}
						} else {
						}
					},
					error: function (error) {
					}
				});
			},
				getIfCanApproval(orgId){
				var _this=this
					$.ajax({
						type: "post",
						url: "/super_service/notice/approval/getSetByOrgId",
						data: {
							"orgId":  orgId
						},
						success: function (data) {
							if (data.code == 200) {
								if(data.data.isOpen==1){//显示审核下拉列表
									_this.getApproveTypeIsOpen(orgId)
								}else{////不显示审核下拉列表
									$(".approvalStyle").hide();
								}
							} else {
								layer.msg(data.msg)
							}
						},
						error: function (error) {
							layer.msg('error')
						}
					});
				},
					
				},
				created(){
					let org=$("#orgId").val()
					console.log("org",org)
					this.contextBasePath = $("#contextPath").val().split("super_service")[0]+"super_cloud"
					console.log("contextBasePath",this.contextBasePath)
					if(this.contextBasePath=='/super_cloud'){
						this.contextBasePath="http://wx.palmnest.com/super_cloud"
					}
					this.getProjectList();
					this.dataForm.orgId=org
					var id = this.getQueryString("id")
					this.editId=id
					console.log("org",id)
					if (!!id) {
						this.ajaxDetail(id)
					}

				},
			})
		})
	</script>

<script type="text/javascript" src="<c:url value='/scripts/admin/notice/noticeMsgPublish.js?v=123341'/>"></script>
</body>
</html>