Browse Source

no message

devlop
xpz2018 3 years ago
parent
commit
f485ea0ec3
3 changed files with 193 additions and 15 deletions
  1. 4
      manifest.json
  2. 45
      pages/device-production-info/index.vue
  3. 159
      utils/floatObj.js

4
manifest.json

@ -2,8 +2,8 @@
"name" : "印包管家", "name" : "印包管家",
"appid" : "__UNI__EBBA73E", "appid" : "__UNI__EBBA73E",
"description" : "", "description" : "",
"versionName" : "1.0.5",
"versionCode" : 101,
"versionName" : "1.0.6",
"versionCode" : 102,
"transformPx" : false, "transformPx" : false,
"networkTimeout" : { "networkTimeout" : {
"request" : 6000 "request" : 6000

45
pages/device-production-info/index.vue

@ -15,14 +15,23 @@
<text class="text_7">{{ info.belongWorkshop }}</text> <text class="text_7">{{ info.belongWorkshop }}</text>
</view> </view>
</view> </view>
<view class="flex-col group_9">
<view class="flex-row-start-space group_9" style="color: #999999;">
<text>品牌{{ info.trademark }}</text> <text>品牌{{ info.trademark }}</text>
<text class="text_9">供应商{{ info.supplier }}</text>
<text class="text_10">出厂年月{{ info.producedAt | formatDate }}</text>
<text class="text_11">平均产能{{ info.avgCapacity }}/小时</text>
<text class="text_12">电压/功率{{ info.voltage }}V/10KW</text>
<text>供应商{{ info.supplier }}</text>
<text>出厂年月{{ info.producedAt | formatDate }}</text>
</view> </view>
<view class="flex-row-start-space group_9" style="color: #999999;margin-top: 6rpx;">
<text>平均产能{{ info.avgCapacity }}/小时</text>
<text>电压/功率{{ info.voltage }}V/10KW</text>
</view>
</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="#e1e1e1" size="16"></uni-icons>
<text style="padding-top: 4rpx;">{{ info.position }}</text>
</view>
</view>
<view class="flex-col line-tabs"> <view class="flex-col line-tabs">
<view class="flex-col section_3"> <view class="flex-col section_3">
<view class="flex-row group_2"> <view class="flex-row group_2">
@ -47,24 +56,24 @@
<text class="text_17">{{ info.monthCapacity }}</text> <text class="text_17">{{ info.monthCapacity }}</text>
<text class="text_18">今日{{ info.todayCapacity }}</text> <text class="text_18">今日{{ info.todayCapacity }}</text>
<text class="text_18">昨日{{ info.yesterdayCapacity }}</text> <text class="text_18">昨日{{ info.yesterdayCapacity }}</text>
<text class="text_18">累计{{ info.totalCapacity }}</text>
<!-- <text class="text_18">累计{{ info.totalCapacity }}</text> -->
</view> </view>
<view class="flex-col group_11"> <view class="flex-col group_11">
<view class="flex-row group_12"> <view class="flex-row group_12">
<image src="/static/imgs/factory/clock-icon.png" class="image_6" /> <image src="/static/imgs/factory/clock-icon.png" class="image_6" />
<text class="text_16">当月工作</text> <text class="text_16">当月工作</text>
</view> </view>
<text class="text_17">{{ info.monthWorkHour }} h</text>
<text class="text_18">今日{{ info.todayWorkHour }}</text>
<text class="text_18">昨日{{ info.yesterdayWorkHour }}</text>
<text class="text_18">累计{{ info.totalWorkHour }}</text>
<text class="text_17">{{ transHours(info.monthWorkTime) }} h</text>
<text class="text_18">今日{{ transHours(info.todayWorkTime) }}</text>
<text class="text_18">昨日{{ info.yesterdayWorkTime }}</text>
<!-- <text class="text_18">累计{{ info.totalWorkHour }}</text> -->
</view> </view>
<view class="flex-col group_11"> <view class="flex-col group_11">
<view class="flex-row group_12"> <view class="flex-row group_12">
<image src="/static/imgs/factory/calc-icon.png" class="image_6" /> <image src="/static/imgs/factory/calc-icon.png" class="image_6" />
<text class="text_16">开机率</text> <text class="text_16">开机率</text>
</view> </view>
<text class="text_17">{{ info.startupRate }}%</text>
<text class="text_17">{{ info.monthOperationRate }}%</text>
</view> </view>
</view> </view>
<view class="flex-col items-center empty-info" v-show="curTab == 2"> <view class="flex-col items-center empty-info" v-show="curTab == 2">
@ -133,6 +142,7 @@
<script> <script>
import OrderItem from './OrderItem' import OrderItem from './OrderItem'
import { go2, back } from '@/utils/hook.js' import { go2, back } from '@/utils/hook.js'
import { accDiv } from '@/utils/floatObj.js'
import { getMachineInfo, makeDeviceShare } from '@/apis/deviceApi' import { getMachineInfo, makeDeviceShare } from '@/apis/deviceApi'
import { getOrderListByMachine } from '@/apis/orderApi.js' import { getOrderListByMachine } from '@/apis/orderApi.js'
import { H5_URL_DEVICE, isEncrypt } from '@/enums/index.js' import { H5_URL_DEVICE, isEncrypt } from '@/enums/index.js'
@ -185,6 +195,15 @@ export default {
}) })
} }
}, },
transHours(hour) {
if(hour <= 0){
return 0
}
if(hour < 360){
return '小于6分钟'
}
return accDiv(hour, 3600).toFixed(2)
},
translate(time) { translate(time) {
if (!time) { if (!time) {
return '' return ''
@ -280,8 +299,8 @@ export default {
white-space: nowrap; white-space: nowrap;
position: relative; position: relative;
.image_2 { .image_2 {
width: 91.5vw;
height: 51.5vw;
width: 100vw;
height: 50vw;
} }
.text_18 { .text_18 {
position: absolute; position: absolute;

159
utils/floatObj.js

@ -0,0 +1,159 @@
export function accAdd(num1, num2) {
// 加法
num1 = Number(num1);
num2 = Number(num2);
let dec1, dec2;
try {
dec1 = countDecimals(num1) + 1;
} catch (e) {
dec1 = 0;
}
try {
dec2 = countDecimals(num2) + 1;
} catch (e) {
dec2 = 0;
}
const times = Math.pow(10, Math.max(dec1, dec2));
// let result = (num1 * times + num2 * times) / times
const result = (accMul(num1, times) + accMul(num2, times)) / times;
return getCorrectResult("add", num1, num2, result);
// return result
}
export function accSub(num1, num2) {
// 减法
num1 = Number(num1);
num2 = Number(num2);
let dec1, dec2;
try {
dec1 = countDecimals(num1) + 1;
} catch (e) {
dec1 = 0;
}
try {
dec2 = countDecimals(num2) + 1;
} catch (e) {
dec2 = 0;
}
const times = Math.pow(10, Math.max(dec1, dec2));
// let result = Number(((num1 * times - num2 * times) / times)
const result = Number((accMul(num1, times) - accMul(num2, times)) / times);
return getCorrectResult("sub", num1, num2, result);
// return result
}
export function accDiv(num1, num2) {
// 除法
num1 = Number(num1);
num2 = Number(num2);
let t1 = 0;
let t2 = 0;
try {
t1 = countDecimals(num1);
} catch (e) {
console.log(e);
}
try {
t2 = countDecimals(num2);
} catch (e) {
console.log(e);
}
const dec1 = convertToInt(num1);
const dec2 = convertToInt(num2);
const result = accMul(dec1 / dec2, Math.pow(10, t2 - t1));
return getCorrectResult("div", num1, num2, result);
// return result
}
export function accMul(num1, num2) {
// 乘法
num1 = Number(num1);
num2 = Number(num2);
let times = 0;
const s1 = num1.toString();
const s2 = num2.toString();
try {
times += countDecimals(s1);
} catch (e) {
console.log(e);
}
try {
times += countDecimals(s2);
} catch (e) {
console.log(e);
}
const result = (convertToInt(s1) * convertToInt(s2)) / Math.pow(10, times);
return getCorrectResult("mul", num1, num2, result);
// return result
}
function countDecimals(num) {
var len = 0;
try {
num = Number(num);
let str = num.toString().toUpperCase();
if (str.split("E").length === 2) {
// scientific notation
let isDecimal = false;
if (str.split(".").length === 2) {
str = str.split(".")[1];
if (parseInt(str.split("E")[0]) !== 0) {
isDecimal = true;
}
}
const x = str.split("E");
if (isDecimal) {
len = x[0].length;
}
len -= parseInt(x[1]);
} else if (str.split(".").length === 2) {
// decimal
if (parseInt(str.split(".")[1]) !== 0) {
len = str.split(".")[1].length;
}
}
} catch (e) {
throw e;
} finally {
if (isNaN(len) || len < 0) {
len = 0;
}
// return len
}
return len;
}
function convertToInt(num) {
num = Number(num);
let newNum = num;
const times = countDecimals(num);
const temp_num = num.toString().toUpperCase();
if (temp_num.split("E").length === 2) {
newNum = Math.round(num * Math.pow(10, times));
} else {
newNum = Number(temp_num.replace(".", ""));
}
return newNum;
}
function getCorrectResult(type, num1, num2, result) {
let temp_result = 0;
switch (type) {
case "add":
temp_result = num1 + num2;
break;
case "sub":
temp_result = num1 - num2;
break;
case "div":
temp_result = num1 / num2;
break;
case "mul":
temp_result = num1 * num2;
break;
}
if (Math.abs(result - temp_result) > 1) {
return temp_result;
}
return result;
}
Loading…
Cancel
Save