Commit 33a8eedd by 张立顺

feat 功能开发

1 parent 55f7adf6
Showing 36 changed files with 1514 additions and 79 deletions
手机号 15818722524
\ No newline at end of file \ No newline at end of file
...@@ -73,8 +73,8 @@ ...@@ -73,8 +73,8 @@
"name": "packageTool", "name": "packageTool",
"pages": [ "pages": [
"index/index", "index/index",
"salesDailyReport/index", "salesDailyReport/salesDailyReport",
"salesReport/index" "salesReport/salesReport"
] ]
}, },
{ {
......
@import "/style/common.wxss"; @import "/style/common.wxss";
@font-face {
font-family: "numberNor";
src: url("https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/font/D-DIN-PRO-500-Medium.ttf");
}
@font-face {
font-family: "numberBold";
src: url("https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/font/D-DIN-PRO-700-Bold.ttf");
}
/* @font-face { /* @font-face {
font-family: "Gotham"; font-family: "Gotham";
src: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/font/Gotham-Black.woff"); src: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/font/Gotham-Black.woff");
...@@ -13,10 +23,12 @@ ...@@ -13,10 +23,12 @@
font-family: "number"; font-family: "number";
src: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/font/subset-AlimamaShuHeiTi-Bold.woff"); src: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/font/subset-AlimamaShuHeiTi-Bold.woff");
} }
@font-face { @font-face {
font-family: "ali-medium"; font-family: "ali-medium";
src: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/font/subset-AlibabaPuHuiTi-Medium.woff"); src: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/font/subset-AlibabaPuHuiTi-Medium.woff");
} }
@font-face { @font-face {
font-family: "ali-bold"; font-family: "ali-bold";
src: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/font/subset-AlibabaPuHuiTi-Bold.woff"); src: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/font/subset-AlibabaPuHuiTi-Bold.woff");
...@@ -39,6 +51,19 @@ page { ...@@ -39,6 +51,19 @@ page {
--constantSafeAreaInsetBottom: constant(safe-area-inset-bottom); --constantSafeAreaInsetBottom: constant(safe-area-inset-bottom);
/* 兼容 IOS>11.2 */ /* 兼容 IOS>11.2 */
--envSafeAreaInsetBottom: env(safe-area-inset-bottom); --envSafeAreaInsetBottom: env(safe-area-inset-bottom);
@for $i from 1 through 1300 {
--fontSize#{$i}: calc(#{$i}vmin / 7.5);
--fontSizeContent#{$i}: calc(#{$i}vmin / 7.176);
}
@media screen and (min-device-width: 768px) and (-webkit-min-device-pixel-ratio: 1) {
@for $i from 1 through 1300 {
--fontSize#{$i}: calc(#{$i}vmin / 8.5);
--fontSizeContent#{$i}: calc(#{$i}vmin / 6.719);
}
}
} }
image { image {
......
/* packageTool/pages/index/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--packageTool/pages/index/index.wxml-->
<text>packageTool/pages/index/index.wxml</text>
\ No newline at end of file \ No newline at end of file
// packageTool/pages/index/index.js // packageTool/pages/salesDailyReport/salesDailyReport.js
Page({ Page({
/** /**
......
{ {
"navigationBarTitleText": "销售日报",
"usingComponents": {} "usingComponents": {}
} }
/* packageTool/pages/salesDailyReport/salesDailyReport.wxss */
\ No newline at end of file \ No newline at end of file
<!--packageTool/pages/salesDailyReport/salesDailyReport.wxml-->
<text>packageTool/pages/salesDailyReport/salesDailyReport.wxml</text>
\ No newline at end of file \ No newline at end of file
// components/GlCell/GlCell.js
Component({
options: {
styleIsolation: 'apply-shared'
// styleIsolation: 'shared'
},
/**
* 组件的属性列表
*/
properties: {
label: String,
border: Boolean,
haveArrow: Boolean,
value: String,
valueAlign: String,
required: Boolean,
placeholder: String,
iconSrc: String,
labelStyle: String,
cellStyle: String,
cellBoxStyle: String,
labelText: String,
headerSlot: String,
labelWidth: {
type: String,
value: 'var(--fontSize300)'
},
background: {
type: String,
value: '#FFFFFF'
},
cellHeight: {
type: Boolean,
value: true
},
requiredBefore: {
type: Boolean,
value: true
},
requiredAfter: {
type: Boolean,
value: false,
observer: function (n, o) {
if (n) {
this.setData({
requiredBefore: false
})
}
}
},
disabled: Boolean,
titleBtn: String
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
click(e) {
if (this.data.disabled) return
this.triggerEvent('click')
},
titleClick() {
this.triggerEvent('titleClick')
}
}
})
{ {
"component": true,
"usingComponents": {} "usingComponents": {}
} }
\ No newline at end of file \ No newline at end of file
<view class="cell-box" style="background:{{ background}};{{cellBoxStyle }}">
<view class="cell {{ cellHeight?'cellHeight': ''}} {{border?'border':'' }}" style="{{ cellStyle }}" bindtap="click">
<view class="cell-label title-style" style="width:{{ labelWidth}};{{labelStyle }}" bindtap="titleClick">
<view class="header">
<text wx:if="{{ required&&requiredBefore }}" class="required">*</text>
{{label||'标题'}}
<!-- <slot name='headerSlot'></slot> -->
<text class="headerSlot" wx:if="{{headerSlot}}">{{headerSlot}}</text>
<text wx:if="{{ required&&requiredAfter }}" class="required">*</text>
<image webp class="titleIcon" wx:if="{{ iconSrc }}" src="{{ iconSrc }}" />
<text class="titleBtn" wx:if="{{ titleBtn }}">{{titleBtn}}</text>
</view>
<view class="footer" wx:if="{{ labelText }}">{{labelText}}</view>
</view>
<view class="cell-value" style="width:calc(100% - {{ labelWidth }});">
<view class="value ">
<view class="slot">
<slot />
</view>
<block wx:if="{{ value }}">
<view class="details">{{value}}</view>
</block>
<block wx:if="{{ placeholder }}">
<view class="placeholder">{{placeholder}}</view>
</block>
</view>
<!-- <image wx:if="{{ haveArrow }}" class="arrow" src="../images/arrow-x.png" /> -->
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
/* components/GlCell/GlCell.wxss */
.cell-box {
background: #fff;
font-size: var(--fontSize28);
color: #333333;
box-sizing: border-box;
}
.cell {
width: 100%;
box-sizing: border-box;
display: flex;
padding-left: var(--fontSize40);
align-items: center;
}
.cellHeight {
height: var(--fontSize120);
}
.cell.border {
border-bottom: var(--fontSize1) solid #EFF0F2;
}
.cell-label {
width: 25%;
}
.titleIcon {
width: var(--fontSize32);
height: var(--fontSize32);
margin-left: var(--fontSize8);
}
.titleBtn {
display: inline-block;
background: #FFFFFF;
border: var(--fontSize1) solid #347BFF;
border-radius: 26px;
color: #347BFF;
height: var(--fontSize48);
line-height: var(--fontSize48);
padding: 0 var(--fontSize24);
font-size: var(--fontSize24);
margin-left: var(--fontSize8);
}
.cell-value {
width: 75%;
position: relative;
height: 100%;
}
.cell-value .false {
padding-right: var(--fontSize0) !important;
}
.value {
width: 100%;
height: 100%;
display: flex;
align-items: center;
/* padding-right: var(--fontSize70); */
box-sizing: border-box;
}
.header {
display: flex;
/* justify-content: space-between; */
align-items: center;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: var(--fontSize28);
color: #292D33;
}
.required {
color: #f00;
}
.footer {
font-size: var(--fontSize24);
color: #999999;
margin-left: var(--fontSize10);
}
.details,
.placeholder {
display: none;
}
.slot:empty+.details,
.slot:empty+.placeholder {
display: block;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.placeholder {
color: #C3C3C3;
}
.cell-value .right {
justify-content: flex-end;
height: 100%;
box-sizing: border-box;
}
.cell-value .right .details,
.cell-value .right .placeholder {
text-align: right;
}
.slot {
width: 100%;
height: 100%;
}
.slot:empty {
display: none;
}
.arrow {
position: absolute;
right: var(--fontSize40);
top: 50%;
transform: translateY(-50%);
width: var(--fontSize28);
height: var(--fontSize26);
margin: 0 !important;
}
.headerSlot {
font-size: var(--fontSize28);
color: #347BFF;
max-width: var(--fontSize125);
/* max-width: 150rpx; */
/* margin-left: 3rpx; */
margin-left: var(--fontSize3);
/* max-width: 135rpx; */
white-space: nowrap;
/* 不换行 */
overflow: hidden;
/* 控制溢出部分的显示与否 */
text-overflow: ellipsis;
/* 添加省略号 */
}
\ No newline at end of file \ No newline at end of file
// tabWorkOrder/pages/staffDaily/components/selectItemPopup/selectItemPopup.js
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean
},
title: {
type: String
},
optionList: {
type: Array
},
index: {
type: Number
},
optionLabel: {
type: 'String',
default: 'confName'
}
},
/**
* 组件的初始数据
*/
data: {
},
lifetimes: {
attached() {
console.log(this.data.optionList)
},
},
/**
* 组件的方法列表
*/
methods: {
click(e) {
let { pidx, idx } = e.currentTarget.dataset
this.triggerEvent('click', {pidx, idx})
},
confirm() {
this.triggerEvent('confirm')
},
cancel() {
this.triggerEvent('cancel')
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* tabWorkOrder/pages/staffDaily/components/selectItemPopup/selectItemPopup.wxss */
.check-block {
display: flex;
flex-wrap: wrap;
padding: var(--fontSize24) 0;
.check-box {
position: relative;
box-sizing: border-box;
width: calc((100% - var(--fontSize40)) / 3);
height: var(--fontSize64);
line-height: var(--fontSize64);
text-align: center;
// background: #F7F7F7;
font-size: var(--fontSize24);
// color: #666666;
color: #292D33;
margin-right: var(--fontSize16);
background: #F7F8FA;
border-radius: var(--fontSize4);
}
.check-box.active {
background: #347BFF14;
border: var(--fontSize2) solid #347BFF;
color: #347BFF;
font-family: PingFangSC-Medium;
font-weight: 500;
line-height: var(--fontSize60);
.mult {
position: absolute;
bottom: 0;
right: 0;
width: var(--fontSize20);
height: var(--fontSize20);
}
}
.check-box:nth-child(3n+3) {
margin-right: 0;
}
.check-box:nth-child(n+4) {
margin-top: var(--fontSize10);
}
}
\ No newline at end of file \ No newline at end of file
<!--tabWorkOrder/pages/staffDaily/components/selectItemPopup/selectItemPopup.wxml-->
<popup class="date-background" popup-slot-class="popup-style" show="{{ show }}" bindcancel="cancel" bindconfirm="confirm" height="var(--fontSize500)" title="{{title}}">
<scroll-view style="height: 200rpx;" scroll-y>
<view class="check-block" >
<view
class="check-box {{ subItem.active ? 'active' : '' }}"
wx:for="{{ optionList }}"
wx:for-item="subItem"
wx:for-index="idx"
wx:key="idx"
bindtap="click"
data-pidx="{{ index }}"
data-idx="{{ idx }}"
>
{{subItem[optionLabel]}}
<image wx:if="{{ subItem.active }}" class="mult" src="../../../../images/check-active.png"></image>
</view>
</view>
</scroll-view>
</popup>
\ No newline at end of file \ No newline at end of file
// packageEquity/components/storePicker/storePicker.js
Component({
options: {
// 在组件定义时的选项中启用多slot支持
multipleSlots: true
},
/**
* 组件的属性列表
*/
properties: {
subIndex: {
type: Number,
observer: function (n) {
this.setData({
selectStoreIndex: [n]
})
}
},
pickList: {
type: Array,
value: [],
observer: function (n) {
this.setData({
selectStoreIndex: this.data.selectStoreIndex
})
// selectStoreIndex: [0]
// if (n.length == 1) {
// }
}
},
show: {
type: Boolean,
observer: function (n) {
this.setData({
searchValue: ''
})
this.triggerEvent('search', { value: '' })
}
},
pickerType: {
type: String,
observer: function (n) {
let thisPage = wx.$router.getPageInstance()
// 有搜索内容 将门店弹窗选中值置为0
if (this.data.searchValue) thisPage.setData({ subIndex: 0 })
// 清空搜索框内容
this.setData({
searchValue: ''
})
this.triggerEvent('search', { value: '' })
}
},
merchantRangeListTotal: {
type: Number,
}
},
/**
* 组件的初始数据
*/
data: {
searchValue: '',
selectStoreIndex: '',
edit: false
},
/**
* 组件的方法列表
*/
methods: {
open() {
if (this.data.disabled) return
this.setData({
edit: true,
inputFocus: true
})
},
setValue(value) {
if (this.properties.filterEmoji) {
if (wx.$util.haveEmoji(value)) value = wx.$util.replaceEmoji(value)
}
this.setData({
searchValue: value
})
},
input(e) {
let { value } = e.detail
this.setValue(value)
this.triggerEvent('input', {
value
})
// this.setData({
// selectStoreIndex: [0],
// // defaultSelectStoreIndex: [0]
// })
},
inputBlur(e) {
this.emit(e)
},
inputConfifm(e) {
this.emit(e)
},
emit(e) {
let {
detail: { value },
type
} = e
this.setData({
edit: false
})
if (type == 'confirm') {
this.setData({
selectStoreIndex: [0]
})
}
this.setValue(value)
this.triggerEvent(type == 'confirm' ? 'search' : 'blur', { value })
},
confirm() {
let { selectStoreIndex, pickList, subIndex, pickerType } = this.data
let value = selectStoreIndex[0]
console.log(value)
console.log(pickList)
if (!pickList[value]?.merchantName) {
let toastMessage = pickerType == 'merchant' ? '请选择门店' : '请选择员工'
return wx.$util.showToast(toastMessage)
}
// console.log(value)
this.triggerEvent('confirm', { value })
// this.triggerEvent('search', { value })
this.setData({
show: false
})
},
cancel() {
this.triggerEvent('cancel')
},
changeStore(e) {
// console.log(e.detail.value[0])
this.setData({
selectStoreIndex: [e.detail.value[0]]
})
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<!--packageEquity/components/storePicker/storePicker.wxml-->
<popup class="date-background" popup-slot-class="popup-style" show="{{ show }}" bindconfirm="confirm" bindcancel="cancel" height="var(--fontSize800)">
<view class="date-container">
<view class="date-confirm">
<view class="search-box">
<view class="search-input">
<block wx:if="{{ !edit }}">
<view class="input {{ searchValue?'':'placeholder' }}" bindtap="open">
<block wx:if="{{ searchValue }}">{{searchValue}}</block>
<block wx:else>
<image src="/images/search.png" class="icon"></image>
{{ pickerType == 'merchant'? '请输入门店' : '请输入员工姓名'}}
</block>
</view>
</block>
<block wx:else>
<input type="text" class="input" value="{{ searchValue }}" focus="{{ inputFocus }}" confirm-type="search" bindinput="input" bindblur="inputBlur" bindconfirm="inputConfifm" />
</block>
</view>
</view>
</view>
<!-- <view class="{{ pickerType == 'merchant'? 'picker-box-merchant':'picker-box'}}"> -->
<view class="{{ 'picker-box'}}">
<picker-view class="picker" value="{{ selectStoreIndex }}" immediate-change="true" indicator-class="indicator" bindchange="changeStore">
<picker-view-column>
<block wx:for="{{ pickList }}" wx:key="merchantId">
<view class="view pickViewColumn">{{pickerType == 'merchant'?item.merchantName:item.staffName}}</view>
</block>
</picker-view-column>
</picker-view>
</view>
<view class="totalCount" wx:if="{{ pickerType == 'merchant'}}">共计{{merchantRangeListTotal}}家门店</view>
</view>
</popup>
\ No newline at end of file \ No newline at end of file
/* packageEquity/components/storePicker/storePicker.wxss */
.date-container {
height: 100%;
}
.search-box {
height: var(--fontSize104);
display: flex;
align-items: center;
justify-content: center;
margin: 0 var(--fontSize32);
font-size: var(--fontSize28);
}
.search-box .search-input {
width: var(--fontSize686);
height: var(--fontSize72);
background: #F7F8FA;
border-radius: var(--fontSize38);
color: #333;
}
.search-input .input {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
text-align: center;
}
.search-input .icon {
width: var(--fontSize28);
height: var(--fontSize28);
margin-right: var(--fontSize10);
}
.search-input .placeholder {
color: #C8C9CC;
}
.date-confirm {
display: flex;
justify-content: center;
align-items: center;
padding: 0 var(--fontSize20);
font-size: var(--fontSize34);
line-height: var(--fontSize70);
}
.picker-box {
height: var(--fontSize450);
display: flex;
}
.picker-box-merchant {
height: var(--fontSize400);
display: flex;
}
.picker-box .picker {
width: 100%;
}
.tbn_class {
font-size: var(--fontSize26);
color: #333;
}
.pickViewColumn {
text-align: center;
line-height: 34px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.popup-style {
height: calc(100% - var(--fontSize100)) !important;
}
.totalCount {
text-align: center;
margin-top: 100rpx;
color: #347BFF;
}
\ No newline at end of file \ No newline at end of file
// compoents/weekCalendar/weekCalendar.js
Component({
options: {
multipleSlots: true // 在组件定义时的选项中启用多slot支持
},
/** * 组件的属性列表 * 用于组件自定义设置 */
properties: {
timeBean: {
// 属性名 在wxml调用组件时利用该属性传递组件显示的数据
type: Object, // 类型(必填),目前接受的类型包括:String, Number, Boolean, Object, Array, null(表示任意类型)
value: '' // 属性初始值(可选),如果未指定则会根据类型选择一个
},
index: {
type: Number
}
// weeklyList: {
// type: Array,
// value: []
// }
},
/**
* 组件的方法列表
*/
methods: {
lastWeek: function (e) {
//点击了上一周
this.triggerEvent('lastWeek')
},
nextWeek: function (e) {
//点击了下一周
this.triggerEvent('nextWeek')
},
itemClick: function (e) {
//点击了某一日,传递该日的下标
// 超过当前时间不可点击
if (e.currentTarget.dataset.disabled) {
return
}
var index = e.currentTarget.dataset.index
this.triggerEvent('dayClick', index)
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* tabWorkOrder/pages/staffDaily/weekCalendar/weekCalendar.wxss */
/* compoents/weekCalendar/weekCalendar.wxss */
.row {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
background: #fff;
.week_box {
height: var(--fontSize60);
width: 100%;
display: flex;
justify-content: space-around;
align-items: center;
box-shadow: 0 var(--fontSize4) var(--fontSize8) 0 #cdcdd159;
}
.date_box {
height: var(--fontSize128);
width: 100%;
display: flex;
justify-content: space-around;
align-items: center;
}
}
.weekselect {
height: var(--fontSize80);
flex-direction: row;
// justify-content: space-between;
justify-content: center;
}
.column {
display: flex;
flex-flow: column;
align-items: center;
justify-content: center;
flex: 1;
}
.nextWeek {
font-family: PingFangSC-Regular;
font-weight: 400;
flex-direction: row;
color: #181A1F;
width: var(--fontSize180);
}
.dateType {
position: relative;
display: flex;
align-items: center;
justify-content: center;
font-size: var(--fontSize32);
color: #292D33;
border-radius: 50%;
width: var(--fontSize64);
height: var(--fontSize64);
.empty {
box-sizing: border-box;
position: absolute;
width: var(--fontSize38);
text-align: center;
height: var(--fontSize32);
background: #F24724;
border-radius: var(--fontSize16);
bottom: var(--fontSize40);
left: var(--fontSize40);
font-size: var(--fontSize22);
z-index: 2;
padding: 0 var(--fontSize4);
color: #fff;
}
}
.dateType.dateType_disabled {
color: #BEC1C7;
}
.weekType {
font-size: var(--fontSize28);
color: #292D33;
}
.select-column {
.dateType {
background: #347BFF;
color: #fff;
}
}
.disabled {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-bottom: var(--fontSize5);
padding-top: var(--fontSize5);
margin-left: var(--fontSize5);
margin-right: var(--fontSize5);
margin-top: var(--fontSize10);
flex: 1;
border-top-left-radius: var(--fontSize20);
border-top-right-radius: var(--fontSize20);
background: #F6FCFE;
color: #292D33;
}
.timeType {
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: var(--fontSize28);
color: #181A1F;
// font-size: var(--fontSize35);
// font-weight: bold;
// margin-right: auto;
}
.line {
height: var(--fontSize1);
width: 100%;
background-color: gainsboro;
}
.lastweek {
width: var(--fontSize180);
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: var(--fontSize28);
flex-direction: row;
color: #181A1F;
}
.line-shadow {
height: var(--fontSize3);
width: 100%;
background-color: gainsboro;
box-shadow: 5px 0px 5px 0px gainsboro;
}
@font-face {
font-family: "iconfont";
src: url('iconfont.eot?t=1533031583450');
/* IE9*/
src: url('iconfont.eot?t=1533031583450#iefix') format('embedded-opentype'),
/* IE6-IE8 */
url('data:application/x-font-woff;charset=utf-8;base64,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') format('woff'),
url('iconfont.ttf?t=1533031583450') format('truetype'),
/* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
url('iconfont.svg?t=1533031583450#iconfont') format('svg');
/* iOS 4.1- */
}
.icon {
width: 32rpx;
height: 32rpx;
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/**
*字体图标,左右箭头,书,米饭,可以修改界面对图标进行修改替换
*/
.icon-sanjiaoleft:before {
content: "\e6b6";
}
.icon-sanjiaoright:before {
content: "\e6b7";
}
.icon-book1:before {
content: "\e631";
}
.icon-mifan:before {
content: "\e606";
}
\ No newline at end of file \ No newline at end of file
<!--tabWorkOrder/pages/staffDaily/weekCalendar/weekCalendar.wxml-->
<!--compoents/weekCalendar/weekCalendar.wxml-->
<!-- <view class="line"></view> -->
<view class="row weekselect">
<view class="row lastweek" bindtap="lastWeek">
<glsx-image class="icon" src="{{ '/tools/left.png' }}" webp></glsx-image>
<!-- <text class="iconfont icon-sanjiaoleft" style="padding:var(--fontSize15);color: #bec1c7;"></text> -->
<!-- <view style="">上一周</view> -->
</view>
<view class="timeType">{{timeBean.yearMonth}}</view>
<view class="row nextWeek" bindtap="nextWeek">
<block wx:if="{{ !timeBean.isInCurrentWeek }}">
<glsx-image class="icon" src="{{ '/tools/right.png' }}" webp></glsx-image>
<!-- <view style=" ">下一周</view> -->
<!-- <text class="iconfont icon-sanjiaoright" style="padding:var(--fontSize15);color: #bec1c7;"></text> -->
</block>
</view>
</view>
<!-- <view class="row">
<view class="week_box">
<view wx:for="{{ [0,1,2,3,4,5,6] }}" data-index="{{ index }}" data-disabled="{{ timeBean.weekDayList[index].disabled }}" class="item column" bindtap="itemClick" wx:key="index">
<view class="weekType">{{timeBean.weekDayList[index].week}}</view>
</view>
</view>
<view class="date_box">
<view wx:for="{{ [0,1,2,3,4,5,6] }}" data-index="{{ index }}" data-disabled="{{ timeBean.weekDayList[index].disabled }}" class="item column {{ index==timeBean.selectDay?'select-column':'' }}" bindtap="itemClick" wx:key="index">
<view class="dateType {{timeBean.weekDayList[index].disabled ? 'dateType_disabled' : ''}}">
{{timeBean.weekDayList[index].day}}
<view class="empty" wx:if="{{ !timeBean.weekDayList[index].disabled && !timeBean.weekDayList[index].hasDailyValue }}">空</view>
</view>
</view>
</view>
</view> -->
<!-- <view class="line-shadow"></view> -->
<view class="suspension" bindtap="addMenuClick">
<text class="iconfont icon-tianjia" style="font-size:var(--fontSize60); color:#fff;"></text>
</view>
\ No newline at end of file \ No newline at end of file
// packageTool/pages/index/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
/* packageTool/pages/index/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--packageTool/pages/index/index.wxml-->
<text>packageTool/pages/index/index.wxml</text>
\ No newline at end of file \ No newline at end of file
// packageTool/pages/salesReport/salesReport.js
var util = require('~/utils/timeFormat/time-utils.js')
import { getUserInfo } from '~/utils/cache/userInfo'
Page({
/**
* 页面的初始数据
*/
data: {
timeBean: {}, //timeBean 传递给组件的数据,数据的格式在一开始的工具类中明确
selectWeek: 0 //0代表的本周 1代表下一周 -1代表上一周
},
/**
* 点击了上一周,选择周数字减一,然后直接调用工具类中一个方法获取到数据
*/
lastWeek: function (e) {
// let userInfo = wx.$util.getUserInfo()
// let {
// orderObj: { yqMerchantId, merchantId, staffUuid }
// } = this.data
// // 在超管/区域督导未拿到门店或员工信息
// if (
// (userInfo?.isSuper ||
// userInfo?.loginRole == 3 ||
// userInfo?.loginRole == 5) &&
// (!yqMerchantId || !merchantId || !staffUuid)
// )
// return
var selectWeek = --this.data.selectWeek
var timeBean = this.data.timeBean
timeBean = util.getWeekDayList(selectWeek)
if (selectWeek != 0) {
timeBean.selectDay = 0
}
this.setData({
timeBean,
selectWeek
})
this.setReportDate()
// this.getStaffReport()
// this.getStaffDailyReportDetailWeeklyList()
},
/**
* 点击了下一周,选择周数字加一,然后直接调用工具类中一个方法获取到数据
*/
nextWeek: function (e) {
// let userInfo = wx.$util.getUserInfo()
// let {
// orderObj: { yqMerchantId, merchantId, staffUuid }
// } = this.data
// // 在超管/区域督导未拿到门店或员工信息
// if (
// (userInfo?.isSuper ||
// userInfo?.loginRole == 3 ||
// userInfo?.loginRole == 5) &&
// (!yqMerchantId || !merchantId || !staffUuid)
// )
// return
var selectWeek = ++this.data.selectWeek
var timeBean = this.data.timeBean
// console.log(timeBean.weekDayList[6].date, 'timeBean.weekDayList[6].date');
// timeBean = util.getWeekDayList(selectWeek, timeBean.weekDayList[6].date)
console.log(selectWeek)
timeBean = util.getWeekDayList(selectWeek)
console.log(timeBean, 'nextWeek')
if (selectWeek != 0) {
timeBean.selectDay = 0
}
this.setData({
timeBean,
selectWeek
})
this.setReportDate()
// this.getStaffReport()
// this.getStaffDailyReportDetailWeeklyList()
},
initData(userInfo) {
this.setData({
timeBean: util.getWeekDayList(this.data.selectWeek)
})
this.setReportDate()
},
// 设置报告日期
setReportDate() {
let { timeBean } = this.data
let date = timeBean.weekDayList[timeBean.selectDay].date
var time = new Date(date)
var y = time.getFullYear()
var m = time.getMonth() + 1
this.setData({
['timeBean.yearMonth']: y + '-' + m,
['orderObj.reportDate']: date,
isEditReport: false
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
userInfo: getUserInfo()
})
this.initData()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
})
{
"navigationBarTitleText": "销售人员日报",
"usingComponents": {
"weekCalendar": "./components/weekCalendar/weekCalendar"
}
}
/* packageTool/pages/salesReport/salesReport.wxss */
.main {
box-sizing: border-box;
width: 710rpx;
// height: 420rpx;
border-radius: 16rpx;
margin: 24rpx 20rpx 100rpx 20rpx;
background: #FFFFFF;
padding: 0 32rpx 32rpx;
.staffBox {
.title {
display: flex;
align-items: center;
width: 100%;
height: 68rpx;
// opacity: 1;
border-top: 1rpx solid #e4e8ee;
border-bottom: 1rpx solid #e4e8ee;
background: #f2f6ff;
color: #757980;
font-size: 24rpx;
.name {
width: 286rpx;
padding-left: 10rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.num {
flex: 1;
}
}
.listItem {
display: flex;
align-items: center;
min-height: 72rpx;
padding: 16rpx 0;
border-bottom: 1rpx solid #e4e8ee;
.name {
display: flex;
// align-items: center;
// flex-direction: column;
flex-wrap: wrap;
width: 286rpx;
// padding-left: 10rpx;
color: #292d33;
font-size: 26rpx;
.text-hide {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
}
.area {
// width: 104rpx;
// height: 32rpx;
border-radius: 4rpx;
// opacity: 1;
border-radius: 2rpx;
background: #347bff14;
color: #347bff;
font-size: 22rpx;
box-sizing: border-box;
padding: 0 8rpx;
margin-top: 4rpx;
// margin-left: 8rpx;
}
// overflow: hidden;
// text-overflow: ellipsis;
// white-space: nowrap;
}
.num {
flex: 1;
text-align: center;
color: #347bff;
font-size: 32rpx;
font-family: numberNor;
}
}
}
}
\ No newline at end of file \ No newline at end of file
<!--packageTool/pages/salesReport/salesReport.wxml-->
<!-- <view style="margin-top:{{ navBarHeight }}px"> -->
<view class="main">
<weekCalendar timeBean="{{ timeBean }}" bind:lastWeek="lastWeek" bind:nextWeek="nextWeek" bind:dayClick="dayClick"></weekCalendar>
<view class="staffBox">
<view class="title">
<view class="name">销售名称</view>
<view class="num">已填日报</view>
<view class="num">未填日报</view>
<view class="num">应填日报</view>
</view>
<view class="listItem">
<view class="name">
<view class="text-hide">迪丽热巴·迪力木拉提</view>
<view class="area">东北大区-经理</view>
</view>
<view class="num">0</view>
<view class="num">0</view>
<view class="num">0</view>
</view>
</view>
</view>
<!-- </view> -->
\ No newline at end of file \ No newline at end of file
...@@ -6,7 +6,18 @@ Page({ ...@@ -6,7 +6,18 @@ Page({
data: { data: {
toolsList: [{ name: '销售日报', url: '/pages/tool/qrcode/qrcode' }] toolsList: [{ name: '销售日报', url: '/pages/tool/qrcode/qrcode' }]
}, },
toSalesDailyReport() {
let { loginRole } = wx.$storage.get('userInfo')
// 登录角色 1-总监 2-大区经理 3-销售人员
// 根据不同角色做对应的不同跳转
const path = {
1: 'packageTool.salesReport',
2: 'packageTool.salesReport',
3: 'packageTool.salesDailyReport'
}[loginRole]
wx.$router.go(path)
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
......
...@@ -6,3 +6,36 @@ ...@@ -6,3 +6,36 @@
page { page {
background: #f7f8fa; background: #f7f8fa;
} }
.title {
height: 110rpx;
line-height: 110rpx;
color: #181a1f;
font-size: 32rpx;
font-weight: 500;
padding-left: 40rpx;
}
.tools {
padding: 0 40rpx;
}
.list {
width: 25%;
display: flex;
flex-direction: column;
// align-items: center;
justify-content: center;
align-items: center;
.icon {
width: 72rpx;
height: 72rpx;
margin-bottom: 16rpx;
}
.label {
color: #000000;
font-size: 28rpx;
}
}
\ No newline at end of file \ No newline at end of file
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
<view class="main"> <view class="main">
<view class="title">我的工具</view> <view class="title">我的工具</view>
<view class="tools"> <view class="tools">
<view class="list" wx:for="{{ toolsList }}" wx:key="index"> <!-- wx:for="{{ toolsList }}" wx:key="index" -->
<view class="list" bind:tap="toSalesDailyReport">
<glsx-image class="icon" src="{{ '/tools/salesDailyReport.png' }}" webp>头像</glsx-image>
<!-- <view class="icon">{{item}}</view> --> <!-- <view class="icon">{{item}}</view> -->
<img src="{{ item.imgurl }}" alt="" /> <!-- <img src="{{ item.imgurl }}" alt="" /> -->
<view class="label">{{item.name}}</view> <view class="label">销售日报</view>
</view> </view>
</view> </view>
</view> </view>
\ No newline at end of file \ No newline at end of file
/**
* 获取该周的所要显示的周和日期的对应数据,数据结构如下
* var weekDay = {week: '',day: ''}
* 参数:selectWeek 0为本周,数字代表前几周或者后几周,例如1是下一周
*/
function getWeekDayList(selectWeek, selectDay, customerDisabled,) {
// 1.获取周一对应得时间
// 2.用循环七次添加周一到周日对应得周几和几号
var selectWeekTime = getCurrentTimeStamp(selectDay) + selectWeek * 7 * 24 * 60 * 60 * 1000
var mondayTime = selectWeekTime - (getWeekNumber(selectWeekTime) - 1) * 24 * 60 * 60 * 1000
// let testDate = new Date(mondayTime)
console.log(selectWeekTime, 'selectWeekTime');
// console.log(getWeekNumber(selectWeekTime), getWeekNumber(selectWeekTime) - 1, 'getWeekNumber(selectWeekTime) - 1')
// console.log(getDataFormat(selectWeekTime), 'selectWeekTime')
console.log(selectWeekTime, 'selectWeekTime');
// console.log(getDataFormat(mondayTime), 'mondayTime')
var timeBean = {
selectDay: 0,
yearMonth: '',
weekDayList: []
}
timeBean.yearMonth = getYearMonth(selectWeekTime)
console.log(timeBean.yearMonth, 'timeBean.yearMonth');
const yearLabel = getYearMonth(selectWeekTime, '/')
// 获取当前时间戳(以毫秒为单位)
const currentTimestamp = Date.now()
for (var i = 0; i < 7; i++) {
var weekDay = {
week: '',
day: '',
disabled: '',
date: ''
}
let dataStr = mondayTime + i * 24 * 60 * 60 * 1000
weekDay.week = getWeek(dataStr)
weekDay.day = getMyDay(dataStr)
weekDay.date = getDataFormat(dataStr)
weekDay.disabled = customerDisabled ? dataStr > (currentTimestamp + 24 * 60 * 60 * 1000) : dataStr > currentTimestamp
timeBean.weekDayList.push(weekDay)
if (i == 0) {
timeBean.starDay = getMyDay(dataStr)
timeBean.starDayLabel = getYearMonth(dataStr, '/') + '/' + weekDay.day
timeBean.reportStartDate = getDataFormat(dataStr)
}
if (i == 6) {
timeBean.endDayLabel = getYearMonth(dataStr, '/') + '/' + weekDay.day
timeBean.reportEndDate = getDataFormat(dataStr)
// console.log(dataStr)
timeBean.isInCurrentWeek = isTimestampInCurrentWeek(dataStr, customerDisabled)
}
}
timeBean.selectDay = getCurrenrWeek(selectDay)
timeBean.formatYearMonth = getFormatYearMonth(selectWeekTime)
return timeBean
}
//获取当前时间戳 --
function getCurrentTimeStamp(selectDay) {
var timestamp
if (selectDay) {
timestamp = new Date(selectDay).getTime()
} else {
timestamp = new Date().getTime()
}
return timestamp
}
//获取当前周几
function getCurrenrWeek(selectDay) {
let str
if (selectDay) {
str = '6012345'.charAt(new Date(selectDay).getDay())
} else {
str = '6012345'.charAt(new Date().getDay())
}
return str
}
//时间戳获得年月
function getYearMonth(res, unit = '-') {
var time = new Date(res)
var y = time.getFullYear()
var m = time.getMonth() + 1
// 将月份转换成两位数的字符串
// var formattedMonth = month < 10 ? '0' + month : '' + month;
return y + unit + m
}
//时间戳获得年月
function getFormatYearMonth(res) {
var time = new Date(res)
var y = time.getFullYear()
var m = time.getMonth() + 1
// 将月份转换成两位数的字符串
var formattedMonth = m < 10 ? '0' + m : '' + m
return y + '-' + formattedMonth
}
//时间戳转几号
function getMyDay(res) {
var time = new Date(res)
var d = time.getDate()
return d
}
//时间戳转周几
function getWeek(res) {
// var time = new Date(res)
// var y = time.getFullYear()
// var m = time.getMonth() + 1
// var d = time.getDate()
// return '日一二三四五六'.charAt(new Date(y + '-' + m + '-' + d).getDay())
var days = ['日', '一', '二', '三', '四', '五', '六'];
var time = new Date(res);
var dayIndex = time.getDay();
return days[dayIndex];
}
//时间戳转周几 0123456 --
function getWeekNumber(res) {
// var days = [6, 0, 1, 2, 3, 4, 5,];
var days = [7, 1, 2, 3, 4, 5, 6];
var time = new Date(res);
var dayIndex = time.getDay();
return days[dayIndex];
// var time = new Date(res)
// var y = time.getFullYear()
// var m = time.getMonth() + 1
// var d = time.getDate()
// return '0123456'.charAt(new Date(y + '-' + m + '-' + d).getDay())
}
//时间戳转年月份 --
function getDataFormat(res) {
// const timestamp = 1675372800000; // 时间戳,单位为毫秒
const date = new Date(res)
const year = date.getFullYear().toString()
const month = ('0' + (date.getMonth() + 1)).slice(-2)
const day = ('0' + date.getDate()).slice(-2)
return `${year}-${month}-${day}`
}
// function isTimestampInCurrentWeek(timestamp) {
// const currentDate = new Date()
// const currentDay = currentDate.getDay() // 获取当前日期是星期几
// // 计算当前周的起始日期(周一)
// const currentWeekStart = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - currentDay + 1)
// console.log(currentWeekStart, 'currentWeekStart');
// // 计算当前周的结束日期(周日)
// const currentWeekEnd = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() + (7 - currentDay), 23, 59, 59, 999)
// console.log(currentWeekEnd, 'currentWeekEnd');
// const targetDate = new Date(timestamp) // 不再乘以1000
// return targetDate >= currentWeekStart && targetDate <= currentWeekEnd
// }
function isTimestampInCurrentWeek(timestamp, customerDisabled) {
const currentDate = new Date();
const currentDay = currentDate.getDay(); // 获取当前日期是星期几
// 计算当前周的起始日期(周一)
const currentWeekStart = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - currentDay + (currentDay === 0 ? -6 : 1));
// 计算当前周的结束日期(周日)
const currentWeekEnd = new Date(currentWeekStart.getFullYear(), currentWeekStart.getMonth(), currentWeekStart.getDate() + 6, 23, 59, 59, 999);
const targetDate = new Date(timestamp);
if (customerDisabled) {
let startOfTargetDate = new Date(targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate())
let endOfTargetDate = new Date(startOfTargetDate.getTime() + (24 * 60 * 60 * 1000) - 1)
let tomorrow = new Date(new Date().getTime() + (24 * 60 * 60 * 1000))
return tomorrow <= endOfTargetDate
}
return targetDate >= currentWeekStart && targetDate <= currentWeekEnd;
}
function getWeeksDiff(startDate, endDate) {
// 设置一周的第一天为周一
const firstDayOfWeek = 1 // 0表示周日,1表示周一,以此类推
// 获取开始日期和结束日期的时间戳(单位:毫秒)
const startTimestamp = new Date(startDate).getTime()
const endTimestamp = new Date(endDate).getTime()
// 获取结束日期是一周的第几天
const endDateObj = new Date(endDate)
let dayOfWeek = endDateObj.getDay()
// 如果结束日期是一周的第一天(周一),则不需要调整
if (dayOfWeek === firstDayOfWeek) {
dayOfWeek = 0
}
// 计算结束日期距离一周第一天的天数差
const daysDiff = (dayOfWeek + 7 - firstDayOfWeek) % 7
// 计算结束日期距离一周第一天的周数差
const weeksDiff = Math.floor((endTimestamp + daysDiff * 24 * 3600 * 1000 - startTimestamp) / (7 * 24 * 3600 * 1000))
return weeksDiff
}
function isDateWithin7Days(date) {
console.log(date, 'isDateWithin7Daysdate');
// console.log(date, 'date');
const oneDay = 24 * 60 * 60 * 1000 // 一天的毫秒数
const currentDate = new Date() // 当前日期
const targetDate = new Date(date) // 给定的日期
// 计算给定日期与当前日期的时间差(以毫秒为单位)
const diffMilliseconds = targetDate - currentDate
// 计算时间差对应的天数
const diffDays = Math.floor(diffMilliseconds / oneDay)
// console.log(diffDays, 'diffDays');
return diffDays >= -7
}
function isDateWithin60Days(date) {
const oneDay = 24 * 60 * 60 * 1000 // 一天的毫秒数
const currentDate = new Date() // 当前日期
const targetDate = new Date(date) // 给定的日期
// 计算给定日期与当前日期的时间差(以毫秒为单位)
const diffMilliseconds = targetDate - currentDate
// 计算时间差对应的天数
const diffDays = Math.floor(diffMilliseconds / oneDay)
return diffDays >= -60
}
// 示例用法
// const inputDate = '2024-02-15';
// const isWithin7Days = isDateWithin7Days(inputDate);
// console.log(isWithin7Days); // 输出:true
// // 示例用法
// const startDate = '2024-02-19'; // 开始日期
// const endDate = '2024-02-25'; // 结束日期
// const weeksDiff = getWeeksDiff(startDate, endDate);
// console.log("开始日期距离结束日期的周数差:", weeksDiff);
module.exports = {
//把方法共享,让引用的地方可以调用
getWeekDayList: getWeekDayList,
isDateWithin7Days: isDateWithin7Days,
isDateWithin60Days: isDateWithin60Days
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!