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