微信小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. // pages/apply/paymentTemplate/paymentTemplate.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. show: false,
  17. countMoney:0,
  18. form:{},
  19. SJimage: [],
  20. FPimage: [],
  21. QTimage: [],
  22. fileForm:[],
  23. activeNames: ['1'],
  24. },
  25. showPopup() {
  26. this.setData({ show: true });
  27. },
  28. bindNameInput(even){
  29. this.setData({
  30. ["form.approvalItemTemplate.templateName"]:even.detail.value
  31. })
  32. },
  33. goSubmit(e){
  34. var that = this;
  35. if(e.currentTarget.dataset.type == 1){
  36. if(that.data.form.approvalItemTemplate.templateName == ''){
  37. UTIL.showToastNoneIcon('请输入模板名称!');
  38. return;
  39. }
  40. }
  41. if(e.currentTarget.dataset.type == 3){
  42. for (let i = 0; i < that.data.form.transfers.length; i++) {
  43. that.data.form.transfers[i].approvalMode = '2';
  44. }
  45. that.data.form.approvalItemTemplate.dataType = e.currentTarget.dataset.type
  46. }
  47. that.data.form.method = 'POST';
  48. that.data.form.approvalItemTemplate.dataType = e.currentTarget.dataset.type;
  49. that.data.form.approvalItemTemplate.id = null;
  50. for (let i = 0; i < that.data.form.transfers.length; i++) {
  51. that.data.form.transfers[i].id = null;
  52. }
  53. console.log(that.data.form);
  54. UTIL.httpRequest(API.URL_GET_SAVE, that.data.form, {
  55. success: (res) => {
  56. if (res.code == API.SUCCESS_CODE) {
  57. console.log(that.data.form);
  58. for (let j = 0; j < res.data.transfers.length; j++) {
  59. if(that.data.form.transfers[j].fileForm == undefined){continue;}
  60. for (let i = 0; i < that.data.form.transfers[j].fileForm.length; i++) {
  61. that.data.form.transfers[j].fileForm[i].tableId = res.data.transfers[j].id
  62. const element = that.data.form.transfers[j].fileForm[i];
  63. wx.uploadFile({
  64. url: API.URL_GET_UPLOAD,
  65. filePath: element.file,
  66. name: 'file',
  67. header: {
  68. "Content-Type": "multipart/form-data",//记得设置
  69. "chartset":"utf-8",
  70. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  71. },
  72. formData:element,
  73. success (response){
  74. console.log(res);
  75. },
  76. fail(res){
  77. console.log(res)
  78. }
  79. })
  80. }
  81. }
  82. if(e.currentTarget.dataset.type == 0){
  83. wx.navigateTo({
  84. url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId,
  85. })
  86. }
  87. if(e.currentTarget.dataset.type == 3){
  88. UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
  89. success: (res2) => {
  90. if (res2.code == API.SUCCESS_CODE) {
  91. wx.showToast({
  92. title: '操作成功',
  93. icon: 'success',
  94. duration: 2000,
  95. complete(){
  96. setTimeout(function(){
  97. that.back();
  98. },2000)
  99. }
  100. })
  101. }else{
  102. wx.showToast({
  103. title: '操作失败',
  104. icon: 'success',
  105. duration: 2000
  106. })
  107. }
  108. }
  109. })
  110. }
  111. }
  112. }
  113. })
  114. },
  115. onClose() {
  116. this.setData({ show: false });
  117. },
  118. goApproval(){
  119. wx.navigateTo({
  120. url: '../approval/approval',
  121. })
  122. },
  123. goSee(){
  124. let array = JSON.stringify(this.data.form)
  125. wx.navigateTo({
  126. url: 'see/see?array='+array+"&index="+e.currentTarget.dataset.index,
  127. })
  128. },
  129. goUpdate(e){
  130. let array = JSON.stringify(this.data.form)
  131. wx.navigateTo({
  132. url: 'add/add?type=update&array='+array+'&add='+e.currentTarget.dataset.add,
  133. })
  134. },
  135. /**
  136. * 生命周期函数--监听页面加载
  137. */
  138. onLoad(options) {
  139. var that = this ;
  140. UTIL.httpRequest(API.URL_GET_APPROVALITEMS + options.id, {method:'GET'}, {
  141. success: (res) => {
  142. let transList = res.data.transfers;
  143. let countMoney = that.data.countMoney
  144. transList.forEach((item,index) => {
  145. item.num = UTIL.convertToChinaNum(index+1)
  146. countMoney += parseInt(item.expenditureAmount);
  147. //收据附件
  148. UTIL.httpRequest(
  149. API.URL_GET_FINDLIST,
  150. {
  151. method:'GET',
  152. tableName:'t_yinnong_transfer',
  153. tableId:item.id,
  154. fileType:1
  155. },
  156. {
  157. success: (res) => {
  158. let list = [];
  159. res.data.forEach((item2,index2)=>{
  160. wx.downloadFile({
  161. url: URL_PREFIX+item2.fileUrl, //仅为示例,并非真实的资源
  162. success (response) {
  163. if (response.statusCode === 200) {
  164. let fileForm = item.fileForm?item.fileForm:[];
  165. fileForm.push({
  166. file: response.tempFilePath,
  167. fileType:'1',
  168. bizPath:'transfer',
  169. tableName:'t_yinnong_transfer',
  170. tableId:''
  171. })
  172. console.log("--------------fileForm2 start----------------");
  173. console.log(fileForm);
  174. console.log("--------------fileForm2 end----------------");
  175. list.push({
  176. tempFilePath:response.tempFilePath
  177. })
  178. that.setData({
  179. ["form.transfers["+index+"].SJimage"]:list,
  180. ["form.transfers["+index+"].fileForm"]:fileForm
  181. });
  182. }
  183. }
  184. })
  185. })
  186. }
  187. })
  188. //发票
  189. UTIL.httpRequest(
  190. API.URL_GET_FINDLIST,
  191. {
  192. method:'GET',
  193. tableName:'t_yinnong_transfer',
  194. tableId:item.id,
  195. fileType:2
  196. },
  197. {
  198. success: (res) => {
  199. let list = [];
  200. res.data.forEach((item2,index2)=>{
  201. wx.downloadFile({
  202. url: URL_PREFIX+item2.fileUrl, //仅为示例,并非真实的资源
  203. success (response) {
  204. if (response.statusCode === 200) {
  205. let fileForm = item.fileForm?item.fileForm:[];
  206. fileForm.push({
  207. file: response.tempFilePath,
  208. fileType:'2',
  209. bizPath:'transfer',
  210. tableName:'t_yinnong_transfer',
  211. tableId:item.id
  212. })
  213. list.push({
  214. tempFilePath:response.tempFilePath
  215. })
  216. that.setData({
  217. ["form.transfers["+index+"].FPimage"]:list,
  218. ["form.transfers["+index+"].fileForm"]:fileForm
  219. });
  220. }
  221. }
  222. })
  223. })
  224. }
  225. })
  226. //其他
  227. UTIL.httpRequest(
  228. API.URL_GET_FINDLIST,
  229. {
  230. method:'GET',
  231. tableName:'t_yinnong_transfer',
  232. tableId:item.id,
  233. fileType:3
  234. },
  235. {
  236. success: (res) => {
  237. let list = [];
  238. let fileForm = item.fileForm?item.fileForm:[];
  239. res.data.forEach((item2,index2)=>{
  240. wx.downloadFile({
  241. url: URL_PREFIX+item2.fileUrl, //仅为示例,并非真实的资源
  242. success (response) {
  243. if (response.statusCode === 200) {
  244. let fileForm = item.fileForm?item.fileForm:[];
  245. fileForm.push({
  246. file: response.tempFilePath,
  247. fileType:'3',
  248. bizPath:'transfer',
  249. tableName:'t_yinnong_transfer',
  250. tableId:item.id
  251. })
  252. list.push({
  253. tempFilePath:response.tempFilePath
  254. })
  255. that.setData({
  256. ["form.transfers["+index+"].QTimage"]:list,
  257. ["form.transfers["+index+"].fileForm"]:fileForm
  258. });
  259. }
  260. }
  261. })
  262. })
  263. }
  264. })
  265. });
  266. res.data.transfers = transList
  267. that.setData({
  268. form:res.data,
  269. countMoney:countMoney
  270. });
  271. }
  272. })
  273. },
  274. /**
  275. * 生命周期函数--监听页面初次渲染完成
  276. */
  277. onReady() {
  278. },
  279. goDelete(e){
  280. var that = this;
  281. if(that.data.form.transfers.length<2){
  282. UTIL.showToastNoneIcon('最少保留一条事项');
  283. return;
  284. }
  285. let countMoney = that.data.countMoney;
  286. console.log(that.data.form);
  287. countMoney -= parseInt(that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount);
  288. that.data.form.transfers.splice(e.currentTarget.dataset.index, 1);
  289. that.setData({
  290. form : that.data.form,
  291. countMoney:countMoney
  292. })
  293. UTIL.showToastNoneIcon('删除成功!');
  294. },
  295. back:function(){
  296. wx.navigateBack({
  297. delta: 1
  298. })
  299. },
  300. onChange(event) {
  301. this.setData({
  302. activeNames: event.detail,
  303. });
  304. },
  305. /**
  306. * 生命周期函数--监听页面显示
  307. */
  308. onShow() {
  309. },
  310. /**
  311. * 生命周期函数--监听页面隐藏
  312. */
  313. onHide() {
  314. },
  315. /**
  316. * 生命周期函数--监听页面卸载
  317. */
  318. onUnload() {
  319. },
  320. /**
  321. * 页面相关事件处理函数--监听用户下拉动作
  322. */
  323. onPullDownRefresh() {
  324. },
  325. /**
  326. * 页面上拉触底事件的处理函数
  327. */
  328. onReachBottom() {
  329. },
  330. /**
  331. * 用户点击右上角分享
  332. */
  333. onShareAppMessage() {
  334. }
  335. })