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

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