{"size": 5696, "ext": "js", "max_stars_repo_path": "newproject/view/listpage/servertem.js", "max_stars_repo_name": "cgsunshine/dhs", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "newproject/view/listpage/servertem.js", "max_issues_repo_name": "cgsunshine/dhs", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "newproject/view/listpage/servertem.js", "max_forks_repo_name": "cgsunshine/dhs", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.623655914, "max_line_length": 106, "alphanum_fraction": 0.3953651685}
const servertemplate = `
                <div>
                <el-row>
                    <el-button @click="addserver">添加</el-button>
                    <el-dropdown @command="handleCommand">
                        <el-button type="primary" >
                            操作<i class="el-icon-arrow-down el-icon--right"></i>
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item command="redact" disabled>编辑</el-dropdown-item>
                            <el-dropdown-item command="main" :disabled="mainbool">设置主</el-dropdown-item>
                            <el-dropdown-item command="follow" :disabled="pagebool">设置从</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </el-row>
                <el-table
                ref="multipleTable"
                :data="modelback"
                tooltip-effect="dark"
                style="width: 100%;margin-top:20px"
                @selection-change="handleSelectionChange">
                        <el-table-column
                        type="selection"
                        width="55">
                        </el-table-column>
                        <el-table-column
                        prop="ip"
                        label="服务器Ip"
                        show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                        prop="type"
                        label="主从"
                        >
                        <template slot-scope="scope">
							<span v-if="scope.row.type">
								<span v-if="scope.row.type == 'master'">
	                                主
	                            </span>
	                            <span v-else>
	                                从
	                            </span>  
							</span>
							<span v-else>
								无
							</span>     
                        </template>
                        </el-table-column>
						<el-table-column
                        label="备注"
                        >
                        </el-table-column>
                       
                </el-table>
                </div>
                `

var serverTemplate = {
    template:servertemplate,
    data:function(){
        return {
			updatabool:true,
            mainbool:true,
            pagebool:true,
            multipleSelection: []
        }
    },
 	props:["modelback"],
    methods:{
            // 关闭模态框
            handleCommand(command){
                if(command == 'loginout'){
                    remove('name')
                    window.location.href="/user/login.html"
                }else if(command == 'redact'){
                    this.redact()
                }else if(command == 'main'){
                    this.main()
                }else if(command == 'follow'){
                    this.follow()
                }
            },
            // 编辑
            redact(){
                const json = {
                    name:"编辑",
                    data:this.multipleSelection[0]
                }
                this.$emit("listen",json)
            },
            // 设置主 
            main(){
                this.multipleSelection[0]["type"] = "master"
                var sendobj ={
                    url:"http://10.1.2.193/home/action", 
                    data:{jsoninfo:JSON.stringify(this.multipleSelection[0])}
                }
				var notund = underwaydata(this,"设置主服务器")
				setTimeout(()=>{
					var returnData = SendAjax(sendobj,"post")
					notund.close()
					notifyshow(this,{bool:returnData.Success,data:returnData.Msg})
					this.$emit("listen",{name:"设置主返回"})
				},500)
            },
            // 设置从
            follow(){
				var masterIp = []
				for (var i = 0; i < this.modelback.length; i++){
					if(this.modelback[i].type == 'master'){
						masterIp.push(this.modelback[i])
					}
				}
				if(masterIp.length > 0){
					this.multipleSelection[0]['masterIpdata'] = masterIp
					const json = {
	                    name:"设置从",
	                    data:this.multipleSelection[0]
	                }
	                this.$emit("listen",json)
				}else{
					this.$message({
			          message: '请设置一个主控！ 最少有一个主控！！！',
			          type: 'warning'
			        });
				}
            },
            // 添加服务
            addserver(){
                this.name="更改的值"
                const json = {
                    name:"添加服务器",
                }
                this.$emit("listen",json)
            },
        	handleSelectionChange(val) {
	            if(val.length == 1){
					this.updatabool = false
					this.mainbool = false
	                this.pagebool = false
						if(val[0].type == 'master' || val[0].type == "slave"){
							this.mainbool = true
	                    	this.pagebool = true
						}else{
							this.mainbool = false
	                    	this.pagebool = false
						}
	            }else{
					this.updatabool = true
	                this.mainbool = true
	                this.pagebool = true
	            }
	            this.multipleSelection = val;
        },
        // 查看是否 有主
        mainjudge(){
			var noset = 0
			var setmassav = 0
            for ( var i = 0 ; i < this.modelback.length; i++ ){
                if(this.modelback[i].type){
					if(this.modelback[i].type == "master"){
						setmassav ++
	                }
				}else{
					noset++
				}
            }
			if(noset == this.modelback.length){
				// 设置主
				return '设置主'
			}else if(setmassav == 1){
				// 已经有主这能设置从
				return '设置从'
			}
			
			noset = 0
			setmassav = 0
        }
    }
};





