46 changed files with 1309 additions and 110 deletions
@ -1,12 +1,10 @@ |
|||||
import domain from '@/config/domains'; |
// 插件的地址是固定的
|
||||
const apiUrl = process.env.VUE_APP_API_URL; |
const url = process.env.VUE_APP_API_URL; |
||||
const mock = `${apiUrl}${domain}`; |
|
||||
const plugin = `${apiUrl}/pluginshop/plugin`; |
|
||||
|
|
||||
const install = (Vue, vm) => { |
const install = (Vue, vm) => { |
||||
vm.$u.api = { ...vm.$u.api } || {}; |
vm.$u.api = { ...vm.$u.api } || {}; |
||||
vm.$u.api.getPlugin = param => vm.$u.post(`${mock}/plugin`, param); |
// 获取插件信息
|
||||
vm.$u.api.getOtherPlugin = param => vm.$u.post(`${plugin}/query`, param); |
vm.$u.api.getOtherPlugin = param => vm.$u.post(`${url}/pluginshop/plugin/query`, param); |
||||
}; |
}; |
||||
|
|
||||
export default { install }; |
export default { install }; |
||||
|
@ -1,12 +1,7 @@ |
|||||
const apiUrl = process.env.VUE_APP_API_URL; |
|
||||
import domainPath from '@/config/domains'; |
|
||||
const tall = `${apiUrl}${domainPath}`; |
|
||||
const project = `${tall}/project`; |
|
||||
|
|
||||
const install = (Vue, vm) => { |
const install = (Vue, vm) => { |
||||
vm.$u.api = { ...vm.$u.api } || {}; |
vm.$u.api = { ...vm.$u.api } || {}; |
||||
//根据id获取项目信息
|
//根据id获取项目信息
|
||||
vm.$u.api.findProjectById = param => vm.$u.post(`${project}/findProjectById`, param); |
vm.$u.api.findProjectById = param => vm.$u.post(`${uni.$t.domain}/project/findProjectById`, param); |
||||
}; |
}; |
||||
|
|
||||
export default { install }; |
export default { install }; |
||||
|
@ -1,11 +1,7 @@ |
|||||
const apiUrl = process.env.VUE_APP_API_URL; |
|
||||
import domain from '@/config/domains'; |
|
||||
const role = `${apiUrl}${domain}/role`; |
|
||||
|
|
||||
const install = (Vue, vm) => { |
const install = (Vue, vm) => { |
||||
vm.$u.api = { ...vm.$u.api } || {}; |
vm.$u.api = { ...vm.$u.api } || {}; |
||||
//根据时间基准点和角色查找定期任务
|
//根据时间基准点和角色查找定期任务
|
||||
vm.$u.api.findShowRole = param => vm.$u.post(`${role}/show`, param); |
vm.$u.api.findShowRole = param => vm.$u.post(`${uni.$t.domain}/role/show`, param); |
||||
}; |
}; |
||||
|
|
||||
export default { install }; |
export default { install }; |
||||
|
@ -1,13 +1,11 @@ |
|||||
const apiUrl = process.env.VUE_APP_API_URL; |
|
||||
import domain from '@/config/domains'; |
|
||||
const task = `${apiUrl}${domain}/task`; |
|
||||
|
|
||||
const install = (Vue, vm) => { |
const install = (Vue, vm) => { |
||||
vm.$u.api = { ...vm.$u.api } || {}; |
vm.$u.api = { ...vm.$u.api } || {}; |
||||
vm.$u.api.getGlobal = param => vm.$u.post(`${task}/global`, param); |
vm.$u.api.getGlobal = param => vm.$u.post(`${uni.$t.domain}/task/global`, param); |
||||
vm.$u.api.getPermanent = param => vm.$u.post(`${task}/permanent`, param); |
vm.$u.api.getPermanent = param => vm.$u.post(`${uni.$t.domain}/task/permanent`, param); |
||||
//根据时间基准点和角色查找定期任务
|
//根据时间基准点和角色查找定期任务
|
||||
vm.$u.api.getRegularTask = param => vm.$u.post(`${task}/regular`, param); |
vm.$u.api.getRegularTask = param => vm.$u.post(`${uni.$t.domain}/task/regular`, param); |
||||
|
//修改任务状态
|
||||
|
vm.$u.api.updateTaskType = param => vm.$u.post(`${uni.$t.domain}/task/type`, param); |
||||
}; |
}; |
||||
|
|
||||
export default { install }; |
export default { install }; |
||||
|
@ -0,0 +1,7 @@ |
|||||
|
const install = (Vue, vm) => { |
||||
|
vm.$u.api = { ...vm.$u.api } || {}; |
||||
|
// 导入wbs
|
||||
|
vm.$u.api.import = formData => vm.$t.chooseAndUpload(`${uni.$t.domain}/wbs`, formData); |
||||
|
}; |
||||
|
|
||||
|
export default { install }; |
@ -0,0 +1,472 @@ |
|||||
|
<template> |
||||
|
<view class="zzx-calendar"> |
||||
|
<view class="calendar-heander"> |
||||
|
{{ timeStr }} |
||||
|
</view> |
||||
|
|
||||
|
<!-- 星期几标题 --> |
||||
|
<view class="calendar-weeks"> |
||||
|
<view class="calendar-week" :class="{ 'text-red-500': week === '六' || week === '日' }" v-for="(week, index) in weeks" :key="index"> |
||||
|
{{ week }} |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="calendar-content"> |
||||
|
<swiper |
||||
|
class="calendar-swiper" |
||||
|
:style="{ |
||||
|
width: '100%', |
||||
|
height: sheight, |
||||
|
}" |
||||
|
:indicator-dots="false" |
||||
|
:autoplay="false" |
||||
|
:duration="duration" |
||||
|
:current="current" |
||||
|
@change="changeSwp" |
||||
|
:circular="true" |
||||
|
> |
||||
|
<swiper-item class="calendar-item" v-for="sitem in swiper" :key="sitem"> |
||||
|
<view class="calendar-days"> |
||||
|
<!-- 当前的 --> |
||||
|
<template v-if="sitem === current"> |
||||
|
<view |
||||
|
class="calendar-day" |
||||
|
v-for="(item, index) in days" |
||||
|
:key="index" |
||||
|
:class="{ 'day-hidden': !item.show }" |
||||
|
@click="clickItem(item)" |
||||
|
> |
||||
|
<view class="date" :class="[item.isToday ? todayClass : '', item.fullDate === selectedDate ? checkedClass : '']"> |
||||
|
{{ item.time.getDate() }} |
||||
|
</view> |
||||
|
<view class="dot-show" v-if="item.info" :style="dotStyle"> </view> |
||||
|
</view> |
||||
|
</template> |
||||
|
<template v-else> |
||||
|
<!-- 下一个月/周 --> |
||||
|
<template v-if="current - sitem === 1 || current - sitem === -2"> |
||||
|
<view |
||||
|
class="calendar-day" |
||||
|
v-for="(item, index) in predays" |
||||
|
:key="index" |
||||
|
:class="{ |
||||
|
'day-hidden': !item.show, |
||||
|
}" |
||||
|
> |
||||
|
<view class="date" :class="[item.isToday ? todayClass : '']"> |
||||
|
{{ item.time.getDate() }} |
||||
|
</view> |
||||
|
</view> |
||||
|
</template> |
||||
|
<!-- 上一个月/周 --> |
||||
|
<template v-else> |
||||
|
<view |
||||
|
class="calendar-day" |
||||
|
v-for="(item, index) in nextdays" |
||||
|
:key="index" |
||||
|
:class="{ |
||||
|
'day-hidden': !item.show, |
||||
|
}" |
||||
|
> |
||||
|
<view class="date" :class="[item.isToday ? todayClass : '']"> |
||||
|
{{ item.time.getDate() }} |
||||
|
</view> |
||||
|
</view> |
||||
|
</template> |
||||
|
</template> |
||||
|
</view> |
||||
|
</swiper-item> |
||||
|
</swiper> |
||||
|
|
||||
|
<!-- <view class="mode-change" @click="changeMode"> |
||||
|
<view :class="weekMode ? 'mode-arrow-bottom' : 'mode-arrow-top'"> </view> |
||||
|
</view> --> |
||||
|
</view> |
||||
|
|
||||
|
<view class="flex justify-center u-font-18" style="color: #3b82f6" @click="goback"> 今日 </view> |
||||
|
</view> |
||||
|
</template> |
||||
|
mb-3 |
||||
|
<script> |
||||
|
import { gegerateDates, dateEqual, formatDate } from './generateDates.js'; |
||||
|
|
||||
|
export default { |
||||
|
props: { |
||||
|
duration: { |
||||
|
type: Number, |
||||
|
default: 500, |
||||
|
}, |
||||
|
dotList: { |
||||
|
type: Array, /// 打点日期列表 |
||||
|
default() { |
||||
|
return []; |
||||
|
}, |
||||
|
}, |
||||
|
showBack: { |
||||
|
type: Boolean, // 是否返回今日 |
||||
|
default: false, |
||||
|
}, |
||||
|
todayClass: { |
||||
|
type: String, // 今日的自定义样式class |
||||
|
default: 'is-today', |
||||
|
}, |
||||
|
checkedClass: { |
||||
|
type: String, // 选中日期的样式class |
||||
|
default: 'is-checked', |
||||
|
}, |
||||
|
dotStyle: { |
||||
|
type: Object, // 打点日期的自定义样式 |
||||
|
default() { |
||||
|
return { background: '#FF0000' }; |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
watch: { |
||||
|
dotList: function (newvalue) { |
||||
|
const days = this.days.slice(0); |
||||
|
newvalue.forEach(item => { |
||||
|
const index = days.findIndex(ditem => ditem.fullDate === item.date); |
||||
|
if (index > 0) { |
||||
|
days[index].info = item; |
||||
|
} |
||||
|
}); |
||||
|
this.days = days; |
||||
|
console.log(days); |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
data() { |
||||
|
return { |
||||
|
weeks: ['日', '一', '二', '三', '四', '五', '六'], // 周 |
||||
|
current: 1, |
||||
|
currentYear: '', |
||||
|
currentMonth: '', |
||||
|
currentDate: '', |
||||
|
days: [], |
||||
|
weekMode: false, // false -> 月 true -> 显示周 |
||||
|
swiper: [0, 1, 2], |
||||
|
// dotList: [], // 打点的日期列表 |
||||
|
selectedDate: formatDate(new Date(), 'yyyy-MM-dd'), // 当前选中的日期 |
||||
|
}; |
||||
|
}, |
||||
|
|
||||
|
computed: { |
||||
|
sheight() { |
||||
|
// 根据年月判断有多少行 |
||||
|
// 判断该月有多少天 |
||||
|
let h = '35px'; |
||||
|
if (!this.weekMode) { |
||||
|
const d = new Date(this.currentYear, this.currentMonth, 0); |
||||
|
const days = d.getDate(); // 判断本月有多少天 |
||||
|
let day = new Date(d.setDate(1)).getDay(); |
||||
|
// if (day === 0) { |
||||
|
// day = 7; |
||||
|
// } |
||||
|
const pre = 8 - day; |
||||
|
const rows = Math.ceil((days - pre) / 7) + 1; |
||||
|
h = 35 * rows + 'px'; |
||||
|
} |
||||
|
return h; |
||||
|
}, |
||||
|
|
||||
|
// 当前日期 年月 |
||||
|
timeStr() { |
||||
|
let str = ''; |
||||
|
const d = new Date(this.currentYear, this.currentMonth - 1, this.currentDate); |
||||
|
const y = d.getFullYear(); |
||||
|
const m = d.getMonth() + 1 <= 9 ? `0${d.getMonth() + 1}` : d.getMonth() + 1; |
||||
|
str = `${y}年${m}月`; |
||||
|
return str; |
||||
|
}, |
||||
|
|
||||
|
// 上一周期的days书籍 |
||||
|
predays() { |
||||
|
let pres = []; |
||||
|
if (this.weekMode) { |
||||
|
// 周模式 |
||||
|
const d = new Date(this.currentYear, this.currentMonth - 1, this.currentDate); |
||||
|
d.setDate(d.getDate() - 7); |
||||
|
pres = gegerateDates(d, 'week'); |
||||
|
} else { |
||||
|
// 月模式 |
||||
|
const d = new Date(this.currentYear, this.currentMonth - 2, 1); |
||||
|
pres = gegerateDates(d, 'month'); |
||||
|
} |
||||
|
return pres; |
||||
|
}, |
||||
|
|
||||
|
// 下一周期的days书籍 |
||||
|
nextdays() { |
||||
|
let nexts = []; |
||||
|
if (this.weekMode) { |
||||
|
// 周模式 |
||||
|
const d = new Date(this.currentYear, this.currentMonth - 1, this.currentDate); |
||||
|
d.setDate(d.getDate() + 7); |
||||
|
nexts = gegerateDates(d, 'week'); |
||||
|
} else { |
||||
|
// 月模式 |
||||
|
const d = new Date(this.currentYear, this.currentMonth, 1); |
||||
|
nexts = gegerateDates(d, 'month'); |
||||
|
} |
||||
|
return nexts; |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
created() { |
||||
|
this.initDate(); |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
// |
||||
|
/** |
||||
|
* 滑动切换上下周期 |
||||
|
* 根据前一个减去目前的值我们可以判断是下一个月/周还是上一个月/周 |
||||
|
* current - pre === 1, -2 下一个月/周 |
||||
|
* current - pre === -1, 2 上一个月或者上一周 |
||||
|
*/ |
||||
|
changeSwp(e) { |
||||
|
const pre = this.current; |
||||
|
const current = e.target.current; |
||||
|
this.current = current; |
||||
|
|
||||
|
if (current - pre === 1 || current - pre === -2) { |
||||
|
// 下一个月 或 下一周 |
||||
|
this.daysNext(); |
||||
|
} else { |
||||
|
// 上一个月 或 上一周 |
||||
|
this.daysPre(); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
// 初始化日历的方法 |
||||
|
initDate(cur) { |
||||
|
let date = ''; |
||||
|
if (cur) { |
||||
|
date = new Date(cur); |
||||
|
} else { |
||||
|
date = new Date(); |
||||
|
} |
||||
|
this.currentDate = date.getDate(); // 今日日期 几号 |
||||
|
this.currentYear = date.getFullYear(); // 当前年份 |
||||
|
this.currentMonth = date.getMonth() + 1; // 当前月份 |
||||
|
this.currentWeek = date.getDay() === 0 ? 7 : date.getDay(); // 1...6,0 星期几 |
||||
|
// const nowY = new Date().getFullYear(); // 当前年份 |
||||
|
// const nowM = new Date().getMonth() + 1; |
||||
|
// const nowD = new Date().getDate(); // 今日日期 几号 |
||||
|
// const nowW = new Date().getDay(); |
||||
|
// this.selectedDate = formatDate(new Date(), 'yyyy-MM-dd') |
||||
|
this.days = []; |
||||
|
let days = []; |
||||
|
if (this.weekMode) { |
||||
|
days = gegerateDates(date, 'week'); |
||||
|
// this.selectedDate = days[0].fullDate; |
||||
|
} else { |
||||
|
days = gegerateDates(date, 'month'); |
||||
|
// const sel = new Date(this.selectedDate.replace('-', '/').replace('-', '/')); |
||||
|
// const isMonth = sel.getFullYear() === this.currentYear && (sel.getMonth() + 1) === this.currentMonth; |
||||
|
// if(!isMonth) { |
||||
|
// this.selectedDate = formatDate(new Date(this.currentYear, this.currentMonth-1,1), 'yyyy-MM-dd') |
||||
|
// } |
||||
|
} |
||||
|
days.forEach(day => { |
||||
|
const dot = this.dotList.find(item => { |
||||
|
return dateEqual(item.date, day.fullDate); |
||||
|
}); |
||||
|
if (dot) { |
||||
|
day.info = dot; |
||||
|
} |
||||
|
}); |
||||
|
this.days = days; |
||||
|
console.log(days); |
||||
|
// 派发事件,时间发生改变 |
||||
|
let obj = { |
||||
|
start: '', |
||||
|
end: '', |
||||
|
}; |
||||
|
if (this.weekMode) { |
||||
|
obj.start = this.days[0].time; |
||||
|
obj.end = this.days[6].time; |
||||
|
} else { |
||||
|
const start = new Date(this.currentYear, this.currentMonth - 1, 1); |
||||
|
const end = new Date(this.currentYear, this.currentMonth, 0); |
||||
|
obj.start = start; |
||||
|
obj.end = end; |
||||
|
} |
||||
|
this.$emit('days-change', obj); |
||||
|
}, |
||||
|
|
||||
|
// 上一个 |
||||
|
daysPre() { |
||||
|
if (this.weekMode) { |
||||
|
const d = new Date(this.currentYear, this.currentMonth - 1, this.currentDate); |
||||
|
d.setDate(d.getDate() - 7); |
||||
|
this.initDate(d); |
||||
|
} else { |
||||
|
const d = new Date(this.currentYear, this.currentMonth - 2, 1); |
||||
|
this.initDate(d); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
// 下一个 |
||||
|
daysNext() { |
||||
|
if (this.weekMode) { |
||||
|
const d = new Date(this.currentYear, this.currentMonth - 1, this.currentDate); |
||||
|
d.setDate(d.getDate() + 7); |
||||
|
this.initDate(d); |
||||
|
} else { |
||||
|
const d = new Date(this.currentYear, this.currentMonth, 1); |
||||
|
this.initDate(d); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
// 切换模式 |
||||
|
changeMode() { |
||||
|
const premode = this.weekMode; |
||||
|
let isweek = false; |
||||
|
if (premode) { |
||||
|
isweek = !!this.days.find(item => item.fullDate === this.selectedDate); |
||||
|
} |
||||
|
this.weekMode = !this.weekMode; |
||||
|
let d = new Date(this.currentYear, this.currentMonth - 1, this.currentDate); |
||||
|
const sel = new Date(this.selectedDate.replace('-', '/').replace('-', '/')); |
||||
|
const isMonth = sel.getFullYear() === this.currentYear && sel.getMonth() + 1 === this.currentMonth; |
||||
|
if ((this.selectedDate && isMonth) || isweek) { |
||||
|
d = new Date(this.selectedDate.replace('-', '/').replace('-', '/')); |
||||
|
} |
||||
|
this.initDate(d); |
||||
|
}, |
||||
|
|
||||
|
// 点击日期 |
||||
|
clickItem(e) { |
||||
|
this.selectedDate = e.fullDate; |
||||
|
this.$emit('selected-change', e); |
||||
|
}, |
||||
|
|
||||
|
// 返回 |
||||
|
goback() { |
||||
|
const d = new Date(); |
||||
|
this.initDate(d); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.zzx-calendar { |
||||
|
width: 100%; |
||||
|
height: auto; |
||||
|
background-color: #fff; |
||||
|
padding-bottom: 10px; |
||||
|
|
||||
|
.calendar-heander { |
||||
|
text-align: center; |
||||
|
padding: 16px 0; |
||||
|
position: relative; |
||||
|
font-size: 15px; |
||||
|
} |
||||
|
|
||||
|
.calendar-weeks { |
||||
|
width: 100%; |
||||
|
display: flex; |
||||
|
flex-flow: row nowrap; |
||||
|
margin-bottom: 10px; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
font-size: 12px; |
||||
|
color: #9ca3af; |
||||
|
font-weight: bold; |
||||
|
|
||||
|
.calendar-week { |
||||
|
width: calc(100% / 7); |
||||
|
height: 100%; |
||||
|
text-align: center; |
||||
|
} |
||||
|
} |
||||
|
swiper { |
||||
|
width: 100%; |
||||
|
height: 60upx; |
||||
|
} |
||||
|
.calendar-content { |
||||
|
min-height: 30px; |
||||
|
} |
||||
|
.calendar-swiper { |
||||
|
min-height: 35px; |
||||
|
transition: height ease-out 0.3s; |
||||
|
} |
||||
|
.calendar-item { |
||||
|
margin: 0; |
||||
|
padding: 0; |
||||
|
height: 100%; |
||||
|
} |
||||
|
.calendar-days { |
||||
|
display: flex; |
||||
|
flex-flow: row wrap; |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
overflow: hidden; |
||||
|
font-size: 14px; |
||||
|
|
||||
|
.calendar-day { |
||||
|
width: calc(100% / 7); |
||||
|
height: 35px; |
||||
|
text-align: center; |
||||
|
display: flex; |
||||
|
flex-flow: column nowrap; |
||||
|
justify-content: flex-start; |
||||
|
align-items: center; |
||||
|
position: relative; |
||||
|
} |
||||
|
} |
||||
|
.day-hidden { |
||||
|
visibility: hidden; |
||||
|
} |
||||
|
|
||||
|
.mode-change { |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
margin-top: 5px; |
||||
|
|
||||
|
.mode-arrow-top { |
||||
|
width: 0; |
||||
|
height: 0; |
||||
|
border-left: 6px solid transparent; |
||||
|
border-right: 6px solid transparent; |
||||
|
border-bottom: 5px solid #ff6633; |
||||
|
} |
||||
|
.mode-arrow-bottom { |
||||
|
width: 0; |
||||
|
height: 0; |
||||
|
border-left: 6px solid transparent; |
||||
|
border-right: 6px solid transparent; |
||||
|
border-top: 5px solid #ff6633; |
||||
|
} |
||||
|
} |
||||
|
.is-today { |
||||
|
background: #ffffff; |
||||
|
border: 1upx solid #ff6633; |
||||
|
border-radius: 50%; |
||||
|
color: #ff6633; |
||||
|
} |
||||
|
.is-checked { |
||||
|
background: #ff6633; |
||||
|
color: #ffffff; |
||||
|
} |
||||
|
.date { |
||||
|
width: 25px; |
||||
|
height: 25px; |
||||
|
line-height: 25px; |
||||
|
margin: 0 auto; |
||||
|
border-radius: 25px; |
||||
|
} |
||||
|
.dot-show { |
||||
|
width: 8px; |
||||
|
height: 8px; |
||||
|
// background: red; |
||||
|
border-radius: 5px; |
||||
|
position: absolute; |
||||
|
top: 2px; |
||||
|
right: 10px; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,136 @@ |
|||||
|
/* |
||||
|
*此函数的作用是根据传入的一个日期,返回这一周的日期或者这一个月的日期, |
||||
|
* 如果是月的话注意还包含上个月和下个月的日期,月的话总共数据有 6 * 7 = 42个 |
||||
|
* |
||||
|
*/ |
||||
|
/* |
||||
|
* 时间格式化函数 |
||||
|
* 重要提示,微信小程序new Date('2020-04-16')在ios中无法获取时间对象 |
||||
|
* 解决方式: 建议将时间都格式化成'2020/04/16 00:00:00'的格式 |
||||
|
* 函数示例: formatDate(new Date(), 'YYYY/MM/dd hh:mm:ss') |
||||
|
*/ |
||||
|
export const formatDate = (date, fmt) => { |
||||
|
if (/(y+)/.test(fmt)) { |
||||
|
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); |
||||
|
} |
||||
|
let o = { |
||||
|
'M+': date.getMonth() + 1, |
||||
|
'd+': date.getDate(), |
||||
|
'h+': date.getHours(), |
||||
|
'm+': date.getMinutes(), |
||||
|
's+': date.getSeconds(), |
||||
|
}; |
||||
|
for (let k in o) { |
||||
|
if (new RegExp(`(${k})`).test(fmt)) { |
||||
|
let str = o[k] + ''; |
||||
|
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str)); |
||||
|
} |
||||
|
} |
||||
|
return fmt; |
||||
|
}; |
||||
|
const padLeftZero = str => { |
||||
|
return ('00' + str).substr(str.length); |
||||
|
}; |
||||
|
|
||||
|
// 判断是不是date对象
|
||||
|
export const judgeType = s => { |
||||
|
// 函数返回数据的具体类型
|
||||
|
return Object.prototype.toString.call(s).slice(8, -1); |
||||
|
}; |
||||
|
|
||||
|
export const equalDate = (d1, d2) => { |
||||
|
let result = false; |
||||
|
if (d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate()) { |
||||
|
result = true; |
||||
|
} |
||||
|
return result; |
||||
|
}; |
||||
|
|
||||
|
/* 比较时间,时间格式为2020-04-04 |
||||
|
*/ |
||||
|
export const dateEqual = (before, after) => { |
||||
|
before = new Date(before.replace('-', '/').replace('-', '/')); |
||||
|
after = new Date(after.replace('-', '/').replace('-', '/')); |
||||
|
if (before.getTime() - after.getTime() === 0) { |
||||
|
return true; |
||||
|
} else { |
||||
|
return false; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
export const gegerateDates = (date = new Date(), type = 'week') => { |
||||
|
const result = []; |
||||
|
if (judgeType(date) === 'Date') { |
||||
|
// 年,月,日
|
||||
|
const y = date.getFullYear(); |
||||
|
const m = date.getMonth(); |
||||
|
const d = date.getDate(); |
||||
|
const days = new Date(y, m + 1, 0).getDate(); |
||||
|
// 获取日期是星期几
|
||||
|
// let weekIndex = date.getDay() === 0 ? 7 : date.getDay();
|
||||
|
let weekIndex = date.getDay(); |
||||
|
if (type === 'month') { |
||||
|
const dobj = new Date(y, m, 1); |
||||
|
// weekIndex = dobj.getDay() === 0 ? 7 : dobj.getDay();
|
||||
|
weekIndex = dobj.getDay(); |
||||
|
} |
||||
|
if (type === 'week') { |
||||
|
for (let i = weekIndex; i > 0; i--) { |
||||
|
const dtemp = new Date(y, m, d); |
||||
|
dtemp.setDate(dtemp.getDate() - i); |
||||
|
result.push({ |
||||
|
time: dtemp, |
||||
|
show: true, |
||||
|
fullDate: formatDate(dtemp, 'yyyy-MM-dd'), |
||||
|
isToday: equalDate(new Date(), dtemp), |
||||
|
}); |
||||
|
} |
||||
|
for (let i = 0; i <= 7 - weekIndex; i++) { |
||||
|
const dtemp = new Date(y, m, d); |
||||
|
dtemp.setDate(dtemp.getDate() + i); |
||||
|
result.push({ |
||||
|
time: dtemp, |
||||
|
show: true, |
||||
|
fullDate: formatDate(dtemp, 'yyyy-MM-dd'), |
||||
|
isToday: equalDate(new Date(), dtemp), |
||||
|
}); |
||||
|
} |
||||
|
} else if (type === 'month') { |
||||
|
// 上个月
|
||||
|
for (let i = weekIndex; i > 0; i--) { |
||||
|
const dtemp = new Date(y, m, 1); |
||||
|
dtemp.setDate(dtemp.getDate() - i); |
||||
|
result.push({ |
||||
|
time: dtemp, |
||||
|
show: false, |
||||
|
fullDate: formatDate(dtemp, 'yyyy-MM-dd'), |
||||
|
isToday: equalDate(new Date(), dtemp), |
||||
|
}); |
||||
|
} |
||||
|
// 这个月的日期
|
||||
|
for (let i = 0; i < days; i++) { |
||||
|
const dtemp = new Date(y, m, 1); |
||||
|
dtemp.setDate(dtemp.getDate() + i); |
||||
|
result.push({ |
||||
|
time: dtemp, |
||||
|
show: true, |
||||
|
fullDate: formatDate(dtemp, 'yyyy-MM-dd'), |
||||
|
isToday: equalDate(new Date(), dtemp), |
||||
|
}); |
||||
|
} |
||||
|
const len = 42 - result.length; |
||||
|
// 下个月的日期
|
||||
|
for (let i = 1; i <= len; i++) { |
||||
|
const dtemp = new Date(y, m + 1, 0); |
||||
|
dtemp.setDate(dtemp.getDate() + i); |
||||
|
result.push({ |
||||
|
time: dtemp, |
||||
|
show: false, |
||||
|
fullDate: formatDate(dtemp, 'yyyy-MM-dd'), |
||||
|
isToday: equalDate(new Date(), dtemp), |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
}; |
@ -0,0 +1,7 @@ |
|||||
|
<template> |
||||
|
<view class="flex items-center justify-between"> |
||||
|
这是子项目 |
||||
|
</template> |
||||
|
<script> |
||||
|
export default {}; |
||||
|
</script> |
@ -0,0 +1,72 @@ |
|||||
|
<template> |
||||
|
<view class="py-3 mt-4 bg-white"> |
||||
|
<view v-for="(project, index) in projects" :key="index"> |
||||
|
<!-- 有子项目 --> |
||||
|
<view class="flex items-center justify-between p-3"> |
||||
|
<view class="text-blue-400 border border-blue-200 rounded-full order bg-blue-50"> |
||||
|
{{ index + 1 }} |
||||
|
</view> |
||||
|
|
||||
|
<view class="flex-1 px-3"> |
||||
|
<view class="flex items-center mb-1"> |
||||
|
<view class="mr-2">{{ project.name }}</view> |
||||
|
<!-- 状态 TODO:--> |
||||
|
<view class="px-2 text-xs text-green-400 bg-green-100 rounded-full">进行中</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="flex items-center text-xs text-gray-400"> |
||||
|
<view class="pr-2">{{ $moment(+project.startTime).format('MM-DD HH:mm') }}</view> |
||||
|
至 |
||||
|
<view class="pl-2"> {{ $moment(+project.endTime).format('MM-DD HH:mm') }}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<!-- 箭头 --> |
||||
|
<u-icon name="arrow-right" class="text-gray-400" size="14px" @click="openProject(project)"></u-icon> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { mapGetters, mapState } from 'vuex'; |
||||
|
|
||||
|
export default { |
||||
|
data() { |
||||
|
return {}; |
||||
|
}, |
||||
|
|
||||
|
computed: { |
||||
|
...mapState('project', ['projects']), |
||||
|
...mapGetters('user', ['userId']), |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
/** |
||||
|
* 打开项目 |
||||
|
* @param {object} project 所点击的项目的信息 |
||||
|
*/ |
||||
|
openProject(project) { |
||||
|
const { name, id, url } = project; |
||||
|
url && (uni.$t.domain = url); |
||||
|
this.$u.route('pages/project/project', { |
||||
|
u: this.userId, |
||||
|
p: id, |
||||
|
pname: name, |
||||
|
url: encodeURIComponent(url), |
||||
|
}); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.order { |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
width: 32px; |
||||
|
height: 32px; |
||||
|
font-size: 13px; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1 @@ |
|||||
|
Subproject commit 2603a0bc8b5036c399a5f28b93586072c4850c4b |
@ -0,0 +1,38 @@ |
|||||
|
<template> |
||||
|
<view class="upload"> |
||||
|
<view @tap="handleUpload"> |
||||
|
<u-icon name="plus" color="#ffffff" size="24px" class="flex justify-center w-12 h-12 bg-blue-100 rounded-full shadow-md"></u-icon> |
||||
|
</view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
methods: { |
||||
|
// 倒入wbs |
||||
|
async handleUpload() { |
||||
|
try { |
||||
|
const data = await this.$u.api.import(); |
||||
|
// 导入WBS成功后 |
||||
|
// 直接打开导入的项目 |
||||
|
console.log('data: ', data); |
||||
|
} catch (error) { |
||||
|
this.$emit('show-alert', error); |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.upload { |
||||
|
position: absolute; |
||||
|
right: 10px; |
||||
|
bottom: 0; |
||||
|
transform: translate3d(0, 50%, 0); |
||||
|
} |
||||
|
|
||||
|
/deep/ .uicon-plus { |
||||
|
color: theme('colors.blue.500') !important; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,92 @@ |
|||||
|
<template> |
||||
|
<view class="bg-gray-50"> |
||||
|
<view class="relative"> |
||||
|
<!-- 日历 --> |
||||
|
<Calendar @selected-change="onDateChange" :show-back="true" :dot-list="days" /> |
||||
|
<!-- 上传 导入wbs --> |
||||
|
<Upload @show-alert="onShowAlert" /> |
||||
|
</view> |
||||
|
|
||||
|
<!-- 项目列表 --> |
||||
|
<Projects /> |
||||
|
|
||||
|
<!-- 全局提示框 --> |
||||
|
<u-alert-tips |
||||
|
class="top-0 -inset-x-0" |
||||
|
style="position: fixed !important" |
||||
|
type="error" |
||||
|
:close-able="true" |
||||
|
:title="alert.title" |
||||
|
:show="alert.show" |
||||
|
:description="alert.description" |
||||
|
@close="alert.show = false" |
||||
|
></u-alert-tips> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { mapState, mapMutations } from 'vuex'; |
||||
|
|
||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
days: [ |
||||
|
{ date: '2020-08-14' }, |
||||
|
{ date: '2020-08-27' }, |
||||
|
{ date: '2020-08-09' }, |
||||
|
// {date: '2020-08-16'} |
||||
|
], |
||||
|
alert: { |
||||
|
show: false, |
||||
|
title: '', |
||||
|
description: '', |
||||
|
}, |
||||
|
}; |
||||
|
}, |
||||
|
|
||||
|
computed: mapState('user', ['token']), |
||||
|
|
||||
|
watch: { |
||||
|
token(value) { |
||||
|
if (!value) return; |
||||
|
this.getProjects(); |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
onShow() { |
||||
|
console.log('index onShow'); |
||||
|
if (!this.token) return; |
||||
|
this.getProjects(); |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
...mapMutations('project', ['setProjects']), |
||||
|
|
||||
|
// 获取项目列表 |
||||
|
async getProjects(start = this.$moment().startOf('day').valueOf(), end = this.$moment().endOf('day').valueOf()) { |
||||
|
try { |
||||
|
const data = await this.$u.api.getProjects(start, end); |
||||
|
this.setProjects(data); |
||||
|
} catch (error) { |
||||
|
console.log('error: ', error); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
changeList() { |
||||
|
this.days = [{ date: '2021-08-03' }, { date: '2021-08-04' }, { date: '2021-08-06' }]; |
||||
|
}, |
||||
|
|
||||
|
onDateChange(event) { |
||||
|
console.log(event); |
||||
|
}, |
||||
|
|
||||
|
// 受到展示alert的消息 |
||||
|
onShowAlert(event) { |
||||
|
this.alert.description = event || '发生了点小意外'; |
||||
|
this.alert.show = true; |
||||
|
|
||||
|
setTimeout(() => (this.alert.show = false), 10000); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
@ -0,0 +1,7 @@ |
|||||
|
<template> |
||||
|
<view>交付物检查</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default {}; |
||||
|
</script> |
@ -0,0 +1,7 @@ |
|||||
|
<template> |
||||
|
<view>成员管理</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default {}; |
||||
|
</script> |
@ -0,0 +1,7 @@ |
|||||
|
<template> |
||||
|
<view>项目管理</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default {}; |
||||
|
</script> |
@ -0,0 +1,7 @@ |
|||||
|
<template> |
||||
|
<view>角色管理</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default {}; |
||||
|
</script> |
@ -0,0 +1,7 @@ |
|||||
|
<template> |
||||
|
<view>任务管理</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default {}; |
||||
|
</script> |
@ -1,11 +1,16 @@ |
|||||
<template> |
<template> |
||||
<!-- 任务描述 --> |
<!-- 任务描述 --> |
||||
<view>{{ text }}</view> |
<view>{{ task.description }}</view> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
export default { |
export default { |
||||
name: 'p-task-description', |
name: 'p-task-description', |
||||
props: { text: { type: String, default: '' } }, |
props: { |
||||
|
task: { |
||||
|
type: Object, |
||||
|
default: () => {}, |
||||
|
}, |
||||
|
}, |
||||
}; |
}; |
||||
</script> |
</script> |
||||
|
@ -1,11 +1,16 @@ |
|||||
<template> |
<template> |
||||
<!-- 任务名插件 --> |
<!-- 任务名插件 --> |
||||
<view>{{ name }}</view> |
<view>{{ task.name }}</view> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
export default { |
export default { |
||||
name: 'p-task-title', |
name: 'p-task-title', |
||||
props: { name: { type: String, default: '' } }, |
props: { |
||||
|
task: { |
||||
|
type: Object, |
||||
|
default: () => {}, |
||||
|
}, |
||||
|
}, |
||||
}; |
}; |
||||
</script> |
</script> |
||||
|
@ -0,0 +1,3 @@ |
|||||
|
<template> |
||||
|
<view>导入wbs</view> |
||||
|
</template> |
After Width: | Height: | Size: 853 B |
@ -1,6 +1,7 @@ |
|||||
/* eslint-disable */ |
/* eslint-disable */ |
||||
const state = { |
const state = { |
||||
project: { name: '加载中...' }, // 当前项目信息
|
project: { name: '加载中...' }, // 当前项目信息
|
||||
|
projects: [], // 项目列表
|
||||
}; |
}; |
||||
|
|
||||
export default state; |
export default state; |
||||
|
@ -0,0 +1,50 @@ |
|||||
|
export default { |
||||
|
/** |
||||
|
* 上传单个文件 |
||||
|
* @param {string} url 服务器地址 |
||||
|
* @param {object} formData 上传的其他字段 |
||||
|
* @param {array} extension 上传文件类型 扩展名数组 |
||||
|
* @param {string} name |
||||
|
* @returns |
||||
|
*/ |
||||
|
chooseAndUpload(url, formData = {}, extension = ['.xls', '.xlsx'], name = 'param') { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
const token = uni.$t.storage.getStorageSync(uni.$t.app.tokenKey); |
||||
|
if (!token) { |
||||
|
return reject('用户未登录,请登录后重试'); |
||||
|
} |
||||
|
uni.chooseFile({ |
||||
|
count: 1, //默认100
|
||||
|
extension, |
||||
|
success: res => { |
||||
|
uni.uploadFile({ |
||||
|
url, |
||||
|
filePath: res.tempFilePaths[0], |
||||
|
name, |
||||
|
formData, |
||||
|
header: { Authorization: `Bearer ${token}` }, |
||||
|
success: ({ data, statusCode }) => { |
||||
|
console.log('data, statusCode: ', data, statusCode); |
||||
|
if (statusCode === 200 && data) { |
||||
|
const { code, msg } = JSON.parse(data); |
||||
|
if (code !== 200) { |
||||
|
reject(msg); |
||||
|
} else { |
||||
|
resolve(data.data); |
||||
|
} |
||||
|
} else { |
||||
|
reject('上传失败'); |
||||
|
} |
||||
|
}, |
||||
|
fail: error => { |
||||
|
reject(error); |
||||
|
}, |
||||
|
}); |
||||
|
}, |
||||
|
fail: error => { |
||||
|
reject(error); |
||||
|
}, |
||||
|
}); |
||||
|
}); |
||||
|
}, |
||||
|
}; |
Loading…
Reference in new issue