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

706 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){this.setData({areas:res.data[0].children[this.data.value[1]].children})}
  379. }
  380. }
  381. }
  382. })
  383. },
  384. /* 获取账套*/
  385. getBookList:function(){
  386. var that = this ;
  387. let d = {
  388. loginDeptID : this.data.userInfoObj.loginDeptId,
  389. method:'GET'
  390. }
  391. UTIL.httpRequest(API.URL_GET_BOOKLISTBYDEPTID,d, {
  392. success: (res) => {
  393. if (res.code == API.SUCCESS_CODE) {
  394. this.setData({bookList:res.rows})
  395. if(this.data.bookName==""&&res.total>0){
  396. let loginBookId = res.rows.filter(function (e) { return e.id == that.data.userInfoObj.loginBookId; });
  397. if(loginBookId.length > 0){
  398. loginBookId =loginBookId[0].bookName
  399. this.setData({bookName:loginBookId})
  400. this.setData({bookId:res.rows[0].id})
  401. }else{
  402. this.setData({bookName:"选择账套"})
  403. }
  404. }else if(this.data.bookName==""&&res.total==0){
  405. this.setData({bookName:"无可用账套"})
  406. }
  407. }
  408. },fail:(res) => {
  409. },complete:(res) => {
  410. }
  411. })
  412. },
  413. bindPickerChange:function(e){
  414. this.setData({
  415. bookId: this.data.bookList[e.detail.value].id,
  416. bookName:this.data.bookList[e.detail.value].bookName
  417. })
  418. let data={
  419. loginBookId:this.data.bookList[e.detail.value].id,
  420. method:'GET'
  421. }
  422. let _this = this
  423. UTIL.httpRequest(API.URL_GET_CHANGEBOOK,data, {
  424. success: (res) => {
  425. _this.reset();
  426. _this.onShow();
  427. }
  428. })
  429. },
  430. closePopUp() {
  431. this.setData({
  432. visible: false
  433. })
  434. },
  435. pickAddress() {
  436. this.setData({
  437. visible: true,
  438. value: [...this.data.regionValue]
  439. })
  440. },
  441. // 处理省市县联动逻辑 并保存 value
  442. cityChange(e) {
  443. var value = e.detail.value
  444. let {
  445. provinces,
  446. citys
  447. } = this.data
  448. var provinceNum = value[0]
  449. var cityNum = value[1]
  450. var areaNum = value[2]
  451. if (this.data.value[0] !== provinceNum) {
  452. var id = provinces[provinceNum].id
  453. this.setData({
  454. value: [provinceNum, 0, 0],
  455. citys: this.data.provinces[provinceNum].children,
  456. areas: this.data.provinces[provinceNum].children[cityNum].children
  457. })
  458. } else if (this.data.value[1] !== cityNum) {
  459. var id = citys[cityNum].id
  460. this.setData({
  461. value: [provinceNum, cityNum, 0],
  462. areas: this.data.provinces[provinceNum].children[cityNum].children
  463. })
  464. } else {
  465. this.setData({
  466. value: [provinceNum, cityNum, areaNum]
  467. })
  468. }
  469. console.log(this.data.value);
  470. },
  471. preventTouchmove() {},
  472. // 城市选择器
  473. // 点击地区选择取消按钮
  474. cityCancel(e) {
  475. var id = this.data.provinces[0].id
  476. this.setData({
  477. // citys: this.data.lastCitys || this.data.userInfoObj.parentDeptName, //默认北京市辖区,
  478. // areas: this.data.lastAreas || this.data.userInfoObj.deptName,
  479. // value: [...this.data.regionValue],
  480. visible: false
  481. })
  482. },
  483. // 提交时由序号获取省市区id
  484. getRegionId(type) {
  485. console.log(this.data.provinces);
  486. console.log(this.data.regionValue);
  487. let value = this.data.regionValue
  488. if (type === 'provinceId') {
  489. let provinceId = this.data.provinces[value[0]].id
  490. return provinceId
  491. } else if (type === 'townId') {
  492. let townId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  493. return townId
  494. } else {
  495. let areaId = ''
  496. if (this.data.provinces[value[0]].children[value[1]].children) {
  497. areaId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  498. } else if(this.data.provinces[value[0]].children){
  499. areaId = this.data.provinces[value[0]].children[value[1]].id
  500. } else if(this.data.provinces[value[0]]){
  501. areaId = this.data.provinces[value[0]].id
  502. } else {
  503. areaId = 0
  504. }
  505. return areaId
  506. }
  507. },
  508. chooseStart(e) {
  509. this.setData({
  510. isCanConfirm: false
  511. })
  512. },
  513. chooseEnd(e) {
  514. this.setData({
  515. isCanConfirm: true
  516. })
  517. },
  518. // 点击地区选择确定按钮
  519. citySure(e) {
  520. if (this.data.isCanConfirm) {
  521. var value = this.data.value
  522. this.setData({
  523. visible: false
  524. })
  525. // 将选择的城市信息显示到输入框
  526. try {
  527. var region = (this.data.provinces[value[0]].label || '') + (this.data.citys[value[1]].label || '')
  528. if (this.data.areas.length > 0) {
  529. region = this.data.areas[value[2]].label || ''
  530. } else {
  531. this.data.value[2] = 0
  532. }
  533. } catch (error) {
  534. console.log('adress select something error')
  535. }
  536. console.log(this.getRegionId('areas'));
  537. this.setData({
  538. region: region,
  539. lastCitys: this.data.citys,
  540. lastAreas: this.data.areas,
  541. regionValue: value,
  542. deptId:this.getRegionId('areas'),
  543. bookName:"",
  544. bookId:""
  545. }, () => {
  546. let data={
  547. loginDeptID : this.getRegionId('areas'),
  548. method:'GET'
  549. }
  550. let _this = this
  551. UTIL.httpRequest(API.URL_GET_CHANGEDEPT,data, {
  552. success: (res) => {
  553. setTimeout(()=>{
  554. _this.reset()
  555. _this.onShow()
  556. },1000)
  557. }
  558. })
  559. })
  560. // this.data.userInfoObj.loginDeptId = this.getRegionId('areas');
  561. // this.getBookList();
  562. }
  563. },
  564. godetail:function(e){
  565. // wx.navigateTo({
  566. // url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  567. // })
  568. wx.navigateTo({
  569. url: '/pages/apply/paymentTemplate/addNew/addNew?id='+e.currentTarget.dataset.id,
  570. })
  571. },
  572. goMajorDetail:function(e){
  573. wx.navigateTo({
  574. url: 'majorDetail/majorDetail?id='+e.currentTarget.dataset.id+'&taskId='+e.currentTarget.dataset.taskid+'&type='+e.currentTarget.dataset.type,
  575. })
  576. },
  577. gosee:function(e){
  578. wx.navigateTo({
  579. 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,
  580. })
  581. },
  582. goUpdate(e){
  583. wx.navigateTo({
  584. url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  585. })
  586. },
  587. showModal(){
  588. wx.showModal({
  589. title: '提示',
  590. content: '此功能未正式启用!',
  591. showCancel: false,
  592. success (res) {
  593. if (res.confirm) {
  594. console.log('用户点击确定')
  595. } else if (res.cancel) {
  596. console.log('用户点击取消')
  597. }
  598. }
  599. })
  600. },
  601. navigate(even){
  602. wx.navigateTo({
  603. url: even.currentTarget.dataset.url,
  604. })
  605. },
  606. delete(e){
  607. console.log(e);
  608. var that = this;
  609. wx.showModal({
  610. title: '提示',
  611. content: '确认删除?',
  612. success (res) {
  613. if (res.confirm) {
  614. UTIL.httpRequest(API.URL_GET_REMOVETRANFERL + e.currentTarget.dataset.id, {method:'GET'},{
  615. success: (res) => {
  616. if (res.code == API.SUCCESS_CODE) {
  617. that.data.yzdList.splice(e.currentTarget.dataset.index, 1);
  618. wx.showToast({
  619. title: '删除成功!',
  620. icon: 'success',
  621. duration: 2000
  622. })
  623. that.setData({
  624. yzdList : that.data.yzdList,
  625. yzdNum:that.data.yzdNum-1
  626. })
  627. }
  628. }
  629. })
  630. } else if (res.cancel) {
  631. console.log('用户点击取消')
  632. }
  633. }
  634. })
  635. },
  636. goRegion(){
  637. wx.navigateTo({
  638. url: '/pages/user/region/region',
  639. })
  640. },
  641. testBtn(){
  642. wx.requestSubscribeMessage({
  643. tmplIds: ['_Npje859RvKIf5AcqaikWYGXJpOcigMTzyB3HjJ1L9I'],
  644. success (res) { }
  645. })
  646. },
  647. rollback(e){
  648. var that = this;
  649. let prames = {
  650. id : e.currentTarget.dataset.id,
  651. auditStatus : '0',
  652. applyUserId : '',
  653. applyUserName : '',
  654. applyTime : '',
  655. instanceId : '',
  656. processKey : '',
  657. method:'POST'
  658. }
  659. wx.showModal({
  660. title: '提示',
  661. content: '确认撤回?',
  662. success (res) {
  663. if (res.confirm) {
  664. UTIL.httpRequest(API.URL_GET_UPDATETYINNONGTRANSFERFOSTATUS, prames ,{
  665. success: (res) => {
  666. if (res.code == API.SUCCESS_CODE) {
  667. wx.showToast({
  668. title: '撤回成功!',
  669. icon: 'success',
  670. duration: 2000
  671. })
  672. that.setData({
  673. yfqList:[],
  674. yzdList:[]
  675. })
  676. that.getTransferList2()
  677. that.getTransferList1()
  678. }else{
  679. wx.showToast({
  680. title: res.msg,
  681. icon: 'error',
  682. duration: 2000
  683. })
  684. }
  685. }
  686. })
  687. } else if (res.cancel) {
  688. console.log('用户点击取消')
  689. }
  690. }
  691. })
  692. },
  693. })