<template>
	<div>
		<div class="crumbs">
			<el-breadcrumb separator="/">
				<el-breadcrumb-item>
					<i class="el-icon-box"></i> Reviewer list
				</el-breadcrumb-item>
			</el-breadcrumb>
		</div>
		<div class="container">
			<div class="handle-box">
				<el-button type="primary" icon="el-icon-plus" class="handle-del" @click="add_Selection">Add</el-button>
			</div>
			<div class="handle-box">
				<el-select v-model="query.journalId" placeholder="Please select a journal" @change="getContent">
					<el-option label="All journal" :key="0" :value="0"></el-option>
					<el-option v-for="item in df_jour" :label="item.title" :key="item.journal_id" :value="item.journal_id"></el-option>
				</el-select>
				<el-input v-model="query.keyword" placeholder="Please enter ..." style="width: 220px;margin: 0 15px;"></el-input>
				<el-button type="primary" icon="el-icon-search" @click="getContent">Search</el-button>
			</div>
			<el-table :data="tableData" border class="table" ref="multipleTable" header-cell-class-name="table-header" empty-text="New messages (0)">
				<el-table-column prop="account" label="Account"></el-table-column>
				<el-table-column prop="realname" label="Realname"></el-table-column>
				<el-table-column prop="journal_title" label="Journal"></el-table-column>
				<el-table-column prop="email" label="Email"></el-table-column>
				<el-table-column prop="technical" label="Technical"></el-table-column>
				<el-table-column prop="company" label="Affiliation"></el-table-column>
				<el-table-column prop="board" label="Youth editorial board" width="80" align="center">
					<template slot-scope="scope">
						<el-button icon="el-icon-check" type="text" style="color: #0fa31d" v-if="scope.row.is_yboard=='1'"></el-button>
						<el-button icon="el-icon-close" type="text" style="color: #ff0000" v-if="scope.row.is_yboard=='0'"></el-button>
					</template>
				</el-table-column>
				<el-table-column label="CV" width="50" align="center"><template slot-scope="scope">
						<el-button icon="el-icon-check" type="text" style="color: #0fa31d" v-if="scope.row.qualifications!=''"></el-button>
						<el-button icon="el-icon-close" type="text" style="color: #ff0000" v-if="scope.row.qualifications==''"></el-button>
					</template>
				</el-table-column>
				<el-table-column label="" width="320" align="center">
					<template slot-scope="scope">
						<el-button size="mini" type="success" plain icon="el-icon-sort-up" @click="gradeup(scope.row)" v-if="scope.row.is_yboard=='0'">Upgrade</el-button>
						<el-button size="mini" type="warning" plain icon="el-icon-sort-down" @click="gradedown(scope.row)" v-if="scope.row.is_yboard=='1'">downgrade</el-button>
						<el-button size="mini" type="primary" plain icon="el-icon-tickets" @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
						<el-button size="mini" type="danger" plain icon="el-icon-delete" @click="showDelete(scope.row)">Delete</el-button>
					</template>
				</el-table-column>
			</el-table>
			<div class="pagination">
				<el-pagination background layout="total, prev, pager, next" :current-page="query.pageIndex" :page-size="query.pageSize"
				 :total="link_Total" @current-change="handlePageChange"></el-pagination>
			</div>
		</div>

		<!-- 添加弹出框 -->
		<el-dialog title="Add" :visible.sync="addVisible" width="40%" :close-on-click-modal="false">
			<el-form ref="add_Form" :model="addForm" :rules="rules" label-width="110px">
				<el-form-item label="account" prop="account">
					<el-input v-model="addForm.account" @blur='saerNa_U()'></el-input>
				</el-form-item>
				<el-form-item label="email" prop="email">
					<el-input v-model="addForm.email" @blur='saerEm_U()'></el-input>
				</el-form-item>
				<el-form-item label="password" prop="password">
					<span style="color: #666;">123456qwe</span>
				</el-form-item>
				<el-form-item label="gender" prop="gender">
					<el-radio-group v-model="addForm.gender">
						<el-radio :label="1">male</el-radio>
						<el-radio :label="2">female</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="journal" prop="journal_id">
					<el-select v-model="addForm.journal_id" placeholder="Please select a journal">
						<el-option v-for="item in df_jour" :label="item.title" :key="item.journal_id" :value="item.journal_id"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="title" prop="title">
					<el-select v-model="addForm.title" filterable placeholder="Please select a title" value-key="groupID" style="width: 300px;">
						<el-option v-for="item in df_technical" :key="item.label" :label="item.label" :value="item.label"></el-option>
					</el-select>
				</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 df_country" :label="item.en_name" :key="item.en_name" :value="item.en_name"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="realname" prop="realname">
					<el-input v-model="addForm.realname"></el-input>
				</el-form-item>
				<el-form-item label="orcid">
					<el-input v-model="addForm.orcid"></el-input>
				</el-form-item>
				<el-form-item label="introduction">
					<el-input v-model="addForm.introduction" type="textarea"></el-input>
				</el-form-item>
				<el-form-item label="affiliation">
					<el-input v-model="addForm.company"></el-input>
				</el-form-item>
				<el-form-item label="major" prop="maj_cn">
					<el-cascader v-model="addForm.maj_cn" :options="jl_major" :props="defaultParams" placeholder="Please select major"
					 @change="ched_id" style="width: 300px;"></el-cascader>
				</el-form-item>
				<el-form-item label="field" prop="field">
					<el-input v-model="addForm.field" type="textarea"></el-input>
				</el-form-item>
				<!-- 简历 -->
				<el-form-item prop="qualifications" label="CV.">
					<el-upload class="upload-demo" :action="baseUrl+'api/Reviewer/up_cv_file'" :on-success="handleFileSuccess1" name="reviewerCV"
					 type="reviewerCV" :on-error="handleFileError" :on-preview="handlePreview" :on-remove="handleRemove"
					 :before-remove="beforeRemove" :on-change="handleChange1" accept=".pdf" :on-exceed="handleExceed" :file-list="fileL_pdf1"
					 ref="upload">
						<el-button type="text" style="font-weight: bolder;"><b class="el-icon-lx-top" style="font-weight: bolder;"></b>upload</el-button>
					</el-upload>
					<span style="font-size: 12px; color: #aaa;">Only compressed files can be uploaded(.pdf)</span>
				</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(addForm)" :disabled="this.btn_alert">OK</el-button>
			</span>
		</el-dialog>

		<!-- 添加重复弹出框 -->
		<el-dialog title="Add old" :visible.sync="oldVisible" width="40%" :close-on-click-modal="false">
			<el-form ref="old_Form" :model="oldForm" :rules="rules" label-width="110px">
				<el-form-item label="account" prop="account">
					<el-input v-model="oldForm.account"></el-input>
				</el-form-item>
				<el-form-item label="email" prop="email">
					<el-input v-model="oldForm.email"></el-input>
				</el-form-item>
				<el-form-item label="gender" prop="gender">
					<el-radio-group v-model="oldForm.gender">
						<el-radio :label="1">male</el-radio>
						<el-radio :label="2">female</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="journal" prop="journal_id">
					<el-select v-model="oldForm.journal_id" placeholder="Please select a journal">
						<el-option v-for="item in df_jour" :label="item.title" :key="item.journal_id" :value="item.journal_id"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="title" prop="title">
					<el-select v-model="oldForm.title" filterable placeholder="Please select a title" value-key="groupID" style="width: 300px;">
						<el-option v-for="item in df_technical" :key="item.label" :label="item.label" :value="item.label"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="country" prop="country">
					<el-select v-model="oldForm.country" filterable placeholder="Please select a country" value-key="groupID" style="width: 300px;">
						<el-option v-for="item in df_country" :label="item.en_name" :key="item.en_name" :value="item.en_name"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="realname" prop="realname">
					<el-input v-model="oldForm.realname"></el-input>
				</el-form-item>
				<el-form-item label="orcid">
					<el-input v-model="oldForm.orcid"></el-input>
				</el-form-item>
				<el-form-item label="introduction">
					<el-input v-model="oldForm.introduction" type="textarea" :autosize="{minRows: 2}"></el-input>
				</el-form-item>
				<el-form-item label="affiliation">
					<el-input v-model="oldForm.company"></el-input>
				</el-form-item>
				<el-form-item label="major" prop="maj_cn">
					<el-cascader v-model="oldForm.maj_cn" :options="jl_major" :props="defaultParams" placeholder="Please select major"
					 @change="ched_id_old" style="width: 300px;"></el-cascader>
				</el-form-item>
				<el-form-item label="field" prop="field">
					<el-input v-model="oldForm.field" type="textarea"></el-input>
				</el-form-item>
				<!-- 简历 -->
				<el-form-item prop="qualifications" label="CV.">
					<el-upload class="upload-demo" :action="baseUrl+'api/Reviewer/up_cv_file'" :on-success="handleFileSuccess2" name="reviewerCV"
					 type="reviewerCV" :on-error="handleFileError" :on-preview="handlePreview" :on-remove="handleRemove"
					 :before-remove="beforeRemove" :on-change="handleChange2" accept=".pdf" :on-exceed="handleExceed" :file-list="fileL_pdf2"
					 ref="upload">
						<el-button type="text" style="font-weight: bolder;"><b class="el-icon-lx-top" style="font-weight: bolder;"></b>upload</el-button>
					</el-upload>
					<span style="font-size: 12px; color: #aaa;">Only compressed files can be uploaded(.pdf)</span>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="oldVisible = false">Cancel</el-button>
				<el-button type="primary" @click="saveOld(oldForm)">OK</el-button>
			</span>
		</el-dialog>

		<!-- 编辑弹出框 -->
		<el-dialog title="Edit message" :visible.sync="editVisible" width="40%" :close-on-click-modal="false">
			<el-form ref="edit_Form" :model="editForm" :rules="rules" label-width="110px">
				<el-form-item label="account" prop="account">
					{{editForm.account}}
				</el-form-item>
				<el-form-item label="email" prop="email">
					{{editForm.email}}
				</el-form-item>
				<el-form-item label="gender" prop="gender">
					<span v-if="editForm.gender==1">male</span>
					<span v-if="editForm.gender==2">female</span>
				</el-form-item>
				<el-form-item label="journal" prop="journal_title">
					{{editForm.journal_title}}
				</el-form-item>
				<el-form-item label="title" prop="title">
					<el-select v-model="editForm.title" filterable placeholder="Please select a title" value-key="groupID" style="width: 300px;">
						<el-option v-for="item in df_technical" :key="item.label" :label="item.label" :value="item.label"></el-option>
					</el-select>
				</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 df_country" :label="item.en_name" :key="item.en_name" :value="item.en_name"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="realname">
					{{editForm.realname}}
				</el-form-item>
				<el-form-item label="orcid">
					{{editForm.orcid}}
				</el-form-item>
				<el-form-item label="introduction">
					<el-input v-model="editForm.introduction" type="textarea" :autosize="{minRows: 2}"></el-input>
				</el-form-item>
				<el-form-item label="affiliation">
					<el-input v-model="editForm.company"></el-input>
				</el-form-item>
				<el-form-item label="major" prop="maj_cn">
					<el-cascader :options="jl_major" v-model="editForm.maj_cn" :props="defaultParams" placeholder="Please select major"
					 @change="ched_id_edit" style="width: 300px;"></el-cascader>
				</el-form-item>
				<el-form-item label="field">
					<el-input v-model="editForm.field" type="textarea"></el-input>
				</el-form-item>
				<!-- 简历 -->
				<el-form-item prop="qualifications" label="CV.">
					<el-upload class="upload-demo" :action="baseUrl+'api/Reviewer/up_cv_file'" :on-success="handleFileSuccess3" name="reviewerCV"
					 type="reviewerCV" :on-error="handleFileError" :on-preview="handlePreview" :on-remove="handleRemove"
					 :before-remove="beforeRemove" :on-change="handleChange3" accept=".pdf" :on-exceed="handleExceed" :file-list="fileL_pdf3"
					 ref="upload">
						<el-button type="text" style="font-weight: bolder;"><b class="el-icon-lx-top" style="font-weight: bolder;"></b>upload</el-button>
					</el-upload>
					<span style="font-size: 12px; color: #aaa;">Only compressed files can be uploaded(.pdf)</span>
				</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(editForm)">OK</el-button>
			</span>
		</el-dialog>

		<!-- 删除弹出框 -->
		<el-dialog title="删除" :visible.sync="delOpen" width="40%" :close-on-click-modal="false">
			<div v-for="item in lineOptions" :name='item.journal_id' :value='item.reviewer_id' style="margin-left: 60px;">
				{{item.journal.title}} - {{item.reviewer.account}}
				<el-button type="text" icon="el-icon-delete" @click="lastDelete($event)" style="color: #FF0000;margin-left: 20px;">Delete</el-button>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="delOpen = false;" type="primary">取 消</el-button>
			</span>
		</el-dialog>

	</div>
</template>

<script>
	export default {
		data() {
			return {
				tableData: [],
				addForm: {
					gender: 1,
					major: [],
					qualifications: ''
				},
				mess_age: {},
				editForm: {
					title: '',
				},
				oldForm: {},
				delOpen: false,
				editVisible: false,
				addVisible: false,
				oldVisible: false,
				btn_alert: false,
				df_jour: [],
				df_country: [],
				jl_major: [],
				lineOptions: [],
				defaultParams: {
					label: 'title',
					value: 'major_id',
					children: 'children'
				},
				edit_id: localStorage.getItem('U_id'),
				query: {
					username: localStorage.getItem('U_name'),
					journalId: 0,
					pageIndex: 1,
					pageSize: 15
				},
				df_technical: [{
					label: 'Prof',
				}, {
					label: 'Associate Prof.',
				}, {
					label: 'Assistant Prof.',
				}, {
					label: 'Ph.D.',
				}, {
					label: 'Others',
				}],
				link_Total: 0,
				aid: -1,
				idx: -1,
				baseUrl: this.Common.baseUrl,
				mediaUrl: this.Common.mediaUrl,
				fileL_pdf1: [],
				fileL_pdf2: [],
				fileL_pdf3: [],
				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"
					}],
					genger: [{
						required: true,
						message: 'Please select genger',
						trigger: 'blur'
					}],
					journal_id: [{
						required: true,
						message: 'Please select journal_id',
						trigger: 'blur'
					}],
					journal_title: [{
						required: true,
						message: 'Please select journal_title',
						trigger: 'blur'
					}],
					maj_cn: [{
						required: true,
						message: 'Please select maj_cn',
						trigger: 'blur'
					}],
					title: [{
						required: true,
						message: 'Please select title',
						trigger: 'blur'
					}],
					technical: [{
						required: true,
						message: 'Please select title',
						trigger: 'blur'
					}],
					country: [{
						required: true,
						message: 'Please select country',
						trigger: 'blur'
					}],
					field: [{
						required: true,
						message: 'Please input field',
						trigger: 'blur'
					}],
					realname: [{
						required: true,
						message: 'Please input realname',
						trigger: 'blur'
					}],
					// qualifications: [{
					// 	required: true,
					// 	message: 'Please upload your resume',
					// 	trigger: 'blur'
					// }]
				}
			};
		},
		created() {
			this.getDate();
			this.getContent();
		},
		methods: {
			// 获取编辑列表数据
			getDate() {
				this.$api
					.post('api/Chief/getJournalsByEditor', {
						'user_id': this.edit_id
					})
					.then(res => {
						if (res.code == 0) {
							this.df_jour = res.data.journals;
						} else {
							this.$message.error(res.msg);
						}
					})
					.catch(err => {
						this.$message.error(err);
					});

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

			getContent() {
				this.$api
					.post('api/Reviewer/getReviewerListByJournal', this.query)
					.then(res => {
						if (res.code == 0) {
							this.tableData = res.data;
							this.link_Total = res.total || 0;
						} else {
							this.$message.error(res.msg);
						}
					})
					.catch(err => {
						this.$message.error(err);
					});
			},
			// 分页导航
			handlePageChange(val) {
				this.$set(this.query, 'pageIndex', val);
				this.getContent();
			},
			// 升级
			gradeup(row) {
				// 二次确认
				this.$confirm('确定要升级' + row.account + '为青年编委吗？', '提示', {
						type: 'warning'
					})
					.then(() => {
						this.$api
							.post('api/User/upReviewerToYboard', row)
							.then(res => {
								if (res.code == 0) {
									this.$message.success('升级' + row.account + '为青年编委成功');
									this.getContent();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});
					})
					.catch(() => {});
			},
			// 降级
			gradedown(row) {
				// 二次确认
				this.$confirm('确定要降级' + row.account + '为审稿人吗？', '提示', {
						type: 'warning'
					})
					.then(() => {
						this.$api
							.post('api/User/downReviewerToYboard ', row)
							.then(res => {
								if (res.code == 0) {
									this.$message.success('降级为' + row.account + '审稿人成功');
									this.getContent();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});
					})
					.catch(() => {});
			},
			// 添加操作
			add_Selection(index, row) {
				this.aid = index;
				this.addVisible = true;
				this.fileL_pdf1 = [];
			},
			// 下拉级联添加
			ched_id(event) {
				this.addForm.major = event[0];
				this.addForm.cmajor = event[1];
			},
			ched_id_old(event) {
				this.oldForm.major = event[0];
				this.oldForm.cmajor = event[1];
			},
			ched_id_edit(event) {
				this.editForm.major = event[0];
				this.editForm.cmajor = event[1];
			},
			// 保存添加
			saveAdd(addForm) {
				this.$refs.add_Form.validate((valid) => {
					// if (this.addForm.qualifications == '') {
					// 	this.$message.error('Please make sure that the qualifications document is uploaded successfully');
					// 	return false;
					// }
					if (valid) {
						this.$api
							.post('api/Reviewer/addReviewer', this.addForm)
							.then(res => {
								if (res.code == 0) {
									this.addVisible = false;
									this.btn_alert = false;
									this.$refs.add_Form.resetFields();
									this.$message.success(`Added successfully!`);
									this.getContent();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});

					} else {
						this.$message.error('error submit!!');
						return false;
					}
				});
			},
			// 查找与他相同的账号
			saerNa_U() {
				if (this.addForm.account != undefined) {
					this.$api
						.post('api/Reviewer/checkUser', {
							'account': this.addForm.account
						})
						.then(res => {
							if (res.code == 0) {
								if (res.data.has == 'no') {
									this.btn_alert = false
								} else {
									this.$confirm('Repeat of user account!', 'Tips', {})
										.then(res => {

											this.$api
												.post('api/Reviewer/getReviewerByNameEmail', {
													'account': this.addForm.account
												})
												.then(res => {
													this.oldForm = res.data.reviewer;
													this.oldForm.title = res.data.reviewer.technical;
													this.oldForm.cv = res.data.reviewer.qualifications;
													this.fileL_pdf2 = [];
													if (res.data.reviewer.qualifications != "") {
														this.fileL_pdf2 = [{}];
														this.fileL_pdf2[0].name = 'reviewerCV';
														this.fileL_pdf2[0].url = this.mediaUrl + 'reviewer/' + res.data.reviewer.qualifications;
													}
													this.oldForm.maj_cn = [this.oldForm.major, this.oldForm.cmajor];
													this.oldVisible = true
												})
												.catch(err => {
													this.$message.error(err);
												});

										}).catch(() => {});
									this.btn_alert = true
								}
							} else {
								this.$message.error(res.msg);
							}
						})
						.catch(err => {
							this.$message.error(err);
						});
				}
			},
			// 查找与他相同的邮箱
			saerEm_U() {
				if (this.addForm.email != undefined) {
					this.$api
						.post('api/Reviewer/checkUser', {
							'account': this.addForm.email
						})
						.then(res => {
							if (res.code == 0) {
								if (res.data.has == 'no') {
									this.btn_alert = false
								} else {
									this.$confirm('Repeat of user account!', 'Tips', {})
										.then(res => {
											this.$api
												.post('api/Reviewer/getReviewerByNameEmail', {
													'account': this.addForm.email
												})
												.then(res => {
													this.oldForm = res.data.reviewer;
													this.oldForm.maj_cn = [this.oldForm.major, this.oldForm.cmajor];
													this.oldVisible = true
												})
												.catch(err => {
													this.$message.error(err);
												});

										}).catch(() => {});
									this.btn_alert = true
								}
							} else {
								this.$message.error(res.msg);
							}
						})
						.catch(err => {
							this.$message.error(err);
						});
				}
			},
			// 保存重复的添加
			saveOld(oldForm) {
				this.$refs.old_Form.validate((valid) => {
					// if (this.oldForm.qualifications == '') {
					// 	this.$message.error('Please make sure that the qualifications document is uploaded successfully');
					// 	return false;
					// }
					if (valid) {
						this.$api
							.post('api/Reviewer/addReviewerBee', this.oldForm)
							.then(res => {
								if (res.code == 0) {
									this.addVisible = false;
									this.oldVisible = false;
									this.btn_alert = false;
									this.$refs.add_Form.resetFields();
									this.$refs.old_Form.resetFields();
									this.$message.success(`Added successfully!`);
									this.getContent();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});

					} else {
						this.$message.error('error submit!!');
						return false;
					}
				});
			},
			// 编辑操作
			handleEdit(index, row) {
				this.idx = index;
				row.title = row.technical;
				this.editForm = Object.assign({}, row);
				this.editForm.cv = this.editForm.qualifications;
				this.fileL_pdf3 = [];
				if (this.editForm.qualifications != "") {
					this.fileL_pdf3 = [{}];
					this.fileL_pdf3[0].name = 'reviewerCV';
					this.fileL_pdf3[0].url = this.mediaUrl + 'reviewer/' + this.editForm.qualifications;
				}
				this.editForm.maj_cn = [this.editForm.major, this.editForm.cmajor];
				this.editVisible = true;

			},
			// 保存编辑
			saveEdit(editForm) {
				this.$refs.edit_Form.validate((valid) => {
					// if (this.editForm.qualifications == '') {
					// 	this.$message.error('Please make sure that the qualifications document is uploaded successfully');
					// 	return false;
					// }
					if (valid) {
						this.$api
							.post('api/Reviewer/editReviewerForEditor', this.editForm)
							.then(res => {
								if (res.code == 0) {
									this.editVisible = false;
									this.btn_alert = false;
									this.$message.success(`Successfully changed line ${this.idx + 1} `);
									this.getContent();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});
					} else {
						this.$message.error('error submit!!');
						return false;
					}
				});
			},
			// 删除弹窗
			showDelete(index, row) {
				this.aid = index;
				this.delOpen = true;
				this.$api
					.post('api/User/getReviewerForDel', {
						reviewer_id: index.reviewer_id,
						editor_account: localStorage.getItem('U_name')
					})
					.then(res => {
						this.lineOptions = res.data;
					})
					.catch(err => {
						this.$message.error(err);
					});
			},
			// 删除操作
			lastDelete(e) {
				this.mess_age.reviewer_id = e.currentTarget.parentElement.getAttribute('value')
				this.mess_age.journal_id = e.currentTarget.parentElement.getAttribute('name')
				// 二次确认删除
				this.$confirm('确定要删除吗？', '提示', {
						type: 'warning'
					})
					.then(() => {
						this.$api
							.post('api/User/deleteArticleReviewer', this.mess_age)
							.then(res => {
								if (res.code == 0) {
									this.delOpen = false;
									this.$message.success('删除成功');
									this.getContent();
								} else {
									this.$message.error(res.msg);
								}
							})
							.catch(err => {
								this.$message.error(err);
							});
					})
					.catch(() => {});
			},
			// 上传文件
			handleChange1(file, fileList) {
				if (fileList.length > 0) {
					this.fileL_pdf1 = [fileList[fileList.length - 1]]
				}
			},
			handleChange2(file, fileList) {
				if (fileList.length > 0) {
					this.fileL_pdf2 = [fileList[fileList.length - 1]]
				}
			},
			handleChange3(file, fileList) {
				if (fileList.length > 0) {
					this.fileL_pdf3 = [fileList[fileList.length - 1]]
				}
			},
			handleFileSuccess1(res, file) {
				if (res.code == 0) {
					this.addForm.cv = res.upurl;
					this.addForm.qualifications = res.upurl;
				} else {
					this.$message.error(res.msg);
				}
			},
			handleFileSuccess2(res, file) {
				if (res.code == 0) {
					this.oldForm.cv = res.upurl;
					this.oldForm.qualifications = res.upurl;
				} else {
					this.$message.error(res.msg);
				}
			},
			handleFileSuccess3(res, file) {
				if (res.code == 0) {
					this.editForm.cv = res.upurl;
					this.editForm.qualifications = res.upurl;
				} else {
					this.$message.error(res.msg);
				}
			},
			beforeRemove(file, fileList) {
				return this.$confirm(`Remove ${ file.name }？`)
			},
			handleFileError(res, file) {

			},

			handleRemove(file, fileList) {

			},
			handlePreview(file) {
				window.open(file.url);
			},
			handleExceed(files, fileList) {
				this.$message.warning("当前限制选择 1 个文件，请先删除当前文件！");
			},
		}
	};
</script>

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

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

	.table-td-thumb {
		display: block;
		margin: auto;
		width: 40px;
		height: 40px;
	}

	.el-table .warning-row {
		background: #f3ca7f;
	}

	.el-table .success-row {
		background: #bcfc9a;
	}

	.el-table .normol-row {
		background: #d8f1c7;
	}

	.el-table .red-row {
		background: #f05555;
	}
</style>
