9 changed files with 384 additions and 53 deletions
-
19src/components/check/index.vue
-
194src/components/container/Item/index.vue
-
73src/components/home/FillSolution/index.vue
-
1src/libs/utils.ts
-
1src/types/container.d.ts
-
13src/views/container/index.vue
-
60src/views/container/liquidItem.vue
-
40src/views/debug/index.vue
-
14src/views/home/index.vue
@ -0,0 +1,194 @@ |
|||||
|
<script setup lang="ts"> |
||||
|
import { getSolsList } from 'apis/solution' |
||||
|
import { useSolutionStore } from 'stores/useSolutionStore' |
||||
|
import { computed, onMounted, ref, watch } from 'vue' |
||||
|
|
||||
|
const props = defineProps({ |
||||
|
container: { |
||||
|
type: Object, |
||||
|
default: () => ({}), |
||||
|
}, |
||||
|
}) |
||||
|
console.log(props.container) |
||||
|
onMounted(() => { |
||||
|
querySolutionList() |
||||
|
}) |
||||
|
const solutionList = ref<Solution.SolutionItem[]>([]) |
||||
|
const solutionStore = useSolutionStore() |
||||
|
const querySolutionList = async () => { |
||||
|
const res = await getSolsList() |
||||
|
if (res && res.list) { |
||||
|
solutionList.value = res.list |
||||
|
solutionStore.updateSolution(res.list) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const form = ref(props.container) |
||||
|
|
||||
|
const reloadKey = ref(1) |
||||
|
watch(() => form.value, () => { |
||||
|
reloadKey.value++ |
||||
|
}, { deep: true }) |
||||
|
|
||||
|
watch(() => props, () => { |
||||
|
reloadKey.value++ |
||||
|
}, { deep: true }) |
||||
|
|
||||
|
const svgText = computed(() => { |
||||
|
const percent = Math.round(((props.container.capacityTotal - props.container.capacityUsed) / props.container.capacityTotal) * 100) |
||||
|
return `<svg |
||||
|
:key="reloadKey" |
||||
|
xmlns="http://www.w3.org/2000/svg" |
||||
|
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
|
fill="none" |
||||
|
version="1.1" |
||||
|
width="162.44374084472656" |
||||
|
height="227.99989318847656" |
||||
|
viewBox="0 0 162.44374084472656 227.99989318847656" |
||||
|
> |
||||
|
<defs> |
||||
|
<clipPath id="bottle-clip"> |
||||
|
<path |
||||
|
d="M0,54.0618L0,64.2474C0,65.1128,0.699314,65.8144,1.56196,65.8144C2.4246,65.8144,3.12392,66.516,3.12392,67.3814L3.12392,73.6495C3.12392,74.5149,2.4246,75.2165,1.56196,75.2165C0.699314,75.2165,0,75.918,0,76.7835L0,90.8866C0,91.752,0.699314,92.4536,1.56196,92.4536C2.4246,92.4536,3.12392,93.1551,3.12392,94.0206L3.12392,100.289C3.12392,101.154,2.4246,101.856,1.56196,101.856C0.699314,101.856,0,102.557,0,103.423L0,122.227C0,123.092,0.699314,123.794,1.56196,123.794C2.4246,123.794,3.12392,124.495,3.12392,125.361L3.12392,131.629C3.12392,132.494,2.4246,133.196,1.56196,133.196C0.699314,133.196,0,133.897,0,134.763L0,153.567C0,154.432,0.699314,155.134,1.56196,155.134C2.4246,155.134,3.12392,155.836,3.12392,156.701L3.12392,162.969C3.12392,163.834,2.4246,164.536,1.56196,164.536C0.699314,164.536,0,165.238,0,166.103L0,183.34C0,184.206,0.699314,184.907,1.56196,184.907C2.4246,184.907,3.12392,185.609,3.12392,186.474L3.12392,193.526C3.12392,194.391,2.4246,195.093,1.56196,195.093C0.699314,195.093,0,195.794,0,196.66L0,206.062C0,218.178,9.79038,228,21.8674,228L140.576,228C152.653,228,162.444,218.178,162.444,206.062L162.444,196.66C162.444,195.794,161.744,195.093,160.882,195.093C160.019,195.093,159.32,194.391,159.32,193.526L159.32,186.474C159.32,185.609,160.019,184.907,160.882,184.907C161.744,184.907,162.444,184.206,162.444,183.34L162.444,166.103C162.444,165.238,161.744,164.536,160.882,164.536C160.019,164.536,159.32,163.834,159.32,162.969L159.32,156.701C159.32,155.836,160.019,155.134,160.882,155.134C161.744,155.134,162.444,154.432,162.444,153.567L162.444,134.763C162.444,133.897,161.744,133.196,160.882,133.196C160.019,133.196,159.32,132.494,159.32,131.629L159.32,125.361C159.32,124.495,160.019,123.794,160.882,123.794C161.744,123.794,162.444,123.092,162.444,122.227L162.444,103.423C162.444,102.557,161.744,101.856,160.882,101.856C160.019,101.856,159.32,101.154,159.32,100.289L159.32,94.0206C159.32,93.1551,160.019,92.4536,160.882,92.4536C161.744,92.4536,162.444,91.752,162.444,90.8866L162.444,76.7835C162.444,75.918,161.744,75.2165,160.882,75.2165C160.019,75.2165,159.32,74.5149,159.32,73.6495L159.32,67.3814C159.32,66.516,160.019,65.8144,160.882,65.8144C161.744,65.8144,162.444,65.1128,162.444,64.2474L162.444,54.0618C162.444,41.9457,152.653,32.1237,140.576,32.1237L134.962,32.1237C132.711,32.1237,131.583,29.3931,133.175,27.7961C137.914,23.042,140.576,16.594,140.576,9.87062L140.576,4.70103C140.576,2.10472,138.478,0,135.89,0L26.5533,0C23.9654,0,21.8674,2.10472,21.8674,4.70103L21.8674,9.87062C21.8674,16.594,24.5297,23.042,29.2685,27.7961C30.8603,29.3931,29.7329,32.1237,27.4817,32.1237L21.8674,32.1237C9.79038,32.1237,0,41.9457,0,54.0618Z" |
||||
|
fill="#EEEFF8" |
||||
|
fill-opacity="1" |
||||
|
/> |
||||
|
<use xlink:href="#bottle" /> |
||||
|
</clipPath> |
||||
|
<!-- 定义渐变背景(垂直方向,从上到下填充) --> |
||||
|
<linearGradient id="fill-gradient" x1="0%" y1="0%" x2="0%" y2="100%"> |
||||
|
<stop offset="${percent}%" stop-color="#EEEFF8" /> |
||||
|
<stop offset="${percent}%" stop-color="red" /> |
||||
|
<stop offset="100%" stop-color="red" /> |
||||
|
</linearGradient> |
||||
|
</defs> |
||||
|
<rect width="100%" height="100%" fill="url(#fill-gradient)" clip-path="url(#bottle-clip)" /> |
||||
|
</svg>` |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<div class="box"> |
||||
|
<el-select v-model="form.solutionId"> |
||||
|
<el-option v-for="item in solutionList" :key="item.id" :label="item.name" :value="item.id" /> |
||||
|
</el-select> |
||||
|
<div v-html="svgText" /> |
||||
|
<!-- <svg --> |
||||
|
<!-- :key="reloadKey" --> |
||||
|
<!-- xmlns="http://www.w3.org/2000/svg" --> |
||||
|
<!-- xmlns:xlink="http://www.w3.org/1999/xlink" --> |
||||
|
<!-- fill="none" --> |
||||
|
<!-- version="1.1" --> |
||||
|
<!-- width="162.44374084472656" --> |
||||
|
<!-- height="227.99989318847656" --> |
||||
|
<!-- viewBox="0 0 162.44374084472656 227.99989318847656" --> |
||||
|
<!-- > --> |
||||
|
<!-- <defs> --> |
||||
|
<!-- <clipPath id="bottle-clip"> --> |
||||
|
<!-- <path --> |
||||
|
<!-- d="M0,54.0618L0,64.2474C0,65.1128,0.699314,65.8144,1.56196,65.8144C2.4246,65.8144,3.12392,66.516,3.12392,67.3814L3.12392,73.6495C3.12392,74.5149,2.4246,75.2165,1.56196,75.2165C0.699314,75.2165,0,75.918,0,76.7835L0,90.8866C0,91.752,0.699314,92.4536,1.56196,92.4536C2.4246,92.4536,3.12392,93.1551,3.12392,94.0206L3.12392,100.289C3.12392,101.154,2.4246,101.856,1.56196,101.856C0.699314,101.856,0,102.557,0,103.423L0,122.227C0,123.092,0.699314,123.794,1.56196,123.794C2.4246,123.794,3.12392,124.495,3.12392,125.361L3.12392,131.629C3.12392,132.494,2.4246,133.196,1.56196,133.196C0.699314,133.196,0,133.897,0,134.763L0,153.567C0,154.432,0.699314,155.134,1.56196,155.134C2.4246,155.134,3.12392,155.836,3.12392,156.701L3.12392,162.969C3.12392,163.834,2.4246,164.536,1.56196,164.536C0.699314,164.536,0,165.238,0,166.103L0,183.34C0,184.206,0.699314,184.907,1.56196,184.907C2.4246,184.907,3.12392,185.609,3.12392,186.474L3.12392,193.526C3.12392,194.391,2.4246,195.093,1.56196,195.093C0.699314,195.093,0,195.794,0,196.66L0,206.062C0,218.178,9.79038,228,21.8674,228L140.576,228C152.653,228,162.444,218.178,162.444,206.062L162.444,196.66C162.444,195.794,161.744,195.093,160.882,195.093C160.019,195.093,159.32,194.391,159.32,193.526L159.32,186.474C159.32,185.609,160.019,184.907,160.882,184.907C161.744,184.907,162.444,184.206,162.444,183.34L162.444,166.103C162.444,165.238,161.744,164.536,160.882,164.536C160.019,164.536,159.32,163.834,159.32,162.969L159.32,156.701C159.32,155.836,160.019,155.134,160.882,155.134C161.744,155.134,162.444,154.432,162.444,153.567L162.444,134.763C162.444,133.897,161.744,133.196,160.882,133.196C160.019,133.196,159.32,132.494,159.32,131.629L159.32,125.361C159.32,124.495,160.019,123.794,160.882,123.794C161.744,123.794,162.444,123.092,162.444,122.227L162.444,103.423C162.444,102.557,161.744,101.856,160.882,101.856C160.019,101.856,159.32,101.154,159.32,100.289L159.32,94.0206C159.32,93.1551,160.019,92.4536,160.882,92.4536C161.744,92.4536,162.444,91.752,162.444,90.8866L162.444,76.7835C162.444,75.918,161.744,75.2165,160.882,75.2165C160.019,75.2165,159.32,74.5149,159.32,73.6495L159.32,67.3814C159.32,66.516,160.019,65.8144,160.882,65.8144C161.744,65.8144,162.444,65.1128,162.444,64.2474L162.444,54.0618C162.444,41.9457,152.653,32.1237,140.576,32.1237L134.962,32.1237C132.711,32.1237,131.583,29.3931,133.175,27.7961C137.914,23.042,140.576,16.594,140.576,9.87062L140.576,4.70103C140.576,2.10472,138.478,0,135.89,0L26.5533,0C23.9654,0,21.8674,2.10472,21.8674,4.70103L21.8674,9.87062C21.8674,16.594,24.5297,23.042,29.2685,27.7961C30.8603,29.3931,29.7329,32.1237,27.4817,32.1237L21.8674,32.1237C9.79038,32.1237,0,41.9457,0,54.0618Z" --> |
||||
|
<!-- fill="#EEEFF8" --> |
||||
|
<!-- fill-opacity="1" --> |
||||
|
<!-- /> --> |
||||
|
<!-- <use xlink:href="#bottle" /> --> |
||||
|
<!-- </clipPath> --> |
||||
|
<!-- <!– 定义渐变背景(垂直方向,从上到下填充) –> --> |
||||
|
<!-- <linearGradient id="fill-gradient" x1="0%" y1="0%" x2="0%" y2="100%"> --> |
||||
|
<!-- <stop :offset="`${Math.round(((container.capacityTotal - container.capacityUsed) / container.capacityTotal) * 100)}%`" stop-color="#EEEFF8" /> <!– 透明区域 –> --> |
||||
|
<!-- <stop :offset="`${Math.round(((container.capacityTotal - container.capacityUsed) / container.capacityTotal) * 100)}%`" stop-color="red" /> <!– 填充截止百分比(如 50%) –> --> |
||||
|
<!-- <stop offset="100%" stop-color="red" /> --> |
||||
|
<!-- </linearGradient> --> |
||||
|
<!-- </defs> --> |
||||
|
<!-- <rect width="100%" height="100%" fill="url(#fill-gradient)" clip-path="url(#bottle-clip)" /> --> |
||||
|
<!-- </svg> --> |
||||
|
<!-- 绘制瓶子轮廓(保留原有填充色,可自定义描边) --> |
||||
|
<!-- <div class="container-bg"> --> |
||||
|
<!-- <div class="inner-div"> --> |
||||
|
<!-- <div --> |
||||
|
<!-- class="fill-div" --> |
||||
|
<!-- :style="`height: ${((container.capacityTotal - container.capacityUsed) / container.capacityTotal) * 100}%; background: ${container.capacityTotal - container.capacityUsed < 100 ? '#EE8223' : '#26D574'}`" --> |
||||
|
<!-- /> --> |
||||
|
<!-- <span --> |
||||
|
<!-- class="percentage-text" --> |
||||
|
<!-- > --> |
||||
|
<!-- {{ `${Math.round(((container.capacityTotal - container.capacityUsed) / container.capacityTotal) * 100)}%` }} --> |
||||
|
<!-- </span> --> |
||||
|
<!-- </div> --> |
||||
|
<!-- </div> --> |
||||
|
<div> |
||||
|
<div class="footer-edit"> |
||||
|
<span>预充</span> |
||||
|
<el-input v-model="form.capacityUsed" size="small" @blur="onInputBlur"> |
||||
|
<template #append> |
||||
|
ml |
||||
|
</template> |
||||
|
</el-input> |
||||
|
</div> |
||||
|
<div class="footer-edit"> |
||||
|
<span>剩余</span> |
||||
|
<el-input v-model="form.capacityUsed" size="small" @blur="onInputBlur"> |
||||
|
<template #append> |
||||
|
ml |
||||
|
</template> |
||||
|
</el-input> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
.footer-edit { |
||||
|
display: flex; |
||||
|
justify-content: space-around; |
||||
|
padding: 10px 0; |
||||
|
.el-input { |
||||
|
margin-left: 10px; |
||||
|
width: 120px; |
||||
|
} |
||||
|
} |
||||
|
.box { |
||||
|
width: 200px; |
||||
|
height: 300px; |
||||
|
border: 1px solid #ccc; |
||||
|
border-radius: 10px; |
||||
|
padding: 10px; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
align-items: center; |
||||
|
justify-content: space-between; |
||||
|
} |
||||
|
.container-bg { |
||||
|
background-image: url('../../../assets/images/liquied/liquied_bottle.svg'); |
||||
|
background-size: cover; |
||||
|
position: relative; |
||||
|
width: 100px; |
||||
|
height: 140px; |
||||
|
} |
||||
|
|
||||
|
.inner-div { |
||||
|
position: absolute; |
||||
|
top: 8px; |
||||
|
bottom: 0; |
||||
|
width: 100%; |
||||
|
border-radius: 4px; |
||||
|
overflow: hidden; |
||||
|
} |
||||
|
|
||||
|
.fill-div { |
||||
|
position: absolute; |
||||
|
left: 0; |
||||
|
width: 100%; |
||||
|
bottom: 0; |
||||
|
background-color: #26D574; |
||||
|
} |
||||
|
|
||||
|
.percentage-text { |
||||
|
position: absolute; |
||||
|
left: 50%; |
||||
|
top: 50%; |
||||
|
transform: translate(-50%, -50%); |
||||
|
font-size: 12px; |
||||
|
font-weight: 500; |
||||
|
color: #000; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,73 @@ |
|||||
|
<script setup lang="ts"> |
||||
|
import { getContainerList } from 'apis/container' |
||||
|
import { useHomeStore } from 'stores/homeStore' |
||||
|
import { onMounted, ref } from 'vue' |
||||
|
|
||||
|
const emits = defineEmits(['ok', 'cancel']) |
||||
|
|
||||
|
const homeStore = useHomeStore() |
||||
|
let currentCommandId = '' |
||||
|
onMounted(() => { |
||||
|
queryContainerList() |
||||
|
}) |
||||
|
|
||||
|
const containerList = ref<Container.ContainerItem[]>([]) |
||||
|
|
||||
|
const queryContainerList = async () => { |
||||
|
containerList.value = await getContainerList() |
||||
|
} |
||||
|
|
||||
|
const form = ref({ |
||||
|
list: [], |
||||
|
}) |
||||
|
const formRef = ref() |
||||
|
|
||||
|
const rules = { |
||||
|
list: [ |
||||
|
{ required: true, message: '请选择容器', trigger: 'change' }, |
||||
|
], |
||||
|
} |
||||
|
|
||||
|
const okHandle = async () => { |
||||
|
try { |
||||
|
const valid = await formRef.value.validate() |
||||
|
if (!valid) { |
||||
|
return |
||||
|
} |
||||
|
currentCommandId = Date.now().toString() |
||||
|
const params = { |
||||
|
commandId: currentCommandId, |
||||
|
command: 'filled_solution', |
||||
|
params: { |
||||
|
...form.value, |
||||
|
}, |
||||
|
} |
||||
|
await homeStore.sendControl(params) |
||||
|
emits('ok') |
||||
|
} |
||||
|
catch (error) { |
||||
|
console.log(error) |
||||
|
} |
||||
|
} |
||||
|
const cancel = () => { |
||||
|
emits('cancel') |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<FtDialog visible title="预充管路" width="40%" :ok-handle="okHandle" @cancel="cancel"> |
||||
|
<el-form ref="formRef" label-width="auto" :model="form" :rules="rules"> |
||||
|
<el-form-item label="容器" prop="list"> |
||||
|
<el-select v-model="form.list" placeholder="请选择容器" multiple> |
||||
|
<el-option v-for="item in containerList.filter(item => item.type === 0)" :key="item.id" :label="item.solutionName" :value="item.id" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</FtDialog> |
||||
|
</template> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
.el-tag { |
||||
|
margin-right: 5px; |
||||
|
} |
||||
|
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue