Browse Source

feat: 项目操作面板

refact
xuesinan 4 years ago
parent
commit
3beb05e3cd
  1. 20
      CHANGELOG.md
  2. 66
      components/PrettyExchange/PrettyExchange.vue
  3. 63
      components/Projects/ProjectItem.vue
  4. 17
      pages/index/index.vue

20
CHANGELOG.md

@ -3,7 +3,9 @@
### 🌟 新功能
范围|描述|commitId
--|--|--
- | 更新代码 | [392c8cc](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/392c8cc)
- | 日历页首页 | [561c8e6](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/561c8e6)
- | 日历页添加 | [1b46a91](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/1b46a91)
- | 使用uview完成api请求 | [1b3efd8](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/1b3efd8)
- | 项目列表 | [a52e6d5](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/a52e6d5)
- | app.vue | [970cf9a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/970cf9a)
@ -11,6 +13,24 @@
- | vue3 | [12ed2ad](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/12ed2ad)
### 🎨 代码样式
范围|描述|commitId
--|--|--
- | calender格式及细节调整 | [db9602b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/db9602b)
### 🚀 性能优化
范围|描述|commitId
--|--|--
- | 更新代码 | [0dd443b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/0dd443b)
### chore
范围|描述|commitId
--|--|--
- | editorconfig update | [0c08089](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/0c08089)
范围|描述|commitId
--|--|--
- | Initial commit | [52b8f49](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/52b8f49)

66
components/PrettyExchange/PrettyExchange.vue

@ -3,15 +3,27 @@
<scroll-view scroll-y="true">
<view v-if="!data.changeEvent">
<view :id="'cu-' + index" :key="item.id" class="cu-item flex-col" v-for="(item, index) in data.itemList">
<ProjectItem class="w-full" :index="index" :item="item" :menuList="menuList" @setData="setData"
@openSubProject="openSubProject" />
<ProjectItem
class="w-full"
:index="index"
:item="item"
:menuList="data.menuList"
@setData="setData"
@openSubProject="openSubProject"
/>
</view>
</view>
<view v-else>
<view :id="'cu-' + index" :key="index" :style="{ 'background-color': item.color }"
@touchend="stops($event, index)" @touchmove.stop.prevent="move" @touchstart="start($event, index)"
class="cu-item flex-col" v-for="(item, index) in itemList">
<view
:id="'cu-' + index"
:key="index"
:style="{ 'background-color': item.color }"
@touchend="stops($event, index)"
@touchmove.stop.prevent="move"
@touchstart="start($event, index)"
class="cu-item flex-col" v-for="(item, index) in data.itemList"
>
<view class="border-100 bg-blue-500" v-if="item.showTopBorder"></view>
<!-- 内容区 -->
@ -24,23 +36,20 @@
<view class="flex items-center mb-1">
<view class="mr-2">{{ item.name }}</view>
<!-- 状态 TODO:-->
<view class="px-2 text-xs text-green-400 bg-green-100 rounded-full flex-shrink-0">
进行中</view>
<view class="px-2 text-xs text-green-400 bg-green-100 rounded-full flex-shrink-0">进行中</view>
</view>
<view class="flex items-center text-xs text-gray-400">
<view class="pr-2">{{ $moment(+item.startTime).format('MM-DD HH:mm') }}</view>
<view class="pr-2">{{ dayjs(+item.startTime).format('MM-DD HH:mm') }}</view>
<view class="pl-2">{{ $moment(+item.endTime).format('MM-DD HH:mm') }}</view>
<view class="pl-2">{{ dayjs(+item.endTime).format('MM-DD HH:mm') }}</view>
</view>
</view>
<!-- 箭头 -->
<view v-if="item.sonProjectList && item.sonProjectList.length">
<u-icon @click="openSubProject(item.sonProjectList.length, index)" class="text-gray-400"
name="arrow-up" size="14px" v-if="item.show"></u-icon>
<u-icon @click="openSubProject(item.sonProjectList.length, index)" class="text-gray-400"
name="arrow-down" size="14px" v-else></u-icon>
<u-icon @click="openSubProject(item.sonProjectList.length, index)" class="text-gray-400" name="arrow-up" size="14px" v-if="item.show"></u-icon>
<u-icon @click="openSubProject(item.sonProjectList.length, index)" class="text-gray-400" name="arrow-down" size="14px" v-else></u-icon>
</view>
<u-icon class="text-gray-400" name="arrow-right" size="14px" v-else></u-icon>
</view>
@ -62,7 +71,15 @@
<view class="mr-2">{{ subItem.name }}</view>
<!-- 状态 -->
<view
:class="subItem.status === 0 ? 'text-blue-400 bg-blue-100' : subItem.status === 1 ? 'text-green-400 bg-green-100' : subItem.status === 2 ? 'text-red-400 bg-red-100' : 'text-gray-400 bg-gray-100'"
:class="
subItem.status === 0
? 'text-blue-400 bg-blue-100'
: subItem.status === 1
? 'text-green-400 bg-green-100'
: subItem.status === 2
? 'text-red-400 bg-red-100'
: 'text-gray-400 bg-gray-100'
"
class="px-2 text-xs text-gray-400 bg-gray-100 rounded-full flex-shrink-0">
{{ subItem.status === 0 ? '未开始' : subItem.status === 1 ? '进行中' : subItem.status === 2 ? '暂停' : '已完成' }}
</view>
@ -84,7 +101,7 @@
</scroll-view>
<!-- 移动悬浮 begin -->
<view v-if="showMoveImage">
<view v-if="data.showMoveImage">
<view :style="{ left: moveLeft + 'px', top: moveTop + 'px' }" class="cu-item absolute">
<ProjectItem class="w-full" :item="moveItem" />
</view>
@ -92,7 +109,7 @@
<!-- 移动悬浮 end -->
<!-- 项目操作面板 -->
<u-action-sheet :list="menuList" :tips="tips" @click="chooseAction" v-model="showMenu"></u-action-sheet>
<u-action-sheet :list="data.menuList" :tips="data.tips" @click="chooseAction" v-model="data.showMenu"></u-action-sheet>
</view>
</template>
@ -100,6 +117,7 @@
import { ref, onMounted, watch, computed } from 'vue';
import ProjectItem from '@/components/Projects/ProjectItem.vue';
import { useStore } from 'vuex';
import dayjs from 'dayjs';
const store = useStore();
const projects = computed(() => store.state.project.projects);
@ -142,8 +160,6 @@
item.showSubBorder = false;
item.showTopBorder = false;
});
console.log('watch', data.value.itemList)
})
onMounted(() => {
@ -153,8 +169,6 @@
item.showSubBorder = false;
item.showTopBorder = false;
});
console.log('onMounted', data.value.itemList)
});
//
@ -183,9 +197,9 @@
}
function chooseAction(e) {
let data = { index: e, projectId: data.value.projectId };
let obj = { index: e, projectId: data.value.projectId };
// this.$emit('chooseAction', data);
actionFun(data);
actionFun(obj);
}
//
@ -193,7 +207,7 @@
let action = data.value.menuList[obj.index].text;
if (action === '排序') {
data.value.changeEvent = true;
this.$ui.showToast('请移动进行排序');
uni.$ui.showToast('请移动进行排序');
}
if (action === '删除') {
@ -219,6 +233,7 @@
if (isNumber(index)) {
data.value.setSubItem = false;
const query = uni.createSelectorQuery().in(this);
console.log('2222', query)
query.select(`#cu-${index}`).boundingClientRect(res => {
data.value.moveTop = res.top;
data.value.moveLeft = res.left;
@ -255,8 +270,9 @@
}
data.value.moveLeft = touch.pageX - data.value.deltaLeft;
data.value.moveTop = touch.pageY - data.value.deltaTop;
let lastIndex = (lastIndex = findOverIndex(touch.pageY, length));
let lastIndex = (lastIndex = findOverIndex(touch.pageY, length));
console.log('111111', lastIndex);
// 线
for (let i = 0; i < data.value.itemList.length; i++) {
if (data.value.moveLeft > 35) {

63
components/Projects/ProjectItem.vue

@ -76,15 +76,11 @@
</view>
</view>
</view>
<!-- 项目操作面板 -->
<!-- <u-action-sheet :list="menuList" :tips="tips" @click="$emit('chooseAction', $event)" v-model="showMenu"></u-action-sheet> -->
<!-- <u-action-sheet :list="menuList" :tips="tips" @click="chooseAction" v-model="showMenu"></u-action-sheet> -->
</view>
</template>
<script setup>
import { ref } from 'vue';
import { ref, computed } from 'vue';
import dayjs from 'dayjs';
defineProps({
@ -101,15 +97,56 @@
default: () => [],
},
});
const emit = defineEmits(['setData']);
const userId = computed(() => store.getters['user/userId']);
const data = ref({
showMenu: false,
tips: {
text: '',
color: '#909399',
fontSize: 28,
},
// show: false,
// border: 'border border-blue-500 shadow rounded-md',
// showBorder: false,
projectId: 0,
})
//
function openProject(project) {
const { name, id, url } = project;
url && (uni.$t.domain = url);
this.$u.route('pages/project-webview/project-webview', {
u: userId.value,
p: id,
pname: name,
url: encodeURIComponent(url),
});
}
/**
* 弹出项目操作面板
*/
function openMenu(project) {
data.value.showMenu = true;
data.value.projectId = project.id;
data.value.tips.text = project.name;
emit('setData', data.value.showMenu, data.value.projectId, data.value.tips);
// this.$emit('setData', data.value.showMenu, data.value.projectId, data.value.tips);
}
</script>
<style lang="scss" scoped>
.border-100 {
height: 4rpx;
margin: 0 20rpx;
}
.border-80 {
height: 4rpx;
margin: 0 20rpx 0 90rpx;
}
.border-100 {
height: 4rpx;
margin: 0 20rpx;
}
.border-80 {
height: 4rpx;
margin: 0 20rpx 0 90rpx;
}
</style>

17
pages/index/index.vue

@ -1,5 +1,6 @@
<template>
<view class="flex flex-col h-full bg-gray-50" @click="openAuth">
<!-- <view class="flex flex-col h-full bg-gray-50" @click="openAuth"> -->
<view class="flex flex-col h-full bg-gray-50">
<view class="relative" @touchmove="onMove">
<!-- 日历 -->
<Calendar @selected-change="onDateChange" :show-back="true" ref="calendar"
@ -89,6 +90,20 @@
duration: '6000',
});
};
// /
function onMove(event) {
const y = event.changedTouches[0].pageY;
if (y - prevY > 0) {
// weekMode=true weekMode=false
data.value.calendar.weekMode && (data.value.calendar.weekMode = false);
} else if (y - prevY < 0) {
// weekMode=false weekMode=true
!data.value.calendar.weekMode && (data.value.calendar.weekMode = true);
}
prevY = y;
data.value.calendar.initDate();
}
</script>
<style>

Loading…
Cancel
Save