shaogen1995 4 лет назад
Родитель
Сommit
af3525eb03

BIN
src/assets/img/user1.jpg


+ 2 - 2
src/main.js

@@ -79,10 +79,10 @@ const checkBtn = {
     // 状态的数据处理
     myState (id) {
       const list = [
-        { id: 0, name: '草稿中' },
+        { id: 0, name: '待办理' },
         { id: 1, name: '待审核' },
         { id: 2, name: '审核不通过' },
-        { id: 3, name: '审核通过' }
+        { id: 3, name: '已完成' }
       ]
       return list.filter(v => id === v.id)[0].name
     },

+ 5 - 1
src/router/index.js

@@ -1,5 +1,6 @@
 import Vue from 'vue'
 import VueRouter from 'vue-router'
+import { Message } from 'element-ui'
 
 Vue.use(VueRouter)
 
@@ -210,7 +211,10 @@ router.beforeEach((to, from, next) => {
   else {
     const token = localStorage.getItem('daliCK_token')
     if (token) next()
-    else next({ name: 'login' })
+    else {
+      Message.warning('登录失效,请重新登录')
+      next({ name: 'login' })
+    }
   }
 })
 

+ 2 - 3
src/utils/request.js

@@ -1,5 +1,4 @@
 import axios from 'axios'
-import { Message } from 'element-ui'
 // export const baseURL = '666初始地址'
 const service = axios.create({
   baseURL: 'http://192.168.0.135:8006',
@@ -29,9 +28,9 @@ service.interceptors.response.use(function (response) {
   // 对响应数据做点什么--response就是发送每个请求的返回值
   if (response.data.code === 5001 || response.data.code === 5002) {
     // Toast.fail('未登录,请先登录')
-    Message.warning('登录失效,请重新登录')
+    localStorage.removeItem('daliCK')
+    localStorage.removeItem('daliCK_token')
     // 登录完之后能返回刚刚的页面
-    location.href = '#/login'
   }
   return response.data
 }, function (error) {

+ 189 - 45
src/views/holding/holding0.vue

@@ -1,8 +1,7 @@
 <!--  -->
 <template>
   <div class="holding">
-
-<TabList />
+    <TabList />
     <div class="right">
       <div class="top">
         <el-breadcrumb separator="/">
@@ -13,6 +12,16 @@
       </div>
       <div class="conten">
         <div class="middle">
+          <ul class="title">
+            <li
+              :class="{ active: stateInd === index }"
+              @click="stateSelect(index)"
+              v-for="(item, index) in stateArr"
+              :key="index"
+            >
+              {{ item.txt }}({{ item.num }})
+            </li>
+          </ul>
           <div class="select">
             <span>藏品来源:</span>
             <el-select v-model="myData.sourceId" placeholder="请选择">
@@ -32,14 +41,17 @@
               style="width: 217px"
             ></el-input>
             <span>创建日期:</span>
-                <el-date-picker
-      v-model="time"
-      type="daterange"
-      range-separator="-"
-      start-placeholder="开始日期"
-      end-placeholder="结束日期">
-    </el-date-picker>
-            <el-button style="margin-left: 20px" @click="inquire">查询</el-button>
+            <el-date-picker
+              v-model="time"
+              type="daterange"
+              range-separator="-"
+              start-placeholder="开始日期"
+              end-placeholder="结束日期"
+            >
+            </el-date-picker>
+            <el-button style="margin-left: 20px" @click="inquire"
+              >查询</el-button
+            >
             <el-button type="primary" @click="addOne()">新增</el-button>
           </div>
           <!--表格 -->
@@ -65,11 +77,35 @@
               <el-table-column prop="status" label="状态" width="130">
               </el-table-column>
               <el-table-column label="操作" width="150">
-                <template #default='{row}'>
-                  <el-button type="text" v-if="row.status==='已完成'||row.status==='审核不通过'||row.status==='审核通过'" @click="mylook(row)">查看</el-button>
-                  <el-button type="text" v-if="row.status==='待办理'||row.status==='草稿中'||row.status==='待审核'" @click="editH0(row)">编辑</el-button>
-                  <el-button type="text" v-if="row.status==='待审核'||row.status==='草稿中'" @click="auditH0(row)">审核</el-button>
-                  <el-button type="text" @click="removeH0(row.id)" v-if="row.status!=='审核通过'">删除</el-button>
+                <template #default="{ row }">
+                  <el-button
+                    type="text"
+                    v-if="
+                      row.status === '已完成' ||
+                      row.status === '审核不通过' ||
+                      row.status === '已完成'
+                    "
+                    @click="mylook(row)"
+                    >查看</el-button
+                  >
+                  <el-button
+                    type="text"
+                    v-if="row.status === '待办理' || row.status === '待办理'"
+                    @click="editH0(row)"
+                    >编辑</el-button
+                  >
+                  <el-button
+                    type="text"
+                    v-if="row.status === '待审核'"
+                    @click="auditH0(row)"
+                    >审核</el-button
+                  >
+                  <el-button
+                    type="text"
+                    @click="removeH0(row.id)"
+                    v-if="row.status !== '已完成'"
+                    >删除</el-button
+                  >
                 </template>
               </el-table-column>
             </el-table>
@@ -77,9 +113,8 @@
           <!-- 分页器 -->
           <div class="paging">
             <el-pagination
-            @current-change='currentChange'
-            @size-change='sizeChange'
-            :page-sizes='[8,16,24,32]'
+              @current-change="currentChange"
+              @size-change="sizeChange"
               background
               layout="prev, pager, next,sizes,jumper"
               :total="total"
@@ -93,7 +128,7 @@
 </template>
 
 <script>
-import { oneAdd, getList, getGoodsFrom, removeH0, auditH0 } from '@/apis/holding'
+import { oneAdd, getList, getGoodsFrom, removeH0 } from '@/apis/holding'
 import TabList from '@/components/tabLeft.vue'
 export default {
   name: 'Holding0',
@@ -102,6 +137,15 @@ export default {
   },
   data () {
     return {
+      // 选择状态的变量
+      stateInd: 0,
+      stateArr: [
+        { txt: '全部', num: 0 },
+        { txt: '待审核', num: 0 },
+        { txt: '待办理', num: 0 },
+        { txt: '已完成', num: 0 },
+        { txt: '审核不通过', num: 0 }
+      ],
       // 数据总条数
       total: 0,
       // 获取列表数据字段
@@ -109,9 +153,10 @@ export default {
         startTime: '', // 开始时间
         endTime: '', // 结束时间
         pageNum: 1, // 起始页码,默认1为第一页
-        pageSize: 8, // 每页数量
+        pageSize: 10, // 每页数量
         searchKey: '', // 搜索条件
-        sourceId: null // 臧品来源Id
+        sourceId: null, // 臧品来源Id
+        status: ''
       },
       time: '',
       source: [],
@@ -130,6 +175,34 @@ export default {
   },
   // 方法集合
   methods: {
+    // 点击上面的状态切换
+    stateSelect (index) {
+      if (index !== this.stateInd) {
+        this.myData.pageNum = 1
+        // 点击待审核
+        if (index === 1) {
+          this.myData.status = 1
+          this.getList(this.myData)
+        } else if (index === 2) {
+          // 点击待办理
+          this.myData.status = 0
+          this.getList(this.myData)
+        } else if (index === 3) {
+          // 点击已完成
+          this.myData.status = 3
+          this.getList(this.myData)
+        } else if (index === 4) {
+          // 点击审核不通过
+          this.myData.status = 2
+          this.getList(this.myData)
+        } else if (index === 0) {
+          // 点击全部
+          this.myData.status = ''
+          this.getList(this.myData)
+        }
+      }
+      this.stateInd = index
+    },
     // 点击查询
     inquire () {
       this.myData.pageNum = 1
@@ -138,10 +211,29 @@ export default {
     // 分页器
     currentChange (val) {
       // console.log('当前页改变了', val)
+      // this.myData.sourceId = null
+      // this.myData.searchKey = ''
+      // this.time = []
+      // this.myData.endTime = ''
+      // this.myData.startTime = ''
       this.myData.pageNum = val
       this.getList(this.myData)
+      this.$nextTick(() => {
+        // 所有dom加载完毕之后---要执行的代码
+        setTimeout(() => {
+          if (this.tableData.length === 0) {
+            this.myData.pageNum = 1
+            this.getList(this.myData)
+          }
+        }, 100)
+      })
     },
     sizeChange (val) {
+      // this.myData.sourceId = null
+      // this.myData.searchKey = ''
+      // this.time = []
+      // this.myData.endTime = ''
+      // this.myData.startTime = ''
       // console.log('条数改变了', val)
       this.myData.pageSize = val
       this.getList(this.myData)
@@ -162,7 +254,7 @@ export default {
     },
     // 点击审核
     async auditH0 (val) {
-      if (val.status === '草稿中') await auditH0(val.id)
+      // if (val.status === '草稿中') await auditH0(val.id)
       this.$router.push({
         path: '/layout/holding0_audit',
         query: val
@@ -174,20 +266,22 @@ export default {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
-      }).then(async () => {
-        // 发请求,清空数据
-        await removeH0(id)
-        this.$message({
-          type: 'success',
-          message: '删除成功!'
+      })
+        .then(async () => {
+          // 发请求,清空数据
+          await removeH0(id)
+          this.$message({
+            type: 'success',
+            message: '删除成功!'
+          })
+          this.getList(this.myData)
         })
-        this.getList(this.myData)
-      }).catch(() => {
-        this.$message({
-          type: 'info',
-          message: '已取消.'
+        .catch(() => {
+          this.$message({
+            type: 'info',
+            message: '已取消.'
+          })
         })
-      })
     },
     // 时间处理----------------
     handleSelect (e) {
@@ -199,12 +293,18 @@ export default {
       this.myData.endTime = date[1]
     },
     gettime (data) {
-      const value = data.getFullYear() + '-' +
-      this.checkTime(data.getMonth() + 1) + '-' +
-      this.checkTime(data.getDate()) + ' ' +
-      this.checkTime(data.getHours()) + ':' +
-      this.checkTime(data.getMinutes()) + ':' +
-      this.checkTime(data.getSeconds())
+      const value =
+        data.getFullYear() +
+        '-' +
+        this.checkTime(data.getMonth() + 1) +
+        '-' +
+        this.checkTime(data.getDate()) +
+        ' ' +
+        this.checkTime(data.getHours()) +
+        ':' +
+        this.checkTime(data.getMinutes()) +
+        ':' +
+        this.checkTime(data.getSeconds())
       return value
     },
     checkTime (i) {
@@ -218,12 +318,13 @@ export default {
       const res = await getList(data)
       this.total = res.data.total
       this.tableData = res.data.list
-      this.tableData.forEach(v => {
+      this.tableData.forEach((v) => {
         v.sourceId = this.mySource(v.sourceId)
         v.status = this.myState(v.status)
       })
       // console.log(6666, res.data.list)
     },
+
     // 点击新增
     async addOne () {
       // 从主页面点击第一层新增
@@ -242,10 +343,28 @@ export default {
     // 获取藏品来源
     const res = await getGoodsFrom()
     this.source = res.data
+    this.source.unshift({ id: '', name: '全部' })
   },
   // 生命周期 - 挂载完成(可以访问DOM元素)
-  mounted () {
+  async mounted () {
     this.tabInd = this.INtabInd
+    // 进页面拿到所有数据
+    const res = await getList({ ...this.myData, pageSize: 99999 })
+    this.stateArr[0].num = res.data.list.length
+    let num1 = 0
+    let num2 = 0
+    let num3 = 0
+    let num4 = 0
+    res.data.list.forEach(v => {
+      if (v.status === 1) num1++
+      if (v.status === 0) num2++
+      if (v.status === 3) num3++
+      if (v.status === 2) num4++
+    })
+    this.stateArr[1].num = num1
+    this.stateArr[2].num = num2
+    this.stateArr[3].num = num3
+    this.stateArr[4].num = num4
   },
   beforeCreate () {}, // 生命周期 - 创建之前
   beforeMount () {}, // 生命周期 - 挂载之前
@@ -258,7 +377,7 @@ export default {
 </script>
 <style lang='less' scoped>
 .holding {
-    /deep/#mytitle>span{
+  /deep/#mytitle > span {
     font-weight: 800;
   }
 
@@ -280,6 +399,26 @@ export default {
       width: 100%;
       height: 829px;
       .middle {
+        .title {
+          height: 60px;
+          border-bottom: 1px solid #ccc;
+          margin: 0 25px;
+          display: flex;
+          align-items: center;
+          color: black;
+          .active {
+            color: #409eff;
+            border-bottom: 2px solid #409eff;
+          }
+          li {
+            height: 60px;
+            line-height: 60px;
+            padding: 0 15px;
+            text-align: center;
+            margin-left: 40px;
+            cursor: pointer;
+          }
+        }
         position: relative;
         width: 100%;
         height: 100%;
@@ -292,9 +431,14 @@ export default {
           }
         }
         .table {
-          max-height: 640px;
-          overflow: auto;
+          max-height: 580px;
+          max-width: 1710px;
+          // overflow: auto;
           padding: 24px;
+          /deep/.el-table__body-wrapper{
+            max-height: 510px;
+            overflow-y: auto;
+          }
         }
         .paging {
           position: absolute;

+ 27 - 2
src/views/holding/holding0_add.vue

@@ -97,7 +97,7 @@
         <!-- 最下面的2个按钮 -->
         <div class="bot_btn">
             <el-button type="primary" @click="submit(mydata.id)">提 交</el-button>
-             <el-button @click="$router.go(-1)">返 回</el-button>
+             <el-button @click="goBack(mydata.id)">返 回</el-button>
         </div>
       </div>
     </div>
@@ -140,7 +140,8 @@ export default {
         people: '',
         sourceId: 1, // 藏品来源
         unit: '',
-        description: ''
+        description: '',
+        status: null
       },
       // 表单验证
       rules: {
@@ -163,8 +164,32 @@ export default {
   watch: {},
   // 方法集合
   methods: {
+    // 点击返回
+    goBack (id) {
+      this.$confirm('您需要保存这条数据吗?', '提示', {
+        confirmButtonText: '保存',
+        cancelButtonText: '放弃',
+        type: 'warning'
+      }).then(async () => {
+        // 发请求
+        this.fromData.status = null
+        await addSubmit({ ...this.fromData, id: this.mydata.id })
+        this.$router.push('/layout/holding0')
+        this.$message({
+          type: 'success',
+          message: '保存成功!'
+        })
+      }).catch(() => {
+        this.$router.push('/layout/holding0')
+        this.$message({
+          type: 'info',
+          message: '放弃保存.'
+        })
+      })
+    },
     // 点击提交
     async submit (id) {
+      this.fromData.status = 1
       const res = await addSubmit({ ...this.fromData, id: this.mydata.id })
       if (res.code === 0) {
         this.$message.success('提交成功')

+ 41 - 8
src/views/holding/holding1.vue

@@ -83,7 +83,7 @@
 <script>
 import TabList from '@/components/tabLeft.vue'
 export default {
-  name: 'Holding0',
+  name: 'Holding1',
   components: { TabList },
   data () {
     return {
@@ -93,7 +93,8 @@ export default {
         { txt: '全部', num: 356 },
         { txt: '待审核', num: 35 },
         { txt: '待办理', num: 35 },
-        { txt: '已完成', num: 35 }
+        { txt: '已完成', num: 35 },
+        { txt: '审核不通过', num: 35 }
       ],
       type: '',
       time: '',
@@ -115,16 +116,43 @@ export default {
   // 监听属性 类似于data概念
   computed: {},
   // 监控data中的数据变化
-  watch: {},
+  watch: {
+    // 处理时间
+    time (val) {
+      this.handleSelect(val)
+    }
+  },
   // 方法集合
   methods: {
-
+    // 时间处理----------------
+    handleSelect (e) {
+      const date = []
+      for (const i in e) {
+        date.push(this.gettime(e[i]))
+      }
+      // this.myData.startTime = date[0]
+      // this.myData.endTime = date[1]
+    },
+    gettime (data) {
+      const value = data.getFullYear() + '-' +
+      this.checkTime(data.getMonth() + 1) + '-' +
+      this.checkTime(data.getDate()) + ' ' +
+      this.checkTime(data.getHours()) + ':' +
+      this.checkTime(data.getMinutes()) + ':' +
+      this.checkTime(data.getSeconds())
+      return value
+    },
+    checkTime (i) {
+      if (i < 10) {
+        i = '0' + i
+      }
+      return i
+    }
   },
   // 生命周期 - 创建完成(可以访问当前this实例)
   created () {},
   // 生命周期 - 挂载完成(可以访问DOM元素)
   mounted () {
-    this.tabInd = this.INtabInd
   },
   beforeCreate () {}, // 生命周期 - 创建之前
   beforeMount () {}, // 生命周期 - 挂载之前
@@ -172,7 +200,7 @@ export default {
           li {
             height: 60px;
             line-height: 60px;
-            width: 120px;
+            padding: 0 15px;
             text-align: center;
             margin-left: 40px;
             cursor: pointer;
@@ -190,9 +218,14 @@ export default {
           }
         }
         .table {
-          max-height: 640px;
-          overflow: auto;
+          max-height: 580px;
+          max-width: 1710px;
+          // overflow: auto;
           padding: 24px;
+          /deep/.el-table__body-wrapper{
+            max-height: 510px;
+            overflow-y: auto;
+          }
         }
         .paging {
           position: absolute;

+ 11 - 6
src/views/holding/holding2.vue

@@ -12,7 +12,7 @@
       </div>
       <div class="conten">
         <div class="middle">
-                    <ul class="title">
+          <ul class="title">
             <li :class="{active:stateInd===index}" @click="stateInd=index" v-for="(item,index) in stateArr" :key="index">{{item.txt}}({{item.num}})</li>
           </ul>
 
@@ -93,7 +93,8 @@ export default {
         { txt: '全部', num: 356 },
         { txt: '待审核', num: 35 },
         { txt: '待办理', num: 35 },
-        { txt: '已完成', num: 35 }
+        { txt: '已完成', num: 35 },
+        { txt: '审核不通过', num: 35 }
       ],
       type: '',
       time: '',
@@ -124,7 +125,6 @@ export default {
   created () {},
   // 生命周期 - 挂载完成(可以访问DOM元素)
   mounted () {
-    this.tabInd = this.INtabInd
   },
   beforeCreate () {}, // 生命周期 - 创建之前
   beforeMount () {}, // 生命周期 - 挂载之前
@@ -171,7 +171,7 @@ export default {
           li {
             height: 60px;
             line-height: 60px;
-            width: 120px;
+            padding: 0 15px;
             text-align: center;
             margin-left: 40px;
             cursor: pointer;
@@ -189,9 +189,14 @@ export default {
           }
         }
         .table {
-          max-height: 640px;
-          overflow: auto;
+          max-height: 580px;
+          max-width: 1710px;
+          // overflow: auto;
           padding: 24px;
+          /deep/.el-table__body-wrapper{
+            max-height: 510px;
+            overflow-y: auto;
+          }
         }
         .paging {
           position: absolute;

+ 2 - 2
src/views/layout/index.vue

@@ -33,9 +33,9 @@
       </div>
       <div class="right">
         <div class="img">
-          <img src="@/assets/img/user.png" alt="" />
+          <img src="@/assets/img/user1.jpg" alt="" />
         </div>
-        <span>{{userData.nickName}}</span>
+        <span>{{userData.realName}}</span>
         <span class="loginOut" @click="loginOut">退出登录</span>
       </div>
     </div>