Commit ecbaa823 by Jaxon

style: 格式化

1 parent 825f7520
import api from '~/api/index/index' import api from "~/api/index/index";
import dayjs from 'dayjs' import dayjs from "dayjs";
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/' const IMG_URL = "https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/";
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -8,213 +8,223 @@ Page({ ...@@ -8,213 +8,223 @@ Page({
data: { data: {
IMG_URL, IMG_URL,
navBarHeight: 84, navBarHeight: 84,
navStyle: 'background-color: rgba(0,0,0,0);', navStyle: "background-color: rgba(0,0,0,0);",
navTitleStyle: 'font-weight: 600; font- size: 32rpx; color: #000;', navTitleStyle: "font-weight: 600; font- size: 32rpx; color: #000;",
userInfo: {}, userInfo: {},
staticList: [{ staticList: [
label: '驻店人员', {
width: '208', label: "驻店人员",
key: 'staffCount', width: "208",
background: 'linear-gradient(90deg, #42CCCF 0%, #36D9A5 100%)' key: "staffCount",
}, { background: "linear-gradient(90deg, #42CCCF 0%, #36D9A5 100%)",
label: '门店数量', },
width: '192', {
key: 'shopCount', label: "门店数量",
background: 'linear-gradient(90deg, #5E69FF 0%, #4079FF 100%)' width: "192",
}, { key: "shopCount",
label: '总产值', background: "linear-gradient(90deg, #5E69FF 0%, #4079FF 100%)",
key: 'totalValue', },
background: 'linear-gradient(90deg, #3D76FC 0%, #4DA6FF 100%)' {
}], label: "总产值",
tabList: [{ key: "totalValue",
text: '每日任务' background: "linear-gradient(90deg, #3D76FC 0%, #4DA6FF 100%)",
}, { },
text: '本周任务' ],
}, { tabList: [
text: '月度任务' {
}, { text: "每日任务",
text: '专项任务' },
}], {
text: "本周任务",
},
{
text: "月度任务",
},
{
text: "专项任务",
},
],
tabIndex: 0, tabIndex: 0,
statusMap: { statusMap: {
0: {name: '待完成', color: '#2C66F7', background: '#2c66f71a'}, 0: { name: "待完成", color: "#2C66F7", background: "#2c66f71a" },
1: {name: '进行中', color: '#FF9D0A', background: '#ff9d0a1a'}, 1: { name: "进行中", color: "#FF9D0A", background: "#ff9d0a1a" },
2: {name: '已完成', color: '#35C376', background: '#35c3761a'}, 2: { name: "已完成", color: "#35C376", background: "#35c3761a" },
}, },
missionMap: { missionMap: {
3: {name: '录音复盘'}, 3: { name: "录音复盘" },
5: {name: '人员带教'}, 5: { name: "人员带教" },
0: {name: '督导日报'}, 0: { name: "督导日报" },
1: {name: '本周复盘'}, 1: { name: "本周复盘" },
2: {name: '督导月度计划'}, 2: { name: "督导月度计划" },
4: {name: '专项任务'}, 4: { name: "专项任务" },
}, },
list: [], list: [],
scrollTop: 0 scrollTop: 0,
}, },
onTabItemTap(e) { onTabItemTap(e) {
// 点击埋点 // 点击埋点
wx.$track.setTrackData(0, 'supervisor_index_page', {}, '') wx.$track.setTrackData(0, "supervisor_index_page", {}, "");
}, },
navbarReady(e) { navbarReady(e) {
let navBarHeight = e.detail.height let navBarHeight = e.detail.height;
this.setData({ this.setData({
navBarHeight navBarHeight,
}) });
}, },
onScroll(e) { onScroll(e) {
this.setData({ this.setData({
scrollTop: e.detail.scrollTop scrollTop: e.detail.scrollTop,
}) });
const {navBarHeight} = this.data const { navBarHeight } = this.data;
const query = wx.createSelectorQuery().in(this) const query = wx.createSelectorQuery().in(this);
query.select('.data-container').boundingClientRect() query.select(".data-container").boundingClientRect();
query.exec(res => { query.exec((res) => {
this.setData({ this.setData({
isSticky: res[0].top <= navBarHeight isSticky: res[0].top <= navBarHeight,
}) });
}) });
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
let userInfo = wx.$util.getUserInfo() let userInfo = wx.$util.getUserInfo();
this.setData({userInfo}) this.setData({ userInfo });
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function () {},
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow () { onShow() {
this.getStaticData() this.getStaticData();
this.setData({ this.setData(
{
list: [], list: [],
pageNum: 1, pageNum: 1,
flag: false, flag: false,
nothing: false nothing: false,
}, () => { },
this.getList(true) () => {
}) this.getList(true);
},
);
}, },
formatThousands (v) { formatThousands(v) {
const s = String(v) const s = String(v);
if (!s) return s if (!s) return s;
const isNeg = s[0] === '-' const isNeg = s[0] === "-";
const raw = isNeg ? s.slice(1) : s const raw = isNeg ? s.slice(1) : s;
const [intPart, decPart] = raw.split('.') const [intPart, decPart] = raw.split(".");
const intFmt = String(intPart || '0').replace(/\B(?=(\d{3})+(?!\d))/g, ',') const intFmt = String(intPart || "0").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
const res = decPart ? `${intFmt}.${decPart}` : intFmt const res = decPart ? `${intFmt}.${decPart}` : intFmt;
return isNeg ? `-${res}` : res return isNeg ? `-${res}` : res;
}, },
getStaticData() { getStaticData() {
api.getSupervisorStaticData({}).then(res => { api.getSupervisorStaticData({}).then((res) => {
let { code, data, message } = res let { code, data, message } = res;
if (code == 0) { if (code == 0) {
data.staffCount = (data.staffCount ?? '') === '' ? '-' : this.formatThousands(data.staffCount) data.staffCount = (data.staffCount ?? "") === "" ? "-" : this.formatThousands(data.staffCount);
data.shopCount = (data.shopCount ?? '') === '' ? '-' : this.formatThousands(data.shopCount) data.shopCount = (data.shopCount ?? "") === "" ? "-" : this.formatThousands(data.shopCount);
data.totalValue = (data.totalValue ?? '') === '' ? '-' : this.formatThousands(data.totalValue) data.totalValue = (data.totalValue ?? "") === "" ? "-" : this.formatThousands(data.totalValue);
this.setData({staticData: data}) this.setData({ staticData: data });
} else { } else {
wx.$util.showToast(message) wx.$util.showToast(message);
} }
}) });
}, },
tabClick(e) { tabClick(e) {
let eventCode = ['supervisor_dayTask_tab', 'supervisor_weeklyTask_tab', 'supervisor_monthlyTask_tab', 'supervisor_specificTask_tab'] let eventCode = ["supervisor_dayTask_tab", "supervisor_weeklyTask_tab", "supervisor_monthlyTask_tab", "supervisor_specificTask_tab"];
// 点击埋点 // 点击埋点
wx.$track.setTrackData(0, eventCode[e.detail], {}, '') wx.$track.setTrackData(0, eventCode[e.detail], {}, "");
this.setData({ this.setData({
tabIndex: e.detail tabIndex: e.detail,
}) });
}, },
jump(e) { jump(e) {
const { target } = e.currentTarget.dataset const { target } = e.currentTarget.dataset;
const pageUrl = { const pageUrl = {
3: '/packageIndex/pages/recordingReview/recordingReview', 3: "/packageIndex/pages/recordingReview/recordingReview",
5: '/packageCrew/pages/mentoring/mentoring', 5: "/packageCrew/pages/mentoring/mentoring",
0: '/packageIndex/pages/dailySupervisionReport/dailySupervisionReport', 0: "/packageIndex/pages/dailySupervisionReport/dailySupervisionReport",
1: '/packageIndex/pages/weeklyReview/weeklyReview', 1: "/packageIndex/pages/weeklyReview/weeklyReview",
2: '/packageIndex/pages/monthlyPlan/monthlyPlan', 2: "/packageIndex/pages/monthlyPlan/monthlyPlan",
4: '/packageIndex/pages/specialTask/specialTask' 4: "/packageIndex/pages/specialTask/specialTask",
} };
const eventCode = { const eventCode = {
3: {view: 'supervisor_recording_view', execute: 'supervisor_recording_execute'}, 3: { view: "supervisor_recording_view", execute: "supervisor_recording_execute" },
5: {view: 'supervisor_mentoring_view', execute: 'supervisor_mentoring_execute'}, 5: { view: "supervisor_mentoring_view", execute: "supervisor_mentoring_execute" },
0: {view: 'supervisor_report_view', execute: 'supervisor_report_execute'}, 0: { view: "supervisor_report_view", execute: "supervisor_report_execute" },
1: {view: 'supervisor_weeklyReview_view', execute: 'supervisor_weeklyReview_execute'}, 1: { view: "supervisor_weeklyReview_view", execute: "supervisor_weeklyReview_execute" },
2: {view: 'supervisor_monthlyPlan_view', execute: 'supervisor_monthlyPlan_execute'}, 2: { view: "supervisor_monthlyPlan_view", execute: "supervisor_monthlyPlan_execute" },
4: {view: 'supervisor_specificTask_view', execute: 'supervisor_specificTask_execute'}, 4: { view: "supervisor_specificTask_view", execute: "supervisor_specificTask_execute" },
} };
let status = target.taskStatus != 2 ? 'execute' : 'view' let status = target.taskStatus != 2 ? "execute" : "view";
console.log(eventCode[target.taskType][status]) console.log(eventCode[target.taskType][status]);
wx.$track.setTrackData(0, eventCode[target.taskType][status], {}, '') wx.$track.setTrackData(0, eventCode[target.taskType][status], {}, "");
wx.navigateTo({ wx.navigateTo({
url: `${pageUrl[target.taskType]}?taskStatus=${target.taskStatus}&id=${target.id}`, url: `${pageUrl[target.taskType]}?taskStatus=${target.taskStatus}&id=${target.id}`,
}) });
}, },
search(e) { search(e) {
this.setData({ this.setData(
{
list: [], list: [],
pageNum: 1, pageNum: 1,
flag: false, flag: false,
nothing: false, nothing: false,
startStr: e.detail.startDay?.replace(/\//g, '-'), startStr: e.detail.startDay?.replace(/\//g, "-"),
endStr: e.detail.endDay?.replace(/\//g, '-') endStr: e.detail.endDay?.replace(/\//g, "-"),
}, () => { },
this.getList(true) () => {
}) this.getList(true);
},
);
}, },
scrollonReachBottom() { scrollonReachBottom() {
this.getList() this.getList();
}, },
// 获取列表数据 // 获取列表数据
getList(repload) { getList(repload) {
let { pageNum, nothing, startStr, endStr, tabIndex, topBoxHeight, scrollTop } = this.data let { pageNum, nothing, startStr, endStr, tabIndex, topBoxHeight, scrollTop } = this.data;
if (nothing) return if (nothing) return;
const taskList = [[0, 3, 5], [1], [2], [4]] const taskList = [[0, 3, 5], [1], [2], [4]];
wx.$util.showLoading() wx.$util.showLoading();
let params = { let params = {
taskTypeList: taskList[tabIndex], taskTypeList: taskList[tabIndex],
startDate: startStr, startDate: startStr,
endDate: endStr, endDate: endStr,
pageNum, pageNum,
pageSize: 10 pageSize: 10,
} };
api.getMissionList(params).then(res => { api.getMissionList(params).then((res) => {
wx.$util.hideLoading() wx.$util.hideLoading();
let total = 0 let total = 0;
let list = [] let list = [];
let { let { code, data, message } = res;
code, data?.list?.forEach((val) => {
data, val.updatedDate = val.updatedDate ? dayjs(val.updatedDate).format("YYYY-MM-DD HH:mm:ss") : "";
message val.createTime = val.createTime ? dayjs(val.createTime).format("YYYY-MM-DD HH:mm:ss") : "";
} = res });
data?.list?.forEach(val => {
val.updatedDate = val.updatedDate ? dayjs(val.updatedDate).format('YYYY-MM-DD HH:mm:ss') : ''
val.createTime = val.createTime ? dayjs(val.createTime).format('YYYY-MM-DD HH:mm:ss') : ''
})
if (code == 0) { if (code == 0) {
list = data.list list = data.list;
total = data.total total = data.total;
} else { } else {
wx.$util.showToast(message) wx.$util.showToast(message);
} }
if (total != 0) { if (total != 0) {
this.setData({ this.setData({
[`list[${pageNum - 1}]`]: list [`list[${pageNum - 1}]`]: list,
}) });
} }
// if (repload) { // if (repload) {
// const query = wx.createSelectorQuery().in(this) // const query = wx.createSelectorQuery().in(this)
...@@ -235,21 +245,19 @@ Page({ ...@@ -235,21 +245,19 @@ Page({
flag: true, flag: true,
triggered: false, triggered: false,
pageNum: pageNum + 1, pageNum: pageNum + 1,
nothing: pageNum == data?.pages nothing: pageNum == data?.pages,
}) });
}) });
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {},
},
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { onUnload: function () {},
},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
...@@ -260,5 +268,5 @@ Page({ ...@@ -260,5 +268,5 @@ Page({
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () {}, onShareAppMessage: function () {},
onShareTimeline: function () {} onShareTimeline: function () {},
}) });
<!--pages/tab/index/index.wxml--> <!--pages/tab/index/index.wxml-->
<navigation-bar bindnavbarReady="navbarReady" <navigation-bar bindnavbarReady="navbarReady"
class="navigation-header" class="navigation-header"
navStyle="background-color:{{isSticky ? '#FFFFFF' : 'transparent'}};box-shadow:none;"> navStyle="background-color:{{ isSticky ? '#FFFFFF' : 'transparent' }};box-shadow:none;">
<view class="page-title"> <view class="page-title">
工作台 工作台
</view> </view>
</navigation-bar> </navigation-bar>
<view class="bg" wx:if="{{!isSticky}}"></view> <view class="bg" wx:if="{{ !isSticky }}"></view>
<scroll-view class="container" scroll-y enable-back-to-top <scroll-view class="container"
scroll-top="{{setScrollTop}}" scroll-y
enable-back-to-top
scroll-top="{{ setScrollTop }}"
bind:scroll="onScroll" bind:scroll="onScroll"
bindrefresherrefresh="search" bind:refresherrefresh="search"
bindscrolltolower="scrollonReachBottom" bind:scrolltolower="scrollonReachBottom"
enhanced="{{true}}" enhanced="{{ true }}"
show-scrollbar="{{false}}" style="padding-top: {{navBarHeight}}px;"> show-scrollbar="{{ false }}"
style="padding-top: {{ navBarHeight }}px;">
<view class="top-box"> <view class="top-box">
<view class="user-info"> <view class="user-info">
<image src="{{IMG_URL}}default-avatar.png" /> <image src="{{ IMG_URL }}default-avatar.png" />
<view>督导{{userInfo.name}}</view> <view>
督导{{ userInfo.name }}
</view>
</view> </view>
<view class="static-info"> <view class="static-info">
<view class="static-item" style="flex: {{item.width}}rpx 0 0;background: {{item.background}};" wx:for="{{staticList}}" wx:key="index"> <view class="static-item"
<view class="label">{{item.label}}</view> style="flex: {{ item.width }}rpx 0 0;background: {{ item.background }};"
<view class="value">{{staticData[item.key]}}</view> wx:for="{{ staticList }}"
wx:key="index">
<view class="label">
{{ item.label }}
</view>
<view class="value">
{{ staticData[item.key] }}
</view>
</view> </view>
</view> </view>
</view> </view>
<view class="data-container"> <view class="data-container">
<view class="sticky-box {{isSticky ? 'is-sticky' : ''}}"> <view class="sticky-box {{ isSticky ? 'is-sticky' : '' }}">
<view class="tab-box"> <view class="tab-box">
<tab-bar tabList="{{ tabList }}" bindclick="tabClick" activeIndex="{{ tabIndex }}" /> <tab-bar tabList="{{ tabList }}"
bindclick="tabClick"
activeIndex="{{ tabIndex }}" />
</view> </view>
<view class="date"> <view class="date">
<date-screen tabSelected="{{tabIndex}}" isSticky="{{isSticky}}" bind:search="search"></date-screen> <date-screen tabSelected="{{ tabIndex }}"
isSticky="{{ isSticky }}"
bind:search="search"></date-screen>
</view>
<view class="number">
共{{ total || 0 }}条任务
</view> </view>
<view class="number">共{{total || 0}}条任务</view>
</view> </view>
<view class="content-box"> <view class="content-box">
<view class="list"> <view class="list">
<block wx:if="{{ list.length > 0 }}"> <block wx:if="{{ list.length > 0 }}">
<block wx:for="{{ list }}" wx:for-item="val" wx:for-index="sIndex" wx:key="sIndex"> <block wx:for="{{ list }}"
<block wx:for="{{val}}" wx:key="index"> wx:for-item="val"
wx:for-index="sIndex"
wx:key="sIndex">
<block wx:for="{{ val }}" wx:key="index">
<view class="item content"> <view class="item content">
<!-- 顶部状态和标题 --> <!-- 顶部状态和标题 -->
<view class="item-top"> <view class="item-top">
<view <view class="status text-center"
class="status text-center" style="color: {{ statusMap[item.taskStatus].color }}; background-color: {{ statusMap[item.taskStatus].background }};">
style="color: {{statusMap[item.taskStatus].color}}; background-color: {{statusMap[item.taskStatus].background}};" {{ statusMap[item.taskStatus].name }}
> </view>
{{statusMap[item.taskStatus].name}} <view class="name" wx:if="{{ item.taskType != 4 }}">
{{ missionMap[item.taskType].name }}<text wx:if="{{ item.taskType == 5 }}">-{{ item.storeManagerName || '-' }}</text>
</view> </view>
<view class="name" wx:else>
<view class="name" wx:if="{{item.taskType != 4}}"> {{ item.merchantName || '-' }}
{{missionMap[item.taskType].name}}
<text wx:if="{{item.taskType == 5}}">-{{item.storeManagerName || '-'}}</text>
</view> </view>
<view class="name" wx:else>{{item.merchantName || '-'}}</view>
</view> </view>
<view wx:if="{{(item.taskType == 0 || item.taskType == 1 || item.taskType == 2) && item.taskStatus == 2}}" class="list-item"> <view wx:if="{{ (item.taskType == 0 || item.taskType == 1 || item.taskType == 2) && item.taskStatus == 2 }}"
<image class="icon" src="{{IMG_URL}}task-icon.png" mode="" /> class="list-item">
<view class="label">{{['日报内容:', '复盘内容:', '月度计划:'][item.taskType]}}</view> <image class="icon"
<view class="text-hide">{{item.taskContext || '-'}}</view> src="{{ IMG_URL }}task-icon.png"
mode="" />
<view class="label">
{{ ['日报内容:', '复盘内容:', '月度计划:'][item.taskType] }}
</view> </view>
<block wx:if="{{item.taskType == 4}}"> <view class="text-hide">
{{ item.taskContext || '-' }}
</view>
</view>
<block wx:if="{{ item.taskType == 4 }}">
<view class="list-item"> <view class="list-item">
<image class="icon" src="{{IMG_URL}}matter-icon.png" mode="" /> <image class="icon"
<view class="label">事项描述:</view> src="{{ IMG_URL }}matter-icon.png"
<view class="text-hide">{{item.taskDesc || '-'}}</view> mode="" />
<view class="label">
事项描述:
</view>
<view class="text-hide">
{{ item.taskDesc || '-' }}
</view>
</view>
<view wx:if="{{ item.taskStatus == 2 }}" class="list-item">
<image class="icon"
src="{{ IMG_URL }}task-icon.png"
mode="" />
<view class="label">
专项任务:
</view>
<view class="text-hide">
{{ item.taskContext || '-' }}
</view> </view>
<view wx:if="{{item.taskStatus == 2}}" class="list-item">
<image class="icon" src="{{IMG_URL}}task-icon.png" mode="" />
<view class="label">专项任务:</view>
<view class="text-hide">{{item.taskContext || '-'}}</view>
</view> </view>
<view wx:else class="list-item"> <view wx:else class="list-item">
<image class="icon" src="{{IMG_URL}}time-icon.png" mode="" /> <image class="icon"
<view class="label">创建时间:</view> src="{{ IMG_URL }}time-icon.png"
<view>{{item.createTime || '-'}}</view> mode="" />
<view class="label">
创建时间:
</view>
<view>
{{ item.createTime || '-' }}
</view>
</view> </view>
</block> </block>
<view wx:if="{{item.taskType != 4 || (item.taskType == 4 && item.taskStatus == 2)}}" class="list-item"> <view wx:if="{{ item.taskType != 4 || (item.taskType == 4 && item.taskStatus == 2) }}"
<image class="icon" src="{{IMG_URL}}time-icon.png" mode="" /> class="list-item">
<view class="label">完成时间:</view> <image class="icon"
<view>{{item.updatedDate || '-'}}</view> src="{{ IMG_URL }}time-icon.png"
mode="" />
<view class="label">
完成时间:
</view> </view>
<view wx:if="{{item.taskType == 3}}" class="list-item"> <view>
{{ item.updatedDate || '-' }}
</view>
</view>
<view wx:if="{{ item.taskType == 3 }}" class="list-item">
<view class="progress"> <view class="progress">
<view class="progress-line"></view> <view class="progress-line"></view>
<view <view class="progress-item"
class="progress-item" style="width: {{ (item.audioReviewCompletedCount / item.audioReviewTotalCount * 100) + '%' }}"></view>
style="width: {{ (item.audioReviewCompletedCount / item.audioReviewTotalCount * 100) + '%' }}" <view class="num">
></view> {{ item.audioReviewCompletedCount + '/' + item.audioReviewTotalCount }}
<view class="num">{{item.audioReviewCompletedCount + '/' + item.audioReviewTotalCount}}</view> </view>
</view> </view>
</view> </view>
<!-- 底部按钮 --> <!-- 底部按钮 -->
<view class="btn-box"> <view class="btn-box">
<view <view bindtap="jump"
bindtap="jump" data-target="{{ item }}"
data-target="{{item}}" class="btn {{ item.taskStatus == 2 ? '' : 'primary' }}">
class="btn {{item.taskStatus == 2 ? '' : 'primary'}}" {{ item.taskStatus == 2 ? '查看' : '去执行' }}
>
{{item.taskStatus == 2 ? '查看' : '去执行'}}
</view> </view>
</view> </view>
</view> </view>
</block> </block>
</block> </block>
<block wx:if="{{ nothing }}"> <block wx:if="{{ nothing }}">
<view class="list-nothing">到底了~</view> <view class="list-nothing">
到底了~
</view>
</block> </block>
</block> </block>
<block wx:else> <block wx:else>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!