微信小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

project.js 10 KiB

3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. // pages/project/project.js
  2. import * as UTIL from '../../utils/util.js';
  3. import * as API from '../../utils/API.js';
  4. let EVN_CONFIG = require('../../env/env');
  5. const DISTRIBUTE_ENVIROMENT = 'IMGURL';
  6. let {
  7. URL_PREFIX,
  8. } = EVN_CONFIG[DISTRIBUTE_ENVIROMENT];
  9. const app = getApp();
  10. Page({
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. isIPX: app.globalData.isIPX,
  16. name:"",
  17. value:'',
  18. pageNums:1,
  19. showUpload:false,
  20. uploadOptions:[],
  21. fileList:[],
  22. itemId:"",
  23. list:[],
  24. fileEvent:{},
  25. projectList:[]
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad(options) {
  31. var _this = this;
  32. let qu = wx.createSelectorQuery()
  33. qu.select("#top_view").boundingClientRect()
  34. qu.exec(res => {
  35. _this.setData({
  36. scrollHeight:wx.getSystemInfoSync().windowHeight-res[0].height-res[0].top
  37. })
  38. })
  39. //获取附件字典
  40. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'common_attach', {method:'GET'}, {
  41. success: (res) => {
  42. this.setData({
  43. uploadOptions:res.data,
  44. })
  45. }
  46. })
  47. },
  48. /**
  49. * 生命周期函数--监听页面初次渲染完成
  50. */
  51. onReady() {
  52. this.onShow();
  53. },
  54. goSearch(e){
  55. this.setData({name:e.detail})
  56. this.onShow();
  57. },
  58. goAdd(){
  59. wx.navigateTo({
  60. url: 'add/add',
  61. })
  62. },
  63. back:function(){
  64. wx.navigateBack({
  65. delta: 1
  66. })
  67. },
  68. /**
  69. * 生命周期函数--监听页面显示
  70. */
  71. onShow() {
  72. var that = this;
  73. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'yn_projcet_status', {method:'GET'}, {
  74. success: (res) => {
  75. this.setData({
  76. ynProjcetStatusOptions:res.data
  77. });
  78. let params= {
  79. projectName:this.data.name,
  80. method:'GET'
  81. }
  82. UTIL.httpRequest(API.URL_GET_GETPROJECTLIST, params,{
  83. success: (response) => {
  84. if (response.code == API.SUCCESS_CODE) {
  85. for (let i = 0; i < response.rows.length; i++) {
  86. response.rows[i].ynProjcetStatusText = UTIL.getTransform(response.rows[i].ynProjcetStatus,res.data);
  87. response.rows[i].startTime = response.rows[i].startTime.replace(/-/g,".");
  88. response.rows[i].endTime = response.rows[i].endTime.replace(/-/g,".");
  89. response.rows[i].projectAmount = parseFloat(response.rows[i].projectAmount).toFixed(2);
  90. }
  91. that.setData({
  92. projectList:response.rows
  93. })
  94. }
  95. }
  96. })
  97. }
  98. })
  99. },
  100. delete(e){
  101. var that = this;
  102. UTIL.httpRequest(API.URL_GET_PROJECTDELETE + e.currentTarget.dataset.id, {method:'GET'},{
  103. success: (res) => {
  104. if (res.code == API.SUCCESS_CODE) {
  105. let list = that.data.projectList
  106. list.splice(e.currentTarget.dataset.index, 1);
  107. wx.showToast({
  108. title: '删除成功!',
  109. icon: 'success',
  110. duration: 2000
  111. })
  112. that.setData({
  113. projectList : list,
  114. })
  115. }
  116. }
  117. })
  118. },
  119. changeTab(e){
  120. var that = this ;
  121. that.setData({value1:e.detail})
  122. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_type', {method:'GET'}, {
  123. success: (res) => {
  124. UTIL.httpRequest(API.URL_GET_GETMONEYORDERLIST, {method:'GET',orderType:that.data.value1,orderStatus:that.data.value2},{
  125. success: (response) => {
  126. if (response.code == API.SUCCESS_CODE) {
  127. for (let i = 0; i < response.rows.length; i++) {
  128. response.rows[i].orderTypeText = UTIL.getTransform(response.rows[i].orderType,res.data);
  129. response.rows[i].startTime = response.rows[i].startTime.replace(/-/g,".");
  130. response.rows[i].endTime = response.rows[i].endTime.replace(/-/g,".");
  131. response.rows[i].orderAmount = parseFloat(response.rows[i].orderAmount).toFixed(2);
  132. }
  133. that.setData({
  134. moneyorderList:response.rows
  135. })
  136. }
  137. }
  138. })
  139. }
  140. })
  141. },
  142. changeTab2(e){
  143. var that = this ;
  144. that.setData({value2:e.detail})
  145. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_type', {method:'GET'}, {
  146. success: (res) => {
  147. UTIL.httpRequest(API.URL_GET_GETMONEYORDERLIST, {method:'GET',orderType:that.data.value1,orderStatus:that.data.value2},{
  148. success: (response) => {
  149. if (response.code == API.SUCCESS_CODE) {
  150. for (let i = 0; i < response.rows.length; i++) {
  151. response.rows[i].orderTypeText = UTIL.getTransform(response.rows[i].orderType,res.data);
  152. response.rows[i].startTime = response.rows[i].startTime.replace(/-/g,".");
  153. response.rows[i].endTime = response.rows[i].endTime.replace(/-/g,".");
  154. response.rows[i].orderAmount = parseFloat(response.rows[i].orderAmount).toFixed(2);
  155. }
  156. that.setData({
  157. moneyorderList:response.rows
  158. })
  159. }
  160. }
  161. })
  162. }
  163. })
  164. },
  165. upload(e){
  166. this.setData({itemId:e.currentTarget.dataset.id});
  167. this.asyncFun(e.currentTarget.dataset.id)
  168. },
  169. asyncFun(id){
  170. this.setData({"fileList":[]})
  171. let uploadList = this.data.uploadOptions
  172. let newList = []
  173. let _this = this
  174. uploadList.map( res => {
  175. let oData = {
  176. tableId: id,
  177. tableName: "t_yinnong_project", //上传表
  178. bizPath: "yinnong",
  179. fileType: res.dictValue, //附件类型 1原始发票 2会议纪要 3会议照片 4 参会人员签字
  180. method:'GET'
  181. }
  182. UTIL.httpRequest(API.URL_GET_ATTACHMENTLIST, oData, {
  183. success: (rr) => {
  184. if(rr.rows.length>0){
  185. rr.rows.map((rrr,index) => {
  186. rrr.url = URL_PREFIX + rrr.fileUrl
  187. if(index==rr.rows.length-1){
  188. newList.push(Object.assign({},res,{"list":rr.rows}))
  189. _this.setData({"fileList":_this.data.fileList.concat(newList)});
  190. _this.setData({"showUpload":true})
  191. }
  192. })
  193. }else{
  194. let newuploadList = uploadList
  195. newuploadList.map(rd => {
  196. rd.list = newList
  197. })
  198. _this.setData({"fileList":newuploadList});
  199. _this.setData({"showUpload":true})
  200. }
  201. },
  202. fail:(rr) =>{
  203. },
  204. complete:(rr) => {
  205. }
  206. })
  207. })
  208. },
  209. closeBox(){
  210. this.setData({"showUpload":false})
  211. },
  212. deleteImg(event){
  213. this.setData({"fileEvent":event})
  214. this.setData({"showPopup":true});
  215. },
  216. cancelTem:function(e){
  217. this.setData({"fileEvent":"{}"});
  218. this.setData({"showPopup":false});
  219. },
  220. confirmTem:function(e){
  221. let event = this.data.fileEvent
  222. console.log(event);
  223. UTIL.httpRequest(API.URL_GET_GETFILEREMOVE+event.detail.file.id , {method:'GET'}, {
  224. success: (res) => {
  225. if(res.code==200){
  226. let ll = this.data.fileList
  227. var jsonlist = ll[event.target.dataset.idx].list;
  228. jsonlist.splice(event.detail.index, 1)
  229. ll[event.target.dataset.idx].list = jsonlist
  230. this.setData({"fileList":ll})
  231. this.setData({showPopup:false});
  232. wx.showToast({
  233. title: '删除成功!',
  234. icon: 'success',
  235. duration: 2000,
  236. })
  237. }
  238. }
  239. })
  240. },
  241. uploadFile(uploadFile,event) {
  242. let _this = this
  243. return new Promise((resolve, reject) => {
  244. wx.uploadFile({
  245. url: API.URL_GET_UPLOAD,
  246. filePath: uploadFile.file.file[0].url,
  247. name: 'file',
  248. header: {
  249. "Content-Type": "multipart/form-data",//记得设置
  250. "chartset":"utf-8",
  251. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  252. },
  253. formData:uploadFile,
  254. success: (res) => {
  255. res.data = JSON.parse(res.data);
  256. if(res.statusCode == 200){
  257. let files = _this.data.fileList
  258. let fName = res.data.fileUrl.split('/')
  259. let fLength = fName.length
  260. files[event.currentTarget.dataset.idx].list.push({
  261. "fileName": fName[fLength-1],
  262. "fileType": "0",
  263. "fileUrl":res.data.fileUrl ,
  264. "id": res.data.id,
  265. "tableId": 6,
  266. "url":URL_PREFIX+res.data.fileUrl
  267. })
  268. _this.setData({"fileList":files})
  269. wx.hideLoading()
  270. }
  271. },
  272. fail: (err) => {
  273. //上传失败:修改pedding为reject
  274. reject(err)
  275. }
  276. });
  277. })
  278. },
  279. afterRead(event) {
  280. let _this = this
  281. wx.showLoading({
  282. title: '上传中...'
  283. })
  284. let fileForm={
  285. file: event.detail,
  286. fileType:event.currentTarget.dataset.idx,
  287. tableName: "t_yinnong_project", //上传表
  288. bizPath: "yinnong",
  289. tableId:_this.data.itemId
  290. }
  291. this.uploadFile(fileForm,event)
  292. },
  293. lookDown(file,detail){
  294. // 获取指定字符串最后一次出现的位置,返回index
  295. var index1 = file.detail.url.lastIndexOf('.');
  296. // substr(start, length) 抽取从start下标开始的length个字符,返回新的字符串;
  297. var style = file.detail.url.substr(index1 + 1)
  298. //判断图片类型,不需要下载,不做处理
  299. if(style=='png'||style=='jpg'||style=='jpeg'||style=='bmp'||style=='gif'||style=='webp'||style=='psd'||style== 'svg'||style=='tiff'){
  300. //判断非图片类型
  301. }else{
  302. wx.downloadFile({
  303. url: file.detail.url,
  304. success(data){
  305. wx.openDocument({
  306. filePath: data.tempFilePath,
  307. fileType: style,
  308. showMenu:true,
  309. success(res){
  310. }
  311. })
  312. }
  313. })
  314. }
  315. },
  316. /**
  317. * 生命周期函数--监听页面隐藏
  318. */
  319. onHide() {
  320. },
  321. /**
  322. * 生命周期函数--监听页面卸载
  323. */
  324. onUnload() {
  325. },
  326. /**
  327. * 页面相关事件处理函数--监听用户下拉动作
  328. */
  329. onPullDownRefresh() {
  330. },
  331. /**
  332. * 页面上拉触底事件的处理函数
  333. */
  334. onReachBottom() {
  335. },
  336. /**
  337. * 用户点击右上角分享
  338. */
  339. onShareAppMessage() {
  340. }
  341. })