merge dev-jack info shenzhen-dev

This commit is contained in:
Jack 2022-08-11 18:49:46 +08:00
commit 4dfe1f8a18
2 changed files with 393 additions and 278 deletions

View File

@ -3,17 +3,14 @@ import axios from 'axios'
// import QS from 'qs' // import QS from 'qs'
import store from '@/store' import store from '@/store'
// import router from '../../router' // import router from '../../router'
import { import { Loading, Message } from 'element-ui'
Loading,
Message
} from 'element-ui'
Vue.prototype.$http = axios Vue.prototype.$http = axios
// Vue.prototype.qs = QS; // Vue.prototype.qs = QS;
// Vue.use(ElementUI) // Vue.use(ElementUI)
var loading; var loading
let needLoadingRequestCount = 0; let needLoadingRequestCount = 0
let showLoadingConfig = ''; let showLoadingConfig = ''
function getLang() { function getLang() {
let currentLanguage = store.state.currentLanguage let currentLanguage = store.state.currentLanguage
@ -21,10 +18,10 @@ function getLang() {
switch (currentLanguage) { switch (currentLanguage) {
case 'zh': case 'zh':
langParam = 'zh_CN' langParam = 'zh_CN'
break; break
case 'en': case 'en':
langParam = 'en_US' langParam = 'en_US'
break; break
} }
return langParam return langParam
} }
@ -37,14 +34,13 @@ if (process.env.NODE_ENV == 'development') {
// axios.defaults.baseURL = 'https://zhgd.loganwy.com/' //龙光 // axios.defaults.baseURL = 'https://zhgd.loganwy.com/' //龙光
// axios.defaults.baseURL = 'https://zhgd-uat.logan.com.cn/' // axios.defaults.baseURL = 'https://zhgd-uat.logan.com.cn/'
// axios.defaults.baseURL = 'http://36.137.53.203:9090/'; // 南昌地铁 17512009894 123456789 gdjt 123456789 // axios.defaults.baseURL = 'http://36.137.53.203:9090/' // 南昌地铁 17512009894 123456789 gdjt 87654321
// axios.defaults.baseURL = 'http://192.168.34.125:6023/' // axios.defaults.baseURL = 'http://192.168.34.125:6023/'
// axios.defaults.baseURL = 'http://124.71.178.44:100/' // 河南 // axios.defaults.baseURL = 'http://124.71.178.44:100/' // 河南
// tag: 本地 // tag: 本地
// axios.defaults.baseURL = 'http://192.168.34.174:6023/' // 老大本地 // axios.defaults.baseURL = 'http://192.168.34.174:6023/' // 老大本地
axios.defaults.baseURL = 'http://192.168.34.125:6023/'; //杨意本地 http/1.1 axios.defaults.baseURL = 'http://192.168.34.125:6023/' //杨意本地 http/1.1
// axios.defaults.baseURL = 'http://q59pa4.natappfree.cc/'; //杨
// axios.defaults.baseURL = 'http://192.168.34.231:6023/'; //杨思瑞本地 // axios.defaults.baseURL = 'http://192.168.34.231:6023/'; //杨思瑞本地
// axios.defaults.baseURL = 'http://47.97.202.104:6023/'; // axios.defaults.baseURL = 'http://47.97.202.104:6023/';
// axios.defaults.baseURL = 'http://124.71.178.44:9500/'; // 星璇 // axios.defaults.baseURL = 'http://124.71.178.44:9500/'; // 星璇
@ -54,7 +50,6 @@ if (process.env.NODE_ENV == 'development') {
// axios.defaults.baseURL = 'http://182.90.224.237:7000/'; // 广西 // axios.defaults.baseURL = 'http://182.90.224.237:7000/'; // 广西
// axios.defaults.baseURL = 'http://120.196.217.6:7000/' //鹤洲 // axios.defaults.baseURL = 'http://120.196.217.6:7000/' //鹤洲
// axios.defaults.baseURL = 'http://117.156.17.59:9090/'; // // axios.defaults.baseURL = 'http://117.156.17.59:9090/'; //
// axios.defaults.baseURL = 'http://120.236.247.200:9000/'; //横琴线上 // axios.defaults.baseURL = 'http://120.236.247.200:9000/'; //横琴线上
// axios.defaults.baseURL = 'http://223.82.100.80:9000/'; //南昌地铁 // axios.defaults.baseURL = 'http://223.82.100.80:9000/'; //南昌地铁
@ -76,12 +71,11 @@ if (process.env.NODE_ENV == 'development') {
// axios.defaults.baseURL = 'http://218.92.215.138:9090/' //盐城 新佳城小区 123456 // axios.defaults.baseURL = 'http://218.92.215.138:9090/' //盐城 新佳城小区 123456
// axios.defaults.baseURL = 'http://36.137.53.203:9090/' //盐城 gdjt 123456789 // axios.defaults.baseURL = 'http://36.137.53.203:9090/' //盐城 gdjt 123456789
// axios.defaults.baseURL = 'http://183.234.150.152:9090/' //华发 huaxin 123456789 // axios.defaults.baseURL = 'http://183.234.150.152:9090/' //华发 huaxin 123456789
} } else if (process.env.NODE_ENV == 'debug') {
else if (process.env.NODE_ENV == 'debug') { axios.defaults.baseURL = 'https://www.ceshi.com'
axios.defaults.baseURL = 'https://www.ceshi.com';
} else if (process.env.NODE_ENV == 'production') { } else if (process.env.NODE_ENV == 'production') {
let host = window.location.host; let host = window.location.host
axios.defaults.baseURL = window.location.protocol + "//" + host + "/" axios.defaults.baseURL = window.location.protocol + '//' + host + '/'
// axios.defaults.baseURL ='http://192.168.34.125:6023/' // axios.defaults.baseURL ='http://192.168.34.125:6023/'
// axios.defaults.baseURL = window.location.protocol + "//" + host.split(":")[0] + ":6023" + "/" // axios.defaults.baseURL = window.location.protocol + "//" + host.split(":")[0] + ":6023" + "/"
// axios.defaults.baseURL = 'http://zhgd.loganwy.com/' // axios.defaults.baseURL = 'http://zhgd.loganwy.com/'
@ -96,11 +90,12 @@ if (COMPANY == 'henan') {
// console.log('store.state.userInfo',store) // console.log('store.state.userInfo',store)
if (store.state.userInfo) { if (store.state.userInfo) {
axios.defaults.headers.common['Authorization'] = 'Bearer' + ' ' + store.state.userInfo.token; axios.defaults.headers.common['Authorization'] = 'Bearer' + ' ' + store.state.userInfo.token
axios.defaults.headers.common['operateId'] = store.state.userInfo.userId; axios.defaults.headers.common['operateId'] = store.state.userInfo.userId
} }
// http请求拦截器 // http请求拦截器
axios.interceptors.request.use(config => { axios.interceptors.request.use(
config => {
// 分屏插件兼容配置 // 分屏插件兼容配置
const screensBaseURL = sessionStorage.getItem('screens-baseURL') const screensBaseURL = sessionStorage.getItem('screens-baseURL')
if (config.url.indexOf(screensBaseURL) !== -1) { if (config.url.indexOf(screensBaseURL) !== -1) {
@ -120,19 +115,21 @@ axios.interceptors.request.use(config => {
showFullScreenLoading() showFullScreenLoading()
} }
return config return config
}, error => { },
error => {
tryHideFullScreenLoading() tryHideFullScreenLoading()
// Message.error('加载超时'); // Message.error('加载超时');
return Promise.reject(error) return Promise.reject(error)
}) }
)
// 响应拦截器 // 响应拦截器
axios.interceptors.response.use( axios.interceptors.response.use(
response => { response => {
tryHideFullScreenLoading() tryHideFullScreenLoading()
if (response.status === 200) { if (response.status === 200) {
return Promise.resolve(response); return Promise.resolve(response)
} else { } else {
return Promise.reject(response); return Promise.reject(response)
} }
}, },
// 服务器状态码不是2开头的的情况 // 服务器状态码不是2开头的的情况
@ -146,7 +143,10 @@ axios.interceptors.response.use(
let errorUrl = error.response.config.baseURL let errorUrl = error.response.config.baseURL
console.log('-----------------', errorUrl) console.log('-----------------', errorUrl)
let screensUrl = sessionStorage.getItem('screens-baseURL') let screensUrl = sessionStorage.getItem('screens-baseURL')
if(errorUrl == screensUrl){
const url = error.response.url
if (errorUrl == screensUrl || url === '26938512:7zS9LX2X8u4tW4Ps0ZjN/login') {
return return
} else { } else {
switch (error.response.status) { switch (error.response.status) {
@ -154,31 +154,31 @@ axios.interceptors.response.use(
// 未登录则跳转登录页面,并携带当前页面的路径 // 未登录则跳转登录页面,并携带当前页面的路径
// 在登录成功后返回当前页面,这一步需要在登录页操作。 // 在登录成功后返回当前页面,这一步需要在登录页操作。
case 401: case 401:
Message.error('会话已失效,请重新登录'); Message.error('会话已失效,请重新登录')
logout() logout()
break; break
// 403 token过期 // 403 token过期
// 登录过期对用户进行提示 // 登录过期对用户进行提示
// 清除本地token和清空vuex中token对象 // 清除本地token和清空vuex中token对象
// 跳转登录页面 // 跳转登录页面
case 403: case 403:
Message.error('登录过期,请重新登录'); Message.error('登录过期,请重新登录')
logout() logout()
break; break
// 404请求不存在 // 404请求不存在
case 404: case 404:
Message.error('网络请求不存在'); Message.error('网络请求不存在')
break; break
case 500: case 500:
Message.error('服务器错误'); Message.error('服务器错误')
break; break
} }
return Promise.reject(error.response); return Promise.reject(error.response)
} }
} }
} }
); )
/** /**
* get方法对应get请求 * get方法对应get请求
* @param {String} url [请求的url地址] * @param {String} url [请求的url地址]
@ -194,41 +194,48 @@ function logout() {
name: '工作站', name: '工作站',
id: 1, id: 1,
url: '/projectV2/taskList', url: '/projectV2/taskList',
menuList: [{ menuList: [
{
id: 100000, id: 100000,
menuName: "任务清单", menuName: '任务清单',
path: "/projectV2/taskList" path: '/projectV2/taskList'
}, { },
{
id: 100001, id: 100001,
menuName: "通知公告", menuName: '通知公告',
path: "/projectV2/noticeList" path: '/projectV2/noticeList'
}, { },
{
id: 100002, id: 100002,
menuName: "工作日程", menuName: '工作日程',
path: "/projectV2/workerSchedule" path: '/projectV2/workerSchedule'
}]
} }
this.$store.commit("setCurModule", json); ]
}
this.$store.commit('setCurModule', json)
setTimeout(() => { setTimeout(() => {
window.location.href = "/index.html#/login" window.location.href = '/index.html#/login'
}, 1000) }, 1000)
} }
export function get(url, params, config) { export function get(url, params, config) {
showLoadingConfig = config showLoadingConfig = config
url = url + '?lang=' + getLang() url = url + '?lang=' + getLang()
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(url, { axios
.get(url, {
params: params params: params
}).then(res => { })
.then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
resolve(res.data); resolve(res.data)
} else { } else {
Message.error(res.data.message); Message.error(res.data.message)
} }
}).catch(err => { })
.catch(err => {
reject(err.data) reject(err.data)
}) })
}); })
} }
/** /**
@ -240,22 +247,23 @@ export function post(url, params, config) {
showLoadingConfig = config showLoadingConfig = config
url = url + '?lang=' + getLang() url = url + '?lang=' + getLang()
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.post(url, params) axios
.post(url, params)
.then(res => { .then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
resolve(res.data); resolve(res.data)
} else { } else {
if (res.data.status !== 'SUCCESS') { if (res.data.status !== 'SUCCESS') {
Message.error(res.data.message); Message.error(res.data.message)
} else { } else {
resolve(res.data); resolve(res.data)
} }
} }
}) })
.catch(err => { .catch(err => {
reject(err.data) reject(err.data)
}) })
}); })
} }
/** /**
* put方法对应put请求 * put方法对应put请求
@ -266,18 +274,19 @@ export function put(url, params, config) {
showLoadingConfig = config showLoadingConfig = config
url = url + '?lang=' + getLang() url = url + '?lang=' + getLang()
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.put(url, params) axios
.put(url, params)
.then(res => { .then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
resolve(res.data); resolve(res.data)
} else { } else {
Message.error(res.data.message); Message.error(res.data.message)
} }
}) })
.catch(err => { .catch(err => {
reject(err.data) reject(err.data)
}) })
}); })
} }
export function showFullScreenLoading() { export function showFullScreenLoading() {
if (needLoadingRequestCount === 0) { if (needLoadingRequestCount === 0) {

View File

@ -1,13 +1,13 @@
<template> <template>
<Card :title="title"> <Card :title="title">
<div class="gantt-chart"> <div class="gantt-chart">
<div class="table"> <div class="table" @scroll="handleScroll">
<div class="thead"> <div class="thead">
<div class="row"> <div class="row">
<div class="td">分部分项工程名称</div> <div class="td">分部分项工程名称</div>
<div class="td">开始日期</div> <div class="td">开始日期</div>
<div class="td">完成日期</div> <div class="td">完成日期</div>
<div class="td" v-for="date in dates" :key="date"> <div class="td" v-for="date in dateList" :key="date">
<div class="date"> <div class="date">
<div class="month"> <div class="month">
{{ date }} {{ date }}
@ -25,33 +25,39 @@
<div class="td" @click="handleOpen(i)">{{ p.pName }}</div> <div class="td" @click="handleOpen(i)">{{ p.pName }}</div>
<div class="td">{{ p.startTime }}</div> <div class="td">{{ p.startTime }}</div>
<div class="td">{{ p.endTime }}</div> <div class="td">{{ p.endTime }}</div>
<div class="td" v-for="date in dates" :key="date + 'grid-date'"> <div class="td" v-for="date in dateList" :key="date + 'grid-date'">
<div class="grids"> <div class="grids">
<div class="grid" v-for="day in getDays(date)" :key="'grid' + day.num" :ref="p.pName + '-' + day.date"></div> <div class="grid" v-for="day in getDays(date)" :key="'grid' + day.num" :ref="p.pName + '-' + day.date"></div>
</div> </div>
</div> </div>
<div class="progress" :style="{ left: gantt.left, width: gantt.width }" v-for="(gantt, index) in p.gantts" :key="index"></div> <div
class="progress"
:style="gantt"
v-for="(gantt, index) in p.gantts"
:key="index"
@mouseenter="handleHover"
@mouseleave="handleLeave"
></div>
</div> </div>
<div class="children"> <div class="children">
<div class="row" v-for="child in p.children" :key="'child-' + child.pName"> <div class="row" v-for="child in p.children" :key="'child-' + child.pName">
<div class="td">{{ child.pName }}</div> <div class="td">{{ child.pName }}</div>
<div class="td">{{ child.startTime }}</div> <div class="td">{{ child.startTime }}</div>
<div class="td">{{ child.endTime }}</div> <div class="td">{{ child.endTime }}</div>
<div class="td" v-for="date in dates" :key="date + 'grid-date'"> <div class="td" v-for="date in dateList" :key="date + 'grid-date'">
<div class="grids"> <div class="grids">
<div class="grid" v-for="day in getDays(date)" :key="'grid' + day.num" :ref="child.pName + '-' + day.date"></div> <div class="grid" v-for="day in getDays(date)" :key="'grid' + day.num" :ref="child.pName + '-' + day.date"></div>
</div> </div>
</div> </div>
<div <div class="progress" :style="gantt" v-for="(gantt, index) in child.gantts" :key="index"></div>
class="progress"
:style="{ left: gantt.left, width: gantt.width }"
v-for="(gantt, index) in child.gantts"
:key="index"
></div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="tooltips" :style="tooltipsStyle">
<div class="status">已逾期5天</div>
<div class="charger">负责人史蒂夫</div>
</div>
</div> </div>
</div> </div>
</Card> </Card>
@ -75,30 +81,37 @@ export default {
}, },
data() { data() {
return { return {
dates: ['2020/03', '2020/04', '2020/05', '2020/06', '2020/07', '2020/08'],
projects: [ projects: [
{ {
pName: '地基与基础工程', pName: '地基与基础工程',
startTime: '2020/04/06', startTime: '2020/04/06',
endTime: '2020/05/09', endTime: '2020/05/09',
delay: 10,
status: 0,
gantts: [], gantts: [],
// gantts: [{ left: '420px', width: '100px', status: '' }], // gantts: [{ left: '420px', width: '100px', status: '' }],
children: [ children: [
{ pName: '无支护土方工程', startTime: '2020/04/06', endTime: '2020/04/09', gantts: [] }, { pName: '无支护土方工程', startTime: '2020/04/06', endTime: '2020/04/09', status: 1 },
{ pName: '有支护土方工程', startTime: '2020/04/10', endTime: '2020/05/08', gantts: [] } { pName: '有支护土方工程', startTime: '2020/04/10', endTime: '2020/05/08', status: 3 }
] ]
}, },
{ pName: '主体结构', startTime: '2020/03/12', endTime: '2020/06/04' }, { pName: '主体结构', startTime: '2020/03/12', endTime: '2020/06/04', status: 2 },
{ pName: '建筑装饰装修', startTime: '2020/04/21', endTime: '2020/07/30', gantts: [] } { pName: '建筑装饰装修', startTime: '2020/04/21', endTime: '2020/07/30', status: 1 }
], ],
openedIndex: 9999 openedIndex: 9999,
colors: ['#4C87FF', '#54CF8E', '#F2D026', '#FF6C7F'],
tooltipsStyle: {
display: 'none',
left: 0,
top: 0
},
scrollLeft: 0,
scrollTimer: 0
} }
}, },
methods: { methods: {
setGantts() { getGanttStyle(project) {
const configGantts = projects => { let { startTime, endTime, pName } = project
projects.map(project => {
let { startTime, endTime, pName, gantts } = project
const startArr = startTime.split('/') const startArr = startTime.split('/')
const endArr = endTime.split('/') const endArr = endTime.split('/')
let startRef = null let startRef = null
@ -125,14 +138,29 @@ export default {
const endLeft = endRef.offsetLeft const endLeft = endRef.offsetLeft
const ganttWidth = endLeft - startLeft + endWidth const ganttWidth = endLeft - startLeft + endWidth
const gantt = { left: startLeft + 'px', width: ganttWidth + 'px' } return { left: startLeft + 'px', width: ganttWidth + 'px' }
},
setGantts() {
const configGantts = projects => {
projects.map(project => {
let { endTime, pName, gantts } = project
const gantt = this.getGanttStyle(project)
gantt.background = this.colors[project.status]
if (gantts) { if (gantts) {
gantts.push(gantt) gantts.push(gantt)
} else { } else {
project.gantts = [gantt] project.gantts = [gantt]
} }
console.log(startLeft, ganttWidth, '丢雷', `${pName}-${endTime}`) if (project.delay) {
const delayStartTime = this.increaseDate(endTime, 1)
const delayEndTime = this.increaseDate(endTime, project.delay)
const gantt = this.getGanttStyle({ startTime: delayStartTime, endTime: delayEndTime, pName })
gantt.background = this.colors[3]
gantts.push(gantt)
console.log(gantt, '是的发生的范范')
}
// debugger // debugger
project.children && configGantts(project.children) project.children && configGantts(project.children)
@ -140,6 +168,13 @@ export default {
} }
configGantts(this.projects) configGantts(this.projects)
}, },
increaseDate(date, delay) {
const timestamp = new Date(date).getTime() + (delay + 1) * 1000 * 60 * 60 * 24
return new Date(timestamp)
.toISOString()
.replace(/-/g, '/')
.slice(0, 10)
},
getDays(date) { getDays(date) {
const year = date.split('/')[0] const year = date.split('/')[0]
const month = +date.split('/')[1] const month = +date.split('/')[1]
@ -182,6 +217,46 @@ export default {
} else { } else {
this.openedIndex = index this.openedIndex = index
} }
},
handleScroll(e) {
if (this.scrollTimer) {
clearTimeout(this.scrollTimer)
}
this.scrollTimer = setTimeout(() => {
this.scrollLeft = e.target.scrollLeft
this.scrollTimer = null
}, 100)
},
handleHover(e) {
const { clientX, clientY } = e
const decreaseLeft = clientX - 680
const decreaseTop = clientY - 200
this.tooltipsStyle = {
left: decreaseLeft + this.scrollLeft + 'px',
top: decreaseTop + 'px',
display: 'block'
}
},
handleLeave() {
this.tooltipsStyle = {
display: 'none'
}
}
},
computed: {
dateList() {
let dates = []
const mapDates = data => {
data.map(p => {
dates.push(p.startTime)
dates.push(p.endTime)
p.children && mapDates(p.children)
})
}
mapDates(this.projects)
dates = dates.map(date => date.slice(0, 7)).sort()
dates = [...new Set(dates)]
return dates
} }
} }
} }
@ -191,8 +266,19 @@ export default {
.gantt-chart { .gantt-chart {
height: 100%; height: 100%;
.table { .table {
position: relative;
height: 100%; height: 100%;
overflow-x: auto; overflow-x: auto;
&::-webkit-scrollbar {
width: 10px;
height: 8px;
cursor: pointer;
}
&::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: skyblue;
}
.thead { .thead {
border-bottom: 1px solid #234d5f; border-bottom: 1px solid #234d5f;
.row { .row {
@ -234,6 +320,7 @@ export default {
border-left: 1px solid #234d5f; border-left: 1px solid #234d5f;
.row-groups { .row-groups {
position: relative; position: relative;
height: 42px;
&::before { &::before {
content: ''; content: '';
position: absolute; position: absolute;
@ -248,13 +335,11 @@ export default {
z-index: 99; z-index: 99;
} }
&.open { &.open {
height: unset;
&::before { &::before {
border-left-color: transparent; border-left-color: transparent;
border-top-color: #5be1f4; border-top-color: #5be1f4;
} }
.children {
display: block;
}
} }
> .row .td:first-child { > .row .td:first-child {
user-select: none; user-select: none;
@ -302,11 +387,10 @@ export default {
top: calc(50% - 7px); top: calc(50% - 7px);
width: 20px; width: 20px;
height: 14px; height: 14px;
background: pink; background: #557dee;
} }
} }
.children { .children {
display: none;
.td { .td {
height: 38px; height: 38px;
line-height: 38px; line-height: 38px;
@ -315,6 +399,28 @@ export default {
} }
} }
} }
.tooltips {
position: absolute;
box-sizing: border-box;
padding: 10px;
width: 130px;
height: 65px;
font-size: 14px;
color: #fff;
border-radius: 8px;
background-color: #50a6b3;
.status {
display: inline-block;
margin-bottom: 6px;
padding: 0 10px;
height: 20px;
min-width: 60px;
line-height: 20px;
font-size: 12px;
border-radius: 10px;
background-color: #ff6c7f;
}
}
} }
} }
</style> </style>