微信小程序
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.

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
há 3 anos
há 3 anos
há 3 anos
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. // pages/paymentManager/paymentManager.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. list:[],
  13. isLoading:false,
  14. pageNums:1,
  15. scrollHeight:"",
  16. name:"",
  17. showUpload:false,
  18. uploadOptions:[],
  19. fileList:[],
  20. showPopup:false,
  21. fileEvent:{},
  22. itemId:"",
  23. assetTypeOptions:[],
  24. option1: [
  25. { text: '支付状态', value: '' },
  26. { text: '待支付', value: '1' },
  27. { text: '银行受理', value: '3' },
  28. { text: '支付失败', value: '4' },
  29. { text: '部分失败', value: '5' },
  30. ],
  31. option2: [
  32. { text: '支出类别', value: '' },
  33. { text: '结算类', value: '1' },
  34. { text: '工程项目类', value: '2' },
  35. { text: '合同类', value: '4' },
  36. { text: '其他', value: '5' },
  37. ],
  38. option3: [
  39. { text: '申请类别', value: '' },
  40. { text: '银行卡转账', value: '1' },
  41. { text: '信用卡还款', value: '2' },
  42. ],
  43. value1: '',
  44. value2: '',
  45. value3: '',
  46. },
  47. goAdd(){
  48. wx.navigateTo({
  49. url: 'add/add',
  50. })
  51. },
  52. back:function(){
  53. wx.navigateBack({
  54. delta: 1
  55. })
  56. },
  57. assetTypeDict(val){
  58. this.data.assetTypeOptions.map(res => {
  59. if(res.dictValue == val){
  60. return res.dictLabel
  61. }
  62. })
  63. },
  64. /**
  65. * 生命周期函数--监听页面加载
  66. */
  67. onLoad(options) {
  68. var that = this;
  69. let qu = wx.createSelectorQuery()
  70. qu.select("#top_view1").boundingClientRect()
  71. qu.select("#top_ban").boundingClientRect()
  72. qu.exec(res => {
  73. that.setData({
  74. scrollHeight:wx.getSystemInfoSync().windowHeight-res[0].height-res[0].top
  75. })
  76. })
  77. this.getList();
  78. },
  79. /**
  80. * 生命周期函数--监听页面初次渲染完成
  81. */
  82. onReady() {
  83. //获取附件字典
  84. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bookkeeping_type', {method:'GET'}, {
  85. success: (res) => {
  86. if(res.data.length>0){
  87. this.setData({
  88. uploadOptions:res.data,
  89. })
  90. }
  91. }
  92. })
  93. },
  94. getList:function(){
  95. let params = {
  96. pageNum:this.data.pageNums,
  97. pageSize:10,
  98. name:this.data.name,
  99. remark:this.data.name,
  100. paymentState:this.data.value1,
  101. capitalExpenditureType:this.data.value2,
  102. transferType:this.data.value3
  103. }
  104. UTIL.httpRequest(API.URL_GET_TRANSFERPAYLIST,params,{
  105. success: (res) => {
  106. let _this = this
  107. if(res.code == 200){
  108. for (let i = 0; i < res.rows.length; i++) {
  109. const element = res.rows[i];
  110. res.rows[i].expenditureAmount = parseFloat(res.rows[i].expenditureAmount).toFixed(2);
  111. }
  112. if(this.data.pageNums!=1&&this.data.list.length<res.total){
  113. console.log("11111");
  114. let lists = []
  115. res.rows.map((rr,index) => {
  116. rr.expenditureAmount = Number(rr.expenditureAmount ).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  117. return $1 + ","; }).replace(/\.$/, "")
  118. if(index==(res.rows.length-1)){
  119. lists = _this.data.list.concat(res.rows)
  120. }
  121. })
  122. //获取资产类别
  123. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_type', {method:'GET'}, {
  124. success: (r) => {
  125. if(r.data.length>0){
  126. let li = lists.map( res => {
  127. r.data.map(rr => {
  128. if(res.assetType == rr.dictValue){
  129. res.assetType = rr.dictLabel
  130. }
  131. })
  132. return res
  133. })
  134. _this.setData({list:li})
  135. }else{
  136. _this.setData({list:lists})
  137. }
  138. }
  139. })
  140. }else if(this.data.pageNums==1){
  141. console.log("22222");
  142. //获取资产类别
  143. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'asset_type', {method:'GET'}, {
  144. success: (r) => {
  145. if(r.data.length>0){
  146. let li = res.rows.map( ress => {
  147. ress.originalValue = Number(ress.originalValue ).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  148. return $1 + ","; }).replace(/\.$/, "")
  149. r.data.map(rr => {
  150. if(ress.assetType == rr.dictValue){
  151. ress.assetType = rr.dictLabel
  152. }
  153. })
  154. return ress
  155. })
  156. _this.setData({list:li})
  157. }else{
  158. _this.setData({list:res.rows})
  159. }
  160. }
  161. })
  162. }
  163. }else{
  164. UTIL.showToastNoneIcon(res.msg);
  165. }
  166. }
  167. })
  168. },
  169. paging(){
  170. this.setData({
  171. pageNums:this.data.pageNums+1,
  172. })
  173. this.getList();
  174. },
  175. goSearch(e){
  176. this.setData({name:e.detail});
  177. this.setData({remark:e.detail});
  178. this.setData({pageNums:1});
  179. this.getList();
  180. },
  181. toPay(e){
  182. wx.navigateTo({
  183. url: '/pages/paymentManager/toPay/toPay?id='+e.currentTarget.dataset.ids
  184. })
  185. },
  186. toPayDetail(e){
  187. wx.navigateTo({
  188. url: '/pages/pay/detail?id='+e.currentTarget.dataset.id+'&&ids='+e.currentTarget.dataset.ids,
  189. })
  190. },
  191. scrap(e){
  192. console.log(e.currentTarget.dataset.data.id,e.currentTarget.dataset.data.index);
  193. if(e.currentTarget.dataset.data.assetStatus != 1){
  194. UTIL.showToastNoneIcon('只允许修改资产状态为正常的资产!');
  195. return false;
  196. }else if(e.currentTarget.dataset.data.useType == 3){
  197. UTIL.showToastNoneIcon('使用状态为出租或出借不允许操作!');
  198. return false;
  199. }else{
  200. UTIL.httpRequest(API.URL_GET_UPDATERSCRAP + e.currentTarget.dataset.data.id , {method:'GET'}, {
  201. success: (res) => {
  202. if(res.code==200){
  203. let new_list = this.data.list
  204. new_list.splice(e.currentTarget.dataset.data.index,1)
  205. this.setData({'list':new_list})
  206. UTIL.showToastNoneIcon('报废成功!');
  207. }else{
  208. UTIL.showToastNoneIcon('报废失败!:'+res.msg);
  209. }
  210. }
  211. })
  212. }
  213. },
  214. sell(e){
  215. console.log(e.currentTarget.dataset.data.id,e.currentTarget.dataset.data.index);
  216. if(e.currentTarget.dataset.data.assetStatus != 1){
  217. UTIL.showToastNoneIcon('只允许修改资产状态为正常的资产!');
  218. return false;
  219. }else if(e.currentTarget.dataset.data.useType == 3){
  220. UTIL.showToastNoneIcon('使用状态为出租或出借不允许操作!');
  221. return false;
  222. }else{
  223. UTIL.httpRequest(API.URL_GET_UPDATERSALE + e.currentTarget.dataset.data.id , {method:'GET'}, {
  224. success: (res) => {
  225. if(res.code==200){
  226. let new_list = this.data.list
  227. new_list.splice(e.currentTarget.dataset.data.index,1)
  228. this.setData({'list':new_list})
  229. UTIL.showToastNoneIcon('出售成功!');
  230. }else{
  231. UTIL.showToastNoneIcon('出售失败!:'+res.msg);
  232. }
  233. }
  234. })
  235. }
  236. },
  237. change(e){
  238. var that = this ;
  239. that.setData({value:e.detail,pageNum:1})
  240. this.getList()
  241. },
  242. changeTab(e){
  243. var that = this ;
  244. that.setData({value1:e.detail,pageNums:1})
  245. this.getList()
  246. },
  247. changeTab2(e){
  248. var that = this ;
  249. that.setData({value2:e.detail,pageNums:1})
  250. this.getList()
  251. },
  252. changeTab3(e){
  253. var that = this ;
  254. that.setData({value3:e.detail,pageNums:1})
  255. this.getList()
  256. },
  257. upload(e){
  258. this.setData({itemId:e.currentTarget.dataset.id});
  259. this.asyncFun(e.currentTarget.dataset.id)
  260. },
  261. asyncFun(id){
  262. this.setData({"fileList":[]})
  263. let uploadList = this.data.uploadOptions
  264. let _this = this
  265. uploadList.map( (res,idx) => {
  266. res.list=[]
  267. console.log(res);
  268. let oData = {
  269. tableId: id,
  270. tableName: "t_yinnong_transfer", //上传表
  271. bizPath: "transfer",
  272. fileType: res.dictValue, //附件类型 1原始发票 2会议纪要 3会议照片 4 参会人员签字
  273. method:'GET'
  274. }
  275. UTIL.httpRequest(API.URL_GET_ATTACHMENTLIST, oData, {
  276. success: (rr) => {
  277. if(rr.rows.length>0){
  278. rr.rows.map((rrr,index) => {
  279. rrr.url = wx.getStorageSync('dressCode') + rrr.fileUrl
  280. rrr.name = rrr.fileName
  281. if(index==rr.rows.length-1){
  282. res.list = rr.rows
  283. let lis = uploadList
  284. lis[idx] = res
  285. _this.setData({"fileList":lis});
  286. _this.setData({"showUpload":true})
  287. }
  288. })
  289. }
  290. else{
  291. _this.setData({"showUpload":true})
  292. }
  293. }
  294. })
  295. })
  296. },
  297. closeBox(){
  298. this.setData({"showUpload":false})
  299. },
  300. uploadFile(uploadFile,event) {
  301. let _this = this
  302. return new Promise((resolve, reject) => {
  303. wx.uploadFile({
  304. url: API.URL_GET_UPLOAD,
  305. filePath: uploadFile.file.file.url,
  306. name: 'file',
  307. header: {
  308. "Content-Type": "multipart/form-data",//记得设置
  309. "chartset":"utf-8",
  310. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  311. },
  312. formData:uploadFile,
  313. success: (res) => {
  314. res.data = JSON.parse(res.data);
  315. if(res.statusCode == 200){
  316. let files = _this.data.fileList
  317. let fName = res.data.fileUrl.split('/')
  318. let fLength = fName.length
  319. files[event.currentTarget.dataset.idx].list.push({
  320. "fileName": fName[fLength-1],
  321. "name":fName[fLength-1],
  322. "fileType": "0",
  323. "fileUrl":res.data.fileUrl ,
  324. "id": res.data.id,
  325. "tableId": 6,
  326. "url":wx.getStorageSync('dressCode')+res.data.fileUrl
  327. })
  328. _this.setData({"fileList":files})
  329. wx.hideLoading()
  330. }
  331. },
  332. fail: (err) => {
  333. //上传失败:修改pedding为reject
  334. reject(err)
  335. }
  336. });
  337. })
  338. },
  339. afterRead(event) {
  340. let _this = this
  341. wx.showLoading({
  342. title: '上传中...'
  343. })
  344. let fileForm={
  345. file: event.detail,
  346. fileType:event.currentTarget.dataset.idx,
  347. tableName: "t_yinnong_transfer", //上传表
  348. bizPath: "transfer",
  349. tableId:_this.data.itemId
  350. }
  351. this.uploadFile(fileForm,event)
  352. },
  353. lookDown(e){
  354. let file =e
  355. // 获取指定字符串最后一次出现的位置,返回index
  356. var index1 = file.detail.url.lastIndexOf('.');
  357. // substr(start, length) 抽取从start下标开始的length个字符,返回新的字符串;
  358. var style = file.detail.url.substr(index1 + 1)
  359. //判断图片类型,不需要下载,不做处理
  360. if(style=='png'||style=='jpg'||style=='jpeg'||style=='bmp'||style=='gif'||style=='webp'||style=='psd'||style== 'svg'||style=='tiff'){
  361. //判断非图片类型
  362. }else{
  363. wx.downloadFile({
  364. url: file.detail.url,
  365. success(data){
  366. wx.openDocument({
  367. filePath: data.tempFilePath,
  368. fileType: style,
  369. showMenu:true,
  370. success(res){
  371. }
  372. })
  373. }
  374. })
  375. }
  376. },
  377. /**
  378. * 生命周期函数--监听页面显示
  379. */
  380. onShow() {
  381. this.setData({'pageNums':1})
  382. this.getList();
  383. },
  384. /**
  385. * 生命周期函数--监听页面隐藏
  386. */
  387. onHide() {
  388. },
  389. /**
  390. * 生命周期函数--监听页面卸载
  391. */
  392. onUnload() {
  393. },
  394. /**
  395. * 页面相关事件处理函数--监听用户下拉动作
  396. */
  397. onPullDownRefresh() {
  398. },
  399. /**
  400. * 页面上拉触底事件的处理函数
  401. */
  402. onReachBottom() {
  403. },
  404. /**
  405. * 用户点击右上角分享
  406. */
  407. onShareAppMessage() {
  408. }
  409. })