微信小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

393 satır
11 KiB

  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.code,
  85. })
  86. },
  87. selectContraction(){
  88. this.setData({showHt:true})
  89. },
  90. bindPickerChange (e) {
  91. let obj = e.detail.value;
  92. this.setData({
  93. crlxShow:false,
  94. 'formData.incomeType':obj.dictValue,
  95. incomeTypeText:obj.dictLabel
  96. })
  97. },
  98. inputChange(e){
  99. this.setData({
  100. [e.currentTarget.dataset.prop]: e.detail.value
  101. })
  102. },
  103. /**
  104. * 生命周期函数--监听页面加载
  105. */
  106. onShow: function (options) {
  107. },
  108. /**
  109. * 生命周期函数--监听页面初次渲染完成
  110. */
  111. onLoad: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面显示
  115. */
  116. onReady: function () {
  117. let that = this;
  118. //获取收入单位
  119. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  120. success: (res) => {
  121. if (res.code == API.SUCCESS_CODE) {
  122. this.setData({bookName:res.user.bookName})
  123. }
  124. }
  125. })
  126. //获取收入类型状态
  127. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'income_type', {method:'GET'}, {
  128. success: (res) => {
  129. if(res.data.length>0){
  130. that.setData({
  131. incomeTypeOptions:res.data,
  132. incomeTypeText:res.data[0].dictLabel,
  133. 'formData.incomeType':res.data[0].dictValue
  134. })
  135. }
  136. }
  137. })
  138. // 获取合同信息列表
  139. UTIL.httpRequest(API.URL_GET_CONTRACTIONLIST , {method:'GET'}, {
  140. success: (res) => {
  141. that.setData({
  142. contractionOptions:res.rows,
  143. })
  144. }
  145. })
  146. //获取当前账套付款账户列表
  147. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , {method:'GET'}, {
  148. success: (res) => {
  149. that.setData({
  150. accountListOptions:res.rows,
  151. })
  152. }
  153. })
  154. },
  155. deleteimg:function(e){
  156. let oData = e.currentTarget.dataset;
  157. let file = this.data[oData.status];
  158. file.splice(oData.id,1)
  159. this.setData({
  160. [oData.status]:file
  161. })
  162. },
  163. back:function(){
  164. wx.navigateBack({
  165. delta: 1
  166. })
  167. },
  168. uploadSjPics: function (e) { //这里是选取图片的方法
  169. var that = this;
  170. var detailPics = that.data.sjPics;
  171. if (detailPics.length >= that.data.count) {
  172. wx.showToast({
  173. title: '最多选择' + that.data.count + '张!',
  174. })
  175. return;
  176. }
  177. wx.chooseImage({
  178. count: that.data.count, // 最多可以选择的图片张数,默认9
  179. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  180. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  181. success: function (res) {
  182. let fileForm = that.data.sjPics
  183. res.tempFilePaths.forEach(item => {
  184. fileForm.push({
  185. file: item,
  186. fileType:'1',
  187. bizPath:'cashier',
  188. tableName:'t_cashier_account_flow',
  189. tableId:''
  190. })
  191. })
  192. that.setData({
  193. sjPics:fileForm
  194. })
  195. },
  196. })
  197. },
  198. uploadFpPics: function (e) { //这里是选取图片的方法
  199. var that = this;
  200. var pics = [];
  201. var detailPics = that.data.fpPics;
  202. if (detailPics.length >= that.data.count) {
  203. wx.showToast({
  204. title: '最多选择' + that.data.count + '张!',
  205. })
  206. return;
  207. }
  208. wx.chooseImage({
  209. count: that.data.count, // 最多可以选择的图片张数,默认9
  210. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  211. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  212. success: function (res) {
  213. let fileForm = that.data.fpPics
  214. res.tempFilePaths.forEach(item => {
  215. fileForm.push({
  216. file: item,
  217. fileType:'2',
  218. bizPath:'cashier',
  219. tableName:'t_cashier_account_flow',
  220. tableId:''
  221. })
  222. })
  223. that.setData({
  224. fpPics:fileForm
  225. })
  226. },
  227. })
  228. },
  229. uploadQtPics: function (e) { //这里是选取图片的方法
  230. var that = this;
  231. var pics = [];
  232. var detailPics = that.data.qtPics;
  233. if (detailPics.length >= that.data.count) {
  234. wx.showToast({
  235. title: '最多选择' + that.data.count + '张!',
  236. })
  237. return;
  238. }
  239. wx.chooseImage({
  240. count: that.data.count, // 最多可以选择的图片张数,默认9
  241. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  242. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  243. success: function (res) {
  244. let fileForm = that.data.qtPics
  245. res.tempFilePaths.forEach(item => {
  246. fileForm.push({
  247. file: item,
  248. fileType:'3',
  249. bizPath:'cashier',
  250. tableName:'t_cashier_account_flow',
  251. tableId:''
  252. })
  253. })
  254. that.setData({
  255. qtPics:fileForm
  256. })
  257. },
  258. })
  259. },
  260. swichAccounting:function(e){
  261. let codeStr = e.currentTarget.dataset.code;
  262. let formDataObj = this.data.formData;
  263. if(formDataObj.jieAmount==''){ //收入金额
  264. UTIL.showToastNoneIcon('请填写收入金额!');
  265. return false;
  266. }else if(formDataObj.accountName==''){ //存入账户
  267. UTIL.showToastNoneIcon('请选择存入账户!');
  268. return false;
  269. }else if(formDataObj.billNum==''){ //单据编码
  270. UTIL.showToastNoneIcon('请输入单据编码!');
  271. return false;
  272. }else if(formDataObj.accountSummary==''){ //备注说明
  273. UTIL.showToastNoneIcon('请输入备注说明!');
  274. return false;
  275. }else if(formDataObj.incomeType == '2' && formDataObj.contractionId==''){
  276. UTIL.showToastNoneIcon('收入类型为发包收入,必须选择关联合同!');
  277. return false;
  278. }
  279. let data = this.data.formData;
  280. data.method = "POST";
  281. data.checkedStatus = codeStr;
  282. UTIL.httpRequest(API.URL_POST_GERFLOWADD,data,{
  283. success: (res) => {
  284. if(res.code == 200){
  285. let vouerId = res.data;
  286. // let vouerId = 1;
  287. let updataList = [...this.data.sjPics,...this.data.fpPics,...this.data.qtPics];
  288. for(let i=0; i<updataList.length; i++){
  289. let arrData=updataList[i];
  290. arrData.tableId = vouerId;
  291. wx.uploadFile({
  292. url: API.URL_GET_UPLOAD,
  293. filePath: arrData.file,
  294. name: 'file',
  295. header: {
  296. "Content-Type": "multipart/form-data",//记得设置
  297. "chartset":"utf-8",
  298. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  299. },
  300. formData:arrData,
  301. success (response){
  302. console.log(response);
  303. },
  304. fail(res){
  305. console.log(response)
  306. }
  307. })
  308. }
  309. wx.redirectTo({
  310. url: '/pages/index/index'
  311. })
  312. }else{
  313. UTIL.showToastNoneIcon(res.msg);
  314. }
  315. }
  316. })
  317. },
  318. onChange(event){
  319. this.setData({
  320. [event.currentTarget.dataset.value]: event.detail,
  321. })
  322. },
  323. imgPreviewImage(e){
  324. let currentImgList = e.currentTarget.dataset;
  325. //获取当前附件列表
  326. let currentStatus = this.data[currentImgList.status];
  327. //当前选中图片index
  328. let currentIndex = currentImgList.id;
  329. let imgList = []
  330. for(let i = 0; i<currentStatus.length; i++){
  331. imgList.push(currentStatus[i].file)
  332. }
  333. wx.previewImage({
  334. current: imgList[currentIndex], // 当前显示图片的http链接
  335. urls: imgList // 需要预览的图片http链接列表
  336. })
  337. },
  338. /**
  339. * 生命周期函数--监听页面隐藏
  340. */
  341. onHide: function () {
  342. },
  343. /**
  344. * 生命周期函数--监听页面卸载
  345. */
  346. onUnload: function () {
  347. },
  348. /**
  349. * 页面相关事件处理函数--监听用户下拉动作
  350. */
  351. onPullDownRefresh: function () {
  352. },
  353. /**
  354. * 页面上拉触底事件的处理函数
  355. */
  356. onReachBottom: function () {
  357. },
  358. /**
  359. * 用户点击右上角分享
  360. */
  361. onShareAppMessage: function () {
  362. }
  363. })