瀏覽代碼

巡检工单填写步骤显示,填写逻辑校验

lipenghui 3 月之前
父節點
當前提交
f2c67c88ca
共有 1 個文件被更改,包括 31 次插入22 次删除
  1. 31 22
      src/views/pms/inspect/order/WriteOrder.vue

+ 31 - 22
src/views/pms/inspect/order/WriteOrder.vue

@@ -25,17 +25,6 @@
               :title="`${step.item}`"
               :status="getStepStatus(tabIndex, stepIndex)"
             >
-<!--              <template #description>-->
-<!--                <div class="step-content">-->
-<!--                  <el-tooltip-->
-<!--                    effect="dark"-->
-<!--                    placement="top"-->
-<!--                    :content="step.standard"-->
-<!--                  >-->
-<!--                    <Icon icon="ep:info-filled"/>-->
-<!--                  </el-tooltip>-->
-<!--                </div>-->
-<!--              </template>-->
               <template #title>
                 <div class="step-title-wrapper">
                   <span class="title-text">{{ step.item }}</span>
@@ -52,6 +41,7 @@
           </el-steps>
 
           <div class="form-wrapper">
+            <ContentWrap>
             <el-form
               :model="formData[tabIndex][currentStep[tabIndex]]"
               :rules="formRules"
@@ -80,7 +70,7 @@
                 </el-select>
               </el-form-item>
 
-              <el-form-item label="异常描述" prop="description">
+              <el-form-item label="异常描述" prop="description" :rules="formData[tabIndex][currentStep[tabIndex]].ifNormal?descriptionRule:[]">
                 <el-input
                   v-model="formData[tabIndex][currentStep[tabIndex]].description"
                   type="textarea"
@@ -110,6 +100,17 @@
                 {{ isLastStep(tabIndex) ? '完成提交' : '下一步' }}
               </el-button>
             </div>
+            </ContentWrap>
+            <ContentWrap style="margin-top: 50px">
+              <el-card>
+                <span style="font-weight: bold">巡检标准:</span>{{JSON.parse(tab.itemJson)[currentStep[tabIndex]].standard}}<br />
+                <el-divider />
+                <span style="font-weight: bold">附件:</span>
+                <el-button v-if="JSON.parse(tab.itemJson)[currentStep[tabIndex]].urls" link type="primary" @click="openWeb(JSON.parse(tab.itemJson)[currentStep[tabIndex]].urls)">
+                  <Icon size="19" icon="ep:view" />预览
+                </el-button>
+              </el-card>
+            </ContentWrap>
           </div>
         </div>
       </el-tab-pane>
@@ -141,23 +142,26 @@ onMounted(async () => {
     loading.value = false
   }
 })
-
+const openWeb = (url) => {
+  window.open('http://1.94.244.160:8012/onlinePreview?url='+encodeURIComponent(Base64.encode(url)));
+}
 // 响应式状态
 const loading = ref(true)
 const activeTab = ref('0')
 const currentStep = ref({})
 const formRefs = ref([])
 const formData = reactive([])
-
+const descriptionRule = [
+  { required: true, message: '描述不能为空', trigger: 'blur' }
+];
 // 表单验证规则
 const formRules = reactive({
   ifNormal: [
     { required: true, message: '请输入是否异常', trigger: 'blur' }
   ],
-  description: [
-    { required: true, message: '请输入异常描述', trigger: 'blur' },
-  ],
-
+  // description: [
+  //   { required: true, message: '请输入异常描述', trigger: 'blur' },
+  // ],
 })
 
 // 初始化表单数据
@@ -183,15 +187,21 @@ const getStepStatus = (tabIndex, stepIndex) => {
 // 完成步骤数计算
 const completedSteps = (tabIndex) => {
   return formData[tabIndex].filter(item =>
-    item.ifNormal && item.description !== null
+    item.ifNormal !=null
   ).length
 }
 
 // 步骤验证
 const isStepValid = (tabIndex) => {
   const current = currentStep.value[tabIndex]
-  return formData[tabIndex][current].ifNormal!=null &&
-    formData[tabIndex][current].description !== null&&formData[tabIndex][current].description !== ''
+  debugger
+  if (formData[tabIndex][current].ifNormal===null) {
+    return false
+  }
+  if (formData[tabIndex][current].ifNormal&&(formData[tabIndex][current].description===undefined||formData[tabIndex][current].description===null||formData[tabIndex][current].description==='')) {
+    return false
+  }
+  return true
 }
 
 // 导航控制
@@ -226,7 +236,6 @@ const isLastStep = (tabIndex) => {
 // 提交表单
 const submitForm =  (tabIndex,current,type) => {
   try {
-    debugger
     IotInspectOrderApi.writeIotInspectOrder(formData[tabIndex][current], id)
     if (type === 'finish') {
       message.success(t('common.createSuccess'))