微信小程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

352 rader
7.7 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. ],
  15. option2: [
  16. { text: '业务类型', value: '' },
  17. { text: '结算类', value: '1' },
  18. { text: '工程项目类', value: '2' },
  19. { text: '合同类', value: '4' },
  20. { text: '其他', value: '5' },
  21. ],
  22. option3: [
  23. { text: '票据状态', value: '' },
  24. { text: '银行卡转账', value: '1' },
  25. { text: '信用卡还款', value: '2' },
  26. ],
  27. value1: '',
  28. value2: '',
  29. value3: '',
  30. showPopup:false,
  31. result:[],
  32. showReceiptDialog:false,
  33. beforeClose(action) {
  34. return new Promise((resolve) => {
  35. setTimeout(() => {
  36. if (action === 'confirm') {
  37. // 拦截确认操作
  38. resolve(false);
  39. } else {
  40. resolve(true);
  41. }
  42. }, 0);
  43. });
  44. },
  45. deptOptions:[],
  46. deptName:'',
  47. deptId:''
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad(options) {
  53. var that = this ;
  54. console.log(new Date().getFullYear());
  55. //下发单位查询
  56. UTIL.httpRequest(API.URL_GET_GETDEPTLIST, {method:'GET'}, {
  57. success: (res2) => {
  58. console.log(res2);
  59. that.setData({
  60. deptOptions:res2.data,
  61. })
  62. }
  63. })
  64. var form = {
  65. pageNum:'1',
  66. pageSize:'999',
  67. year:'',
  68. billType:'',
  69. orderByColumn:'id',
  70. isAsc:'desc',
  71. method:'GET'
  72. }
  73. // 票据状态字典查询
  74. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bill_type', {method:'GET'}, {
  75. success: (res) => {
  76. let option3 = [{
  77. text: '票据状态', value: ''
  78. }];
  79. res.data.map(rr=>{
  80. if (rr.dictValue == 2 ||rr.dictValue == 3 ||rr.dictValue == 5) {
  81. option3.push({
  82. text: rr.dictLabel, value: rr.dictValue
  83. })
  84. }
  85. })
  86. that.setData({
  87. option3:option3,
  88. billTypeOptions:res.data,
  89. })
  90. UTIL.httpRequest(API.URL_GET_GETBILLLIST , form, {
  91. success: (res2) => {
  92. res2.rows.map(rrr=>{
  93. rrr.billTypeText = UTIL.getTransform(rrr.billType,res.data);
  94. })
  95. that.setData({
  96. billList:res2.rows
  97. })
  98. }
  99. })
  100. }
  101. })
  102. console.log(form);
  103. },
  104. bindSelectTypePickerChange: function(e) {
  105. var that = this;
  106. var dictValue = that.data.deptOptions[e.detail.value].deptId;
  107. var text = that.data.deptOptions[e.detail.value].deptName;
  108. this.setData({
  109. deptId:dictValue,
  110. deptName:text
  111. })
  112. },
  113. back:function(){
  114. wx.navigateBack({
  115. delta: 1
  116. })
  117. },
  118. showPopup(){
  119. var that = this;
  120. that.setData({
  121. showPopup:true
  122. })
  123. },
  124. onClose() {
  125. this.setData({ showPopup: false });
  126. },
  127. onChange(event) {
  128. console.log(event.detail);
  129. this.setData({
  130. result: event.detail,
  131. });
  132. },
  133. showReceiptDialog(e){
  134. var that = this;
  135. that.setData({
  136. showReceiptDialog:true,
  137. projectId:e.currentTarget.dataset.id,
  138. deptId:'',
  139. deptName:''
  140. })
  141. },
  142. goQS(e){
  143. var that = this ;
  144. wx.showModal({
  145. title: '提示',
  146. content: '确认签收?',
  147. success (res) {
  148. if (res.confirm) {
  149. UTIL.httpRequest(API.URL_GET_GETBILLLISTGET+e.currentTarget.dataset.id , {method:'GET'}, {
  150. success: (res) => {
  151. if (res.code == API.SUCCESS_CODE) {
  152. wx.showToast({
  153. title: '签收成功',
  154. icon: 'success',
  155. duration: 2000,
  156. })
  157. that.onLoad();
  158. }else{
  159. wx.showToast({
  160. title: '签收失败',
  161. icon: 'error',
  162. duration: 2000,
  163. })
  164. }
  165. }
  166. })
  167. } else if (res.cancel) {
  168. console.log('用户点击取消')
  169. }
  170. }
  171. })
  172. },
  173. goZF(e){
  174. var that = this ;
  175. wx.showModal({
  176. title: '提示',
  177. content: '确认作废',
  178. success (res) {
  179. if (res.confirm) {
  180. UTIL.httpRequest(API.URL_GET_GETBILLLISTCANCEL+e.currentTarget.dataset.id , {method:'GET'}, {
  181. success: (res) => {
  182. if (res.code == API.SUCCESS_CODE) {
  183. wx.showToast({
  184. title: '作废成功',
  185. icon: 'success',
  186. duration: 2000,
  187. })
  188. that.onLoad();
  189. }else{
  190. wx.showToast({
  191. title: '作废失败',
  192. icon: 'error',
  193. duration: 2000,
  194. })
  195. }
  196. }
  197. })
  198. } else if (res.cancel) {
  199. console.log('用户点击取消')
  200. }
  201. }
  202. })
  203. },
  204. goXF(e){
  205. var that = this ;
  206. if (that.data.deptId == '') {
  207. UTIL.showToastNoneIcon('请选择下发单位!');
  208. return;
  209. }
  210. UTIL.httpRequest(API.URL_GET_GETBILLLISTEDIT+that.data.projectId+'/'+that.data.deptId , {method:'GET'}, {
  211. success: (res) => {
  212. if (res.code == API.SUCCESS_CODE) {
  213. wx.showToast({
  214. title: '下发成功',
  215. icon: 'success',
  216. duration: 2000,
  217. })
  218. that.setData({
  219. showReceiptDialog:false
  220. })
  221. that.onLoad();
  222. }else{
  223. wx.showToast({
  224. title: '下发失败',
  225. icon: 'error',
  226. duration: 2000,
  227. })
  228. }
  229. }
  230. })
  231. },
  232. changeTab1(event){
  233. this.setData({
  234. value1: event.detail
  235. });
  236. var that = this ;
  237. var form = {
  238. pageNum:'1',
  239. pageSize:'999',
  240. year:that.data.value1,
  241. billType:that.data.value3,
  242. orderByColumn:'id',
  243. isAsc:'desc',
  244. method:'GET'
  245. }
  246. console.log(form);
  247. UTIL.httpRequest(API.URL_GET_GETBILLLIST , form, {
  248. success: (res) => {
  249. res.rows.map(rrr=>{
  250. rrr.billTypeText = UTIL.getTransform(rrr.billType,that.data.billTypeOptions);
  251. })
  252. that.setData({
  253. billList:res.rows
  254. })
  255. }
  256. })
  257. },
  258. changeTab3(event){
  259. this.setData({
  260. value3: event.detail
  261. });
  262. var that = this ;
  263. var form = {
  264. pageNum:'1',
  265. pageSize:'999',
  266. year:that.data.value1,
  267. billType:that.data.value3,
  268. orderByColumn:'id',
  269. isAsc:'desc',
  270. method:'GET'
  271. }
  272. console.log(form);
  273. UTIL.httpRequest(API.URL_GET_GETBILLLIST , form, {
  274. success: (res) => {
  275. res.rows.map(rrr=>{
  276. rrr.billTypeText = UTIL.getTransform(rrr.billType,that.data.billTypeOptions);
  277. })
  278. that.setData({
  279. billList:res.rows
  280. })
  281. }
  282. })
  283. },
  284. /**
  285. * 生命周期函数--监听页面初次渲染完成
  286. */
  287. onReady() {
  288. },
  289. /**
  290. * 生命周期函数--监听页面显示
  291. */
  292. onShow() {
  293. var that = this ;
  294. let year = new Date().getFullYear()
  295. let years = that.data.option1;
  296. for (let i = 0; i < 10; i++) {
  297. years.push({
  298. text: year-i,
  299. value: year-i
  300. })
  301. }
  302. that.setData({
  303. option1:years,
  304. })
  305. },
  306. /**
  307. * 生命周期函数--监听页面隐藏
  308. */
  309. onHide() {
  310. },
  311. /**
  312. * 生命周期函数--监听页面卸载
  313. */
  314. onUnload() {
  315. },
  316. /**
  317. * 页面相关事件处理函数--监听用户下拉动作
  318. */
  319. onPullDownRefresh() {
  320. },
  321. /**
  322. * 页面上拉触底事件的处理函数
  323. */
  324. onReachBottom() {
  325. },
  326. /**
  327. * 用户点击右上角分享
  328. */
  329. onShareAppMessage() {
  330. }
  331. })