Commit ada32ec5 by chenwq

feat(日报): 添加日报模板默认值自动填充功能

新增reportFirstAutoObj配置对象用于定义各模板默认值映射关系
在supervisorDaily.js中添加getUserStat方法获取用户统计数据并自动填充
添加dailyCumulativeAchievement字段验证规则
更新api.js添加userStat接口用于获取统计数据
1 parent 3d71f8e2
// 日报/周报/月报 首次填写,默认填入的字段数据结构
export const reportFirstAutoObj = {
/** 1.1轻改区域日报模版 */
'qinggai-temp-001': {
list: [{
attrName: 'todayRegionalTotalOutput',
// 今日产值
valueObj: 'staffTodayTotal'
}, {
attrName: 'monthRegionalTotalOutput',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.3延保区域日报模版 */
'uuid-temp-001': {
list: [{
attrName: 'dailyCumulativeAchievement',
// 今日产值
valueObj: 'staffTodayTotal'
}, {
attrName: 'monthlyCumulativeAchievement',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.1权益区域日报模版 */
'uuid-temp-011': {
list: [{
attrName: 'dailyCumulativeAchievement',
// 今日产值
valueObj: 'staffTodayTotal'
}, {
attrName: 'monthlyCumulativeAchievement',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.1区域经理周报模版 */
'uuid-temp-012': {
list: [{
attrName: 'monthlyStoreCumulativeAchievement012',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 1.1区域经理周报模版 */
'uuid-temp-013': {
list: [{
attrName: 'monthlyStoreCumulativeAchievement013',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.3区域经理周报模版 */
'uuid-temp-014': {
list: [{
attrName: 'monthlyStoreCumulativeAchievement014',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.1运营主管周报模版 */
'uuid-temp-015': {
list: [{
attrName: 'monthlyOutput015',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 1.1运营主管周报模版 */
'uuid-temp-016': {
list: [{
attrName: 'monthlyOutput016',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.3运营主管周报模版 */
'uuid-temp-017': {
list: [{
attrName: 'monthlyOutput017',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 1.1区域经理月报模版 */
'uuid-temp-018': {
list: [{
attrName: 'actualAchievement018',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.1区域经理月报模版 */
'uuid-temp-019': {
list: [{
attrName: 'actualAchievement019',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.3区域经理月报模版 */
'uuid-temp-020': {
list: [{
attrName: 'actualAchievement020',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.1运营主管月报模版 */
'uuid-temp-021': {
list: [{
attrName: 'monthlyOutput021',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 1.1运营主管月报模版 */
'uuid-temp-022': {
list: [{
attrName: 'monthlyOutput022',
// 本月产值
valueObj: 'staffMonthTotal'
}]
},
/** 2.3运营主管月报模版 */
'uuid-temp-023': {
list: [{
attrName: 'monthlyOutput023',
// 本月产值
valueObj: 'staffMonthTotal'
}]
}
}
\ No newline at end of file \ No newline at end of file
...@@ -54,6 +54,16 @@ export const tempRuleFnObj = { ...@@ -54,6 +54,16 @@ export const tempRuleFnObj = {
return /^$|^[0]$|^\d{1}(\.\d{1,2})$|^([1-9]\d*)(\.\d{1,2})?$/.test(value) ? null : { message: '本月累计达成请输入仅有两位小数的数字' } return /^$|^[0]$|^\d{1}(\.\d{1,2})$|^([1-9]\d*)(\.\d{1,2})?$/.test(value) ? null : { message: '本月累计达成请输入仅有两位小数的数字' }
} }
}, },
/** 今日累计达成 */
dailyCumulativeAchievement: {
ruleFn: (rule, value) => {
const maxValue = 100000000
if (value < 0 || value > maxValue) {
return { message: `今日累计达成请输入0-${maxValue}` }
}
return /^$|^[0]$|^\d{1}(\.\d{1,2})$|^([1-9]\d*)(\.\d{1,2})?$/.test(value) ? null : { message: '今日累计达成请输入仅有两位小数的数字' }
}
},
/** 本月时间进度 */ /** 本月时间进度 */
monthlyTimeProgress: { monthlyTimeProgress: {
ruleFn: (rule, value) => { ruleFn: (rule, value) => {
......
// tabWorkOrder/pages/supervisorDaily/supervisorDaily.js // tabWorkOrder/pages/supervisorDaily/supervisorDaily.js
var util = require("~/utils/timeFormat/time-utils.js"); var util = require("~/utils/timeFormat/time-utils.js");
import { resData } from "./resData" import { resData } from "./resData";
import { tempRuleFnObj } from "./ruleFnObj" import { tempRuleFnObj } from "./ruleFnObj";
import fn from '~/components/GLCustForm/ruleFn' import { reportFirstAutoObj } from "./reportFirstAuto";
import fn from "~/components/GLCustForm/ruleFn";
import api from "../../api"; import api from "../../api";
import apiDefault from "~/api/api"; import apiDefault from "~/api/api";
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/' const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/'
var allRuleObj = {}
import { var allRuleObj = {};
setConfigInfo import { setConfigInfo } from "~/store/index";
} from '~/store/index' const app = getApp();
const app = getApp()
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -106,6 +106,48 @@ Page({ ...@@ -106,6 +106,48 @@ Page({
this.initData(options); this.initData(options);
}); });
}, },
// 获取默认值
getUserStat() {
const userInfo = wx.$util.getUserInfo();
const { routeParams, tmlpFormData, tmlpInitData } = this.data;
console.log(routeParams, "routeParams");
if (!userInfo) {
return;
}
wx.$util.showLoading("加载中...");
api
.userStat({
merchantId: userInfo?.shopMerchantId || undefined,
})
.then((result) => {
let { code, data } = result;
if (code == 0) {
const needDefaultCodeList = Object.keys(reportFirstAutoObj);
console.log(needDefaultCodeList, "needDefaultCodeList----");
if (needDefaultCodeList.includes(routeParams.code)) {
reportFirstAutoObj[routeParams.code]?.list.forEach((item) => {
tmlpFormData[item.attrName] =
data[item.valueObj].totalOrderMoney + "";
});
this.setData(
{
tmlpFormData: tmlpFormData,
tabChange: false,
},
() => {
this.setData({
tabChange: true,
});
}
);
}
}
})
.finally(() => {
wx.hideLoading();
});
},
async initData(options) { async initData(options) {
const { routeParams } = this.data; const { routeParams } = this.data;
// 获取配置服务数据 // 获取配置服务数据
...@@ -162,7 +204,13 @@ Page({ ...@@ -162,7 +204,13 @@ Page({
radioEvent(e) { radioEvent(e) {
let pAttr = e.target.id; let pAttr = e.target.id;
let { attr } = e.detail; let { attr } = e.detail;
let { tmlpFormData, tmlpObj, trainTmlpSuffix, tmlpCode, dailyReportTempList } = this.data; let {
tmlpFormData,
tmlpObj,
trainTmlpSuffix,
tmlpCode,
dailyReportTempList,
} = this.data;
tmlpObj["organizeTraining" + trainTmlpSuffix]?.forEach((item) => { tmlpObj["organizeTraining" + trainTmlpSuffix]?.forEach((item) => {
if (!item.name.includes("isTrainingOrganized")) { if (!item.name.includes("isTrainingOrganized")) {
item.isHide = tmlpFormData[attr] == "否" ? true : false; item.isHide = tmlpFormData[attr] == "否" ? true : false;
...@@ -305,7 +353,7 @@ Page({ ...@@ -305,7 +353,7 @@ Page({
currentYear, currentYear,
selectedMonth, selectedMonth,
selectedWeek, selectedWeek,
dailyReportTempList dailyReportTempList,
} = this.data; } = this.data;
console.log(tmlpEditList, "tmlpEditList"); console.log(tmlpEditList, "tmlpEditList");
console.log(tmlpCode, "tmlpCode"); console.log(tmlpCode, "tmlpCode");
...@@ -425,6 +473,11 @@ Page({ ...@@ -425,6 +473,11 @@ Page({
updates.isDisable = disable; updates.isDisable = disable;
updates.hasDailyValue = false; updates.hasDailyValue = false;
updates.isTodayEdit = false; updates.isTodayEdit = false;
// 当前月且可提交且未提交
if (isCurrentMonth && currentMonthData.beAbleSubmit === true) {
this.getUserStat();
}
} }
this.setData(updates); this.setData(updates);
} }
...@@ -457,7 +510,6 @@ Page({ ...@@ -457,7 +510,6 @@ Page({
}); });
} }
this.setData({ weekList }); this.setData({ weekList });
let currentWeekData = weekList.find( let currentWeekData = weekList.find(
(w) => w.week == this.data.selectedWeek (w) => w.week == this.data.selectedWeek
); );
...@@ -479,6 +531,10 @@ Page({ ...@@ -479,6 +531,10 @@ Page({
updates.isDisable = false; updates.isDisable = false;
updates.hasDailyValue = false; updates.hasDailyValue = false;
updates.isTodayEdit = false; updates.isTodayEdit = false;
if (currentWeekData.beAbleSubmit === true) {
this.getUserStat();
}
} }
} else { } else {
// Cannot operate -> Read Only // Cannot operate -> Read Only
...@@ -502,12 +558,15 @@ Page({ ...@@ -502,12 +558,15 @@ Page({
new Date().format("yyyy-MM-dd") new Date().format("yyyy-MM-dd")
) { ) {
//改---------------- //改----------------
const hasDailyValue =
timeBean.weekDayList[timeBean.selectDay].hasDailyValue || false;
this.setData({ this.setData({
isDisable: isDisable: hasDailyValue,
timeBean.weekDayList[timeBean.selectDay].hasDailyValue || false, hasDailyValue: hasDailyValue,
hasDailyValue:
timeBean.weekDayList[timeBean.selectDay].hasDailyValue || false,
}); });
if (!hasDailyValue) {
this.getUserStat();
}
} else if (tmlpEditList.includes(tmlpCode)) { } else if (tmlpEditList.includes(tmlpCode)) {
// 往期编辑 // 往期编辑
this.setData({ this.setData({
...@@ -1328,4 +1387,4 @@ Page({ ...@@ -1328,4 +1387,4 @@ Page({
this.getDateRecord(); this.getDateRecord();
this.getRecordDetail(); this.getRecordDetail();
}, },
});
\ No newline at end of file \ No newline at end of file
});
...@@ -28,7 +28,7 @@ Page({ ...@@ -28,7 +28,7 @@ Page({
}, { }, {
name: "工作日报", name: "工作日报",
url: "packageWorkspace.supervisorDaily", url: "packageWorkspace.supervisorDaily",
icon: "modifications-supervisor-daily", icon: "warranty-supervisor-daily",
reportTypeAttr: 'daily', reportTypeAttr: 'daily',
reportTypeVal: '1', reportTypeVal: '1',
trackingCode: 'regional-modifications-supervisor-daily' trackingCode: 'regional-modifications-supervisor-daily'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!