init(projects): 整体修改

master
xushilin 11 months ago
parent 3bd002c96f
commit 622f68e4da

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

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

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

@ -96,21 +96,57 @@ const columns: Ref<DataTableColumns<drawingProcessCheckRecord.TableList>> = ref(
width: 70, width: 70,
render: (_row, index) => (searchForm.value.pageNum - 1) * searchForm.value.pageSize + index + 1 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: '工单类型', title: '是否合格',
key: 'workOrdeType', key: 'qualifiedOrNot',
align: 'center', align: 'center',
width: 100, 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 => { 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: '机台', title: '机台',
key: 'deviceName', key: 'deviceName',
@ -134,20 +170,11 @@ const columns: Ref<DataTableColumns<drawingProcessCheckRecord.TableList>> = ref(
tooltip: true tooltip: true
} }
}, },
// {
// title: '',
// key: 'clientName',
// align: 'center',
// width: 140,
// ellipsis: {
// tooltip: true
// }
// },
{ {
title: '生产工单号', title: '生产工单号',
key: 'generateWorkOrderNumber', key: 'generateWorkOrderNumber',
align: 'center', align: 'center',
width: 100, width: 180,
ellipsis: { ellipsis: {
tooltip: true tooltip: true
} }
@ -156,14 +183,14 @@ const columns: Ref<DataTableColumns<drawingProcessCheckRecord.TableList>> = ref(
title: '产品规格', title: '产品规格',
key: 'productSpecifications', key: 'productSpecifications',
align: 'center', align: 'center',
width: 100 width: 160
},
{
title: '数量',
key: 'weight',
align: 'center',
width: 100
}, },
// {
// title: '',
// key: 'weight',
// align: 'center',
// width: 100
// },
{ {
title: '单位', title: '单位',
key: 'measure', key: 'measure',
@ -174,49 +201,13 @@ const columns: Ref<DataTableColumns<drawingProcessCheckRecord.TableList>> = ref(
title: '批号', title: '批号',
key: 'batchNumber', key: 'batchNumber',
align: 'center', align: 'center',
width: 100 width: 180
}, },
{ {
title: '日期', title: '日期',
key: 'createTime', key: 'createTime',
align: 'center', align: 'center',
width: 180 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, width: 70,
render: (_row, index) => (searchForm.value.pageNum - 1) * searchForm.value.pageSize + index + 1 render: (_row, index) => (searchForm.value.pageNum - 1) * searchForm.value.pageSize + index + 1
}, },
{ // {
title: '工单类型', // title: '',
key: 'workOrdeType', // key: 'workOrdeType',
align: 'center', // align: 'center',
width: 100, // width: 100,
render: row => { // render: row => {
return row.workOrdeType === '0' ? '金属' : '板材'; // return row.workOrdeType === '0' ? '' : '';
} // }
}, // },
{ {
title: '机台', title: '机台',
key: 'deviceName', key: 'deviceName',
align: 'center', align: 'center',
width: 100 width: 100
}, },
{ // {
title: '轴号', // title: '',
key: 'axisNumber', // key: 'axisNumber',
align: 'center', // align: 'center',
width: 100 // width: 100
}, // },
{ {
title: '订单类型', title: '订单类型',
key: 'orderType', key: 'orderType',
@ -194,20 +194,20 @@ const columns: Ref<DataTableColumns<enamellingProcessCheckRecord.TableList>> = r
tooltip: true tooltip: true
} }
}, },
{ // {
title: '料号', // title: '',
key: 'partNumber', // key: 'partNumber',
align: 'center', // align: 'center',
width: 140, // width: 140,
ellipsis: { // ellipsis: {
tooltip: true // tooltip: true
} // }
}, // },
{ {
title: '批号', title: '批号',
key: 'batchNumber', key: 'batchNumber',
align: 'center', align: 'center',
width: 140 width: 180
}, },
{ {
title: '生产工单号', title: '生产工单号',
@ -222,13 +222,13 @@ const columns: Ref<DataTableColumns<enamellingProcessCheckRecord.TableList>> = r
title: '产品型号', title: '产品型号',
key: 'productModel', key: 'productModel',
align: 'center', align: 'center',
width: 100 width: 160
}, },
{ {
title: '产品规格', title: '产品规格',
key: 'productSpecifications', key: 'productSpecifications',
align: 'center', align: 'center',
width: 100 width: 160
}, },
{ {
title: '日期', title: '日期',
@ -238,10 +238,16 @@ const columns: Ref<DataTableColumns<enamellingProcessCheckRecord.TableList>> = r
}, },
{ {
title: '质检人', title: '质检人',
key: 'qualityInspector', key: 'createBy',
align: 'center', align: 'center',
width: 100 width: 100
}, },
{
title: '检测项',
key: 'attr2',
align: 'center',
width: 180
},
{ {
title: '是否合格', title: '是否合格',
key: 'qualifiedOrNot', key: 'qualifiedOrNot',

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

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

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

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

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

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

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

Loading…
Cancel
Save