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

486 行
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. if(res.data[0].children){
  294. this.setData({citys:res.data[0].children})
  295. if(res.data[0].children[this.data.value[1]].children){this.setData({areas:res.data[0].children[this.data.value[1]].children})}
  296. }
  297. }
  298. }
  299. })
  300. },
  301. /* 获取账套*/
  302. getBookList:function(){
  303. let d = {
  304. loginDeptID : this.data.userInfoObj.loginDeptId
  305. }
  306. UTIL.httpRequest(API.URL_GET_BOOKLISTBYDEPTID,d, {
  307. success: (res) => {
  308. if (res.code == API.SUCCESS_CODE) {
  309. this.setData({bookList:res.rows})
  310. if(this.data.bookName==""&&res.total>0){
  311. this.setData({bookName:res.rows[0].bookName})
  312. this.setData({bookId:res.rows[0].id})
  313. }else if(this.data.bookName==""&&res.total==0){
  314. this.setData({bookName:"无可用账套"})
  315. }
  316. }
  317. },fail:(res) => {
  318. },complete:(res) => {
  319. }
  320. })
  321. },
  322. bindPickerChange:function(e){
  323. this.setData({
  324. bookId: this.data.bookList[e.detail.value].id,
  325. bookName:this.data.bookList[e.detail.value].bookName
  326. })
  327. let data={
  328. loginBookId:this.data.bookList[e.detail.value].id
  329. }
  330. let _this = this
  331. UTIL.httpRequest(API.URL_GET_CHANGEBOOK,data, {
  332. success: (res) => {
  333. _this.reset()
  334. _this.onLoad()
  335. }
  336. })
  337. },
  338. closePopUp() {
  339. this.setData({
  340. visible: false
  341. })
  342. },
  343. pickAddress() {
  344. this.setData({
  345. visible: true,
  346. value: [...this.data.regionValue]
  347. })
  348. },
  349. // 处理省市县联动逻辑 并保存 value
  350. cityChange(e) {
  351. var value = e.detail.value
  352. let {
  353. provinces,
  354. citys
  355. } = this.data
  356. var provinceNum = value[0]
  357. var cityNum = value[1]
  358. var areaNum = value[2]
  359. if (this.data.value[0] !== provinceNum) {
  360. var id = provinces[provinceNum].id
  361. this.setData({
  362. value: [provinceNum, 0, 0],
  363. citys: this.data.provinces[provinceNum].children,
  364. areas: this.data.provinces[provinceNum].children[cityNum].children
  365. })
  366. } else if (this.data.value[1] !== cityNum) {
  367. var id = citys[cityNum].id
  368. this.setData({
  369. value: [provinceNum, cityNum, 0],
  370. areas: this.data.provinces[provinceNum].children[cityNum].children
  371. })
  372. } else {
  373. this.setData({
  374. value: [provinceNum, cityNum, areaNum]
  375. })
  376. }
  377. console.log(this.data.value);
  378. },
  379. preventTouchmove() {},
  380. // 城市选择器
  381. // 点击地区选择取消按钮
  382. cityCancel(e) {
  383. var id = this.data.provinces[0].id
  384. this.setData({
  385. citys: this.data.lastCitys || this.data.userInfoObj.parentDeptName, //默认北京市辖区,
  386. areas: this.data.lastAreas || this.data.userInfoObj.deptName,
  387. value: [...this.data.regionValue],
  388. visible: false
  389. })
  390. },
  391. // 提交时由序号获取省市区id
  392. getRegionId(type) {
  393. let value = this.data.regionValue
  394. let provinceId = this.data.provinces[value[0]].id
  395. let townId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  396. let areaId = ''
  397. if (this.data.provinces[value[0]].children[value[1]].children[value[2]].id) {
  398. areaId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id
  399. } else {
  400. areaId = 0
  401. }
  402. if (type === 'provinceId') {
  403. return provinceId
  404. } else if (type === 'townId') {
  405. return townId
  406. } else {
  407. return areaId
  408. }
  409. },
  410. chooseStart(e) {
  411. this.setData({
  412. isCanConfirm: false
  413. })
  414. },
  415. chooseEnd(e) {
  416. this.setData({
  417. isCanConfirm: true
  418. })
  419. },
  420. // 点击地区选择确定按钮
  421. citySure(e) {
  422. if (this.data.isCanConfirm) {
  423. var value = this.data.value
  424. this.setData({
  425. visible: false
  426. })
  427. // 将选择的城市信息显示到输入框
  428. try {
  429. var region = (this.data.provinces[value[0]].label || '') + (this.data.citys[value[1]].label || '')
  430. if (this.data.areas.length > 0) {
  431. region = this.data.areas[value[2]].label || ''
  432. } else {
  433. this.data.value[2] = 0
  434. }
  435. } catch (error) {
  436. console.log('adress select something error')
  437. }
  438. this.setData({
  439. region: region,
  440. lastCitys: this.data.citys,
  441. lastAreas: this.data.areas,
  442. regionValue: value,
  443. deptId:this.getRegionId('areas'),
  444. bookName:"",
  445. bookId:""
  446. }, () => {
  447. let data={
  448. loginDeptID : this.getRegionId('areas')
  449. }
  450. let _this = this
  451. UTIL.httpRequest(API.URL_GET_CHANGEDEPT,data, {
  452. success: (res) => {
  453. setTimeout(()=>{
  454. _this.reset()
  455. _this.onLoad()
  456. },1000)
  457. }
  458. })
  459. })
  460. }
  461. },
  462. godetail:function(e){
  463. wx.navigateTo({
  464. url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  465. })
  466. },
  467. gosee:function(e){
  468. wx.navigateTo({
  469. url: '/pages/handle/expenditureAudit/expenditureAudit?id='+e.currentTarget.dataset.id+'&taskId='+e.currentTarget.dataset.taskid+'&type='+e.currentTarget.dataset.type,
  470. })
  471. },
  472. goUpdate(e){
  473. wx.navigateTo({
  474. url: '/pages/apply/paymentTemplate/add/add?id='+e.currentTarget.dataset.id,
  475. })
  476. },
  477. })