微信小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

update.js 15 KiB

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