<template>
	<div>
		<div class="crumbs">
			<el-breadcrumb separator="/">
				<el-breadcrumb-item>
					<i class="el-icon-copy-document"></i>
					<router-link :to="{path:'/youthed'}">
						<span class="top_dao"> Young scientist member article</span>
					</router-link>
					>> Young scientist member Article Detail
				</el-breadcrumb-item>
			</el-breadcrumb>
		</div>
		<div class="container_l" v-loading="loading" element-loading-text="Loading..."
			element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
			<el-card class="box-card">
				<div class="tet_list" :model="txt_mess">
					<h4><span>{{txt_mess.atype}}</span>{{txt_mess.article_title}}</h4>
					<h5>{{txt_mess.title}}<span style="margin: 0 10px;"> >> </span> Manuscript ID:
						{{txt_mess.accept_sn}}</h5>
					<p><b>Submitted time :</b> {{txt_mess.ctime}}</p>
					<p><b>Abstract :</b> <br>{{txt_mess.abstrart}}</p>
					<div class="file_sty" v-for="item in fileList" style="margin-top: 15px;">
						<img src="../../assets/img/icon_0.png" alt="" class="icon_img">
						<a :href='mediaUrl+item.file_url' target="_blank" class="txt_pdf">{{item.type_name}} <span
								style="margin-left: 50px;color: #888;font-size: 13px;">{{item.ctime}}</span>
							<i class="el-icon-download" style="margin-left: 20px;color: #66b1ff;font-weight: bold;"></i>
						</a><br>
					</div>

					<div class="file_sty" v-for="item in picList">
						<img src="../../assets/img/icon_0.png" alt="" class="icon_img">
						<a :href='mediaUrl+item.file_url' target="_blank" class="txt_pdf">{{item.type_name}} <span
								style="margin-left: 50px;color: #888;font-size: 13px;">{{item.ctime}}</span>
							<i class="el-icon-download" style="margin-left: 20px;color: #66b1ff;font-weight: bold;"></i>
						</a><br>
					</div>
					<p style="margin-top: 5px;color: #999;font-size: 14px;">
						<b style="color: #e41411;">Download failed？</b>
						<br>If you have upgraded the Google Chrome browser to version 86, released on October 6, 2020,
						you may have
						noticed that some file downloads don't work anymore in the browser. You click on the download
						link and nothing
						happens.
						<br>1. Right now, the easiest option available is to
						<b style="color: #e41411;">right-click on the download link and select "save link as".</b>
						The download is executed when you do that.
						<br>2. Please try to use a different browser for downloads. For now, a browser like Firefox,
						Internet Explorer,
						Brave, Vivaldi, the new Edge, or Opera all allow the download.
					</p>
				</div>

			</el-card>

			<el-card class="box-card" style="font-size: 15px;line-height: 24px;" v-if="this.add_apply == 1">
				<el-row :gutter="20" class="trah_c">
					<el-col :span="1"><img src="../../assets/img/icon_8.png" alt="" class="icon_img"></el-col>
					<el-col :span="23">
						<p>
							If you are intereted in reviewing this manuscript, please click the "Review the Manuscript"
							button, we will
							offer
							a
							reviewer-comment-form for you.(After that, this manuscript will be listed in your
							"reviewing” list, then,
							after
							the reviewing form be finished, you can only find this manuscript in “history list”. If you
							have any questions,
							please don't hesitate to contact us: tmr@tmrjournals.com)
						</p>
					</el-col>
				</el-row>
				<div style="text-align: center;margin-top: 12px;">
					<el-button type="warning" @click="saveAdd()" style="width: 250px;">Apply</el-button>
				</div>
			</el-card>

			<el-card class="box-card" v-if="this.add_apply == 1">
				<div class="ques_tion">
					<el-form :model="questionform" :rules="rules" ref="question" label-width="300px"
						label-position="top">
						<el-divider content-position="center">REFEREE'S ASSESSMENT</el-divider>
						<el-row :gutter="24">
							<el-col :span="12">
								<el-form-item label="1.Originality of the topic">
									<el-radio-group v-model="questionform.qu1">
										<el-radio :label="1">Excellent</el-radio>
										<el-radio :label="2">Good</el-radio>
										<el-radio :label="3">Fair</el-radio>
										<el-radio :label="4">Poor</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="2.Importance in its Field">
									<el-radio-group v-model="questionform.qu3">
										<el-radio :label="1">Excellent</el-radio>
										<el-radio :label="2">Good</el-radio>
										<el-radio :label="3">Fair</el-radio>
										<el-radio :label="4">Poor</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item
									label="3.Does the manuscript fall within the aim and scope of the journal?">
									<el-radio-group v-model="questionform.qu6">
										<el-radio :label="1">Excellent</el-radio>
										<el-radio :label="2">Good</el-radio>
										<el-radio :label="3">Fair</el-radio>
										<el-radio :label="4">Poor</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="4.English language">
									<el-radio-group v-model="questionform.qu8">
										<el-radio :label="1">Excellent</el-radio>
										<el-radio :label="2">Good</el-radio>
										<el-radio :label="3">Fair</el-radio>
										<el-radio :label="4">Poor</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="5.Readily Understandable">
									<el-radio-group v-model="questionform.qu5">
										<el-radio :label="1">Excellent</el-radio>
										<el-radio :label="2">Good</el-radio>
										<el-radio :label="3">Fair</el-radio>
										<el-radio :label="4">Poor</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-collapse>
									<el-form-item label="6.Does the title represent manuscript's contents?">
										<el-switch v-model="questionform.qu9" active-text="yes" inactive-text="no">
										</el-switch>
										<el-collapse-item name="1">
											<template slot="title">
												<i class="el-icon-edit"></i>Comments/ Suggestions
											</template>
											<el-input type="textarea" placeholder="please input content"
												v-model="questionform.qu9contents" :rows="4"></el-input>
										</el-collapse-item>
									</el-form-item>
								</el-collapse>
							</el-col>
						</el-row>


						<el-collapse>
							<el-form-item label="7.Is the Abstract accurate and concise?">
								<el-switch v-model="questionform.qu10" active-text="yes" inactive-text="no"></el-switch>
								<el-collapse-item name="2">
									<template slot="title">
										<i class="el-icon-edit"></i>Comments/ Suggestions
									</template>
									<el-input type="textarea" placeholder="please input content"
										v-model="questionform.qu10contents" :rows="4"></el-input>
								</el-collapse-item>
							</el-form-item>
							<el-form-item label="8.Are the approach/ methods properly described?">
								<el-switch v-model="questionform.qu11" active-text="yes" inactive-text="no"></el-switch>
								<el-collapse-item name="3">
									<template slot="title">
										<i class="el-icon-edit"></i>Comments/ Suggestions
									</template>
									<el-input type="textarea" placeholder="please input content"
										v-model="questionform.qu11contents" :rows="4"></el-input>
								</el-collapse-item>
							</el-form-item>
							<el-form-item label="9.Are the conclusions and interpretations sound?">
								<el-switch v-model="questionform.qu12" active-text="yes" inactive-text="no"></el-switch>
								<el-collapse-item name="4">
									<template slot="title">
										<i class="el-icon-edit"></i>Comments/ Suggestions
									</template>
									<el-input type="textarea" placeholder="please input content"
										v-model="questionform.qu12contents" :rows="4"></el-input>
								</el-collapse-item>
							</el-form-item>
							<el-form-item label="10.Are the references properly cited?">
								<el-switch v-model="questionform.qu13" active-text="yes" inactive-text="no"></el-switch>
								<el-collapse-item name="5">
									<template slot="title">
										<i class="el-icon-edit"></i>Comments/ Suggestions
									</template>
									<el-input type="textarea" placeholder="please input content"
										v-model="questionform.qu13contents" :rows="4"></el-input>
								</el-collapse-item>
							</el-form-item>

							<el-divider content-position="center">REFEREE'S RECOMMENDATIONS</el-divider>
							<el-form-item label="Overall the Paper is Rated">
								(Poor-------------------------------------------------------------Excellent)
								<br />
								<el-radio-group v-model="questionform.rated" size="small">
									<el-radio-button label="1"></el-radio-button>
									<el-radio-button label="2"></el-radio-button>
									<el-radio-button label="3"></el-radio-button>
									<el-radio-button label="4"></el-radio-button>
									<el-radio-button label="5"></el-radio-button>
									<el-radio-button label="6"></el-radio-button>
									<el-radio-button label="7"></el-radio-button>
									<el-radio-button label="8"></el-radio-button>
									<el-radio-button label="9"></el-radio-button>
									<el-radio-button label="10"></el-radio-button>
								</el-radio-group>
								<br />
								<span>Your score:{{questionform.rated}}</span>
							</el-form-item>
							<el-form-item label="REFEREE'S RECOMMENDATIONS" prop="recommend">
								<el-radio-group v-model="questionform.recommend" style="line-height: 30px;">
									<el-radio :label="1">Accept with minor revision</el-radio>
									<br />
									<el-radio :label="2">Accept with major revision</el-radio>
									<br />
									<el-radio :label="3">Reject in current form, but may be resubmitted</el-radio>
									<br />
									<el-radio :label="4">Reject, with no resubmission</el-radio>
								</el-radio-group>
							</el-form-item>
							<el-form-item label="OTHER SPECIFIC CRITICISMS">
								<el-radio-group v-model="questionform.other" style="line-height: 30px;">
									<el-radio :label="1">Imperfect style</el-radio>
									<br />
									<el-radio :label="2">Too long</el-radio>
									<br />
									<el-radio :label="3">References incorrectly presented</el-radio>
									<br />
									<el-radio :label="4">Typographical and Grammatical errors</el-radio>
								</el-radio-group>
							</el-form-item>
							<el-form-item label="Comments for the Authors"
								v-if="this.txt_mess.atype == 'Comment' || this.txt_mess.atype == 'News'">
								<el-input type="textarea" placeholder="please input content"
									v-model="questionform.comment" :rows="8"></el-input>
							</el-form-item>
							<el-form-item label="Comments for the Authors" prop="comment"
								v-if="this.txt_mess.atype != 'Comment' && this.txt_mess.atype != 'News'">
								<el-input type="textarea" placeholder="please input content"
									v-model="questionform.comment" :rows="8"></el-input>
							</el-form-item>
							<el-form-item label="Confidential Comments to the Editor">
								<el-input type="textarea" placeholder="please input content"
									v-model="questionform.confident" :rows="8"></el-input>
							</el-form-item>
							<el-form-item label="Please choose disclose your name or remain anonymous.">
								<el-radio-group v-model="item.question.is_anonymous" style="line-height: 30px;">
									<el-radio :label="0">Disclose name</el-radio>
									<br />
									<el-radio :label="1">Remain anonymous</el-radio>
								</el-radio-group>
								<p style="line-height: 20px;color: #aaa;font-size: 13px;margin: 12px 0 0 0;">
									If you agree to disclose your name, we will acknowledge you by name in the published
									PDF. However, if you prefer to remain anonymous, we will still express our gratitude
									by thanking you as an anonymous reviewer. 
									<br />For example, {{txt_mess.title}} would like to thank AAAAAAAA, BBBBBBBB, and other anonymous reviewers for their
									invaluable contributions to the peer review process of this paper.
								</p>
							</el-form-item>
							<el-form-item>
								<el-button type="primary" @click="questionSubmit">submit</el-button>
							</el-form-item>
						</el-collapse>
					</el-form>
				</div>
			</el-card>

		</div>
	</div>

</template>

<script>
	export default {
		data() {
			return {
				loading: false,
				Direct_log: this.$route.query.act,
				Art_id: this.$route.query.Art_id,
				txt_mess: {},
				fileList: [],
				picList: [],
				mediaUrl: this.Common.mediaUrl,
				add_edit: {
					article_id: this.$route.query.Art_id,
					user_id: localStorage.getItem('U_id'),
					content: ''
				},
				head_line: '',
				questionform: {
					rev_qu_id: '',
					art_rev_id: this.$route.query.Art_id,
					qu1: '',
					qu2: '',
					qu3: '',
					qu4: '',
					qu5: '',
					qu6: '',
					qu7: '',
					qu8: '',
					qu9: '',
					qu9contents: '',
					qu10: '',
					qu10contents: '',
					qu11: '',
					qu11contents: '',
					qu12: '',
					qu12contents: '',
					qu13: '',
					qu13contents: '',
					qu14: '',
					qu14contents: '',
					qu15: '',
					qu15contents: '',
					rated: '',
					recommend: '',
					other: '',
					confident: '',
					comment: ''
				},
				add_apply: 1,
				rules: {
					recommend: [{
						required: true,
						message: 'please select',
						trigger: 'blur'
					}],
					comment: [{
						required: true,
						message: "please input content",
						trigger: "blur"
					}],
				}
			}
		},
		created() {
			if (this.Direct_log == null) {
				this.$api
					.post('api/Reviewer/checkUserForReviewer', this.add_edit)
					.then(res => {
						this.getData();
						if (res.code == 0) {
							this.add_apply = 0;
						} else {
							this.add_apply = 1;
						}
					})
					.catch(err => {
						this.$message.error(err);
					});
			} else {
				this.$api
					.post('api/Chief/autoLoginForChief ', {
						'code': this.Direct_log
					})
					.then(res => {
						if (res.code == 0) {
							localStorage.setItem('U_role', res.data.roles);
							localStorage.setItem('U_name', res.data.user.account);
							localStorage.setItem('U_id', res.data.user.user_id);
							localStorage.setItem('U_relname', res.data.user.realname);
							this.getData();
						} else {
							this.$message.error(res.msg);
						}
					})
					.catch(err => {
						this.$message.error(err);
					});
			}
		},
		methods: {
			getData() {
				// 获取文章信息
				this.$api
					.post('api/Reviewer/getartrevdate', {
						'revid': this.Art_id,
						'human': 'reviewer'
					})
					.then(res => {
						this.txt_mess = res
					})
					.catch(err => {
						this.$message.error(err);
					});

				this.$api
					.post('api/Reviewer/getAFilelistByID ', {
						'revid': this.Art_id
					})
					.then(res => {
						for (var i = 0; i < res.data.length; i++) {
							let date = new Date(parseInt(res.data[i].ctime) * 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();
							res.data[i].ctime = Y + M + D;
						}
						this.fileList = res.data
					})
					.catch(err => {
						this.$message.error(err);
					});

				this.$api
					.post('api/Reviewer/getBFilelistByID', {
						'revid': this.Art_id
					})
					.then(res => {
						for (var i = 0; i < res.data.length; i++) {
							let date = new Date(parseInt(res.data[i].ctime) * 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();
							res.data[i].ctime = Y + M + D;
						}
						this.picList = res.data
					})
					.catch(err => {
						this.$message.error(err);
					});


				//初始化问卷
				this.$api.post('api/Reviewer/getQuestion', {
					artrevid: this.Art_id
				}).then((res) => {
					if (res.code == 0) {
						this.questionform.rev_qu_id = res.data.rev_qu_id;
						this.questionform.qu1 = res.data.qu1;
						this.questionform.qu2 = res.data.qu2;
						this.questionform.qu3 = res.data.qu3;
						this.questionform.qu4 = res.data.qu4;
						this.questionform.qu5 = res.data.qu5;
						this.questionform.qu6 = res.data.qu6;
						this.questionform.qu7 = res.data.qu7;
						this.questionform.qu8 = res.data.qu8;
						this.questionform.qu9 = res.data.qu9;
						this.questionform.qu9contents = res.data.qu9_contents;
						this.questionform.qu10 = res.data.qu10 == 0 ? false : true;
						this.questionform.qu10contents = res.data.qu10_contents;
						this.questionform.qu11 = res.data.qu11 == 0 ? false : true;
						this.questionform.qu11contents = res.data.qu11_contents;
						this.questionform.qu12 = res.data.qu12 == 0 ? false : true;
						this.questionform.qu12contents = res.data.qu12_contents;
						this.questionform.qu13 = res.data.qu13 == 0 ? false : true;
						this.questionform.qu13contents = res.data.qu13_contents;
						this.questionform.qu14 = res.data.qu14 == 0 ? false : true;
						this.questionform.qu14contents = res.data.qu14_contents;
						this.questionform.qu15 = res.data.qu15 == 0 ? false : true;
						this.questionform.qu15contents = res.data.qu15_contents;
						this.questionform.rated = res.data.rated;
						this.questionform.recommend = res.data.recommend;
						this.questionform.other = res.data.other;
						this.questionform.confident = res.data.confidential;
						this.questionform.comment = res.data.comments;
						this.questionform.is_anonymous = res.data.is_anonymous;
					}
				});
			},

			questionSubmit() {
				if (this.questionform.is_anonymous == "" && this.questionform.is_anonymous != "0") {
					this.$message.error('Please choose disclose your name or remain anonymous.');
				} else {
					this.loading = true
					this.$refs.question.validate((valid) => {
						if (valid) {
							this.$api
								.post('api/Reviewer/questionSubmit', this.questionform)
								.then((res) => {
									if (res.code == 0) {
										this.loading = false;
										this.$message.success('success!!');
										this.getData();
										this.$router.push('/per_text_success');
									} else {
										this.loading = false;
										this.$message.error('question submit error');
									}
								});
						} else {
							this.loading = false
							this.$message.error('Please complete the information!');
						}
					});
				}
			},

			saveAdd() {
				this.$api
					.post('api/Reviewer/addArticleReviewer', {
						articleId: this.Art_id,
						uid: localStorage.getItem('U_id')
					})
					.then(res => {
						this.add_apply = 0;
						this.$message.success('Successful application!');
						this.getData();
					})
					.catch(err => {
						this.$message.error(err);
					});
			}

		},
		mounted() {

		},
	}
</script>

<style>
	.tet_list {
		font-size: 20px;
	}

	.box-card {
		margin-bottom: 20px;
		line-height: 24px;
	}

	.upload-txtc .el-upload-list__item .el-icon-upload-success {
		display: none !important;
	}

	.tet_list h4>span {
		padding: 0 10px;
		margin-right: 10px;
		display: inline-block;
		background-color: #108dcc;
		color: #fff;
		font-size: 13px;
		height: 28px;
		line-height: 28px;
		font-weight: normal;
	}

	.tet_list h5 {
		font-size: 15px;
		margin: 20px 0 5px 0;
		font-weight: normal;
	}

	.tet_list p {
		font-family: Calibri;
		line-height: 22px;
		font-size: 16px;
	}

	.file_sty {
		margin-bottom: 6px;
	}

	.file_sty a {
		color: #606266;
		font-size: 14px;
	}

	.file_sty a:hover {
		text-decoration: underline;
	}

	.red {
		color: #ff0000;
	}

	.el-collapse {
		border-top: 0;
		border-bottom: 0;
	}

	.top_dao:hover {
		text-decoration: underline;
		cursor: pointer;
	}

	.icon_img {
		width: 15px;
		height: 15px;
		margin-right: 10px;
		vertical-align: middle;
	}

	.trah_c .icon_img {
		width: 24px;
		height: 24px;
		margin: 0 20px;
	}
</style>
