微信小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

590 lines
18 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. },
  55. onLoad: function (options) {
  56. //获取滚动条高度
  57. this.computeBarLocation();
  58. },
  59. openView(){
  60. var that = this;
  61. let num = that.data.num;
  62. console.log((num%2));
  63. if( (num%2) > 0 ){
  64. num++;
  65. that.setData({
  66. showList:true,
  67. showListText:'收起',
  68. num:num
  69. })
  70. }else{
  71. num++;
  72. that.setData({
  73. showList:false,
  74. showListText:'更多',
  75. num:num
  76. })
  77. }
  78. },
  79. // getUserProfile(e) {
  80. // // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
  81. // // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  82. // wx.getUserProfile({
  83. // desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  84. // success: (res) => {
  85. // this.setData({
  86. // userInfo: res.userInfo,
  87. // hasUserInfo: true
  88. // })
  89. // }
  90. // })
  91. // },
  92. onShow(){
  93. //获取用户信息
  94. this.getUserInfo()
  95. //查询待办
  96. this.getTaskList();
  97. //查询已办
  98. this.getTaskDoneList();
  99. //查询dept
  100. this.getTreeDept();
  101. },
  102. reset:function(){
  103. this.setData({
  104. active:1,
  105. todoList:[],
  106. doneList:[],
  107. yfqList:[],
  108. yzdList:[],
  109. todoNum:0,
  110. doneNum:0,
  111. yfqNum:0,
  112. yzdNum:0
  113. })
  114. },
  115. switchTab:function(e){
  116. this.setData({
  117. active:e.currentTarget.dataset.gid
  118. })
  119. },
  120. dictTranslate(d,value){
  121. let val = ""
  122. for(var index in d){
  123. if(d[index].dictVale==value){
  124. return val = d[index].dictLabel
  125. }
  126. }
  127. },
  128. getTaskList:function(e){
  129. let data = {
  130. pageNum:1,
  131. pageSize:999,
  132. orderByColumn:"A.ID_",
  133. isAsc:"desc",
  134. systemType:4,
  135. method:"GET",
  136. taskName:'相关人员审批'
  137. }
  138. UTIL.httpRequest(API.URL_GET_TASKLIST,data, {
  139. success: (res) => {
  140. if (res.code == API.SUCCESS_CODE) {
  141. this.setData({todoNum:res.total})
  142. if(res.rows!=null&&res.rows!=""){
  143. for(let i = 0;i<res.total;i++){
  144. let d = this.dictTranslate(this.data.transferType,res.rows[i].formData.transferType)
  145. res.rows[i].formData.transferType = d
  146. res.rows[i].formData.totalAmount = Number(res.rows[i].formData.totalAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  147. return $1 + ","; }).replace(/\.$/, "")
  148. }
  149. this.setData({todoList:res.rows})
  150. }
  151. }
  152. }, fail: (res) => {
  153. console.log(res);
  154. },
  155. complete: (res) => {
  156. }
  157. })
  158. },
  159. getTaskDoneList:function(e){
  160. let data = {
  161. pageNum:1,
  162. pageSize:999,
  163. orderByColumn:"A.ID_",
  164. isAsc:"desc",
  165. systemType:4,
  166. method:"GET",
  167. taskName:'相关人员审批'
  168. }
  169. UTIL.httpRequest(API.URL_GET_TASKDONELIST,data, {
  170. success: (res) => {
  171. if (res.code == API.SUCCESS_CODE) {
  172. this.setData({doneNum:res.total})
  173. if(res.rows!=null&&res.rows!=""){
  174. for(let i = 0;i<res.total;i++){
  175. let d = this.dictTranslate(this.data.transferType,res.rows[i].formData.transferType)
  176. res.rows[i].formData.transferType = d
  177. res.rows[i].formData.totalAmount = Number(res.rows[i].formData.totalAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  178. return $1 + ","; }).replace(/\.$/, "")
  179. }
  180. this.setData({doneList:res.rows})
  181. }
  182. }
  183. }, fail: (res) => {
  184. console.log(res);
  185. },
  186. complete: (res) => {
  187. }
  188. })
  189. },
  190. getTransferList:function(e){
  191. let data = {
  192. // pageNum:1,
  193. // pageSize:10,
  194. transferType:"1",
  195. status:"5",
  196. method:"GET",
  197. applyUserName:this.data.userInfoObj.nickName
  198. }
  199. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  200. success: (res) => {
  201. console.log(res);
  202. if (res.code == API.SUCCESS_CODE) {
  203. let a = res.total
  204. this.setData({yfqNum:a})
  205. for(let i = 0;i<res.total;i++){
  206. res.rows[i].totalAmount = Number(res.rows[i].totalAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  207. return $1 + ","; }).replace(/\.$/, "")
  208. }
  209. this.setData({yfqList:res.rows})
  210. }
  211. }, fail: (res) => {
  212. },
  213. complete: (res) => {
  214. }
  215. })
  216. },
  217. getTransferList1:function(e){
  218. let data = {
  219. // pageNum:1,
  220. // pageSize:10,
  221. transferType:"1",
  222. auditStatus:"3",
  223. method:"GET"
  224. }
  225. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  226. success: (res) => {
  227. console.log(res);
  228. if (res.code == API.SUCCESS_CODE) {
  229. let a = this.data.yfqNum+res.total
  230. this.setData({yfqNum:a})
  231. let b = this.data.yfqList
  232. let c = res.rows.concat(b)
  233. for(let i = 0;i< c.length;i++){
  234. c[i].totalAmount = Number(c[i].totalAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  235. return $1 + ","; }).replace(/\.$/, "")
  236. }
  237. this.setData({yfqList:c})
  238. }
  239. }, fail: (res) => {
  240. },
  241. complete: (res) => {
  242. }
  243. })
  244. },
  245. //已制单
  246. getTransferList2:function(e){
  247. let data = {
  248. // pageNum:1,
  249. // pageSize:10,
  250. transferType:"1",
  251. status:"0",
  252. method:"GET",
  253. submitter:this.data.userInfoObj.nickName
  254. }
  255. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  256. success: (res) => {
  257. if (res.code == API.SUCCESS_CODE) {
  258. this.setData({yzdNum:res.total})
  259. for(let i = 0;i< res.rows.length;i++){
  260. res.rows[i].totalAmount = Number(res.rows[i].totalAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  261. return $1 + ","; }).replace(/\.$/, "")
  262. }
  263. this.setData({yzdList:res.rows})
  264. }
  265. }, fail: (res) => {
  266. },
  267. complete: (res) => {
  268. }
  269. })
  270. },
  271. //跳转收入登记
  272. swichInCome:function(e){
  273. wx.navigateTo({
  274. url: '../inCome/inCome?',
  275. })
  276. },
  277. //跳转收入登记
  278. swichKeeping:function(e){
  279. wx.navigateTo({
  280. url: '/pages/Bookkeeping/Bookkeeping',
  281. })
  282. },
  283. //跳转支出申请
  284. swichPayment:function(e){
  285. console.log(e.currentTarget.dataset.current);
  286. // let cur = e.currentTarget.dataset.current;
  287. // if (this.data.currentTaB == cur) {
  288. // return false;
  289. // }else{
  290. // wx.navigateTo({
  291. // url: '../inCome/index?id=' + id,
  292. // })
  293. // }
  294. wx.navigateTo({
  295. url: '/pages/apply/index?',
  296. })
  297. },
  298. toList:function(){
  299. wx.navigateTo({
  300. url: '/pages/handle/liist?active='+this.data.active,
  301. })
  302. },
  303. /* 计算bar 高度*/
  304. computeBarLocation() {
  305. var that = this;
  306. let CustomMenuButton = wx.getMenuButtonBoundingClientRect();
  307. let CustomWidows = wx.getSystemInfoSync();
  308. // 根据文档,先创建一个SelectorQuery对象实例
  309. let query = wx.createSelectorQuery().in(this);
  310. query.select('.top_title').boundingClientRect();
  311. query.select('.information_header').boundingClientRect();
  312. query.select('.navList_main').boundingClientRect();
  313. query.select('.child_function').boundingClientRect();
  314. query.select('.work_plan').boundingClientRect();
  315. query.exec((res) => {
  316. let wrokScrollHeight = CustomWidows.windowHeight;
  317. res.forEach((v)=>{
  318. wrokScrollHeight = wrokScrollHeight - v.height;
  319. })
  320. wrokScrollHeight = wrokScrollHeight-CustomMenuButton.top-CustomMenuButton.bottom -15;
  321. that.setData({
  322. wrokScrollHeight: wrokScrollHeight,
  323. });
  324. })
  325. that.setData({
  326. CustomMenuButton: CustomMenuButton,
  327. });
  328. },
  329. /* 获取用户信息*/
  330. getUserInfo(){
  331. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  332. success: (res) => {
  333. if (res.code == API.SUCCESS_CODE) {
  334. this.setData({userInfoObj:res.user})
  335. console.log(res.user);
  336. this.setData({region:res.user.deptName})
  337. this.setData({item:JSON.stringify(res.user)})
  338. this.getBookList()
  339. //查询已制单
  340. this.getTransferList2();
  341. //查询已发起
  342. this.getTransferList();
  343. // this.getTransferList1();
  344. }
  345. }
  346. })
  347. },
  348. /* 获取区镇村*/
  349. getTreeDept:function(){
  350. UTIL.httpRequest(API.URL_GET_TREESELECTBYUSER, {method:'GET'}, {
  351. success: (res) => {
  352. if (res.code == API.SUCCESS_CODE) {
  353. this.setData({provinces:res.data})
  354. if(res.data[0].children){
  355. this.setData({citys:res.data[0].children})
  356. if(res.data[0].children[this.data.value[1]].children){this.setData({areas:res.data[0].children[this.data.value[1]].children})}
  357. }
  358. }
  359. }
  360. })
  361. },
  362. /* 获取账套*/
  363. getBookList:function(){
  364. let d = {
  365. loginDeptID : this.data.userInfoObj.loginDeptId,
  366. method:'GET'
  367. }
  368. UTIL.httpRequest(API.URL_GET_BOOKLISTBYDEPTID,d, {
  369. success: (res) => {
  370. if (res.code == API.SUCCESS_CODE) {
  371. this.setData({bookList:res.rows})
  372. if(this.data.bookName==""&&res.total>0){
  373. this.setData({bookName:res.rows[0].bookName})
  374. this.setData({bookId:res.rows[0].id})
  375. }else if(this.data.bookName==""&&res.total==0){
  376. this.setData({bookName:"无可用账套"})
  377. }
  378. }
  379. },fail:(res) => {
  380. },complete:(res) => {
  381. }
  382. })
  383. },
  384. bindPickerChange:function(e){
  385. this.setData({
  386. bookId: this.data.bookList[e.detail.value].id,
  387. bookName:this.data.bookList[e.detail.value].bookName
  388. })
  389. let data={
  390. loginBookId:this.data.bookList[e.detail.value].id,
  391. method:'GET'
  392. }
  393. let _this = this
  394. UTIL.httpRequest(API.URL_GET_CHANGEBOOK,data, {
  395. success: (res) => {
  396. _this.reset();
  397. _this.onShow();
  398. }
  399. })
  400. },
  401. closePopUp() {
  402. this.setData({
  403. visible: false
  404. })
  405. },
  406. pickAddress() {
  407. this.setData({
  408. visible: true,
  409. value: [...this.data.regionValue]
  410. })
  411. },
  412. // 处理省市县联动逻辑 并保存 value
  413. cityChange(e) {
  414. var value = e.detail.value
  415. let {
  416. provinces,
  417. citys
  418. } = this.data
  419. var provinceNum = value[0]
  420. var cityNum = value[1]
  421. var areaNum = value[2]
  422. if (this.data.value[0] !== provinceNum) {
  423. var id = provinces[provinceNum].id
  424. this.setData({
  425. value: [provinceNum, 0, 0],
  426. citys: this.data.provinces[provinceNum].children,
  427. areas: this.data.provinces[provinceNum].children[cityNum].children
  428. })
  429. } else if (this.data.value[1] !== cityNum) {
  430. var id = citys[cityNum].id
  431. this.setData({
  432. value: [provinceNum, cityNum, 0],
  433. areas: this.data.provinces[provinceNum].children[cityNum].children
  434. })
  435. } else {
  436. this.setData({
  437. value: [provinceNum, cityNum, areaNum]
  438. })
  439. }
  440. console.log(this.data.value);
  441. },
  442. preventTouchmove() {},
  443. // 城市选择器
  444. // 点击地区选择取消按钮
  445. cityCancel(e) {
  446. var id = this.data.provinces[0].id
  447. this.setData({
  448. citys: this.data.lastCitys || this.data.userInfoObj.parentDeptName, //默认北京市辖区,
  449. areas: this.data.lastAreas || this.data.userInfoObj.deptName,
  450. value: [...this.data.regionValue],
  451. visible: false
  452. })
  453. },
  454. // 提交时由序号获取省市区id
  455. getRegionId(type) {
  456. let value = this.data.regionValue
  457. let provinceId = this.data.provinces[value[0]].id
  458. let townId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  459. let areaId = ''
  460. if (this.data.provinces[value[0]].children[value[1]].children[value[2]].id) {
  461. areaId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  462. } else {
  463. areaId = 0
  464. }
  465. if (type === 'provinceId') {
  466. return provinceId
  467. } else if (type === 'townId') {
  468. return townId
  469. } else {
  470. return areaId
  471. }
  472. },
  473. chooseStart(e) {
  474. this.setData({
  475. isCanConfirm: false
  476. })
  477. },
  478. chooseEnd(e) {
  479. this.setData({
  480. isCanConfirm: true
  481. })
  482. },
  483. // 点击地区选择确定按钮
  484. citySure(e) {
  485. if (this.data.isCanConfirm) {
  486. var value = this.data.value
  487. this.setData({
  488. visible: false
  489. })
  490. // 将选择的城市信息显示到输入框
  491. try {
  492. var region = (this.data.provinces[value[0]].label || '') + (this.data.citys[value[1]].label || '')
  493. if (this.data.areas.length > 0) {
  494. region = this.data.areas[value[2]].label || ''
  495. } else {
  496. this.data.value[2] = 0
  497. }
  498. } catch (error) {
  499. console.log('adress select something error')
  500. }
  501. this.setData({
  502. region: region,
  503. lastCitys: this.data.citys,
  504. lastAreas: this.data.areas,
  505. regionValue: value,
  506. deptId:this.getRegionId('areas'),
  507. bookName:"",
  508. bookId:""
  509. }, () => {
  510. let data={
  511. loginDeptID : this.getRegionId('areas'),
  512. method:'GET'
  513. }
  514. let _this = this
  515. UTIL.httpRequest(API.URL_GET_CHANGEDEPT,data, {
  516. success: (res) => {
  517. setTimeout(()=>{
  518. _this.reset()
  519. _this.onLoad()
  520. },1000)
  521. }
  522. })
  523. })
  524. }
  525. },
  526. godetail:function(e){
  527. wx.navigateTo({
  528. url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  529. })
  530. },
  531. gosee:function(e){
  532. wx.navigateTo({
  533. url: '/pages/handle/expenditureAudit/expenditureAudit?id='+e.currentTarget.dataset.id+'&taskId='+e.currentTarget.dataset.taskid+'&type='+e.currentTarget.dataset.type+'&business='+e.currentTarget.dataset.business,
  534. })
  535. },
  536. goUpdate(e){
  537. wx.navigateTo({
  538. url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  539. })
  540. },
  541. showModal(){
  542. wx.showModal({
  543. title: '提示',
  544. content: '此功能未正式启用!',
  545. showCancel: false,
  546. success (res) {
  547. if (res.confirm) {
  548. console.log('用户点击确定')
  549. } else if (res.cancel) {
  550. console.log('用户点击取消')
  551. }
  552. }
  553. })
  554. },
  555. navigate(even){
  556. wx.navigateTo({
  557. url: even.currentTarget.dataset.url,
  558. })
  559. },
  560. delete(e){
  561. console.log(e);
  562. var that = this;
  563. UTIL.httpRequest(API.URL_GET_REMOVEAPPROVAL + e.currentTarget.dataset.id, {method:'GET'},{
  564. success: (res) => {
  565. if (res.code == API.SUCCESS_CODE) {
  566. that.data.yzdList.splice(e.currentTarget.dataset.index, 1);
  567. wx.showToast({
  568. title: '删除成功!',
  569. icon: 'success',
  570. duration: 2000
  571. })
  572. that.setData({
  573. yzdList : that.data.yzdList,
  574. yzdNum:that.data.yzdNum-1
  575. })
  576. }
  577. }
  578. })
  579. },
  580. })