| | |
| | | // 退出登录 |
| | | outLogin() { |
| | | sessionStorage.clear() |
| | | this.$router.replace({ path: "/login" }); |
| | | this.$router.replace({ path: "/" }); |
| | | }, |
| | | // 关闭标签 |
| | | closeTag(tag) { |
| | |
| | | }, |
| | | // 跳转标签 |
| | | 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); // 减少延迟时间 |
| | | } |
| | | }, |
| | |
| | | const routes = [ |
| | | { |
| | | path: "/", |
| | | redirect: "/projectList/list", |
| | | redirect: "/login", |
| | | }, |
| | | { |
| | | path: "/login", |
| | |
| | | path: "list", |
| | | name: "ProjectList", |
| | | meta: { |
| | | title: "项目组管理", |
| | | title: "菌种库项目组管理", |
| | | }, |
| | | component: () => import("../views/projectList"), |
| | | }, |
| | |
| | | path: "addProject", |
| | | name: "AddProject", |
| | | meta: { |
| | | title: "新增项目组", |
| | | title: "新增菌种库项目组", |
| | | hide: true, |
| | | keepAlive: true, |
| | | }, |
| | |
| | | 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) { |
| | |
| | | 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)) |
| | |
| | | } |
| | | |
| | | next() |
| | | // } |
| | | }); |
| | | |
| | | export default router; |
| | |
| | | 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({ |
| | |
| | | // 添加窗口大小变化监听器 |
| | | 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 |
| | |
| | | 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') |
| | | }) |
| | | } |
| | | } |
| | |
| | | |
| | | // 登录 |
| | | export const loginReq = (data) => { |
| | | return axios.post('/login', { ...data }) |
| | | return axios.post('/api/login', { ...data }) |
| | | } |
| | |
| | | <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="至" |
| | |
| | | </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> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { getProjectList } from './service' |
| | | import { getProjectList, changeStatus, deleteProject } from './service' |
| | | export default { |
| | | name: 'ProjectList', |
| | | data() { |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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() |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // 列表 |
| | | 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}`) |
| | | } |
| | |
| | | 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: { |
| | |
| | | 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') |