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

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