微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

708 lines
22 KiB

  1. import * as UTIL from '../../utils/util.js';
  2. import * as API from '../../utils/API.js';
  3. Page({
  4. data: {
  5. //顶部胶囊按钮位置信息rect
  6. CustomMenuButton: null,
  7. wrokScrollHeight:0,
  8. userInfoObj:{}, //用户信息,
  9. item:"",
  10. address: '', //详细收货地址(四级)
  11. value: [0, 0, 0], // 地址选择器省市区 暂存 currentIndex
  12. region: '', //所在地区
  13. deptId: '',
  14. regionValue: [0, 0, 0], // 地址选择器省市区 最终 currentIndex
  15. provinces: [], // 一级地址
  16. citys: [], // 二级地址
  17. areas: [], // 三级地址
  18. visible: false,
  19. isCanConfirm: true, //是否禁止在第一列滚动期间点击确定提交数据
  20. bookId:"",
  21. bookName:"",
  22. bookList:[],
  23. active:1,
  24. // 待办列表
  25. todoList:[],
  26. // 已办列表
  27. doneList:[],
  28. // 已发起
  29. yfqList:[],
  30. // 已制单
  31. yzdList:[],
  32. //待办数量
  33. todoNum:0,
  34. //已办数量
  35. doneNum:0,
  36. //已发起数量
  37. yfqNum:0,
  38. //已制单数量
  39. yzdNum:0,
  40. //字典
  41. transferType:[
  42. {"dictVale":1,"dictLabel":"村账户转账"},
  43. {"dictVale":2,"dictLabel":"公务卡转账"},
  44. {"dictVale":3,"dictLabel":"虚拟挂账"},
  45. {"dictVale":4,"dictLabel":"代管账户转账"},
  46. {"dictVale":5,"dictLabel":"母子转账"},
  47. {"dictVale":10,"dictLabel":"现金提现"},
  48. {"dictVale":11,"dictLabel":"现金使用"},
  49. {"dictVale":12,"dictLabel":"汇票支出"}
  50. ],
  51. showList:false,
  52. showListText:'更多',
  53. num:1,
  54. active:1
  55. },
  56. onLoad: function (options) {
  57. //获取滚动条高度
  58. this.computeBarLocation();
  59. },
  60. openView(){
  61. var that = this;
  62. let num = that.data.num;
  63. console.log((num%2));
  64. if( (num%2) > 0 ){
  65. num++;
  66. that.setData({
  67. showList:true,
  68. showListText:'收起',
  69. num:num
  70. })
  71. }else{
  72. num++;
  73. that.setData({
  74. showList:false,
  75. showListText:'更多',
  76. num:num
  77. })
  78. }
  79. },
  80. // getUserProfile(e) {
  81. // // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
  82. // // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  83. // wx.getUserProfile({
  84. // desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  85. // success: (res) => {
  86. // this.setData({
  87. // userInfo: res.userInfo,
  88. // hasUserInfo: true
  89. // })
  90. // }
  91. // })
  92. // },
  93. onShow(){
  94. //获取滚动条高度
  95. // this.computeBarLocation();
  96. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'payment_state', {method:'GET'}, {
  97. success: (res) => {
  98. this.setData({
  99. paymentStateOption:res.data
  100. })
  101. }
  102. })
  103. //获取用户信息
  104. this.getUserInfo()
  105. //查询dept
  106. this.getTreeDept();
  107. },
  108. reset:function(){
  109. this.setData({
  110. active:1,
  111. todoList:[],
  112. doneList:[],
  113. yfqList:[],
  114. yzdList:[],
  115. todoNum:0,
  116. doneNum:0,
  117. yfqNum:0,
  118. yzdNum:0
  119. })
  120. },
  121. switchTab:function(e){
  122. this.setData({
  123. active:e.currentTarget.dataset.gid
  124. })
  125. },
  126. dictTranslate(d,value){
  127. let val = ""
  128. for(var index in d){
  129. if(d[index].dictVale==value){
  130. return val = d[index].dictLabel
  131. }
  132. }
  133. },
  134. getTaskList:function(e){
  135. let data = {
  136. pageNum:1,
  137. pageSize:999,
  138. // orderByColumn:"A.ID_",
  139. // isAsc:"desc",
  140. systemType:4,
  141. method:"GET",
  142. deptId:JSON.parse(wx.getStorageSync('user')).deptId,
  143. // taskName:'相关人员审批'
  144. }
  145. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'activity_business_type', {method:'GET'}, {
  146. success: (res) => {
  147. }
  148. })
  149. UTIL.httpRequest(API.A_myTodoList,data, {
  150. success: (res) => {
  151. if (res.code == API.SUCCESS_CODE) {
  152. let list = [];
  153. for(let i = 0;i < res.total;i++){
  154. res.rows[i].createTime = res.rows[i].createTime.substr(0,10)
  155. console.log(res.rows[i].createTime);
  156. list.push(res.rows[i])
  157. }
  158. this.setData({todoList:list,todoNum:res.rows.length})
  159. }
  160. }
  161. })
  162. },
  163. getTaskDoneList:function(e){
  164. let data = {
  165. pageNum:1,
  166. pageSize:999,
  167. // orderByColumn:"A.ID_",
  168. // isAsc:"desc",
  169. systemType:4,
  170. method:"GET",
  171. deptId:JSON.parse(wx.getStorageSync('user')).deptId,
  172. // taskName:'相关人员审批'
  173. }
  174. UTIL.httpRequest(API.A_myDoneList,data, {
  175. success: (res) => {
  176. if (res.code == API.SUCCESS_CODE) {
  177. let list = [];
  178. // for(let i = 0;i<res.total;i++){
  179. // if(res.rows[i].formData){
  180. // if (res.rows[i].formData.activityBusinessType == '16' || res.rows[i].formData.activityBusinessType=='36') {
  181. // let d = this.dictTranslate(this.data.transferType,res.rows[i].formData.transferType)
  182. // res.rows[i].formData.transferType = d
  183. // res.rows[i].formData.expenditureAmount = Number(res.rows[i].formData.expenditureAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  184. // return $1 + ","; }).replace(/\.$/, "")
  185. // list.push(res.rows[i])
  186. // }
  187. // }
  188. // }
  189. for(let i = 0;i < res.total;i++){
  190. res.rows[i].data.expenditureAmount = Number(res.rows[i].data.expenditureAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  191. return $1 + ","; }).replace(/\.$/, "")
  192. res.rows[i].auditTime = res.rows[i].auditTime.substr(0,10)
  193. console.log(res.rows[i].createTime);
  194. list.push(res.rows[i])
  195. }
  196. this.setData({doneList:list,doneNum:list.length})
  197. }
  198. }, fail: (res) => {
  199. console.log(res);
  200. },
  201. complete: (res) => {
  202. }
  203. })
  204. },
  205. getTransferList:function(e){//已废弃
  206. let data = {
  207. // pageNum:1,
  208. // pageSize:10,
  209. transferType:"1",
  210. status:"5",
  211. method:"GET",
  212. applyUserName:this.data.userInfoObj.nickName
  213. }
  214. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  215. success: (res) => {
  216. console.log(res);
  217. if (res.code == API.SUCCESS_CODE) {
  218. let a = res.total
  219. this.setData({yfqNum:a})
  220. for(let i = 0;i<res.total;i++){
  221. res.rows[i].totalAmount = Number(res.rows[i].totalAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  222. return $1 + ","; }).replace(/\.$/, "");
  223. }
  224. this.setData({yfqList:res.rows})
  225. }
  226. }, fail: (res) => {
  227. },
  228. complete: (res) => {
  229. }
  230. })
  231. },
  232. getTransferList1:function(e){
  233. let data = {
  234. // pageNum:1,
  235. // pageSize:10,
  236. transferType:"",
  237. params:{
  238. "auditStatusXiaochengxu":"2"
  239. },
  240. method:"POST",
  241. }
  242. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  243. success: (res) => {
  244. console.log(res);
  245. if (res.code == API.SUCCESS_CODE) {
  246. this.setData({yfqNum:res.total})
  247. let c = res.rows
  248. for(let i = 0;i< c.length;i++){
  249. c[i].totalAmount = Number(c[i].totalAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  250. return $1 + ","; }).replace(/\.$/, "")
  251. c[i].paymentStateText = UTIL.getTransform(res.rows[i].paymentState,this.data.paymentStateOption);
  252. }
  253. this.setData({yfqList:c})
  254. }
  255. }, fail: (res) => {
  256. },
  257. complete: (res) => {
  258. }
  259. })
  260. },
  261. //已制单
  262. getTransferList2:function(e){
  263. let data = {
  264. // pageNum:1,
  265. // pageSize:10,
  266. transferType:"",
  267. method:"POST",
  268. params:{
  269. "auditStatusXiaochengxu":"1"
  270. },
  271. }
  272. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  273. success: (res) => {
  274. if (res.code == API.SUCCESS_CODE) {
  275. this.setData({yzdNum:res.total})
  276. for(let i = 0;i< res.rows.length;i++){
  277. res.rows[i].totalAmount = Number(res.rows[i].totalAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  278. return $1 + ","; }).replace(/\.$/, "")
  279. }
  280. this.setData({yzdList:res.rows})
  281. }
  282. }, fail: (res) => {
  283. },
  284. complete: (res) => {
  285. }
  286. })
  287. },
  288. //跳转收入登记
  289. swichInCome:function(e){
  290. wx.navigateTo({
  291. url: '../inCome/index?',
  292. })
  293. },
  294. //跳转收入登记
  295. swichKeeping:function(e){
  296. wx.navigateTo({
  297. url: '/pages/Bookkeeping/Bookkeeping',
  298. })
  299. },
  300. //跳转支出申请
  301. swichPayment:function(e){
  302. console.log(e.currentTarget.dataset.current);
  303. // let cur = e.currentTarget.dataset.current;
  304. // if (this.data.currentTaB == cur) {
  305. // return false;
  306. // }else{
  307. // wx.navigateTo({
  308. // url: '../inCome/index?id=' + id,
  309. // })
  310. // }
  311. wx.navigateTo({
  312. url: '/pages/apply/index?',
  313. })
  314. },
  315. toList:function(){
  316. wx.navigateTo({
  317. url: '/pages/handle/liist?active='+this.data.active,
  318. })
  319. },
  320. /* 计算bar 高度*/
  321. computeBarLocation() {
  322. console.log('aaaaaaaaaaaaa');
  323. var that = this;
  324. let CustomMenuButton = wx.getMenuButtonBoundingClientRect();
  325. let CustomWidows = wx.getSystemInfoSync();
  326. // 根据文档,先创建一个SelectorQuery对象实例
  327. let query = wx.createSelectorQuery().in(this);
  328. query.select('.top_title').boundingClientRect();
  329. query.select('.information_header').boundingClientRect();
  330. query.select('.navList_main').boundingClientRect();
  331. query.select('.child_function').boundingClientRect();
  332. query.select('.work_plan').boundingClientRect();
  333. query.exec((res) => {
  334. let wrokScrollHeight = CustomWidows.windowHeight;
  335. res.forEach((v)=>{
  336. wrokScrollHeight = wrokScrollHeight - v.height;
  337. console.log(v.height);
  338. })
  339. wrokScrollHeight = wrokScrollHeight-CustomMenuButton.top-CustomMenuButton.bottom -15;
  340. that.setData({
  341. wrokScrollHeight: wrokScrollHeight,
  342. });
  343. })
  344. that.setData({
  345. CustomMenuButton: CustomMenuButton,
  346. });
  347. },
  348. /* 获取用户信息*/
  349. getUserInfo(){
  350. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  351. success: (res) => {
  352. if (res.code == API.SUCCESS_CODE) {
  353. this.setData({userInfoObj:res.user})
  354. this.setData({region:res.user.deptName})
  355. this.setData({item:JSON.stringify(res.user)})
  356. wx.setStorageSync('user', JSON.stringify(res.user))
  357. this.getBookList()
  358. //查询已制单
  359. this.getTransferList2();
  360. //查询已发起
  361. this.getTransferList1();
  362. //查询待办
  363. this.getTaskList();
  364. //查询已办
  365. this.getTaskDoneList();
  366. }
  367. }
  368. })
  369. },
  370. /* 获取区镇村*/
  371. getTreeDept:function(){
  372. UTIL.httpRequest(API.URL_GET_TREESELECTBYUSER, {method:'GET'}, {
  373. success: (res) => {
  374. if (res.code == API.SUCCESS_CODE) {
  375. this.setData({provinces:res.data})
  376. if(res.data[0].children){
  377. this.setData({citys:res.data[0].children})
  378. if(res.data[0].children[this.data.value[1]].children){
  379. this.setData({areas:res.data[0].children[this.data.value[1]].children})
  380. }
  381. }
  382. }
  383. }
  384. })
  385. },
  386. /* 获取账套*/
  387. getBookList:function(){
  388. var that = this ;
  389. let d = {
  390. loginDeptID : this.data.userInfoObj.loginDeptId,
  391. method:'GET'
  392. }
  393. UTIL.httpRequest(API.URL_GET_BOOKLISTBYDEPTID,d, {
  394. success: (res) => {
  395. if (res.code == API.SUCCESS_CODE) {
  396. this.setData({bookList:res.rows})
  397. if(this.data.bookName==""&&res.total>0){
  398. let loginBookId = res.rows.filter(function (e) { return e.id == that.data.userInfoObj.loginBookId; });
  399. if(loginBookId.length > 0){
  400. loginBookId =loginBookId[0].bookName
  401. this.setData({bookName:loginBookId})
  402. this.setData({bookId:res.rows[0].id})
  403. }else{
  404. this.setData({bookName:"选择账套"})
  405. }
  406. }else if(this.data.bookName==""&&res.total==0){
  407. this.setData({bookName:"无可用账套"})
  408. }
  409. }
  410. },fail:(res) => {
  411. },complete:(res) => {
  412. }
  413. })
  414. },
  415. bindPickerChange:function(e){
  416. this.setData({
  417. bookId: this.data.bookList[e.detail.value].id,
  418. bookName:this.data.bookList[e.detail.value].bookName
  419. })
  420. let data={
  421. loginBookId:this.data.bookList[e.detail.value].id,
  422. method:'GET'
  423. }
  424. let _this = this
  425. UTIL.httpRequest(API.URL_GET_CHANGEBOOK,data, {
  426. success: (res) => {
  427. _this.reset();
  428. _this.onShow();
  429. }
  430. })
  431. },
  432. closePopUp() {
  433. this.setData({
  434. visible: false
  435. })
  436. },
  437. pickAddress() {
  438. this.setData({
  439. visible: true,
  440. value: [...this.data.regionValue]
  441. })
  442. },
  443. // 处理省市县联动逻辑 并保存 value
  444. cityChange(e) {
  445. var value = e.detail.value
  446. let {
  447. provinces,
  448. citys
  449. } = this.data
  450. var provinceNum = value[0]
  451. var cityNum = value[1]
  452. var areaNum = value[2]
  453. if (this.data.value[0] !== provinceNum) {
  454. var id = provinces[provinceNum].id
  455. this.setData({
  456. value: [provinceNum, 0, 0],
  457. citys: this.data.provinces[provinceNum].children,
  458. areas: this.data.provinces[provinceNum].children[cityNum].children
  459. })
  460. } else if (this.data.value[1] !== cityNum) {
  461. var id = citys[cityNum].id
  462. this.setData({
  463. value: [provinceNum, cityNum, 0],
  464. areas: this.data.provinces[provinceNum].children[cityNum].children
  465. })
  466. } else {
  467. this.setData({
  468. value: [provinceNum, cityNum, areaNum]
  469. })
  470. }
  471. console.log(this.data.value);
  472. },
  473. preventTouchmove() {},
  474. // 城市选择器
  475. // 点击地区选择取消按钮
  476. cityCancel(e) {
  477. var id = this.data.provinces[0].id
  478. this.setData({
  479. // citys: this.data.lastCitys || this.data.userInfoObj.parentDeptName, //默认北京市辖区,
  480. // areas: this.data.lastAreas || this.data.userInfoObj.deptName,
  481. // value: [...this.data.regionValue],
  482. visible: false
  483. })
  484. },
  485. // 提交时由序号获取省市区id
  486. getRegionId(type) {
  487. console.log(this.data.provinces);
  488. console.log(this.data.regionValue);
  489. let value = this.data.regionValue
  490. if (type === 'provinceId') {
  491. let provinceId = this.data.provinces[value[0]].id
  492. return provinceId
  493. } else if (type === 'townId') {
  494. let townId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  495. return townId
  496. } else {
  497. let areaId = ''
  498. if (this.data.provinces[value[0]].children[value[1]].children) {
  499. areaId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  500. } else if(this.data.provinces[value[0]].children){
  501. areaId = this.data.provinces[value[0]].children[value[1]].id
  502. } else if(this.data.provinces[value[0]]){
  503. areaId = this.data.provinces[value[0]].id
  504. } else {
  505. areaId = 0
  506. }
  507. return areaId
  508. }
  509. },
  510. chooseStart(e) {
  511. this.setData({
  512. isCanConfirm: false
  513. })
  514. },
  515. chooseEnd(e) {
  516. this.setData({
  517. isCanConfirm: true
  518. })
  519. },
  520. // 点击地区选择确定按钮
  521. citySure(e) {
  522. if (this.data.isCanConfirm) {
  523. var value = this.data.value
  524. this.setData({
  525. visible: false
  526. })
  527. // 将选择的城市信息显示到输入框
  528. try {
  529. var region = (this.data.provinces[value[0]].label || '') + (this.data.citys[value[1]].label || '')
  530. if (this.data.areas.length > 0) {
  531. region = this.data.areas[value[2]].label || ''
  532. } else {
  533. this.data.value[2] = 0
  534. }
  535. } catch (error) {
  536. console.log('adress select something error')
  537. }
  538. console.log(this.getRegionId('areas'));
  539. this.setData({
  540. region: region,
  541. lastCitys: this.data.citys,
  542. lastAreas: this.data.areas,
  543. regionValue: value,
  544. deptId:this.getRegionId('areas'),
  545. bookName:"",
  546. bookId:""
  547. }, () => {
  548. let data={
  549. loginDeptID : this.getRegionId('areas'),
  550. method:'GET'
  551. }
  552. let _this = this
  553. UTIL.httpRequest(API.URL_GET_CHANGEDEPT,data, {
  554. success: (res) => {
  555. setTimeout(()=>{
  556. _this.reset()
  557. _this.onShow()
  558. },1000)
  559. }
  560. })
  561. })
  562. // this.data.userInfoObj.loginDeptId = this.getRegionId('areas');
  563. // this.getBookList();
  564. }
  565. },
  566. godetail:function(e){
  567. // wx.navigateTo({
  568. // url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  569. // })
  570. wx.navigateTo({
  571. url: '/pages/apply/paymentTemplate/addNew/addNew?id='+e.currentTarget.dataset.id,
  572. })
  573. },
  574. goMajorDetail:function(e){
  575. wx.navigateTo({
  576. url: 'majorDetail/majorDetail?id='+e.currentTarget.dataset.id+'&taskId='+e.currentTarget.dataset.taskid+'&type='+e.currentTarget.dataset.type,
  577. })
  578. },
  579. gosee:function(e){
  580. wx.navigateTo({
  581. url: '/pages/handle/expenditureAuditNew/expenditureAuditNew?id='+e.currentTarget.dataset.id+'&taskId='+e.currentTarget.dataset.taskid+'&type='+e.currentTarget.dataset.type+'&business='+e.currentTarget.dataset.business,
  582. })
  583. },
  584. goUpdate(e){
  585. wx.navigateTo({
  586. url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  587. })
  588. },
  589. showModal(){
  590. wx.showModal({
  591. title: '提示',
  592. content: '此功能未正式启用!',
  593. showCancel: false,
  594. success (res) {
  595. if (res.confirm) {
  596. console.log('用户点击确定')
  597. } else if (res.cancel) {
  598. console.log('用户点击取消')
  599. }
  600. }
  601. })
  602. },
  603. navigate(even){
  604. wx.navigateTo({
  605. url: even.currentTarget.dataset.url,
  606. })
  607. },
  608. delete(e){
  609. console.log(e);
  610. var that = this;
  611. wx.showModal({
  612. title: '提示',
  613. content: '确认删除?',
  614. success (res) {
  615. if (res.confirm) {
  616. UTIL.httpRequest(API.URL_GET_REMOVETRANFERL + e.currentTarget.dataset.id, {method:'GET'},{
  617. success: (res) => {
  618. if (res.code == API.SUCCESS_CODE) {
  619. that.data.yzdList.splice(e.currentTarget.dataset.index, 1);
  620. wx.showToast({
  621. title: '删除成功!',
  622. icon: 'success',
  623. duration: 2000
  624. })
  625. that.setData({
  626. yzdList : that.data.yzdList,
  627. yzdNum:that.data.yzdNum-1
  628. })
  629. }
  630. }
  631. })
  632. } else if (res.cancel) {
  633. console.log('用户点击取消')
  634. }
  635. }
  636. })
  637. },
  638. goRegion(){
  639. wx.navigateTo({
  640. url: '/pages/user/region/region',
  641. })
  642. },
  643. testBtn(){
  644. wx.requestSubscribeMessage({
  645. tmplIds: ['_Npje859RvKIf5AcqaikWYGXJpOcigMTzyB3HjJ1L9I'],
  646. success (res) { }
  647. })
  648. },
  649. rollback(e){
  650. var that = this;
  651. let prames = {
  652. id : e.currentTarget.dataset.id,
  653. auditStatus : '0',
  654. applyUserId : '',
  655. applyUserName : '',
  656. applyTime : '',
  657. instanceId : '',
  658. processKey : '',
  659. method:'POST'
  660. }
  661. wx.showModal({
  662. title: '提示',
  663. content: '确认撤回?',
  664. success (res) {
  665. if (res.confirm) {
  666. UTIL.httpRequest(API.URL_GET_UPDATETYINNONGTRANSFERFOSTATUS, prames ,{
  667. success: (res) => {
  668. if (res.code == API.SUCCESS_CODE) {
  669. wx.showToast({
  670. title: '撤回成功!',
  671. icon: 'success',
  672. duration: 2000
  673. })
  674. that.setData({
  675. yfqList:[],
  676. yzdList:[]
  677. })
  678. that.getTransferList2()
  679. that.getTransferList1()
  680. }else{
  681. wx.showToast({
  682. title: res.msg,
  683. icon: 'error',
  684. duration: 2000
  685. })
  686. }
  687. }
  688. })
  689. } else if (res.cancel) {
  690. console.log('用户点击取消')
  691. }
  692. }
  693. })
  694. },
  695. })