项目排产,甘特图待完善
This commit is contained in:
44
api/oa/reportSchedule.js
Normal file
44
api/oa/reportSchedule.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import request from "@/util/oaRequest"
|
||||
|
||||
// 查询项目排产列表
|
||||
export function listReportSchedule(query) {
|
||||
return request({
|
||||
url: '/oa/reportSchedule/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询项目排产详细
|
||||
export function getReportSchedule(scheduleId) {
|
||||
return request({
|
||||
url: '/oa/reportSchedule/' + scheduleId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增项目排产
|
||||
export function addReportSchedule(data) {
|
||||
return request({
|
||||
url: '/oa/reportSchedule',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改项目排产
|
||||
export function updateReportSchedule(data) {
|
||||
return request({
|
||||
url: '/oa/reportSchedule',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除项目排产
|
||||
export function delReportSchedule(scheduleId) {
|
||||
return request({
|
||||
url: '/oa/reportSchedule/' + scheduleId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
16
pages.json
16
pages.json
@@ -293,6 +293,22 @@
|
||||
"navigationBarTitleText" : "任务详情",
|
||||
"navigationStyle": "default"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/workbench/reportSchedule/reportSchedule",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "项目排产",
|
||||
"navigationStyle": "default"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/workbench/reportSchedule/gantt",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "项目排产",
|
||||
"navigationStyle": "default"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tabBar": {
|
||||
|
||||
@@ -14,10 +14,14 @@
|
||||
<image class="entry-icon" src="/static/images/shigong.png" mode="aspectFit" />
|
||||
<text class="entry-text">施工进度</text>
|
||||
</view>
|
||||
<view class="entry-item" @click="goTask">
|
||||
<image class="entry-icon" src="/static/images/task.png" mode="aspectFit"></image>
|
||||
<text class="entry-text">任务中心</text>
|
||||
</view>
|
||||
<view class="entry-item" @click="goTask">
|
||||
<image class="entry-icon" src="/static/images/task.png" mode="aspectFit"></image>
|
||||
<text class="entry-text">任务中心</text>
|
||||
</view>
|
||||
<view class="entry-item" @click="goSchedule">
|
||||
<image class="entry-icon" src="/static/images/paichan.png" mode="aspectFit"></image>
|
||||
<text class="entry-text">项目排产</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -59,11 +63,16 @@ export default {
|
||||
url: '/pages/workbench/construction/construction'
|
||||
});
|
||||
},
|
||||
goTask() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/workbench/task/task'
|
||||
})
|
||||
}
|
||||
goTask() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/workbench/task/task'
|
||||
})
|
||||
},
|
||||
goSchedule() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/workbench/reportSchedule/reportSchedule'
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
249
pages/workbench/reportSchedule/gantt.vue
Normal file
249
pages/workbench/reportSchedule/gantt.vue
Normal file
@@ -0,0 +1,249 @@
|
||||
<template>
|
||||
<view class="gantt-container">
|
||||
<scroll-view scroll-x class="gantt-scroll-x">
|
||||
<view class="gantt-table">
|
||||
<!-- 时间轴头部 -->
|
||||
<view class="gantt-header-row">
|
||||
<view class="gantt-header-cell gantt-project-col">项目</view>
|
||||
<view class="gantt-header-cell gantt-date-col" v-for="d in dateList" :key="d">{{ d.slice(5) }}</view>
|
||||
</view>
|
||||
<!-- 任务条 -->
|
||||
<view v-for="(task, idx) in tasks" :key="idx" class="gantt-row">
|
||||
<view class="gantt-project-col gantt-task-label">{{ task.projectName }}</view>
|
||||
<view class="gantt-bar-area" :style="{ minWidth: (dateList.length * cellWidth) + 'rpx' }">
|
||||
<view
|
||||
class="gantt-bar"
|
||||
:style="getBarStyle(task)"
|
||||
@click="showDetail(task)"
|
||||
>
|
||||
<text class="gantt-bar-text">{{ task.scheduleName }}({{ task.headerName }})</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 详情弹窗 -->
|
||||
<uni-popup ref="detailPopup" type="center" :mask-click="true">
|
||||
<view class="detail-popup-content" v-if="currentTask">
|
||||
<view class="detail-title">排产详情</view>
|
||||
<view class="detail-row"><text class="detail-label">项目:</text>{{ currentTask.projectName }}</view>
|
||||
<view class="detail-row"><text class="detail-label">排产名称:</text>{{ currentTask.scheduleName }}</view>
|
||||
<view class="detail-row"><text class="detail-label">负责人:</text>{{ currentTask.headerName }}</view>
|
||||
<view class="detail-row"><text class="detail-label">开始日期:</text>{{ currentTask.startDate }}</view>
|
||||
<view class="detail-row"><text class="detail-label">结束日期:</text>{{ currentTask.endDate }}</view>
|
||||
<view class="detail-row"><text class="detail-label">备注:</text>{{ currentTask.remark || '-' }}</view>
|
||||
<view class="detail-btns">
|
||||
<button class="detail-btn" @click="closeDetail">关闭</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
|
||||
function dateDiffInDays(a, b) {
|
||||
return Math.floor((new Date(a) - new Date(b)) / (1000 * 60 * 60 * 24));
|
||||
}
|
||||
export default {
|
||||
components: { uniPopup },
|
||||
props: {
|
||||
chartData: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentTask: null,
|
||||
cellWidth: 80 // 每个日期格子的宽度,单位 rpx
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
tasks() {
|
||||
if (!this.chartData || !this.chartData.series || !this.chartData.series[0] || !this.chartData.series[0].data) return []
|
||||
return this.chartData.series[0].data
|
||||
},
|
||||
minDate() {
|
||||
if (!this.tasks.length) return null
|
||||
const min = this.tasks.reduce((min, t) => t.startDate < min ? t.startDate : min, this.tasks[0].startDate)
|
||||
const d = new Date(min)
|
||||
d.setDate(d.getDate() - 2)
|
||||
return d.toISOString().slice(0, 10)
|
||||
},
|
||||
maxDate() {
|
||||
if (!this.tasks.length) return null
|
||||
const max = this.tasks.reduce((max, t) => t.endDate > max ? t.endDate : max, this.tasks[0].endDate)
|
||||
const d = new Date(max)
|
||||
d.setDate(d.getDate() + 2)
|
||||
return d.toISOString().slice(0, 10)
|
||||
},
|
||||
dateList() {
|
||||
if (!this.minDate || !this.maxDate) return []
|
||||
const res = []
|
||||
let cur = new Date(this.minDate)
|
||||
const end = new Date(this.maxDate)
|
||||
while (cur <= end) {
|
||||
res.push(cur.toISOString().slice(0, 10))
|
||||
cur.setDate(cur.getDate() + 1)
|
||||
}
|
||||
return res
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getBarStyle(task) {
|
||||
if (!this.minDate || !this.maxDate) return {}
|
||||
const startOffset = dateDiffInDays(task.startDate, this.minDate)
|
||||
const duration = dateDiffInDays(task.endDate, task.startDate) + 1
|
||||
const left = startOffset * this.cellWidth + 'rpx'
|
||||
const width = duration * this.cellWidth + 'rpx'
|
||||
return {
|
||||
left,
|
||||
width,
|
||||
position: 'absolute',
|
||||
height: '32rpx',
|
||||
background: '#2979ff',
|
||||
borderRadius: '8rpx',
|
||||
color: '#fff',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontSize: '24rpx',
|
||||
padding: '0 12rpx',
|
||||
boxSizing: 'border-box',
|
||||
minWidth: '60rpx',
|
||||
zIndex: 2
|
||||
}
|
||||
},
|
||||
showDetail(task) {
|
||||
this.currentTask = task
|
||||
this.$refs.detailPopup.open('center')
|
||||
},
|
||||
closeDetail() {
|
||||
this.$refs.detailPopup.close()
|
||||
this.currentTask = null
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.gantt-container {
|
||||
padding: 24rpx;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.gantt-scroll-x {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.gantt-table {
|
||||
min-width: 800rpx;
|
||||
}
|
||||
.gantt-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 8rpx 8rpx 0 0;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
.gantt-header-cell {
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
color: #888;
|
||||
padding: 0 8rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.gantt-project-col {
|
||||
width: 200rpx;
|
||||
min-width: 200rpx;
|
||||
text-align: right;
|
||||
font-weight: bold;
|
||||
color: #2979ff;
|
||||
background: #f0f7ff;
|
||||
border-right: 1rpx solid #e0e0e0;
|
||||
padding-right: 12rpx;
|
||||
}
|
||||
.gantt-date-col {
|
||||
width: 80rpx;
|
||||
min-width: 80rpx;
|
||||
}
|
||||
.gantt-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 64rpx;
|
||||
position: relative;
|
||||
}
|
||||
.gantt-task-label {
|
||||
font-size: 24rpx;
|
||||
color: #2979ff;
|
||||
padding-right: 12rpx;
|
||||
}
|
||||
.gantt-bar-area {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
height: 64rpx;
|
||||
background: transparent;
|
||||
/* min-width 由内联 style 动态设置 */
|
||||
}
|
||||
.gantt-bar {
|
||||
position: absolute;
|
||||
top: 16rpx;
|
||||
height: 40rpx;
|
||||
background: #2979ff;
|
||||
border-radius: 8rpx;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24rpx;
|
||||
padding: 0 12rpx;
|
||||
min-width: 60rpx;
|
||||
z-index: 2;
|
||||
box-shadow: 0 2rpx 8rpx rgba(41,121,255,0.08);
|
||||
cursor: pointer;
|
||||
}
|
||||
.gantt-bar-text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
/* 详情弹窗样式 */
|
||||
.detail-popup-content {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 40rpx 32rpx 24rpx 32rpx;
|
||||
min-width: 480rpx;
|
||||
max-width: 90vw;
|
||||
}
|
||||
.detail-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #2979ff;
|
||||
margin-bottom: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.detail-row {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 18rpx;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.detail-label {
|
||||
color: #888;
|
||||
min-width: 120rpx;
|
||||
display: inline-block;
|
||||
}
|
||||
.detail-btns {
|
||||
margin-top: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.detail-btn {
|
||||
background: #2979ff;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8rpx;
|
||||
padding: 16rpx 48rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
768
pages/workbench/reportSchedule/reportSchedule.vue
Normal file
768
pages/workbench/reportSchedule/reportSchedule.vue
Normal file
@@ -0,0 +1,768 @@
|
||||
<template>
|
||||
<view class="report-schedule">
|
||||
<!-- 视图切换按钮 -->
|
||||
<view class="gantt-toggle-bar">
|
||||
<u-button :type="!showGanttView ? 'primary' : 'default'" size="mini"
|
||||
@click="showGanttView = false">表格视图</u-button>
|
||||
<u-button :type="showGanttView ? 'primary' : 'default'" size="mini" @click="showGanttView = true">甘特图视图</u-button>
|
||||
</view>
|
||||
|
||||
<gantt v-if="showGanttView" :chart-data="ganttChartData" />
|
||||
|
||||
<view v-else>
|
||||
<!-- 顶栏 -->
|
||||
<view class="search-bar">
|
||||
<view class="search-container">
|
||||
<view class="task-type-button-container">
|
||||
<view class="task-type-button" @click="openDrawer">
|
||||
<uni-icons type="list" color="#2979ff" size="22"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="search-input custom-search-input">
|
||||
<input v-model="searchName" class="input" type="text" placeholder="搜索排产名称" @confirm="onSearch"
|
||||
@keyup.enter="onSearch" />
|
||||
<view class="search-icon" @click="onSearch">
|
||||
<uni-icons type="search" color="#bbb" size="20"></uni-icons>
|
||||
</view>
|
||||
<view v-if="searchName" class="clear-icon" @click="onClearSearch">
|
||||
<uni-icons type="closeempty" color="#bbb" size="18"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="add-button" @click="handleAdd">
|
||||
<uni-icons type="plusempty" color="#2979ff" size="22"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 筛选抽屉 -->
|
||||
<uni-drawer ref="drawerRef" mode="left" :width="320">
|
||||
<view class="drawer-content">
|
||||
<view class="drawer-title">筛选</view>
|
||||
<view class="drawer-form">
|
||||
<view class="drawer-form-item">
|
||||
<text class="drawer-label">项目</text>
|
||||
<uni-data-select v-model="filterProject" :localdata="projectOptions" placeholder="请选择项目" :clear="true"
|
||||
filterable />
|
||||
</view>
|
||||
<view class="drawer-form-item">
|
||||
<text class="drawer-label">执行人</text>
|
||||
<uni-data-select v-model="filterHeader" :localdata="headerOptions" placeholder="请选择执行人" :clear="true"
|
||||
filterable />
|
||||
</view>
|
||||
<view class="drawer-form-item">
|
||||
<text class="drawer-label">日期</text>
|
||||
<uni-datetime-picker v-model="filterDateRange" type="daterange" rangeSeparator="至"
|
||||
start-placeholder="开始日期" end-placeholder="结束日期" :clear-icon="true" style="width:100%" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="drawer-btns">
|
||||
<button class="drawer-btn-primary" @click="applyFilterAndClose">确定</button>
|
||||
<button class="drawer-btn" @click="resetFilterAndClose">重置</button>
|
||||
<button class="drawer-btn" @click="closeDrawer">关闭</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-drawer>
|
||||
|
||||
<!-- 自定义列表,右滑菜单(uni-ui实现) -->
|
||||
<scroll-view scroll-y style="height: 100vh;" @scrolltolower="loadMore">
|
||||
<view v-if="reportScheduleList.length">
|
||||
<uni-swipe-action>
|
||||
<block v-for="(item, index) in reportScheduleList" :key="item.scheduleId">
|
||||
<uni-swipe-action-item :right-options="getSwipeOptions(item)" @click="swipeActionClick($event, item)"
|
||||
style="margin-bottom: 16rpx;">
|
||||
<view class="card">
|
||||
<view class="card-title">
|
||||
<text class="project">{{ item.scheduleName }}</text>
|
||||
<text class="status" :class="'status-' + item.status">
|
||||
{{ getStatusText(item.status) }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="card-content">
|
||||
<view>项目名称:{{ getProjectName(item.projectId) }}</view>
|
||||
<view>负责人:{{ getHeaderName(item.header) }}</view>
|
||||
<view>开始日期:{{ item.startDate }}</view>
|
||||
<view>结束日期:{{ item.endDate }}</view>
|
||||
<view>备注:{{ item.remark }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
</view>
|
||||
<view v-else class="empty">暂无数据</view>
|
||||
<view class="load-more-tips">
|
||||
<u-loading-icon v-if="loadingMore" text="加载中..." size="20" textSize="14" />
|
||||
<text v-else-if="!hasMore && reportScheduleList.length">没有更多了</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 新增/编辑弹窗 -->
|
||||
<uni-popup ref="popupRef" type="bottom">
|
||||
<view class="popup-content">
|
||||
<view class="uni-form">
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">项目</text>
|
||||
<uni-data-select v-model="form.projectId" :localdata="projectOptions" placeholder="请选择项目" filterable
|
||||
:clear="true" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">排产名称</text>
|
||||
<u-input v-model="form.scheduleName" placeholder="请输入排产名称" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">开始日期</text>
|
||||
<uni-datetime-picker v-model="form.startDate" type="datetime" placeholder="请选择开始日期" style="width:100%" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">结束日期</text>
|
||||
<uni-datetime-picker v-model="form.endDate" type="datetime" placeholder="请选择结束日期" style="width:100%" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">负责人</text>
|
||||
<uni-data-select v-model="form.header" :localdata="headerOptions" placeholder="请选择负责人" filterable
|
||||
:clear="true" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">备注</text>
|
||||
<u-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="popup-btns">
|
||||
<u-button type="primary" @click="submitForm">确定</u-button>
|
||||
<u-button @click="closePopup">取消</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 开始弹窗 -->
|
||||
<uni-popup ref="startPopupRef" type="bottom">
|
||||
<view class="popup-content">
|
||||
<view class="uni-form">
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">汇报标题</text>
|
||||
<u-input v-model="startForm.reportTitle" placeholder="请输入汇报标题" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">汇报日期</text>
|
||||
<uni-datetime-picker v-model="startForm.reportDate" type="datetime" placeholder="请选择汇报日期"
|
||||
style="width:100%" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">汇报人</text>
|
||||
<uni-data-select v-model="startForm.reporter" :localdata="headerOptions" placeholder="请选择汇报人" filterable
|
||||
:clear="true" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">涉及项目</text>
|
||||
<uni-data-select v-model="startForm.projectId" :localdata="projectOptions" placeholder="请选择项目" filterable
|
||||
:clear="true" />
|
||||
</view>
|
||||
<view class="uni-form-item">
|
||||
<text class="uni-form-label">备注</text>
|
||||
<u-input v-model="startForm.remark" type="textarea" placeholder="请输入内容" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="popup-btns">
|
||||
<u-button type="primary" :loading="startLoading" @click="submitStartForm">确定</u-button>
|
||||
<u-button @click="closeStartPopup">取消</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import uniSwipeAction from '@/uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action.vue'
|
||||
import uniSwipeActionItem from '@/uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item.vue'
|
||||
import uniDrawer from '@/uni_modules/uni-drawer/components/uni-drawer/uni-drawer.vue'
|
||||
import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
|
||||
import uniDataSelect from '@/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue'
|
||||
import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue'
|
||||
import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
|
||||
import gantt from './gantt.vue'
|
||||
import { listProject } from '@/api/oa/project'
|
||||
import { addReportSchedule, delReportSchedule, getReportSchedule, listReportSchedule, updateReportSchedule } from '@/api/oa/reportSchedule'
|
||||
import { listUser } from '@/api/oa/user'
|
||||
import { addReportSummary } from '@/api/oa/reportSummary'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
gantt,
|
||||
uniSwipeAction,
|
||||
uniSwipeActionItem,
|
||||
uniDrawer,
|
||||
uniIcons,
|
||||
uniDataSelect,
|
||||
uniDatetimePicker,
|
||||
uniPopup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId: '',
|
||||
scheduleName: '',
|
||||
header: '',
|
||||
dateRange: []
|
||||
},
|
||||
projectOptions: [],
|
||||
headerOptions: [],
|
||||
reportScheduleList: [],
|
||||
total: 0,
|
||||
single: true,
|
||||
multiple: true,
|
||||
form: {},
|
||||
viewType: 'table',
|
||||
showStartDate: false,
|
||||
showEndDate: false,
|
||||
swipeOptions: [
|
||||
{
|
||||
text: '编辑',
|
||||
style: {
|
||||
backgroundColor: '#2979ff',
|
||||
color: '#fff'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: '删除',
|
||||
style: {
|
||||
backgroundColor: '#fa3534',
|
||||
color: '#fff'
|
||||
}
|
||||
}
|
||||
],
|
||||
// 新增:筛选相关
|
||||
searchName: '',
|
||||
filterProject: '',
|
||||
filterHeader: '',
|
||||
filterDateRange: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
loadingMore: false,
|
||||
hasMore: true,
|
||||
startForm: {
|
||||
reportTitle: '',
|
||||
reportDate: '',
|
||||
reporter: '',
|
||||
projectId: '',
|
||||
remark: '',
|
||||
type: 1
|
||||
},
|
||||
startLoading: false,
|
||||
startPopupOpen: false,
|
||||
_startScheduleId: null,
|
||||
showGanttView: false,
|
||||
ganttChartData: {
|
||||
categories: [],
|
||||
series: []
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.pageNum = 1
|
||||
this.hasMore = true
|
||||
this.getProjectOptions()
|
||||
this.getHeaderOptions()
|
||||
this.handleQuery()
|
||||
},
|
||||
watch: {
|
||||
showGanttView(val) {
|
||||
if (val) {
|
||||
this.ganttChartData = this.getGanttChartData(this.reportScheduleList)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openDrawer() {
|
||||
this.$refs.drawerRef.open();
|
||||
},
|
||||
closeDrawer() {
|
||||
this.$refs.drawerRef.close();
|
||||
},
|
||||
applyFilterAndClose() {
|
||||
this.applyFilter();
|
||||
this.closeDrawer();
|
||||
},
|
||||
resetFilterAndClose() {
|
||||
this.resetFilter();
|
||||
this.closeDrawer();
|
||||
},
|
||||
getProjectOptions() {
|
||||
listProject().then(res => {
|
||||
this.projectOptions = (res.rows || []).map(item => ({
|
||||
text: item.projectName,
|
||||
value: item.projectId
|
||||
}))
|
||||
})
|
||||
},
|
||||
getHeaderOptions() {
|
||||
listUser().then(res => {
|
||||
this.headerOptions = (res.rows || []).map(item => ({
|
||||
text: item.nickName,
|
||||
value: item.userId
|
||||
}))
|
||||
})
|
||||
},
|
||||
// 搜索框检索
|
||||
onSearch() {
|
||||
this.searchName = this.searchName
|
||||
this.handleQuery()
|
||||
},
|
||||
onClearSearch() {
|
||||
this.searchName = ''
|
||||
this.queryParams.scheduleName = ''
|
||||
this.handleQuery()
|
||||
},
|
||||
// 筛选抽屉应用
|
||||
applyFilter() {
|
||||
this.queryParams.projectId = this.filterProject
|
||||
this.queryParams.header = this.filterHeader
|
||||
if (this.filterDateRange && this.filterDateRange.length === 2) {
|
||||
this.queryParams.dateRange = this.filterDateRange
|
||||
} else {
|
||||
this.queryParams.dateRange = []
|
||||
}
|
||||
this.handleQuery()
|
||||
},
|
||||
// 筛选抽屉重置
|
||||
resetFilter() {
|
||||
this.filterProject = ''
|
||||
this.filterHeader = ''
|
||||
this.filterDateRange = []
|
||||
},
|
||||
handleQuery() {
|
||||
this.pageNum = 1
|
||||
this.hasMore = true
|
||||
this.queryParams.pageNum = 1
|
||||
if (this.queryParams.dateRange && this.queryParams.dateRange.length === 2) {
|
||||
this.queryParams.startDate = this.queryParams.dateRange[0]
|
||||
this.queryParams.endDate = this.queryParams.dateRange[1]
|
||||
} else {
|
||||
this.queryParams.startDate = ''
|
||||
this.queryParams.endDate = ''
|
||||
}
|
||||
this.getList()
|
||||
},
|
||||
resetQuery() {
|
||||
this.queryParams = {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId: '',
|
||||
scheduleName: '',
|
||||
header: '',
|
||||
dateRange: []
|
||||
}
|
||||
this.searchName = ''
|
||||
this.pageNum = 1
|
||||
this.hasMore = true
|
||||
this.getList()
|
||||
},
|
||||
getList() {
|
||||
this.loadingMore = true
|
||||
this.queryParams.pageNum = this.pageNum
|
||||
this.queryParams.pageSize = this.pageSize
|
||||
listReportSchedule(this.queryParams).then(res => {
|
||||
const rows = res.rows || []
|
||||
if (this.pageNum === 1) {
|
||||
this.reportScheduleList = rows
|
||||
} else {
|
||||
this.reportScheduleList = this.reportScheduleList.concat(rows)
|
||||
}
|
||||
// 判断是否还有更多
|
||||
this.hasMore = rows.length === this.pageSize
|
||||
this.total = res.total || 0
|
||||
}).finally(() => {
|
||||
this.loadingMore = false
|
||||
})
|
||||
},
|
||||
loadMore() {
|
||||
if (!this.hasMore || this.loadingMore) return
|
||||
this.pageNum++
|
||||
this.getList()
|
||||
},
|
||||
handleAdd() {
|
||||
this.form = {}
|
||||
this.$refs.popupRef.open('bottom')
|
||||
},
|
||||
handleUpdate(row) {
|
||||
console.log('handleUpdate called', row);
|
||||
getReportSchedule(row.scheduleId).then(res => {
|
||||
this.form = res.data || {}
|
||||
this.$refs.popupRef.open('bottom')
|
||||
})
|
||||
},
|
||||
handleDelete(item) {
|
||||
console.log('handleDelete called', item);
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: `确定要删除排产“${item.scheduleName}”吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
const ids = item ? [item.scheduleId] : this.selectedIds
|
||||
delReportSchedule(ids).then(() => {
|
||||
uni.showToast({ title: '删除成功', icon: 'success' })
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
handleExport() {
|
||||
// 导出逻辑可根据实际API实现
|
||||
uni.showToast({ title: '导出功能开发中', icon: 'none' })
|
||||
},
|
||||
submitForm() {
|
||||
if (this.form.scheduleId) {
|
||||
updateReportSchedule(this.form).then(() => {
|
||||
uni.showToast({ title: '修改成功', icon: 'success' })
|
||||
this.closePopup()
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addReportSchedule(this.form).then(() => {
|
||||
uni.showToast({ title: '新增成功', icon: 'success' })
|
||||
this.closePopup()
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
},
|
||||
closePopup() {
|
||||
this.$refs.popupRef.close()
|
||||
},
|
||||
getSwipeOptions(item) {
|
||||
const options = [
|
||||
{
|
||||
text: '编辑',
|
||||
style: { backgroundColor: '#2979ff', color: '#fff' }
|
||||
},
|
||||
{
|
||||
text: '删除',
|
||||
style: { backgroundColor: '#fa3534', color: '#fff' }
|
||||
}
|
||||
];
|
||||
if (!item.status || item.status === 0) {
|
||||
options.push({
|
||||
text: '开始',
|
||||
style: { backgroundColor: '#19be6b', color: '#fff' }
|
||||
});
|
||||
}
|
||||
return options;
|
||||
},
|
||||
swipeActionClick(e, item) {
|
||||
console.log('swipeActionClick e:', e);
|
||||
console.log('swipeActionClick item:', item);
|
||||
if (e && e.content) {
|
||||
console.log('swipeActionClick e.content:', e.content);
|
||||
console.log('swipeActionClick e.content.text:', e.content.text);
|
||||
}
|
||||
const text = e.content.text;
|
||||
if (text === '编辑') {
|
||||
this.handleUpdate(item);
|
||||
} else if (text === '删除') {
|
||||
this.handleDelete(item);
|
||||
} else if (text === '开始') {
|
||||
this.handleStart(item);
|
||||
}
|
||||
},
|
||||
handleStart(row) {
|
||||
console.log('handleStart called', row);
|
||||
const now = new Date();
|
||||
const pad = n => n < 10 ? '0' + n : n;
|
||||
const formatDate = d => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
||||
this.startForm = {
|
||||
reportTitle: row.scheduleName,
|
||||
reportDate: formatDate(now),
|
||||
reporter: row.header,
|
||||
projectId: row.projectId,
|
||||
remark: row.remark,
|
||||
type: 1
|
||||
}
|
||||
this._startScheduleId = row.scheduleId
|
||||
this.openStartPopup()
|
||||
},
|
||||
openStartPopup() {
|
||||
this.$refs.startPopupRef.open('bottom')
|
||||
this.startPopupOpen = true
|
||||
},
|
||||
closeStartPopup() {
|
||||
this.$refs.startPopupRef.close()
|
||||
this.startPopupOpen = false
|
||||
},
|
||||
async submitStartForm() {
|
||||
if (!this.startForm.reportTitle || !this.startForm.reportDate || !this.startForm.reporter || !this.startForm.projectId) {
|
||||
uni.showToast({ title: '请填写完整', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.startLoading = true
|
||||
try {
|
||||
await addReportSummary(this.startForm)
|
||||
await updateReportSchedule({ scheduleId: this._startScheduleId, status: 1 })
|
||||
uni.showToast({ title: '开始成功', icon: 'success' })
|
||||
this.closeStartPopup()
|
||||
this.getList()
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '操作失败', icon: 'none' })
|
||||
} finally {
|
||||
this.startLoading = false
|
||||
}
|
||||
},
|
||||
getProjectName(id) {
|
||||
const p = this.projectOptions.find(i => i.value == id)
|
||||
return p ? p.text : id
|
||||
},
|
||||
getHeaderName(id) {
|
||||
const h = this.headerOptions.find(i => i.value == id)
|
||||
return h ? h.text : id
|
||||
},
|
||||
getStatusText(status) {
|
||||
if (status === 1) return '已开始'
|
||||
if (status === 0 || status === undefined) return '未开始'
|
||||
return '其他'
|
||||
},
|
||||
getGanttChartData(list) {
|
||||
if (!list || !list.length) {
|
||||
return { categories: [], series: [] }
|
||||
}
|
||||
// 只保留唯一 projectId
|
||||
const uniqueProjectIds = Array.from(new Set(list.map(item => item.projectId)))
|
||||
const categories = uniqueProjectIds.map(id => this.getProjectName(id))
|
||||
console.log(categories, '获取分类', list)
|
||||
|
||||
|
||||
const data = list.map(item => ({
|
||||
...item,
|
||||
projectName: this.getProjectName(item.projectId),
|
||||
headerName: this.getHeaderName(item.header),
|
||||
}))
|
||||
|
||||
return {
|
||||
categories,
|
||||
series: [
|
||||
{
|
||||
name: '进度',
|
||||
data
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.report-schedule {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
padding: 20rpx;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.task-type-button-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #f5f5f5;
|
||||
border-radius: 100rpx;
|
||||
padding: 0 24rpx;
|
||||
height: 60rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
background: transparent;
|
||||
font-size: 30rpx;
|
||||
outline: none;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
margin-left: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.clear-icon {
|
||||
margin-left: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.task-type-button,
|
||||
.add-button {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
background-color: transparent;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.drawer-content {
|
||||
padding: 32rpx 24rpx 24rpx 24rpx;
|
||||
}
|
||||
|
||||
.drawer-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.drawer-form {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.drawer-form-item {
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.drawer-label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.drawer-btns {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.drawer-btn-primary {
|
||||
flex: 1;
|
||||
background: #2979ff;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8rpx;
|
||||
padding: 16rpx 0;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.drawer-btn {
|
||||
flex: 1;
|
||||
background: #f5f5f5;
|
||||
color: #333;
|
||||
border: none;
|
||||
border-radius: 8rpx;
|
||||
padding: 16rpx 0;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.project {
|
||||
color: #2979ff;
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 24rpx;
|
||||
padding: 0 12rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.status-1 {
|
||||
background: #e0f7fa;
|
||||
color: #009688;
|
||||
}
|
||||
|
||||
.status-0,
|
||||
.status-undefined {
|
||||
background: #fffbe6;
|
||||
color: #faad14;
|
||||
}
|
||||
|
||||
.status-other {
|
||||
background: #fbeff2;
|
||||
color: #e91e63;
|
||||
}
|
||||
|
||||
.card-content view {
|
||||
margin-bottom: 8rpx;
|
||||
color: #666;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.empty {
|
||||
text-align: center;
|
||||
color: #bbb;
|
||||
margin: 40rpx 0;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
padding: 24rpx;
|
||||
background: #fff;
|
||||
border-radius: 16rpx 16rpx 0 0;
|
||||
}
|
||||
|
||||
.uni-form {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.uni-form-item {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.uni-form-label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.load-more-tips {
|
||||
text-align: center;
|
||||
color: #bbb;
|
||||
padding: 24rpx 0 32rpx 0;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.card-ops {
|
||||
margin-top: 16rpx;
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.gantt-toggle-bar {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
padding: 16rpx 0 8rpx 0;
|
||||
background: #fff;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
BIN
static/images/paichan.png
Normal file
BIN
static/images/paichan.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
13
uni_modules/uni-drawer/changelog.md
Normal file
13
uni_modules/uni-drawer/changelog.md
Normal file
@@ -0,0 +1,13 @@
|
||||
## 1.2.1(2021-11-22)
|
||||
- 修复 vue3中个别scss变量无法找到的问题
|
||||
## 1.2.0(2021-11-19)
|
||||
- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
|
||||
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-drawer](https://uniapp.dcloud.io/component/uniui/uni-drawer)
|
||||
## 1.1.1(2021-07-30)
|
||||
- 优化 vue3下事件警告的问题
|
||||
## 1.1.0(2021-07-13)
|
||||
- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
|
||||
## 1.0.7(2021-05-12)
|
||||
- 新增 组件示例地址
|
||||
## 1.0.6(2021-02-04)
|
||||
- 调整为uni_modules目录规范
|
||||
45
uni_modules/uni-drawer/components/uni-drawer/keypress.js
Normal file
45
uni_modules/uni-drawer/components/uni-drawer/keypress.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// #ifdef H5
|
||||
export default {
|
||||
name: 'Keypress',
|
||||
props: {
|
||||
disable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
const keyNames = {
|
||||
esc: ['Esc', 'Escape'],
|
||||
tab: 'Tab',
|
||||
enter: 'Enter',
|
||||
space: [' ', 'Spacebar'],
|
||||
up: ['Up', 'ArrowUp'],
|
||||
left: ['Left', 'ArrowLeft'],
|
||||
right: ['Right', 'ArrowRight'],
|
||||
down: ['Down', 'ArrowDown'],
|
||||
delete: ['Backspace', 'Delete', 'Del']
|
||||
}
|
||||
const listener = ($event) => {
|
||||
if (this.disable) {
|
||||
return
|
||||
}
|
||||
const keyName = Object.keys(keyNames).find(key => {
|
||||
const keyName = $event.key
|
||||
const value = keyNames[key]
|
||||
return value === keyName || (Array.isArray(value) && value.includes(keyName))
|
||||
})
|
||||
if (keyName) {
|
||||
// 避免和其他按键事件冲突
|
||||
setTimeout(() => {
|
||||
this.$emit(keyName, {})
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
document.addEventListener('keyup', listener)
|
||||
// this.$once('hook:beforeDestroy', () => {
|
||||
// document.removeEventListener('keyup', listener)
|
||||
// })
|
||||
},
|
||||
render: () => {}
|
||||
}
|
||||
// #endif
|
||||
183
uni_modules/uni-drawer/components/uni-drawer/uni-drawer.vue
Normal file
183
uni_modules/uni-drawer/components/uni-drawer/uni-drawer.vue
Normal file
@@ -0,0 +1,183 @@
|
||||
<template>
|
||||
<view v-if="visibleSync" :class="{ 'uni-drawer--visible': showDrawer }" class="uni-drawer" @touchmove.stop.prevent="clear">
|
||||
<view class="uni-drawer__mask" :class="{ 'uni-drawer__mask--visible': showDrawer && mask }" @tap="close('mask')" />
|
||||
<view class="uni-drawer__content" :class="{'uni-drawer--right': rightMode,'uni-drawer--left': !rightMode, 'uni-drawer__content--visible': showDrawer}" :style="{width:drawerWidth+'px'}">
|
||||
<slot />
|
||||
</view>
|
||||
<!-- #ifdef H5 -->
|
||||
<keypress @esc="close('mask')" />
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// #ifdef H5
|
||||
import keypress from './keypress.js'
|
||||
// #endif
|
||||
/**
|
||||
* Drawer 抽屉
|
||||
* @description 抽屉侧滑菜单
|
||||
* @tutorial https://ext.dcloud.net.cn/plugin?id=26
|
||||
* @property {Boolean} mask = [true | false] 是否显示遮罩
|
||||
* @property {Boolean} maskClick = [true | false] 点击遮罩是否关闭
|
||||
* @property {Boolean} mode = [left | right] Drawer 滑出位置
|
||||
* @value left 从左侧滑出
|
||||
* @value right 从右侧侧滑出
|
||||
* @property {Number} width 抽屉的宽度 ,仅 vue 页面生效
|
||||
* @event {Function} close 组件关闭时触发事件
|
||||
*/
|
||||
export default {
|
||||
name: 'UniDrawer',
|
||||
components: {
|
||||
// #ifdef H5
|
||||
keypress
|
||||
// #endif
|
||||
},
|
||||
emits:['change'],
|
||||
props: {
|
||||
/**
|
||||
* 显示模式(左、右),只在初始化生效
|
||||
*/
|
||||
mode: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
/**
|
||||
* 蒙层显示状态
|
||||
*/
|
||||
mask: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
/**
|
||||
* 遮罩是否可点击关闭
|
||||
*/
|
||||
maskClick:{
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
/**
|
||||
* 抽屉宽度
|
||||
*/
|
||||
width: {
|
||||
type: Number,
|
||||
default: 220
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visibleSync: false,
|
||||
showDrawer: false,
|
||||
rightMode: false,
|
||||
watchTimer: null,
|
||||
drawerWidth: 220
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// #ifndef APP-NVUE
|
||||
this.drawerWidth = this.width
|
||||
// #endif
|
||||
this.rightMode = this.mode === 'right'
|
||||
},
|
||||
methods: {
|
||||
clear(){},
|
||||
close(type) {
|
||||
// fixed by mehaotian 抽屉尚未完全关闭或遮罩禁止点击时不触发以下逻辑
|
||||
if((type === 'mask' && !this.maskClick) || !this.visibleSync) return
|
||||
this._change('showDrawer', 'visibleSync', false)
|
||||
},
|
||||
open() {
|
||||
// fixed by mehaotian 处理重复点击打开的事件
|
||||
if(this.visibleSync) return
|
||||
this._change('visibleSync', 'showDrawer', true)
|
||||
},
|
||||
_change(param1, param2, status) {
|
||||
this[param1] = status
|
||||
if (this.watchTimer) {
|
||||
clearTimeout(this.watchTimer)
|
||||
}
|
||||
this.watchTimer = setTimeout(() => {
|
||||
this[param2] = status
|
||||
this.$emit('change',status)
|
||||
}, status ? 50 : 300)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$uni-mask: rgba($color: #000000, $alpha: 0.4) ;
|
||||
// 抽屉宽度
|
||||
$drawer-width: 220px;
|
||||
|
||||
.uni-drawer {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: block;
|
||||
/* #endif */
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.uni-drawer__content {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: block;
|
||||
/* #endif */
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: $drawer-width;
|
||||
bottom: 0;
|
||||
background-color: $uni-bg-color;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.uni-drawer--left {
|
||||
left: 0;
|
||||
/* #ifdef APP-NVUE */
|
||||
transform: translateX(-$drawer-width);
|
||||
/* #endif */
|
||||
/* #ifndef APP-NVUE */
|
||||
transform: translateX(-100%);
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.uni-drawer--right {
|
||||
right: 0;
|
||||
/* #ifdef APP-NVUE */
|
||||
transform: translateX($drawer-width);
|
||||
/* #endif */
|
||||
/* #ifndef APP-NVUE */
|
||||
transform: translateX(100%);
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.uni-drawer__content--visible {
|
||||
transform: translateX(0px);
|
||||
}
|
||||
|
||||
|
||||
.uni-drawer__mask {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: block;
|
||||
/* #endif */
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
background-color: $uni-mask;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.uni-drawer__mask--visible {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: block;
|
||||
/* #endif */
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
87
uni_modules/uni-drawer/package.json
Normal file
87
uni_modules/uni-drawer/package.json
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"id": "uni-drawer",
|
||||
"displayName": "uni-drawer 抽屉",
|
||||
"version": "1.2.1",
|
||||
"description": "抽屉式导航,用于展示侧滑菜单,侧滑导航。",
|
||||
"keywords": [
|
||||
"uni-ui",
|
||||
"uniui",
|
||||
"drawer",
|
||||
"抽屉",
|
||||
"侧滑导航"
|
||||
],
|
||||
"repository": "https://github.com/dcloudio/uni-ui",
|
||||
"engines": {
|
||||
"HBuilderX": ""
|
||||
},
|
||||
"directories": {
|
||||
"example": "../../temps/example_temps"
|
||||
},
|
||||
"dcloudext": {
|
||||
"category": [
|
||||
"前端组件",
|
||||
"通用组件"
|
||||
],
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "无",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": ["uni-scss"],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y"
|
||||
},
|
||||
"client": {
|
||||
"App": {
|
||||
"app-vue": "y",
|
||||
"app-nvue": "y"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "y",
|
||||
"IE": "y",
|
||||
"Edge": "y",
|
||||
"Firefox": "y",
|
||||
"Safari": "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "y",
|
||||
"百度": "y",
|
||||
"字节跳动": "y",
|
||||
"QQ": "y"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
},
|
||||
"Vue": {
|
||||
"vue2": "y",
|
||||
"vue3": "y"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
uni_modules/uni-drawer/readme.md
Normal file
10
uni_modules/uni-drawer/readme.md
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
## Drawer 抽屉
|
||||
> **组件名:uni-drawer**
|
||||
> 代码块: `uDrawer`
|
||||
|
||||
抽屉侧滑菜单。
|
||||
|
||||
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-drawer)
|
||||
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
|
||||
Reference in New Issue
Block a user