微信小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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