微信小程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

3 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. // pages/apply/index.js
  2. import * as UTIL from '../../../utils/util.js';
  3. import * as API from '../../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. bookName:'', //付款单位
  12. formData:{
  13. accountType:'', //账户类型
  14. accountDate:'', //收入时间
  15. jieAmount:'', //收入金额
  16. accountName:'', //存入账户
  17. incomeType:'', //收入类型
  18. billNum:'', //单据编码
  19. accountSummary:'', //备注说明
  20. contractionId:'', //合同编码
  21. incomeExpensesType:1, //收支类别
  22. isBill:0
  23. },
  24. incomeTypeOptions:[], //收入类型选项
  25. incomeTypeText:'222', //收入类型显示文字
  26. contractionOptions:[], //付款人合同信息列表接口
  27. showHt:false,
  28. payerText:'', //付款人
  29. sjPics:[], //收据图片列表数据
  30. fpPics:[], //发票图片列表数据
  31. qtPics:[], //其他图片列表数据
  32. //收入时间弹窗显隐
  33. srShow:false,
  34. minDate: new Date(2021, 6, 1).getTime(),
  35. maxDate: new Date(2023, 0, 31).getTime(),
  36. crzhShow:false,
  37. accountListOptions:[], //存入账户类型选项
  38. crlxShow:false, //收入类型弹窗显隐
  39. },
  40. onCancelcrlx(){
  41. this.setData({crlxShow:false,})
  42. },
  43. oncrlxShow(){ this.setData({crlxShow:true})},
  44. onCancelcrzh(){
  45. this.setData({crzhShow:false})
  46. },
  47. oncrzhShow(){ this.setData({crzhShow:true})},
  48. onConfirmcrzh(e){
  49. let data = e.detail.value;
  50. this.setData({
  51. crzhShow:false,
  52. 'formData.accountName':data.accountName,
  53. 'formData.accountId':data.id,
  54. 'formData.accountType':data.accountType
  55. })
  56. },
  57. onsrDate(){
  58. this.setData({srShow:true})
  59. },
  60. onClose(){ this.setData({srShow:false})},
  61. onConfirm(e){
  62. let data = this.getNewDate(new Date(e.detail));
  63. this.setData({'formData.accountDate':data})
  64. this.setData({srShow:false})
  65. },
  66. closeBox(){
  67. this.setData({showHt:false})
  68. },
  69. getNewDate(date){
  70. //date是传过来的时间戳,注意需为13位,10位需*1000
  71. //也可以不传,获取的就是当前时间
  72. var time = new Date(date);
  73. var year= time.getFullYear() //年
  74. var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
  75. var day = ("0" + time.getDate()).slice(-2); //日
  76. var mydate = year + "-" + month + "-" + day;
  77. return mydate
  78. },
  79. onConfirmContraction(value){
  80. let obj = value.detail.value;
  81. this.setData({
  82. payerText:obj.name,
  83. showHt:false,
  84. 'formData.contractionId':obj.id,
  85. contractionIdID:obj.code
  86. })
  87. },
  88. selectContraction(){
  89. this.setData({showHt:true})
  90. },
  91. bindPickerChange (e) {
  92. let obj = e.detail.value;
  93. this.setData({
  94. crlxShow:false,
  95. 'formData.expenditureType':obj.dictValue,
  96. expenditureTypeText:obj.dictLabel
  97. })
  98. },
  99. inputChange(e){
  100. this.setData({
  101. [e.currentTarget.dataset.prop]: e.detail.value
  102. })
  103. },
  104. /**
  105. * 生命周期函数--监听页面加载
  106. */
  107. onShow: function () {
  108. },
  109. /**
  110. * 生命周期函数--监听页面初次渲染完成
  111. */
  112. onLoad: function (options) {
  113. console.log(options);
  114. var that = this;
  115. //查询收入详情
  116. UTIL.httpRequest(API.URL_GET_FLOWGET + options.id , {method:'GET'}, {
  117. success: (res) => {
  118. //获取收入类型状态expenditureTypeText
  119. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'capital_expenditure_type', {method:'GET'}, {
  120. success: (res2) => {
  121. if(res2.data.length>0){
  122. that.setData({
  123. expenditureTypeOptions:res2.data,
  124. })
  125. that.setData({
  126. formData:res.data,
  127. contractionIdID:res.data.code,
  128. expenditureTypeText:UTIL.getTransform(res.data.expenditureType,res2.data)
  129. })
  130. }
  131. }
  132. })
  133. console.log(res);
  134. }
  135. })
  136. },
  137. /**
  138. * 生命周期函数--监听页面显示
  139. */
  140. onReady: function () {
  141. let that = this;
  142. //获取收入单位
  143. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  144. success: (res) => {
  145. if (res.code == API.SUCCESS_CODE) {
  146. this.setData({bookName:res.user.bookName})
  147. }
  148. }
  149. })
  150. // 获取合同信息列表
  151. UTIL.httpRequest(API.URL_GET_CONTRACTIONLIST , {method:'GET'}, {
  152. success: (res) => {
  153. that.setData({
  154. contractionOptions:res.rows,
  155. })
  156. }
  157. })
  158. //获取当前账套付款账户列表
  159. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , {method:'GET'}, {
  160. success: (res) => {
  161. that.setData({
  162. accountListOptions:res.rows,
  163. })
  164. }
  165. })
  166. },
  167. deleteimg:function(e){
  168. let oData = e.currentTarget.dataset;
  169. let file = this.data[oData.status];
  170. file.splice(oData.id,1)
  171. this.setData({
  172. [oData.status]:file
  173. })
  174. },
  175. back:function(){
  176. wx.navigateBack({
  177. delta: 1
  178. })
  179. },
  180. uploadSjPics: function (e) { //这里是选取图片的方法
  181. var that = this;
  182. var detailPics = that.data.sjPics;
  183. if (detailPics.length >= that.data.count) {
  184. wx.showToast({
  185. title: '最多选择' + that.data.count + '张!',
  186. })
  187. return;
  188. }
  189. wx.chooseImage({
  190. count: that.data.count, // 最多可以选择的图片张数,默认9
  191. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  192. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  193. success: function (res) {
  194. let fileForm = that.data.sjPics
  195. res.tempFilePaths.forEach(item => {
  196. fileForm.push({
  197. file: item,
  198. fileType:'1',
  199. bizPath:'cashier',
  200. tableName:'t_cashier_account_flow',
  201. tableId:''
  202. })
  203. })
  204. that.setData({
  205. sjPics:fileForm
  206. })
  207. },
  208. })
  209. },
  210. uploadFpPics: function (e) { //这里是选取图片的方法
  211. var that = this;
  212. var pics = [];
  213. var detailPics = that.data.fpPics;
  214. if (detailPics.length >= that.data.count) {
  215. wx.showToast({
  216. title: '最多选择' + that.data.count + '张!',
  217. })
  218. return;
  219. }
  220. wx.chooseImage({
  221. count: that.data.count, // 最多可以选择的图片张数,默认9
  222. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  223. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  224. success: function (res) {
  225. let fileForm = that.data.fpPics
  226. res.tempFilePaths.forEach(item => {
  227. fileForm.push({
  228. file: item,
  229. fileType:'2',
  230. bizPath:'cashier',
  231. tableName:'t_cashier_account_flow',
  232. tableId:''
  233. })
  234. })
  235. that.setData({
  236. fpPics:fileForm
  237. })
  238. },
  239. })
  240. },
  241. uploadQtPics: function (e) { //这里是选取图片的方法
  242. var that = this;
  243. var pics = [];
  244. var detailPics = that.data.qtPics;
  245. if (detailPics.length >= that.data.count) {
  246. wx.showToast({
  247. title: '最多选择' + that.data.count + '张!',
  248. })
  249. return;
  250. }
  251. wx.chooseImage({
  252. count: that.data.count, // 最多可以选择的图片张数,默认9
  253. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  254. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  255. success: function (res) {
  256. let fileForm = that.data.qtPics
  257. res.tempFilePaths.forEach(item => {
  258. fileForm.push({
  259. file: item,
  260. fileType:'3',
  261. bizPath:'cashier',
  262. tableName:'t_cashier_account_flow',
  263. tableId:''
  264. })
  265. })
  266. that.setData({
  267. qtPics:fileForm
  268. })
  269. },
  270. })
  271. },
  272. swichAccounting:function(e){
  273. let codeStr = e.currentTarget.dataset.code;
  274. let formDataObj = this.data.formData;
  275. if(formDataObj.jieAmount==''){ //收入金额
  276. UTIL.showToastNoneIcon('请填写收入金额!');
  277. return false;
  278. }else if(formDataObj.accountName==''){ //存入账户
  279. UTIL.showToastNoneIcon('请选择存入账户!');
  280. return false;
  281. }else if(formDataObj.billNum==''){ //单据编码
  282. UTIL.showToastNoneIcon('请输入单据编码!');
  283. return false;
  284. }else if(formDataObj.accountSummary==''){ //备注说明
  285. UTIL.showToastNoneIcon('请输入备注说明!');
  286. return false;
  287. }
  288. let data = this.data.formData;
  289. data.method = "POST";
  290. data.checkedStatus = codeStr;
  291. console.log(data);
  292. UTIL.httpRequest(API.URL_POST_GERFLOWEDIT,data,{
  293. success: (res) => {
  294. if(res.code == 200){
  295. let vouerId = res.data;
  296. // let vouerId = 1;
  297. let updataList = [...this.data.sjPics,...this.data.fpPics,...this.data.qtPics];
  298. for(let i=0; i<updataList.length; i++){
  299. let arrData=updataList[i];
  300. arrData.tableId = vouerId;
  301. wx.uploadFile({
  302. url: API.URL_GET_UPLOAD,
  303. filePath: arrData.file,
  304. name: 'file',
  305. header: {
  306. "Content-Type": "multipart/form-data",//记得设置
  307. "chartset":"utf-8",
  308. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  309. },
  310. formData:arrData,
  311. success (response){
  312. console.log(response);
  313. },
  314. fail(res){
  315. console.log(response)
  316. }
  317. })
  318. }
  319. wx.redirectTo({
  320. url: '/pages/index/index'
  321. })
  322. }else{
  323. UTIL.showToastNoneIcon(res.msg);
  324. }
  325. }
  326. })
  327. },
  328. onChange(event){
  329. this.setData({
  330. [event.currentTarget.dataset.value]: event.detail,
  331. })
  332. },
  333. imgPreviewImage(e){
  334. let currentImgList = e.currentTarget.dataset;
  335. //获取当前附件列表
  336. let currentStatus = this.data[currentImgList.status];
  337. //当前选中图片index
  338. let currentIndex = currentImgList.id;
  339. let imgList = []
  340. for(let i = 0; i<currentStatus.length; i++){
  341. imgList.push(currentStatus[i].file)
  342. }
  343. wx.previewImage({
  344. current: imgList[currentIndex], // 当前显示图片的http链接
  345. urls: imgList // 需要预览的图片http链接列表
  346. })
  347. },
  348. /**
  349. * 生命周期函数--监听页面隐藏
  350. */
  351. onHide: function () {
  352. },
  353. /**
  354. * 生命周期函数--监听页面卸载
  355. */
  356. onUnload: function () {
  357. },
  358. /**
  359. * 页面相关事件处理函数--监听用户下拉动作
  360. */
  361. onPullDownRefresh: function () {
  362. },
  363. /**
  364. * 页面上拉触底事件的处理函数
  365. */
  366. onReachBottom: function () {
  367. },
  368. /**
  369. * 用户点击右上角分享
  370. */
  371. onShareAppMessage: function () {
  372. }
  373. })