微信小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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