<template>
	<div>
		<div class="diy_tip_bg">
			<el-alert class="diy-tip" type="success" description>
				<p><b>使用说明：</b></p>
				<div class="headLi">1、参考“奖票示例”制作好实体奖票模版（最大尺寸22*9cm）</div>
				<div class="headLi">2、前往【打印配置】调整对应文本的打印位置</div>
				<div class="headLi">3、连接打印机，勾选对应的奖票进行打印</div>
				<div class="headLi">4、打印成功后，标识对应的奖票“已打印”</div>
			</el-alert>
		</div>
		<div>
			<div ref="print" v-if="isPrint">
				<div v-for="(item,index) in selectionItems2" :key="item.id" style="width: 100%;height: 100%;">
					<div :style="{width:printW+'cm',height:printH+'cm'}" style="position: relative;">
						<template v-for="(e,index2) in item">
							<div class="input-item"
								:style="{left:e.x+'cm',top:e.y+'cm',width:e.w? e.w+'cm':'auto',height:e.id==2? '2.33rem':'auto'}"
								style="z-index: 2;">
								{{e.val}}
							</div>
						</template>
					</div>
				</div>
			</div>
		</div>
		<div class="all padding-20">
			<FormBox>
				<div class="form-item">
					<div class="form-label">人员范围</div>
					<div class="form-search">
						<el-select size="medium" v-model="selectType" placeholder="请选择分类" style="width: 95px;margin-right: 5px;">
							<el-option label="部门" :value="1"></el-option>
							<el-option label="人员" :value="2"></el-option>
						</el-select>
						<el-cascader style="width: 190px;" v-if="selectType==1" size="medium" v-model="dept_name" :options="dept_tree"
							:props="{ multiple: true,value: 'id', label: 'name', children: '_child' }" ref="dept"
							collapse-tags clearable filterable placeholder="全公司"></el-cascader>
						<el-select style="width: 190px;" v-else size="medium" filterable multiple clearable v-model="formData.employee_id"
							placeholder="请输入或选择人员">
							<el-option v-for="item in employee_map" :key="item.id" :label="item.name"
								:value="item.id"></el-option>
						</el-select>
					</div>
				</div>
				<div class="form-item">
					<div class="form-label">事件时间</div>
					<div class="form-search">
						<el-date-picker size="medium" v-model="time_range" type="daterange"
							value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期"
							end-placeholder="结束日期" :picker-options="instantPickerOptions"></el-date-picker>
					</div>
				</div>
				<div class="form-item">
					<div class="form-label">打印状态</div>
					<div class="form-search">
						<el-select size="medium" v-model="formData.has_print">
							<el-option v-for="item in source_type" :key="item.id" :label="item.name"
								:value="item.id"></el-option>
						</el-select>
					</div>
				</div>
				<div class="form-item">
					<div class="form-label">内容搜索</div>
					<div class="form-search">
						<el-input size="medium" v-model="formData.keyword" clearable placeholder="请输入"
							maxlength="20"></el-input>
					</div>
				</div>
			</FormBox>
			<div class="flex-box-ce" style="margin: 10px 0;">
				<el-button size="small" @click="printFn" plain type="primary">打印当前已选中的奖票</el-button>
				<div class="flex-1"></div>
				<el-popover placement="top-end" width="640" trigger="click">
					<div><img src="@/assets/image/09.png" style="width: 100%;" /></div>
					<div class="blue cursor" slot="reference" style="margin-right: 10px;cursor: pointer;">奖票示例</div>
				</el-popover>
				<el-button size="small" type="primary" @click="dialogVisible=true">打印配置</el-button>
				<el-button size="small" type="primary" @click="openPrint">批量修改状态</el-button>
			</div>
			<el-table :data="list" style="width: 100%;cursor: pointer;" v-loading="loading"
				@selection-change="deleteEvents">
				<el-table-column width="50" type="selection"></el-table-column>
				<el-table-column label="姓名" align="left" width="250px">
					<template slot-scope="scope">
						<div class="flex-box">
							<userImage :user_name="scope.row.employee_name" :img_url="scope.row.employee_img_url"
								width="50px" height="50px"></userImage>
							<span style="line-height: 50px; padding-left: 10px;">{{ scope.row.employee_name }}</span>
						</div>
					</template>
				</el-table-column>
				<el-table-column label="部门" align="left" width="250px" prop="employee_dept"></el-table-column>
				<el-table-column label="奖票事件" align="left" prop="point">
					<template slot-scope="scope">
						<span>{{scope.row.remark.customize||scope.row.remark.rule}}</span>
					</template>
				</el-table-column>
				<el-table-column label="事件时间" align="left" prop="dateStr" width="130"></el-table-column>
				<el-table-column label="发放人" align="left" prop="publisher_name" width="130"></el-table-column>
				<el-table-column label="打印状态" width="160">
					<template slot-scope="scope">
						<span class="green" v-if="scope.row.has_print">已打印</span>
						<span class="fontColorC" v-else>未打印</span>
						<el-switch style="padding-left: 10px;" @change="changePrint($event,scope.row)"
							v-model="scope.row.has_print" :active-value="1" :inactive-value="0"></el-switch>
					</template>
				</el-table-column>
				<template slot="empty">
					<div class="nopoint_box">
						<div class="noimg noperson"></div>
						<span class="title">没有对应的数据</span>
					</div>
				</template>
			</el-table>
			<center style="padding: 20px 0;">
				<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
					:current-page="page" :page-sizes="[10, 20, 50, 100]" layout="total, sizes, prev, pager, next"
					:page-size="page_size" :total="total"></el-pagination>
			</center>
		</div>
		<!-- 打印配置 -->
		<el-dialog title="打印配置" :visible.sync="dialogVisible" width="900px" :close-on-press-escape="false"
			:close-on-click-modal="false">
			<div class="flex-box-ce">
				<div class="flex-box-ce flex-1">
					<div class="input-item" :class="selectInput.id==item.id? 'activeInput':''" @click="selectInput=item"
						style="margin-right: 10px;position: relative;" v-for="item in inputs" :key="item.id">
						{{item.name}}</div>
				</div>
				<div class="flex-box-ce">
					<div class="flex-box-ce">
						<div class="label">奖票长</div>
						<el-input style="width: 60px;" size="small" v-model="printW"
							@input="[checkCountry($event, 1),(printW = printW.match(/\d+(\.\d{0,1})?/) ? printW.match(/\d+(\.\d{0,1})?/)[0] : '')]"></el-input>
						<span style="font-size: 12px;position: relative;top: 5px;left: 5px;">cm</span>
					</div>
					<div class="flex-box-ce" style="margin-left: 30px;">
						<div class="label">奖票宽</div>
						<el-input style="width: 60px;" size="small" v-model="printH"
							@input="[checkCountry($event, 2),(printH = printH.match(/\d+(\.\d{0,1})?/) ? printH.match(/\d+(\.\d{0,1})?/)[0] : '')]"></el-input>
						<span style="font-size: 12px;position: relative;top: 5px;left: 5px;">cm</span>
					</div>
				</div>
			</div>
			<div class="flex-box-ce" style="margin: 20px 0;">
				<div class="flex-box-ce">
					<div class="label">X</div>
					<el-input style="width: 60px;" size="small" v-model="selectInput.x"
						@input="[checkCountry($event, 3),(selectInput.x = selectInput.x.match(/\d+(\.\d{0,1})?/) ? selectInput.x.match(/\d+(\.\d{0,1})?/)[0] : '')]"></el-input>
					<span style="font-size: 12px;position: relative;top: 5px;left: 5px;">cm</span>
				</div>
				<div class="flex-box-ce" style="margin-left: 20px;">
					<div class="label">Y</div>
					<el-input style="width: 60px;" size="small" v-model="selectInput.y"
						@input="[checkCountry($event, 4),(selectInput.y = selectInput.y.match(/\d+(\.\d{0,1})?/) ? selectInput.y.match(/\d+(\.\d{0,1})?/)[0] : '')]"></el-input>
					<span style="font-size: 12px;position: relative;top: 5px;left: 5px;">cm</span>
				</div>
				<div class="flex-box-ce" style="margin-left: 20px;" v-if="selectInput.id==2">
					<div class="label">长</div>
					<el-input style="width: 60px;" size="small" v-model="selectInput.w"
						@input="[checkCountry($event, 5),(selectInput.w = selectInput.w.match(/\d+(\.\d{0,1})?/) ? selectInput.w.match(/\d+(\.\d{0,1})?/)[0] : '')]"></el-input>
					<span style="font-size: 12px;position: relative;top: 5px;left: 5px;">cm</span>
				</div>
				<div class="flex-1"></div>
				<el-popover placement="top-end" width="640" trigger="click">
					<div><img src="@/assets/image/09.png" style="width: 100%;" /></div>
					<div class="blue" slot="reference" style="cursor: pointer;">奖票示例</div>
				</el-popover>
				<el-button type="primary" plain size="small" icon="el-icon-refresh-right" style="margin-left: 10px;"
					@click="reset">重置参数</el-button>
			</div>
			<div style="width: 100%;height: 10cm;background-color: #f1f1f1;position: relative;">
				<div :style="{width:printW+'cm',height:printH+'cm'}"
					style="position:relative;background-color: #fff;margin: 0 auto;top: 50%;transform: translate(0, -50%);">
					<template v-for="item in inputs">
						<div @click="selectInput=item" class="input-item" style="height: 2.33rem;" v-if="item.id==2"
							:class="{activeInput:item.id==selectInput.id}"
							:style="{left:item.x+'cm',top:item.y+'cm',width:item.w? item.w+'cm':'auto'}">
							{{item.name}}
						</div>
						<div v-else @click="selectInput=item" class="input-item"
							:class="{activeInput:item.id==selectInput.id}"
							:style="{left:item.x+'cm',top:item.y+'cm',width:item.w? item.w+'cm':'auto'}">
							{{item.name}}
						</div>
					</template>
				</div>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false" size="medium">取 消</el-button>
				<el-button type="primary" @click="sumbitConfig" size="medium">保 存</el-button>
			</span>
		</el-dialog>

		<el-dialog @close="closeCode" :visible.sync="innerVisible" width="444px">
			<div
				style="border-radius: 15px;border: 1px solid #f1f1f1;padding: 10px; width: 346px;box-sizing: border-box;margin: 0 auto;">
				<div id="qrcode" ref="qrcode"></div>
			</div>
			<div style="margin-top: 10px;text-align: center;color: #666;">请使用钉钉APP扫描二维码</div>
		</el-dialog>

		<el-dialog :visible.sync="isShowPl" width="444px">
			<div>
				<div style="margin-bottom: 20px;">批量修改状态为：</div>
				<template>
					<el-radio-group v-model="radio">
						<el-radio :label="true">已打印</el-radio>
						<el-radio :label="false">未打印</el-radio>
					</el-radio-group>
				</template>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="isShowPl = false" size="medium">取 消</el-button>
				<el-button type="primary" @click="sumbitPrint" size="medium">保 存</el-button>
			</span>
		</el-dialog>
	</div>
</template>
<script>
	import moment from 'moment';
	import QRCode from 'qrcodejs2';
	import {
		_debounce
	} from '@/api/auth';
	export default {
		data() {
			return {
				instantPickerOptions: {
					shortcuts: [{
							text: '今天',
							onClick(picker) {
								const now = new Date(new Date().toLocaleDateString());
								const start = now.getTime();
								picker.$emit('pick', [moment(start).format('YYYY-MM-DD'), moment(start).format(
									'YYYY-MM-DD')]);
							}
						},
						{
							text: '昨天',
							onClick(picker) {
								const now = new Date(new Date().toLocaleDateString());
								const start = now.getTime() - 60 * 60 * 24 * 1000;
								picker.$emit('pick', [moment(start).format('YYYY-MM-DD'), moment(start).format(
									'YYYY-MM-DD')]);
							}
						},
						{
							text: '本周',
							onClick(picker) {
								picker.$emit('pick', [moment().startOf('isoWeek').format('YYYY-MM-DD'),moment().endOf('isoWeek').format('YYYY-MM-DD')]);
							}
						},
						{
							text: '上周',
							onClick(picker) {
								picker.$emit('pick', [moment().subtract(1, 'w').startOf('isoWeek').format('YYYY-MM-DD'),moment().subtract(1, 'w').endOf('isoWeek').format('YYYY-MM-DD')]);
							}
						},
						{
							text: '本月',
							onClick(picker) {
								const now = new Date();
								const startDate = new Date(now.getFullYear(), now.getMonth(), 1);
								const endDate = new Date(now.getFullYear(), now.getMonth() + 1, 0);
								picker.$emit('pick', [moment(startDate.getTime()).format('YYYY-MM-DD'), moment(endDate
									.getTime()).format('YYYY-MM-DD')]);
							}
						},
						{
							text: '上月',
							onClick(picker) {
								const now = new Date();
								const startDate = new Date(now.getFullYear() - (now.getMonth() > 0 ? 0 : 1), (now
									.getMonth() + 11) % 12, 1);
								const endDate = new Date(now.getFullYear(), now.getMonth(), 0);
								picker.$emit('pick', [moment(startDate.getTime()).format('YYYY-MM-DD'), moment(endDate
									.getTime()).format('YYYY-MM-DD')]);
							}
						},
						{
							text: '本季',
							onClick(picker) {
								const quarter = Math.ceil((new Date().getMonth() + 1) / 3)
								let str = moment().format(`YYYY-${(quarter-1)*3+1}-01`);
								let ent = moment(moment().format(`YYYY-${(quarter-1)*3+1}-01`)).add(2, `month`).endOf(
									'month').format("YYYY-MM-DD");
								console.log(str, ent)
								picker.$emit('pick', [str, ent]);
							}
						},
						{
							text: '本年',
							onClick(picker) {
								let year = moment().format('YYYY');
								picker.$emit('pick', [year + '-01-01', year + '-12-31']);
							}
						},
					],
					onPick: (obj) => {
						if (!this.dialogVisible) {
							this.pickerMinDate = new Date(obj.minDate).getTime();
						}
					},
					// disabledDate: time => {
					// 	if (this.pickerMinDate && !this.dialogVisible) {
					// 		const day1 = 30 * 24 * 3600 * 1000 //限制只能选一个月的范围区间
					// 		let maxTime = this.pickerMinDate + day1
					// 		let minTime = this.pickerMinDate - day1
					// 		return time.getTime() > maxTime || time.getTime() < minTime
					// 	}
					// }
				},
				selectType: 1,
				total: 0,
				page: 1,
				page_size: 10,
				time_range: null,
				formData: {
					dept_ids: '0',
					has_print: -1,
					keyword: '',
					start_date: '',
					end_date: '',
					employee_id: 0,
				},
				dept_name: [],
				dept_tree: [],
				loading: false,
				list: [],
				source_type: [{
						id: -1,
						name: '全部'
					},
					{
						id: 1,
						name: '已打印'
					},
					{
						id: 0,
						name: '未打印'
					},
				],
				employee_map: this.$getCache('SET_EMPLOYEE_MAP'),
				employeeId: [],
				selectionID: [],
				dialogVisible: false,

				// 打印配置

				printW: 18,
				printH: 7.5,
				inputs: {
					employee_name: {
						name: '姓名(部门)',
						x: 1.8,
						y: 2,
						w: 0,
						id: 1
					},
					remark: {
						name: '奖票事件',
						x: 1.8,
						y: 3.2,
						w: 14,
						id: 2
					},
					publisher_name: {
						name: '发放人',
						x: 14.7,
						y: 5,
						w: 0,
						id: 3
					},
					year: {
						name: '年',
						x: 11.8,
						y: 6.2,
						w: 0,
						id: 4
					},
					month: {
						name: '月',
						x: 13.6,
						y: 6.2,
						w: 0,
						id: 5
					},
					day: {
						name: '日',
						x: 15,
						y: 6.2,
						w: 0,
						id: 6
					},
				},

				selectInput: {
					name: '姓名(部门)',
					x: 1.8,
					y: 2,
					w: 0,
					id: 1
				},
				innerVisible: false,
				selectionItems: [],
				selectionItems2: [],
				isPrint: false,

				isShowPl: false,
				radio: true,
			};
		},
		watch: {
			'formData.keyword': {
				deep: true,
				handler: _debounce(function(val) {
					this.get_list();
				}, 1000)
			},
			selectType() {
				this.get_list();
			},
			'formData.employee_id'() {
				this.get_list();
			},
			'formData.has_print'() {
				this.get_list();
			},
			time_range(val) {
				this.get_list();
			},
			dept_name(val) {
				if (val.length !== 0) {
					let dept_ids = [];
					val.forEach((item) => {
						dept_ids.push(...item);
					})
					let set = new Set(dept_ids);
					this.formData.dept_ids = [...set];
				} else {
					this.formData.dept_ids = 0;
				}
				this.employeeId = [];
				this.$nextTick(() => {
					this.get_list();
				});
			},
			dialogVisible(val) {
				if (val) {
					let siteConfig = this.$getCache('siteConfig');
					if (siteConfig.ticket_template) {
						let ticket_template = JSON.parse(siteConfig.ticket_template);
						this.selectInput = ticket_template.inputs.employee_name
						this.printW = ticket_template.printW;
						this.printH = ticket_template.printH;
						this.inputs = ticket_template.inputs;
					}
				}
			}
		},
		methods: {
			reset() {
				this.selectInput = {
					name: '姓名(部门)',
					x: 1.8,
					y: 2,
					w: 0,
					id: 1
				};
				this.printW = 18;
				this.printH = 7.5;
				this.inputs = {
					employee_name: {
						name: '姓名(部门)',
						x: 1.8,
						y: 2,
						w: 0,
						id: 1
					},
					remark: {
						name: '奖票事件',
						x: 1.8,
						y: 3.2,
						w: 14,
						id: 2
					},
					publisher_name: {
						name: '发放人',
						x: 14.7,
						y: 5,
						w: 0,
						id: 3
					},
					year: {
						name: '年',
						x: 11.8,
						y: 6.2,
						w: 0,
						id: 4
					},
					month: {
						name: '月',
						x: 13.6,
						y: 6.2,
						w: 0,
						id: 5
					},
					day: {
						name: '日',
						x: 15,
						y: 6.2,
						w: 0,
						id: 6
					},
				};
			},
			sumbitConfig(is) {
				let template = {};
				if (is) {
					template = {
						printW: this.printW,
						printH: this.printH,
						inputs: JSON.parse(JSON.stringify(this.inputs))
					}
				} else {
					template = {
						printW: 18,
						printH: 7.5,
						inputs: {
							employee_name: {
								name: '姓名(部门)',
								x: 1.8,
								y: 2,
								w: 0,
								id: 1
							},
							remark: {
								name: '奖票事件',
								x: 1.8,
								y: 3.2,
								w: 14,
								id: 2
							},
							publisher_name: {
								name: '发放人',
								x: 14.7,
								y: 5,
								w: 0,
								id: 3
							},
							year: {
								name: '年',
								x: 11.8,
								y: 6.2,
								w: 0,
								id: 4
							},
							month: {
								name: '月',
								x: 13.6,
								y: 6.2,
								w: 0,
								id: 5
							},
							day: {
								name: '日',
								x: 15,
								y: 6.2,
								w: 0,
								id: 6
							},
						},
					}
				}
				this.$axios('post', 'api/integral/ticket/template', {
					template: JSON.stringify(template)
				}).then(res => {
					if (is) {
						this.$message.success("已设置")
						this.dialogVisible = false;
					}
					this.cheakAx();
				});
			},
			openPrint() {
				if (this.selectionID.length == 0) {
					this.$message.error("请选择奖票")
					return false
				}
				this.isShowPl = true;
			},
			sumbitPrint() {
				this.$axios('post', 'api/integral/ticket/mark', {
					ids: this.selectionID.toString(),
					status: this.radio ? 1 : 0
				}).then(res => {
					this.$message.success("已修改")
					this.isShowPl = false;
					this.radio = true;
					this.get_list();
				});
			},
			changePrint(is, item) {
				this.$axios('post', 'api/integral/ticket/mark', {
					ids: item.id,
					status: is
				}).then(res => {
					this.$message.success("已修改")
					this.get_list();
				});
			},
			printFn() {
				if (this.selectionID.length == 0) {
					this.$message.error("请选择奖票")
					return false
				}
				//传入dom结构即可
				let selectionItems = [];
				this.selectionItems.map((item) => {
					let obj = {}
					for (let key in item) {
						if (key == 'employee_name') {
							obj.employee_name = JSON.parse(JSON.stringify(this.inputs.employee_name))
							if (item.employee_dept) {
								obj.employee_name.val = item[key] + '(' + item.employee_dept + ')'
							} else {
								obj.employee_name.val = item[key]
							}
						}
						if (key == 'remark') {
							obj.remark = JSON.parse(JSON.stringify(this.inputs.remark))
							obj.remark.val = item[key].customize || item[key].rule
						}
						if (key == 'publisher_name') {
							obj.publisher_name = JSON.parse(JSON.stringify(this.inputs.publisher_name))
							obj.publisher_name.val = item[key] || '--'
						}
						if (key == 'dateStr') {
							obj.year = JSON.parse(JSON.stringify(this.inputs.year))
							obj.year.val = this.$moment(item[key]).format('YYYY')
							obj.month = JSON.parse(JSON.stringify(this.inputs.month))
							obj.month.val = this.$moment(item[key]).format('MM')
							obj.day = JSON.parse(JSON.stringify(this.inputs.day))
							obj.day.val = this.$moment(item[key]).format('DD')
						}
					}
					selectionItems.push(obj)
				})
				this.selectionItems2 = selectionItems;
				this.isPrint = true;
				this.$nextTick(() => {
					this.$print(this.$refs.print);
					this.isPrint = false;
				})
			},
			ruleQRcode() {
				this.innerVisible = true;
				// 使用$nextTick确保数据渲染
				this.$nextTick(() => {
					this.payOrder();
				});
			},
			payOrder() { // 展示二维码
				let url = 'dingtalk://dingtalkclient/action/open_micro_app'
				let appid = '?appId=' + this.$appId
				let corpId = '&corpId=' + this.$getCache('corpId')
				let page = '&page=' + encodeURIComponent(
						`pages/reportBox/report/report?employee_id=${encodeURIComponent(this.$getUserData().id)}`
						) //encodeURIComponent('小米')
				let urls = url + appid + corpId + page
				var qrcode = new QRCode('qrcode', {
					text: urls, // 二维码内容
					width: 325,
					height: 325,
					render: 'table', // 设置渲染方式（有两种方式 table和canvas，默认是canvas）
					colorDark: '#34373e', // 二维码色
					colorLight: '#ffffff', // 背景色
					correctLevel: QRCode.CorrectLevel.H // 容错等级，H是heigh，最高，所以二维码看起来很密
				})
			},
			// 关闭弹框,清除已经生成的二维码
			closeCode() {
				setTimeout(() => {
					this.$refs.qrcode.innerHTML = '';
				}, 150);
			},
			checkCountry(e, index) {
				if (index == 1) {
					if (this.printW > 22) {
						this.printW = '22';
					}
				}
				if (index == 2) {
					if (this.printH > 9) {
						this.printH = '9';
					}
				}
			},
			deleteEvents(selection) {
				this.selectionItems = selection;
				this.selectionID = selection.map(item => {
					return item.id;
				});
			},
			getEmployeeList() {
				this.$axios('get', '/api/employee/list').then(res => {
					this.employee_map = res.data.data.list;
				});
			},
			//请求数据
			get_list(is) {
				!is ? this.page = 1 : '';
				let data = {
					page: this.page,
					page_size: this.page_size,
					keyword: this.formData.keyword,
					has_print: this.formData.has_print,
					has_print: this.formData.has_print
				};
				if (this.selectType == 1) {
					data.dept_ids = this.formData.dept_ids.toString();
				} else {
					data.employee_id = this.formData.employee_id.toString();
				}
				if (this.time_range) {
					data.start_date = this.$moment(this.time_range[0]).format('YYYY-MM-DD')
					data.end_date = this.time_range[1]
				}
				this.loading = true;
				this.$axios('get', '/api/integral/ticket', data, 'v2').then(res => {
					let list = res.data.data.list;
					list.forEach(item => {
						item.dateStr = this.$moment(item.date + '').format('YYYY-MM-DD');

					})
					this.list = list
					this.total = res.data.data.total;
				}).finally(() => {
					this.loading = false;
				});
			},
			//获取部门
			getDepartment() {
				this.$axios('get', '/api/department/tree').then(res => {
					this.dept_tree = this.getTreeData(res.data.data.list);
				});
			},
			// 递归判断列表，把最后的children设为undefined
			getTreeData(data) {
				for (var i = 0; i < data.length; i++) {
					data[i].obj = {
						id: data[i].id,
						name: data[i].name
					};
					if (data[i]._child.length < 1) {
						// children若为空数组，则将children设为undefined
						data[i]._child = undefined;
					} else {
						// children若不为空数组，则继续 递归调用 本方法
						this.getTreeData(data[i]._child);
					}
				}
				return data;
			},
			// 页面变更
			handleCurrentChange(val) {
				this.page = val;
				this.get_list(true);
			},
			// 页面跳转
			handleSizeChange(val) {
				this.page_size = val;
				this.get_list();
			},
			cheakAx() {
				this.$axios('get', '/api/integral/site/config').then(res => {
					this.$store.dispatch('setConfig', res.data.data);
				})
			},
		},
		created() {
			let siteConfig = this.$getCache('siteConfig');
			if (siteConfig.ticket_template) {
				let ticket_template = JSON.parse(siteConfig.ticket_template);
				this.selectInput = ticket_template.inputs.employee_name
				this.printW = ticket_template.printW;
				this.printH = ticket_template.printH;
				this.inputs = ticket_template.inputs;
			} else {
				this.sumbitConfig(false);
			}

			if (this.$getToken()) {
				this.getEmployeeList();
				this.getDepartment();
			} else {
				this.innerVisible = true;
			}
		},
		mounted() {
			this.get_list();
		}
	};
</script>
<style scoped lang="scss">
	.diy_tip_bg {
		background: #f5f6f9;
		overflow: hidden;

		.diy-tip {
			margin-bottom: 10px;
			border: 1px solid #67c23a;
			padding: 20px 16px;

			p {
				color: #67c23a !important;
				font-size: 15px;
				margin: 0 !important;
				padding-bottom: 4px;
			}
		}
	}

	.headLi {
		padding: 4px;
		list-style: disc;
		font-size: 14px;
	}

	.print_img {
		width: 20cm;
		height: 10cm;
		text-align: center;
		border: 1px solid #000;
		z-index: 9;
	}

	.print-box {
		margin: auto;
		background-color: #fff;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}

	.input-item {
		background: #f4f4f5;
		border-radius: 4px;
		padding: 6px 10px;
		cursor: pointer;
		color: #909399;
		position: absolute;
	}

	.activeInput {
		background-color: #ECF5FF;
		color: #26a2ff;
	}

	.label {
		text-align: right;
		vertical-align: middle;
		float: left;
		font-size: 14px;
		color: #606266;
		line-height: 40px;
		padding: 0 12px 0 0;
		box-sizing: border-box;
		font-weight: 600;
	}

	.search_box {
		::v-deep button:active {
			background: #26a2ff;
		}

		::v-deep button:active .el-icon-search {
			color: #fff;
		}
	}

	.date-picker-width {
		width: 100% !important;
	}

	.nopoint_box {
		display: inline-block;
		text-align: center;
		width: 100%;
		margin-bottom: 10px;
	}

	.noimg {
		display: inline-block;
		width: 110px;
		height: 110px;
		margin: 22px auto 16px;
		/* background:url("/static/images/nodata_default.png") no-repeat center; */
		background-size: 99%;
	}

	.noperson {
		display: inline-block;
		width: 110px;
		height: 110px;
		line-height: none;
		margin: 22px auto 16px;
		background: url('/static/images/noperson_default.png') no-repeat center;
		background-size: 99%;
	}

	.title {
		display: block;
		text-align: center;
		font-size: 12px !important;
		line-height: 30px;
		color: #909399 !important;
		padding: 0;
	}

	.nopoint_box a {
		color: #26a2ff;
	}

	.chart_content {
		.chart-legend__wrap {
			text-align: right;
			padding: 20px;
			padding-right: 50px;

			& .chart-legend__pink {
				position: relative;
				padding-left: 12px;
				padding-right: 5px;

				&:after {
					content: '';
					position: absolute;
					margin-top: -2px;
					top: 35%;
					left: 0;
					width: 8px;
					height: 8px;
					background: #f56c6c;
					border-radius: 100%;
				}
			}

			& .chart-legend__green {
				position: relative;
				padding-left: 12px;

				&:after {
					content: '';
					position: absolute;
					margin-top: -2px;
					top: 35%;
					left: 0;
					width: 8px;
					height: 8px;
					background: #53b87f;
					border-radius: 100%;
				}
			}
		}
	}

	.drawer_title {
		font-size: 18px;
		padding: 20px;
	}

	.manager_statistics_box {
		background-color: #ffffff;
		padding: 20px;
		min-height: calc(100vh - 160px);

		::v-deep .el-row .el-checkbox .el-checkbox__label {
			line-height: 20px;
		}
	}

	.diy_tip_bg {
		background: #f5f6f9;
		overflow: hidden;

		.diy-tip {
			margin-bottom: 15px;
			border: 1px solid #67c23a;
			padding: 20px 16px;

			p {
				color: #67c23a !important;
				font-size: 14px;
				margin: 0 !important;
				padding: 4px 0;
			}
		}
	}

	.picker_er {
		margin-top: 20px;
	}

	.el-range-editor--medium.el-input__inner {
		width: 280px;
	}

	.el-checkbox.is-bordered.el-checkbox--medium {
		padding: 9px 20px 7px 10px;
	}
</style>