|  | @@ -1,94 +1,196 @@
 | 
	
		
			
				|  |  | -<script setup lang="ts">/**
 | 
	
		
			
				|  |  | +<script lang="ts" setup>
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  |   * @Name: ComputerDetail.vue
 | 
	
		
			
				|  |  |   * @Description: 电脑信息-当前
 | 
	
		
			
				|  |  |   * @Author: xinyan
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  | +import { useResponse } from '/@/utils/useResponse';
 | 
	
		
			
				|  |  |  import { ComputerColumns } from '/@/views/computer-information/useColumns';
 | 
	
		
			
				|  |  | +import * as api from '../api';
 | 
	
		
			
				|  |  | +import { Picture as IconPicture } from '@element-plus/icons-vue';
 | 
	
		
			
				|  |  | +import { useTableData } from '/@/utils/useTableData';
 | 
	
		
			
				|  |  | +import { usePagination } from '/@/utils/usePagination';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const route = useRoute();
 | 
	
		
			
				|  |  | +const id = route.query.id;
 | 
	
		
			
				|  |  | +const computerOverview: any = ref([]);
 | 
	
		
			
				|  |  | +const overviewLoading = ref();
 | 
	
		
			
				|  |  | +const currentView = ref('history');
 | 
	
		
			
				|  |  | +const { tableOptions, handlePageChange } = usePagination(fetchComputerData);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const gridOptions: any = reactive({
 | 
	
		
			
				|  |  | -  border: 'inner',
 | 
	
		
			
				|  |  | -  round: true,
 | 
	
		
			
				|  |  | -  stripe: true,
 | 
	
		
			
				|  |  | -  currentRowHighLight: true,
 | 
	
		
			
				|  |  | -  height: 870,
 | 
	
		
			
				|  |  | -  toolbarConfig: {
 | 
	
		
			
				|  |  | -    custom: true,
 | 
	
		
			
				|  |  | -    slots: {
 | 
	
		
			
				|  |  | -      buttons: 'toolbar_buttons'
 | 
	
		
			
				|  |  | -      // tools: 'toolbar_tools'
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  rowConfig: {
 | 
	
		
			
				|  |  | -    isHover: true
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  columnConfig: {
 | 
	
		
			
				|  |  | -    resizable: true
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  pagerConfig: {
 | 
	
		
			
				|  |  | -    total: 0,
 | 
	
		
			
				|  |  | -    page: 1,
 | 
	
		
			
				|  |  | -    limit: 10
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  loading: false,
 | 
	
		
			
				|  |  | -  loadingConfig: {
 | 
	
		
			
				|  |  | -    icon: 'vxe-icon-indicator roll',
 | 
	
		
			
				|  |  | -    text: '正在拼命加载中...'
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  columns: ComputerColumns,
 | 
	
		
			
				|  |  | -  data: []
 | 
	
		
			
				|  |  | +	border: 'inner',
 | 
	
		
			
				|  |  | +	round: true,
 | 
	
		
			
				|  |  | +	stripe: true,
 | 
	
		
			
				|  |  | +	currentRowHighLight: true,
 | 
	
		
			
				|  |  | +	height: 700,
 | 
	
		
			
				|  |  | +	toolbarConfig: {
 | 
	
		
			
				|  |  | +		custom: true,
 | 
	
		
			
				|  |  | +		slots: {
 | 
	
		
			
				|  |  | +			buttons: 'toolbar_buttons',
 | 
	
		
			
				|  |  | +			// tools: 'toolbar_tools'
 | 
	
		
			
				|  |  | +		},
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	rowConfig: {
 | 
	
		
			
				|  |  | +		isHover: true,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	columnConfig: {
 | 
	
		
			
				|  |  | +		resizable: true,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	pagerConfig: {
 | 
	
		
			
				|  |  | +		total: tableOptions.value.total,
 | 
	
		
			
				|  |  | +		page: tableOptions.value.page,
 | 
	
		
			
				|  |  | +		limit: tableOptions.value.limit,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	loading: false,
 | 
	
		
			
				|  |  | +	loadingConfig: {
 | 
	
		
			
				|  |  | +		icon: 'vxe-icon-indicator roll',
 | 
	
		
			
				|  |  | +		text: '正在拼命加载中...',
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	columns: ComputerColumns,
 | 
	
		
			
				|  |  | +	data: [],
 | 
	
		
			
				|  |  | +});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +function pageChange({ pageSize, currentPage }: any) {
 | 
	
		
			
				|  |  | +	gridOptions.pagerConfig.limit = pageSize;
 | 
	
		
			
				|  |  | +	gridOptions.pagerConfig.page = currentPage;
 | 
	
		
			
				|  |  | +	fetchComputerData();
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 当前信息、历史记录
 | 
	
		
			
				|  |  | +async function fetchComputerData() {
 | 
	
		
			
				|  |  | +	const query = {
 | 
	
		
			
				|  |  | +		id: id,
 | 
	
		
			
				|  |  | +		page: gridOptions.pagerConfig.page,
 | 
	
		
			
				|  |  | +		limit: gridOptions.pagerConfig.limit,
 | 
	
		
			
				|  |  | +	};
 | 
	
		
			
				|  |  | +	switch (currentView.value) {
 | 
	
		
			
				|  |  | +		case 'current':
 | 
	
		
			
				|  |  | +			currentView.value = 'history';
 | 
	
		
			
				|  |  | +			await useTableData(api.getPastTableData, query, gridOptions);
 | 
	
		
			
				|  |  | +			break;
 | 
	
		
			
				|  |  | +		case 'history':
 | 
	
		
			
				|  |  | +			currentView.value = 'current';
 | 
	
		
			
				|  |  | +			await useTableData(api.getCurrentTableData, query, gridOptions);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +async function fetchComputerDetailOverview() {
 | 
	
		
			
				|  |  | +	const res = await useResponse(id, api.getComputerDetailOverview, overviewLoading);
 | 
	
		
			
				|  |  | +	computerOverview.value = res.data;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const getImageSrc = () => {
 | 
	
		
			
				|  |  | +	// 如果 `images` 有值,则返回第一张图片的 URL;否则返回占位图
 | 
	
		
			
				|  |  | +	return computerOverview.value.images && computerOverview.value.images.length > 0
 | 
	
		
			
				|  |  | +		? computerOverview.value.images[0].image_url
 | 
	
		
			
				|  |  | +		: 'https://via.placeholder.com/150';
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 表格样式
 | 
	
		
			
				|  |  | +const cellStyle = () => {
 | 
	
		
			
				|  |  | +	return {
 | 
	
		
			
				|  |  | +		fontSize: '12px',
 | 
	
		
			
				|  |  | +		fontWeight: '600',
 | 
	
		
			
				|  |  | +	};
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const headerCellStyle = () => {
 | 
	
		
			
				|  |  | +	return {
 | 
	
		
			
				|  |  | +		fontSize: '12px',
 | 
	
		
			
				|  |  | +	};
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +onMounted(() => {
 | 
	
		
			
				|  |  | +	fetchComputerData();
 | 
	
		
			
				|  |  | +	fetchComputerDetailOverview();
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  |  </script>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <template>
 | 
	
		
			
				|  |  | -  <div class="p-2.5">
 | 
	
		
			
				|  |  | -    <!-- overview-card -->
 | 
	
		
			
				|  |  | -    <el-card body-class="flex items-center" shadow="hover" style="border: none">
 | 
	
		
			
				|  |  | -      <el-image :src="`https://via.placeholder.com/150`" class="mr-7 rounded-2xl" style="height: 100px; width: 100px; object-fit: contain">
 | 
	
		
			
				|  |  | -        <template #error>
 | 
	
		
			
				|  |  | -          <div class="mr-3.5 flex items-center justify-center text-5xl" style="height: 100px; width: 100px; background-color: #f5f5f5">
 | 
	
		
			
				|  |  | -            <el-icon>
 | 
	
		
			
				|  |  | -              <icon-picture />
 | 
	
		
			
				|  |  | -            </el-icon>
 | 
	
		
			
				|  |  | -          </div>
 | 
	
		
			
				|  |  | -        </template>
 | 
	
		
			
				|  |  | -      </el-image>
 | 
	
		
			
				|  |  | -      <el-col :span="18">
 | 
	
		
			
				|  |  | -        <div class="info-container">
 | 
	
		
			
				|  |  | -          <div class="info-column">
 | 
	
		
			
				|  |  | -            <div class="font-semibold">电脑编号:</div>
 | 
	
		
			
				|  |  | -            <div class="font-semibold">所属部门:</div>
 | 
	
		
			
				|  |  | -            <div class="font-semibold">工位号:</div>
 | 
	
		
			
				|  |  | -            <div class="font-semibold">IP地址:</div>
 | 
	
		
			
				|  |  | -          </div>
 | 
	
		
			
				|  |  | -          <div class="info-column">
 | 
	
		
			
				|  |  | -            <div class="font-semibold">电脑名称:</div>
 | 
	
		
			
				|  |  | -            <div class="font-semibold">使用人:</div>
 | 
	
		
			
				|  |  | -            <div class="font-semibold">电脑类型:</div>
 | 
	
		
			
				|  |  | -            <div class="font-semibold">MAC地址:</div>
 | 
	
		
			
				|  |  | -          </div>
 | 
	
		
			
				|  |  | -        </div>
 | 
	
		
			
				|  |  | -      </el-col>
 | 
	
		
			
				|  |  | -    </el-card>
 | 
	
		
			
				|  |  | -    <!-- table-card -->
 | 
	
		
			
				|  |  | -    <el-card body-style="padding-top: 10px" class="mt-2.5" shadow="hover" style="border: none">
 | 
	
		
			
				|  |  | -      <vxe-grid v-bind="gridOptions">
 | 
	
		
			
				|  |  | -      </vxe-grid>
 | 
	
		
			
				|  |  | -    </el-card>
 | 
	
		
			
				|  |  | -  </div>
 | 
	
		
			
				|  |  | +	<div class="p-2.5">
 | 
	
		
			
				|  |  | +		<!-- overview-card -->
 | 
	
		
			
				|  |  | +		<el-card v-loading="overviewLoading" body-class="flex items-center" shadow="hover" style="border: none">
 | 
	
		
			
				|  |  | +			<el-image :src="getImageSrc()" class="mr-7 rounded-2xl" style="height: 100px; width: 100px; object-fit: contain">
 | 
	
		
			
				|  |  | +				<template #error>
 | 
	
		
			
				|  |  | +					<div class="mr-3.5 flex items-center justify-center text-5xl" style="height: 100px; width: 100px; background-color: #f5f5f5">
 | 
	
		
			
				|  |  | +						<el-icon>
 | 
	
		
			
				|  |  | +							<icon-picture />
 | 
	
		
			
				|  |  | +						</el-icon>
 | 
	
		
			
				|  |  | +					</div>
 | 
	
		
			
				|  |  | +				</template>
 | 
	
		
			
				|  |  | +			</el-image>
 | 
	
		
			
				|  |  | +			<el-col :span="18">
 | 
	
		
			
				|  |  | +				<div class="info-container text-lg">
 | 
	
		
			
				|  |  | +					<div class="info-column">
 | 
	
		
			
				|  |  | +						<div class="font-semibold">
 | 
	
		
			
				|  |  | +							电脑编号:
 | 
	
		
			
				|  |  | +							<span class="font-medium italic ml-1.5" style="color: #64748b">{{ computerOverview.computerNumber }}</span>
 | 
	
		
			
				|  |  | +						</div>
 | 
	
		
			
				|  |  | +						<div class="font-semibold">
 | 
	
		
			
				|  |  | +							所属店铺:
 | 
	
		
			
				|  |  | +							<span class="font-medium italic ml-1.5" style="color: #64748b">{{ computerOverview.platformNumber }}</span>
 | 
	
		
			
				|  |  | +						</div>
 | 
	
		
			
				|  |  | +						<div class="font-semibold">
 | 
	
		
			
				|  |  | +							工位号:
 | 
	
		
			
				|  |  | +							<span class="font-medium italic ml-1.5" style="color: #64748b">{{ computerOverview.station }}</span>
 | 
	
		
			
				|  |  | +						</div>
 | 
	
		
			
				|  |  | +						<div class="font-semibold">
 | 
	
		
			
				|  |  | +							IP地址:
 | 
	
		
			
				|  |  | +							<span class="font-medium italic ml-1.5" style="color: #64748b">{{ computerOverview.ipaddress }}</span>
 | 
	
		
			
				|  |  | +						</div>
 | 
	
		
			
				|  |  | +					</div>
 | 
	
		
			
				|  |  | +					<div class="info-column">
 | 
	
		
			
				|  |  | +						<div class="font-semibold">
 | 
	
		
			
				|  |  | +							使用人:
 | 
	
		
			
				|  |  | +							<span class="font-medium italic ml-1.5" style="color: #64748b">{{ computerOverview.user }}</span>
 | 
	
		
			
				|  |  | +						</div>
 | 
	
		
			
				|  |  | +						<div class="font-semibold">
 | 
	
		
			
				|  |  | +							电脑类型:
 | 
	
		
			
				|  |  | +							<span class="font-medium italic ml-1.5" style="color: #64748b">{{ computerOverview.computerType }}</span>
 | 
	
		
			
				|  |  | +						</div>
 | 
	
		
			
				|  |  | +						<div class="font-semibold">
 | 
	
		
			
				|  |  | +							MAC地址:
 | 
	
		
			
				|  |  | +							<span class="font-medium italic ml-1.5" style="color: #64748b">{{ computerOverview.macaddress }}</span>
 | 
	
		
			
				|  |  | +						</div>
 | 
	
		
			
				|  |  | +					</div>
 | 
	
		
			
				|  |  | +				</div>
 | 
	
		
			
				|  |  | +			</el-col>
 | 
	
		
			
				|  |  | +		</el-card>
 | 
	
		
			
				|  |  | +		<!-- table-card -->
 | 
	
		
			
				|  |  | +		<el-card body-style="padding-top: 10px" class="mt-2.5" shadow="hover" style="border: none">
 | 
	
		
			
				|  |  | +			<vxe-grid :cell-style="cellStyle" :header-cell-style="headerCellStyle" v-bind="gridOptions">
 | 
	
		
			
				|  |  | +				<template #toolbar_buttons>
 | 
	
		
			
				|  |  | +					<el-button :type="currentView === 'current' ? 'primary' : 'default'" @click="fetchComputerData"> 当前信息 </el-button>
 | 
	
		
			
				|  |  | +					<el-button :type="currentView === 'history' ? 'primary' : 'default'" @click="fetchComputerData"> 历史记录 </el-button>
 | 
	
		
			
				|  |  | +				</template>
 | 
	
		
			
				|  |  | +				<template #pager>
 | 
	
		
			
				|  |  | +					<vxe-pager
 | 
	
		
			
				|  |  | +						v-model:currentPage="gridOptions.pagerConfig.page"
 | 
	
		
			
				|  |  | +						v-model:pageSize="gridOptions.pagerConfig.limit"
 | 
	
		
			
				|  |  | +						:total="gridOptions.pagerConfig.total"
 | 
	
		
			
				|  |  | +						size="small"
 | 
	
		
			
				|  |  | +						@page-change="handlePageChange"
 | 
	
		
			
				|  |  | +					>
 | 
	
		
			
				|  |  | +					</vxe-pager>
 | 
	
		
			
				|  |  | +				</template>
 | 
	
		
			
				|  |  | +			</vxe-grid>
 | 
	
		
			
				|  |  | +		</el-card>
 | 
	
		
			
				|  |  | +	</div>
 | 
	
		
			
				|  |  |  </template>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -<style scoped lang="scss">
 | 
	
		
			
				|  |  | +<style lang="scss" scoped>
 | 
	
		
			
				|  |  |  .info-container {
 | 
	
		
			
				|  |  | -  display: flex;
 | 
	
		
			
				|  |  | -  justify-content: space-between;
 | 
	
		
			
				|  |  | +	display: flex;
 | 
	
		
			
				|  |  | +	justify-content: space-between;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  .info-column {
 | 
	
		
			
				|  |  | -  flex: 1;
 | 
	
		
			
				|  |  | -  padding: 0 10px;
 | 
	
		
			
				|  |  | +	flex: 1;
 | 
	
		
			
				|  |  | +	padding: 0 10px;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  p {
 | 
	
		
			
				|  |  | -  margin: 5px 0;
 | 
	
		
			
				|  |  | +	margin: 5px 0;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -</style>
 | 
	
		
			
				|  |  | +</style>
 |