<template>
	<view class="min-page bg-gray u-p-30 u-flex u-flex-col ">
		<div class="w-full" v-for="item in pageData.list " :key="item.id">
			<printer-item :data="item" @init='init'></printer-item>
		</div>
		<view v-if="!pageData.list.length&&pageData.hasAjax">
			<my-img-empty ></my-img-empty>
		</view>
		<view style="height: 100rpx;"></view>
		<view class="fixed_b u-fixed">
			<my-button shape="circle" @tap="toAdd">
				<view>
					<text>+</text>
					<text>添加云打印机</text>
				</view>
			</my-button>
		</view>
	</view>
</template>

<script setup>
	import go from '@/commons/utils/go.js'
	import {
		onShow,
	} from '@dcloudio/uni-app'
	import {
		onMounted,
		reactive
	} from 'vue';
	import printerItem from './components/printer-item.vue';
	import * as Api from '@/http/yskApi/devices.js'
	const pageData = reactive({
		list: [],
		hasAjax:false,
		query: {
			sort: '',
			name: '',
			contentType: ''
		}
	})
	function toAdd(){
		go.to('PAGES_PRINTER_ADD',{
			a:1
		})
	}
	async function init() {
		const res =await Api.tbPrintMachineGet(pageData.query)
		pageData.hasAjax=true
		pageData.list = res
		// pageData.list = res.filter(v=>v.address)
	}
	onShow(()=>{
		init()
	})
	// onMounted(() => {
	// 	init()
	// })
</script>

<style lang="scss" scoped>
.fixed_b{
	left: 110rpx;
	right: 110rpx;
	bottom: calc(env(safe-area-inset-bottom) + 10rpx);
	/* #ifdef H5 */
	bottom: 30rpx;
	/* #endif */
}
</style>