<template>
	<div class="_box">
		<!-- 下拉选择公司 -->
		<!-- <div class="company-select" v-if="companys !== '' && companys.length > 1">
			<el-dropdown
				trigger="click"
				@command="selectComPany"
			>
				<span class="el-dropdown-link">
						{{companyName}}<i class="el-icon-arrow-down el-icon--right"></i>
				</span>
				<el-dropdown-menu slot="dropdown">
						<div v-for="item in companys" :key="item.id">
								<el-dropdown-item :command="item">{{item.companyName}}</el-dropdown-item>
						</div>
				</el-dropdown-menu>
			</el-dropdown>
		</div> -->
		<el-tabs v-model="activeName" @tab-click="handleClick">
			<el-tab-pane label="我的待办" name="myTask">
				<div>
					<!-- <div class="_title">我的待办事项<span></span></div> -->
					<div class="tableArea">
						<el-table
							individual-columns="individual-vue-table-columns"
              :individual-info="individualInfo"
              drag-column="individual-vue-table"
              @row-click="(e)=>{goDeal(e, 'deal')}"
							:data="tableData"
							v-loading="tableLoading"
							:height="tableHeight + 'px'"
							style="width: 100%" 
							ref="taskTable"
							border
							highlight-current-row>
							<!-- 序号 -->
							<el-table-column
								width="80px"
								type="index"
								label="序号"
								align="center">
							</el-table-column>
							<!-- tableKey表示为根据获取的tableData设置的header显示值列表 -->
							<el-table-column
								v-for ="(item, index) of tableKeys"
								:key="index"
								:label="item.label"
								:prop="item.key"
								:fixed="item.fixed"
								:width="item.width"
								header-align="center"
								align="center"
								sortable
								show-overflow-tooltip>
								<template slot-scope="scope">
			                        <span v-for="item in taskStatus" :key="item.value" :class="item.class" v-if="scope.column.property === 'status' && scope.row.status === item.value">
			                            {{item.label}}
			                        </span>
			                        <span v-if="scope.column.property !== 'status'">
			                            {{scope.row[scope.column.property]}}
			                        </span>
			                    </template>
							</el-table-column>
							<el-table-column
								label="操作"
								align="center"
								width="180">
								<template slot-scope="scope">
									<el-button
										type="text"
										size="mini"
										@click.native.stop="goDeal(scope.row, 'entrust')"
										v-privilege="activeMenu + 'DEAL'"
									>委托</el-button>
									<el-button
										type="text"
										size="mini"
										@click.native.stop="goDeal(scope.row, 'deal')"
										v-privilege="activeMenu + 'DEAL'"
									>处理</el-button>
									<el-button
										type="text"
										size="mini"
										@click.native.stop="goDeal(scope.row, 'see')"
										v-privilege="activeMenu + 'LOOK'"
									>详情</el-button>
									<el-button
										type="text"
										size="mini"
										@click.native.stop="goDeal(scope.row, 'track')"
										v-privilege="activeMenu + 'LOOK'"
									>跟踪</el-button>
								</template>
							</el-table-column>
						</el-table>
					</div>
					<div class="foot-style">
			            <el-pagination
			                @size-change="handleSizeChange"
			                @current-change="handleCurrentChange"
			                :current-page='pageIndex'
			                :page-sizes="[10, 20, 30, 40, 100, 200]"
			                :page-size='pageSize'
			                layout="total, sizes, prev, pager, next, jumper"
			                :total='total'
			            >
			            </el-pagination>
			        </div>
			        <el-dialog v-if="entrustVisible" title="任务委托" :visible.sync="entrustVisible" width="50%" :before-close="close">
			        	<el-form :model="entrustUser" status-icon :rules="entrustUser.rules" ref="entrustForm" label-width="70px" style="margin: 5px 15%">
		                	<el-form-item label="被委托人" prop="userId">
			                    <el-select
				                    v-model="entrustUser.userId"
				                    filterable
				                    placeholder="请选择"
				                    size="small"
				                    clearable
				                    style="width: 100%"
				                >
				                    <el-option
				                        v-for="item in userMap"
				                        :key="item.id"
				                        :label="item.userName ? item.userName : entrustUser.userId"
				                        :value="item.userId ? item.userId : form.user"
				                    >
				                    </el-option>
				                </el-select>
			                </el-form-item>
			                <el-form-item style="padding: 15px;text-align: center;">
			                    <el-button type="primary" size="small" :loading="submitLoading" @click="submitEntrust" style="margin-right: 10px;">提交</el-button>
			                    <el-button size="small" @click="cancel">返回</el-button>
			                </el-form-item>
			            </el-form>
			        </el-dialog>
				</div>
			</el-tab-pane>
			<el-tab-pane label="委托待办" name="entrustTask">
				<div>
					<!-- <div class="_title">委托待办事项<span></span></div> -->
					<div class="tableArea">
						<el-table
							individual-columns="individual-vue-table-columns1"
		                    :individual-info="individualInfo"
		                    drag-column="individual-vue-table1"
							:data="tableData2"
							v-loading="tableLoading2"
							:height="tableHeight + 'px'"
							style="width: 100%" 
							ref="taskTable2"
							border
							highlight-current-row>
							<!-- 序号 -->
							<el-table-column
								width="80px"
								type="index"
								label="序号"
								align="center">
							</el-table-column>
							<!-- tableKey表示为根据获取的tableData设置的header显示值列表 -->
							<el-table-column
								v-for ="(item, index) of tableKeys"
								:key="index"
								:label="item.label"
								:prop="item.key"
								:fixed="item.fixed"
								:width="item.width"
								header-align="center"
								align="center"
								sortable
								show-overflow-tooltip>
								<template slot-scope="scope">
			                        <span v-for="item in taskStatus" :key="item.value" :class="item.class" v-if="scope.column.property === 'status' && scope.row.status === item.value">
			                            {{item.label}}
			                        </span>
			                        <span v-if="scope.column.property !== 'status'">
			                            {{scope.row[scope.column.property]}}
			                        </span>
			                    </template>
							</el-table-column>
							<el-table-column
								label="操作"
								align="center"
								width="180">
								<template slot-scope="scope">
									<el-button
										type="text"
										size="mini"
										@click="goDeal(scope.row, 'deal', 'entrust')"
										v-privilege="activeMenu + 'DEAL'"
									>处理</el-button>
									<el-button
										type="text"
										size="mini"
										@click="goDeal(scope.row, 'see')"
										v-privilege="activeMenu + 'LOOK'"
									>详情</el-button>
									<el-button
										type="text"
										size="mini"
										@click="goDeal(scope.row, 'track')"
										v-privilege="activeMenu + 'LOOK'"
									>跟踪</el-button>
								</template>
							</el-table-column>
						</el-table>
					</div>
					<div class="foot-style">
			            <el-pagination
			                @size-change="handleSizeChange2"
			                @current-change="handleCurrentChange2"
			                :current-page='pageIndex2'
			                :page-sizes="[10, 20, 30, 40, 100, 200]"
			                :page-size='pageSize2'
			                layout="total, sizes, prev, pager, next, jumper"
			                :total='total2'
			            >
			            </el-pagination>
			        </div>
				</div>
			</el-tab-pane>
			<el-tab-pane label="我已委托" name="myEntrust">
				<div>
					<!-- <div class="_title">委托他人代办事项<span></span></div> -->
					<div class="tableArea">
						<el-table
							individual-columns="individual-vue-table-columns2"
		                    :individual-info="individualInfo"
		                    drag-column="individual-vue-table2"
							:data="tableData3"
							v-loading="tableLoading3"
							:height="tableHeight + 'px'"
							style="width: 100%" 
							ref="taskTable3"
							border
							highlight-current-row>
							<!-- 序号 -->
							<el-table-column
								width="80px"
								type="index"
								label="序号"
								align="center">
							</el-table-column>
							<!-- tableKey表示为根据获取的tableData设置的header显示值列表 -->
							<el-table-column
								v-for ="(item, index) of tableKeys"
								:key="index"
								:label="item.label"
								:prop="item.key"
								:fixed="item.fixed"
								:width="item.width"
								header-align="center"
								align="center"
								sortable
								show-overflow-tooltip>
								<template slot-scope="scope">
			                        <span v-for="item in taskStatus" :key="item.value" :class="item.class" v-if="scope.column.property === 'status' && scope.row.status === item.value">
			                            {{item.label}}
			                        </span>
			                        <span v-if="scope.column.property !== 'status'">
			                            {{scope.row[scope.column.property]}}
			                        </span>
			                    </template>
							</el-table-column>
							<el-table-column
								label="操作"
								align="center"
								width="180">
								<template slot-scope="scope">
									<el-button
										type="text"
										size="mini"
										@click="goDeal(scope.row, 'see')"
										v-privilege="activeMenu + 'LOOK'"
									>详情</el-button>
									<el-button
										type="text"
										size="mini"
										@click="goDeal(scope.row, 'track')"
										v-privilege="activeMenu + 'LOOK'"
									>跟踪</el-button>
								</template>
							</el-table-column>
						</el-table>
					</div>
					<div class="foot-style">
			            <el-pagination
			                @size-change="handleSizeChange3"
			                @current-change="handleCurrentChange3"
			                :current-page='pageIndex3'
			                :page-sizes="[10, 20, 30, 40, 100, 200]"
			                :page-size='pageSize3'
			                layout="total, sizes, prev, pager, next, jumper"
			                :total='total3'
			            >
			            </el-pagination>
			        </div>
				</div>
			</el-tab-pane>
			<div is='drawerAssembly' :purshowFlag='purshowFlag' :formKey='formKey' :reviewData='reviewData' @refreshData='getTableData'></div>
		</el-tabs>
		<icore-individual :uiId="activeMenu" indexClass="individual-index"></icore-individual>
        <el-drawer
            size="1200px"
            :modal-append-to-body="false"
            :title="approveTitle"
            :visible.sync="approveShow"
            direction="rtl">
            <iframe v-if="approveShow" ref="approveframe" :src="approveUrl" frameborder="0" style="width:100%;height:100%;"></iframe>
        </el-drawer>
	</div>
</template>

<script>
	import {  getCookie } from '@/utils/util.js';
	import store from '@/store/index.js';
	import drawerAssembly from '@/views/workFlow/components/drawerAssembly.vue'
	export default {
		components: {drawerAssembly},
		data () {
			return {
                approveUrl: '',
                approveTitle: '',
                approveShow: false,
                dicKeysMap: {},
				purshowFlag: false,
				activeName: 'myTask',
				activeMenu: '',
				userId: '',
				store,
				individualInfo: {},
				tableHeight: 700,
				tableLoading: false,// 我的任务表格加载
				tableLoading2: false,// 委托任务表格加载
				tableLoading3: false,// 委托他人表格加载
				entrustVisible: false,// 委托弹窗
				submitLoading: false, // 提交按钮
				taskObj: {},
				entrustUser: {
					userId: '',
					rules: {
						userId: [
		                    { required: true, message: '请选择被委托人', trigger: 'change' }
		                ]
		            }
				},
				taskStatus: [
	                {
	                    value: 'PENDING',
	                    label: '正在进行',
	                    class: 'yellow'
	                }, {
	                    value: 'RESOLVED',
	                    label: '已解决',
	                    class: 'green'
	                },{
	                    value: '1',
	                    label: '已提交，待审批',
	                    class: 'yellow'
	                },{
	                    value: '2',
	                    label: '审核中',
	                    class: 'yellowgreen'
	                },{
	                    value: '3',
	                    label: '已完成',
	                    class: 'green'
	                }
	            ],
				tableKeys: [],
				tableData: [],
				tableData2: [],
				tableData3: [],
				formKey: '',
				reviewData: {},
				formkeyData: [
          'demand_approval',
          'plan_approval', 
          'order_approval', 
          'comsuming_approval', 
          'post_approval', 
          'pay_approval', 
          'bill_approval', 
          'contract_approval', 
          'remove_approval'
        ], // 采购审批流
				pageSize: 20,// 默认每页显示条数
				pageIndex: 1,// 默认当前页
				total: 0, // 数据总数
				pageSize2: 20, // 委托任务表格
				pageIndex2: 1,
				total2: 0,
				pageSize3: 20, // 委托任务表格
				pageIndex3: 1,
				total3: 0,
				userMap: {}, // 用户详情
				companys: [], // 公司数组
				companyId: '',
				companyName: '',
				scroll1: 0,
				scroll2: 0,
				scroll3: 0
			}
		},
		created () {
			this.activeMenu = window.top.localStorage.getItem('activeMenu');
		},
		watch: {
			'total': {
				immediate: false,
	            handler: function () {
	                this.$emit('updateTaskNum');
	            }
	        },
	        'total2': {
	            immediate: false,
	            handler: function () {
	                this.$emit('updateTaskNum');
	            }
	        }
	    },
		async mounted () {
            let that = this;
			// 获取公司信息
			this.companys = JSON.parse(window.top.localStorage.getItem('companys'));
			this.companyId = window.top.localStorage.getItem('companyId');
			if (this.companyId !== '' && this.companyId !== null) {
				this.companyName = this.companys.find((x) => x.id === this.companyId).companyName;
			}
			// 获取当前用户
            this.userId = getCookie('userId');
            await this.getDic();
			this.getUser();
			this.$nextTick(() => {
				this.tableHeight = this.getTreeHeight(this.$refs['taskTable'].$el) - 120;
            });
            window.addEventListener('message', event => {
            // 根据上面制定的结构来解析iframe内部发回来的数据
                if (that.approveShow) {
                    that.getTableData();
                }
                that.approveShow = false;
            });
		},
		// 操作成功刷新列表
		activated() {
			this.$nextTick(() => {
				setTimeout(() => {
					this.$refs.taskTable.bodyWrapper.scrollTop = this.scroll1;
					this.$refs.taskTable2.bodyWrapper.scrollTop = this.scroll2;
					this.$refs.taskTable3.bodyWrapper.scrollTop = this.scroll3;
          		}, 13)	
			})
			if (this.$route.params.operate && this.$route.params.operate === 'success') {
				this.getTableData();
				this.getTableData2();
			}
		},
		methods: {
            /**
             * 獲取數據
             */
            async getDic () {
                let that = this;
                let res = await that.getDicData();
                if (res.code === '0') {
                    for (let i = 0; i < res.data.list.length; i++) {
                        let item = res.data.list[i];
                        that.dicKeysMap[item.dictCode] = item.dictName;
                    }
                } else {
                    that.$message.error(res.resultMessage)
                }
            },
            getDicData () {
                return this.axios.get(`pass/v1/sysdicts/?pDictId=ACT_KEYS&companyId=${this.companyId}`);
            },
			// 处理采购系统内部数据
			handleData (type, data) {
				let obj = JSON.parse(JSON.stringify(data.businessMap.businessPo))
				switch (type) {
					case 'demand_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.name = data.name
						obj.groupId = data.groupId // 职务id
            obj.groupName = data.name 
            obj.orgId = data.businessMap.orgId
					break;
					case 'plan_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.taskName = data.taskName
						obj.name = data.name
						obj.groupId = data.groupId // 职务id
            obj.groupName = data.name 
            obj.orgId = data.businessMap.orgId
					break;
					case 'order_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.taskName = data.taskName
            obj.name = data.name
            obj.orgId = data.businessMap.orgId
					break;
					case 'comsuming_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.taskName = data.taskName
            obj.name = data.name
            obj.orgId = data.businessMap.orgId
					break;
					case 'post_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.taskName = data.taskName
            obj.name = data.name
            obj.orgId = data.businessMap.orgId
					break;
					case 'pay_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.taskName = data.taskName
            obj.name = data.name
            obj.orgId = data.businessMap.orgId
					break;
					case 'bill_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.taskName = data.taskName
            obj.name = data.name
            obj.orgId = data.businessMap.orgId
					break;
					case 'contract_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.taskName = data.taskName
            obj.name = data.name
            obj.orgId = data.businessMap.orgId
          break;
          case 'remove_approval':
						obj.instanceId = data.procInstId
						obj.taskId = data.id
						obj.taskName = data.taskName
            obj.name = data.name
            obj.orgId = data.businessMap.orgId
					break;
				}
				return obj
			},
			//  计算树区域高度
			getTreeHeight (dom) {
				return window.innerHeight - dom.offsetTop;
			},
			handleClick(tab, event) {
				// console.log(tab, event);
			},
			getUser () {
				this.tableKeys = [
					{
						key: 'type',
						label: '流程类型',
						width: 'auto'
					},
					{
						key: 'name',
						label: '流程名称',
						width: 'auto'
					},
					{
						key: 'userName',
						label: '申请人',
						width: 'auto'
					},
					{
						key: 'reason',
						label: '申请理由',
						width: 'auto'
					},
					{
						key: 'taskName',
						label: '当前步骤',
						width: 'auto'
					},
					{
						key: 'startTime',
						label: '任务开始时间',
						width: 'auto'
					},
					{
						key: 'status',
						label: '审批状态',
						width: 'auto'
					}
				]
				this.tableLoading = true;
				this.tableLoading2 = true;
				this.tableLoading3 = true;
				this.axios.get('pass/v1/sysusers/?pageSize=1000000').then((res) => {
        			if (res.code === '0') {
        				res.data.list.forEach((item, index) => {
        					this.userMap[item.id] = item;
        				});
        				this.getTableData();
        				this.getTableData2();
        				this.getTableData3();
        			} else {
        				this.$message.error(res.message);
        			}
				});
			},
			// 获取待办任务
			getTableData () {
				let that = this;
				that.tableLoading = true;
				this.axios.get('pass/act/v1/actusertasks/findMyToDoTask?userId=' + this.userId + '&companyId=' + this.companyId + '&pageNum=' + this.pageIndex + '&pageSize=' + this.pageSize).then((res) => {
					let data = [];
					if (res.code === '0') {
						if (res.data.list.length >= 1) {
							for (let i = 0; i < res.data.list.length; i++) {
								let item = {};
								item.type = res.data.list[i].type;
								item.name = res.data.list[i].procDefName;
								if (res.data.list[i].businessMap !== null) {
									item.userId = res.data.list[i].businessMap.userId;
									try {
										item.userName = that.userMap[item.userId].userName ? that.userMap[item.userId].userName : item.userId;
									} catch (err) {
										console.log(res.data.list[i]);
										console.log (err + '错误用户id:' + item.userId);
                                    }
									item.reason = res.data.list[i].businessMap.businessPo.memo;
									item.formKey = res.data.list[i].businessMap.formKey;
									item.status = res.data.list[i].businessMap.status
									// switch (res.data.list[i].businessMap.status) {
									// 	case '1':
									// 		item.status = '已提交，待审批';
									// 		break
									// 	case '2':
									// 		item.status = '审批中';
									// 		break
									// 	case '3':
									// 		item.status = '已完成';
									// 		break
									// }
								}
								item.id = res.data.list[i].id;
								item.taskId = res.data.list[i].id;
								item.instanceId = res.data.list[i].procInstId;
								item.taskName = res.data.list[i].name;
								item.startTime = res.data.list[i].startTime;
								item.businessPo = res.data.list[i]
								data.push(item);
							}
						}
            that.tableData = data;
						that.total = res.data.total;
						that.tableLoading = false;
					} else {
						that.$message.error(res.message);
						that.tableLoading = false;
					}
				}).catch((err) => {
					console.log(err);
				})
			},
			// 获取我的委托待办任务
			getTableData2 () {
				let that = this;
				that.tableLoading2 = true;
				this.axios.get('pass/act/v1/actusertasks/findMyToDoDelegateTask?userId=' + this.userId + '&companyId=' + this.companyId + '&pageNum=' + this.pageIndex2 + '&pageSize=' + this.pageSize2).then((res) => {
					let data = [];
					if (res.code === '0') {
						if (res.data.list.length >= 1) {
							for (let i = 0; i < res.data.list.length; i++) {
								let item = {};
								item.type = res.data.list[i].type;
								item.name = res.data.list[i].procDefName;
								if (res.data.list[i].businessMap !== null) {
									item.userId = res.data.list[i].businessMap.userId;
									try {
										item.userName = that.userMap[item.userId].userName ? that.userMap[item.userId].userName : item.userId;
									} catch (err) {
										console.log(res.data.list[i]);
										console.log (err + '错误用户id:' + item.userId);
									}
									item.reason = res.data.list[i].businessMap.businessPo.memo;
									item.formKey = res.data.list[i].businessMap.formKey;
									item.status = res.data.list[i].delegation;
									// switch (res.data.list[i].delegation) {
									// 	case 'PENDING':
									// 		item.status = '正在进行';
									// 		break
									// 	case 'RESOLVED':
									// 		item.status = '被解决';
									// 		break
									// 	default:
									// 		item.status = '未定义状态';
									// 		break
									// }
								}
								item.id = res.data.list[i].id;
								item.taskId = res.data.list[i].id;
								item.instanceId = res.data.list[i].procInstId;
								item.taskName = res.data.list[i].name;
								item.startTime = res.data.list[i].startTime;
								data.push(item);
							}
						}
						that.tableData2 = data;
						that.total2 = res.data.total;
						that.tableLoading2 = false;
					} else {
						that.$message.error(res.message);
						that.tableLoading2 = false;
					}
				}).catch((err) => {
					console.log(err);
				})
			},
			// 获取我的委托他人代办任务
			getTableData3 () {
				let that = this;
				that.tableLoading3 = true;
				this.axios.get('pass/act/v1/actusertasks/findMyDelegateTask?userId=' + this.userId + '&companyId=' + this.companyId + '&pageNum=' + this.pageIndex3 + '&pageSize=' + this.pageSize3).then((res) => {
					let data = [];
					if (res.code === '0') {
						if (res.data.list.length >= 1) {
							for (let i = 0; i < res.data.list.length; i++) {
								let item = {};
								item.type = res.data.list[i].type;
								item.name = res.data.list[i].procDefName;
								if (res.data.list[i].businessMap !== null) {
									item.userId = res.data.list[i].businessMap.userId;
									try {
										item.userName = that.userMap[item.userId].userName ? that.userMap[item.userId].userName : item.userId;
									} catch (err) {
										console.log (err + '错误用户id:' + item.userId);
									}
									item.reason = res.data.list[i].businessMap.businessPo.memo;
									item.formKey = res.data.list[i].businessMap.formKey;
									item.status = res.data.list[i].delegation;
									// switch (res.data.list[i].delegation) {
									// 	case 'PENDING':
									// 		item.status = '正在进行';
									// 		break
									// 	case 'RESOLVED':
									// 		item.status = '被解决';
									// 		break
									// 	default:
									// 		item.status = '未定义状态';
									// 		break
									// }
								}
								item.id = res.data.list[i].id;
								item.taskId = res.data.list[i].id;
								item.instanceId = res.data.list[i].procInstId;
								item.taskName = res.data.list[i].name;
								item.startTime = res.data.list[i].startTime;
								data.push(item);
							}
						}
						that.tableData3 = data;
						that.total3 = res.data.total;
						that.tableLoading3 = false;
					} else {
						that.$message.error(res.message);
						that.tableLoading3 = false;
					}
				}).catch((err) => {
					console.log(err);
				})
			},
			// 跳转处理页面
			goDeal (row, status, entrust) {
				if (status === 'entrust') { // 委托他人代审批
					this.taskObj = row;
					this.entrustVisible = true;
				} else {
                    // 通用设计模板
                    if (this.dicKeysMap[row.formKey]) {
                        this.approveTitle = row.name + '审批';
                        let temp = '';
                        let businessPo = row.businessPo.businessMap.businessPo.id;
                        for (let i in businessPo) {
                            temp = temp + `&${i}=${businessPo[i]}`
                        }
                        this.approveUrl = this.dicKeysMap[row.formKey] + `?taskId=${row.taskId}${temp}`;
                        this.approveShow = true;
                    } else if (status === 'deal' && this.formkeyData.includes(row.formKey)) { 
                        // 如果为采购系统审批流
                        this.reviewData = this.handleData(row.formKey, row.businessPo)
                        console.log('测试一下下', this.reviewData)
						this.formKey = row.formKey
						this.purshowFlag = !this.purshowFlag
					} else { // 其他系统审批流
						let wrapperScrollTop1 = this.$refs.taskTable.bodyWrapper.scrollTop;
						let wrapperScrollTop2 = this.$refs.taskTable2.bodyWrapper.scrollTop;
						let wrapperScrollTop3 = this.$refs.taskTable3.bodyWrapper.scrollTop;
						this.scroll1 = wrapperScrollTop1;
						this.scroll2 = wrapperScrollTop2;
						this.scroll3 = wrapperScrollTop3;
                        let data = row ? JSON.stringify(row) : '';
                        console.log('行数据', row)
						let userMap = JSON.stringify(this.userMap);
						this.$router.push({ name: 'approvelDetails', query: { type: status, data: data || '', userId: this.userId, userMap: userMap, entrust: entrust || ''}})
					}
				}
			},
			// 委托提交
			submitEntrust () {
				this.submitLoading = true;
				console.log(this.taskObj);
				let params = {
					ownerId: this.userId,
					taskId: this.taskObj.taskId,
					userId: this.entrustUser.userId
				}
				this.axios.post('pass/act/v1/act/delegateTask', params).then((res) => {
					if (res.code === '0') {
						this.$message.success('委托成功！');
						this.submitLoading = false;
						this.entrustVisible = false;
						this.entrustUser.userId = '';
						this.getTableData();
						this.getTableData3();
					} else {
						this.$message.error(res.message);
					}
				}).catch((err) => {
					console.log(err)
				})
			},
			cancel () {
				this.$refs['entrustForm'].resetFields();
				this.submitLoading = false;
				this.entrustVisible = false;
				this.entrustUser.userId = '';
			},
			// 弹窗操作取消
			close: function (done) {
				this.$confirm(`您确定要取消吗`, 'Warning', {
                    confirmButtonText: '是',
                    cancelButtonText: '否',
                    type: 'warning'
                }).then(async() => {
                	this.submitLoading = false;
                    this.$refs['entrustForm'].resetFields();
                    done();
                }).catch(() => {})
			},
			// 当前页
			handleCurrentChange (pageIndex) {
				this.pageIndex = pageIndex
				this.getTableData();
			},
			// 每页条数
			handleSizeChange (pageSize) {
				this.pageIndex = 1
				this.pageSize = pageSize;
				this.getTableData();
			},
			// 当前页
			handleCurrentChange2 (pageIndex) {
				this.pageIndex2 = pageIndex
				this.getTableData2();
			},
			// 每页条数
			handleSizeChange2 (pageSize) {
				this.pageInde2 = 1
				this.pageSize2 = pageSize;
				this.getTableData2();
			},
			// 当前页
			handleCurrentChange3 (pageIndex) {
				this.pageIndex3 = pageIndex
				this.getTableData3();
			},
			// 每页条数
			handleSizeChange3 (pageSize) {
				this.pageIndex3 = 1
				this.pageSize3 = pageSize;
				this.getTableData3();
			},
			// 下拉选择公司
			selectComPany (command) {
				this.companyId = command.id;
				this.companyName = command.companyName;
				// 下拉选择了公司以后需要再重新调用下查询接口，重新获取数据
				this.getTableData();
				this.getTableData2();
				this.getTableData3();
			}
		}
	}
</script>

<style lang="less" scoped>
	._box {
		padding: 15px;
		min-width: 800px;
        position: relative;
        /deep/ .el-drawer__body {
            padding: 0px !important;
        }
        /deep/ .el-drawer {
            overflow: auto;
        }

        /deep/ .el-drawer__header {
            -webkit-box-align: center;
            -ms-flex-align: center;
            align-items: center;
            color: #ffffff;
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            margin-bottom: 0px;
            padding: 20px 20px 20px;
            background-color: #0c2278;
            font-size: 16px;
        }
        /deep/ .el-drawer__close-btn:hover {
            color: #fff;
            font-size: 20px;
            animation: rotating 2s linear infinite;
        }
    	/deep/ .el-tabs__content {
    		overflow: hidden !important;
    	}
		._title {
		    width: 100%;
		    height: 30px;
		    line-height: 30px;
		    margin-top: 10px;
		    font-size: 18px;
		    padding-left: 15px;
		    position: relative;
			span {
		        display: block;
		        position: absolute;
		        width: 5px;
		        height: 30px;
		        background: #409EFF;
		        left: 0px;
		        top: 0px;
		    }
		}
		.tableArea {
			margin-top: 2px;
			.el-table__row {
				height: 35px;
			}
		}
		.foot-style {
			margin: 5px 0 0;
			text-align: right;
		}
		.el-tabs__content {
	    	overflow: hidden !important;
	    }
		.green {
			color: #67C23A;
		}
		.yellow {
			color: #f36716;
		}
		yellowgreen {
			color: yellowgreen;
		}
	}
	.el-dialog {
    	max-width: 650px;
    }
	.company-select {
	    position: absolute;
    	right: 20px;
		margin-bottom: 5px;
		z-index: 1999;
	    .el-dropdown {
	        font-weight: bold;
	        font-size: 14px;
	        cursor: pointer;
	    }
	}
</style>
