From edbe2964e959a334e1d9e12717bf854d89d25c92 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期三, 15 六月 2022 21:01:26 +0800
Subject: [PATCH] 1.cookie带到接口上
---
src/utils/request.js | 5
src/views/jcsz/zzjg.vue | 170 ++++++++++++++++++++++++++++-----
.env.development | 3
src/store/modules/user.js | 1
vue.config.js | 4
src/api/user.js | 7 +
src/layout/components/Navbar.vue | 31 +++++
.env.production | 3
src/layout/components/AppMain.vue | 2
src/layout/components/Sidebar/index.vue | 10 +
src/utils/auth.js | 40 ++++----
src/router/index.js | 2
12 files changed, 216 insertions(+), 62 deletions(-)
diff --git a/.env.development b/.env.development
index 849e0a2..2c7f004 100644
--- a/.env.development
+++ b/.env.development
@@ -2,5 +2,6 @@
ENV = 'development'
# base api
-VUE_APP_BASE_API = 'http://121.196.36.24:8001/api/'
+VUE_APP_BASE_API = '/api/'
+#VUE_APP_BASE_API = 'http://47.96.97.237/API/'
diff --git a/.env.production b/.env.production
index 93546cd..6dfae28 100644
--- a/.env.production
+++ b/.env.production
@@ -2,6 +2,5 @@
ENV = 'production'
# base api
-#VUE_APP_BASE_API = './'
-VUE_APP_BASE_API = 'http://121.196.36.24:8001/api/'
+VUE_APP_BASE_API = '/apis/'
diff --git a/src/api/user.js b/src/api/user.js
index 48a69de..371bcfe 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -1,5 +1,12 @@
import request from '@/utils/request'
+// export function login(data) {
+// return request({
+// url: 'Web/GetUser',
+// method: 'get',
+// params: data
+// })
+// }
export function login(data) {
return request({
url: 'Login/LoginSave',
diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue
index 8f4c279..766bb6d 100644
--- a/src/layout/components/AppMain.vue
+++ b/src/layout/components/AppMain.vue
@@ -26,7 +26,7 @@
<style lang="scss" scoped>
.app-main {
/* 50= navbar 50 */
- min-height: calc(100vh - 90px);
+ min-height: calc(100vh - 100px);
width: 100%;
position: relative;
overflow: hidden;
diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index aeb09b7..79c30ae 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -7,8 +7,13 @@
<div class="right-menu">
<el-dropdown class="avatar-container" trigger="click">
<div class="avatar-wrapper">
- <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
- <i class="el-icon-caret-bottom" />
+ <!-- <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">-->
+ <div style="display: flex;align-items: center;margin-top: -5px">
+ <div class="headerImg"><i class="el-icon-user" /></div>
+ <div class="headerName">{{ username }}</div>
+ </div>
+
+ <!-- <i class="el-icon-caret-bottom" />-->
</div>
<el-dropdown-menu slot="dropdown" class="user-dropdown">
<!-- <router-link to="/">-->
@@ -22,6 +27,9 @@
<!-- <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">-->
<!-- <el-dropdown-item>Docs</el-dropdown-item>-->
<!-- </a>-->
+ <!-- <el-dropdown-item @click.native="logout">-->
+ <!-- <span style="display:block;">淇敼瀵嗙爜</span>-->
+ <!-- </el-dropdown-item>-->
<!-- divided-->
<el-dropdown-item @click.native="logout">
<span style="display:block;">閫�鍑�</span>
@@ -36,6 +44,7 @@
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
+import { getCookie } from '@/utils/auth'
export default {
components: {
@@ -47,6 +56,14 @@
'sidebar',
'avatar'
])
+ },
+ created() {
+ this.username = getCookie('admin')
+ },
+ data() {
+ return {
+ username: ''
+ }
},
methods: {
toggleSideBar() {
@@ -118,10 +135,18 @@
.avatar-wrapper {
margin-top: 5px;
position: relative;
+ cursor: pointer;
+ .headerImg{
+ margin: 5px;
+ }
+
+ .headerName{
+ font-weight: bolder;
+ }
.user-avatar {
cursor: pointer;
- width: 40px;
+ width: 60px;
height: 40px;
border-radius: 10px;
}
diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue
index 8e366d8..c9b7c99 100644
--- a/src/layout/components/Sidebar/index.vue
+++ b/src/layout/components/Sidebar/index.vue
@@ -37,6 +37,7 @@
import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'
import { LoginMenu } from '@/api/user'
+import axios from 'axios'
export default {
components: { SidebarItem, Logo },
@@ -55,7 +56,8 @@
// children: [
// { name: '缁勭粐鏋舵瀯' },
// { name: '瑙掕壊娓呭崟' },
- // { name: '鐢ㄦ埛娓呭崟' }
+ // { name: '鐢ㄦ埛娓呭崟' }color: $main_color !important;
+
// ]
// },
// {
@@ -68,8 +70,14 @@
// }
// ]
// this.routers = arr
+ console.log(document.cookie, 777)
+
const res = await LoginMenu()
console.log(res, 999)
+
+ // axios.get('http://121.196.36.24:8001/api/Login/LoginSave?username=Admin&password=123456').then(res => {
+ // console.log(res, 11)
+ // })
},
computed: {
...mapGetters([
diff --git a/src/router/index.js b/src/router/index.js
index fed8437..a40dae4 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -62,7 +62,7 @@
path: 'index',
name: 'index',
component: () => import('@/views/xtsy/index'),
- meta: { title: '绯荤粺棣栭〉', icon: 'dashboard' }
+ meta: { title: '绯荤粺棣栭〉', icon: 'dashboard', affix: true }
}]
},
{
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index a2ae53f..204eab3 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -33,6 +33,7 @@
const { username, password } = userInfo
return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => {
+ // login({ UserName: '001', PassWord: 123, HOrgName: 1 }).then(response => {
const { data: res } = response
setCookie('admin', res.username)
diff --git a/src/utils/auth.js b/src/utils/auth.js
index e9bdf27..6249c38 100644
--- a/src/utils/auth.js
+++ b/src/utils/auth.js
@@ -14,32 +14,32 @@
return Cookies.remove(TokenKey)
}
-export function getCookie(c_name) {
+export function getCookie(key) {
// document.cookie = escape(key) + ';path=/'
- if (document.cookie.length > 0) {
- let c_start = document.cookie.indexOf(c_name + '=')
- if (c_start != -1) {
- c_start = c_start + c_name.length + 1
- let c_end = document.cookie.indexOf(';', c_start)
- if (c_end == -1) {
- c_end = document.cookie.length
- }
- return unescape(document.cookie.substring(c_start, c_end))
- }
- }
- return ''
- // return Cookies.get(key)
+ // if (document.cookie.length > 0) {
+ // let c_start = document.cookie.indexOf(c_name + '=')
+ // if (c_start != -1) {
+ // c_start = c_start + c_name.length + 1
+ // let c_end = document.cookie.indexOf(';', c_start)
+ // if (c_end == -1) {
+ // c_end = document.cookie.length
+ // }
+ // return unescape(document.cookie.substring(c_start, c_end))
+ // }
+ // }
+ // return ''
+ return Cookies.get(key)
}
export function setCookie(key, value) {
- var date = new Date()
- date.setSeconds(date.getSeconds() + 10000)
- document.cookie = key + '=' + escape(value) + '; expires=' + date.toGMTString() + ';path=/'
+ // var date = new Date()
+ // date.setSeconds(date.getSeconds() + 10000)
+ // document.cookie = key + '=' + escape(value) + '; expires=' + date.toGMTString() + ';path=/'
- // return Cookies.set(key, value)
+ return Cookies.set(key, value)
}
export function removeCookie(key) {
- setCookie(key, '', -1)
- // return Cookies.remove(key)
+ // setCookie(key, '', -1)
+ return Cookies.remove(key)
}
diff --git a/src/utils/request.js b/src/utils/request.js
index aa096f6..a36953c 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -3,12 +3,13 @@
import store from '@/store'
import { getCookie, getToken } from '@/utils/auth'
// create an axios instance
+
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
withCredentials: true, // send cookies when cross-domain requests
timeout: 5000 // request timeout
-
})
+// axios.defaults.withCredentials = true
// request interceptor
service.interceptors.request.use(
@@ -21,7 +22,7 @@
// please modify it according to the actual situation
// config.headers['X-Token'] = getToken()
// config.headers['Authorization'] = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
- config.headers['Cookie'] = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
+ // config.headers['Cookie'] = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
// document.cookie = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
// document.cookie = 'admin'
}
diff --git a/src/views/jcsz/zzjg.vue b/src/views/jcsz/zzjg.vue
index 4a057bb..0e91ae2 100644
--- a/src/views/jcsz/zzjg.vue
+++ b/src/views/jcsz/zzjg.vue
@@ -1,10 +1,10 @@
<template>
<div>
- <div class="body" style="background-color: #ffffff; padding: 20px 10px 0 20px;">
+ <div class="body" style="background-color: #ffffff; padding: 20px 10px 0 20px;" :style="{height:mainHeight+'px'}">
<div style="margin-bottom: 20px;display: flex">
- <el-button type="primary" icon="el-icon-circle-plus-outline">鏂板</el-button>
- <el-button type="primary" icon="el-icon-delete">淇敼</el-button>
- <el-button type="primary" icon="el-icon-delete">鍒犻櫎</el-button>
+ <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
+ <el-button type="primary" icon="el-icon-delete" @click="edit('edit')">淇敼</el-button>
+ <el-button type="primary" icon="el-icon-delete" @click="del">鍒犻櫎</el-button>
</div>
<div style="display: flex;border: 1px solid #eee">
@@ -22,7 +22,7 @@
<el-tree
ref="tree"
- style="margin-left: 10px;overflow-y: scroll;height: 230px"
+ :style="{marginLeft: 10+'px',overflowY: 'scroll',height:(tableHeight-140)+'px'}"
:icon-class="iconClass"
:data="treeData"
default-expand-all
@@ -33,32 +33,11 @@
@node-click="nodeClick"
/>
</div>
- <el-table
- v-if="false"
- :data="tableTreeData"
- border
- style="flex: 0.22"
- :span-method="spanMethod"
- :header-cell-style="headerCellStyle"
- >
- <el-table-column
- label="缁勭粐鍒嗙被"
- width="300"
- prop="zzfl"
- :resizable="false"
- >
- <template slot-scope="{row}">
-
- <el-input v-model="filterText" placeholder="璇疯緭鍏ュ唴瀹�" />
-
- </template>
- </el-table-column>
- </el-table>
<el-table
:data="tableData"
border
- style="width: 72%"
+ :style="{width: 72+'%',height:tableHeight+'px'}"
:header-cell-style="this.$headerCellStyle"
:cell-style="this.$cellStyle"
>
@@ -113,11 +92,53 @@
align="right"
layout="prev, pager, next,sizes"
popper-class="select_bottom"
- style="padding: 0;margin-top: 100px"
/>
<!-- @pagination="getManageList"-->
</div>
+
+ <el-dialog
+ :title="operation==='add'?'娣诲姞':'淇敼'"
+ :visible.sync="dialogVisible"
+ width="50%"
+ top="15vh"
+ @closed="handleClose"
+ >
+ <el-form ref="dialogForm" :model="dialogForm" label-width="80px">
+ <el-form-item label="缁勭粐绫诲瀷" required>
+ <el-radio-group v-model="dialogForm.zzlx" style="display: flex;align-items: end;height: 29px;">
+ <el-radio :label="1">宸ュ巶</el-radio>
+ <el-radio :label="2">閮ㄩ棬</el-radio>
+ <el-radio :label="3">杞﹂棿</el-radio>
+ <el-radio :label="4">绉戝</el-radio>
+ <el-radio :label="5">鐢熶骇绾�</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ <el-form-item label="缁勭粐缂栫爜" required>
+ <el-input v-model="dialogForm.zzbm" style="width: 220px" />
+ </el-form-item>
+ <el-form-item label="缁勭粐鍚嶇О" required>
+ <el-input v-model="dialogForm.zzmc" style="width: 220px" />
+ </el-form-item>
+ <el-form-item label="涓婄骇鍗曚綅" required>
+ <!-- <el-input v-model="dialogForm.sjdw" />-->
+ <el-select v-model="dialogForm.sjdw" style="width: 220px" placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="item in sjdw"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ />
+ </el-select>
+ </el-form-item>
+ </el-form>
+ <span slot="footer" class="dialog-footer">
+ <div class="footerButton">
+ <el-button @click="dialogVisibleCancel">鍙� 娑�</el-button>
+ <el-button type="primary" @click="dialogVisibleConfirm">纭� 瀹�</el-button>
+ </div>
+ </span>
+ </el-dialog>
</div>
</template>
@@ -131,6 +152,8 @@
},
data() {
return {
+ mainHeight: 0,
+ tableHeight: 0,
form: {
pageNum: 1, // 绗嚑椤�
pageSize: 10 // 姣忛〉澶氬皯鏉�
@@ -146,6 +169,16 @@
{ id: 7, zzbm: 'OD', zzmc: '閿�鍞儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin4', cjsj: '2022-04-15 10:12:10' },
{ id: 8, zzbm: 'OD', zzmc: '閿�鍞儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin4', cjsj: '2022-04-15 10:12:10' },
{ id: 9, zzbm: 'FC', zzmc: '宸ョ▼閮�', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-16 12:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
+ { id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' },
{ id: 10, zzbm: 'CM', zzmc: '寮�鍙戦儴', zzlx: '閮ㄩ棬', sjdw: '澶ц繛鎭掔ゥ', cjry: 'Admin3', cjsj: '2022-04-17 15:10:10' }
],
filterText: '',
@@ -195,7 +228,21 @@
children: 'children',
label: 'label'
},
- iconClass: 'el-icon-caret-right'
+ iconClass: 'el-icon-caret-right',
+ dialogVisible: true,
+ dialogForm: {
+ zzlx: '',
+ zzbm: '',
+ zzmc: '',
+ sjdw: ''
+ },
+ sjdw: [
+ // { value: '001', label: 'test1' },
+ // { value: '001', label: 'test2' },
+ // { value: '001', label: 'test3' },
+ // { value: '001', label: 'test4' }
+ ],
+ operation: ''
}
},
@@ -207,8 +254,47 @@
created() {
},
+ mounted() {
+ window.addEventListener('resize', this.getHeight)
+ this.getHeight()
+ },
methods: {
+ // 鏂板鎸夐挳
+ add(val) {
+ this.operation = val
+ this.dialogVisible = true
+ },
+ // 淇敼鎸夐挳
+ edit(val) {
+ this.operation = val
+ this.dialogVisible = true
+ },
+ // 鍒犻櫎鎸夐挳
+ del() {
+ },
+ // 瀵硅瘽妗嗗叧闂簨浠�
+ handleClose() {
+
+ },
+ // 瀵硅瘽妗嗗彇娑�
+ dialogVisibleCancel() {
+ this.dialogVisible = false
+ },
+ // 瀵硅瘽妗嗙‘璁�
+ dialogVisibleConfirm() {
+ console.log(this.dialogForm.zzlx)
+ // this.dialogVisible = false
+ },
+ // 鑾峰彇椤甸潰楂樺害
+ getHeight() {
+ this.$nextTick(() => {
+ this.mainHeight = window.innerHeight - 200
+ // this.panelHeight = this.mainHeight - 40
+ this.tableHeight = this.mainHeight - 55
+ })
+ },
+ // 鏍戝舰杩囨护鑺傜偣
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
@@ -266,6 +352,32 @@
font-size: 14px
}
+.footerButton{
+ display: flex;
+ justify-content: end;
+}
+::v-deep .el-button--default{
+ background-color: #ffffff !important;
+ height: 30px;
+ display: flex;
+ align-items: center;
+}
+
+::v-deep .el-button--default:hover{
+ color: #606266;
+}
+::v-deep .el-dialog__body{
+ padding: 20px 100px !important;
+}
+
+::v-deep .el-radio__input.is-checked .el-radio__inner{
+ background-color: $main_color;
+ border-color: $main_color;
+}
+
+::v-deep .el-radio__input.is-checked+.el-radio__label{
+color: $main_color !important;
+}
/*::v-deep*/
/*.el-icon-caret-right:before {*/
/* content: "\e722";*/
diff --git a/vue.config.js b/vue.config.js
index f0c725d..320915d 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -38,10 +38,10 @@
},
proxy: {
[process.env.VUE_APP_BASE_API]: {
- target: process.env.VUE_APP_BASE_API, // 璇锋眰鐨勭涓夆絽鎺モ紳鍦板潃
+ target: 'http://121.196.36.24:8001', // 璇锋眰鐨勭涓夆絽鎺モ紳鍦板潃
changeOrigin: true, // 璇锋眰璺ㄥ煙鏃讹紝闇�閰嶇疆姝ら」
pathRewrite: { // 璺緞閲嶅啓,鏇挎崲target涓殑璇锋眰鍦板潃
- ['^' + process.env.VUE_APP_BASE_API]: ''
+ ['^' + process.env.VUE_APP_BASE_API]: '/api/'
}
}
}
--
Gitblit v1.9.3