微信小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

index.js 16 KiB

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