hejianhao
2025-05-09 a982b6de0096cebfe51629c34d77b111bdee2f79
登录
9个文件已修改
220 ■■■■ 已修改文件
culture/src/layouts/components/HeaderNav.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
culture/src/router/index.js 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
culture/src/utils/request.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
culture/src/views/login/index.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
culture/src/views/login/service.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
culture/src/views/projectList/index.vue 108 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
culture/src/views/projectList/service.js 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
culture/vue.config.js 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
laboratory/src/views/login/index.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
culture/src/layouts/components/HeaderNav.vue
@@ -57,7 +57,7 @@
    // 退出登录
    outLogin() {
      sessionStorage.clear()
      this.$router.replace({ path: "/login" });
      this.$router.replace({ path: "/" });
    },
    // 关闭标签
    closeTag(tag) {
@@ -73,23 +73,26 @@
    },
    // 跳转标签
    goTag(tag) {
      this.$router.push(tag.path)
      this.$router.push({
        path: tag.path,
        query: tag.query
      })
    },
    handleWheel(e) {
      if (this.scrollTimer) {
        this.scrollAmount += e.deltaY;
        return;
      }
      const container = e.currentTarget;
      this.scrollAmount = e.deltaY;
      const scroll = () => {
        container.scrollLeft += this.scrollAmount * 1.2; // 增加滚动速度
        this.scrollAmount = 0;
        this.scrollTimer = null;
      };
      this.scrollTimer = setTimeout(scroll, 8); // 减少延迟时间
    }
  },
culture/src/router/index.js
@@ -26,7 +26,7 @@
const routes = [
    {
        path: "/",
        redirect: "/projectList/list",
        redirect: "/login",
    },
    {
        path: "/login",
@@ -48,7 +48,7 @@
                path: "list",
                name: "ProjectList",
                meta: {
                    title: "项目组管理",
                    title: "菌种库项目组管理",
                },
                component: () => import("../views/projectList"),
            },
@@ -56,7 +56,7 @@
                path: "addProject",
                name: "AddProject",
                meta: {
                    title: "新增项目组",
                    title: "新增菌种库项目组",
                    hide: true,
                    keepAlive: true,
                },
@@ -345,17 +345,28 @@
    document.title = to.meta.title || '实验室流程';
    // 登录验证
    // if (to.path === "/login") {
    //     sessionStorage.removeItem('userInfo')
    //     next()
    // } else if (!sessionStorage.getItem('userInfo')) {
    //     next('/login')
    // } else {
    //     // 判断是否拥有要跳转菜单权限
    //     let menus = store.state.menus
    //     if (to.meta.hasOwnProperty('privilege') && !menus.includes(to.meta.privilege)) {
    //         return
    //     }
    // 排除登录页的校验
    if (to.path === "/login") {
        if (sessionStorage.getItem('token')) {
            next('/projectList');  // 已登录状态访问登录页时重定向到系统首页
            return;
        }
        next();
        return;
    }
    // 登录状态校验
    const isAuthenticated = sessionStorage.getItem('token');
    // if (!isAuthenticated) {
    //     next('/login');  // 未登录用户重定向到登录页
    //     return;
    // }
    // 判断是否拥有要跳转菜单权限
    let menus = store.state.menus
    if (to.meta.hasOwnProperty('privilege') && !menus.includes(to.meta.privilege)) {
        return
    }
    // 设置标签列表
    if (!to.meta.hide || !to.meta.oneself) {
@@ -367,7 +378,8 @@
            const tagInfo = {
                path: to.path,
                name: to.name,
                meta: to.meta
                meta: to.meta,
                query: to.query,
            }
            tagList.push(tagInfo)
            sessionStorage.setItem('tagList', JSON.stringify(tagList))
@@ -388,7 +400,6 @@
    }
    next()
    // }
});
export default router;
culture/src/utils/request.js
@@ -60,7 +60,8 @@
      if (!res.data) {
        return Promise.resolve({})
      }
      return Promise.resolve(res.data)
      console.log('res', res.data.data || res.data)
      return Promise.resolve(res.data.data || res.data)
    } else {
      if (res.data.code == 103 || res.data.code == 401) {
        Message({
culture/src/views/login/index.vue
@@ -68,11 +68,20 @@
    // 添加窗口大小变化监听器
    window.addEventListener('resize', this.handleResize)
  },
  mounted() {
    document.addEventListener("keydown", this.handleKeyDown);
  },
  destroyed() {
    // 组件销毁时移除监听器
    window.removeEventListener('resize', this.handleResize)
    document.removeEventListener("keydown", this.handleKeyDown);
  },
  methods: {
    handleKeyDown(event) {
      if (event.key === 'Enter') {
        this.login()
      }
    },
    // 添加处理窗口大小变化的方法
    handleResize() {
      this.viewWidth = window.innerWidth
@@ -90,7 +99,7 @@
      loginReq(this.loginForm).then(res => {
        sessionStorage.setItem('token', res.token)
        sessionStorage.setItem('userInfo', JSON.stringify(res.userInfo.user))
        this.$router.push('/')
        this.$router.push('/projectList')
      })
    }
  }
culture/src/views/login/service.js
@@ -2,5 +2,5 @@
// 登录
export const loginReq = (data) => {
    return axios.post('/login', { ...data })
    return axios.post('/api/login', { ...data })
}
culture/src/views/projectList/index.vue
@@ -5,10 +5,10 @@
            <template #search>
                <el-form label-width="140px" inline>
                    <el-form-item label="项目组名称:">
                        <el-input v-model="queryForm.name" placeholder="请输入"></el-input>
                        <el-input v-model="queryForm.teamName" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="项目负责人:">
                        <el-input v-model="queryForm.name" placeholder="请输入"></el-input>
                        <el-input v-model="queryForm.personCharge" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="创建日期:">
                        <el-date-picker v-model="queryForm.createdDate" type="daterange" range-separator="至"
@@ -16,32 +16,32 @@
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item class="search-btn-box">
                        <el-button>重置</el-button>
                        <el-button type="primary">查询</el-button>
                        <el-button @click="reset">重置</el-button>
                        <el-button type="primary" @click="search">查询</el-button>
                    </el-form-item>
                </el-form>
            </template>
            <template #setting>
                <el-button @click="handleAddProject" class="el-icon-plus" type="primary">
                <el-button @click="handleProject('add')" class="el-icon-plus" type="primary">
                    新增菌种库项目组</el-button>
            </template>
            <template #table>
                <el-table-column prop="name" label="菌种库项目组名称" />
                <el-table-column prop="age" label="菌种库项目负责人" />
                <el-table-column prop="age" label="项目组成员" />
                <el-table-column prop="age" label="项目创建时间" />
                <el-table-column prop="age" label="状态">
                <el-table-column prop="teamName" label="菌种库项目组名称" />
                <el-table-column prop="personCharge" label="菌种库项目负责人" />
                <el-table-column prop="staffName" label="项目组成员" />
                <el-table-column prop="createTime" label="项目创建时间" />
                <el-table-column prop="status" label="状态">
                    <template #default="{ row }">
                        <el-tag v-if="row.status == 1" type="success">正常运作</el-tag>
                        <el-tag v-else type="danger">已封存</el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="age" label="操作">
                <el-table-column label="操作">
                    <template #default="{ row }">
                        <el-button type="text" @click="handleChangeStatus(row, 1)">封存</el-button>
                        <el-button type="text" @click="handleChangeStatus(row, 0)">解封</el-button>
                        <el-button type="text">编辑</el-button>
                        <el-button type="text">详情</el-button>
                        <el-button v-if="row.status == 1" type="text" @click="handleChangeStatus(row, 2)">封存</el-button>
                        <el-button v-if="row.status == 2" type="text" @click="handleChangeStatus(row, 1)">解封</el-button>
                        <el-button type="text" @click="handleProject('edit', row.id)">编辑</el-button>
                        <el-button type="text" @click="handleProject('detail', row.id)">详情</el-button>
                        <el-button type="text" @click="handleDel(row)">删除</el-button>
                    </template>
                </el-table-column>
@@ -54,7 +54,7 @@
</template>
<script>
import { getProjectList } from './service'
import { getProjectList, changeStatus, deleteProject } from './service'
export default {
    name: 'ProjectList',
    data() {
@@ -76,20 +76,43 @@
        this.getList()
    },
    methods: {
        handleAddProject() {
            this.$router.push({
                path: '/projectList/addProject'
            })
        handleProject(type, id) {
            if (type == 'add') {
                this.$router.push({
                    path: '/projectList/addProject'
                })
                return
            }
            if (type == 'edit') {
                this.$router.push({
                    path: '/projectList/editProject',
                    query: {
                        id
                    }
                })
                return
            }
            if (type == 'detail') {
                this.$router.push({
                    path: '/projectList/detailProject',
                    query: {
                        id
                    }
                })
                return
            }
        },
        handleDel(row) {
            this.rowId = row.id
            this.showDelConfirm = true
        },
        handleDelConfirm() {
            this.showDelConfirm = false
            this.msgsuccess('删除成功')
            this.rowId = ''
            this.getList()
            deleteProject({ id: this.rowId }).then(res => {
                this.showDelConfirm = false
                this.msgsuccess('删除成功')
                this.rowId = ''
                this.getList()
            })
        },
        handleChangeStatus(row, status) {
            this.rowId = row.id
@@ -98,12 +121,14 @@
            this.changeStatus = true
        },
        handleChangeStatusConfirm() {
            this.changeStatus = false
            this.msgsuccess('操作成功')
            this.rowId = ''
            this.changeStatusTitle = ''
            this.changeStatusTip = ''
            this.getList()
            changeStatus({ id: this.rowId, status: this.status }).then(res => {
                this.changeStatus = false
                this.msgsuccess('操作成功')
                this.rowId = ''
                this.changeStatusTitle = ''
                this.changeStatusTip = ''
                this.getList()
            })
        },
        handleCurrentChange(page) {
            this.queryForm.pageNum = page
@@ -114,9 +139,28 @@
            this.getList()
        },
        getList() {
            getProjectList(this.queryForm).then(res => {
                console.log(res);
            let obj = {
                ...this.queryForm
            }
            if (obj.createdDate) {
                obj.startTime = moment(obj.createdDate[0]).format('YYYY-MM-DD')
                obj.endTime = moment(obj.createdDate[1]).format('YYYY-MM-DD')
                delete obj.createdDate
            }
            getProjectList(obj).then(res => {
                this.tableData = res.data.records
                this.total = res.data.total
            })
        },
        reset() {
            this.queryForm = {
                pageSize: 10,
                pageNum: 1
            }
            this.getList()
        },
        search() {
            this.getList()
        }
    }
}
culture/src/views/projectList/service.js
@@ -2,5 +2,30 @@
// 列表
export const getProjectList = (data) => {
    return axios.post('/api/t-project-team/pageList', { ...data })
}
    return axios.post('/t_project_team/api/pageList', { ...data })
}
// 新增
export const addProject = (data) => {
    return axios.post('/t_project_team/api/add', { ...data })
}
// 编辑
export const editProject = (data) => {
    return axios.post('/t_project_team/api/update', { ...data })
}
// 详情
export const getProjectDetail = (data) => {
    return axios.get(`/t_project_team/open/getDetailById?id=${data.id}`)
}
// 修改项目组状态
export const changeStatus = (data) => {
    return axios.post('/t_project_team/api/upAndDown', { ...data })
}
// 删除项目组
export const deleteProject = (data) => {
    return axios.delete(`/t_project_team/open/deleteById?id=${data.id}`)
}
culture/vue.config.js
@@ -10,13 +10,21 @@
        disableHostCheck: true, //禁用主机检查 
        proxy: {
            "/api": { // 设置以什么前缀开头的请求用来代理
                target: "http://192.168.110.34:8081", //要访问的跨域的域名
                target: "http://192.168.110.64:8081", //要访问的跨域的域名
                secure: false, // 使用的是http协议则设置为false,https协议则设置为true
                changOrigin: true, //开启代理
                pathRewrite: {
                    "^/api": "/api",
                },
            },
            "/": { // 设置以什么前缀开头的请求用来代理
                target: "http://192.168.110.64:8081", //要访问的跨域的域名
                secure: false, // 使用的是http协议则设置为false,https协议则设置为true
                changOrigin: true, //开启代理
                pathRewrite: {
                    "^/": "/",
                },
            },
        },
    },
    configureWebpack: {
laboratory/src/views/login/index.vue
@@ -96,7 +96,6 @@
        return
      }
      loginReq(this.loginForm).then(res => {
        console.log('111111', res)
        sessionStorage.setItem('token', res.token)
        sessionStorage.setItem('userInfo', JSON.stringify(res.userInfo.user))
        this.$router.push('/system')