|
@@ -1,7 +1,8 @@
|
|
|
<template>
|
|
|
<ContentWrap>
|
|
|
<el-tabs v-model="activeTab" type="border-card" tab-position="left" v-loading="loading" style="height: 80vh">
|
|
|
- <el-tab-pane style="height: 100%"
|
|
|
+ <el-tab-pane
|
|
|
+ style="height: 100%"
|
|
|
v-for="(tab, tabIndex) in tabs"
|
|
|
:key="tab.deviceName"
|
|
|
:name="String(tabIndex)"
|
|
@@ -43,7 +44,6 @@
|
|
|
placement="top"
|
|
|
effect="dark"
|
|
|
>
|
|
|
-<!-- <el-icon class="tip-icon"/>-->
|
|
|
<Icon icon="ep:info-filled"/>
|
|
|
</el-tooltip>
|
|
|
</div>
|
|
@@ -58,7 +58,7 @@
|
|
|
ref="formRefs"
|
|
|
label-width="120px"
|
|
|
>
|
|
|
- <el-form-item label="设备id" prop="deviceId">
|
|
|
+ <el-form-item label="设备id" v-if="false" prop="deviceId">
|
|
|
<el-input
|
|
|
v-model="formData[tabIndex][currentStep[tabIndex]].deviceId"
|
|
|
:model-value="tab.deviceId"
|
|
@@ -83,9 +83,8 @@
|
|
|
<el-form-item label="异常描述" prop="description">
|
|
|
<el-input
|
|
|
v-model="formData[tabIndex][currentStep[tabIndex]].description"
|
|
|
- :min="0"
|
|
|
type="textarea"
|
|
|
- controls-position="right"
|
|
|
+ :rows="5"
|
|
|
placeholder="请填写异常描述"
|
|
|
/>
|
|
|
</el-form-item>
|
|
@@ -106,7 +105,7 @@
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
:disabled="!isStepValid(tabIndex)"
|
|
|
- @click="handleNext(tabIndex)"
|
|
|
+ @click="handleNext(tabIndex, tab.deviceId)"
|
|
|
>
|
|
|
{{ isLastStep(tabIndex) ? '完成提交' : '下一步' }}
|
|
|
</el-button>
|
|
@@ -119,10 +118,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+const { push } = useRouter() // 路由
|
|
|
+
|
|
|
+const { t } = useI18n() // 国际化
|
|
|
import { ref, reactive, onMounted } from 'vue'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import {IotInspectOrderApi} from "@/api/pms/inspect/order";
|
|
|
import {DICT_TYPE, getBoolDictOptions} from "@/utils/dict";
|
|
|
+const message = useMessage() // 消息弹窗
|
|
|
|
|
|
const tabs = ref([])
|
|
|
const { params, name } = useRoute() // 查询参数
|
|
@@ -157,27 +160,17 @@ const formRules = reactive({
|
|
|
// 初始化表单数据
|
|
|
const initFormData = (tabsData) => {
|
|
|
tabsData.forEach((tab, tabIndex) => {
|
|
|
- formData[tabIndex] = JSON.parse(tab.itemJson).map(() => ({
|
|
|
- ifNormal: '',
|
|
|
- description: null,
|
|
|
- picUrl: ''
|
|
|
+ formData[tabIndex] = JSON.parse(tab.itemJson).map((item) => ({
|
|
|
+ deviceId: item.deviceId,
|
|
|
+ indexId: item.indexId,
|
|
|
+ ifNormal: item.ifNormal,
|
|
|
+ description: item.description,
|
|
|
+ picUrl: item.picUrl,
|
|
|
}))
|
|
|
currentStep.value[tabIndex] = 0
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// 获取数据
|
|
|
-const fetchData = async () => {
|
|
|
- try {
|
|
|
- const data = await mockApi()
|
|
|
- tabs.value = data
|
|
|
- initFormData(data)
|
|
|
- } catch (error) {
|
|
|
- ElMessage.error('数据加载失败')
|
|
|
- } finally {
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// 步骤状态计算
|
|
|
const getStepStatus = (tabIndex, stepIndex) => {
|
|
|
if (stepIndex < currentStep.value[tabIndex]) return 'finish'
|
|
@@ -194,8 +187,7 @@ const completedSteps = (tabIndex) => {
|
|
|
// 步骤验证
|
|
|
const isStepValid = (tabIndex) => {
|
|
|
const current = currentStep.value[tabIndex]
|
|
|
- debugger
|
|
|
- return formData[tabIndex][current].ifNormal &&
|
|
|
+ return formData[tabIndex][current].ifNormal!=null &&
|
|
|
formData[tabIndex][current].description !== null&&formData[tabIndex][current].description !== ''
|
|
|
}
|
|
|
|
|
@@ -206,17 +198,21 @@ const handlePrev = (tabIndex) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const handleNext = async (tabIndex) => {
|
|
|
+const handleNext = (tabIndex, deviceId) => {
|
|
|
if (!isStepValid(tabIndex)) {
|
|
|
return ElMessage.warning('请先完成当前步骤的必填项')
|
|
|
}
|
|
|
-
|
|
|
+ const current = currentStep.value[tabIndex]
|
|
|
const totalSteps = JSON.parse(tabs.value[tabIndex].itemJson).length
|
|
|
- debugger
|
|
|
if (currentStep.value[tabIndex] < totalSteps - 1) {
|
|
|
+ formData[tabIndex][current].indexId = current+1
|
|
|
+ formData[tabIndex][current].deviceId = deviceId
|
|
|
currentStep.value[tabIndex]++
|
|
|
+ submitForm(tabIndex, current, '')
|
|
|
} else {
|
|
|
- await submitForm(tabIndex)
|
|
|
+ formData[tabIndex][current].indexId = current+1
|
|
|
+ formData[tabIndex][current].deviceId = deviceId
|
|
|
+ submitForm(tabIndex, current,'finish')
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -225,11 +221,14 @@ const isLastStep = (tabIndex) => {
|
|
|
}
|
|
|
|
|
|
// 提交表单
|
|
|
-const submitForm = async (tabIndex) => {
|
|
|
+const submitForm = (tabIndex,current,type) => {
|
|
|
try {
|
|
|
debugger
|
|
|
- // 这里添加实际提交逻辑
|
|
|
- ElMessage.success(`提交成功:${tabs.value[tabIndex].deviceName}`)
|
|
|
+ IotInspectOrderApi.writeIotInspectOrder(formData[tabIndex][current], id)
|
|
|
+ if (type === 'finish') {
|
|
|
+ message.success(t('common.createSuccess'))
|
|
|
+ push({ name: 'IotInspectOrder' })
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
ElMessage.error('提交失败,请检查数据')
|
|
|
}
|
|
@@ -238,10 +237,6 @@ const submitForm = async (tabIndex) => {
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.container {
|
|
|
- padding: 10px;
|
|
|
- background: #f5f7fa;
|
|
|
-}
|
|
|
|
|
|
.step-container {
|
|
|
display: grid;
|
|
@@ -269,40 +264,15 @@ const submitForm = async (tabIndex) => {
|
|
|
}
|
|
|
|
|
|
.custom-label {
|
|
|
- font-weight: 500;
|
|
|
- padding: 0 15px;
|
|
|
+ font-weight: 1000;
|
|
|
+ font-size: 17px;
|
|
|
+ padding: 0 10px;
|
|
|
}
|
|
|
::v-deep .el-step__icon {
|
|
|
background-color: #409eff;
|
|
|
color: #fff;
|
|
|
border: 0px;
|
|
|
}
|
|
|
-.el-step__title {
|
|
|
- font-size: 14px;
|
|
|
-}
|
|
|
-
|
|
|
-.el-form-item {
|
|
|
- margin-bottom: 22px;
|
|
|
-}
|
|
|
-.hint-icon {
|
|
|
- color: #909399;
|
|
|
- font-size: 14px;
|
|
|
- cursor: help;
|
|
|
- transition: color 0.2s;
|
|
|
-
|
|
|
- &:hover {
|
|
|
- color: #409eff;
|
|
|
- }
|
|
|
-}
|
|
|
-.step-content {
|
|
|
- display: flex;
|
|
|
- flex-direction: row;
|
|
|
- align-items: center;
|
|
|
- gap: 5px;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
.step-title-wrapper {
|
|
|
display: inline-flex;
|
|
|
align-items: center;
|
|
@@ -311,21 +281,6 @@ const submitForm = async (tabIndex) => {
|
|
|
padding-right: 25px;
|
|
|
}
|
|
|
|
|
|
-/* 提示图标样式 */
|
|
|
-.tip-icon {
|
|
|
- font-size: 16px;
|
|
|
- color: #e6a23c;
|
|
|
- cursor: help;
|
|
|
- transition:
|
|
|
- color 0.3s ease,
|
|
|
- transform 0.2s ease;
|
|
|
-
|
|
|
- &:hover {
|
|
|
- color: #f56c6c;
|
|
|
- transform: scale(1.1);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
/* 覆盖步骤条默认样式 */
|
|
|
:deep(.custom-steps) {
|
|
|
/* 调整头部位置 */
|