微信小程序
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.

approval.js 13 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
há 3 anos
há 3 anos
há 3 anos
há 3 anos
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. // pages/apply/approval/approval.js
  2. import * as UTIL from '../../../utils/util.js';
  3. import * as API from '../../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. steps: [
  12. {
  13. assigneeName: '同意',
  14. activityName: '测试测试',
  15. durationInMillis: '描述信息',
  16. endTime: '2022-01-02',
  17. comment: '同意',
  18. type: '1'
  19. },
  20. {
  21. assigneeName: '申请中',
  22. activityName: '测试测试',
  23. durationInMillis: '描述信息',
  24. endTime: '2022-01-02',
  25. comment: '同意',
  26. type: '2'
  27. },
  28. {
  29. assigneeName: '驳回',
  30. activityName: '测试测试',
  31. durationInMillis: '描述信息',
  32. endTime: '2022-01-02',
  33. comment: '同意',
  34. type: '3'
  35. },
  36. {
  37. assigneeName: '步骤四',
  38. activityName: '测试测试',
  39. durationInMillis: '描述信息',
  40. endTime: '2022-01-02',
  41. comment: '同意'
  42. },
  43. ],
  44. //事务总表对象
  45. item:{},
  46. detpId:187,
  47. itemId:13,
  48. active:0,
  49. result:[],
  50. show:false,
  51. showPopup:false,
  52. templateList:[],
  53. templateDetailList:[],
  54. groups:[],
  55. villages:[],
  56. towns:[],
  57. temName:"",
  58. temId:""
  59. },
  60. /**
  61. * 生命周期函数--监听页面加载
  62. */
  63. onLoad(options) {
  64. this.setData({itemId:options.id,deptId:options.deptId});
  65. console.log(options);
  66. //this.getApprovalItemList();
  67. this.groupList();
  68. this.townList();
  69. this.villageList();
  70. this.getApprovalItemsById();
  71. },
  72. getApprovalItemsById(){
  73. let _this = this
  74. let url = API.URL_GET_APPROVALITEMSBYID+this.data.itemId
  75. wx.request({
  76. url,
  77. method:"GET",
  78. timeout: 60000,
  79. header: {
  80. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  81. },
  82. success: function (response) {
  83. _this.setData({item:response.data.data})
  84. if(_this.data.item.templateId!=""&&_this.data.item.templateId!=null){
  85. _this.setData({item:response.data.data,temId:_this.data.itemId})
  86. let d = {
  87. templateId : _this.data.item.templateId,
  88. orderByColumn:"id",
  89. isAsc:"asc",
  90. method:"GET"
  91. }
  92. UTIL.httpRequest(API.URL_GET_TEMPLATEDETAIL, d, {
  93. success: (r) => {
  94. if (r.code == API.SUCCESS_CODE) {
  95. _this.setData({templateDetailList:r.rows});
  96. let list = []
  97. r.rows.map(rr => {
  98. list.push(rr.userId+"")
  99. })
  100. _this.setData({result:list})
  101. }
  102. }
  103. })
  104. }else {
  105. _this.getApprovalItemList()
  106. }
  107. }
  108. })
  109. },
  110. inputTem:function(e){
  111. this.setData({temName:e.detail.value})
  112. },
  113. confirmTem:function(e){
  114. let data={
  115. approvalTemplate:{
  116. name:this.data.temName,
  117. type:1,
  118. dataType:0
  119. },
  120. approvalTemplateDetailList:this.data.templateDetailList,
  121. method:"POST"
  122. }
  123. UTIL.httpRequest(API.URL_POST_MOBILEADD,data,{
  124. success: (res) => {
  125. if (res.code == API.SUCCESS_CODE) {
  126. let list = this.data.templateList
  127. list.push(res.data)
  128. this.setData({
  129. temId:res.data.id,
  130. templateList:list,
  131. temName:"",
  132. showPopup:false
  133. });
  134. }
  135. }
  136. })
  137. },
  138. cancelTem:function(e){
  139. this.setData({temName:"",showPopup:false});
  140. },
  141. upItem:function(e){
  142. let index = e.currentTarget.dataset.id
  143. let item = this.data.templateDetailList[index]
  144. let list = this.data.templateDetailList
  145. if(index>0&&index<=list.length){
  146. list.splice(index,1)
  147. list.splice(index-1,0,item)
  148. for(let i = 0;i< list.length;i++){
  149. list[i].name = i+1
  150. }
  151. this.setData({templateDetailList:list});
  152. }
  153. },
  154. downItem:function(e){
  155. let index = e.currentTarget.dataset.id
  156. let item = this.data.templateDetailList[index]
  157. let list = this.data.templateDetailList
  158. if(index>=0&&index<list.length){
  159. list.splice(index,1)
  160. list.splice(index+1,0,item)
  161. for(let i = 0;i< list.length;i++){
  162. list[i].name = i+1
  163. }
  164. this.setData({templateDetailList:list});
  165. }
  166. },
  167. getApprovalItemList:function(){
  168. let data={
  169. dataType:0,
  170. pageNum:1,
  171. pageSize:50,
  172. method:"GET"
  173. }
  174. UTIL.httpRequest(API.URL_GET_TEMPLATELIST, data, {
  175. success: (res) => {
  176. if (res.code == API.SUCCESS_CODE) {
  177. this.setData({templateList:res.rows});
  178. if(res.total>0){
  179. let d = {
  180. templateId : res.rows[0].id,
  181. orderByColumn:"id",
  182. isAsc:"asc",
  183. method:"GET"
  184. }
  185. UTIL.httpRequest(API.URL_GET_TEMPLATEDETAIL, d, {
  186. success: (r) => {
  187. if (r.code == API.SUCCESS_CODE) {
  188. this.setData({templateDetailList:r.rows});
  189. let list = []
  190. r.rows.map(rr => {
  191. list.push(rr.userId+"")
  192. })
  193. this.setData({result:list})
  194. }
  195. }
  196. })
  197. }
  198. }
  199. }
  200. })
  201. },
  202. chooseTemplate:function(e){
  203. let data = {
  204. templateId : e.currentTarget.dataset.id,
  205. orderByColumn:"id",
  206. isAsc:"asc",
  207. method:"GET"
  208. }
  209. UTIL.httpRequest(API.URL_GET_TEMPLATEDETAIL, data, {
  210. success: (res) => {
  211. if (res.code == API.SUCCESS_CODE) {
  212. this.setData({templateDetailList:res.rows});
  213. this.closeBox();
  214. }
  215. }
  216. })
  217. },
  218. deleteTemplate:function(e){
  219. let ids = [e.currentTarget.dataset.id]
  220. let url = API.URL_GET_MOBILEREMOVE+ids
  221. let _this = this
  222. wx.request({
  223. url,
  224. method:"GET",
  225. timeout: 60000,
  226. header: {
  227. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  228. },
  229. success: function (response) {
  230. _this.getApprovalItemList()
  231. }
  232. })
  233. },
  234. townList:function(){
  235. let _this = this
  236. let url = API.URL_GET_TOWNINFOBYDEPTID+0
  237. wx.request({
  238. url,
  239. method:"GET",
  240. timeout: 60000,
  241. header: {
  242. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  243. },
  244. success: function (response) {
  245. let d = {
  246. deptId:response.data.data.deptId,
  247. deptLevel:3,
  248. method:"GET"
  249. }
  250. UTIL.httpRequest(API.URL_GET_USERLIST,d,{
  251. success: (res) => {
  252. if (res.code == API.SUCCESS_CODE) {
  253. console.log(res);
  254. _this.setData({towns:res.rows});
  255. }
  256. }
  257. })
  258. }
  259. })
  260. },
  261. groupList:function(){
  262. let data = {
  263. deptId : this.data.deptId,
  264. deptLevel:1,
  265. method:"GET"
  266. }
  267. UTIL.httpRequest(API.URL_GET_USERLIST,data ,{
  268. success: (res) => {
  269. if (res.code == API.SUCCESS_CODE) {
  270. this.setData({groups:res.rows});
  271. }
  272. }
  273. })
  274. },
  275. villageList:function(){
  276. let data = {
  277. deptId : this.data.deptId,
  278. deptLevel:2,
  279. method:"GET"
  280. }
  281. UTIL.httpRequest(API.URL_GET_USERLIST,data ,{
  282. success: (res) => {
  283. if (res.code == API.SUCCESS_CODE) {
  284. this.setData({villages:res.rows});
  285. }
  286. }
  287. })
  288. },
  289. onChange(event) {
  290. let _this = this
  291. this.setData({result:event.detail})
  292. this.setData({templateDetailList:[]})
  293. let list = _this.data.templateDetailList
  294. for (let j in event.detail){
  295. let str = event.detail[j]
  296. for(let i in _this.data.groups){
  297. if(_this.data.groups[i].userId == str){
  298. let sin = _this.data.groups[i]
  299. list.push(sin)
  300. _this.setData({templateDetailList:list})
  301. }
  302. }
  303. for(let i in _this.data.villages){
  304. if(_this.data.villages[i].userId == str){
  305. let sin = _this.data.villages[i]
  306. list.push(sin)
  307. _this.setData({templateDetailList:list})
  308. }
  309. }
  310. for(let i in _this.data.towns){
  311. if(_this.data.towns[i].userId == str){
  312. let sin = _this.data.towns[i]
  313. list.push(sin)
  314. _this.setData({templateDetailList:list})
  315. }
  316. }
  317. }
  318. let li = this.data.templateDetailList
  319. li = li.filter(function(e,i,s){
  320. s[i].name = i+1
  321. return true
  322. })
  323. this.setData({templateDetailList:li})
  324. },
  325. back:function(){
  326. wx.navigateBack({
  327. delta: 1
  328. })
  329. },
  330. save:function(){
  331. let _this = this
  332. let list = this.data.templateDetailList
  333. list = list.filter(function(e,i,s){
  334. s[i].name = i+1
  335. return true
  336. })
  337. if(this.data.temId==""||this.data.temId==null){
  338. let data={
  339. approvalTemplate:{
  340. name:this.data.temName,
  341. type:1,
  342. dataType:1
  343. },
  344. approvalTemplateDetailList:list,
  345. method:"POST"
  346. }
  347. UTIL.httpRequest(API.URL_POST_MOBILEADD,data,{
  348. success: (res) => {
  349. if (res.code == API.SUCCESS_CODE) {
  350. let list = this.data.templateList
  351. list.push(res.data)
  352. this.setData({
  353. temId:res.data.id,
  354. templateList:list,
  355. temName:""
  356. });
  357. let item_ = this.data.item
  358. item_.templateId = res.data.id
  359. item_.method = "POST"
  360. UTIL.httpRequest(API.URL_POST_APPROVALITEMSEDIT,item_,{
  361. success: (res) => {
  362. if (res.code == API.SUCCESS_CODE) {
  363. wx.showToast({
  364. title: "暂存成功!",
  365. duration: 2000,
  366. icon:"success"
  367. })
  368. }
  369. }
  370. })
  371. }
  372. }
  373. })
  374. }else{
  375. let url = API.URL_POST_TEMPLATEEDIT
  376. wx.request({
  377. url,
  378. data: list,
  379. method:"POST",
  380. timeout: 60000,
  381. header: {
  382. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  383. },
  384. success: function (response) {
  385. wx.showToast({
  386. title: "暂存成功!",
  387. duration: 2000,
  388. icon:"success"
  389. })
  390. },
  391. })
  392. }
  393. },
  394. submit:function(){
  395. let _this = this
  396. if(this.data.temId==""||this.data.temId==null){
  397. let data={
  398. approvalTemplate:{
  399. name:this.data.temName,
  400. type:1,
  401. dataType:1
  402. },
  403. approvalTemplateDetailList:this.data.templateDetailList,
  404. method:"POST"
  405. }
  406. UTIL.httpRequest(API.URL_POST_MOBILEADD,data,{
  407. success: (res) => {
  408. if (res.code == API.SUCCESS_CODE) {
  409. let list = this.data.templateList
  410. list.push(res.data)
  411. this.setData({
  412. temId:res.data.id,
  413. templateList:list,
  414. temName:""
  415. });
  416. let item_ = this.data.item
  417. item_.templateId = res.data.id
  418. item_.method = "POST"
  419. UTIL.httpRequest(API.URL_POST_APPROVALITEMSEDIT,item_,{
  420. success: (res) => {
  421. if (res.code == API.SUCCESS_CODE) {
  422. _this.requestSubmit()
  423. }
  424. }
  425. })
  426. }
  427. }
  428. })
  429. }else{
  430. let url = API.URL_POST_TEMPLATEEDIT
  431. wx.request({
  432. url,
  433. data: _this.data.templateDetailList,
  434. method:"POST",
  435. timeout: 60000,
  436. header: {
  437. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  438. },
  439. success: function (response) {
  440. _this.requestSubmit()
  441. },
  442. })
  443. }
  444. },
  445. requestSubmit:function(){
  446. let url = API.URL_POST_APPROVALITEMSSUBMIT+this.data.item.id+"/"+this.data.item.templateId
  447. wx.request({
  448. url,
  449. method:"POST",
  450. timeout: 60000,
  451. header: {
  452. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  453. },
  454. success: function (r) {
  455. wx.showToast({
  456. title: "提交成功!",
  457. duration: 2000,
  458. icon:"success"
  459. })
  460. },
  461. })
  462. },
  463. openBox:function(){
  464. var that = this ;
  465. that.setData({
  466. show: true,
  467. })
  468. },
  469. closeBox:function(){
  470. var that = this ;
  471. that.setData({
  472. show: false
  473. })
  474. },
  475. showPopup() {
  476. this.setData({
  477. showPopup: true,
  478. temName:""
  479. });
  480. },
  481. onClose() {
  482. this.setData({ showPopup: false});
  483. },
  484. /**
  485. * 生命周期函数--监听页面初次渲染完成
  486. */
  487. onReady() {
  488. },
  489. /**
  490. * 生命周期函数--监听页面显示
  491. */
  492. onShow() {
  493. },
  494. /**
  495. * 生命周期函数--监听页面隐藏
  496. */
  497. onHide() {
  498. },
  499. /**
  500. * 生命周期函数--监听页面卸载
  501. */
  502. onUnload() {
  503. },
  504. /**
  505. * 页面相关事件处理函数--监听用户下拉动作
  506. */
  507. onPullDownRefresh() {
  508. },
  509. /**
  510. * 页面上拉触底事件的处理函数
  511. */
  512. onReachBottom() {
  513. },
  514. /**
  515. * 用户点击右上角分享
  516. */
  517. onShareAppMessage() {
  518. }
  519. })