微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 line
4.5 KiB

  1. // pages/contract/add/add.js
  2. import * as UTIL from '../../../utils/util.js';
  3. import * as API from '../../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. id:null,
  12. voteTypeOptions: [],
  13. voteStatusOptions: [],
  14. voteResultOptions: [],
  15. fileList: [],
  16. form:{}
  17. },
  18. back:function(){
  19. wx.navigateBack({
  20. delta: 1
  21. })
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad(options) {
  27. this.setData({id:options.id})
  28. },
  29. goForm(e){
  30. wx.navigateTo({
  31. url: '../form/form?id='+e.currentTarget.dataset.id,
  32. })
  33. },
  34. /**
  35. * 生命周期函数--监听页面初次渲染完成
  36. */
  37. onReady() {
  38. },
  39. /**
  40. * 生命周期函数--监听页面显示
  41. */
  42. onShow() {
  43. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'vote_type', {method:'GET'}, {
  44. success: (res) => {
  45. this.setData({
  46. voteTypeOptions:res.data,
  47. })
  48. }
  49. })
  50. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'vote_status', {method:'GET'}, {
  51. success: (res) => {
  52. this.setData({
  53. voteStatusOptions:res.data,
  54. })
  55. }
  56. })
  57. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'vote_result', {method:'GET'}, {
  58. success: (res) => {
  59. this.setData({
  60. voteResultOptions:res.data,
  61. })
  62. }
  63. })
  64. //获取收入合同状态
  65. UTIL.httpRequest(API.URL_GET_VOTEDETAIL + this.data.id , {method:'GET'}, {
  66. success: (res) => {
  67. res.data.voteStatusText = UTIL.getTransform(res.data.voteStatus,this.data.voteStatusOptions);
  68. res.data.voteTypeText = UTIL.getTransform(res.data.voteType,this.data.voteTypeOptions);
  69. res.data.yesForm = [];
  70. res.data.noForm = [];
  71. res.data.everForm = [];
  72. res.data.detailList.map(rr=>{
  73. rr.voteResultText = UTIL.getTransform(rr.voteResult,this.data.voteResultOptions);
  74. if(rr.voteResult == 1){
  75. res.data.yesForm.push(rr);
  76. }
  77. if(rr.voteResult == 2){
  78. res.data.noForm.push(rr);
  79. }
  80. if(rr.voteResult == 3){
  81. res.data.everForm.push(rr);
  82. }
  83. })
  84. console.log(res.data);
  85. this.setData({'form':res.data});
  86. this.asyncFun(this.data.id);
  87. }
  88. })
  89. },
  90. asyncFun(id){
  91. this.data.form.fileList = [];
  92. let uploadList = this.data.uploadOptions
  93. let newList = []
  94. let _this = this
  95. let oData = {
  96. tableId: id,
  97. tableName: "t_hz_vote", //上传表
  98. bizPath: "subcontract",
  99. method:'GET'
  100. }
  101. UTIL.httpRequest(API.URL_GET_ATTACHMENTLIST, oData, {
  102. success: (rr) => {
  103. if(rr.code==200&&rr.rows.length>0){
  104. rr.rows.map((rrr,index) => {
  105. rrr.url = wx.getStorageSync('dressCode') + rrr.fileUrl
  106. if(index==rr.rows.length-1){
  107. newList.push(Object.assign({},{"list":rr.rows}))
  108. _this.setData({"form.fileList":_this.data.fileList.concat(newList)});
  109. }
  110. })
  111. console.log(this.data.fileList);
  112. }else{
  113. let newuploadList = uploadList
  114. newuploadList.map(rd => {
  115. rd.list = newList
  116. })
  117. _this.setData({"form.fileList":newuploadList});
  118. }
  119. }
  120. })
  121. },
  122. lookDown(file,detail){
  123. // 获取指定字符串最后一次出现的位置,返回index
  124. var index1 = file.detail.url.lastIndexOf('.');
  125. // substr(start, length) 抽取从start下标开始的length个字符,返回新的字符串;
  126. var style = file.detail.url.substr(index1 + 1)
  127. //判断图片类型,不需要下载,不做处理
  128. if(style=='png'||style=='jpg'||style=='jpeg'||style=='bmp'||style=='gif'||style=='webp'||style=='psd'||style== 'svg'||style=='tiff'){
  129. //判断非图片类型
  130. }else{
  131. wx.downloadFile({
  132. url: file.detail.url,
  133. success(data){
  134. wx.openDocument({
  135. filePath: data.tempFilePath,
  136. fileType: style,
  137. showMenu:true,
  138. success(res){
  139. }
  140. })
  141. }
  142. })
  143. }
  144. },
  145. /**
  146. * 生命周期函数--监听页面隐藏
  147. */
  148. onHide() {
  149. },
  150. /**
  151. * 生命周期函数--监听页面卸载
  152. */
  153. onUnload() {
  154. },
  155. /**
  156. * 页面相关事件处理函数--监听用户下拉动作
  157. */
  158. onPullDownRefresh() {
  159. },
  160. /**
  161. * 页面上拉触底事件的处理函数
  162. */
  163. onReachBottom() {
  164. },
  165. /**
  166. * 用户点击右上角分享
  167. */
  168. onShareAppMessage() {
  169. }
  170. })