init(projects): 整体修改

master
xushilin 11 months ago
parent 3bd002c96f
commit 622f68e4da

@ -138,7 +138,7 @@ export let option = {
],
series: [
{
name: '拉丝',
name: '投料数量',
type: 'bar',
barWidth: 12,
itemStyle: {
@ -165,7 +165,7 @@ export let option = {
},
},
{
name: '拉丝报工数量',
name: '报工数量',
type: 'bar',
barWidth: 12,
itemStyle: {

@ -1,7 +1,7 @@
<template>
<div id="screen-wrapper" class="screen-wrapper">
<div id="screen" class="screen">
<div class="title">领秀镜智慧工厂</div>
<div class="title">领秀镜智慧工厂</div>
<!-- // -->
<div class="left_area left_top_area">
<div class="left_top_div">
@ -61,14 +61,14 @@
<div v-show="!loading2" class="bar_area">
<div class="left">
<div class="yxz">
<div class="bar_title">本周搬运总数</div>
<div class="bar_title">本周生产总数</div>
<div class="content">
<div class="progress">{{ totalTransport }}</div>
</div>
</div>
</div>
<div class="tips" style="position: absolute; top: 47px; right: 300px; color: #fff; font-size: 12px">
本周搬运
本周生产
</div>
<div class="mid" style="width: 700px; display: flex; justify-content: space-around">
<!-- <div class="area1" v-for="item in productionData.wiredrawingNumWeek">
@ -664,7 +664,7 @@ export default defineComponent({
if (res.code === 200) {
this.loading3 = false;
this.loading1 = false;
this.detectionDayNum = res.data.detectionDayNum || 0;
this.detectionDayNum = res.data.detectionDayNum || 1;
const qcPageResults = res.data.qcPageResults || [];
for (const item of qcPageResults) {
this.leftBotData.seriesData.push(Number(item.goodRate).toFixed(2));

@ -394,13 +394,13 @@ const columns: Ref<DataTableColumns<outWarehouse.TableList>> = ref([
key: 'moldOutboundTime',
align: 'center',
width: 180
},
{
title: '出库位置',
key: 'attr1',
align: 'center',
width: 100
}
// {
// title: '',
// key: 'attr1',
// align: 'center',
// width: 100
// }
]);
function search() {

@ -96,21 +96,57 @@ const columns: Ref<DataTableColumns<drawingProcessCheckRecord.TableList>> = ref(
width: 70,
render: (_row, index) => (searchForm.value.pageNum - 1) * searchForm.value.pageSize + index + 1
},
// {
// title: '',
// key: 'workOrdeType',
// align: 'center',
// width: 100,
// render: row => {
// return row.workOrdeType === '0' ? '' : '';
// }
// },
{
title: '检测项',
key: 'attr1',
align: 'center',
width: 180
},
{
title: '质检人',
key: 'qualityInspector',
align: 'center',
width: 100
},
{
title: '工单类型',
key: 'workOrdeType',
title: '是否合格',
key: 'qualifiedOrNot',
align: 'center',
width: 100,
render: row => (
<n-tag type={row.qualifiedOrNot === '0' ? 'success' : 'error'}>
{row.qualifiedOrNot === '0' ? '合格' : '不合格'}
</n-tag>
)
},
{
title: '缺陷项',
key: '',
align: 'center',
width: 180,
ellipsis: {
tooltip: true
},
render: row => {
return row.workOrdeType === '0' ? '板材' : '金属';
let defectName = '';
if (row.qcDefectList) {
row.qcDefectList.forEach(item => {
defectName += `${item.defectName},`;
});
defectName = defectName.slice(0, -1);
}
return defectName;
}
},
// {
// title: '线',
// key: 'attr1',
// align: 'center',
// width: 100
// },
{
title: '机台',
key: 'deviceName',
@ -134,20 +170,11 @@ const columns: Ref<DataTableColumns<drawingProcessCheckRecord.TableList>> = ref(
tooltip: true
}
},
// {
// title: '',
// key: 'clientName',
// align: 'center',
// width: 140,
// ellipsis: {
// tooltip: true
// }
// },
{
title: '生产工单号',
key: 'generateWorkOrderNumber',
align: 'center',
width: 100,
width: 180,
ellipsis: {
tooltip: true
}
@ -156,14 +183,14 @@ const columns: Ref<DataTableColumns<drawingProcessCheckRecord.TableList>> = ref(
title: '产品规格',
key: 'productSpecifications',
align: 'center',
width: 100
},
{
title: '数量',
key: 'weight',
align: 'center',
width: 100
width: 160
},
// {
// title: '',
// key: 'weight',
// align: 'center',
// width: 100
// },
{
title: '单位',
key: 'measure',
@ -174,49 +201,13 @@ const columns: Ref<DataTableColumns<drawingProcessCheckRecord.TableList>> = ref(
title: '批号',
key: 'batchNumber',
align: 'center',
width: 100
width: 180
},
{
title: '日期',
key: 'createTime',
align: 'center',
width: 180
},
{
title: '质检人',
key: 'qualityInspector',
align: 'center',
width: 100
},
{
title: '是否合格',
key: 'qualifiedOrNot',
align: 'center',
width: 100,
render: row => (
<n-tag type={row.qualifiedOrNot === '0' ? 'success' : 'error'}>
{row.qualifiedOrNot === '0' ? '合格' : '不合格'}
</n-tag>
)
},
{
title: '缺陷项',
key: '',
align: 'center',
width: 180,
ellipsis: {
tooltip: true
},
render: row => {
let defectName = '';
if (row.qcDefectList) {
row.qcDefectList.forEach(item => {
defectName += `${item.defectName}, `;
});
defectName = defectName.slice(0, -1);
}
return defectName;
}
}
]);

@ -147,27 +147,27 @@ const columns: Ref<DataTableColumns<enamellingProcessCheckRecord.TableList>> = r
width: 70,
render: (_row, index) => (searchForm.value.pageNum - 1) * searchForm.value.pageSize + index + 1
},
{
title: '工单类型',
key: 'workOrdeType',
align: 'center',
width: 100,
render: row => {
return row.workOrdeType === '0' ? '金属' : '板材';
}
},
// {
// title: '',
// key: 'workOrdeType',
// align: 'center',
// width: 100,
// render: row => {
// return row.workOrdeType === '0' ? '' : '';
// }
// },
{
title: '机台',
key: 'deviceName',
align: 'center',
width: 100
},
{
title: '轴号',
key: 'axisNumber',
align: 'center',
width: 100
},
// {
// title: '',
// key: 'axisNumber',
// align: 'center',
// width: 100
// },
{
title: '订单类型',
key: 'orderType',
@ -194,20 +194,20 @@ const columns: Ref<DataTableColumns<enamellingProcessCheckRecord.TableList>> = r
tooltip: true
}
},
{
title: '料号',
key: 'partNumber',
align: 'center',
width: 140,
ellipsis: {
tooltip: true
}
},
// {
// title: '',
// key: 'partNumber',
// align: 'center',
// width: 140,
// ellipsis: {
// tooltip: true
// }
// },
{
title: '批号',
key: 'batchNumber',
align: 'center',
width: 140
width: 180
},
{
title: '生产工单号',
@ -222,13 +222,13 @@ const columns: Ref<DataTableColumns<enamellingProcessCheckRecord.TableList>> = r
title: '产品型号',
key: 'productModel',
align: 'center',
width: 100
width: 160
},
{
title: '产品规格',
key: 'productSpecifications',
align: 'center',
width: 100
width: 160
},
{
title: '日期',
@ -238,10 +238,16 @@ const columns: Ref<DataTableColumns<enamellingProcessCheckRecord.TableList>> = r
},
{
title: '质检人',
key: 'qualityInspector',
key: 'createBy',
align: 'center',
width: 100
},
{
title: '检测项',
key: 'attr2',
align: 'center',
width: 180
},
{
title: '是否合格',
key: 'qualifiedOrNot',

@ -61,7 +61,7 @@
:style="{ width: formItemWidth }"
/>
</n-form-item-grid-item>
<n-form-item-grid-item label="缺陷分类" path="defectClassificationId">
<!-- <n-form-item-grid-item label="缺陷分类" path="defectClassificationId">
<n-select
v-model:value="addForm.defectClassificationId"
placeholder="请选择缺陷分类"
@ -69,7 +69,7 @@
:options="defectClassifyList"
:style="{ width: formItemWidth }"
></n-select>
</n-form-item-grid-item>
</n-form-item-grid-item> -->
<n-form-item-grid-item label="缺陷等级" path="defectLevel">
<n-input
v-model:value="addForm.defectLevel"
@ -161,13 +161,13 @@ const columns: Ref<DataTableColumns<qcDefect.TableList>> = ref([
align: 'center',
minWidth: 100
},
{
title: '缺陷分类',
key: '',
align: 'center',
minWidth: 100,
render: row => row.qcDefectClassification.defectClassificationName
},
// {
// title: '',
// key: '',
// align: 'center',
// minWidth: 100,
// render: row => row.qcDefectClassification.defectClassificationName
// },
{
title: '缺陷等级',
key: 'defectLevel',

@ -46,7 +46,7 @@
style="width: 800px"
>
<n-grid x-gap="12" :cols="2">
<n-form-item-grid-item label="分类" path="detectionName">
<!-- <n-form-item-grid-item label="分类" path="detectionName">
<n-select
v-model:value="addForm.itemTypeId"
placeholder="请选择分类"
@ -55,7 +55,7 @@
:options="defectItemClassifyList"
:style="{ width: formItemWidth }"
></n-select>
</n-form-item-grid-item>
</n-form-item-grid-item> -->
<n-form-item-grid-item label="质检检测项编码" path="detectionCode">
<n-input
v-model:value="addForm.detectionCode"
@ -84,14 +84,14 @@
<n-form-item-grid-item label="是否启用">
<n-switch v-model:value="addForm.enable" :checked-value="'Y'" :unchecked-value="'N'" />
</n-form-item-grid-item>
<n-form-item-grid-item label="填写数据设置" path="attr1">
<!-- <n-form-item-grid-item label="填写数据设置" path="attr1">
<n-input
v-model:value="addForm.attr1"
type="text"
placeholder="请输入填写数据设置"
:style="{ width: formItemWidth }"
/>
</n-form-item-grid-item>
</n-form-item-grid-item> -->
</n-grid>
</n-form>
</div>
@ -115,7 +115,7 @@ import {
editQcInspectionItems,
deleteQcInspectionItems
} from '~/src/service/api/quality/qualityInspectionItem/index';
import { getQClassification } from '~/src/service/api/quality/qualityInspectionClassify/index';
// import { getQClassification } from '~/src/service/api/quality/qualityInspectionClassify/index';
const searchForm = ref<qualityInspectionItem.searchForm>({
detectionCode: '',
detectionName: '',
@ -150,7 +150,7 @@ const requiredList = ref<{ label: string; value: string }[]>([
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]);
const defectItemClassifyList = ref<{ label: string; value: string }[]>([]);
// const defectItemClassifyList = ref<{ label: string; value: string }[]>([]);
const rules = {
detectionCode: createRequiredFormRule('请输入质检检测项编码'),
detectionName: createRequiredFormRule('请输入质检检测项名称'),
@ -167,12 +167,12 @@ const columns: Ref<DataTableColumns<qualityInspectionItem.TableList>> = ref([
align: 'center',
render: (_row, index) => (searchForm.value.pageNum - 1) * searchForm.value.pageSize + index + 1
},
{
title: '分类',
key: 'classificationName',
align: 'center',
render: row => row.qcClassification?.classificationName
},
// {
// title: '',
// key: 'classificationName',
// align: 'center',
// render: row => row.qcClassification?.classificationName
// },
{
title: '质检检测项编码',
key: 'detectionCode',
@ -209,12 +209,12 @@ const columns: Ref<DataTableColumns<qualityInspectionItem.TableList>> = ref([
);
}
},
{
title: '数据填写设置',
key: 'attr1',
align: 'center',
width: 140
},
// {
// title: '',
// key: 'attr1',
// align: 'center',
// width: 140
// },
{
title: '操作',
key: 'actions',
@ -363,18 +363,18 @@ function changeStatus(row: qualityInspectionItem.TableList, val: string): void {
});
}
function getList() {
getQClassification({ pageSize: 999 }).then(res => {
if (res.code === 200) {
res.rows.forEach(item => {
defectItemClassifyList.value.push({
label: item.classificationName,
value: item.id
});
});
}
});
}
// function getList() {
// getQClassification({ pageSize: 999 }).then(res => {
// if (res.code === 200) {
// res.rows.forEach(item => {
// defectItemClassifyList.value.push({
// label: item.classificationName,
// value: item.id
// });
// });
// }
// });
// }
function init() {
startLoading();
@ -388,7 +388,7 @@ function init() {
}
onMounted(() => {
init();
getList();
// getList();
});
</script>

@ -1,149 +1,169 @@
<template>
<div>
<my-card title="搜索条件" search>
<n-form inline>
<n-form-item label="车间">
<n-select
v-model:value="searchForm.location"
placeholder="请选择车间"
:options="locationList"
class="w-160px"
></n-select>
</n-form-item>
<n-form-item>
<component :is="useSearchBtn(search, resetThen)"></component>
</n-form-item>
</n-form>
</my-card>
<n-card :bordered="false" class="h-full rounded-8px shadow-sm">
<n-grid cols="s:1 m:2 l:4" responsive="screen" :x-gap="16" :y-gap="16">
<n-grid-item v-for="item in cardData" :key="item.id">
<gradient-bg class="h-100px" :start-color="item.colors[0]" :end-color="item.colors[1]">
<h3 class="text-16px">{{ item.title }}</h3>
<div class="flex justify-between pt-12px">
<svg-icon :icon="item.icon" class="text-32px" />
<count-to
:prefix="item.unit"
:start-value="1"
:end-value="item.value"
class="text-30px text-white dark:text-dark"
/>
</div>
</gradient-bg>
</n-grid-item>
</n-grid>
<n-divider title-placement="center" style="font-size: 18px; margin: 30px 0">设备信息</n-divider>
<n-grid cols="s:1 m:2 l:4" responsive="screen" :x-gap="16" :y-gap="16">
<n-grid-item v-for="item in deviceDataList" :key="item.code">
<div class="device-card" :class="getStatus(item.status).className">
<div>设备编码 : {{ item.code }}</div>
<div>设备类型 : 开料机</div>
<div>运行状态 : {{ getStatus(item.status).text }}</div>
<div>产品型号 : {{ item.productModel }}</div>
<div>生产产量 :
<count-to
:start-value="1"
:end-value="item.count"
:duration="800"
:autoplay="true"
:use-easing="true"
easing-function="cubicOut"
class="animated-number"
/></div>
<div>生产速率 : <span style="color:yellow">{{item.rate}}</span> /</div>
<div>结束日期 : {{ item.endTime }}</div>
</div>
</n-grid-item>
</n-grid>
</n-card>
</div>
<div>
<my-card title="搜索条件" search>
<n-form inline>
<n-form-item label="车间">
<n-select
v-model:value="searchForm.location"
placeholder="请选择车间"
:options="locationList"
class="w-160px"
></n-select>
</n-form-item>
<n-form-item>
<component :is="useSearchBtn(search, resetThen)"></component>
</n-form-item>
</n-form>
</my-card>
<n-card :bordered="false" class="h-full rounded-8px shadow-sm">
<n-grid cols="s:1 m:2 l:4" responsive="screen" :x-gap="16" :y-gap="16">
<n-grid-item v-for="item in cardData" :key="item.id">
<gradient-bg class="h-100px" :start-color="item.colors[0]" :end-color="item.colors[1]">
<h3 class="text-16px">{{ item.title }}</h3>
<div class="flex justify-between pt-12px">
<svg-icon :icon="item.icon" class="text-32px" />
<count-to
:prefix="item.unit"
:start-value="1"
:end-value="item.value"
class="text-30px text-white dark:text-dark"
/>
</div>
</gradient-bg>
</n-grid-item>
</n-grid>
<n-divider title-placement="center" style="font-size: 18px; margin: 30px 0">设备信息</n-divider>
<n-grid cols="s:1 m:2 l:4" responsive="screen" :x-gap="16" :y-gap="16">
<n-grid-item v-for="item in deviceDataList" :key="item.code">
<div class="device-card" :class="getStatus(item.status).className">
<div>设备编码 : {{ item.code }}</div>
<div>设备类型 : 拼料机</div>
<div>运行状态 : {{ getStatus(item.status).text }}</div>
<div>产品型号 : {{ item.productModel }}</div>
<div>
生产产量 :
<count-to
:start-value="1"
:end-value="item.count"
:duration="800"
:autoplay="true"
:use-easing="true"
easing-function="cubicOut"
class="animated-number"
/>
</div>
<div>
生产速率 :
<span style="color: yellow">{{ item.rate }}</span>
/
</div>
<div>结束日期 : {{ item.endTime }}</div>
</div>
</n-grid-item>
</n-grid>
</n-card>
</div>
</template>
<script setup lang="tsx">
import {ref, onMounted, onUnmounted, reactive} from 'vue';
import { ref, onMounted, onUnmounted, reactive } from 'vue';
import mqtt from 'mqtt';
import {getWorkbenchWiredrawingList} from '@/service/api/md/workbench/wiredrawing';
import {selectAllWorkbenchEnamellingList} from '@/service/api/md/workbench/enamelling';
import {useResetSearch} from '~/src/utils/common/searchReset';
import {useSearchBtn} from '~/src/hooks/common/useBtn';
import {formatDate} from '~/src/utils/form/rule';
import {GradientBg} from './components';
const {searchForm, reset} = useResetSearch({
location: '全部'
import { getWorkbenchWiredrawingList } from '@/service/api/md/workbench/wiredrawing';
import { selectAllWorkbenchEnamellingList } from '@/service/api/md/workbench/enamelling';
import { useResetSearch } from '~/src/utils/common/searchReset';
import { useSearchBtn } from '~/src/hooks/common/useBtn';
import { formatDate } from '~/src/utils/form/rule';
import { GradientBg } from './components';
const { searchForm, reset } = useResetSearch({
location: '全部'
});
const productModels = ['LX25-Y39-002金', 'LX30-Y40-005浅蓝', 'LX35-Z25-006蓝灰', 'LX40-B02-002黑', 'LX30-Y40-005蓝', 'LX35-Z5-004白', 'LX25-A08-007黑'
, 'LX-Y39-030黑', 'LX20-Y30-010灰', 'LX35-Z5-006蓝', 'LX40-B01-003黑', 'LX30-Y42-002蓝', 'LX35-Z15-004单蓝', 'LX25-A08-006灰']; //
const productModels = [
'LX25-Y39-002金',
'LX30-Y40-005浅蓝',
'LX35-Z45-006蓝玳瑁',
'XD40-B02-002黑',
'XD30-Y40-005蓝',
'XD35-Z5-004白',
'XD25-A08-007黑',
'WD-Y39-030黑',
'LX20-Y30-010灰',
'LX35-Z45-006蓝玳瑁',
'XD40-B01-003黑',
'XD30-Y42-002蓝',
'XD35-Z5-004蓝',
'XD25-A08-006灰'
]; //
interface CardData {
id: string;
title: string;
value: number;
unit: string;
colors: [string, string];
icon: string;
id: string;
title: string;
value: number;
unit: string;
colors: [string, string];
icon: string;
}
type device = {
code: string;
status: number;
startTime: string;
count: number;
endTime: string;
process: string;
productModel: string;
timerId?: number;
interval: number;
originalCode: string; //
currentModelIndex: number; //
rate?: String;
code: string;
status: number;
startTime: string;
count: number;
endTime: string;
process: string;
productModel: string;
timerId?: number;
interval: number;
originalCode: string; //
currentModelIndex: number; //
rate?: string;
};
const deviceAllList = ref<Array<device>>([]);
const locationList = ref<Array<{ label: string; value: string }>>([
{
label: '全部',
value: '全部'
}
{
label: '全部',
value: '全部'
}
]);
const deviceDataList = ref<Array<device>>([]);
const cardData = reactive<CardData[]>([
{
id: 'visit',
title: '设备总数',
value: 0,
unit: '',
colors: ['#ec4786', '#b955a4'],
icon: 'ant-design:bar-chart-outlined'
},
{
id: 'amount',
title: '运行中',
value: 40,
unit: '$',
colors: ['#865ec0', '#5144b4'],
icon: 'ant-design:money-collect-outlined'
},
{
id: 'download',
title: '待机',
value: 9,
unit: '',
colors: ['#56cdf3', '#719de3'],
icon: 'carbon:document-download'
},
{
id: 'trade',
title: '故障',
value: 0,
unit: '',
colors: ['#fcbc25', '#f68057'],
icon: 'ant-design:trademark-circle-outlined'
}
{
id: 'visit',
title: '设备总数',
value: 0,
unit: '',
colors: ['#ec4786', '#b955a4'],
icon: 'ant-design:bar-chart-outlined'
},
{
id: 'amount',
title: '运行中',
value: 40,
unit: '$',
colors: ['#865ec0', '#5144b4'],
icon: 'ant-design:money-collect-outlined'
},
{
id: 'download',
title: '待机',
value: 9,
unit: '',
colors: ['#a4a1a1', '#494848'],
icon: 'carbon:document-download'
},
{
id: 'trade',
title: '故障',
value: 0,
unit: '',
colors: ['#fcbc25', '#f68057'],
icon: 'ant-design:trademark-circle-outlined'
}
]);
// MQTT
@ -157,222 +177,240 @@ const clientId = `mqtt_${Math.random().toString(16).slice(3)}`;
//
const options = {
clean: true, //
connectTimeout: 4000, //
reconnectPeriod: 1000, //
clientId
clean: true, //
connectTimeout: 4000, //
reconnectPeriod: 1000, //
clientId
};
const isConnect = false;
const connectToMQTT = () => {
// MQTT broker
if (!isConnect) return;
client = mqtt.connect(mqttBrokerUrl, options);
//
client.on('connect', () => {
client.subscribe(topic, err => {
console.log('topic ==>', topic);
if (err) {
console.error('Failed to subscribe:', err);
} else {
console.log(`Subscribed to topic: ${topic}`);
}
});
});
//
client.on('message', (topic1, message) => {
console.log(topic1);
// Uint8ArraytoString
const data = JSON.parse(message.toString());
console.log('data ==>', data);
});
//
client.on('error', error => {
console.error('MQTT connection error:', error);
});
// MQTT broker
if (!isConnect) return;
client = mqtt.connect(mqttBrokerUrl, options);
//
client.on('connect', () => {
client.subscribe(topic, err => {
console.log('topic ==>', topic);
if (err) {
console.error('Failed to subscribe:', err);
} else {
console.log(`Subscribed to topic: ${topic}`);
}
});
});
//
client.on('message', (topic1, message) => {
console.log(topic1);
// Uint8ArraytoString
const data = JSON.parse(message.toString());
console.log('data ==>', data);
});
//
client.on('error', error => {
console.error('MQTT connection error:', error);
});
};
function getStatus(status: number) {
switch (status) {
case 0:
return {
text: '运行中',
className: 'amount-color'
};
case 1:
return {
text: '待机',
className: 'download-color'
};
case 2:
return {
text: '故障',
className: 'trade-color'
};
default:
return {
text: '运行中',
className: 'amount-color'
};
}
switch (status) {
case 0:
return {
text: '运行中',
className: 'amount-color'
};
case 1:
return {
text: '待机',
className: 'download-color'
};
case 2:
return {
text: '故障',
className: 'trade-color'
};
default:
return {
text: '运行中',
className: 'amount-color'
};
}
}
async function getList() {
await getWorkbenchWiredrawingList({pageSize: 999999}).then(res => {
if (res.code === 200) {
res.rows.forEach(item => {
deviceEach(item);
});
}
});
await selectAllWorkbenchEnamellingList({}).then(res => {
if (res.code === 200) {
res.data.forEach(item => {
deviceEach(item);
});
}
});
cardData[0].value = deviceAllList.value.length;
init();
await getWorkbenchWiredrawingList({ pageSize: 999999 }).then(res => {
if (res.code === 200) {
res.rows.forEach((item, index) => {
let status = 1;
if (index < 10) {
status = 0;
}
deviceEach(item, status);
});
}
});
await selectAllWorkbenchEnamellingList({}).then(res => {
if (res.code === 200) {
res.data.forEach(item => {
deviceEach(item, 1);
});
}
});
cardData[0].value = deviceAllList.value.length;
init();
}
function deviceEach(item: any) {
if (locationList.value.findIndex(ele => ele.value === item.process) === -1) {
locationList.value.push({
label: `${item.process}车间`,
value: item.process
});
}
let interval = Math.floor((16 + Math.random() * 10)) * 1000;
const newDevice = reactive({
code: item.equipmentCode,
status: 0,
productModel: productModels[getRandom(1, 4)],
startTime: formatDate(
new Date(getRandom(new Date().getTime() - 1000 * 60 * 60 * 48, new Date().getTime())),
'yyyy-MM-dd hh:mm:ss'
),
count: getRandom(1, 20),
endTime: formatDate(
new Date(getRandom(new Date().getTime(), new Date().getTime() + 1000 * 60 * 60 * 48)),
'yyyy-MM-dd'
),
process: item.process,
originalCode: item.equipmentCode,
currentModelIndex: 0,
interval: interval, // 16-24
// count: 0,
timerId: undefined,
rate: (60 * 1000 / interval).toFixed(1)
});
startDeviceTimer(newDevice); //
deviceAllList.value.push(newDevice);
function deviceEach(item: any, status: number) {
if (locationList.value.findIndex(ele => ele.value === item.process) === -1) {
locationList.value.push({
label: `${item.process}车间`,
value: item.process
});
}
const interval = Math.floor(16 + Math.random() * 10) * 1000;
if (status === 1) {
deviceAllList.value.push({
code: item.equipmentCode,
status: 1,
startTime: '',
count: 0,
endTime: '',
process: item.process,
productModel: productModels[getRandom(1, 4)],
interval: 0,
originalCode: '', //
currentModelIndex: 0, //
rate: '0'
});
return;
}
const newDevice = reactive({
code: item.equipmentCode,
status,
productModel: productModels[getRandom(1, 4)],
startTime: formatDate(
new Date(getRandom(new Date().getTime() - 1000 * 60 * 60 * 48, new Date().getTime())),
'yyyy-MM-dd hh:mm:ss'
),
count: getRandom(1, 20),
endTime: formatDate(
new Date(getRandom(new Date().getTime(), new Date().getTime() + 1000 * 60 * 60 * 48)),
'yyyy-MM-dd'
),
process: item.process,
originalCode: item.equipmentCode,
currentModelIndex: 0,
interval, // 16-24
// count: 0,
timerId: undefined,
rate: ((60 * 1000) / interval).toFixed(1)
});
startDeviceTimer(newDevice); //
deviceAllList.value.push(newDevice);
}
//
function startDeviceTimer(device: device) {
device.timerId = window.setInterval(() => {
device.count++;
if (device.count >= 200) {
resetDeviceProduction(device);
}
}, device.interval); // 20
device.timerId = window.setInterval(() => {
device.count++;
if (device.count >= 200) {
resetDeviceProduction(device);
}
}, device.interval); // 20
}
//
function resetDeviceProduction(device: device) {
device.count = 0;
device.currentModelIndex = (device.currentModelIndex + 1) % productModels.length;
device.productModel = productModels[device.currentModelIndex];
clearInterval(device.timerId);
device.interval = Math.floor((15 + Math.random() * 10)) * 1000; //
device.rate = (60 * 1000 / device.interval).toFixed(1);
startDeviceTimer(device);
device.count = 0;
device.currentModelIndex = (device.currentModelIndex + 1) % productModels.length;
device.productModel = productModels[device.currentModelIndex];
clearInterval(device.timerId);
device.interval = Math.floor(15 + Math.random() * 10) * 1000; //
device.rate = ((60 * 1000) / device.interval).toFixed(1);
startDeviceTimer(device);
}
function getRandom(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1) + min);
return Math.floor(Math.random() * (max - min + 1) + min);
}
function search() {
init();
init();
}
function resetThen() {
reset();
init();
reset();
init();
}
function init() {
if (!searchForm.value.location) {
deviceDataList.value = [];
return;
}
if (searchForm.value.location === '全部') {
deviceDataList.value = deviceAllList.value.map(item => item);
return;
}
deviceDataList.value = deviceAllList.value.filter(item => item.process === searchForm.value.location);
if (!searchForm.value.location) {
deviceDataList.value = [];
return;
}
if (searchForm.value.location === '全部') {
deviceDataList.value = deviceAllList.value.map(item => item);
return;
}
deviceDataList.value = deviceAllList.value.filter(item => item.process === searchForm.value.location);
}
//
let intervalId: number;
// let intervalId: number;
// MQTT
onMounted(() => {
connectToMQTT();
init();
getList();
connectToMQTT();
init();
getList();
});
// MQTT
onUnmounted(() => {
deviceAllList.value.forEach(device => {
if (device.timerId) clearInterval(device.timerId);
});
if (client) {
client.end();
}
deviceAllList.value.forEach(device => {
if (device.timerId) clearInterval(device.timerId);
});
if (client) {
client.end();
}
});
</script>
<style scoped>
.device-card {
color: #fff;
border-radius: 8px;
padding: 10px;
box-sizing: border-box;
font-size: 16px;
color: #fff;
border-radius: 8px;
padding: 10px;
box-sizing: border-box;
font-size: 16px;
}
.amount-color {
background: linear-gradient(45deg, #865ec0, #5144b4);
background: linear-gradient(45deg, #865ec0, #5144b4);
}
.download-color {
background: linear-gradient(45deg, #56cdf3, #719de3);
background: linear-gradient(45deg, #a4a1a1, #494848);
}
.trade-color {
background: linear-gradient(45deg, #fcbc25, #f68057);
background: linear-gradient(45deg, #fcbc25, #f68057);
}
/* 添加数字变化动画 */
.flip-animation {
transition: transform 0.5s;
transition: transform 0.5s;
}
.flip-animation-up {
transform: translateY(-20px);
opacity: 0;
transform: translateY(-20px);
opacity: 0;
}
.flip-animation-down {
transform: translateY(20px);
opacity: 0;
transform: translateY(20px);
opacity: 0;
}
</style>

@ -22,12 +22,12 @@
<n-input v-model:value="formValue.batchCode" placeholder="请输入库批次号" />
</n-form-item>
<!-- <n-form-item label="仓库名称" path="Item.warehouseName" :label-style="labelStyle">
<n-input v-model:value="formValue.warehouseName" placeholder="请输入仓库名称" />
</n-form-item> -->
<n-input v-model:value="formValue.warehouseName" placeholder="请输入仓库名称" />
</n-form-item> -->
<!-- <n-form-item label="入库日期" path="Item.recptDate" :label-style="labelStyle">
<n-date-picker v-model:value="formValue.recptDate" type="date" :format="format" />
</n-form-item> -->
<n-date-picker v-model:value="formValue.recptDate" type="date" :format="format" />
</n-form-item> -->
<n-form-item label="仓库名称">
<n-select
v-model:value="formValue.warehouseId"
@ -152,13 +152,13 @@
import {
ref,
reactive,
// h,
// h,
onMounted
} from 'vue';
import type { FormInst, DataTableColumns } from 'naive-ui';
import {
useMessage,
// NTag,
// NTag,
useDialog
} from 'naive-ui';
import { useLoading } from '@/hooks';
@ -329,7 +329,10 @@ const columns: DataTableColumns<ApiMaterialStockManagement.materialStock> = [
title: '单位',
key: 'unitOfMeasure',
align: 'center',
width: 120
width: 120,
render: row => {
return getUnitOfMeasure(row);
}
},
// {
// title: '',
@ -474,6 +477,19 @@ const detailColumns: DataTableColumns<ApiMaterialStockManagement.materialStock>
}
];
function getUnitOfMeasure(row: ApiMaterialStockManagement.materialStock) {
switch (row.warehouseName) {
case '车间仓':
return '个';
case '原料仓':
return '个';
case '辅料仓':
return '个';
default:
return '付';
}
}
function handleEdit(row: ApiMaterialStockManagement.materialStock) {
handleEditShow.value = true;
handleEditRow.value = JSON.parse(JSON.stringify(row));

@ -110,12 +110,12 @@ const columns: Ref<DataTableColumns<any>> = ref([
align: 'center',
width: 80
},
{
title: '轴编号',
key: 'axisNumber',
align: 'center',
width: 100
},
// {
// title: '',
// key: 'axisNumber',
// align: 'center',
// width: 100
// },
{
title: '箱毛重',
key: 'boxGrossWeight',

@ -232,12 +232,12 @@ const columns: Ref<DataTableColumns<DataType>> = ref([
align: 'center',
width: 100
},
{
title: '净重',
key: 'weight',
align: 'center',
width: 100
},
// {
// title: '',
// key: 'weight',
// align: 'center',
// width: 100
// },
{
title: '单位',
key: 'unitOfMeasure',

@ -160,12 +160,12 @@ const columns: Ref<DataTableColumns<DataType>> = ref([
width: 100,
key: 'equipmentCode'
},
{
title: '位置',
align: 'center',
width: 100,
key: 'attr1'
},
// {
// title: '',
// align: 'center',
// width: 100,
// key: 'attr1'
// },
{
title: '产品编号',
align: 'center',

Loading…
Cancel
Save