Browse Source

rebase 冲突

feature/three
LiLongLong 3 months ago
parent
commit
3348fbc752
  1. 12
      src/libs/socket.ts
  2. 4
      src/router/routes.ts
  3. 51
      src/views/craft/AddCraftDialog.vue
  4. 132
      src/views/craft/CraftStatus.vue
  5. 9
      src/views/craft/TransferRight.vue
  6. 35
      src/views/craft/craftType.ts
  7. 21
      src/views/craft/index.vue

12
src/libs/socket.ts

@ -144,12 +144,12 @@ export const socket: socket = {
if (socket.is_reconnect) { if (socket.is_reconnect) {
socket.reconnect_timer = setTimeout(() => { socket.reconnect_timer = setTimeout(() => {
// 超过重连次数 // 超过重连次数
// if (socket.reconnect_current > socket.reconnect_count) {
// clearTimeout(socket.reconnect_timer);
// socket.is_reconnect = false;
// console.error('超出重连次数,不再重连', new Date());
// return;
// }
if (socket.reconnect_current > socket.reconnect_count) {
clearTimeout(socket.reconnect_timer)
socket.is_reconnect = false
console.error('超出重连次数,不再重连', new Date())
return
}
// 记录重连次数 // 记录重连次数
socket.reconnect_current++ socket.reconnect_current++
socket.reconnect() socket.reconnect()

4
src/router/routes.ts

@ -78,10 +78,10 @@ const authRoutes: RouteRecordRaw[] = [
{ {
path: '/ore', path: '/ore',
name: 'ore', name: 'ore',
component: () => import('views/home/index.vue'),
component: () => import('views/craft/index.vue'),
meta: { meta: {
isDefault: true, isDefault: true,
title: '矿石管理',
title: '工艺管理',
icon: n_ore, icon: n_ore,
activeIcon: s_ore, activeIcon: s_ore,
}, },

51
src/views/craft/AddCraftDialog.vue

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Craft, StepCmd, StepStruct, TransferRightType } from './craftType'
import type { Craft, StepCmd, StepStruct, TubeSolStruct } from './craftType'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { ref } from 'vue' import { ref } from 'vue'
import { StepCmdDescMap } from './craftType' import { StepCmdDescMap } from './craftType'
@ -13,7 +13,6 @@ const emit = defineEmits<{
const visible = ref(false) const visible = ref(false)
const stepStructs = ref<StepStruct[]>([]) const stepStructs = ref<StepStruct[]>([])
const craftObj = ref<Craft>({}) const craftObj = ref<Craft>({})
const transferRight = ref<TransferRightType | null>(null)
const stepCmds: StepCmd[] = [ const stepCmds: StepCmd[] = [
// 'upTray', // 'upTray',
@ -38,11 +37,23 @@ const closeDialog = () => {
} }
const editDialog = (craftInfo: Craft) => { const editDialog = (craftInfo: Craft) => {
console.log('craftInfo---', craftInfo)
craftObj.value = { ...craftInfo } craftObj.value = { ...craftInfo }
if (craftInfo && craftInfo.steps) { if (craftInfo && craftInfo.steps) {
const step = JSON.parse(craftInfo.steps) const step = JSON.parse(craftInfo.steps)
console.log('step---', step)
/* eslint-disable no-debugger */
if (step && step.length) {
step.forEach((item: StepStruct) => {
if (item.method === 'addLiquid') {
const list = item.params.tubeSolList
if (list && list.length === 16 && item.params.tubeSolList) {
item.params.tubeSolList = [{
tubeNum: 0,
addLiquidList: item.params.tubeSolList[0].addLiquidList,
}]
}
}
})
}
stepStructs.value = step stepStructs.value = step
} }
openDialog() openDialog()
@ -53,8 +64,28 @@ function onConfirm() {
ElMessage.warning('请输入工艺名称') ElMessage.warning('请输入工艺名称')
return return
} }
for (const step of stepStructs.value) {
if (step.method === 'addLiquid') {
const list = step.params.tubeSolList
if (list && list.length) {
list.forEach((item) => {
const tubeNum = item.tubeNum
if (tubeNum === 0) {
const tubeSolList: TubeSolStruct[] = []
for (let index = 0; index < 16; index++) {
tubeSolList.push({
tubeNum: index + 1,
addLiquidList: item.addLiquidList,
})
}
step.params.tubeSolList = tubeSolList
}
})
}
}
}
craftObj.value.steps = JSON.stringify(stepStructs.value) craftObj.value.steps = JSON.stringify(stepStructs.value)
console.log('craftObj-22--', craftObj.value)
emit('ok', craftObj.value) emit('ok', craftObj.value)
} }
@ -65,7 +96,7 @@ function addStep(step: StepCmd) {
method: step, method: step,
params: { params: {
tubeSolList: [{ tubeSolList: [{
tubeNum: 1,
tubeNum: 0,
addLiquidList: [{ addLiquidList: [{
solId: 1, solId: 1,
volume: 10, volume: 10,
@ -112,10 +143,6 @@ function onStepItemDel(order: number) {
function transferChange(stepData: StepStruct, order: number) { function transferChange(stepData: StepStruct, order: number) {
console.log('order === ', stepStructs.value, stepData, order) console.log('order === ', stepStructs.value, stepData, order)
// if (order) {
// stepStructs.value[order - 1] = stepData
// }
// console.log('stepStructs.value==1===', stepStructs.value)
} }
defineExpose({ defineExpose({
@ -126,7 +153,7 @@ defineExpose({
</script> </script>
<template> <template>
<el-dialog v-model="visible" title="添加工艺" style="width:70vw; height:65vh">
<el-dialog v-model="visible" title="添加工艺" style="width:70vw; height:70vh">
<div> <div>
<div class="mt-5 mb-8 flex items-center"> <div class="mt-5 mb-8 flex items-center">
<label class="font-medium mr-4">工艺名称</label> <label class="font-medium mr-4">工艺名称</label>
@ -152,7 +179,7 @@ defineExpose({
<TransferLeft v-for="cmd in stepCmds" :key="cmd" :title="StepCmdDescMap[cmd]" @click="addStep(cmd)" /> <TransferLeft v-for="cmd in stepCmds" :key="cmd" :title="StepCmdDescMap[cmd]" @click="addStep(cmd)" />
</div> </div>
<div v-if="stepStructs && stepStructs.length" class="transfer-right"> <div v-if="stepStructs && stepStructs.length" class="transfer-right">
<TransferRight v-for="(step, idx) in stepStructs" ref="transferRight" :key="idx" :order="idx + 1" :step="step" @del="onStepItemDel" @transfer-change="transferChange" />
<TransferRight v-for="(step, idx) in stepStructs" :key="idx" :order="idx + 1" :step="step" type="add" @del="onStepItemDel" @transfer-change="transferChange" />
</div> </div>
<div v-else> <div v-else>
<el-empty description="description"> <el-empty description="description">

132
src/views/craft/CraftStatus.vue

@ -1,14 +1,50 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { CraftState } from './craftType'
import { craftstatus } from '@/apis/crafts' import { craftstatus } from '@/apis/crafts'
import { ref } from 'vue' import { ref } from 'vue'
import TransferRight from './TransferRight.vue'
const statusVisible = ref(false) const statusVisible = ref(false)
const intervalTimes = ref() const intervalTimes = ref()
const stateList: any = ref([])
const craftValue = ref()
const craftList = ref<CraftState[]>([])
const stateMap: any = {
RUNNING: '执行中',
FINISHED: '执行完成',
}
const queryCraftStatus = () => { const queryCraftStatus = () => {
intervalTimes.value = setInterval(() => { intervalTimes.value = setInterval(() => {
craftstatus().then((res) => { craftstatus().then((res) => {
console.log('res====', res)
const craftStateList: CraftState[] = res
const uniqueData: CraftState[] = []
const idMap: any = {}
res.forEach((item: CraftState) => {
const craftsId = item.craftsId
if (!idMap[craftsId]) {
idMap[craftsId] = true
uniqueData.push(item)
}
})
craftList.value = uniqueData
if (uniqueData.length) {
const craftsId = uniqueData[0].craftsId
craftValue.value = craftsId
onSelectChange(craftsId)
}
stateList.value.push(...uniqueData)
if (craftStateList && craftStateList.length) {
const finishedList = []
uniqueData.forEach((item) => {
const state = item.state
if (state === 'FINISHED') {
finishedList.push(state)
}
})
if (finishedList.length === uniqueData.length) {
clearInterval(intervalTimes.value)
}
}
}) })
}, 1000) }, 1000)
} }
@ -18,16 +54,100 @@ const showDialog = () => {
queryCraftStatus() queryCraftStatus()
} }
const onCloseDialog = () => {
stateList.value = []
}
const currentSteps = ref()
const onSelectChange = (value: string | number) => {
const list = craftList.value.filter(item => item.craftsId === value)
list.forEach((item) => {
const steps = item.steps
currentSteps.value = item.steps
steps.forEach((item) => {
if (item.method === 'addLiquid') {
const list = item.params.tubeSolList
if (list && list.length === 16 && item.params.tubeSolList) {
item.params.tubeSolList = [{
tubeNum: 0,
addLiquidList: item.params.tubeSolList[0].addLiquidList,
}]
}
}
})
})
}
defineExpose({ defineExpose({
showDialog, showDialog,
}) })
</script> </script>
<template> <template>
<el-dialog v-model="statusVisible">
<div>
<div></div>
<div></div>
<el-dialog v-model="statusVisible" style="width:80vw; height:60vh" :close-on-click-modal="false" @close="onCloseDialog">
<div class="state-container">
<div class="item1">
<div class="state-left" style="width:40vw">
<div>工艺列表</div>
<div style="margin-left:10px">
<el-select v-model="craftValue" style="width: 100px" size="small" placeholder="请选择" @change="onSelectChange">
<el-option v-for="item in craftList" :key="item.craftsId" :label="item.craftsName" :value="item.craftsId" />
</el-select>
</div>
</div>
<div class="state-log">
<TransferRight v-for="(step, idx) in currentSteps" :key="idx" :order="idx + 1" :step="step" type="showlog" @del="() => {}" @transfer-change="() => {}" />
</div>
</div>
<div class="item2">
<div>工艺执行状态</div>
<div class="state-log">
<div v-for="item in stateList" :key="item.state">
<span class="state-span"><label class="state-log-label">矿石名称</label><span class="state-log-text">{{ item.oresName }}</span></span>
<span class="state-span"><label class="state-log-label">工艺名称</label><span class="state-log-text">{{ item.craftsName }}</span></span>
<span class="state-span"><label class="state-log-label">加热区</label><span class="state-log-text">{{ item.heatId }}</span></span>
<span class="state-span"><label class="state-log-label">执行状态</label><span class="state-log-text">{{ stateMap[item.state] }}</span></span>
</div>
</div>
</div>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
<style lang="scss" scoped>
.state-container{
display: grid;
grid-template-columns: repeat(3, 1fr);
.state-left{
display: flex;
justify-content: center;
}
.item1 {
grid-column: 1 / 2;
}
.item2 {
grid-column: 2 / 4;
}
}
.state-log{
height: 50vh;
max-height: 50vh;
overflow: auto;
padding: 20px;
}
.state-span{
padding-left: 10px;
}
.state-log-label{
font-weight: 600;
font-size: .875rem;
}
.state-log-text{
font-size: .875rem;
}
.el-select-dropdown__item{
display: flex;
align-items: center;
height: 15px;
}
</style>

9
src/views/craft/TransferRight.vue

@ -7,6 +7,7 @@ import { StepCmdDescMap, tubeSolList } from './craftType'
const props = defineProps<{ const props = defineProps<{
order: number order: number
step: StepStruct step: StepStruct
type: string
}>() }>()
const $emit = defineEmits<{ const $emit = defineEmits<{
@ -37,22 +38,22 @@ watch(stepInfo, (newVal) => {
<section class="right-main"> <section class="right-main">
<span class="right-seq">{{ order }}</span> <span class="right-seq">{{ order }}</span>
<span class="right-base">{{ StepCmdDescMap[stepInfo.method] }}</span> <span class="right-base">{{ StepCmdDescMap[stepInfo.method] }}</span>
<div class="text-item" @click="$emit('del', order)">
<div v-if="type !== 'showlog'" class="text-item" @click="$emit('del', order)">
<img class="item-img" src="@/assets/images/icon_del_s.svg" alt="del"> <img class="item-img" src="@/assets/images/icon_del_s.svg" alt="del">
</div> </div>
</section> </section>
<template v-if="stepInfo.method !== 'takePhoto'"> <template v-if="stepInfo.method !== 'takePhoto'">
<section v-if="stepInfo.method === 'addLiquid'" class="right-liquid right-base"> <section v-if="stepInfo.method === 'addLiquid'" class="right-liquid right-base">
<div v-for="(tubeItem, index) in stepInfo.params.tubeSolList" :key="index" class="right-liquid"> <div v-for="(tubeItem, index) in stepInfo.params.tubeSolList" :key="index" class="right-liquid">
<el-select v-model="tubeItem.tubeNum" size="small" placeholder="Select" style="width: 100px" class="right-base">
<el-select v-model="tubeItem.tubeNum" size="small" placeholder="请选择" style="width: 120px" class="right-base" :disabled="type === 'showlog'">
<el-option v-for="item in tubeSolList" :key="item.id" :label="item.name" :value="item.id" /> <el-option v-for="item in tubeSolList" :key="item.id" :label="item.name" :value="item.id" />
</el-select> </el-select>
<div v-for="(liquidItem, liquidIndex) in tubeItem.addLiquidList" :key="liquidIndex" class="right-liquid right-base"> <div v-for="(liquidItem, liquidIndex) in tubeItem.addLiquidList" :key="liquidIndex" class="right-liquid right-base">
<el-select v-model="liquidItem.solId" size="small" placeholder="Select" style="width: 100px" class="right-base">
<el-select v-model="liquidItem.solId" size="small" placeholder="请选择" style="width: 100px" class="right-base" :disabled="type === 'showlog'">
<el-option v-for="item in liquidStore.liquids" :key="item.id" :label="item.name" :value="item.id" /> <el-option v-for="item in liquidStore.liquids" :key="item.id" :label="item.name" :value="item.id" />
</el-select> </el-select>
<div> <div>
<el-input v-model.number="liquidItem.volume" size="small" style="width: 100px" />
<el-input v-model.number="liquidItem.volume" size="small" style="width: 100px" :disabled="type === 'showlog'" />
<span class="ml-2">ml</span> <span class="ml-2">ml</span>
</div> </div>
</div> </div>

35
src/views/craft/craftType.ts

@ -105,10 +105,35 @@ export interface Craft {
oresId?: number oresId?: number
} }
const list = [] const list = []
for (let i = 0; i < 16; i++) {
list.push({
id: i + 1,
name: `${i + 1}号试管`,
})
for (let i = 0; i < 17; i++) {
let tubeInfo = {
id: 0,
name: '全部试管',
}
if (i === 0) {
tubeInfo = {
id: 0,
name: '全部试管',
}
}
else {
tubeInfo = {
id: i,
name: `${i}号试管`,
}
}
list.push(tubeInfo)
} }
export const tubeSolList = list export const tubeSolList = list
export interface CraftState {
craftsId: number
craftsName: string
currentIndex: number
heatId: string
oresId: number
oresName: string
state: string
steps: StepStruct[]
}

21
src/views/craft/index.vue

@ -34,6 +34,10 @@ const onAddCraft = () => {
} }
const onEditCraft = () => { const onEditCraft = () => {
if (multipleSelection.value && multipleSelection.value.length !== 1) {
ElMessage.warning('请选择一条数据进行编辑')
return
}
if (addCraftRef.value && multipleSelection.value) { if (addCraftRef.value && multipleSelection.value) {
addCraftRef.value.editDialog(multipleSelection.value[0]) addCraftRef.value.editDialog(multipleSelection.value[0])
} }
@ -41,7 +45,6 @@ const onEditCraft = () => {
const handleSelectionChange = (rows: Craft[]) => { const handleSelectionChange = (rows: Craft[]) => {
if (rows && rows.length) { if (rows && rows.length) {
console.log('rows---', rows)
multipleSelection.value = rows multipleSelection.value = rows
} }
} }
@ -79,8 +82,11 @@ const onSelectHeatId = () => {
heatVisible.value = true heatVisible.value = true
} }
const onShowState = () => {
craftStatusRef.value?.showDialog()
}
const confirmCraftEdit = (craft: Craft) => { const confirmCraftEdit = (craft: Craft) => {
// const req = createCraft({ name: craft.name, steps: craft.steps, oresId })
let req let req
if (craft.id) { if (craft.id) {
req = updateCraft(craft) req = updateCraft(craft)
@ -142,8 +148,11 @@ const onStart = () => {
<el-button type="primary" size="small" @click="onSelectHeatId"> <el-button type="primary" size="small" @click="onSelectHeatId">
执行工艺 执行工艺
</el-button> </el-button>
<el-button type="primary" size="small" @click="onShowState">
查看工艺步骤
</el-button>
</section> </section>
<main>
<main class="craft-main">
<el-table :data="tableData" style="width: 100%" size="small" @selection-change="handleSelectionChange"> <el-table :data="tableData" style="width: 100%" size="small" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" :selectable="selectable" /> <el-table-column type="selection" width="55" :selectable="selectable" />
<el-table-column prop="name" label="工艺名称" /> <el-table-column prop="name" label="工艺名称" />
@ -175,3 +184,9 @@ const onStart = () => {
<CraftStatus ref="craftStatusRef" /> <CraftStatus ref="craftStatusRef" />
</div> </div>
</template> </template>
<style lang="scss" scoped>
.craft-main{
margin-top: 20px;
}
</style>
Loading…
Cancel
Save