duy преди 1 година
родител
ревизия
d5072f0274
променени са 1 файла, в които са добавени 22 реда и са изтрити 6 реда
  1. 22 6
      src/views/patrol/add.vue

+ 22 - 6
src/views/patrol/add.vue

@@ -88,7 +88,7 @@
                     <el-col :span="12">
                         <el-form-item label="检查类别" prop="inspectType">
                             <el-select v-model="addForm.inspectType" placeholder="请选择" clearable style="width:100%" :disabled="type === 'changeRow' || type === 'review' || type === 'view'">
-                                <el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
+                                <el-option v-for="item in typeOptions" :key="item.id" :label="item.dictValue" :value="item.dictKey" />
                             </el-select>
                         </el-form-item>
                     </el-col>
@@ -244,13 +244,14 @@
 </template>
 
 <script setup>
-import { nextTick, onActivated, ref, watch } from 'vue'
+import { onActivated, ref } from 'vue'
 import { useAppStore } from '~src/store'
 import queryApi from '~api/data-fill/query'
 import { arrToKey, formValidate, getArrValue, getObjValue } from 'js-fast-way'
 import { useRoute, useRouter } from 'vue-router'
 import { getTokenHeader } from '~src/api/request/header'
 import patrolApi from '~api/patrol/patrol'
+import { getDictionary } from '~api/other'
 
 //初始变量
 const router = useRouter()
@@ -300,10 +301,17 @@ const addRules = {
 
 //检查类别
 const typeOptions = ref([
-    { label:'安全巡检', value:1 },
-    { label:'质量巡检', value:2 },
+    // { label:'安全巡检', value:1 },
+    // { label:'质量巡检', value:2 },
 ])
-
+//获取检查类别Data = ref([])
+const getTypeOptions = async () => {
+    const { data } = await getDictionary({
+        code: 'inspect_type',
+    })
+    //处理数据
+    typeOptions.value = getArrValue(data)
+}
 const tableColumn = ref([
 { key: 'inspectProject', name: '检查项目' },
             { key: 'inspectContent', name: '检查内容' },
@@ -318,11 +326,16 @@ const tableColumn = ref([
 
 
 onActivated(()=>{
+    getTypeOptions()
     const routerQuery = useRoutes?.query
     type.value = routerQuery?.type || ''
     id.value = routerQuery?.id || ''
     if (id.value.length > 0) {
         getDetail( id.value)
+    } else {
+        addForm.value = {}
+        processDataList.value = []
+        peoples.value = ''
     }
     if (type.value === 'changeRow') {
 
@@ -479,11 +492,12 @@ const tasksUserChange = (a, b, users) => {
 //关联工程用途及部位
 const linksRelateModal = ref(false)
 const linksRelateModalClick = ()=>{
-    TreeAutoExpandKeys.value = processDataList.value[processDataList.value.length - 1].autoExpandKeys
+    TreeAutoExpandKeys.value = processDataList.value[0]?.autoExpandKeys || []
     console.log( TreeAutoExpandKeys.value, '  TreeAutoExpandKeys.value')
     linksRelateModal.value = true
    
     defaultChecked.value = arrToKey(processDataList.value, 'primaryKeyId', ',').split(',')
+    console.log( defaultChecked.value, ' defaultChecked.value')
 }
 const linksRelateModalClose = ()=>{
     linksRelateModal.value = false
@@ -665,6 +679,7 @@ const saveInfo = async ()=>{
         saveLoading.value = false
         if (!error && code === 200) {
             window?.$message?.success('操作成功')
+            goList()
         }
     }
 }
@@ -683,6 +698,7 @@ const updateInfo = async ()=>{
         updateLoaing.value = false
         if (!error && code === 200) {
             window?.$message?.success('操作成功')
+            goList()
         }
     }
 }