微信小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

732 líneas
20 KiB

  1. // pages/regular/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. option1: [
  13. { text: '收支类型', value: '' },
  14. { text: '待支付', value: '1' },
  15. { text: '银行受理', value: '3' },
  16. { text: '支付失败', value: '4' },
  17. { text: '部分失败', value: '5' },
  18. ],
  19. option2: [
  20. { text: '结算方式', value: '' },
  21. { text: '结算类', value: '1' },
  22. { text: '工程项目类', value: '2' },
  23. { text: '合同类', value: '4' },
  24. { text: '其他', value: '5' },
  25. ],
  26. option3: [
  27. { text: '票据状态', value: '' },
  28. { text: '银行卡转账', value: '1' },
  29. { text: '信用卡还款', value: '2' },
  30. ],
  31. value1: '',
  32. value2: '',
  33. value3: '',
  34. showPopup:false,
  35. result1:'',
  36. result2:'',
  37. result3:'',
  38. uploadOptions:[],
  39. showReceiptDialog:false,
  40. beforeClose(action) {
  41. return new Promise((resolve) => {
  42. setTimeout(() => {
  43. if (action === 'confirm') {
  44. // 拦截确认操作
  45. resolve(false);
  46. } else {
  47. resolve(true);
  48. }
  49. }, 0);
  50. });
  51. },
  52. billList:[],
  53. billDate:'',
  54. showPopup2:false
  55. },
  56. /**
  57. * 生命周期函数--监听页面加载
  58. */
  59. onLoad(options) {
  60. },
  61. getDict(){
  62. var that = this;
  63. //获取附件字典
  64. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'common_attach', {method:'GET'}, {
  65. success: (res) => {
  66. if(res.data.length>0){
  67. this.setData({
  68. uploadOptions:res.data,
  69. })
  70. }
  71. }
  72. })
  73. // 收支类型字典查询
  74. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'income_expenses_type', {method:'GET'}, {
  75. success: (res) => {
  76. let option1 = [{
  77. text: '收支类型', value: ''
  78. }];
  79. res.data.map(rr=>{
  80. option1.push({
  81. text: rr.dictLabel, value: rr.dictValue
  82. })
  83. })
  84. that.setData({
  85. option1:option1,
  86. expensesTypeOptions:res.data,
  87. })
  88. }
  89. })
  90. // 结算方式字典查询
  91. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'settle_style', {method:'GET'}, {
  92. success: (res) => {
  93. let option2 = [{
  94. text: '结算方式', value: ''
  95. }];
  96. res.data.map(rr=>{
  97. option2.push({
  98. text: rr.dictLabel, value: rr.dictValue
  99. })
  100. })
  101. that.setData({
  102. option2:option2,
  103. settleTypeOptions:res.data,
  104. })
  105. }
  106. })
  107. // 票据状态字典查询
  108. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bill_type', {method:'GET'}, {
  109. success: (res) => {
  110. let option3 = [{
  111. text: '票据状态', value: ''
  112. }];
  113. res.data.map(rr=>{
  114. if (rr.dictValue == 4 ||rr.dictValue == 5 ||rr.dictValue == 6 ||rr.dictValue == 7) {
  115. option3.push({
  116. text: rr.dictLabel, value: rr.dictValue
  117. })
  118. }
  119. })
  120. that.setData({
  121. option3:option3,
  122. billTypeOptions:res.data,
  123. })
  124. }
  125. })
  126. },
  127. back:function(){
  128. wx.navigateBack({
  129. delta: 1
  130. })
  131. },
  132. showPopup(){
  133. var that = this;
  134. that.setData({
  135. showPopup:true
  136. })
  137. },
  138. onClose() {
  139. this.setData({ showPopup: false });
  140. },
  141. onChange(event) {
  142. console.log(event.detail);
  143. this.setData({
  144. result: event.detail,
  145. });
  146. },
  147. showReceiptDialog(){
  148. var that = this;
  149. that.setData({
  150. showReceiptDialog:true
  151. })
  152. },
  153. onChangeSZ(event) {
  154. console.log(event.detail);
  155. this.setData({
  156. result1: event.detail,
  157. });
  158. },
  159. onChangeJS(event) {
  160. console.log(event.detail);
  161. this.setData({
  162. result2: event.detail,
  163. });
  164. },
  165. onChangePJ(event) {
  166. console.log(event.detail);
  167. this.setData({
  168. result3: event.detail,
  169. });
  170. },
  171. bindDateBeginChange: function(e) {
  172. this.setData({
  173. billDate: e.detail.value
  174. })
  175. },
  176. goSubmit(){
  177. var that = this ;
  178. let form = {
  179. pageNum:'1',
  180. pageSize:'999',
  181. billNum:'',//票据编号
  182. billType:that.data.result3,//票据状态
  183. billDate:that.data.billDate,//开盘日期
  184. accountSummary:that.data.result2,//结算事项
  185. incomeExpensesType:that.data.result1,//收支类型
  186. orderByColumn:'billDate',
  187. isAsc:'desc',
  188. settleStyle:'1',
  189. method:'GET',
  190. }
  191. console.log(form);
  192. UTIL.httpRequest(API.URL_GET_GETBILLLISTDETAIL , form, {
  193. success: (res) => {
  194. res.rows.map(rrr=>{
  195. rrr.billTypeText = UTIL.getTransform(rrr.billType,that.data.billTypeOptions);
  196. rrr.incomeExpensesTypeText = UTIL.getTransform(rrr.incomeExpensesType,that.data.expensesTypeOptions);
  197. rrr.daiAmount = rrr.daiAmount == null ? '0.00':parseFloat(rrr.daiAmount).toFixed(2)
  198. rrr.jieAmount = rrr.jieAmount == null ? '0.00':parseFloat(rrr.jieAmount).toFixed(2)
  199. })
  200. that.setData({
  201. value1:that.data.result1,
  202. value2:that.data.result2,
  203. value3:that.data.result3,
  204. billList:res.rows,
  205. showPopup:false
  206. })
  207. }
  208. })
  209. },
  210. reset(){
  211. this.setData({
  212. value1:'',
  213. value2:'',
  214. value3:'',
  215. result1:'',
  216. result2:'',
  217. result3:'',
  218. })
  219. this.onShow();
  220. },
  221. changeTab1(event){
  222. this.setData({
  223. result1: event.detail,
  224. value1: event.detail
  225. });
  226. var that = this ;
  227. let form = {
  228. pageNum:'1',
  229. pageSize:'999',
  230. billNum:'',//票据编号
  231. billType:that.data.result3,//票据状态
  232. billDate:that.data.billDate,//开盘日期
  233. accountSummary:that.data.result2,//结算事项
  234. incomeExpensesType:that.data.result1,//收支类型
  235. orderByColumn:'billDate',
  236. isAsc:'desc',
  237. settleStyle:'1',
  238. method:'GET',
  239. }
  240. console.log(form);
  241. UTIL.httpRequest(API.URL_GET_GETBILLLISTDETAIL , form, {
  242. success: (res) => {
  243. res.rows.map(rrr=>{
  244. rrr.billTypeText = UTIL.getTransform(rrr.billType,that.data.billTypeOptions);
  245. rrr.incomeExpensesTypeText = UTIL.getTransform(rrr.incomeExpensesType,that.data.expensesTypeOptions);
  246. rrr.daiAmount = rrr.daiAmount == null ? '0.00':parseFloat(rrr.daiAmount).toFixed(2)
  247. rrr.jieAmount = rrr.jieAmount == null ? '0.00':parseFloat(rrr.jieAmount).toFixed(2)
  248. })
  249. that.setData({
  250. billList:res.rows,
  251. showPopup:false
  252. })
  253. }
  254. })
  255. },
  256. changeTab2(event){
  257. this.setData({
  258. result2: event.detail,
  259. value2: event.detail
  260. });
  261. var that = this ;
  262. let form = {
  263. pageNum:'1',
  264. pageSize:'999',
  265. billNum:'',//票据编号
  266. billType:that.data.result3,//票据状态
  267. billDate:that.data.billDate,//开盘日期
  268. accountSummary:that.data.result2,//结算事项
  269. incomeExpensesType:that.data.result1,//收支类型
  270. orderByColumn:'billDate',
  271. isAsc:'desc',
  272. settleStyle:'1',
  273. method:'GET',
  274. }
  275. console.log(form);
  276. UTIL.httpRequest(API.URL_GET_GETBILLLISTDETAIL , form, {
  277. success: (res) => {
  278. res.rows.map(rrr=>{
  279. rrr.billTypeText = UTIL.getTransform(rrr.billType,that.data.billTypeOptions);
  280. rrr.incomeExpensesTypeText = UTIL.getTransform(rrr.incomeExpensesType,that.data.expensesTypeOptions);
  281. rrr.daiAmount = rrr.daiAmount == null ? '0.00':parseFloat(rrr.daiAmount).toFixed(2)
  282. rrr.jieAmount = rrr.jieAmount == null ? '0.00':parseFloat(rrr.jieAmount).toFixed(2)
  283. })
  284. that.setData({
  285. billList:res.rows,
  286. showPopup:false
  287. })
  288. }
  289. })
  290. },
  291. changeTab3(event){
  292. this.setData({
  293. result3: event.detail,
  294. value3: event.detail
  295. });
  296. var that = this ;
  297. let form = {
  298. pageNum:'1',
  299. pageSize:'999',
  300. billNum:'',//票据编号
  301. billType:that.data.result3,//票据状态
  302. billDate:that.data.billDate,//开盘日期
  303. accountSummary:that.data.result2,//结算事项
  304. incomeExpensesType:that.data.result1,//收支类型
  305. orderByColumn:'billDate',
  306. isAsc:'desc',
  307. settleStyle:'1',
  308. method:'GET',
  309. }
  310. console.log(form);
  311. UTIL.httpRequest(API.URL_GET_GETBILLLISTDETAIL , form, {
  312. success: (res) => {
  313. res.rows.map(rrr=>{
  314. rrr.billTypeText = UTIL.getTransform(rrr.billType,that.data.billTypeOptions);
  315. rrr.incomeExpensesTypeText = UTIL.getTransform(rrr.incomeExpensesType,that.data.expensesTypeOptions);
  316. rrr.daiAmount = rrr.daiAmount == null ? '0.00':parseFloat(rrr.daiAmount).toFixed(2)
  317. rrr.jieAmount = rrr.jieAmount == null ? '0.00':parseFloat(rrr.jieAmount).toFixed(2)
  318. })
  319. that.setData({
  320. billList:res.rows,
  321. showPopup:false
  322. })
  323. }
  324. })
  325. },
  326. goHX(e){
  327. var that = this ;
  328. var id = e.currentTarget.dataset.id;
  329. wx.showModal({
  330. title: '提示',
  331. content: '确定核销?',
  332. success (res) {
  333. if (res.confirm) {
  334. UTIL.httpRequest(API.URL_GET_GETDETAILOFF+id , {method:'GET'}, {
  335. success: (res) => {
  336. if (res.code == API.SUCCESS_CODE) {
  337. wx.showToast({
  338. title: '核销成功',
  339. icon: 'success',
  340. duration: 2000,
  341. })
  342. that.onShow();
  343. }
  344. }
  345. })
  346. } else if (res.cancel) {
  347. console.log('用户点击取消')
  348. }
  349. }
  350. })
  351. },
  352. goZF(e){
  353. var that = this ;
  354. var id = e.currentTarget.dataset.id;
  355. wx.showModal({
  356. title: '提示',
  357. content: '确定作废?',
  358. success (res) {
  359. if (res.confirm) {
  360. UTIL.httpRequest(API.URL_GET_GETDETAILCANCEL+id , {method:'GET'}, {
  361. success: (res) => {
  362. if (res.code == API.SUCCESS_CODE) {
  363. wx.showToast({
  364. title: '作废成功',
  365. icon: 'success',
  366. duration: 2000,
  367. })
  368. that.onShow();
  369. }
  370. }
  371. })
  372. } else if (res.cancel) {
  373. console.log('用户点击取消')
  374. }
  375. }
  376. })
  377. },
  378. goYS(e){
  379. var that = this ;
  380. var id = e.currentTarget.dataset.id;
  381. wx.showModal({
  382. title: '提示',
  383. content: '确定遗失?',
  384. success (res) {
  385. if (res.confirm) {
  386. UTIL.httpRequest(API.URL_GET_GETDETAILLOSE+id , {method:'GET'}, {
  387. success: (res) => {
  388. if (res.code == API.SUCCESS_CODE) {
  389. wx.showToast({
  390. title: '操作成功',
  391. icon: 'success',
  392. duration: 2000,
  393. })
  394. that.onShow();
  395. }
  396. }
  397. })
  398. } else if (res.cancel) {
  399. console.log('用户点击取消')
  400. }
  401. }
  402. })
  403. },
  404. goSC(e){
  405. var that = this ;
  406. var id = e.currentTarget.dataset.id;
  407. wx.showModal({
  408. title: '提示',
  409. content: '确定删除?',
  410. success (res) {
  411. if (res.confirm) {
  412. UTIL.httpRequest(API.URL_GET_GETDETAILREMOVE+id , {method:'GET'}, {
  413. success: (res) => {
  414. if (res.code == API.SUCCESS_CODE) {
  415. wx.showToast({
  416. title: '删除成功',
  417. icon: 'success',
  418. duration: 2000,
  419. })
  420. that.onShow();
  421. }
  422. }
  423. })
  424. } else if (res.cancel) {
  425. console.log('用户点击取消')
  426. }
  427. }
  428. })
  429. },
  430. goSCLS(e){
  431. var that = this ;
  432. var id = e.currentTarget.dataset.id;
  433. var options = JSON.stringify(e.currentTarget.dataset.options);
  434. wx.navigateTo({
  435. url: 'flowAdd/flowAdd?options='+options,
  436. })
  437. return;
  438. var form = {
  439. accountDate:'',//日期
  440. accountId:'',//账户id
  441. accountName:'',//账户名称
  442. accountSummary:'',//摘要
  443. accountType:'',//账户类型101=现金,102=银行存款
  444. billNum:'',//单据编号
  445. checkedStatus:'',//审核状态:1未提交、2待审核、3已审核、4已挂起
  446. contractionId:'',//关联合同选择发包收入的时候必填
  447. incomeType:'',//收入类型 1经营收入、2发包收入(这个关联合同)、3补助收入、4其他收入、5投资收益
  448. incomeDate:'',//收入时间
  449. incomeExpensesType:'',//收支类别1收入2支出
  450. isBill:'',//是否来源票据0:否  1:是
  451. jieAmount:'',//收入金额
  452. subjectId:'',//对方科目编码
  453. subjectNameAll:'',//对方科目名称
  454. }
  455. UTIL.httpRequest(API.URL_GET_GETFLOWADD, {method:'GET'}, {
  456. success: (res) => {
  457. if (res.code == API.SUCCESS_CODE) {
  458. wx.showToast({
  459. title: '核销成功',
  460. icon: 'success',
  461. duration: 2000,
  462. })
  463. that.onLoad();
  464. }
  465. }
  466. })
  467. },
  468. goAdd(){
  469. wx.navigateTo({
  470. url: 'add/add',
  471. })
  472. },
  473. goEdit(e){
  474. var options = JSON.stringify(e.currentTarget.dataset.options);
  475. wx.navigateTo({
  476. url: 'edit/edit?detail='+options,
  477. })
  478. },
  479. /**
  480. * 生命周期函数--监听页面初次渲染完成
  481. */
  482. onReady() {
  483. },
  484. /**
  485. * 生命周期函数--监听页面显示
  486. */
  487. onShow() {
  488. var that = this;
  489. that.getDict();
  490. var form = {
  491. pageNum:'1',
  492. pageSize:'999',
  493. billNum:'',//票据编号
  494. billType:'',//票据状态
  495. billDate:'',//开盘日期
  496. accountSummary:'',//结算事项
  497. incomeExpensesType:'',//收支类型
  498. orderByColumn:'billDate',
  499. isAsc:'desc',
  500. settleStyle:'1'
  501. }
  502. console.log(form);
  503. UTIL.httpRequest(API.URL_GET_GETBILLLISTDETAIL , form, {
  504. success: (res) => {
  505. res.rows.map(rrr=>{
  506. rrr.billTypeText = UTIL.getTransform(rrr.billType,that.data.billTypeOptions);
  507. rrr.incomeExpensesTypeText = UTIL.getTransform(rrr.incomeExpensesType,that.data.expensesTypeOptions);
  508. rrr.daiAmount = rrr.daiAmount == null ? '0.00':parseFloat(rrr.daiAmount).toFixed(2)
  509. rrr.jieAmount = rrr.jieAmount == null ? '0.00':parseFloat(rrr.jieAmount).toFixed(2)
  510. })
  511. that.setData({
  512. billList:res.rows
  513. })
  514. }
  515. })
  516. // let query = wx.createSelectorQuery().in(this);
  517. // query.selectAll('.cell_right').boundingClientRect(function(rect){
  518. // console.log(rect)
  519. // }).exec();
  520. // console.log(query.selectAll('.cell_right'));
  521. },
  522. goSearch(e){
  523. console.log(e);
  524. var that = this;
  525. let form = {
  526. pageNum:'1',
  527. pageSize:'999',
  528. billNum:e.detail,//票据编号
  529. billType:that.data.result3,//票据状态
  530. billDate:that.data.billDate,//开盘日期
  531. accountSummary:that.data.result2,//结算事项
  532. incomeExpensesType:that.data.result1,//收支类型
  533. orderByColumn:'billDate',
  534. isAsc:'desc',
  535. settleStyle:'1',
  536. method:'GET',
  537. }
  538. UTIL.httpRequest(API.URL_GET_GETBILLLISTDETAIL , form, {
  539. success: (res) => {
  540. res.rows.map(rrr=>{
  541. rrr.billTypeText = UTIL.getTransform(rrr.billType,that.data.billTypeOptions);
  542. rrr.incomeExpensesTypeText = UTIL.getTransform(rrr.incomeExpensesType,that.data.expensesTypeOptions);
  543. rrr.daiAmount = rrr.daiAmount == null ? '0.00':parseFloat(rrr.daiAmount).toFixed(2)
  544. rrr.jieAmount = rrr.jieAmount == null ? '0.00':parseFloat(rrr.jieAmount).toFixed(2)
  545. })
  546. that.setData({
  547. billList:res.rows
  548. })
  549. }
  550. })
  551. },
  552. upload(e){
  553. this.setData({itemId:e.currentTarget.dataset.id});
  554. this.asyncFun(e.currentTarget.dataset.id)
  555. this.setData({"fileList":[]})
  556. },
  557. asyncFun(id){
  558. let uploadList = this.data.uploadOptions
  559. let newList = []
  560. let _this = this
  561. uploadList.map( res => {
  562. let oData = {
  563. tableId: id,
  564. tableName: "t_contraction_info", //上传表
  565. bizPath: "contraction",
  566. fileType: res.dictValue, //附件类型 1原始发票 2会议纪要 3会议照片 4 参会人员签字
  567. method:'GET'
  568. }
  569. UTIL.httpRequest(API.URL_GET_ATTACHMENTLIST, oData, {
  570. success: (rr) => {
  571. if(rr.code==200&&rr.rows.length>0){
  572. rr.rows.map((rrr,index) => {
  573. rrr.url = wx.getStorageSync('dressCode') + rrr.fileUrl
  574. if(index==rr.rows.length-1){
  575. newList.push(Object.assign({},res,{"list":rr.rows}))
  576. _this.setData({"fileList":_this.data.fileList.concat(newList)});
  577. _this.setData({"showUpload":true})
  578. }
  579. })
  580. }else{
  581. let newuploadList = uploadList
  582. newuploadList.map(rd => {
  583. rd.list = newList
  584. })
  585. _this.setData({"fileList":newuploadList});
  586. _this.setData({"showUpload":true})
  587. }
  588. }
  589. })
  590. })
  591. },
  592. afterRead(event) {
  593. let _this = this
  594. wx.showLoading({
  595. title: '上传中...'
  596. })
  597. let fileForm={
  598. file: event.detail,
  599. fileType:event.currentTarget.dataset.idx,
  600. tableName: "t_contraction_info", //上传表
  601. bizPath: "contraction", //上传目录
  602. tableId:_this.data.itemId
  603. }
  604. this.uploadFile(fileForm,event)
  605. },
  606. uploadFile(uploadFile,event) {
  607. let _this = this
  608. return new Promise((resolve, reject) => {
  609. wx.uploadFile({
  610. url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
  611. filePath: uploadFile.file.file.url,
  612. name: 'file',
  613. header: {
  614. "Content-Type": "multipart/form-data",//记得设置
  615. "chartset":"utf-8",
  616. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  617. },
  618. formData:uploadFile,
  619. success: (res) => {
  620. res.data = JSON.parse(res.data);
  621. if(res.statusCode == 200){
  622. let files = _this.data.fileList
  623. let fName = res.data.fileUrl.split('/')
  624. let fLength = fName.length
  625. files[event.currentTarget.dataset.idx].list.push({
  626. "fileName": fName[fLength-1],
  627. "fileType": "0",
  628. "fileUrl":res.data.fileUrl ,
  629. "id": res.data.id,
  630. "tableId": 6,
  631. "url":wx.getStorageSync('dressCode')+res.data.fileUrl
  632. })
  633. _this.setData({"fileList":files})
  634. wx.hideLoading()
  635. }
  636. },
  637. fail: (err) => {
  638. //上传失败:修改pedding为reject
  639. reject(err)
  640. }
  641. });
  642. })
  643. },
  644. deleteImg(event){
  645. this.setData({"fileEvent":event})
  646. this.setData({"showPopup2":true});
  647. },
  648. closeBox(){
  649. this.setData({"showUpload":false})
  650. this.setData({"showRelevance":false})
  651. },
  652. cancelTem:function(e){
  653. this.setData({"fileEvent":"{}"});
  654. this.setData({"showPopup":false});
  655. },
  656. confirmTem:function(e){
  657. let event = this.data.fileEvent
  658. UTIL.httpRequest(API.URL_GET_GETFILEREMOVE+event.detail.file.id , {method:'GET'}, {
  659. success: (res) => {
  660. if(res.code==200){
  661. let ll = this.data.fileList
  662. var jsonlist = ll[event.target.dataset.idx].list;
  663. jsonlist.splice(event.detail.index, 1)
  664. ll[event.target.dataset.idx].list = jsonlist
  665. this.setData({"fileList":ll})
  666. this.setData({showPopup2:false});
  667. wx.showToast({
  668. title: '删除成功!',
  669. icon: 'success',
  670. duration: 2000,
  671. })
  672. }
  673. }
  674. })
  675. },
  676. /**
  677. * 生命周期函数--监听页面隐藏
  678. */
  679. onHide() {
  680. },
  681. /**
  682. * 生命周期函数--监听页面卸载
  683. */
  684. onUnload() {
  685. },
  686. /**
  687. * 页面相关事件处理函数--监听用户下拉动作
  688. */
  689. onPullDownRefresh() {
  690. },
  691. /**
  692. * 页面上拉触底事件的处理函数
  693. */
  694. onReachBottom() {
  695. },
  696. /**
  697. * 用户点击右上角分享
  698. */
  699. onShareAppMessage() {
  700. }
  701. })