微信小程序
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.

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