微信小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

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