import config from '../../../config' import { queryCountByType } from '../../../api/projectStandard' const app = getApp() Page({ /** * 页面的初始数据 */ data: { deptId: "", loginName: "", projectId: "", minRoleId: "", projectData: {}, initData: {}, show: false, listData: [], standard: null, standardName: '', standardActive: '', typeList: [{ id: 1, name: '作业标准化', icon: config.baseUrl + '/staticFiles/img/zybzh.png', count: 0, }, { id: 2, name: '现场管理标准', icon: config.baseUrl + '/staticFiles/img/xcglbzh.png', count: 0, }, { id: 3, name: '安全技术标准', icon: config.baseUrl + '/staticFiles/img/aqjsbzh.png', count: 0, }, { id: 4, name: '设备管理标准', icon: config.baseUrl + '/staticFiles/img/sbglbzh.png', count: 0, }, { id: 5, name: '文明施工标准', icon: config.baseUrl + '/staticFiles/img/wmsgbzh.png', count: 0, }, { id: 6, name: '环境保护标准', icon: config.baseUrl + '/staticFiles/img/hjbhbzh.png', count: 0, } ], }, skipAdd() { wx.redirectTo({ url: `../add/index?projectId=${this.data.initData.id}&projectName=` + this.data.initData.text, }) }, getInfo(e) { let { id } = e.currentTarget.dataset.set wx.redirectTo({ url: `../info/index?id=${id}` }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let standard; if (options && options.standard) { standard = options.standard; app.globalData.standard = options.standard; } else { standard = app.globalData.standard; } //获取缓存数据 wx.getStorage({ key: 'userinfo', success: res => { this.setData({ deptId: res.data.deptId, loginName: res.data.loginName, userName: res.data.userName, projectId: app.globalData.projectId, minRoleId: res.data.minRoleId, initData: { text: app.globalData.projectName, id: app.globalData.projectId }, standard: standard, standardName: this.data.typeList[standard - 1].name, standardActive: this.data.typeList[standard - 1].id, listData: [], }) this.getListData(app.globalData.projectId, res.data.deptId, res.data.minRoleId); } }) }, /** * 切换页签 * @param {*} e */ standardActive: function (e) { let { id, name } = e.currentTarget.dataset.set this.setData({ standard: id, standardName: name, standardActive: id }) app.globalData.standard = id; this.onLoad() }, /** * 查询项目项目标准化数据 */ getListData(projectId, deptId, minRoleId) { var that = this; //判断角色, if (minRoleId == 2 || minRoleId == 3 || minRoleId == 4) { deptId = 0; } let param = { "standardType": this.data.standard, "projectId": projectId, "deptId": deptId, } this.queryCountByType(param); wx.request({ url: app.globalData.reqUrl + '/wechat/projectStandard/list', data: param, method: "get", success: function (res) { if(res.data.data.length>0){ res.data.data.forEach(item =>{ item.minImageUrl = config.baseUrl+item.imageFile+".min.jpg" }) that.setData({ listData: res.data.data }) }else{ that.setData({ listData: [] }) } } }); }, /** * 根据条件查询类型数量统计 */ queryCountByType: function (data) { queryCountByType(data).then(res => { let typeList = this.data.typeList; typeList.forEach(type => { res.data.forEach(item => { if (type.id == item.standardType) { if (item.total) { type.count = item.total; } } }) }); this.setData({ typeList }) }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, returnToPage: function () { /*关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/ wx.redirectTo({ url: '../../../pages/gengduogongneng/index', }) }, //项目切换 返回值 onProjectSelect(e) { let projectId = e.detail.id; let projectName = e.detail.text; app.globalData.projectId = projectId; app.globalData.projectName = projectName; this.onLoad(); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })