zhangqiOMG пре 1 година
родитељ
комит
5e94c3642e

+ 113 - 0
src/components/detailTemplate/index copy.vue

@@ -0,0 +1,113 @@
+<template>
+  <div style="margin-top:10px;">
+    <a-card class="mt-10" :headStyle="{padding:'0 10px'}" :bodyStyle="{padding:'10px 16px'}" :bordered="false">
+      <template #title>
+        <div class="flex-between">
+          <a-space>
+            <a-button shape="circle" @click="goBack">
+              <arrow-left-outlined />
+            </a-button>
+            <span>{{title}}</span>
+          </a-space>
+          <div class="flex-align-center">
+            <a-space>
+              <slot name="operation"></slot>
+              <a-button v-if="delParam" type="danger" :disabled="disable" @click="delData">删除</a-button>
+              <a-button @click="base.previous">
+                <template #icon>
+                  <left-outlined />
+                </template>
+              </a-button>
+              <a-button @click="base.next">
+                <template #icon>
+                  <right-outlined />
+                </template>
+              </a-button>
+            </a-space>
+          </div>
+        </div>
+      </template>
+      <a-descriptions :column="6" :labelStyle="{color:'#999999'}" :contentStyle="{marginRight:'20px',marginBottom:'5px'}"  size="small">
+        <a-descriptions-item :span="item.span ? item.span : 1"  v-for="item in props.headData" :key="item.index" :label="item.label"><span :style="item.style?item.style():''">{{item.value}}</span></a-descriptions-item>
+      </a-descriptions>
+    </a-card>
+    <div class="y-container">
+      <a-tabs v-model:activeKey="activeKey" @change="onTabChange" >
+        <a-tab-pane v-for="(item,index) in props.tabs" :key="index" :tab="item">
+          <slot :name="'tab' + index"></slot>
+        </a-tab-pane>
+        <a-tab-pane key="log" tab="操作记录">
+          <log-temp :ownertable="ownertable"></log-temp>
+        </a-tab-pane>
+      </a-tabs>
+    </div>
+  </div>
+</template>
+
+<script setup>
+  import logTemp from './modules/log.vue'
+  import Api from '@/api/api'
+  import utils from "@/utils/utils"
+  import {defineProps,ref,createVNode} from 'vue'
+  import { LeftOutlined,RightOutlined,ExclamationCircleOutlined,ArrowLeftOutlined} from '@ant-design/icons-vue'
+  import { useRouter } from "vue-router"
+  import { Modal } from 'ant-design-vue'
+  import { useBaseStore } from '../../stores/modules/base'
+  import { storeToRefs } from 'pinia'
+  const router = useRouter()
+  const base = useBaseStore()
+  let { pageChange } = storeToRefs(base)
+
+  const props = defineProps({
+    headData:Array,
+    tabs:Array,
+    ownertable:String,
+    title:String,
+    delParam:Object,
+    disable:Boolean
+  })
+  
+  const activeKey = ref(0)
+  const goBack = ()=>{
+    router.replace({name:router.currentRoute.value.meta.name})
+  }
+
+  const delData = ()=>{
+    Modal.confirm({
+      title:"删除",
+      content: '确认删除当前数据吗',
+      icon: createVNode(ExclamationCircleOutlined),
+      async onOk() {
+        const res = await Api.requested(props.delParam)
+        utils.message(res,'删除成功',()=>{
+          goBack()
+        })
+      },
+      cancelText: '取消',
+      onCancel() {
+        Modal.destroyAll();
+      },
+    })
+  }
+  const onTabChange = (key)=>{
+    activeKey.value = key
+  }
+</script>
+
+<style scoped>
+.y-container{
+  padding:0 10px 10px 10px
+}
+.flex-between{
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+.flex-align-center{
+  display: flex;
+  align-items:center;
+}
+.mt-10{
+  margin-bottom: 10px;
+}
+</style>

+ 83 - 25
src/components/detailTemplate/index.vue

@@ -1,6 +1,7 @@
 <template>
-  <div style="margin-top:10px;">
-    <a-card class="mt-10" :headStyle="{padding:'0 10px'}" :bodyStyle="{padding:'10px 16px'}" :bordered="false">
+  <div>
+    
+    <a-card class="mt-10" :style="{borderRadius:'0 0 5px 5px'}" :headStyle="{padding:'0 10px'}" :bordered="false">
       <template #title>
         <div class="flex-between">
           <a-space>
@@ -12,13 +13,13 @@
           <div class="flex-align-center">
             <a-space>
               <slot name="operation"></slot>
-              <a-button v-if="delParam" type="danger" :disabled="disable" @click="delData">删除</a-button>
-              <a-button @click="base.previous">
+              <a-button v-if="delParam && utils.hasPermission('delete')" type="primary" :disabled="disable" @click="delData" danger>删除</a-button>
+              <a-button v-if="router.currentRoute.value.query.listqueryid" @click="previous">
                 <template #icon>
                   <left-outlined />
                 </template>
               </a-button>
-              <a-button @click="base.next">
+              <a-button v-if="router.currentRoute.value.query.listqueryid" @click="next">
                 <template #icon>
                   <right-outlined />
                 </template>
@@ -27,20 +28,25 @@
           </div>
         </div>
       </template>
-      <a-descriptions :column="6" :labelStyle="{color:'#999999'}" :contentStyle="{marginRight:'20px',marginBottom:'5px'}"  size="small">
+      <a-descriptions :column="6" :labelStyle="{color:'#666'}" :contentStyle="{marginRight:'20px',marginBottom:'5px'}"  size="small">
         <a-descriptions-item :span="item.span ? item.span : 1"  v-for="item in props.headData" :key="item.index" :label="item.label"><span :style="item.style?item.style():''">{{item.value}}</span></a-descriptions-item>
       </a-descriptions>
+      <slot name="customContent"></slot>
+    </a-card>
+    <slot name="customMid"></slot>
+
+    <a-card class="mt-10" :style="{borderRadius:'5px'}" :bodyStyle="{padding:'0 20px 20px 20px'}" :bordered="false">
+      <div v-if="!props.notabs">
+        <a-tabs v-model:activeKey="activeKey" @change="onTabChange" >
+          <a-tab-pane v-for="(item,index) in props.tabs" :key="index" :tab="item">
+            <slot :name="'tab' + index"></slot>
+          </a-tab-pane>
+          <a-tab-pane key="log" tab="操作记录">
+            <log-temp :ownertable="ownertable"></log-temp>
+          </a-tab-pane>
+        </a-tabs>
+      </div>
     </a-card>
-    <div class="y-container">
-      <a-tabs v-model:activeKey="activeKey" @change="onTabChange" >
-        <a-tab-pane v-for="(item,index) in props.tabs" :key="index" :tab="item">
-          <slot :name="'tab' + index"></slot>
-        </a-tab-pane>
-        <a-tab-pane key="log" tab="操作记录">
-          <log-temp :ownertable="ownertable"></log-temp>
-        </a-tab-pane>
-      </a-tabs>
-    </div>
   </div>
 </template>
 
@@ -48,27 +54,27 @@
   import logTemp from './modules/log.vue'
   import Api from '@/api/api'
   import utils from "@/utils/utils"
-  import {defineProps,ref,createVNode} from 'vue'
+  import {defineProps,ref,createVNode,computed,defineEmits,onMounted,onActivated} from 'vue'
   import { LeftOutlined,RightOutlined,ExclamationCircleOutlined,ArrowLeftOutlined} from '@ant-design/icons-vue'
   import { useRouter } from "vue-router"
-  import { Modal } from 'ant-design-vue'
-  import { useBaseStore } from '../../stores/modules/base'
+  import { Modal,message } from 'ant-design-vue'
+  import { useRouteTabsStore } from '@/stores/modules/routeTabs'
   import { storeToRefs } from 'pinia'
+  const rotTabs = useRouteTabsStore()
   const router = useRouter()
-  const base = useBaseStore()
-  let { pageChange } = storeToRefs(base)
-
   const props = defineProps({
     headData:Array,
     tabs:Array,
     ownertable:String,
     title:String,
     delParam:Object,
-    disable:Boolean
+    disable:Boolean,
+    notabs:Boolean,
   })
-  
   const activeKey = ref(0)
+  
   const goBack = ()=>{
+    rotTabs.delRoute(router.currentRoute.value.name,router.currentRoute.value.name)
     router.replace({name:router.currentRoute.value.meta.name})
   }
 
@@ -78,8 +84,10 @@
       content: '确认删除当前数据吗',
       icon: createVNode(ExclamationCircleOutlined),
       async onOk() {
-        const res = await Api.requested(props.delParam)
+        const res = await Api.post(props.delParam)
         utils.message(res,'删除成功',()=>{
+          let currentRoute = router.currentRoute.value.name
+          rotTabs.delRoute(currentRoute,currentRoute)
           goBack()
         })
       },
@@ -92,6 +100,56 @@
   const onTabChange = (key)=>{
     activeKey.value = key
   }
+  const time = ref(null)
+  const previous = ()=>{
+    let rowindex = Number(router.currentRoute.value.query.rowindex) - 1
+    let listqueryid = router.currentRoute.value.query.listqueryid
+    if (rowindex >= 1) {
+      if (time.value !== null) {
+        clearTimeout(time.value)
+      }
+      time.value = setTimeout(() => {
+        upPageData(rowindex,listqueryid)
+      }, 0);
+    } else {
+      message.warn('已经是第一条了!')
+    }
+  }
+  const next = ()=>{
+    let rowindex = Number(router.currentRoute.value.query.rowindex) + 1
+    let listqueryid = router.currentRoute.value.query.listqueryid
+    if (time.value !== null) {
+      clearTimeout(time.value)
+    }
+    time.value = setTimeout(() => {
+      upPageData(rowindex,listqueryid)
+    }, 0);
+  }
+  const upPageData = async (rowindex,listqueryid)=> {
+    const hide = message.loading({content:'正在查询数据,请稍等..',duration:0,key:1});
+    const res = await Api.requested({
+      "classname": "system.tools",
+      "method":"querylistdatabyrowindex",
+        "content": {
+          "rowindex": rowindex,
+          "listqueryid": listqueryid,
+          "fieldname":router.currentRoute.value.query.fieldName ? router.currentRoute.value.query.fieldName:''
+        }
+    })
+    if (res.data.data) {
+      hide()
+      router.replace({path:router.currentRoute.value.path,query:{id:res.data.data,rowindex:rowindex,listqueryid:listqueryid,fieldName:router.currentRoute.value.query.fieldName}})
+    } else {
+       message.warn('已经是最后一条了!')
+    }
+  }
+  onActivated (()=>{
+    if(!props.tabs || props.tabs.length == 0) {
+      activeKey.value = 'log'
+    }
+  })
+  onMounted (()=>{
+  })
 </script>
 
 <style scoped>

+ 0 - 9
src/components/layout/modules/header.vue

@@ -66,15 +66,6 @@ const accountItemClick = (account,bool)=>{
     router.go(0)
   }
 }
-// const accountItemClick = (account,bool)=>{
-//   if (router.currentRoute.value.meta.isDetail) {
-//     router.go(-1)
-//   }
-//   store.defaultAccount(account,()=>{
-//     store.reloadPage()
-//     historyRoutes.value = []
-//   })
-// }
 const loginOut = ()=>{
   Modal.confirm({
     title: '注意',

+ 8 - 2
src/stores/modules/Htabs.js

@@ -16,7 +16,7 @@ export const useRouteTabsStore = defineStore('routeTabs', {
     enabled: true,
     strategies: [
       {
-        storage: localStorage,
+        storage: sessionStorage,
         paths: ['historyRoutes','activeKey']
       }
     ]
@@ -25,9 +25,15 @@ export const useRouteTabsStore = defineStore('routeTabs', {
   actions:{
       // 存储路由记录
     saveRoute (route) {
+      
       let hasRoute = this.historyRoutes.some(e=>e.name == route.name)
       if (!hasRoute)
-        return this.historyRoutes.push(route)
+        return this.historyRoutes.push({
+          meta:route.meta,
+          name:route.name,
+          path:route.path,
+          query:route.query
+        })
     },
 
     // 删除路由

+ 18 - 15
src/stores/modules/auth.js

@@ -33,18 +33,22 @@ export const useAuthStore = defineStore('auth', {
   },
   getters:{},
   actions:{
-    async systemAuthData () {
-      let data = {
-        "classname": "sysmanage.develop.userauthforweb.userauth",
-        "method": "query_userauth",
-        "content": {
-          "place": 1
-        },
-        "systemappid": ""
-      }
-      const res = await Api.requested(data)
-      this.system = res.data
-      this.mods = res.data[0].modules
+    systemAuthData () {
+      return new Promise(async resolve => {
+        let data = {
+          "classname": "sysmanage.develop.userauthforweb.userauth",
+          "method": "query_userauth",
+          "content": {
+            "place": 1
+          },
+          "systemappid": ""
+        }
+        const res = await Api.requested(data)
+        this.system = res.data
+        this.mods = res.data[0].modules
+        resolve()
+      })
+      
     },
     async hideKeyWords (data) {
       let account = data
@@ -125,7 +129,7 @@ export const useAuthStore = defineStore('auth', {
     /**
      * 设置默认账号
      */
-    defaultAccount (account,fn) {
+    async defaultAccount (account,fn) {
 
       this.nowAccount = account
 
@@ -133,8 +137,7 @@ export const useAuthStore = defineStore('auth', {
 
       this.getConfig()
 
-      this.systemAuthData()
-
+      await this.systemAuthData()
       fn()
     },
     /**

+ 1 - 82
src/stores/modules/base.js

@@ -86,87 +86,6 @@ export const useBaseStore = defineStore('base', {
       }
       return createMenu(res.data)
       
-    },
-
-    async next () {
-      console.log(this.keyid)
-      const rs = await this.checkPaginationData()
-      if (rs == 0 && this.nowPageData.length == 1) return false
-      if (rs == 1 && this.PageUpParam.content.pageNumber == this.pageTotal) return false
-      let fun = (rs) =>{
-        let nowId = this.router.currentRoute.query.id
-        let changeId = ''
-        if (rs == 1) {
-          changeId = this.nowPageData[0][this.keyid]
-        } else {
-          this.nowPageData.forEach((e,index)=>{
-            if (e[this.keyid] == nowId) {
-              changeId = this.nowPageData[index + 1][this.keyid]
-            }
-          })
-        }
-        this.router.replace({path:this.router.currentRoute.path,query:{id:changeId}})
-      }
-      if (rs == 1) {
-        this.PageUpParam.content.pageNumber ++
-        this.newListData((rs)=>{
-          fun(1)
-        })
-      } else {
-        fun()
-      }
-    },
-    async previous () {
-      const res = await this.checkPaginationData()
-      if (res == 0 && this.PageUpParam.content.pageNumber == 1) return false
-      const fun = (rs)=>{
-        let nowId = this.router.currentRoute.query.id
-        let changeId = ''
-       
-        if (rs == 0) {
-          changeId = this.nowPageData[this.nowPageData.length - 1][this.keyid]
-        } else {
-          this.nowPageData.forEach((e,index)=>{
-            if (e[this.keyid] == nowId) {
-              changeId = this.nowPageData[index - 1][this.keyid]
-            }
-          })
-        }
-        this.router.replace({path:this.router.currentRoute.path,query:{id:changeId}})
-      }
-      if (res == 0) {
-        this.PageUpParam.content.pageNumber --
-        this.newListData(()=>{
-          fun(0)
-        })
-      } else {
-        fun()
-      }
-    },
-    checkPaginationData () {
-      return new Promise((reslove,reject)=>{
-        let id = this.router.currentRoute.query.id
-        let n = 0
-        this.nowPageData.filter((e,index)=>{
-          if (e[this.keyid] == id){
-            
-            n = index
-          }
-        })
-        if (n == 0) {
-          reslove(0)
-        } else if (n == this.nowPageData.length - 1) {
-          reslove(1)
-        } else {
-          reslove(-1)
-        }
-      })
-    },
-    async newListData (fn) {
-      const res = await Api.requested(this.PageUpParam)
-      this.nowPageData = res.data
-      this.pageTotal = res.pageTotal
-      fn?fn():''
-    },
+    }
   }
 })

+ 1 - 1
src/views/login/login.vue

@@ -151,7 +151,7 @@ export default defineComponent({
         loading.value = false
         accountList.value = res.account_list
         store.defaultAccount(res.account_list[0],()=>{
-          router.replace({path:'/home'})
+          router.replace({path:'/IoTdashboard'})
         })
 
       } else {