<template>
	<div>
		<div class="crumbs">
			<el-breadcrumb separator="/">
				<el-breadcrumb-item>
					<i class="el-icon-user"></i> Editorial board
				</el-breadcrumb-item>
			</el-breadcrumb>
		</div>
		<div class="container">
			<div class="handle-box" :rules="rules">
				<el-select v-model="query.journal_id" placeholder="Please select a journal" @change="getJourdate"
					style="width: 290px;">
					<el-option v-for="item in df_jour" :label="item.title" :key="item.journal_id"
						:value="item.journal_id"></el-option>
				</el-select>
				<el-select v-model="query.board_group_id" placeholder="Please select a group" @change="getDate"
					style="margin-left: 10px;">
					<el-option v-for="item in df_group" :label="item.group_name" :key="item.board_group_id"
						:value="item.board_group_id">
						{{item.group_name}}
						<span v-if="item.person_num!=undefined" style="color: #bbb;">({{item.person_num}})</span>
					</el-option>
				</el-select>
				<el-button type="warning" icon="el-icon-circle-plus-outline" @click="addGroup"
					style="margin-left: 10px;">
					Group management</el-button>
				<el-button type="primary" icon="el-icon-plus" @click="addEditor" style="float: right;">
					Add new board</el-button>
			</div>

			<el-table :data="tableData_0" border stripe class="table nullTable" ref="multipleTable"
				header-cell-class-name="table-header" empty-text="New messages (0)">
				<el-table-column prop="name" label="Realname"></el-table-column>
				<el-table-column prop="email" label="Email"></el-table-column>
				<el-table-column prop="hindex" label="H-WOS" width="110px" align="center"></el-table-column>
				<el-table-column prop="ghindex" label="H-Google" width="110px" align="center"></el-table-column>
				<el-table-column label="Grade" width="110px" align="center"></el-table-column>
				<!-- <el-table-column label="Remarks" width="180"></el-table-column> -->
				<el-table-column label="" width="190" align="center"></el-table-column>
			</el-table>

			<p class="shen_fen" style="margin-top: 0;" v-if="tableData_A.length!=0">Editor-in-Chief</p>
			<el-table :data="tableData_A" border stripe class="table" ref="multipleTable"
				header-cell-class-name="table-header" empty-text="New messages (0)" :show-header="false"
				v-if="tableData_A.length!=0">
				<el-table-column prop="name" label="Realname">
					<template slot-scope="scope">
						<p @click="perSonnel(scope.row.tuser_id)" class="perSonGo">{{scope.row.name}}</p>
					</template>
				</el-table-column>
				<el-table-column prop="email" label="Email"></el-table-column>
				<el-table-column prop="hindex" label="H-WOS" width="110px" align="center">
					<template slot-scope="scope">
						<p v-html="colorIndex(scope.row.wos_index,scope.row.wos_time)"></p>
					</template>
				</el-table-column>
				<el-table-column prop="ghindex" label="H-Google" width="110px" align="center">
					<template slot-scope="scope">
						<p v-html="colorIndex(scope.row.google_index,scope.row.google_time)"></p>
					</template>
				</el-table-column>
				<el-table-column label="Grade" width="110px" align="center">
					<template slot-scope="scope">
						<p style="display: inline-block;" v-if="scope.row.starList_mark!=0">
							<img src="../../assets/img/star-all.png" v-for="item in scope.row.starList"
								v-if="scope.row.starList_mark<=8&&item.star==1" class="starSty">
							<img src="../../assets/img/star-traf.png" v-for="item in scope.row.starList"
								v-if="scope.row.starList_mark<=8&&item.star==0" class="starSty">
							<img src="../../assets/img/star-none.png" v-for="item in scope.row.starList"
								v-if="scope.row.starList_mark<=8&&item.star==2" class="starSty">
							<img src="../../assets/img/star-all.png" v-if="scope.row.starList_mark>8" class="starSty">
							<b style="font-size: 15px;color: #b77614;" v-if="scope.row.starList_mark>8">×
								{{scope.row.starList_mark}}</b>
						</p>
					</template>
				</el-table-column>
				<!-- <el-table-column label="Remarks" width="180">
					<template slot-scope="scope">
						{{scope.row.remark}}
						<b @click="BoxRemark(scope.row)" style="margin-left:10px;cursor: pointer;color:#006699;"
							class="el-icon-edit"></b>
					</template>
				</el-table-column> -->
				<el-table-column label="" width="190" align="center">
					<template slot-scope="scope">
						<el-button size="mini" type="primary" plain icon="el-icon-edit"
							@click="handleEdit(scope.$index, scope.row)">Edit</el-button>
						<el-button size="mini" type="danger" plain icon="el-icon-delete"
							@click="handleDelete(scope.$index, scope.row)">Delete</el-button>
					</template>
				</el-table-column>
			</el-table>
			<p class="shen_fen" v-if="tableData_B.length!=0">Vice Editor-in-Chief</p>
			<el-table :data="tableData_B" border stripe class="table" ref="multipleTable"
				header-cell-class-name="table-header" empty-text="New messages (0)" :show-header="false"
				v-if="tableData_B.length!=0">
				<el-table-column prop="name" label="Realname">
					<template slot-scope="scope">
						<p @click="perSonnel(scope.row.tuser_id)" class="perSonGo">{{scope.row.name}}</p>
					</template>
				</el-table-column>
				<el-table-column prop="email" label="Email"></el-table-column>
				<el-table-column prop="hindex" label="H-WOS" width="110px" align="center">
					<template slot-scope="scope">
						<p v-html="colorIndex(scope.row.wos_index,scope.row.wos_time)"></p>
					</template>
				</el-table-column>
				<el-table-column prop="ghindex" label="H-Google" width="110px" align="center">
					<template slot-scope="scope">
						<p v-html="colorIndex(scope.row.google_index,scope.row.google_time)"></p>
					</template>
				</el-table-column>
				<el-table-column label="Grade" width="110px" align="center">
					<template slot-scope="scope">
						<p style="display: inline-block;" v-if="scope.row.starList_mark!=0">
							<img src="../../assets/img/star-all.png" v-for="item in scope.row.starList"
								v-if="scope.row.starList_mark<=8&&item.star==1" class="starSty">
							<img src="../../assets/img/star-traf.png" v-for="item in scope.row.starList"
								v-if="scope.row.starList_mark<=8&&item.star==0" class="starSty">
							<img src="../../assets/img/star-none.png" v-for="item in scope.row.starList"
								v-if="scope.row.starList_mark<=8&&item.star==2" class="starSty">
							<img src="../../assets/img/star-all.png" v-if="scope.row.starList_mark>8" class="starSty">
							<b style="font-size: 15px;color: #b77614;" v-if="scope.row.starList_mark>8">×
								{{scope.row.starList_mark}}</b>
						</p>
					</template>
				</el-table-column>
				<!-- <el-table-column label="Remarks" width="180">
					<template slot-scope="scope">
						{{scope.row.remark}}
						<b @click="BoxRemark(scope.row)" style="margin-left:10px;cursor: pointer;color:#006699;"
							class="el-icon-edit"></b>
					</template>
				</el-table-column> -->
				<el-table-column label="" width="190" align="center">
					<template slot-scope="scope">
						<el-button size="mini" type="primary" plain icon="el-icon-edit"
							@click="handleEdit(scope.$index, scope.row)">Edit</el-button>
						<el-button size="mini" type="danger" plain icon="el-icon-delete"
							@click="handleDelete(scope.$index, scope.row)">Delete</el-button>
					</template>
				</el-table-column>
			</el-table>
			<p class="shen_fen" v-if="tableData_C.length!=0">Editorial Board Members</p>
			<div v-for="(item,key) in tableData_C" v-if="tableData_C.length!=0">
				<p class="shen_number">{{key}}</p>
				<el-table :data="item" border stripe class="table" ref="multipleTable" :show-header="false"
					header-cell-class-name="table-header" empty-text="New messages (0)" style="margin-bottom: 20px;">
					<el-table-column prop="name" label="Realname">
						<template slot-scope="scope">
							<p @click="perSonnel(scope.row.tuser_id)" class="perSonGo">{{scope.row.name}}</p>
						</template>
					</el-table-column>
					<el-table-column prop="email" label="Email"></el-table-column>
					<el-table-column prop="hindex" label="H-WOS" width="110px" align="center">
						<template slot-scope="scope">
							<p v-html="colorIndex(scope.row.wos_index,scope.row.wos_time)"></p>
						</template>
					</el-table-column>
					<el-table-column prop="ghindex" label="H-Google" width="110px" align="center">
						<template slot-scope="scope">
							<p v-html="colorIndex(scope.row.google_index,scope.row.google_time)"></p>
						</template>
					</el-table-column>
					<el-table-column label="Grade" width="110px" align="center">
						<template slot-scope="scope">
							<p style="display: inline-block;" v-if="scope.row.starList_mark!=0">
								<img src="../../assets/img/star-all.png" v-for="item in scope.row.starList"
									v-if="scope.row.starList_mark<=8&&item.star==1" class="starSty">
								<img src="../../assets/img/star-traf.png" v-for="item in scope.row.starList"
									v-if="scope.row.starList_mark<=8&&item.star==0" class="starSty">
								<img src="../../assets/img/star-none.png" v-for="item in scope.row.starList"
									v-if="scope.row.starList_mark<=8&&item.star==2" class="starSty">
								<img src="../../assets/img/star-all.png" v-if="scope.row.starList_mark>8"
									class="starSty">
								<b style="font-size: 15px;color: #b77614;" v-if="scope.row.starList_mark>8">×
									{{scope.row.starList_mark}}</b>
							</p>
						</template>
					</el-table-column>
					<!-- <el-table-column label="Remarks" width="180">
						<template slot-scope="scope">
							{{scope.row.remark}}
							<b @click="BoxRemark(scope.row)" style="margin-left:10px;cursor: pointer;color:#006699;"
								class="el-icon-edit"></b>
						</template>
					</el-table-column> -->
					<el-table-column label="" width="190" align="center">
						<template slot-scope="scope">
							<el-button size="mini" type="primary" plain icon="el-icon-edit"
								@click="handleEdit(scope.$index, scope.row)">Edit</el-button>
							<el-button size="mini" type="danger" plain icon="el-icon-delete"
								@click="handleDelete(scope.$index, scope.row)">Delete</el-button>
						</template>
					</el-table-column>
				</el-table>
			</div>

		</div>

		<!-- 添加弹出框 -->
		<el-dialog title="Add Editorial board" :visible.sync="addVisible" width="750px" :close-on-click-modal="false"
			@close='addVisCancle'>
			<el-form ref="add_Form" :model="addForm" :rules="rules" label-width="150px" v-if="!dis_able">
				<el-form-item label="Email :" prop="email" v-if="!dis_able">
					<el-input v-model="addForm.email" style="width: 300px;"></el-input>
					<el-button type="warning" @click="saerNa_U()" style="margin-left: 15px;" icon="el-icon-paperclip">
						Check</el-button>
					<p style="color: #888;margin-top: 10px;">
						Note: The new editorial board must be a registered user. Click
						<a class="zhu_ce" @click="Goto_res()">register</a>.
					</p>
				</el-form-item>
			</el-form>
			<el-form ref="add_Form" :model="addForm" :rules="rules" label-width="150px" v-if="dis_able">
				<el-form-item label="Email :">
					{{addForm.email}}
				</el-form-item>
				<el-form-item label="Account :" prop="account">
					{{addForm.account}}
				</el-form-item>
				<el-form-item label="Realname :" prop="name">
					<el-input v-model="addForm.name" style="width: 300px;"></el-input>
				</el-form-item>
				<el-form-item label="Picture :">
					<span slot="label">
						<i style="color: #F56C6C;">*</i>
						Picture
					</span>
					<el-upload class="avatar-uploader" :action="baseUrl+'api/Board/up_boardIcon_file'"
						:show-file-list="false" name="boardIcon" :on-success="handleAvatarSuccess"
						:on-error="handleAvatarError" :before-upload="beforeAvatarUpload">
						<img v-if="imageUrl" :src="imageUrl" class="avatar">
						<i v-else class="el-icon-plus avatar-uploader-icon"></i>
					</el-upload>
				</el-form-item>
				<el-form-item label="Journal :" prop="journal_id">
					<el-select v-model="addForm.journal_id" placeholder="Please select a journal" @change="getJourAdd()"
						style="width: 300px;">
						<el-option v-for="item in add_jour" :label="item.title" :key="item.journal_id"
							:value="item.journal_id"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="Identity :" prop="type">
					<el-radio-group v-model="addForm.type">
						<el-radio :label="0">Editor-in-Chief</el-radio>
						<el-radio :label="1">Vice Editor-in-Chief</el-radio>
						<el-radio :label="2">Editorial Board Members</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="Group :" prop="board_group_id" v-if="addForm.type==2">
					<el-select v-model="addForm.board_group_id" placeholder="Please select a group"
						style="width: 300px;">
						<el-option v-for="item in add_group" :label="item.group_name" :key="item.board_group_id"
							:value="item.board_group_id"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="Homepage :" prop="website">
					<el-input v-model="addForm.website"></el-input>
				</el-form-item>
				<el-form-item label="Academic degree :" prop="dr">
					<el-input v-model="addForm.dr"></el-input>
				</el-form-item>
				<el-form-item label="Technical :" prop="title">
					<el-select v-model="addForm.title" placeholder="Please select a technical" style="width: 300px;">
						<el-option v-for="item in title_options" :key="item.value" :label="item.value"
							:value="item.value"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="Affiliation :" prop="address">
					<el-input v-model="addForm.address"></el-input>
				</el-form-item>
				<el-form-item label="Country :" prop="country">
					<el-select v-model="addForm.country" filterable placeholder="Please select a country"
						value-key="groupID" style="width: 300px;">
						<el-option v-for="item in add_country" :label="item.en_name" :key="item.en_name"
							:value="item.en_name"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="Field :" prop="field">
					<el-input v-model="addForm.field" type="textarea" rows="5"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="addVisible = false">Cancel</el-button>
				<el-button type="primary" @click="saveAdd()" v-if="dis_able">OK</el-button>
			</span>
		</el-dialog>



		<!-- 编辑弹出框 -->
		<el-dialog title="Edit Editorial board" :visible.sync="editVisible" width="750px">
			<el-form ref="edit_Form" :model="editForm" :rules="rules" label-width="150px">
				<el-form-item label="Email :">
					{{editForm.email}}
				</el-form-item>
				<el-form-item label="Realname :" prop="name">
					<el-input v-model="editForm.name" style="width: 300px;"></el-input>
				</el-form-item>
				<el-form-item label="Picture :">
					<span slot="label">
						<i style="color: #F56C6C;">*</i>
						Picture
					</span>
					<el-upload class="avatar-uploader" :action="baseUrl+'api/Board/up_boardIcon_file'"
						:show-file-list="false" name="boardIcon" :on-success="handleAvatarSuccess_"
						:on-error="handleAvatarError_" :before-upload="beforeAvatarUpload_">
						<img v-if="imageUrl_" :src="imageUrl_" class="avatar">
						<i v-else class="el-icon-plus avatar-uploader-icon"></i>
					</el-upload>
				</el-form-item>
				<el-form-item label="Journal :">
					{{query.journal_title}}
					<!-- 					<el-select v-model="editForm.journal_id" placeholder="Please select a journal"
						@change="getJourEdit(editForm.journal_id)" style="width: 300px;">
						<el-option v-for="item in add_jour" :label="item.title" :key="item.journal_id"
							:value="item.journal_id"></el-option>
					</el-select> -->
				</el-form-item>
				<el-form-item label="Identity :" prop="type">
					<el-radio-group v-model="editForm.type">
						<el-radio :label="0">Editor-in-Chief</el-radio>
						<el-radio :label="1">Vice Editor-in-Chief</el-radio>
						<el-radio :label="2">Editorial Board Members</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="Group :" prop="board_group_id" v-if="editForm.type==2">
					<el-select v-model="editForm.board_group_id" placeholder="Please select a group"
						style="width: 300px;">
						<el-option v-for="item in edit_group" :label="item.group_name" :key="item.board_group_id"
							:value="item.board_group_id"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="Homepage :" prop="website">
					<el-input v-model="editForm.website"></el-input>
				</el-form-item>
				<el-form-item label="Academic degree :" prop="dr">
					<el-input v-model="editForm.dr"></el-input>
				</el-form-item>
				<el-form-item label="Technical :" prop="title">
					<el-select v-model="editForm.title" placeholder="Please select a technical" style="width: 300px;">
						<el-option v-for="item in title_options" :key="item.value" :label="item.value"
							:value="item.value"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="Affiliation :" prop="address">
					<el-input v-model="editForm.address"></el-input>
				</el-form-item>
				<el-form-item label="Country :" prop="country">
					<el-select v-model="editForm.country" filterable placeholder="Please select a country"
						value-key="groupID" style="width: 300px;">
						<el-option v-for="item in add_country" :label="item.en_name" :key="item.en_name"
							:value="item.en_name"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="Field :" prop="field">
					<el-input v-model="editForm.field" type="textarea" autosize></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="editVisible = false">Cancel</el-button>
				<el-button type="primary" @click="saveEdit()">OK</el-button>
			</span>
		</el-dialog>
		
		
		<!-- 标记弹出框 -->
		<el-dialog title="Remarks" :visible.sync="remarkBox" width="550px">
			<el-form ref="remark" :model="remarkMes" label-width="130px">
				<el-form-item label="Editorial board :">
					<p style="line-height: 20px;margin-top: 6px;">{{remarkMes.realname}}</p>
				</el-form-item>
				<el-form-item label="Email :">
					<p style="line-height: 20px;margin-top: 6px;">{{remarkMes.email}}</p>
				</el-form-item>
				<el-form-item label="Content :">
					<el-input type="textarea" rows="5" v-model="remarkMes.remark"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="remarkBox = false">Cancel</el-button>
				<el-button type="primary" @click="saveRemark">Save</el-button>
			</span>
		</el-dialog>


	</div>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: this.Common.baseUrl,
				edit_id: localStorage.getItem('U_id'),
				now_year: 0,
				tableData_0: [],
				tableData_A: [],
				tableData_B: [],
				tableData_C: [],
				df_jour: [],
				df_group: [],
				add_jour: [],
				add_group: [],
				add_country: [],
				addVisible: false,
				editVisible: false,
				addForm: {
					email: '',
					board_group_id: -1
				},
				editForm: {
					journal_id: 0
				},
				edit_group: [],
				dis_able: false,
				remarkMes: {
					remark: ''
				},
				remarkBox: false,
				query: {
					journal_id: 0,
					journal_title: '',
				},
				imageUrl: '',
				imageUrl_: '',
				imageUrl_Mark: 0,
				title_options: [{
						value: 'Instructor'
					},
					{
						value: 'Assistant Professor'
					},
					{
						value: 'Senior Assistant Professor'
					},
					{
						value: 'Associate Professor'
					},
					{
						value: 'Senior Associate professor'
					},
					{
						value: 'Professor'
					},
					{
						value: 'Researcher'
					},
					{
						value: 'Associate Researcher'
					},
					{
						value: 'Assistant Researcher'
					},
					{
						value: 'RN'
					},
					{
						value: 'Research Fellow'
					},
					{
						value: 'Associate Research Scientist'
					},
					{
						value: 'Research Scientist'
					},
					{
						value: 'Senior Research Fellow'
					},
					{
						value: 'Senior Lecturer'
					},
					{
						value: 'Physician'
					},
					{
						value: 'Attending Physician'
					},
					{
						value: 'Associate Chief Physician'
					},
					{
						value: 'Chief Physician'
					},
					{
						value: 'Senior Research Scientist'
					},
					{
						value: 'Honorary Senior Research Fellow'
					},
					{
						value: 'Director'
					},
					{
						value: 'Executive Director'
					},
					{
						value: 'Sr. Bioinformatics Scientist'
					},
					{
						value: 'Psychotherapist'
					},
					{
						value: 'Postdoctoral Researcher'
					},
					{
						value: 'Managing Editor'
					},
					{
						value: 'Scientific Editor'
					},
					{
						value: 'Production Editor'
					},
					{
						value: 'Assistant Editor'
					},
					{
						value: 'Engineer'
					},
					{
						value: 'Lecturer'
					},
					{
						value: 'Investigator'
					},
					{
						value: 'Senior Investigator'
					},
					{
						value: '教授'
					},
					{
						value: '副教授'
					},
					{
						value: '讲师'
					},
					{
						value: '主任医师'
					},
					{
						value: '副主任医师'
					},
					{
						value: '主治医师'
					},
					{
						value: '主任中医师'
					},
					{
						value: '副主任中医师'
					}
				],
				rules: {
					account: [{
						required: true,
						message: 'Please input account',
						trigger: 'blur'
					}],
					email: [{
						required: true,
						message: 'Please input email',
						trigger: 'blur'
					}, {
						validator: function(rule, value, callback) {
							if (/^[-.-_A-Za-z0-9]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value) == false) {
								callback(new Error("Please enter the correct email format"));
							} else {
								callback();
							}
						},
						trigger: "blur"
					}],
					name: [{
						required: true,
						message: 'Please input realname',
						trigger: 'blur'
					}],
					journal_id: [{
						required: true,
						message: 'Please select a journal',
						trigger: 'blur'
					}],
					board_group_id: [{
						required: true,
						message: 'Please select a group',
						trigger: 'blur'
					}],
					website: [{
						required: true,
						message: 'Please input website',
						trigger: 'blur'
					}],
					type: [{
						required: true,
						message: 'Please input type',
						trigger: 'blur'
					}],
					dr: [{
						required: true,
						message: 'Please input academic degree',
						trigger: 'blur'
					}],
					title: [{
						required: true,
						message: 'Please input technical',
						trigger: 'blur'
					}],
					field: [{
						required: true,
						message: 'Please input field ',
						trigger: 'blur'
					}],
					board_icon: [{
						required: true,
						message: 'Please select a icon',
						trigger: 'blur'
					}],
					address: [{
						required: true,
						message: 'Please input affiliation',
						trigger: 'blur'
					}],
					country: [{
						required: true,
						message: 'Please select a country',
						trigger: 'blur'
					}],
				}
			};
		},
		created() {
			this.getjour();
		},
		methods: {
			// 获取编委和负责期刊列表数据
			getDate() {
				const loading = this.$loading({
					lock: true,
					text: 'Loading...',
					spinner: 'el-icon-loading',
					background: 'rgba(0, 0, 0, 0.7)'
				});
				this.$api
					.post('api/Board/getBoards', this.query)
					.then(res => {
						if (res.code == 0) {
							if (res.data.boards.main != undefined) {
								this.tableData_A = res.data.boards.main;
								for (var i = 0; i < this.tableData_A.length; i++) {
									this.getScoreDataA(i, this.tableData_A[i].score)
								}
							} else {
								this.tableData_A = []
							}
							if (res.data.boards.remain != undefined) {
								this.tableData_B = res.data.boards.remain;
								for (var i = 0; i < this.tableData_B.length; i++) {
									this.getScoreDataB(i, this.tableData_B[i].score)
								}
							} else {
								this.tableData_B = []
							}
							if (res.data.boards.member != undefined) {
								this.tableData_C = res.data.boards.member;
								for (var i = 0; i < this.tableData_C.length; i++) {
									this.getScoreDataC(i, this.tableData_C[i].score)
								}
							} else {
								this.tableData_C = []
							}
							loading.close();

						} else {
							this.$message.error(res.msg);
							loading.close();
						}

					})
					.catch(err => {
						this.$message.error(err);
						loading.close();
					});

			},
			getjour() {
				this.now_year = new Date().getFullYear()
				this.$api
					.post('api/Chief/getJournalsByEditor', {
						'user_id': this.edit_id
					})
					.then(res => {
						if (res.code == 0) {
							this.df_jour = res.data.journals;
							this.add_jour = res.data.journals;
							this.query.journal_id = this.df_jour[0].journal_id
							this.query.journal_title = this.df_jour[0].title
							this.getgroup();
						} else {
							this.$message.error(res.msg);
						}
					})
					.catch(err => {
						this.$message.error(err);
					});


				this.$api
					.post('api/Reviewer/getCountrys')
					.then(res => {
						this.add_country = res.countrys;
					})
					.catch(err => {
						this.$message.error(err);
					});
			},

			getgroup() {
				this.$api
					.post('api/Board/getBoardGroupList', {
						journal_id: this.query.journal_id
					})
					.then(res => {
						if (res.code == 0) {
							this.edit_group = JSON.parse(JSON.stringify(res.data.groups));
							this.edit_group.unshift({
								'board_group_id': 0,
								'group_name': 'No Group'
							})

							this.df_group = Object.assign(res.data.groups);
							this.df_group.unshift({
								'board_group_id': -1,
								'group_name': 'All Group'
							}, {
								'board_group_id': 0,
								'group_name': 'No Group'
							})
							this.query.board_group_id = -1
							this.getDate()

						} else {
							this.$message.error(res.msg);
						}
					})
					.catch(err => {
						this.$message.error(err);
					});
			},

			getJourdate() {
				for (let i = 0; i < this.df_jour.length; i++) {
					if (this.df_jour[i].journal_id == this.query.journal_id) {
						this.query.journal_title = this.df_jour[i].title
					}
				}
				this.getgroup()
			},


			// 评分
			getScoreDataA(i, e) {
				this.tableData_A[i].starList = []
				this.tableData_A[i].starList_mark = 0
				if (e < 0.5 && e > 0) {
					this.tableData_A[i].starList.push({
						star: 2
					})
					this.tableData_A[i].starList_mark = 1
				} else {
					let zheng = Math.floor(e)
					let xiao = Number(e) - Math.floor(e)
					if (xiao >= 0.5) {
						xiao = 0.5
					} else {
						xiao = 0
					}
					for (var j = 0; j < zheng; j++) {
						this.tableData_A[i].starList.push({
							star: 1
						})
					}
					if (xiao == 0.5) {
						this.tableData_A[i].starList.push({
							star: 0
						})
					}
					this.tableData_A[i].starList_mark = Number(zheng) + Number(xiao)
				}

			},

			getScoreDataB(i, e) {
				this.tableData_B[i].starList = []
				this.tableData_B[i].starList_mark = 0
				if (e < 0.5 && e > 0) {
					this.tableData_B[i].starList.push({
						star: 2
					})
					this.tableData_B[i].starList_mark = 1
				} else {
					let zheng = Math.floor(e)
					let xiao = Number(e) - Math.floor(e)
					if (xiao >= 0.5) {
						xiao = 0.5
					} else {
						xiao = 0
					}
					for (var j = 0; j < zheng; j++) {
						this.tableData_B[i].starList.push({
							star: 1
						})
					}
					if (xiao == 0.5) {
						this.tableData_B[i].starList.push({
							star: 0
						})
					}
					this.tableData_B[i].starList_mark = Number(zheng) + Number(xiao)
				}
			},
			getScoreDataC(i, e) {
				this.tableData_C[i].starList = []
				this.tableData_C[i].starList_mark = 0
				if (e < 0.5 && e > 0) {
					this.tableData_C[i].starList.push({
						star: 2
					})
					this.tableData_C[i].starList_mark = 1
				} else {
					let zheng = Math.floor(e)
					let xiao = Number(e) - Math.floor(e)
					if (xiao >= 0.5) {
						xiao = 0.5
					} else {
						xiao = 0
					}
					for (var j = 0; j < zheng; j++) {
						this.tableData_C[i].starList.push({
							star: 1
						})
					}
					if (xiao == 0.5) {
						this.tableData_C[i].starList.push({
							star: 0
						})
					}
					this.tableData_C[i].starList_mark = Number(zheng) + Number(xiao)
				}
			},
			// 分组管理
			addGroup() {
				this.$router.push('/editorGroup');
			},

			// 用户跳转
			perSonnel(e) {
				let routerJump = this.$router.resolve({
					path: '/partyRole',
					query: {
						id: e
					}
				});
				window.open(routerJump.href, '_blank');
			},


			// 添加操作
			addEditor(index, row) {
				this.addForm.journal_id = this.add_jour[0].journal_id
				this.getJourAdd()
				this.addVisible = true;
			},

			// 改变期刊
			getJourAdd() {
				this.$api
					.post('api/Board/getBoardGroupList', {
						journal_id: this.addForm.journal_id
					})
					.then(res => {
						if (res.code == 0) {
							this.add_group = res.data.groups;
							this.add_group.unshift({
								'board_group_id': 0,
								'group_name': 'No Group'
							})
							this.addForm.board_group_id = 0
						} else {
							this.$message.error(res.msg);
						}
					})
					.catch(err => {
						this.$message.error(err);
					});
			},


			// 查找账号
			saerNa_U() {
				if (this.addForm.email != '') {
					this.$api
						.post('api/Chief/checkEmailForUser', {
							'email': this.addForm.email
						})
						.then(res => {
							if (res.code == 0) {
								if (res.data.user_info == null) {
									this.$message.error('No email, please fill in or register again!');
								} else {
									this.$message.success('Validation succeeded!');
									this.dis_able = true
									this.addForm.user_id = res.data.user_info.user_id
									this.addForm.account = res.data.user_info.account
									this.addForm.email = res.data.user_info.email
									this.addForm.name = res.data.user_info.realname
								}
							} else {
								this.$message.error(res.msg);
							}
						})
						.catch(err => {
							this.$message.error(err);
						});
				} else {
					this.$message.error('Please fill in the email address!');
				}
			},

			// 保存添加
			saveAdd() {
				this.$refs.add_Form.validate((valid) => {
					if (valid) {
						if (this.addForm.board_icon == '' || this.addForm.board_icon == undefined) {
							this.$message.error('Please upload the picture!');
							return
						}
						this.$api
							.post('api/Board/addBoard', this.addForm)
							.then(res => {
								if (res.code == 0) {
									this.addVisible = false;
									this.$refs.add_Form.resetFields();
									this.$message.success(`Added successfully！`);
									this.dis_able = false
									this.getDate();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});
					} else {
						return false;
					}
				});
			},

			// 添加关闭
			addVisCancle() {
				this.$refs.add_Form.resetFields();
				this.addForm.email = ''
				this.dis_able = false
			},

			// 编辑操作
			handleEdit(index, row) {
				this.editForm = Object.assign({}, row);
				this.imageUrl_ = this.baseUrl + 'journalpublic/' + this.editForm.board_icon
				this.imageUrl_Mark = 0
				this.editVisible = true
				// this.getJourEdit(this.query.journal_id)
			},

			// 改变期刊
			getJourEdit(e) {
				this.$api
					.post('api/Board/getBoardGroupList', {
						journal_id: e
					})
					.then(res => {
						if (res.code == 0) {
							this.edit_group = res.data.groups;
							this.edit_group.unshift({
								'board_group_id': 0,
								'group_name': 'No Group'
							})
						} else {
							this.$message.error(res.msg);
						}
					})
					.catch(err => {
						this.$message.error(err);
					});
			},

			// 保存编辑
			saveEdit() {
				this.$refs.edit_Form.validate((valid) => {
					if (valid) {
						this.$api
							.post('api/Board/editBoard', this.editForm)
							.then(res => {
								if (res.code == 0) {
									this.editVisible = false;
									this.$refs.edit_Form.resetFields();
									this.$message.success(`Edit successfully！`);
									this.getDate();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});

						if (this.imageUrl_Mark == 1) {
							this.$api
								.post('api/Board/editIcon', this.editForm)
								.then(res => {
									if (res.code == 0) {
										this.imageUrl_Mark = 0
									} else {
										this.$message.error(res.msg);
									}
								})
								.catch(err => {
									this.$message.error(err);
								});
						}
					} else {
						return false;
					}
				});
			},


			// 删除操作
			handleDelete(index, row) {
				// 二次确认删除
				this.$confirm('Are you sure you want to delete?', 'Tips', {
						type: 'warning'
					})
					.then(() => {
						this.$api
							.post('api/Board/delBoard', row)
							.then(res => {
								if (res.code == 0) {
									this.$message.success('Delete succeeded');
									this.getDate();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});
					})
					.catch(() => {});
			},

			// 点击注册
			Goto_res() {
				this.$router.push('/register');
			},
			
			// 标记弹出框
			BoxRemark(e) {
				this.remarkBox = true;
				this.remarkMes.realname = e.name;
				this.remarkMes.user_id = e.tuser_id;
				this.remarkMes.email = e.email;
				this.remarkMes.remark = e.remark;
			},
			// 修改标记
			saveRemark() {
				this.$api.post('api/User/editRemarkForUser', this.remarkMes)
					.then(res => {
						if (res.code == 0) {
							this.$message.success('Success');
							this.remarkBox = false;
							this.getDate();
						} else {
							this.$message.error(res.msg);
						}
					});
			},


			// 指数颜色
			colorIndex(num, time) {
				if (time != 0) {
					let date = new Date(parseInt(time * 1000));
					let Y = date.getFullYear() + '-';
					let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-';
					let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
					let H = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
					let U = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
					time = Y + M + D;
				}
				let str = '';
				if (num < 10) {
					str = '<b style="color:#cb160a">' + num +
						'</b><span style="color:#aaa;font-size:14px;margin-left:5px;"><br/>(' + time +
						')</span>'
				} else if (num < 15) {
					str = '<b style="color:#cbb504">' + num +
						'</b><span style="color:#aaa;font-size:14px;margin-left:5px;"><br/>(' + time +
						')</span>'
				} else {
					str = '<b style="color:#0cbc15">' + num +
						'</b><span style="color:#aaa;font-size:14px;margin-left:5px;"><br/>(' + time +
						')</span>'
				}
				if (time == 0) {
					str =
						'<b style="color:#aaa;">0</b><br/><span style="color:#aaa;font-size:14px;margin-left:5px;">(No time)</span>'
				}
				return str;
			},

			//上传图片-添加
			handleAvatarSuccess(res, file) {
				if (res.code == 0) {
					this.addForm.board_icon = res.upurl;
				} else {
					this.$message.error(res.msg);
				}
				this.imageUrl = URL.createObjectURL(file.raw);
			},
			handleAvatarError(res, file) {
				// this.$message.error(res);
			},
			beforeAvatarUpload(file) {
				const isLt2M = file.size / 1024 / 1024 < 1;
				if (!isLt2M) {
					this.$message.error('The picture size cannot exceed 1M!');
				}
				return isLt2M;
			},

			//上传图片-编辑
			handleAvatarSuccess_(res, file) {
				if (res.code == 0) {
					this.editForm.board_icon = res.upurl;
					// this.imageUrl_ = this.baseUrl + 'boardIcon/' + res.upurl;
					this.imageUrl_Mark = 1
				} else {
					this.$message.error(res.msg);
				}
				this.imageUrl_ = URL.createObjectURL(file.raw);
			},
			handleAvatarError_(res, file) {
				// this.$message.error(res);
			},
			beforeAvatarUpload_(file) {
				const isLt2M = file.size / 1024 / 1024 < 1;
				if (!isLt2M) {
					this.$message.error('The picture size cannot exceed 1M!');
				}
				return isLt2M;
			},
		}
	};
</script>

<style scoped>
	.handle-box {
		margin-bottom: 20px;
	}

	.table {
		width: 100%;
		font-size: 14px;
	}

	.red {
		color: #ff0000;
	}

	.zhu_ce {
		text-decoration: underline;
		color: #006699;
		font-weight: bold;
		cursor: pointer;
	}

	.biaoTou {
		background-color: #006699;
		font-size: 14px;
		min-width: 800px;
	}

	.nullTable {
		margin-bottom: 20px;
	}


	.shen_fen {
		margin: 30px 0 20px 0;
		font-weight: bold;
		letter-spacing: -0.5px;
	}

	.shen_number {
		margin-bottom: 15px;
		margin-left: 5px;
	}

	.perSonGo:hover {
		text-decoration: underline;
		color: #006699;
		cursor: pointer;
	}

	.starSty {
		width: 18px;
		margin-right: 4px;
		vertical-align: text-top;
	}

	.starSty:nth-last-child(1) {
		margin-right: 0;
	}

	.avatar-uploader .el-upload {
		border: 1px dashed #d9d9d9;
		border-radius: 6px;
		cursor: pointer;
		position: relative;
		overflow: hidden;
		width: 140px;
		height: 140px;
	}

	.avatar-uploader_small {
		height: 140px;
	}

	.avatar-uploader .el-upload:hover {
		border-color: #409EFF;
	}

	.avatar-uploader-icon {
		font-size: 28px;
		color: #8c939d;
		width: 140px;
		height: 140px;
		line-height: 140px;
		text-align: center;
	}

	.avatar-uploader_small .el-upload {
		width: 80px;
		height: 80px;
	}

	.avatar-uploader_small .avatar-uploader-icon {
		line-height: 80px;
		margin-left: -30px;
	}

	.avatar {
		width: 140px;
		height: 140px;
		display: block;
	}
</style>
