<template>
	<!-- 此页面是请假申请、处分申请和解除处分申请进来的任务流程页面 -->
	<view class="detail">
		<Nav :navs="navs" @change="navChange" />
		<view class="form" v-if="navIndex==0">
			<!-- 请假表单 -->
			<view class="container" style="padding-bottom: 60px;" v-if="formData!=null&&leaveForm">
				<!--学号 -->
				<view class="form-item">
					<text class="label">学号：</text>
					<text class="uni-input">{{ formData.stuNo }}</text>
				</view>

				<!--姓名 -->
				<view class="form-item">
					<text class="label">姓名：</text>
					<text class="uni-input">{{ formData.studentName }}</text>
				</view>

				<!-- 性别 -->
				<view class="form-item">
					<text class="label">性别：</text>
					<text class="uni-input">{{ formData.gender }}</text>
				</view>

				<!--院部 -->
				<view class="form-item">
					<text class="label">院部：</text>
					<text class="uni-input">{{ formData.departmentName }}</text>
				</view>

				<!--班级 -->
				<view class="form-item">
					<text class="label">班级：</text>
					<text class="uni-input">{{ formData.className }}</text>
				</view>

				<!--联系电话 -->
				<view class="form-item">
					<text class="label">联系电话：</text>
					<text class="uni-input">{{ formData.phoneNumber }}</text>
				</view>

				<!--家长姓名 -->
				<view class="form-item">
					<text class="label">家长姓名：</text>
					<text class="uni-input">{{ formData.fatherName }}</text>
				</view>

				<!--家长联系电话 -->
				<view class="form-item">
					<text class="label">家长联系电话：</text>
					<text class="uni-input">{{ formData.fatherRelation }}</text>
				</view>

				<view class="form-item">
					<text class="label">请假事由：</text>
					<text class="uni-input">{{ formData.leaveType=='0'?"病假":"事假" }}--{{formData.reason}}</text>
				</view>
				<view class="form-item">
					<text class="label">请假开始时间：</text>
					<text class="uni-input">{{ formData.startDate }}</text>
				</view>
				<view class="form-item">
					<text class="label">请假结束时间：</text>
					<text class="uni-input">{{ formData.endDate }}</text>
				</view>
				<view class="form-item">
					<text class="label">请假天数：</text>
					<text class="uni-input">{{ formData.leaveDays }}</text>
				</view>
				<view class="form-item">
					<text class="label">目的地：</text>
					<text class="uni-input">{{ formData.destination }}</text>
				</view>
				<view class="form-item">
					<text class="label">目的地详细：</text>
					<text class="uni-input">{{ formData.destinationDetails }}</text>
				</view>
				<view class="form-item">
					<text class="label">是否离桂：</text>
					<text class="uni-input">{{ formData.leavingGx==1?"是":"否" }}</text>
				</view>
				<view class="form-item">
					<text class="label">目的地详细：</text>
					<text class="uni-input">{{ formData.destinationDetails }}</text>
				</view>
				<view class="form-item" style="height: auto;">
					<text class="label">请假人签字：</text>
					<view class="uni-input">
						<image class="form-img" :src="baseImgUrl+formData.applicantSignature" mode=""></image>
					</view>
				</view>
				<view class="form-item" style="height: auto;">
					<text class="label">材料附件：</text>
					<view class="uni-input">
						<image @tap="previewImage(attachments,index)" v-for="(img,index) in attachments" :key="index"
							class="form-img" :src="baseImgUrl+img" mode=""></image>
					</view>
				</view>
				<view class="form-item">
					<text class="label">备注：</text>
					<text class="uni-input"></text>
				</view>
				<view class="btns" v-if="tag==1">
					<button class="submit" v-if="taskName=='学生销假申请'" @tap="cancelLeave">销假</button>
					<button class="turn-down" @tap="onReject" v-if="role!=='学生'&&taskName!=='学生销假申请'">驳回</button>
					<button class="return" @tap="onReturn" v-if="btnShow">回退</button>
					<button class="submit" @tap="onComplete" v-if="taskName!=='学生销假申请'">审批</button>
				</view>
				<!-- <view class="btns" v-if="tag==1">
					<button class="reject" @click="onReject" v-if="role!=='学生'">驳回</button>
					<button @click="onComplete">审批</button>
				</view> -->
			</view>
			<!-- 处分表单 -->
			<view class="container" style="padding-bottom: 60px;" v-else-if="formData!=null&&disposalForm">
				<!--学号 -->
				<view class="form-item">
					<text class="label">学号：</text>
					<text class="uni-input">{{ formData.stuNo }}</text>
				</view>

				<!--姓名 -->
				<view class="form-item">
					<text class="label">姓名：</text>
					<text class="uni-input">{{ formData.stuName }}</text>
				</view>

				<!-- 性别 -->
				<view class="form-item">
					<text class="label">性别：</text>
					<text class="uni-input">{{ formData.gender }}</text>
				</view>

				<!--院部 -->
				<view class="form-item">
					<text class="label">院部：</text>
					<text class="uni-input">{{ formData.departmentName }}</text>
				</view>

				<!--年级 -->
				<view class="form-item">
					<text class="label">年级：</text>
					<text class="uni-input">{{ formData.gradeName }}</text>
				</view>

				<!--班级 -->
				<view class="form-item">
					<text class="label">班级：</text>
					<text class="uni-input">{{ formData.className }}</text>
				</view>

				<!--民族 -->
				<view class="form-item">
					<text class="label">民族：</text>
					<text class="uni-input">{{ formData.mz }}</text>
				</view>

				<!--出生日期 -->
				<view class="form-item">
					<text class="label">出生日期：</text>
					<text class="uni-input">{{ formData.birthday }}</text>
				</view>

				<!--籍贯：省/自治区/直辖市 -->
				<view class="form-item">
					<text class="label">籍贯【省/自治区/直辖市】：</text>
					<text class="uni-input">{{ formData.jg }}</text>
				</view>

				<!--违纪时间 -->
				<view class="form-item">
					<text class="label">违纪时间：</text>
					<text class="uni-input">{{ formData.violationDate }}</text>
				</view>

				<!--处分等级 -->
				<view class="form-item">
					<text class="label">处分等级：</text>
					<text class="uni-input">{{ penaltyTypeMethodFormat(formData.penaltyType) }}</text>
				</view>

				<!-- 违纪材料 -->
				<view class="form-item">
					<text class="label">违纪材料：</text>
					<text class="uni-input">{{ formData.evidenceUpload }}</text>
				</view>

				<!-- 处分建议 -->
				<view class="form-item">
					<text class="label">处分建议：</text>
					<text class="uni-input">{{ formData.penaltyRecommendation }}</text>
				</view>

				<!-- 违规条例 -->
				<view class="form-item">
					<text class="label">违规条例：</text>
					<text class="uni-input">{{ formData.violationRegulations }}</text>
				</view>
				<view class="btns" v-if="tag==1">
					<button class="turn-down" @tap="onReject" v-if="role!=='学生'">驳回</button>
					<button class="return" @tap="onReturn" v-if="btnShow">回退</button>
					<button class="submit" @tap="onComplete">审批</button>
				</view>
				<!-- <view class="btns" v-if="tag==1">
					<button class="reject" @click="onReject" v-if="role!=='学生'">驳回</button>
					<button @click="onComplete">审批</button>
				</view> -->
			</view>
			<!-- 解除处分表单 -->
			<view class="container" style="padding-bottom: 60px;" v-else-if="formData!=null&&relieveForm">
				<!--学号 -->
				<view class="form-item">
					<text class="label">学号：</text>
					<text class="uni-input">{{ formData.stuNo }}</text>
				</view>

				<!--姓名 -->
				<view class="form-item">
					<text class="label">姓名：</text>
					<text class="uni-input">{{ formData.stuName }}</text>
				</view>

				<!-- 性别 -->
				<view class="form-item">
					<text class="label">性别：</text>
					<text class="uni-input">{{ formData.gender }}</text>
				</view>

				<!--院部 -->
				<view class="form-item">
					<text class="label">院部：</text>
					<text class="uni-input">{{ formData.departmentName }}</text>
				</view>

				<!--年级 -->
				<view class="form-item">
					<text class="label">年级：</text>
					<text class="uni-input">{{ formData.gradeName }}</text>
				</view>

				<!--班级 -->
				<view class="form-item">
					<text class="label">班级：</text>
					<text class="uni-input">{{ formData.className }}</text>
				</view>

				<!--民族 -->
				<view class="form-item">
					<text class="label">民族：</text>
					<text class="uni-input">{{ formData.mz }}</text>
				</view>

				<!--出生日期 -->
				<view class="form-item">
					<text class="label">出生日期：</text>
					<text class="uni-input">{{ formData.birthday }}</text>
				</view>

				<!--籍贯：省/自治区/直辖市 -->
				<view class="form-item">
					<text class="label">籍贯：省/自治区/直辖市：</text>
					<text class="uni-input">{{ formData.jg }}</text>
				</view>

				<!--解除处分文号 -->
				<view class="form-item">
					<text class="label">解除处分文号：</text>
					<text class="uni-input">{{ formData.relieveNumber }}</text>
				</view>

				<!--处分文号 -->
				<view class="form-item">
					<text class="label">处分文号：</text>
					<text class="uni-input">{{ formData.penaltyNumber }}</text>
				</view>

				<!-- 违纪时间 -->
				<view class="form-item">
					<text class="label">违纪时间：</text>
					<text class="uni-input">{{ formData.violationDate }}</text>
				</view>

				<!-- 处分等级 -->
				<view class="form-item">
					<text class="label">处分等级：</text>
					<text class="uni-input">{{ penaltyTypeMethodFormat(formData.penaltyType) }}</text>
				</view>

				<!-- 处分期间表现 -->
				<view class="form-item">
					<text class="label">处分期间表现：</text>
					<text class="uni-input">{{ formData.ideologicalEducation }}</text>
				</view>
				<view class="btns" v-if="tag==1">
					<button class="turn-down" @tap="onReject" v-if="btnShow">驳回</button>
					<button class="return" @tap="onReturn" v-if="btnShow">回退</button>
					<button class="submit" @tap="onComplete">审批</button>
				</view>
				<!-- <view class="btns" v-if="tag==1">
					<button class="reject" @click="onReject" v-if="btnShow">驳回</button>
					<button @click="onComplete">审批</button>
				</view> -->
			</view>
		</view>
		<view class="progress" v-if="navIndex==1">
			<FlowStep :procInsId="procInsId" :deployId="deployId" />
		</view>
		<uni-popup class="popup" v-if="formData!=null" ref="approveDialog" type="dialog" background-color="#fff">
			<view class="popup-content">
				<view class="title">
					流程审批
				</view>
				<view class="content">
					<view class="show-letter" v-if="showLetterService">
						<view class="title">
							广西水利电力职业技术学院处分决定送达书
						</view>
						<view class="stu-name">
							{{ formData.stuName }}同学：
						</view>
						<view class="desc">
							{{ formData.letterService }}
						</view>
						<view class="bottom">
							<button size="mini" type="warn">下载处分下文</button>
							<view class="gaizhang">
								<image
									src="https://gss0.baidu.com/7Po3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=debd0a4bb2fd5266a77e34109e28bb1d/8d5494eef01f3a297283d36e9d25bc315d607cc2.jpg"
									mode="widthFix"></image>
								<view class="time">
									<text>学生工作处</text>
									<text>{{ formData.violationDate }}</text>
								</view>
							</view>
						</view>
					</view>
					<scroll-view scroll-y="true" style="height:320px;"
						v-if="dispositionServiceShow||relieveServiceShow||relieveShow">
						<view class="form-item" v-if="dispositionServiceShow">
							<label class="label"><text class="required">*</text>处分文号</label>
							<input type="text" v-model="taskForm.penaltyNumber" placeholder="请输入处分文号" />
						</view>
						<view class="form-item" v-if="dispositionServiceShow">
							<label class="label"><text class="required">*</text>送达书</label>
							<textarea v-model="taskForm.letterServiceContent">
							</textarea>
						</view>
						<view class="form-item" v-if="dispositionServiceShow">
							<label class="label"><text class="required">*</text>违纪时间</label>
							<picker @change="onChangeTime" mode="date" value="2022">
								<view class="uni-input">
									<text
										class="val">{{taskForm.violationDate==''?'请选择违纪日期':taskForm.violationDate}}</text>
									<uni-icons type="calendar" size="25" color="#202020"></uni-icons>
								</view>
							</picker>
						</view>
						<!-- 解除处分审批弹窗 -->
						<view class="form-item" v-if="relieveShow">
							<label class="label"><text class="required">*</text>处分期间表现</label>
							<textarea v-model="taskForm.ideologicalEducation">
							</textarea>
						</view>
						<!-- 解除处分 归档-->
						<view class="form-item" v-if="relieveServiceShow">
							<label class="label"><text class="required">*</text>解除处分文号</label>
							<input type="text" placeholder-class="placeholderColor" v-model="taskForm.relieveNumber"
								placeholder="请输入解除处分文号" />
						</view>
						<view class="form-item" v-if="dispositionServiceShow||relieveServiceShow">
							<label class="label"><text class="required">*</text>处分/解除下文</label>
							<view class="file">
								<uni-file-picker @delete="onRemovefile" @select="onSelectFile" :auto-upload="false"
									file-mediatype="all" file-extname="doc,xls,ppt,txt,pdf,xlsx">
									<text class="add">+ 选择文件</text>
								</uni-file-picker>
								<view class="tip">
									<!-- 请上传大小不超过5MB，格式为doc/xls/ppt/txt/pdf/xlsx的文件 -->
									<text>请上传大小不超过<text class="emphasize">5MB</text> </text>
									<text>格式为<text class="emphasize">doc/xls/ppt/txt/pdf/xlsx</text>的文件</text>
								</view>
							</view>
							<!-- <uni-file-picker @delete="onRemovefile" @select="onSelectFile" :auto-upload="false"
								file-mediatype="all" file-extname="doc,xls,ppt,txt,pdf,xlsx"></uni-file-picker>
							<view class="tip">
								<text>文件大小:5MB以下</text>
								<text>文件格式: doc/xls/ppt/txt/pdf/xlsx</text>
							</view> -->
						</view>
					</scroll-view>
					<!-- 下载解除处分下文按钮 -->
					<view class="form-item download" v-if="showFileDowload">
						<image class="file-icon" src="../../static/file.png" mode="widthFix"></image>
						<text @tap="fileUpload">下载解除处分下文</text>
						<!-- <button @tap="fileUpload" size="mini" type="warn">下载解除处分下文</button> -->
					</view>
				</view>
				<view class="btns">
					<button type="default" @tap="onCancel">取消</button>
					<button type="primary" @tap="approveDialogConfirm">确定</button>
				</view>
			</view>
		</uni-popup>
		<!-- 回退弹窗 -->
		<uni-popup class="popup return-dialog" ref="returnDialog" type="dialog" background-color="#fff">
			<view class="popup-content">
				<view class="title">
					退回流程
				</view>
				<view class="content">
					<view class="form-item">
						<label>退回节点</label>
						<scroll-view scroll-y="true">
							<view class="list">
								<view class="item" @tap="taskDotChange(index,item)"
									:class="index==taskDotIndex?'active':''" v-for="(item,index) in returnTaskList"
									:key="index">
									{{item.name}}
								</view>
							</view>
						</scroll-view>
					</view>
					<view class="form-item">
						<label><text class="required">*</text>退回意见</label>
						<textarea v-model="taskForm.comment"></textarea>
					</view>
				</view>
				<view class="btns">
					<button type="default" @tap="onCancel">取消</button>
					<button type="primary" @tap="returnDialogConfirm">确定</button>
				</view>
			</view>
		</uni-popup>
		<!-- 驳回弹窗 -->
		<uni-popup ref="rejectDialog" type="dialog">
			<uni-popup-dialog mode="input" title="驳回" v-model="inputReject" @confirm="rejectDialogConfirm"
				placeholder="请输入驳回理由"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import Nav from "@/components/navs/navs.vue"
	import FlowStep from "@/components/flow-step/flow-step.vue"
	import {
		baseUrl
	} from "@/config.js";
	import uploadFile from "@/plugins/upload.js";
	import {
		getLeaveApplicationByProcInsId,
		complete,
		reject,
		returnList,
		returnTask,
		getDisciplinaryApplicationByProcInsId,
		getStuDisciplinaryRelieveByProcInsId,
		updateDisciplinaryApplication
	} from "@/api/task.js";
	import {
		updateRelieve
	} from "@/api/applyrelieve/applyrelieve.js";
	import { checkRole } from '@/utils/permission'; // 权限判断函数
	export default {
		components: {
			Nav,
			FlowStep
		},
		data() {
			return {
				navs: [{
						text: "表单信息",
						val: 0
					},
					{
						text: "流程跟踪",
						val: 1
					}
				],
				navIndex: 0,
				taskDotIndex: 0,
				returnTaskList: [], // 回退列表数据
				role: uni.getStorageSync("roles"),
				// 表单参数：目前是考勤表单
				// form: {},
				baseImgUrl: baseUrl,
				status: 'loading',
				formData: null,
				procInsId: '',
				deployId: '',
				tag: "",
				//审批弹窗内容
				inputApprove: "",
				inputReject: "",
				attachments: [],
				category: null, // 流程分类
				leaveForm: false, // 请假表单
				disposalForm: false, // 处分表单
				relieveForm: false, // 解除处分表单
				relieveShow: false, //审批 解除处分弹窗表单
				// violationTime: "请选择违纪日期", //违纪时间
				dispositionServiceShow: false, //处分下文输入框显示
				relieveServiceShow: false, //处分下文输入框显示
				showLetterService: false, //处分送达书是否展示
				dispositionServiceContent: '', //处分下文
				pdfURL: '', // pdf路径
				letterServiceContent: '', // 送达书文字
				ideologicalEducationShow: false, // 处分期间表现输入框
				showFileDowload: false, //是否显示下载下文
				taskName: null, // 任务节点
				taskForm: {
					returnTaskShow: false, // 是否展示回退表单
					delegateTaskShow: false, // 是否展示回退表单
					defaultTaskShow: true, // 默认处理
					comment: '', // 意见内容
					procInsId: '', // 流程实例编号
					instanceId: '', // 流程实例编号
					deployId: '', // 流程定义编号
					taskId: '', // 流程任务编号
					procDefId: '', // 流程编号
					targetKey: '',
					variables: {
						variables: {},
					},
					penaltyNumber: '',
					letterServiceContent: '',
					violationDate: '',
					relieveNumber: '',
					dispositionServiceContent: '',
					ideologicalEducation: '',
				},
				btnShow:false,
			};
		},
		onLoad(option) {
			console.log(this.role)
			let query = JSON.parse(option.query);
			this.taskId = query.taskId;
			this.procInsId = query.procInsId;
			this.category = query.category;
			this.tag = query.tag;
			this.taskForm.deployId = query.deployId;
			this.taskForm.instanceId = query.procInsId
			this.taskForm.procInsId = query.procInsId
			this.taskForm.executionId = query.executionId
			this.taskForm.taskId = query.taskId
			this.taskName = query.taskName
			this.startUser = query.startUser;
			// 如果任务名是其中的两个，则改变审批意见的输入框内容
			if ((this.taskName == '学务干事审批归档' || this.taskName == '学生教育管理科审批归档') && this.category == 'disposal') {
				this.dispositionServiceShow = true //处分下文输入框显示
				this.taskForm.letterServiceContent = '你因  ，根据《广西水利电力职业技术学院学生违纪处分规定》  的相关规定，决定给予你 ，处分期限  。'
			}
			if ((this.taskName == '学务干事审批归档' || this.taskName == '学生教育管理科审批归档') && this.category == 'relieve') {
				this.relieveServiceShow = true // 解除处分
			}
			if ((this.taskName == '学生接收' || this.taskName == '申请人（辅导员）接收') && this.category == 'disposal') {
				this.showLetterService = true
			}
			if (this.taskName == '学生接收' && this.category == 'relieve') {
				this.showFileDowload = true
			}
			if (this.taskName == '辅导员意见审批' && this.category == 'relieve') {
				this.relieveShow = true;
			}
			this.getFormDetail();
			if (this.tag == 1) {
				this.getReturnList();
			}
			this.btnShow = !checkRole(['teststu'])
		},
		methods: {
			navChange(index) {
				this.navIndex = index;
			},
			taskDotChange(index, item) {
				this.taskDotIndex = index;
				this.taskForm.targetKey = item.id;
			},
			penaltyTypeMethodFormat(penaltyType) {
				// 0-警告；1-严重警告；2-记过；3-留校察看；4-开除学籍
				const penaltyTypes = {
					0: '警告',
					1: '严重警告',
					2: '记过',
					3: '留校察看',
					4: '开除学籍',
				};

				if (penaltyTypes.hasOwnProperty(penaltyType)) {
					return penaltyTypes[penaltyType];
				} else {
					return '未知惩罚类型';
				}
			},
			onReturn() {
				this.$refs.returnDialog.open();
			},
			getReturnList() {
				returnList(this.taskForm).then((res) => {
					this.returnTaskList = res.data
				})
			},
			onCancel() {
				this.$refs.approveDialog.close();
				this.$refs.returnDialog.close();
			},
			//回退确认
			returnDialogConfirm() {
				if (this.taskForm.targetKey == "") {
					this.taskForm.targetKey = this.returnTaskList[0].id;
				}
				if (this.taskForm.comment == "") {
					uni.showToast({
						title: `请填写回退意见`,
						icon: "none"
					});
					return;
				}
				uni.showLoading({
					title: "正在回退"
				});
				returnTask(this.taskForm).then((res) => {
					uni.hideLoading();
					uni.showToast({
						title: res.msg
					})
					uni.navigateBack({
						success: () => {
							const pages = getCurrentPages();
							if (pages.length > 0) {
								const prevPage = pages[pages.length - 2]
								if (prevPage && typeof prevPage.getList === 'function') {
									prevPage.handleChange(2);
								}
							}

						}
					})
				})
				this.$refs.returnDialog.close();
			},
			onComplete() {
				this.$refs.approveDialog.open();
			},
			onReject() {
				this.$refs.rejectDialog.open();
			},
			getFormDetail() {
				let sdata = this.procInsId;
				if (this.category == 'leave') {
					this.leaveForm = true
					// 查询表单数据
					getLeaveApplicationByProcInsId(sdata).then(res => {
						this.formData = res.data;
						if (res.data.attachment != null) {
							this.attachments = res.data.attachment.split(',');
						}
					})
				} else if (this.category == 'disposal') {
					this.disposalForm = true;
					getDisciplinaryApplicationByProcInsId(sdata).then(res => {
						this.formData = res.data;
						this.pdfURL = baseUrl + res.data.dispositionService;
					})
				} else if (this.category == 'relieve') {
					console.log('relieve');
					this.relieveForm = true
					getStuDisciplinaryRelieveByProcInsId(sdata).then(res => {
						this.formData = res.data;
						this.pdfURL = baseUrl + res.data.relieveService
					})
				}
			},
			approveDialogConfirm() {
				console.log(this.taskForm);
				let requiredFields = [];
				if ((this.taskName == '学务干事审批归档' || this.taskName == '学生教育管理科审批归档') && this.category ==
					'disposal') {
					requiredFields = [
						'penaltyNumber',
						'letterServiceContent',
						'violationDate',
						'dispositionServiceContent'
					];
				} else if (this.taskName == '辅导员意见审批' && this.category == 'relieve') {
					requiredFields = [
						'ideologicalEducation'
					];
				} else if ((this.taskName == '学务干事审批归档' || this.taskName == '学生教育管理科审批归档') && this
					.category == 'relieve') {
					requiredFields = [
						'dispositionServiceContent',
						'relieveNumber'
					];
				}
				const emptyField = requiredFields.find(field => this.taskForm[field] === "");
				if (emptyField) {
					uni.showToast({
						title: `请填写完必填项内容`,
						icon: "none"
					})
					return;
				}
				this.taskForm.comment = '同意'
				uni.showLoading({
					title: "正在审批"
				});
				complete(this.taskForm).then(res => {
					if (res.code == 200) {
						if ((this.taskName == '学务干事审批归档' || this.taskName == '学生教育管理科审批归档') && this.category ==
							'disposal') {
							this.formData.dispositionService = this.taskForm.dispositionServiceContent
							this.formData.penaltyNumber = this.taskForm.penaltyNumber
							this.formData.violationDate = this.taskForm.violationDate
							this.editDisciplinaryApplication();
						} else if ((this.taskName == '学务干事审批归档' || this.taskName == '学生教育管理科审批归档') && this
							.category == 'relieve') {
							this.formData.relieveService = this.taskForm.dispositionServiceContent
							this.formData.relieveNumber = this.taskForm.relieveNumber
							this.updateRelieve()
						} else if (this.taskName == '辅导员意见审批' && this.category == 'relieve') {
							this.formData.ideologicalEducation = this.taskForm.ideologicalEducation;
							this.updateRelieve();
						}
						uni.showToast({
							title: "审批成功"
						});
						uni.hideLoading();
						uni.navigateBack({
							success: () => {
								const pages = getCurrentPages();
								if (pages.length > 0) {
									const prevPage = pages[pages.length - 2]
									if (prevPage && typeof prevPage.getList === 'function') {
										prevPage.handleChange(2);
									}
								}

							}
						})

					}
				})
			},
			editDisciplinaryApplication() {
				this.formData.penaltyStatus = '0'
				this.formData.letterService = this.taskForm.letterServiceContent
				updateDisciplinaryApplication(this.formData).then((response) => {
					uni.showToast({
						title: response.msg
					})
				})
			},
			updateRelieve() {
				updateRelieve(this.formData).then((response) => {
					uni.showToast({
						title: response.msg
					})
				})
			},
			//下载文档
			fileUpload() {
				console.log(this.pdfURL);
			},
			rejectDialogConfirm() {
				uni.showLoading({
					title: "正在驳回"
				});
				let sData = {
					taskId: this.taskId,
					comment: this.inputReject
				}
				if (this.inputReject == "") {
					uni.showToast({
						title: `请填写驳回原因`,
						icon: "none"
					})
					return;
				}
				reject(sData).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: "已驳回"
						})
						uni.hideLoading();
						uni.navigateBack({
							success: () => {
								const pages = getCurrentPages();
								if (pages.length > 0) {
									const prevPage = pages[pages.length - 2]
									if (prevPage && typeof prevPage.getList === 'function') {
										prevPage.handleChange(2);
										console.log('刷新已办任务数据');
									}
								}
							}
						})
					}
				})
			},
			previewImage(attachmentArray, i) {
				let imgs = attachmentArray.map(img => {
					return this.baseImgUrl + img
				})
				uni.previewImage({
					urls: imgs, // 图片数组
					current: i // 当前显示图片的索引，这里假设默认显示第一张图片
				});
			},
			//移除文件
			onRemovefile(file) {
				let fileListArray = this.taskForm.dispositionServiceContent.split(',');
				fileListArray.splice(file.index, 1);
				this.taskForm.dispositionServiceContent = fileListArray.join(',');
			},
			//上传文件
			onSelectFile(file) {
				uploadFile('/common/upload', file.tempFilePaths[0]).then((res) => {
					let result = JSON.parse(res);
					if (result.code == 200) {
						uni.showToast({
							title: "文件上传成功"
						})
						if (this.taskForm.dispositionServiceContent !== "") {
							this.taskForm.dispositionServiceContent = this.taskForm.dispositionServiceContent +
								"," + result.fileName;
						} else {
							this.taskForm.dispositionServiceContent = result.fileName;
						}
					}
				})
			},
			onChangeTime(e) {
				this.taskForm.violationDate = e.detail.value;
			},
			//销假
			cancelLeave() {
				uni.navigateTo({
					// url: "/pages/applyleave/cancellationLeave?procInsId="+this.procInsId
					url:`/pages/applyleave/cancellationLeave?query=${JSON.stringify(this.taskForm)}`
				})
			}
		},

	};
</script>

<style scoped lang="scss">
	.detail {
		padding-top: 90rpx;

		.container {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 10rpx;

			.form-item {
				width: 95%;
				height: 80rpx;
				display: flex;
				align-items: center;
				margin-bottom: 20rpx;
				justify-content: space-between;
				border-bottom: 1px solid #ededee;

			}

			.custom-input {
				width: 100%;
			}

			.form-text {
				width: 95%;
				margin-bottom: 20rpx;
				border-bottom: 1px solid #ededee;
			}

			.form-img {
				width: 100px;
				height: 100px;
				margin-bottom: 20rpx;
				border-bottom: 1px solid #ededee;
			}

			.example-body {
				margin-top: 20rpx;
				margin-bottom: 20rpx;
			}

			.txt {
				margin-top: 20rpx;
			}

			.label {
				text-align: right;
				margin-right: 20rpx;
				text-wrap: nowrap;
			}

			.select {
				color: #888889;
				white-space: nowrap;
				/* 防止换行 */
				overflow: hidden;
				/* 隐藏溢出部分 */
				text-overflow: ellipsis;
				/* 显示省略号 */
			}

			.uni-input {
				color: #888889;
				text-align: right;
			}

			.btn {
				width: 100%;
				height: 90rpx;
				display: flex;
				justify-content: space-between;

				position: fixed;
				bottom: 20px;
				left: 0;
				margin: 0 auto;
			}

			button {
				width: 30%;
				background-color: #87CEFA;
				color: white;
			}

			.form-address {

				width: 100%;
				display: flex;
				justify-content: space-between;
			}

			.labelsafe {
				color: red;
			}

			.form-canvas {
				width: 95%;
				height: 700rpx;
			}

			.tab-box {
				width: 80%;
				height: 100vh;
				background-color: #f0f0f0;

				.success-img {
					width: 90%;
					height: 300rpx;

				}
			}

			.btns {
				display: flex;
				position: fixed;
				bottom: 0;
				left: 0;
				right: 0;

				button {
					height: 50px;
					line-height: 50px;
					// width: 50%;
					flex: 1;
					border-radius: 0;

					&.turn-down {
						background-color: #FF3334;
					}

					&.return {
						background-color: #FFBA00;
					}

					&.submit {
						background-color: #0092FF;
					}
				}
			}
		}

		.progress {
			padding: 0 30rpx 30rpx;

			.title {
				font-weight: bold;
				color: #202020;
				display: inline-block;
				font-size: 30rpx;
				margin-bottom: 30rpx;
			}
		}

		.popup {
			.popup-content {
				width: 90vw;
				max-height: 86vh;
				overflow: scroll;
				// padding: 0 40rpx;

				.title {
					font-size: 40rpx;
					font-weight: bold;
					text-align: center;
					margin: 20rpx 0;
				}

				.content {
					padding: 0 40rpx;

					.show-letter {
						.title {
							font-size: 30rpx;
						}

						.stu-name {
							margin-bottom: 8rpx;
						}

						.desc {
							color: #797979;
						}

						.bottom {
							button {
								margin: 20rpx 0;
							}

							.gaizhang {
								text-align: right;
								position: relative;

								image {
									width: 200rpx;
								}

								.time {
									position: absolute;
									right: 30rpx;
									bottom: 55rpx;
									display: flex;
									flex-direction: column;
								}


							}
						}
					}

					.form-item {
						.required {
							color: red;
							margin-right: 8rpx;
						}

						&.download {
							margin: 50rpx 0 30rpx;
							display: flex;
							align-items: center;
							color: #4097FE;
							justify-content: center;

							.file-icon {
								width: 50rpx;
								margin-right: 20rpx;
							}

							text {
								border-bottom: 1px solid #4097FE;
								padding-bottom: 2px;
							}
						}

						.label {
							display: inline-block;
							margin: 30rpx 0 20rpx;
							color: #202020;
							font-weight: 600;
						}

						.file {
							border: 1px solid #E1E1E1;
							display: flex;
							flex-direction: column;
							align-items: center;
							padding: 40rpx 0;
							border-radius: 16rpx;

							.uni-file-picker {
								text-align: center;

								.add {
									font-size: 30rpx;
									display: inline-block;
									margin-bottom: 20rpx;
								}

								/deep/ .uni-file-picker__lists {
									border-color: #4097FE !important;
									border-radius: 0 !important;
								}

								/deep/ .files__name {
									color: #4097FE;
								}
							}

							.tip {
								display: flex;
								flex-direction: column;
								color: #999;
								margin-top: 20rpx;
								font-size: 24rpx;

								text:first-child {
									margin-bottom: 10rpx;
								}

								.emphasize {
									color: red;
								}

							}
						}


						input {
							display: inline-block;
							padding: 0 20rpx;
							height: 70rpx;
						}

						textarea {
							height: 200rpx;
							padding: 10rpx;
						}

						.placeholderColor {
							color: #D8D8D8;
						}

						input,
						textarea {
							width: 100%;
							border: 1px solid #E1E1E1;
							border-radius: 16rpx;

						}

						picker {
							border: 1px solid #E1E1E1;
							height: 70rpx;
							line-height: 70rpx;
							padding: 0 30rpx;

							.uni-input {
								display: flex;
								color: #797979;

								.val {
									flex: 1;
								}
							}
						}

						.uni-file-picker {
							/deep/ .uni-progress-bar {
								background-color: transparent !important;
							}
						}

					}
				}

				.btns {
					display: flex;
					margin-top: 80rpx;

					button {
						flex: 1;
						border-radius: 0;
						border-bottom: 0;

						&:first-child {
							background-color: transparent;
							border: 1px solid #4097FE;
							border-bottom: 0;
							color: #4097FE;
						}
					}
				}
			}
		}

		.return-dialog {
			.form-item {
				label {
					font-weight: bold;
					display: inline-block;
					margin-bottom: 10px;
				}

				&:last-child {
					margin-top: 15px;
				}

				.list {
					height: auto;
					max-height: 200px;
					display: flex;
					flex-wrap: wrap;
					// height: 200px;
					// display: flex;
					// flex-wrap: wrap;

					.item {
						width: 100%;
						height: 40px;
						line-height: 40px;
						text-align: center;

						&.active {
							background-color: #0092FF;
							color: white;
						}
					}
				}
			}
		}
	}
</style>
