【前端】印包客app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

560 lines
16 KiB

<template>
<view class="content">
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="生产设备详情">
<view slot="right"><text class="text_4" @click="popupShow">分享</text></view>
</uni-nav-bar>
<view class="flex-col items-center group_1" v-if="info.hlsUrl || (info.imgUrlList && info.imgUrlList[0])">
<image v-if="info.hlsUrl" src="/static/imgs/digital-workshops/camera-tip-bg.png" class="image_2" @click="go2('video-play', { url: encodeURIComponent(info.hlsUrl) })" />
<image v-else :src="info.imgUrlList[0].url" class="image_2" />
</view>
<view class="flex-col group_6">
<view class="flex-col">
<text class="text_5">{{ info.name }}</text>
<view class="flex-row group_8">
<text>{{ translate(info.latestWorkTime) }}</text>
<text class="text_7">{{ info.belongWorkshop }}</text>
</view>
</view>
<view class="flex-row-start-space group_9" style="color: #999999;font-size: 26rpx;">
<text>品牌:{{ info.trademark }}</text>
<text>供应商:{{ info.supplier }}</text>
<text>出厂年月:{{ info.producedAt | formatDate }}</text>
</view>
<view class="flex-row-start-space group_9" style="color: #999999;margin-top: 6rpx;font-size: 26rpx;">
<text>平均产能:{{ info.avgCapacity }}件/小时</text>
<text>电压/功率:{{ info.voltage }}V/10KW</text>
</view>
</view>
<view class="flex-row-start-space" style="color: #999999;padding: 6rpx 24rpx;font-size: 24rpx;">
<text>最近开机:{{ info.latelyBootTime }}</text>
<view class="flex-row-start-center">
<uni-icons type="location" color="#999999" size="18"></uni-icons>
<text>{{ info.position }}</text>
</view>
</view>
<view class="flex-col line-tabs">
<view class="flex-col section_3">
<view class="flex-row group_2">
<view
class="text-wrapper"
:class="{ 'text-wrapper_selected': curTab === item.key }"
v-for="item in tabList"
:key="item.key"
@click="selectTab(item.key)"
>
<text>{{ item.name }}</text>
<view v-show="curTab === item.key" class="divider"></view>
</view>
</view>
</view>
<view class="flex-row section_4" v-show="curTab == 1">
<view class="flex-col group_11">
<view class="flex-row group_12">
<image src="/static/imgs/factory/electric-box-icon.png" class="image_6" />
<text class="text_16">当月产能(件)</text>
</view>
<text class="text_17">{{ info.monthCapacity || '- -'}}</text>
<text class="text_18">今日:{{ info.todayCapacity|| '- -' }}</text>
<text class="text_18">昨日:{{ info.yesterdayCapacity|| '- -' }}</text>
<!-- <text class="text_18">累计:{{ info.totalCapacity }}</text> -->
</view>
<view class="flex-col group_11">
<view class="flex-row group_12">
<image src="/static/imgs/factory/clock-icon.png" class="image_6" />
<text class="text_16">当月工作</text>
</view>
<text class="text_17">{{ transHours(info.monthWorkTime) }} h</text>
<text class="text_18">今日:{{ transHours(info.todayWorkTime)|| '- -' }}h</text>
<text class="text_18">昨日:{{ info.yesterdayWorkTime || '- -' }}h</text>
<!-- <text class="text_18">累计:{{ info.totalWorkHour }}</text> -->
</view>
<view class="flex-col group_11">
<view class="flex-row group_12">
<image src="/static/imgs/factory/calc-icon.png" class="image_6" />
<text class="text_16">开机率</text>
</view>
<text class="text_17">{{ info.monthOperationRate }}%</text>
<text class="text_18">今日:{{ info.todayOperationRate }}%</text>
<text class="text_18">昨日:{{ info.yesterdayOperationRate || '- -' }}%</text>
</view>
</view>
<view class="flex-col items-center empty-info" v-show="curTab == 2">
<text>暂无维修信息</text>
</view>
<view class="flex-col items-center empty-info" v-show="curTab == 3">
<text>暂无购置信息</text>
</view>
</view>
<view v-if="orderList.length">
<OrderItem v-for="(item, index) in orderList" :key="item.orderId" :item="item" :index="index" @click="goDetail"></OrderItem>
<view style="height: 24rpx;"></view>
</view>
<view class="flex-col items-center empty-info" style="margin-top: 16rpx;" v-else>
暂无生产中的订单
</view>
<uni-popup ref="popup" type="bottom">
<view class="flex-col group_10">
<view class="flex-col section_7">
<view class="flex-col section_8">
<text class="text_12">立即分享给好友</text>
<view class="flex-col group_11">
<view class="top-group flex-row">
<image src="/static/imgs/general/session-share-icon.png" class="image_8" @click="share('WXSceneSession')" />
<image src="/static/imgs/general/line-share-icon.png" class="image_9" @click="share('WXSceneTimeline')" />
</view>
<view class="top-group flex-row view_1">
<text>微信好友</text>
<text class="text_14">朋友圈</text>
</view>
<view class="divider"></view>
<view class="flex-col section_9">
<view class="justify-between group_12">
<view class="flex-row group_13" @click="selectMethod(true)">
<image :src="hasPassword ? '/static/imgs/general/selected-icon.png' : '/static/imgs/general/select-icon.png'" class="image_10" />
<text class="text_15">密码分享</text>
</view>
<view class="flex-row group_14" v-show="hasPassword">
<qn-easyinput
:maxlength="20"
v-model="password"
:inputBorder="false"
text="right"
placeholderStyle=" fontSize: 28rpx"
placeholder="请设置访问密码"
></qn-easyinput>
</view>
</view>
<text class="text_17" v-show="hasPassword">请提前告知用户访问密码,以便及时查看信息</text>
<view class="flex-row group_15" @click="selectMethod(false)">
<image :src="hasPassword ? '/static/imgs/general/select-icon.png' : '/static/imgs/general/selected-icon.png'" class="image_10" />
<text class="text_18">公开访问</text>
</view>
</view>
</view>
</view>
</view>
<view class="flex-col items-center button" @click="popupHide">
<text>取消</text>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import OrderItem from './OrderItem'
import { go2, back } from '@/utils/hook.js'
import { accDiv } from '@/utils/floatObj.js'
import { getMachineInfo, makeDeviceShare } from '@/apis/deviceApi'
import { getOrderListByMachine } from '@/apis/orderApi.js'
import { H5_URL_DEVICE, isEncrypt } from '@/enums/index.js'
const tabList = [
{ name: '生产情况', key: 1 },
{ name: '维修保养', key: 2 },
{ name: '购置信息', key: 3 }
]
export default {
components: {
OrderItem
},
data() {
return {
id: null,
info: {},
tabList: Object.freeze(tabList),
curTab: 1,
hasPassword: true,
password: '',
orderList: []
}
},
onLoad(options) {
if (options.id) {
this.id = options.id
this.factoryId = options.factoryId
}
},
watch: {
id(val) {
this.getInfo()
}
},
methods: {
go2,
back,
getInfo() {
if (this.id) {
getMachineInfo(this.id, {factoryId: this.factoryId}).then((res) => {
if (res) {
this.info = res
}
})
getOrderListByMachine(this.id, {status: 1}).then((res) => {
if (res && res.productionTaskList && res.productionTaskList.length) {
this.orderList = res.productionTaskList
}
})
}
},
transHours(hour) {
if(hour <= 0){
return 0
}
if(hour < 360){
return '小于6分钟'
}
return accDiv(hour, 3600).toFixed(2)
},
translate(time) {
if (!time) {
return ''
}
time = time.replace(/-/g, '/')
let date = new Date(time)
let month = date.getMonth() + 1
let day = date.getDate()
let hour = date.getHours()
let minute = date.getMinutes()
if (minute < 10) {
minute = '0' + minute
}
return `最近开机 ${month}${day}${hour}:${minute}`
},
selectTab(key) {
this.curTab = key
},
popupShow() {
this.$refs.popup.open('bottom')
},
popupHide() {
this.$refs.popup.close()
},
selectMethod(isPassword) {
this.hasPassword = isPassword
},
// 根据状态跳转到不同页面
goDetail(order) {
go2('order-info', { orderId: order.orderId })
},
share(scene) {
// 先处理密码的逻辑
if (this.hasPassword && !this.password) {
uni.showToast({
title: '请输入访问密码',
icon: 'none'
})
return
}
makeDeviceShare({
encryptOrNot: this.hasPassword ? isEncrypt.YES : isEncrypt.NO,
mechanicalEquipmentId: this.id,
password: this.password
}).then((res) => {
if (res) {
uni.share({
provider: 'weixin',
type: 0,
title: '设备展示',
summary: '机器进度实时查看',
scene: scene, // WXSceneTimeline,WXSceneSession
imageUrl: 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/wx-share-store.png',
href: H5_URL_DEVICE + `shareId=${res}`,
success: () => {
console.log('分享成功')
},
fail: (err) => {
console.log('err', err)
}
})
}
})
}
},
filters: {
formatDate(time) {
if (!time) {
return ''
}
time = time.replace(/-/g, '/')
let date = new Date(time)
let year = date.getFullYear()
let month = date.getMonth() + 1
return `${year}${month}`
}
}
}
</script>
<style lang="scss" scoped>
.content {
width: 750rpx;
.text_4 {
color: rgb(0, 122, 255);
font-size: 28rpx;
}
.group_1 {
color: rgb(255, 255, 255);
font-size: 28rpx;
font-weight: 500;
line-height: 40rpx;
white-space: nowrap;
position: relative;
.image_2 {
width: 100vw;
height: 50vw;
}
.text_18 {
position: absolute;
left: 24rpx;
top: 16rpx;
}
}
}
.group_6 {
padding: 24rpx 32rpx 32rpx;
.group_9 {
margin-top: 24rpx;
color: rgb(51, 51, 51);
font-size: 28rpx;
line-height: 40rpx;
white-space: nowrap;
.text_9 {
margin-top: 10rpx;
}
.text_10 {
margin-top: 10rpx;
}
.text_11 {
margin-top: 10rpx;
}
.text_12 {
margin-top: 10rpx;
}
}
.text_5 {
color: rgb(0, 0, 0);
font-size: 34rpx;
font-weight: 500;
line-height: 48rpx;
white-space: nowrap;
}
.group_8 {
margin-top: 8rpx;
color: rgb(136, 136, 136);
font-size: 20rpx;
line-height: 28rpx;
white-space: nowrap;
.text_7 {
margin-left: 11rpx;
}
}
}
.line-tabs {
margin-top: 4rpx;
.section_3 {
padding-bottom: 3rpx;
background-color: rgb(255, 255, 255);
.group_2 {
padding: 0 40rpx;
border-bottom: solid 2rpx rgb(221, 221, 221);
.text-wrapper {
color: rgb(136, 136, 136);
font-size: 28rpx;
height: 86rpx;
line-height: 86rpx;
white-space: nowrap;
position: relative;
text-align: center;
margin-right: 40rpx;
min-width: 80rpx;
}
.text-wrapper_selected {
color: rgb(51, 51, 51);
font-weight: 500;
}
.divider {
background-color: rgb(0, 122, 255);
border-radius: 3rpx;
width: 80rpx;
height: 6rpx;
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
}
}
.section_4 {
padding: 0 32rpx 25rpx;
background-color: rgb(255, 255, 255);
.group_11 {
margin-top: 30rpx;
flex: 1 1 auto;
width: 30%;
text-align: center;
.group_12 {
padding-left: 8rpx;
color: rgb(136, 136, 136);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
justify-content: center;
.text_16 {
margin-left: 9rpx;
}
}
.text_17 {
margin-top: 12rpx;
align-self: center;
color: rgb(51, 51, 51);
font-size: 28rpx;
font-weight: 500;
line-height: 40rpx;
white-space: nowrap;
}
.text_18 {
margin-top: 6rpx;
color: rgb(136, 136, 136);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
}
}
.image_6 {
width: 28rpx;
height: 28rpx;
}
}
}
.empty-info {
padding: 50rpx 0 58rpx;
color: rgb(0, 0, 0);
font-size: 28rpx;
font-weight: 500;
line-height: 40rpx;
white-space: nowrap;
background-color: rgb(255, 255, 255);
overflow: hidden;
height: 148rpx;
}
.group_10 {
height: 637rpx;
.section_7 {
padding-bottom: 96rpx;
background-color: rgb(247, 248, 250);
border-radius: 40rpx 40rpx 0px 0px;
.section_8 {
padding-top: 40rpx;
overflow: hidden;
border-radius: 40rpx 40rpx 0px 0px;
background-color: rgb(255, 255, 255);
height: 520rpx;
.text_12 {
align-self: center;
color: rgb(51, 51, 51);
font-size: 28rpx;
font-weight: 500;
line-height: 40rpx;
white-space: nowrap;
}
.group_11 {
margin-top: 40rpx;
.top-group {
padding: 0 48rpx;
.image_8 {
border-radius: 50%;
width: 96rpx;
height: 96rpx;
}
.image_9 {
margin-left: 64rpx;
width: 96rpx;
height: 96rpx;
}
.text_14 {
margin-left: 76rpx;
}
}
.view_1 {
margin-top: 16rpx;
color: rgb(51, 51, 51);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
}
.divider {
margin: 32rpx 32rpx 0;
background-color: rgb(235, 237, 240);
height: 1rpx;
}
.section_9 {
padding: 24rpx 32rpx 0;
background-color: rgb(255, 255, 255);
.image_10 {
margin: 4rpx 0;
width: 32rpx;
height: 32rpx;
}
.group_12 {
padding-left: 2rpx;
.group_13 {
color: rgb(51, 51, 51);
font-size: 28rpx;
line-height: 40rpx;
white-space: nowrap;
.text_15 {
margin-left: 18rpx;
}
}
.group_14 {
color: rgb(136, 136, 136);
font-size: 28rpx;
line-height: 40rpx;
white-space: nowrap;
}
}
.text_17 {
margin-top: 16rpx;
align-self: center;
color: rgb(136, 136, 136);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
}
.group_15 {
margin-top: 22rpx;
padding: 26rpx 2rpx 20rpx;
color: rgb(51, 51, 51);
font-size: 28rpx;
line-height: 40rpx;
white-space: nowrap;
border-top: solid 2rpx rgb(235, 237, 240);
.image_12 {
margin: 4rpx 0;
}
.text_18 {
margin-left: 18rpx;
}
}
.image_4 {
margin-left: 17rpx;
align-self: center;
width: 20rpx;
height: 20rpx;
}
}
}
}
}
.button {
margin-top: -75rpx;
padding: 26rpx 0;
color: rgb(51, 51, 51);
font-size: 32rpx;
line-height: 45rpx;
white-space: nowrap;
background-color: rgb(255, 255, 255);
position: relative;
}
}
</style>