微信小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

484 行
14 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. },
  52. onLoad: function (options) {
  53. //获取用户信息
  54. this.getUserInfo()
  55. //获取滚动条高度
  56. this.computeBarLocation();
  57. //查询待办
  58. this.getTaskList();
  59. //查询已办
  60. this.getTaskDoneList();
  61. //查询dept
  62. this.getTreeDept();
  63. },
  64. reset:function(){
  65. this.setData({
  66. active:1,
  67. todoList:[],
  68. doneList:[],
  69. yfqList:[],
  70. yzdList:[],
  71. todoNum:0,
  72. doneNum:0,
  73. yfqNum:0,
  74. yzdNum:0
  75. })
  76. },
  77. switchTab:function(e){
  78. this.setData({
  79. active:e.currentTarget.dataset.gid
  80. })
  81. },
  82. dictTranslate(d,value){
  83. let val = ""
  84. for(var index in d){
  85. if(d[index].dictVale==value){
  86. return val = d[index].dictLabel
  87. }
  88. }
  89. },
  90. getTaskList:function(e){
  91. let data = {
  92. pageNum:1,
  93. pageSize:10,
  94. orderByColumn:"A.ID_",
  95. isAsc:"desc",
  96. systemType:4,
  97. method:"GET",
  98. taskName:'相关人员审批'
  99. }
  100. UTIL.httpRequest(API.URL_GET_TASKLIST,data, {
  101. success: (res) => {
  102. if (res.code == API.SUCCESS_CODE) {
  103. this.setData({todoNum:res.total})
  104. if(res.rows!=null&&res.rows!=""){
  105. for(let i = 0;i<res.total;i++){
  106. let d = this.dictTranslate(this.data.transferType,res.rows[i].formData.transferType)
  107. res.rows[i].formData.transferType = d
  108. }
  109. this.setData({todoList:res.rows})
  110. }
  111. }
  112. }, fail: (res) => {
  113. console.log(res);
  114. },
  115. complete: (res) => {
  116. }
  117. })
  118. },
  119. getTaskDoneList:function(e){
  120. let data = {
  121. pageNum:1,
  122. pageSize:10,
  123. orderByColumn:"A.ID_",
  124. isAsc:"desc",
  125. systemType:4,
  126. method:"GET",
  127. taskName:'相关人员审批'
  128. }
  129. UTIL.httpRequest(API.URL_GET_TASKDONELIST,data, {
  130. success: (res) => {
  131. if (res.code == API.SUCCESS_CODE) {
  132. this.setData({doneNum:res.total})
  133. if(res.rows!=null&&res.rows!=""){
  134. for(var index in res.rows){
  135. let d = this.dictTranslate(this.data.transferType,res.rows[index].formData.transferType)
  136. res.rows[index].formData.transferType = d
  137. }
  138. this.setData({doneList:res.rows})
  139. }
  140. }
  141. }, fail: (res) => {
  142. console.log(res);
  143. },
  144. complete: (res) => {
  145. }
  146. })
  147. },
  148. getTransferList:function(e){
  149. let data = {
  150. // pageNum:1,
  151. // pageSize:10,
  152. transferType:"1",
  153. status:"5",
  154. method:"GET",
  155. applyUserName:this.data.userInfoObj.nickName
  156. }
  157. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  158. success: (res) => {
  159. console.log(res);
  160. if (res.code == API.SUCCESS_CODE) {
  161. let a = this.data.yfqNum+res.total
  162. this.setData({yfqNum:a})
  163. let b = this.data.yfqList
  164. this.setData({yfqList:res.rows.concat(b)})
  165. }
  166. }, fail: (res) => {
  167. },
  168. complete: (res) => {
  169. }
  170. })
  171. },
  172. getTransferList1:function(e){
  173. let data = {
  174. // pageNum:1,
  175. // pageSize:10,
  176. transferType:"1",
  177. auditStatus:"3",
  178. method:"GET"
  179. }
  180. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  181. success: (res) => {
  182. console.log(res);
  183. if (res.code == API.SUCCESS_CODE) {
  184. let a = this.data.yfqNum+res.total
  185. this.setData({yfqNum:a})
  186. let b = this.data.yfqList
  187. this.setData({yfqList:res.rows.concat(b)})
  188. }
  189. }, fail: (res) => {
  190. },
  191. complete: (res) => {
  192. }
  193. })
  194. },
  195. //已制单
  196. getTransferList2:function(e){
  197. let data = {
  198. // pageNum:1,
  199. // pageSize:10,
  200. transferType:"1",
  201. status:"0",
  202. method:"GET",
  203. submitter:this.data.userInfoObj.nickName
  204. }
  205. UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, {
  206. success: (res) => {
  207. if (res.code == API.SUCCESS_CODE) {
  208. this.setData({yzdNum:res.total})
  209. this.setData({yzdList:res.rows})
  210. }
  211. }, fail: (res) => {
  212. },
  213. complete: (res) => {
  214. }
  215. })
  216. },
  217. //跳转收入登记
  218. swichInCome:function(e){
  219. wx.navigateTo({
  220. url: '../inCome/inCome?',
  221. })
  222. },
  223. //跳转支出申请
  224. swichPayment:function(e){
  225. console.log(e.currentTarget.dataset.current);
  226. // let cur = e.currentTarget.dataset.current;
  227. // if (this.data.currentTaB == cur) {
  228. // return false;
  229. // }else{
  230. // wx.navigateTo({
  231. // url: '../inCome/index?id=' + id,
  232. // })
  233. // }
  234. wx.navigateTo({
  235. url: '/pages/apply/index?',
  236. })
  237. },
  238. toList:function(){
  239. wx.navigateTo({
  240. url: '/pages/handle/liist?active='+this.data.active,
  241. })
  242. },
  243. /* 计算bar 高度*/
  244. computeBarLocation() {
  245. var that = this;
  246. let CustomMenuButton = wx.getMenuButtonBoundingClientRect();
  247. let CustomWidows = wx.getSystemInfoSync();
  248. // 根据文档,先创建一个SelectorQuery对象实例
  249. let query = wx.createSelectorQuery().in(this);
  250. query.select('.top_title').boundingClientRect();
  251. query.select('.information_header').boundingClientRect();
  252. query.select('.navList_main').boundingClientRect();
  253. query.select('.child_function').boundingClientRect();
  254. query.select('.work_plan').boundingClientRect();
  255. query.exec((res) => {
  256. let wrokScrollHeight = CustomWidows.windowHeight;
  257. res.forEach((v)=>{
  258. wrokScrollHeight = wrokScrollHeight - v.height;
  259. })
  260. wrokScrollHeight = wrokScrollHeight-CustomMenuButton.top-CustomMenuButton.bottom -15;
  261. that.setData({
  262. wrokScrollHeight: wrokScrollHeight,
  263. });
  264. })
  265. that.setData({
  266. CustomMenuButton: CustomMenuButton,
  267. });
  268. },
  269. /* 获取用户信息*/
  270. getUserInfo(){
  271. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  272. success: (res) => {
  273. if (res.code == API.SUCCESS_CODE) {
  274. this.setData({userInfoObj:res.user})
  275. this.setData({region:res.user.deptName})
  276. this.setData({item:JSON.stringify(res.user)})
  277. this.getBookList()
  278. //查询已制单
  279. this.getTransferList2();
  280. //查询已发起
  281. this.getTransferList();
  282. // this.getTransferList1();
  283. }
  284. }
  285. })
  286. },
  287. /* 获取区镇村*/
  288. getTreeDept:function(){
  289. UTIL.httpRequest(API.URL_GET_TREESELECTBYUSER, {method:'GET'}, {
  290. success: (res) => {
  291. if (res.code == API.SUCCESS_CODE) {
  292. this.setData({provinces:res.data})
  293. this.setData({citys:res.data[0].children})
  294. this.setData({areas:res.data[0].children[this.data.value[1]].children})
  295. }
  296. }
  297. })
  298. },
  299. /* 获取账套*/
  300. getBookList:function(){
  301. let d = {
  302. loginDeptID : this.data.userInfoObj.loginDeptId
  303. }
  304. UTIL.httpRequest(API.URL_GET_BOOKLISTBYDEPTID,d, {
  305. success: (res) => {
  306. if (res.code == API.SUCCESS_CODE) {
  307. this.setData({bookList:res.rows})
  308. if(this.data.bookName==""&&res.total>0){
  309. this.setData({bookName:res.rows[0].bookName})
  310. this.setData({bookId:res.rows[0].id})
  311. }else if(this.data.bookName==""&&res.total==0){
  312. this.setData({bookName:"无可用账套"})
  313. }
  314. }
  315. },fail:(res) => {
  316. },complete:(res) => {
  317. }
  318. })
  319. },
  320. bindPickerChange:function(e){
  321. this.setData({
  322. bookId: this.data.bookList[e.detail.value].id,
  323. bookName:this.data.bookList[e.detail.value].bookName
  324. })
  325. let data={
  326. loginBookId:this.data.bookList[e.detail.value].id
  327. }
  328. let _this = this
  329. UTIL.httpRequest(API.URL_GET_CHANGEBOOK,data, {
  330. success: (res) => {
  331. _this.reset()
  332. _this.onLoad()
  333. }
  334. })
  335. },
  336. closePopUp() {
  337. this.setData({
  338. visible: false
  339. })
  340. },
  341. pickAddress() {
  342. this.setData({
  343. visible: true,
  344. value: [...this.data.regionValue]
  345. })
  346. },
  347. // 处理省市县联动逻辑 并保存 value
  348. cityChange(e) {
  349. var value = e.detail.value
  350. let {
  351. provinces,
  352. citys
  353. } = this.data
  354. var provinceNum = value[0]
  355. var cityNum = value[1]
  356. var areaNum = value[2]
  357. if (this.data.value[0] !== provinceNum) {
  358. var id = provinces[provinceNum].id
  359. this.setData({
  360. value: [provinceNum, 0, 0],
  361. citys: this.data.provinces[provinceNum].children,
  362. areas: this.data.provinces[provinceNum].children[cityNum].children
  363. })
  364. } else if (this.data.value[1] !== cityNum) {
  365. var id = citys[cityNum].id
  366. this.setData({
  367. value: [provinceNum, cityNum, 0],
  368. areas: this.data.provinces[provinceNum].children[cityNum].children
  369. })
  370. } else {
  371. this.setData({
  372. value: [provinceNum, cityNum, areaNum]
  373. })
  374. }
  375. console.log(this.data.value);
  376. },
  377. preventTouchmove() {},
  378. // 城市选择器
  379. // 点击地区选择取消按钮
  380. cityCancel(e) {
  381. var id = this.data.provinces[0].id
  382. this.setData({
  383. citys: this.data.lastCitys || this.data.userInfoObj.parentDeptName, //默认北京市辖区,
  384. areas: this.data.lastAreas || this.data.userInfoObj.deptName,
  385. value: [...this.data.regionValue],
  386. visible: false
  387. })
  388. },
  389. // 提交时由序号获取省市区id
  390. getRegionId(type) {
  391. let value = this.data.regionValue
  392. let provinceId = this.data.provinces[value[0]].id
  393. let townId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  394. let areaId = ''
  395. if (this.data.provinces[value[0]].children[value[1]].children[value[2]].id) {
  396. areaId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  397. } else {
  398. areaId = 0
  399. }
  400. if (type === 'provinceId') {
  401. return provinceId
  402. } else if (type === 'townId') {
  403. return townId
  404. } else {
  405. return areaId
  406. }
  407. },
  408. chooseStart(e) {
  409. this.setData({
  410. isCanConfirm: false
  411. })
  412. },
  413. chooseEnd(e) {
  414. this.setData({
  415. isCanConfirm: true
  416. })
  417. },
  418. // 点击地区选择确定按钮
  419. citySure(e) {
  420. if (this.data.isCanConfirm) {
  421. var value = this.data.value
  422. this.setData({
  423. visible: false
  424. })
  425. // 将选择的城市信息显示到输入框
  426. try {
  427. var region = (this.data.provinces[value[0]].label || '') + (this.data.citys[value[1]].label || '')
  428. if (this.data.areas.length > 0) {
  429. region = this.data.areas[value[2]].label || ''
  430. } else {
  431. this.data.value[2] = 0
  432. }
  433. } catch (error) {
  434. console.log('adress select something error')
  435. }
  436. this.setData({
  437. region: region,
  438. lastCitys: this.data.citys,
  439. lastAreas: this.data.areas,
  440. regionValue: value,
  441. deptId:this.getRegionId('areas'),
  442. bookName:"",
  443. bookId:""
  444. }, () => {
  445. let data={
  446. loginDeptID : this.getRegionId('areas')
  447. }
  448. let _this = this
  449. UTIL.httpRequest(API.URL_GET_CHANGEDEPT,data, {
  450. success: (res) => {
  451. setTimeout(()=>{
  452. _this.reset()
  453. _this.onLoad()
  454. },1000)
  455. }
  456. })
  457. })
  458. }
  459. },
  460. godetail:function(e){
  461. wx.navigateTo({
  462. url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  463. })
  464. },
  465. gosee:function(e){
  466. wx.navigateTo({
  467. url: '/pages/handle/expenditureAudit/expenditureAudit?id='+e.currentTarget.dataset.id+'&taskId='+e.currentTarget.dataset.taskid,
  468. })
  469. },
  470. goUpdate(e){
  471. wx.navigateTo({
  472. url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  473. })
  474. },
  475. })