<style lang="less">
	@import "@/styles/table-common.less";
	@import "./logiticsCompany.less";
</style>
<template>
	<div class="search">
		<Card>
			<Row v-show="openSearch" @keydown.enter.native="handleSearch">
				<Form ref="searchForm" :model="searchForm" inline :label-width="100">
					<FormItem label="状态" prop="orderId">
						<Select ref="dep" @on-change="checkStatus" clearable="true">
							<Option v-for="(item, i) in dictData" :key="i" :value="item.value">{{
						    item.title
						  }}</Option>
						</Select>
					</FormItem>
					<FormItem label="店铺名称" prop="shopName">
						<Input type="text" v-model="searchForm.shopName" clearable placeholder="请输入公司名称"
							style="width: 200px" />
					</FormItem>
					<FormItem style="margin-left: -35px" class="br">
						<Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
						<Button @click="handleReset">重置</Button>
						<a class="drop-down" @click="dropDown">
							{{ dropDownContent }}
							<Icon :type="dropDownIcon"></Icon>
						</a>
					</FormItem>
				</Form>
			</Row>
			<Row align="middle" justify="space-between" class="operation">
				<div>
					<Button @click="add" type="primary" icon="md-briefcase">一键结算</Button>
					<Button @click="delAll" icon="ios-checkbox-outline">确认</Button>
					<Button @click="delAll" icon="md-folder-open">结算</Button>
				</div>
				<div class="icons">
					<Tooltip content="刷新" placement="top" transfer>
						<Icon type="md-refresh" size="18" class="item" @click="getDataList" />
					</Tooltip>
					<Tooltip :content="openSearch ? '关闭搜索' : '开启搜索'" placement="top" transfer>
						<Icon type="ios-search" size="18" class="item tip" @click="openSearch = !openSearch" />
					</Tooltip>
					<Tooltip :content="openTip ? '关闭提示' : '开启提示'" placement="top" transfer>
						<Icon type="md-bulb" size="18" class="item tip" @click="openTip = !openTip" />
					</Tooltip>
					<Tooltip content="表格密度" placement="top" transfer>
						<Dropdown @on-click="changeTableSize" trigger="click">
							<Icon type="md-list" size="18" class="item" />
							<DropdownMenu slot="list">
								<DropdownItem :selected="tableSize == 'default'" name="default">默认</DropdownItem>
								<DropdownItem :selected="tableSize == 'large'" name="large">宽松</DropdownItem>
								<DropdownItem :selected="tableSize == 'small'" name="small">紧密</DropdownItem>
							</DropdownMenu>
						</Dropdown>
					</Tooltip>
				</div>
			</Row>
			<Alert show-icon v-show="openTip">
				已选择
				<span class="select-count">{{ selectList.length }}</span> 项
				<a class="select-clear" @click="clearSelectAll">清空</a>
			</Alert>
			<Table :loading="loading" border :columns="columns" :data="data" :size="tableSize" sortable="custom"
				@on-sort-change="changeSort" @on-selection-change="showSelect" ref="table"></Table>
			<Row type="flex" justify="end" class="page">
				<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize"
					@on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]"
					size="small" show-total show-elevator show-sizer></Page>
			</Row>
		</Card>
		<Modal :title="线路维护" v-model="Visiable" :mask-closable="false" :scrollabele="true" :width="1000">
			<logistics-address v-if="Visiable" ref="dialog"></logistics-address>
			<div slot="footer" v-show=Visiable>
				<Button type="text" @click="Visiable = false">关闭</Button>
			</div>
		</Modal>
		<Modal :title="线路绑定" v-model="bindingVisiable" :mask-closable="false" :scrollabele="true" :width="1000">
			<line-binding v-if="bindingVisiable" ref="bindinglog"></line-binding>
			<div slot="footer" v-show=bindingVisiable>
				<Button type="text" @click="bindingVisiable = false">关闭</Button>
			</div>
		</Modal>
		<Modal :title="充值记录明细" v-model="rechargeVisiable" :mask-closable="false" :scrollabele="true" :width="1000">
			<recharge-one v-if="rechargeVisiable" ref="rechargelog"></recharge-one>
			<div slot="footer" v-show=rechargeVisiable>
				<Button type="text" @click="rechargeVisiable = false">关闭</Button>
			</div>
		</Modal>
	</div>
</template>

<script>
	import {
		getAllLogiticsCompanyData,
		getLogiticsCompanyData,
		deleteLogiticsCompany,
		onLineCompany,
		offLineCompany
	} from "@/api/app";
	import {
		shortcuts
	} from "@/libs/shortcuts";
	import excel from "@/libs/excel";
	import {
		offLineWorker,
		onLineWorker
	} from "@/api";
	export default {
		name: "logiticsCompany",
		components: {},
		data() {
			return {
				dictData: [{
					title: "全部",
					value: ""
				}, {
					title: "待确认",
					value: 0
				}, {
					title: "待结算",
					value: 1
				}, {
					title: "已打款",
					value: 2
				}],
				tableSize: "default",
				message: "",
				selectIndex: "",
				currentRow: {},
				height: 510,
				showCompany: false,
				bindingVisiable: false,
				showType: "0",
				openSearch: true,
				openTip: true,
				loading: true,
				reading: false,
				loadingExport: true,
				exportModalVisible: false,
				importModalVisible: false,
				deployModalVisible: false,
				uploadfile: {
					name: "",
				},
				drop: false,
				selectList: [],
				searchForm: {
					id: "",
					shopName: "",
					contacts: "",
					mobile: "",
					pageNumber: 1,
					pageSize: 10,
					sort: "createTime",
					order: "desc",
					startDate: "",
					endDate: "",
					signCompany: "0",
				},
				selectDate: null,
				options: {
					shortcuts: shortcuts,
				},
				form: {},
				columns: [{
						type: "selection",
						width: 60,
						align: "center",
						fixed: "left",
					},
					{
						type: "index",
						width: 60,
						align: "center",
						fixed: "left",
					},
					{
						title: "账单周期",
						key: "shopName",
						minWidth: 100,
						sortable: true,
						fixed: "left",
					},
					{
						title: "店铺名称",
						key: "shopName",
						minWidth: 100,
						sortable: true,
						fixed: "left",
					},
					{
						title: "订单数量",
						key: "companyTel",
						minWidth: 150,
						sortable: true,
					},
					{
						title: "配送费",
						key: "companyEmail",
						minWidth: 250,
					},
					{
						title: "商品原价",
						key: "contacts",
						width: 100,
					},
					{
						title: "餐盒费",
						key: "mobile",
						width: 150,
					},
					{
						title: "账户余额支付金额",
						key: "mobile",
						width: 150,
					},
					{
						title: "商家实收总金额",
						key: "mobile",
						width: 150,
					},
					{
						title: "活动金额",
						key: "mobile",
						width: 150,
					},
					{
						title: "抵用券金额",
						key: "mobile",
						width: 150,
					},
					{
						title: "平台补贴",
						key: "mobile",
						width: 150,
					},
					{
						title: "商品平台抽成",
						key: "mobile",
						width: 150,
					},
					{
						title: "商家补贴",
						key: "mobile",
						width: 150,
					},
					{
						title: "商品商家抽成",
						key: "mobile",
						width: 150,
					},
					{
						title: "商家营收",
						key: "mobile",
						width: 150,
					},
					{
						title: "平台营收",
						key: "mobile",
						width: 150,
					},
					{
						title: "本期期初",
						key: "mobile",
						width: 150,
					},
					{
						title: "实际打款金额",
						key: "mobile",
						width: 150,
					},
					{
						title: "账单状态",
						key: "mobile",
						width: 150,
					},
					{
						title: "操作",
						key: "action",
						width: 200,
						align: "center",
						fixed: "right",
						render: (h, params) => {
							return h("div", [h(
									"a", {
										on: {
											click: () => {
												this.findAllRecord(params.row);
											},
										},
									},
									"确认"
								),
								h("Divider", {
									props: {
										type: "vertical",
									},
								}),
								h(
									"a", {
										on: {
											click: () => {
												this.stationBinding(params.row);
											},
										},
									},
									"详情"
								),
								h("Divider", {
									props: {
										type: "vertical",
									},
								}),
								h(
									"a", {
										on: {
											click: () => {
												this.edit(params.row);
											},
										},
									},
									"修改"
								),
							]);
						},
					},
				],
				chooseColumns: [],
				filename: "公司数据",
				exportTitle: "确认导出",
				exportType: "",
				data: [],
				exportData: [],
				total: 0,
				Visiable: false,
				rechargeVisiable: false,
			};
		},
		methods: {
			init() {
				// this.getDataList();
			},
			getDataList() {
				// 多条件搜索用户列表
				this.loading = true;
				getLogiticsCompanyData(this.searchForm).then((res) => {
					this.loading = false;
					if (res.success) {
						if (!this.getStore("roles").includes("ROLE_ADMIN")) {
							res.result.content.forEach((e) => {
								e.mobile = "您无权查看该数据";
							});
						}
						this.data = res.result.content;
						this.total = res.result.totalElements;
						if (this.data.length == 0 && this.searchForm.pageNumber > 1) {
							this.searchForm.pageNumber -= 1;
							this.getDataList();
						}
					}
				});
			},
			handleSearch() {
				this.searchForm.pageNumber = 1;
				this.searchForm.pageSize = 10;
				this.getDataList();
			}
		},
		mounted() {
			// 计算高度
			this.height = Number(document.documentElement.clientHeight - 230);
			this.init();
		},
	};
</script>