微信小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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