import { fetchAssessmentDetail } from '../../../services/enterprise/fetchAssessment';
|
import { fetchSceneAuthen } from '../../../services/enterprise/fetchAuthentication';
|
import { fetchCreditInfo } from '../../../services/enterprise/fetchCreditCode';
|
import { fetchLedgerSummary } from '../../../services/enterprise/fetchLedger';
|
import { fetchCommitmentStat } from '../../../services/enterprise/fetchPromise';
|
import { fetchRiskInfo } from '../../../services/enterprise/fetchRisk';
|
import { useLoading } from '../../../behaviors/loading';
|
import { toTime, toPeriod } from '../../../utils/period';
|
import { openDoc } from '../../../utils/file';
|
import { getLedgerStat } from '../../../model/ledger/ledgerStat';
|
import { getLedgerIsUploaded } from '../../../model/ledger/ledgerSummary';
|
|
Page({
|
behaviors: [useLoading],
|
data: {
|
// 当前展示的周期
|
period: '',
|
monthValue: '',
|
// 企业用户信息
|
enterprise: {},
|
// 企业认证情况
|
authenInfo: [],
|
// 合规风险信息
|
riskInfo: {},
|
// 自巡查信息
|
selfCheckInfo: {},
|
// 台账信息
|
ledgerInfo: {},
|
// 自测自评
|
historyPoint: {},
|
// 守法承诺
|
promsieInfo: {},
|
// 环信码
|
creditInfo: {},
|
},
|
|
onLoad(options) {
|
this.getOpenerEventChannel().on('acceptEnterpriseData', data => {
|
this.setData({ ...data });
|
this.init();
|
this._startLoad();
|
});
|
},
|
|
init() {
|
if (!this.data.period) {
|
const period = toPeriod();
|
const monthValue = toTime(period).format('YYYY-MM');
|
this.setData({ period, monthValue });
|
} else {
|
const monthValue = toTime(this.data.period).format('YYYY-MM');
|
this.setData({ monthValue });
|
}
|
},
|
|
_fetchData(page) {
|
let { id: userId, sceneTypeId: sceneType } = this.data.enterprise;
|
let { period } = this.data;
|
let time = toTime(period).format('YYYY-MM-DD');
|
|
let f1 = fetchAssessmentDetail({ userId, period }).then(res => {
|
this.setData({ historyPoint: res.data });
|
});
|
let f2 = fetchLedgerSummary({ userId, sceneType, time }).then(res => {
|
// 自巡查和台账的提交百分比
|
const stat = getLedgerStat(res.data, time);
|
// 自巡查和台账的具体提交内容
|
const detail = getLedgerIsUploaded(res.data);
|
this.setData({
|
selfCheckInfo: {
|
stat: {
|
total: stat.totalSelf,
|
finished: stat.finishedSelf,
|
percent: stat.percent2,
|
},
|
detail: detail.selfCheckInfo,
|
},
|
ledgerInfo: {
|
stat: {
|
total: stat.totalMust,
|
finished: stat.finishedMust,
|
percent: stat.percent,
|
},
|
detail: detail.ledgerInfo,
|
},
|
});
|
});
|
let f3 = fetchCommitmentStat({ userId }).then(res => {
|
this.setData({ promsieInfo: res.data });
|
});
|
let f4 = fetchCreditInfo({ userId, period }).then(res => {
|
this.setData({ creditInfo: res.data });
|
});
|
let f5 = fetchRiskInfo({ userId, period: time }).then(res => {
|
this.setData({ riskInfo: res.data });
|
});
|
let f6 = fetchSceneAuthen({ userId }).then(res => {
|
this.setData({ authenInfo: res.data });
|
});
|
|
return Promise.all([f1, f2, f3, f4, f5, f6]);
|
},
|
|
onTimePickerConfirm(e) {
|
const { timeText, timeValue } = e.detail;
|
const period = toPeriod(timeValue);
|
const monthValue = toTime(period).format('YYYY-MM');
|
this.setData({ period, monthValue });
|
this._startLoad();
|
},
|
|
navToAssessment() {
|
if (this.data.historyPoint.time) {
|
wx.navigateTo({
|
// url: `/pages/enterprise/assessment/history/index?userId=${this.data.enterprise.id}`,
|
url: `/pages/enterprise/assessment/form/index?userId=${this.data.enterprise.id}&period=${this.data.period}`,
|
});
|
}
|
},
|
|
navToAssessmentReport() {
|
if (this.data.historyPoint.time) {
|
wx.navigateTo({
|
url: `/pages/enterprise/assessment/detail/index?userId=${this.data.enterprise.id}&period=${this.data.period}`,
|
});
|
}
|
},
|
|
navToLedger(e) {
|
const { mode } = e.currentTarget.dataset;
|
wx.navigateTo({
|
url: `/pages/enterprise/ledger/history/index?userId=${this.data.enterprise.id}&sceneTypeId=${this.data.enterprise.sceneTypeId}&time=${this.data.monthValue}&mode=${mode}`,
|
});
|
},
|
|
navToPromise() {
|
// wx.navigateTo({
|
// url: `/pages/enterprise/promise/history/index?userId=${this.data.enterprise.id}`,
|
// });
|
|
const p = this.data.promsieInfo;
|
if (!p.picPath) return;
|
if (p.picPath.length > 0) {
|
wx.navigateTo({
|
url: '/pages/enterprise/promise/detail/index',
|
success: function (res) {
|
// 通过 eventChannel 向被打开页面传送数据
|
res.eventChannel.emit('acceptPromiseData', {
|
promise: {
|
picPath: p.picPath,
|
pdfPath: p.pdfPath,
|
},
|
});
|
},
|
});
|
} else if (p.pdfPath.length > 0) {
|
openDoc(p.pdfPath);
|
}
|
},
|
|
navToEcCode(e) {
|
const id = e.detail;
|
wx.navigateTo({
|
url: `/pages/enterprise/ec-code/index?userId=${id}`,
|
});
|
},
|
});
|