Jelajahi Sumber

代码优化, 添加基础信息配置文件

linqilong 1 bulan lalu
induk
melakukan
90239c0c77

+ 14 - 0
src/assets/js/base.js

@@ -0,0 +1,14 @@
+const baseList = [
+    { type: '工程', inspectTypes: ['008'], columns: [], icon: '', nameColumn: '工程名称', description: '工程地址:{addr}' },
+];
+
+/**
+ * 根据督察类型获取基础信息
+ * @param {督察类型} inspectType 
+ * @returns 
+ */
+function getBaseByInspectType(inspectType) {
+    return baseList.find(base => base.inspectTypes.includes(inspectType));
+}
+
+export { getBaseByInspectType, }

+ 10 - 3
src/components/list01.vue

@@ -1,14 +1,16 @@
 <template>
     <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
         <card01 v-for="item in list" :key="item" :title="item.prsnTitle + ''" icon="notes"
-            :description="`时间:${item.sttm} 至 ${item.entm}`" />
+            :description="`时间:${item.sttm} 至 ${item.entm}`" @click="handleClick(item.prsnId)" />
     </van-list>
 </template>
 <script setup>
-import { ref, defineProps, watch } from 'vue';
+import { ref, defineProps, watch, defineEmits } from 'vue';
 import card01 from './card01.vue';
 import { getCurrGroup, getInspBaseByPersid } from '@/api/inspect.js';
 
+const emits = defineEmits(['onClick']);
+
 const props = defineProps({
     type: {
         type: String,
@@ -27,7 +29,7 @@ function onLoad() {
     if (props.type === 'history' && props.batch) {
         getInspBaseByPersid(props.batch).then(res => {
             list.value = res.data;
-        debugger
+            debugger
             loading.value = false;
             finished.value = true;
         })
@@ -40,6 +42,11 @@ function onLoad() {
     }
 }
 
+function handleClick(id) {
+    emits('onClick', id);
+}
+
+
 watch(() => props.batch, batch => {
     if (batch) {
         onLoad()

+ 27 - 4
src/views/Inspect/current.vue

@@ -3,18 +3,41 @@
         <div class="filter-wrapper">
             <gw-select :columns="inspectTypes" v-model:value="inspectType" />
         </div>
-        <list01 class="ducha-group-wrapper" type="current" :batch="inspectType"></list01>
+        <van-pull-refresh class="inspect-group-wrapper" v-model="loading" @refresh="onLoad()">
+            <card01 v-for="item in list" :key="item" :title="item.prsnTitle + ''" icon="notes"
+                :description="`时间:${item.sttm} 至 ${item.entm}`" @click="emits('onClick', item.prsnId)" />
+        </van-pull-refresh>
     </div>
 </template>
 <script setup>
-import { ref } from "vue";
+import { ref, defineEmits, watch } from "vue";
 import GwSelect from "@/components/GwSelect.vue";
-import List01 from "@/components/list01.vue";
+import card01 from '@/components/card01.vue';
+import { getCurrGroup } from '@/api/inspect.js';
+
+const emits = defineEmits(['onClick']);
 
 const inspectTypes = [
     { text: '稽查工作', value: '008' },
 ];
 const inspectType = ref('008');
+const list = ref([]);
+const loading = ref(false);
+const finished = ref(false);
+
+function onLoad() {
+    getCurrGroup(inspectType.value).then(res => {
+        list.value = res.data;
+        loading.value = false;
+        finished.value = true;
+    })
+}
+
+watch(() => inspectType, inspectType => {
+    if (inspectType.value) {
+        onLoad()
+    }
+})
 </script>
 <style lang="scss" scoped>
 @import '@/assets/styles/filter.scss';
@@ -24,7 +47,7 @@ const inspectType = ref('008');
     height: 100%;
     overflow: auto;
 
-    .ducha-group-wrapper {
+    .inspect-group-wrapper {
         height: calc(100% - 35px);
         overflow: auto;
     }

+ 31 - 12
src/views/Inspect/history.vue

@@ -5,15 +5,20 @@
             <gw-select :columns="baseBatchs" v-model:value="baseBatch" />
             <gw-select :columns="twoBatchs" v-model:value="twoBatch" />
         </div>
-        <list01 class="inspect-group-wrapper" type="history" :batch="twoBatch"></list01>
+        <van-pull-refresh class="inspect-group-wrapper" v-model="loading" @refresh="getInspBase(twoBatch, 3)">
+            <card01 v-for="item in list" :key="item" :title="item.prsnTitle + ''" icon="notes"
+                :description="`时间:${item.sttm} 至 ${item.entm}`" @click="emits('onClick', item.prsnId)" />
+        </van-pull-refresh>
     </div>
 </template>
 <script setup>
-import { onMounted, ref, watch } from "vue";
-import List01 from "@/components/list01.vue";
+import { ref, watch, defineEmits } from "vue";
 import GwSelect from "@/components/GwSelect.vue";
+import card01 from '@/components/card01.vue';
 import { getInspBaseByPersid } from "@/api/inspect";
 
+const emits = defineEmits(['onClick']);
+
 const inspectType = ref('008');
 const inspectTypes = [{ text: '稽查工作', value: '008' }];
 
@@ -23,9 +28,20 @@ const baseBatchs = ref([]);
 const twoBatch = ref(null);
 const twoBatchs = ref([]);
 
+const list = ref([]);
+const loading = ref(false);
+
 function getInspBase(value, level = 1) {
+    if (!value) {
+        return;
+    }
     // 获取批次
     getInspBaseByPersid(value).then(res => {
+        if (level === 3) {
+            list.value = res.data;
+            loading.value = false;
+            return;
+        }
         if (level === 2) {
             twoBatchs.value = res.data.map(item => ({ text: item.prsnTitle, value: item.plnaId })).reverse();
             twoBatch.value = twoBatchs.value[0].value;
@@ -33,20 +49,23 @@ function getInspBase(value, level = 1) {
         }
         baseBatchs.value = res.data.map(item => ({ text: item.prsnTitle, value: item.plnaId }));
         baseBatch.value = baseBatchs.value[0].value;
-        // getInspBase(baseBatch.value, 2);
     });
 }
 
-onMounted(() => {
-    getInspBase(inspectType.value)
-});
-
-
 watch(() => inspectType, inspectType => {
-    getInspBase(inspectType.value);
-})
+    if (inspectType.value) {
+        getInspBase(inspectType.value);
+    }
+}, { deep: true, immediate: true })
 watch(() => baseBatch, baseBatch => {
-    getInspBase(baseBatch.value, 2);
+    if (baseBatch.value) {
+        getInspBase(baseBatch.value, 2);
+    }
+}, { deep: true, immediate: true })
+watch(() => twoBatch, twoBatch => {
+    if (twoBatch.value) {
+        getInspBase(twoBatch.value, 3)
+    }
 }, { deep: true, immediate: true })
 </script>
 <style lang="scss" scoped>