<template>
	<div class="companyManagement">
		<div class="companyManagement1">
			<!-- <el-button type="primary" icon="el-icon-search">搜索</el-button> -->
			<div class="companyManagement1-L">
				<el-button type="primary" icon="el-icon-plus" @click="NewsMang">新增公司</el-button>
			</div>
			<div class="companyManagement1-R">
				<div class="companyManagement1-Rtx">
					搜索：
				</div>
				<el-input v-model="pages.T_name" placeholder="请输入公司名称" @keyup.enter.native="search" clearable>
				</el-input>
			</div>
		</div>
		<div class="companyManagement2">
			<el-table :data="tableData" border size="small">
				<el-table-column label="公司名称" width="250">
					<template slot-scope="scope">
						<span>{{ scope.row.T_name }}</span>
					</template>
				</el-table-column>
				<el-table-column label="隐藏/公开" width="180">
					<template slot-scope="scope">
						<el-switch v-model="scope.row.T_Show" active-color="#409EFF" inactive-color="#ccc"
							:inactive-value="0" :active-value="1" @change="Changswitch(scope.row)">
						</el-switch>
					</template>
				</el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scope">
						<el-button size="small" @click="QuestsFun(scope.row)">任务管理</el-button>
						<el-button size="small" @click="RedactFun(scope.row)">编辑公司</el-button>
						<el-button size="small" @click="DeleteFun(scope.row)">删除公司</el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<div class="companyManagement3">
			<el-pagination @current-change="handleCurrentChange" :current-page="pages.page" :page-size="pages.page_z"
				layout="total, prev, pager, next, jumper" :total="total">
			</el-pagination>
		</div>
		<el-drawer :title="showDra" :visible.sync="dialog" direction="rtl" ref="drawer">
			<div class="demo-drawers">
				<el-form :model="form" :rules="rules" ref="ruleForm">
					<el-form-item label="公司名称" :label-width="LabelWidth" prop="T_name">
						<el-input v-model="form.T_name" autocomplete="off"></el-input>
					</el-form-item>
					<!-- <el-form-item label="权限" :label-width="LabelWidth" prop="T_power">
						<el-select v-model="form.T_power" placeholder="请选择活动区域">
							<el-option :label="item.T_name" :value="item.Id" v-for="(item,index) in optionsPir"
								:key="index"></el-option>
						</el-select>
					</el-form-item> -->
					<!-- <el-form-item label="用户名" :label-width="LabelWidth" prop="T_user">
						<el-input v-model="form.T_user" autocomplete="off"></el-input>
					</el-form-item> -->
					<el-form-item label="密码" :label-width="LabelWidth" prop="T_passstr">
						<el-input v-model="form.T_passstr" autocomplete="off" show-password></el-input>
					</el-form-item>
					<el-form-item :label-width="LabelWidth">
						<el-button type="primary" @click="submitForm('ruleForm')">
							确 定
						</el-button>
						<el-button @click="dialog=false">取 消</el-button>
					</el-form-item>
				</el-form>
			</div>
		</el-drawer>
		<el-drawer title="任务列表" :visible.sync="Drawer" direction="rtl" ref="drawer" size="90%">
			<div class="demo-drawers">
				<el-button type="primary" icon="el-icon-plus" @click="NewsRenwu">添加任务</el-button>
				<div style="margin-top: 10px;">
					<el-table :data="tableData1" border size="small">
						<el-table-column label="任务名称" width="180">
							<template slot-scope="scope">
								<span>{{ scope.row.T_name }}</span>
							</template>
						</el-table-column>
						<el-table-column label="流程" width="400">
							<template slot-scope="scope">
								<!-- <el-steps :active="scope.row | stepVal()" finish-status="success">
								  <el-step title="实施方案" :description="scope.row.T_scheme_name"></el-step>
								  <el-step title="数据采集" :description="scope.row.T_collection_name"></el-step>
								  <el-step title="报告编写" :description="scope.row.T_reporting_name"></el-step>
								  <el-step title="交付审核" :description="scope.row.T_delivery_name"></el-step>
								</el-steps> -->


								<div class="steps">
									<div class="steps_start" :class="scope.row.T_scheme_state==0?'public0':'public1'">
										<div class="steps_start_lin">
											<div class="steps_start_lin1">
												<i
													:class="scope.row.T_scheme_state==1?'el-icon-check':'el-icon-close'"></i>
											</div>
											<div class="steps_start_lin2"></div>
										</div>
										<div class="steps_start_tit">
											实施方案
										</div>
										<div class="steps_start_txt">
											{{scope.row.T_scheme_name}}
										</div>
									</div>
									<div class="steps_process"
										:class="scope.row.T_collection_state!=4?'public0':'public1'">
										<div class="steps_start_lin">
											<div class="steps_start_lin1">
												<i
													:class="scope.row.T_collection_state==4?'el-icon-check':'el-icon-close'"></i>
											</div>
											<div class="steps_start_lin2">

											</div>
										</div>
										<div class="steps_start_tit">
											数据采集
										</div>
										<div class="steps_start_txt">
											{{scope.row.T_collection_name}}
										</div>
									</div>
									<div class="steps_process"
										:class="scope.row.T_reporting_state==0?'public0':'public1'">
										<div class="steps_start_lin">
											<div class="steps_start_lin1">
												<i
													:class="scope.row.T_reporting_state==1?'el-icon-check':'el-icon-close'"></i>
											</div>
											<div class="steps_start_lin2">

											</div>
										</div>
										<div class="steps_start_tit">
											报告编写
										</div>
										<div class="steps_start_txt">
											{{scope.row.T_reporting_name}}
										</div>
									</div>
									<div class="steps_end" :class="scope.row.T_delivery_state==0?'public0':'public1'">
										<div class="steps_start_lin">
											<div class="steps_start_lin1">
												<i
													:class="scope.row.T_delivery_state==1?'el-icon-check':'el-icon-close'"></i>
											</div>
										</div>
										<div class="steps_start_tit">
											交付审核
										</div>
										<div class="steps_start_txt">
											{{scope.row.T_delivery_name}}
										</div>
									</div>
								</div>
							</template>
						</el-table-column>
						<el-table-column label="隐藏/公开" width="80">
							<template slot-scope="scope">
								<el-switch v-model="scope.row.T_Show" active-color="#409EFF" inactive-color="#ccc"
									:inactive-value="0" :active-value="1" @change="Changswitch1(scope.row)">
								</el-switch>
							</template>
						</el-table-column>
						<el-table-column label="截止时间" width="180">
							<template slot-scope="scope">
								{{ scope.row.T_deadline }}
							</template>
						</el-table-column>
						<el-table-column label="操作">
							<template slot-scope="scope">
								<el-dropdown @command="commands($event,scope.row)">
									<div class="el-dropdown-link dropdown-links" style="">
										<el-button type="primary" plain>更多操作</el-button>
									</div>
									<el-dropdown-menu slot="dropdown">
										<el-dropdown-item command="a">查看日志</el-dropdown-item>
										<el-dropdown-item command="b">编辑任务</el-dropdown-item>
										<el-dropdown-item command="c">查看报告</el-dropdown-item>
										<el-dropdown-item command="d">删除</el-dropdown-item>
									</el-dropdown-menu>
								</el-dropdown>
							</template>
						</el-table-column>
					</el-table>
				</div>
				<div style="margin-top: 10px;">
					<el-pagination @current-change="handleCurrentChange111" :current-page="pages1.page"
						:page-size="pages1.page_z" layout="total, prev, pager, next, jumper" :total="total1">
					</el-pagination>
				</div>
			</div>
			<el-drawer title="查看日志" :append-to-body="true" :visible.sync="innerDrawer1" size="60%">
				<!-- 日志 -->
				<div style="padding: 20px;">
					<el-table :data="tableData2" border size="small">
						<el-table-column label="用户名" :show-overflow-tooltip="true">
							<template slot-scope="scope">
								<span>{{ scope.row.T_name }}</span>
							</template>
						</el-table-column>
						<el-table-column label="分类" :show-overflow-tooltip="true">
							<template slot-scope="scope">
								<span>{{ scope.row.Logs_Title }}</span>
							</template>
						</el-table-column>
						<el-table-column label="详情" :show-overflow-tooltip="true">
							<template slot-scope="scope">
								<span>{{ scope.row.Logs_Txt }}</span>
							</template>
						</el-table-column>
						<el-table-column label="时间" :show-overflow-tooltip="true">
							<template slot-scope="scope">
								<span>{{ scope.row.CreateTime }}</span>
							</template>
						</el-table-column>
					</el-table>
					<div style="margin-top: 10px;">
						<el-pagination @current-change="handleCurrentChange2" :current-page="pages2.page"
							:page-size="pages2.page_z" layout="total, prev, pager, next, jumper" :total="total2">
						</el-pagination>
					</div>
				</div>
			</el-drawer>
			<el-drawer title="查看报告" :append-to-body="true" :visible.sync="innerDrawer2" size="80%">
				<!-- 查看报告 -->

				<div style="padding: 20px;">
					<div style="margin-bottom:50px;display: flex;">
						<el-descriptions title="报告信息" border>
							<el-descriptions-item label="报告名称">{{BaoGaoData.T_name}}</el-descriptions-item>
							<el-descriptions-item label="创建时间">{{BaoGaoData.CreateTime}}</el-descriptions-item>
							<el-descriptions-item label="修改时间">{{BaoGaoData.UpdateTime}}</el-descriptions-item>
						</el-descriptions>
					</div>
					<div style="margin-bottom: 50px;">
						<div style="margin-bottom:20px;font-size: 16px; font-weight: 700;">查看/下载pdf</div>
						<div>
							<el-button type="primary" :disabled="BaoGaoData.T_pdf1===''?true:false" size="small"
								icon="el-icon-download" @click="ShowPdf(0,BaoGaoData.T_pdf1)">验证方案</el-button>
							<el-button type="primary" :disabled="BaoGaoData.T_pdf2===''?true:false" size="small"
								icon="el-icon-download" @click="ShowPdf(0,BaoGaoData.T_pdf2)">验证报告</el-button>
							<el-button type="primary" :disabled="BaoGaoData.T_pdf3===''?true:false" size="small"
								icon="el-icon-download" @click="ShowPdf(1,BaoGaoData.T_pdf3)">校准证书</el-button>
							<el-button type="primary" size="small" icon="el-icon-download" @click="Dowload">下载验证数据
							</el-button>

						</div>
					</div>
					<div style="margin-bottom: 50px;">
						<div style="margin-bottom:20px;font-size: 16px;display: flex;align-items: center;">
							<div style="font-weight: 700;">验证设备数据</div>
							<!-- <div style="display: flex;align-items: center;font-size: 12px;color: #409EFF;border-bottom: 1px solid #409EFF;margin-left: 20px;cursor: pointer;">
								<i class="el-icon-download"></i>
								<div style="margin-left:2px;">下载数据</div>
							</div> -->
						</div>
						<div class="Baogao">
							<el-date-picker class="s1" v-model="TimeValue" size="small"
								value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" range-separator="至"
								start-placeholder="开始日期" end-placeholder="结束日期" @change="searchTimeData">
							</el-date-picker>
							<el-input size="small" class="s1" v-model="form2.T_sn" @keyup.enter.native="search1"
								placeholder="请输入SN" clearable></el-input>
							<el-input size="small" class="s1" v-model="form2.T_id" @keyup.enter.native="search1"
								placeholder="请输入编号" clearable></el-input>
							<el-button size="small" class="s1" type="primary" icon="el-icon-search" @click="search1">搜索
							</el-button>
						</div>


						<el-table :data="tableData3" border size="small">
							<el-table-column label="ID">
								<template slot-scope="scope">
									<span>{{ scope.row.ID }}</span>
								</template>
							</el-table-column>
							<el-table-column label="设备编号">
								<template slot-scope="scope">
									{{ scope.row.T_id }}
								</template>
							</el-table-column>
							<el-table-column label="SN">
								<template slot-scope="scope">
									<span>{{ scope.row.T_sn }}</span>
								</template>
							</el-table-column>
							<el-table-column label="温度℃">
								<template slot-scope="scope">
									{{ scope.row.T_t }}
								</template>
							</el-table-column>
						</el-table>
					</div>
					<div class="companyManagement3">
						<el-pagination @current-change="handleCurrentChange3" :current-page="form2.page"
							:page-size="form2.page_z" layout="total, prev, pager, next, jumper" :total="total3">
						</el-pagination>
					</div>
				</div>
				<el-drawer title="校准证书" :visible.sync="innerDrawer211" direction="rtl" ref="drawers"
					:append-to-body="true" :modal-append-to-body="false">
					<div class="demo-drawers" style="z-index: 999999;">
						<div style="margin-bottom: 20px;font-size: 14px;color: #C0C4CC;">请选择对应的校准证书查看:</div>
						<div style="display: grid;grid-template-columns: 1fr 1fr;grid-gap: 10px;">
							<el-radio v-model="radio1" @input="radioInput" :label="item" style="margin: 0;" border
								v-for="item,index in radioXuan" :key="index">{{item.split(",")[0]}}</el-radio>
						</div>
					</div>
				</el-drawer>
			</el-drawer>
			<el-drawer :title="title" :append-to-body="true" :visible.sync="innerDrawer">
				<div style="padding: 20px;">
					<el-form :model="form1" :rules="rules1" ref="ruleForm1">
						<el-form-item label="任务名称" label-width="80px" prop="T_name">
							<el-input v-model="form1.T_name" autocomplete="off"></el-input>
						</el-form-item>
						<el-form-item label="截至时间" label-width="80px" prop="T_deadline">
							<el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"
								v-model="form1.T_deadline">
							</el-date-picker>
						</el-form-item>
						<el-form-item label="任务模板" label-width="80px">
							<div style="display: flex;align-items: center;">
								<el-form-item prop="T_VerifyTemplate_class">
									<el-cascader v-model="form1.T_VerifyTemplate_class" :props="optionProps" placeholder="请选择模板分类"
										:options="optionsData" @change="casChange" style="margin-right: 10px;">
									</el-cascader>
								</el-form-item>
								<el-form-item prop="T_VerifyTemplate_id">
									<el-select v-model="form1.T_VerifyTemplate_id"
										placeholder="先选择模板分类/选择任务模板">
										<el-option :label="item.T_name" :value="item.T_VerifyTemplate_id"
											v-for="(item,index) in optionsRw" :key="index"></el-option>
									</el-select>
								</el-form-item>
							</div>
						</el-form-item>	
						<el-form-item label="实施方案" label-width="80px" prop="T_scheme">
							<el-select v-model="form1.T_scheme" placeholder="请选择实施方案">
								<el-option :label="item.T_name+'('+item.T_power_name+')'" :value="item.T_uuid"
									v-for="(item,index) in optionsFz" :key="index"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="数据采集" label-width="80px" prop="T_collection">
							<el-select v-model="form1.T_collection" placeholder="请选择数据采集">
								<el-option :label="item.T_name+'('+item.T_power_name+')'" :value="item.T_uuid"
									v-for="(item,index) in optionsFz" :key="index"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="报告编辑" label-width="80px" prop="T_reporting">
							<el-select v-model="form1.T_reporting" placeholder="请选择报告编辑">
								<el-option :label="item.T_name+'('+item.T_power_name+')'" :value="item.T_uuid"
									v-for="(item,index) in optionsFz" :key="index"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="交付审核" label-width="80px" prop="T_delivery">
							<el-select v-model="form1.T_delivery" placeholder="请选择交付审核">
								<el-option :label="item.T_name+'('+item.T_power_name+')'" :value="item.T_uuid"
									v-for="(item,index) in optionsFz" :key="index"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label-width="80px">
							<el-button type="primary" @click="submitForm1('ruleForm1')">
								确 定
							</el-button>
							<el-button @click="innerDrawer=false">取 消</el-button>
						</el-form-item>
					</el-form>
				</div>
			</el-drawer>
		</el-drawer>
		<pdf ref="pdf"></pdf>
	</div>
</template>

<script>
	import {
		UserList,
		UserUp,
		UserAdd,
		UserDel,
		UserPowerAll,
		TaskList,
		TaskUp,
		TaskLogsList,
		TaskAdd,
		TempList,
		AdminList_All,
		TaskDel,
		TaskGet,
		TaskEx,
		DowloadExc,
		tempClassList
	} from "@/api/companyManagement"
	import pdf from "./pdf"
	import download from "downloadjs"
	export default {
		name: 'companyManagement',
		components: {
			pdf
		},
		filters: {
			stepVal(e) {
				if (e.T_scheme_state == 1) {
					return 1
				} else if (e.T_collection_state == 1) {
					return 2
				} else if (e.T_reporting_state == 1) {
					return 3
				} else if (e.T_delivery_state == 1) {
					return 4
				} else {
					return null
				}
			}
		},
		data() {
			return {
				optionProps: {
					value: 'Id',
					label: 'T_name',
					children: 'Children',
					checkStrictly: true
				},
				optionsData: [],
				TimeValue: '',
				showDra:'新增公司',
				form: {
					// T_power: '', // 权限
					T_name: '', // 某某公司名称
					// T_user: '', // 登录用户名
					T_pass: '', // 密码 MD5
					T_passstr: '12345678', // 密码明文
				},
				form2: {
					T_task_id: '', // 权限
					T_sn: '', // 某某公司名称
					T_id: '',
					Time_start: '', // 登录用户名
					Time_end: '', // 密码 MD5
					page: 1,
					page_z: 5,
				},
				rules: {
					T_power: [{
						required: true,
						message: '请选择权限',
						trigger: ['blur','change']
					}],
					T_name: [{
						required: true,
						message: '请输入公司名称',
						trigger: 'blur'
					}],
					// T_user: [{
					// 	required: true,
					// 	message: '请输入登录用户名',
					// 	trigger: 'blur'
					// }],
					T_passstr: [{
						required: true,
						message: '请输入密码',
						trigger: 'blur'
					}],
				},
				form1: {
					T_VerifyTemplate_class:[],
					T_name: '', // 任务名称
					T_uuid: '', // 用户的 UUID
					T_VerifyTemplate_id: '', // 任务模板id
					T_deadline: '', // 截止时间
					T_scheme: '', // 实施方案 负责人uuid
					T_collection: '', // 数据采集 负责人uuid
					T_reporting: '', //报告编写 负责人uuid
					T_delivery: '', // 交付审核 负责人uuid
				},
				rules1: {
					T_name: [{
						required: true,
						message: '请输入任务名称',
						trigger: 'blur'
					}],
					T_deadline: [{
						required: true,
						message: '请选择截止时间',
						trigger: 'blur'
					}],
					T_VerifyTemplate_class:[{
						required: true,
						message: '请选择模板分类',
						trigger: 'change'
					}],
					T_VerifyTemplate_id: [{
						required: true,
						message: '请选择任务模板',
						trigger: 'change'
					}],
					T_scheme: [{
						required: true,
						message: '请选择实施方案负责人',
						trigger: 'blur'
					}],
					T_collection: [{
						required: true,
						message: '请选择数据采集负责人',
						trigger: 'blur'
					}],
					T_reporting: [{
						required: true,
						message: '请选择报告编写负责人',
						trigger: 'blur'
					}],
					T_delivery: [{
						required: true,
						message: '请选择交付审核负责人',
						trigger: 'blur'
					}],
				},
				BaoGaoData: {},
				optionsPir: [],
				optionsRw: [],
				optionsFz: [],
				value: true,
				title: '添加任务',
				LabelWidth: "80px",
				LabelWidth1: "120px",
				loading: false,
				dialog: false,
				innerDrawer: false,
				innerDrawer1: false, //日志
				innerDrawer2: false, //查看报告
				innerDrawer211: false, //查看报告
				Drawer: false, //任务管理
				total: 0,
				total1: 0,
				total2: 0,
				total3: 0,
				pages: {
					page: 1,
					page_z: 10,
					T_name: ''
				},
				pages1: {
					T_uuid: '',
					T_name: '',
					page: 1,
					page_z: 5,
				},
				pages2: {
					T_task_id: '',
					page: 1,
					page_z: 10,
				},
				tableData: [],
				tableData1: [],
				tableData2: [],
				tableData3: [],
				blNum: null,
				radioXuan: [],
				radio1: '',
			}
		},
		// watch:{
		// 	innerDrawer(val){
		// 		if(!val){
		// 			// this.cascaderData = ''
		// 			for(let obj in this.form1){
		// 				console.log(obj)
		// 				if(obj!='T_task_id'){
		// 					this.form1[obj] = ''
		// 				}
		// 			}
		// 		}
		// 		console.log('变化',this.form1)
		// 	}
		// },
		mounted() {
			this.GetUserListApi()
		},
		methods: {
			//分类列表
			getTempApi() {
				tempClassList({}).then(res => {
					console.log('分类列表', res)
					if (res.data.Code == 200) {
						var arr = res.data.Data
						this.optionsData = this.recursion(arr)
					}
				})
			},
			recursion(items, childrenName = 'Children') {
				for (let i = 0; i < items.length; i++) {
					const item = items[i]
					// 当前对象存在children
					if (item && item[childrenName]) {
						// children为空数组时删除
						if (item[childrenName].length === 0) {
							delete item[childrenName]
						} else {
							// 递归当前children数组
							this.recursion(item[childrenName], childrenName = 'Children')
						}
					}
				}
				return items
			},
			casChange(e){
				this.form1.T_VerifyTemplate_id = ''
				if (e != undefined) {
					this.GetTempListApi(e)
				}
				console.log('选择发生变化',e,)
			},
			GetTempListApi(e) {
				TempList({
					T_class:e[e.length-1]
				}).then(res => {
					console.log('报错', res)
					if (res.data.Code === 200) {
						this.optionsRw = res.data.Data.List
					}
				})
			},
			radioInput() {
				var values = this.radio1.split(",")[1]
				this.$refs.pdf.SetPdf(values)
			},
			ShowPdf(e, obj) {
				if (e == 1) {
					this.radioXuan = obj.split("|")
					this.innerDrawer211 = true
				} else {
					this.$refs.pdf.SetPdf(e)
				}
			},
			
			submitForm1(formName) {
				let arrClass = {...this.form1}
				if(arrClass.length != 0){
					arrClass.T_VerifyTemplate_class = arrClass.T_VerifyTemplate_class.join('/')
				}
				console.log('提交11',arrClass)
				this.$refs[formName].validate((valid) => {
					if (valid) {
						if (this.blNum == 1) {
							this.GetTaskAddApi()
						} else {
							TaskUp(arrClass).then(res => {
								if (res.data.Code === 200) {
									this.$message.success('编辑成功')
									this.innerDrawer = false
									this.pages1.page = 1
									this.GetTaskListApi()
								}
							})
						}
					} else {
						return false;
					}
				});
			},
			GetTaskAddApi() {
				console.log('添加任务',this.form1)
				let arrClass = {...this.form1}
				if(arrClass.length != 0){
					arrClass.T_VerifyTemplate_class = arrClass.T_VerifyTemplate_class.join('/')
				}
				TaskAdd(this.form1).then(res => {
					console.log('添加', res)
					if (res.data.Code === 200) {
						this.$message.success('添加任务成功')
						this.innerDrawer = false
						this.pages1.page = 1
						this.GetTaskListApi()
					}
				})
			},
			NewsRenwu() {
				if (this.$refs.ruleForm1 != undefined) {
					this.$refs.ruleForm1.clearValidate()
				}
				this.innerDrawer = true
				this.blNum = 1
				
				for (let obj in this.form1) {
					if(obj=='T_task_id'){
						console.log('T_task_id')
					}else if(obj=='T_uuid'){
						console.log('T_uuid')
					}else{
						if(obj=='T_VerifyTemplate_class'){
							this.form1[obj] = []
						}else{
							this.form1[obj] = ''
						}
					}
				}
				this.optionsRw = []
				console.log('新增赋值2',this.form1)
				this.form1.T_uuid = this.pages1.T_uuid
				// this.form1 = this.$options.data().form
				this.getTempApi()
				// console.log('新增8888', this.$options.data(), this.pages1)
			},

			GetAdminList_AllApi() {
				AdminList_All({}).then(res => {
					console.log('负责人', res)
					if (res.data.Code === 200) {
						this.optionsFz = res.data.Data.List
					}
				})
			},
			
			QuestsFun(e) {
				this.pages1.T_uuid = e.T_uuid
				this.Drawer = true
				this.pages1.page = 1
				this.GetTaskListApi()
				this.GetAdminList_AllApi()
			},
			RedactFun(e){
				console.log(e)
				this.showDra = '编辑公司'
				this.form.T_uuid = e.T_uuid// 某某公司名称
				this.form.T_name = e.T_name// 某某公司名称
				this.form.T_power = e.T_power// 权限
				// this.form.T_user = e.T_user// 登录用户名
				this.form.T_pass = e.T_pass// 密码 MD5
				this.form.T_passstr = e.T_passstr// 密码明文

				this.dialog = true
				this.GetPowerAllApi()
				if (this.$refs.ruleForm != undefined) {
					this.$refs.ruleForm.clearValidate()
				}
			},
			DeleteFun(e){
				this.$confirm('此操作将删除公司,请谨慎使用, 是否继续?', '提示', {
					confirmButtonText: '删除',
					cancelButtonText: '取消',
					type: 'warning',
					center: true
					}).then(() => {
						UserDel({T_uuid:e.T_uuid}).then(res=>{
							if(res.data.Code==200) this.$message.success('删除成功!'); this.GetUserListApi()
						})
					}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			GetTaskListApi() {
				TaskList(this.pages1).then(res => {
					if (res.data.Code === 200) {
						this.tableData1 = res.data.Data.List
						this.total1 = res.data.Data.Num
					}
				})
			},
			NewsMang() {
				this.showDra = '新增公司'
				this.dialog = true
				Object.keys(this.form).forEach(item=>{this.form[item] = null})
				this.form.T_passstr = '12345678'
				this.GetPowerAllApi()
				if (this.$refs.ruleForm != undefined) {
					this.$refs.ruleForm.clearValidate()
				}
			},
			GetPowerAllApi() {
				UserPowerAll({}).then(res => {
					if (res.data.Code === 200) {
						this.optionsPir = res.data.Data.List
					}
				})
			},
			submitForm(formName) {
				this.$refs[formName].validate((valid) => {
					if (valid) {
						this.form.T_pass = this.$md5(this.form.T_passstr)
						this.showDra == '新增公司'?this.SetUserAddApi():this.SetUserUpApi()
					} else {
						return false;
					}
				});
			},
			SetUserAddApi() {
				UserAdd(this.form).then(res => {
					if (res.data.Code === 200) {
						this.$message.success('新增公司成功')
						this.dialog = false
						this.pages.page = 1
						this.GetUserListApi()
					}
				})
			},
			SetUserUpApi() {
				UserUp(this.form).then(res => {
					if (res.data.Code === 200) {
						this.$message.success('编辑公司成功')
						this.dialog = false
						this.pages.page = 1
						this.GetUserListApi()
					}
				})
			},
			Changswitch(val) {
				UserUp(val).then(res => {
					if (res.data.Code === 200) {
						this.$message.success('设置成功')
						this.GetUserListApi()
					}
				})
			},
			Changswitch1(val) {
				TaskUp(val).then(res => {
					if (res.data.Code === 200) {
						this.$message.success('设置成功')
						this.GetTaskListApi()
					}
				})
			},
			GetUserListApi() {
				UserList(this.pages).then(res => {
					if (res.data.Code === 200) {
						this.tableData = res.data.Data.List
						this.total = res.data.Data.Num
					}
				})
			},
			search() { //回车搜索
				this.pages.page = 1
				this.GetUserListApi()
			},
			handleCurrentChange111(val) {
				console.log('当前页', this.pages);
				this.pages1.page = val
				this.GetTaskListApi()
			},
			handleCurrentChange(val) {
				console.log('当前页', this.page);
				this.pages.page = val
				this.GetUserListApi()
			},
			handleCurrentChange2(val) {
				this.pages2.page = val
				this.GetTaskLogsListApi()
			},
			GetTaskLogsListApi() {
				TaskLogsList(this.pages2).then(res => {
					console.log('日志', res)
					if (res.data.Code === 200) {
						this.tableData2 = res.data.Data.List
						this.total2 = res.data.Data.Num
					}
				})
			},
			commands(e, obj) {
				console.log(e, obj)
				switch (e) {
					case 'a':
						this.pages2.T_task_id = obj.T_task_id
						this.innerDrawer1 = true
						this.GetTaskLogsListApi()
						break
					case 'b':
						if (this.$refs.ruleForm1 != undefined) {
							this.$refs.ruleForm1.clearValidate()
						}
						this.getTempApi()
						this.blNum = 2
						this.form1.T_name = obj.T_name
						this.form1.T_uuid = obj.T_uuid
						this.form1.T_VerifyTemplate_id = obj.T_VerifyTemplate_id
						this.form1.T_deadline = obj.T_deadline
						this.form1.T_collection = obj.T_collection
						this.form1.T_scheme = obj.T_scheme
						this.form1.T_reporting = obj.T_reporting
						this.form1.T_delivery = obj.T_delivery
						this.form1.T_task_id = obj.T_task_id
						if(obj.T_VerifyTemplate_class!=''){
							let arr = obj.T_VerifyTemplate_class.split('/')
							console.log('传值0',arr)
							this.form1.T_VerifyTemplate_class = arr.map(Number) 
							console.log('传值2',this.form1)
							this.GetTempListApi(this.form1.T_VerifyTemplate_class)
						}
						this.innerDrawer = true
						console.log('编辑999',obj,this.form1)
						break
					case 'c':
						TaskGet({
							T_task_id: obj.T_task_id
						}).then(res => {
							console.log('查看报告', res)
							if (res.data.Code === 200) {
								this.BaoGaoData = res.data.Data
							}
						})
						this.form2.T_task_id = obj.T_task_id
						this.GetTaskExApi()
						this.innerDrawer2 = true
						break
					default:
						this.$confirm('此操作将永久删除该任务, 是否继续?', '提示', {
							confirmButtonText: '立即删除',
							cancelButtonText: '取消',
							type: 'warning',
							center: true
						}).then(() => {
							TaskDel({
								T_task_id: obj.T_task_id
							}).then(res => {
								if (res.data.Code == 200) {
									this.$message.success('删除成功!')
									this.pages1.page = 1
									this.GetTaskListApi()
								}
							})
						}).catch(() => {
							this.$message({
								type: 'info',
								message: '已取消删除'
								});
					});
				}
			},
			GetTaskExApi() {
				TaskEx(this.form2).then(res => {
					console.log('威威', res)
					if (res.data.Code === 200) {
						this.tableData3 = res.data.Data.List
						this.total3 = res.data.Data.Num
					}
				})
			},
			search1() { //回车搜索
				this.form2.page = 1
				this.GetTaskExApi()
			},
			searchTimeData(e) {
				if (e != null) {
					this.form2.Time_start = e[0]
					this.form2.Time_end = e[1]
				} else {
					this.form2.Time_start = ''
					this.form2.Time_end = ''
				}
				this.form2.page = 1
				this.GetTaskExApi()
			},
			handleCurrentChange3(val) {
				console.log('当前页', this.page);
				this.form2.page = val
				this.GetTaskExApi()
			},
			Dowload() { //下载数据
				console.log('下载', this.form2, pams)
				var pams = {
					T_task_id: this.form2.T_task_id,
					T_sn_list: '',
					Time_start: this.form2.Time_start,
					Time_end: this.form2.Time_end
				}
				const loading = this.$loading({
					lock: true,
					text: '正在整理数据，请稍后...',
					spinner: 'el-icon-loading',
					background: 'rgba(0, 0, 0, 0.7)'
				});
				DowloadExc(pams).then(res => {
					console.log(res)
					if (res.data.Code === 200) {
						loading.close()
						download(res.data.Data);
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '../../assets/css/steps.scss';

	// 在填充数据之前隐藏
	[v-cloak] {
		display: none;
	}

	.el-input {
		margin-right: 10px;
		width: 200px;
	}

	.Baogao {
		// display: grid;
		// grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
		// grid-gap: 10px;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		margin-bottom: 20px;

		.s1 {
			margin-bottom: 10px;
			margin-right: 10px;
		}
	}

	.demo-drawers {
		padding: 20px;
	}

	/deep/.el-step__title {
		font-size: 12px !important;
		line-height: 23px;
	}

	.companyManagement {
		.companyManagement1 {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.companyManagement1-L {}

			.companyManagement1-R {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.companyManagement1-Rtx {
					min-width: 45px;
					font-size: 14px;
					color: #909399;
					user-select: none;
				}
			}
		}

		.companyManagement2 {
			margin-top: 20px;
		}

		.companyManagement3 {
			margin-top: 40px;
		}
	}
</style>
