微信小程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

project.js 10 KiB

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