jhwxapp/miniprogram/pageage/project_standard/info/index.js

235 lines
4.9 KiB
JavaScript
Raw Normal View History

2024-05-03 10:37:27 +08:00
import jsonConfig from '../../../utils/json'
import {
getDictCache
} from '../../../api/publics'
2023-11-19 22:40:09 +08:00
const app = getApp()
Page({
2024-05-03 10:37:27 +08:00
/**
* 页面的初始数据
*/
data: {
id: "",
type: "",
infoData: {},
loadShow: false,
loginName: "",
projectName: "",
showDel: false,
imageList: [],
minImageList: [],
request: app.globalData.reqUrl,
standardTypeName: "",
standardTypeRemark: "",
standardNotesName: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let {
id,
standardType
} = options
//获取缓存数据
wx.getStorage({
key: 'userinfo',
success: res => {
this.setData({
id,
type: standardType.substring(0, 1),
loginName: res.data.loginName,
projectName: app.globalData.projectName
})
this.getDicts();
this.getInfo();
}
})
},
//获取字典信息
getDicts() {
let that = this;
/*关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/
getDictCache('prj_standard_type').then(res => {
if (res.code == 200) {
res.data.forEach(item => {
if (item.dictValue == that.data.type) {
that.setData({
standardTypeName: item.dictLabel,
standardTypeRemark: item.remark
})
2023-11-19 22:40:09 +08:00
}
})
2024-05-03 10:37:27 +08:00
}
});
},
/**
* 获取安全检查详情信息
*
*/
getInfo() {
let {
id
} = this.data
let that = this
wx.request({
url: app.globalData.reqUrl + '/wechat/projectStandard/info',
method: "get",
data: {
id: id
},
success(res) {
res = res.data
if (res.code == 200) {
let urls = [];
let minUrls = [];
if (res.data.imageFile) {
res.data.imageFile.split(',').forEach(element => {
urls.push(that.data.request + element);
minUrls.push(that.data.request + element + '.min.jpg');
});
}
if (that.data.type != res.data.standardType) {
let index = that.data.type - 1;
jsonConfig.standardTypeListNotes[index].forEach(it => {
if (it.children && it.children.length > 0) {
it.children.forEach(i => {
if (i.id == res.data.standardType) {
that.setData({
standardNotesName: i.text
})
}
})
} else {
if (it.id == res.data.standardType) {
that.setData({
standardNotesName: it.text
})
}
}
});
2023-11-19 22:40:09 +08:00
}
2024-05-03 10:37:27 +08:00
that.setData({
infoData: res.data,
imageList: urls,
minImageList: minUrls,
loadShow: false
})
//判断当前能否删除
if (res.data.createBy == that.data.loginName) {
that.setData({
showDel: true
2023-11-19 22:40:09 +08:00
})
}
2024-05-03 10:37:27 +08:00
}
}
})
},
onDelete() {
//弹出确认
let that = this
wx.showModal({
title: '提示',
content: '是否确定删除此条数据?',
success: function (sm) {
if (sm.confirm) {
// 用户点击了确定 可以调用了
that.deleteData();
} else if (sm.cancel) {
console.log('用户点击取消');
}
}
})
},
deleteData() {
let {
id
} = this.data
let that = this;
wx.request({
url: app.globalData.reqUrl + '/wechat/projectStandard/remove',
header: {
"Username": that.data.loginName,
},
data: {
id: id
},
method: "get",
success(res) {
app.toast("删除成功!")
wx.redirectTo({
url: `../list/index`,
2023-11-19 22:40:09 +08:00
})
2024-05-03 10:37:27 +08:00
}
})
},
2023-11-19 22:40:09 +08:00
//展示图片
2024-05-03 10:37:27 +08:00
showImg: function (e) {
var that = this;
2023-11-19 22:40:09 +08:00
wx.previewImage({
2024-05-03 10:37:27 +08:00
urls: that.data.imageList,
current: that.data.imageList[e.currentTarget.dataset.index]
2023-11-19 22:40:09 +08:00
})
},
2024-05-03 10:37:27 +08:00
returnToPage: function () {
/*关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/
wx.redirectTo({
url: '../list/index',
})
},
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
},
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
/**
* 生命周期函数--监听页面显示
*/
onShow() {
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
},
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
},
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
},
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
},
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
},
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
2023-11-19 22:40:09 +08:00
2024-05-03 10:37:27 +08:00
}
2023-11-19 22:40:09 +08:00
})