meeting-inspection-abnormal.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // pages/meeting-inspection-abnormal/meeting-inspection-abnormal.js
  2. const app = getApp();
  3. const util = require('../../utils/util.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. imgPath: app.globalData.imgPath,
  10. path: app.globalData.path,
  11. uploadList: [],
  12. ids: [],
  13. desc: null,
  14. inspectionProjectId: null,
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. this.setData({
  21. inspectionProjectId: options.inspectionProjectId
  22. });
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面隐藏
  36. */
  37. onHide: function () {
  38. },
  39. /**
  40. * 生命周期函数--监听页面卸载
  41. */
  42. onUnload: function () {
  43. },
  44. /**
  45. * 页面相关事件处理函数--监听用户下拉动作
  46. */
  47. onPullDownRefresh: function () {
  48. },
  49. /**
  50. * 页面上拉触底事件的处理函数
  51. */
  52. onReachBottom: function () {
  53. },
  54. /**
  55. * 用户点击右上角分享
  56. */
  57. onShareAppMessage: function () {
  58. },
  59. /**
  60. * 上传图片、选择图片
  61. */
  62. chooseImage: function () {
  63. let that = this;
  64. wx.chooseImage({
  65. count: 1,
  66. success: function (res) {
  67. wx.uploadFile({
  68. filePath: res.tempFilePaths[0],
  69. name: 'file',
  70. url: that.data.path + '/api/upload/record/upload',
  71. header: {
  72. "Content-Type": "multipart/form-data",
  73. "Authorization": app.globalData.Authorization
  74. },
  75. formData: {
  76. fileType: 20
  77. },
  78. success(re) {
  79. let datas = JSON.parse(re.data);
  80. if (datas.code != 200) {
  81. util.toast(datas.msg);
  82. } else {
  83. let arr = that.data.uploadList;
  84. let ids = that.data.ids;
  85. arr.push(res.tempFilePaths[0]);
  86. ids.push(datas.data.id);
  87. that.setData({
  88. uploadList: arr,
  89. ids: ids
  90. });
  91. }
  92. }
  93. });
  94. }
  95. });
  96. },
  97. /**
  98. * 移除上传图片
  99. * @param {*} e
  100. */
  101. removeImg: function (e) {
  102. let that = this;
  103. let arr = that.data.uploadList;
  104. let ids = that.data.ids;
  105. arr.splice(e.target.dataset.index, 1);
  106. ids.splice(e.target.dataset.index, 1);
  107. that.setData({
  108. uploadList: arr,
  109. ids: ids
  110. });
  111. },
  112. /**
  113. * 获取描述内容
  114. * @param {*} e
  115. */
  116. forDescription: function (e) {
  117. this.setData({
  118. desc: e.detail.value
  119. });
  120. },
  121. /**
  122. * 巡检结果不正常描述提交
  123. */
  124. submitAbnormal: function () {
  125. let that = this;
  126. let desc = that.data.desc;
  127. if (!desc) {
  128. util.toast('请输入结果描述');
  129. return;
  130. }
  131. let obj = {
  132. fileIds: that.data.ids,
  133. inspectionProjectId: that.data.inspectionProjectId,
  134. remark: desc,
  135. result: 20,
  136. }
  137. wx.setStorageSync('inspectionResultItem', JSON.stringify(obj));
  138. wx.navigateBack({
  139. delta: -1,
  140. });
  141. }
  142. })