微信小程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

index.js 14 KiB

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