first.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. // StepPage/pages/first/first.js
  2. import Dialog from '../../../miniprogram_npm/@vant/weapp/dialog/dialog';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. show_m:false,
  9. shopList:[],
  10. storehouseList:[],
  11. set_status:'',
  12. searchList:[],
  13. searchListC:[],
  14. searchValue:'',
  15. searchValueC:"",
  16. show:false,
  17. show_c:false,
  18. title_c:"",
  19. title:'',
  20. type:'',
  21. is_check:0,
  22. status:0,
  23. oa_state:'',
  24. oa_remark:'',
  25. oa_state_m:'',
  26. is_o:true
  27. },
  28. handleChangeRemark(e){
  29. this.setData({
  30. oa_remark:e.detail
  31. })
  32. },
  33. onSure() {
  34. let app = getApp();
  35. let openid = app.globalData.openID;
  36. if (this.data.is_o) {
  37. this.setData({
  38. is_o:false
  39. })
  40. let data = {
  41. id:app.globalData.oa_id,
  42. state:this.data.oa_state_m,
  43. remark:this.data.oa_remark
  44. }
  45. wx.p.request({
  46. url: `${app.globalData.url}wx/oaCheck`,
  47. method:'POST',
  48. data:{
  49. openid,
  50. ...data
  51. }
  52. }).then(res=>{
  53. if(res.data.code === 200){
  54. this.setData({ show_m: false });
  55. this.initData()
  56. if(this.data.oa_state_m){
  57. this.handleReturn();
  58. }
  59. }
  60. wx.showToast({
  61. icon:'none',
  62. title: res.data.msg,
  63. })
  64. setTimeout(()=>{
  65. this.setData({
  66. is_o:true
  67. })
  68. },2000)
  69. })
  70. }
  71. },
  72. initData(){
  73. let app = getApp();
  74. let openid = app.globalData.openID;
  75. let order_number = app.globalData.detailData.order_number;
  76. if(app.globalData.typePage==1){
  77. wx.p.request({
  78. url: `${app.globalData.url}wx/constructionDetail`,
  79. method:'POST',
  80. data:{
  81. order_number,
  82. openid
  83. }
  84. }).then(res1=>{
  85. if(res1.data.code==200){
  86. this.setData({
  87. status:res1.data.data.status
  88. })
  89. app.globalData.detailData.status = res1.data.data.status;
  90. if ( res1.data.data.status === 1 ) {
  91. wx.p.request({
  92. url: `${app.globalData.url}wx/oaOrderState`,
  93. method:'POST',
  94. data:{
  95. menu_id:224,
  96. order_no:res1.data.data.order_number,
  97. openid
  98. }
  99. }).then(req=>{
  100. if (req.data.code==200) {
  101. app.globalData.oa_state = req.data.data.state;
  102. app.globalData.oa_id = req.data.data.id
  103. }else{
  104. app.globalData.oa_state = '';
  105. app.globalData.oa_id = ''
  106. }
  107. this.setData({
  108. oa_state:app.globalData.oa_state
  109. })
  110. })
  111. }
  112. }
  113. })
  114. }else{
  115. wx.p.request({
  116. url: `${app.globalData.url}wx/inventoryDetail`,
  117. method:'POST',
  118. data:{
  119. order_number,
  120. openid
  121. }
  122. }).then(res=>{
  123. if(res.data.code==200){
  124. this.setData({
  125. status:res1.data.data.status
  126. })
  127. app.globalData.detailData.status = res1.data.data.status;
  128. if(res.data.data.status==1){
  129. wx.p.request({
  130. url: `${app.globalData.url}wx/oaOrderState`,
  131. method:'POST',
  132. data:{
  133. menu_id:249,
  134. order_no:res.data.data.order_number,
  135. openid
  136. }
  137. }).then(req=>{
  138. if (req.data.code==200) {
  139. app.globalData.oa_state = req.data.data.state;
  140. app.globalData.oa_id = req.data.data.id
  141. }else{
  142. app.globalData.oa_state = '';
  143. app.globalData.oa_id = ''
  144. }
  145. })
  146. }
  147. }
  148. })
  149. }
  150. },
  151. onClose() {
  152. this.setData({
  153. show_m: false,
  154. // oa_remark:''
  155. });
  156. },
  157. handleSearch(){
  158. this.setData({
  159. show:true,
  160. searchList:this.data.shopList
  161. })
  162. },
  163. handleSearchC(){
  164. this.setData({
  165. show_c:true,
  166. searchListC:this.data.storehouseList
  167. })
  168. },
  169. handleCancel(){
  170. this.setData({
  171. show:false
  172. })
  173. },
  174. handleCancelC(){
  175. this.setData({
  176. show_c:false
  177. })
  178. },
  179. onSearch(event){
  180. let arr = this.data.shopList.filter(v=>v.title.indexOf(event.detail)!=-1);
  181. this.setData({
  182. searchList:arr
  183. })
  184. },
  185. onSearchC(event){
  186. let arr = this.data.storehouseList.filter(v=>v.title.indexOf(event.detail)!=-1);
  187. this.setData({
  188. searchListC:arr
  189. })
  190. },
  191. handleReturn(){
  192. let app = getApp();
  193. app.globalData.fourShopId = '';
  194. app.globalData.storehouse_id = '';
  195. app.globalData.address = '';
  196. app.globalData.area = '';
  197. app.globalData.contract_person = '';
  198. app.globalData.contract_phone = '';
  199. app.globalData.regional_manager = '';
  200. app.globalData.technical_manager ='';
  201. app.globalData.company_id = '';
  202. if(this.data.set_status&&app.globalData.typePage==1){
  203. app.globalData.set_status = '';
  204. wx.redirectTo({
  205. url: '../report/ShiList/ShiList',
  206. })
  207. }else if(this.data.set_status&&app.globalData.typePage==2){
  208. app.globalData.set_status = '';
  209. wx.redirectTo({
  210. url:'../report/PanList/PanList'
  211. })
  212. }else{
  213. wx.redirectTo({
  214. url: '../../../pages/zero/zero',
  215. })
  216. }
  217. },
  218. handleCheck(){
  219. Dialog.confirm({
  220. title: '审核',
  221. message: '确认审核吗?',
  222. })
  223. .then(() => {
  224. let app = getApp();
  225. let openid = app.globalData.openID;
  226. if(app.globalData.typePage==1){
  227. wx.p.request({
  228. url: `${app.globalData.url}wx/checkAll`,
  229. method:'POST',
  230. data:{
  231. order_number:app.globalData.detailData.order_number,
  232. openid,
  233. opt_case: 5,
  234. menu_id:224
  235. }
  236. }).then(res=>{
  237. if(res.data.code==200){
  238. wx.showToast({
  239. title: res.data.msg
  240. })
  241. this.initData()
  242. }else{
  243. wx.showModal({
  244. content: res.data.msg,
  245. showCancel:false,
  246. confirmText:'返回'
  247. })
  248. }
  249. })
  250. }else if(app.globalData.typePage==2){
  251. wx.p.request({
  252. url: `${app.globalData.url}wx/checkAll`,
  253. method:'POST',
  254. data:{
  255. order_number:app.globalData.detailData.order_number,
  256. openid,
  257. opt_case: 10,
  258. menu_id:249
  259. }
  260. }).then(res=>{
  261. if(res.data.code==200){
  262. wx.showToast({
  263. title: res.data.msg
  264. })
  265. this.initData()
  266. }else{
  267. wx.showModal({
  268. content: res.data.msg,
  269. showCancel:false,
  270. confirmText:'返回'
  271. })
  272. }
  273. })
  274. }
  275. })
  276. .catch(() => {
  277. // on cancel
  278. });
  279. },
  280. handlePassModal(e){
  281. this.setData({
  282. show_m:true,
  283. oa_state_m:e.currentTarget.dataset.item
  284. })
  285. },
  286. handleNext(){
  287. let app = getApp()
  288. if(!app.globalData.storehouse_id){
  289. return
  290. }
  291. if(this.data.type==2){
  292. wx.redirectTo({
  293. url: '../pan/pan',
  294. })
  295. }else{
  296. if(this.data.title){
  297. let app = getApp();
  298. if(app.globalData.set_status){
  299. if(app.globalData.typePage==1){
  300. wx.redirectTo({
  301. url: '../second/second',
  302. })
  303. }else if(app.globalData.typePage==4){
  304. wx.redirectTo({
  305. url: '../tui/tui',
  306. })
  307. }
  308. }else{
  309. if(app.globalData.typePage==1){
  310. let openid = app.globalData.openID;
  311. app.globalData.stepData = app.globalData.stepData.filter(v=>v.sort!=1);
  312. app.globalData.stepData=[{
  313. sort:1,
  314. data:{
  315. title:this.data.title
  316. }
  317. }]
  318. wx.p.request({
  319. url: `${app.globalData.url}wx/saveWxConstructionData`,
  320. method:'POST',
  321. data:{
  322. openid,
  323. type:1,
  324. data:JSON.stringify(app.globalData)
  325. }
  326. }).then(res=>{
  327. if(res.data.code==200){
  328. wx.redirectTo({
  329. url: '../second/second',
  330. })
  331. }
  332. })
  333. }else if(app.globalData.typePage==4){
  334. wx.redirectTo({
  335. url: '../tui/tui',
  336. })
  337. }
  338. }
  339. }
  340. }
  341. },
  342. handleChoose(item){
  343. let app = getApp();
  344. app.globalData.fourShopId = item.target.dataset.item.id;
  345. app.globalData.storehouse_id = item.target.dataset.item.storehouse_id;
  346. app.globalData.address = item.target.dataset.item.address;
  347. app.globalData.area = item.target.dataset.item.area;
  348. app.globalData.contract_person = item.target.dataset.item.contract_person;
  349. app.globalData.contract_phone = item.target.dataset.item.contract_phone;
  350. app.globalData.regional_manager = item.target.dataset.item.regional_manager;
  351. app.globalData.technical_manager = item.target.dataset.item.technical_manager;
  352. app.globalData.company_id = item.target.dataset.item.company_id;
  353. this.setData({
  354. show:false,
  355. title:item.target.dataset.item.title
  356. })
  357. },
  358. handleChooseC(item){
  359. let app = getApp();
  360. app.globalData.storehouse_id = item.target.dataset.item.id;
  361. app.globalData.title_c = item.target.dataset.item.title;
  362. this.setData({
  363. show_c:false,
  364. title_c:item.target.dataset.item.title
  365. })
  366. },
  367. /**
  368. * 生命周期函数--监听页面加载
  369. */
  370. onLoad(options) {
  371. let app = getApp();
  372. let openid = app.globalData.openID;
  373. this.setData({
  374. type:app.globalData.typePage
  375. })
  376. if(app.globalData.typePage==2){
  377. wx.p.request({
  378. url: `${app.globalData.url}wx/storehouseList`,
  379. method:'POST',
  380. data:{
  381. openid
  382. }
  383. }).then(res=>{
  384. if(res.data.code==200){
  385. let storehouseList = res.data.data.data
  386. this.setData({
  387. storehouseList:storehouseList,
  388. set_status:app.globalData.set_status?app.globalData.set_status:''
  389. })
  390. if(app.globalData.set_status){
  391. app.globalData.storehouse_id = app.globalData.detailData.storehouse_id;
  392. this.setData({
  393. is_check: app.globalData.detailData.is_check,
  394. status:app.globalData.detailData.status,
  395. oa_state:app.globalData.oa_state?app.globalData.oa_state:''
  396. })
  397. console.log(this.data)
  398. }
  399. if(app.globalData.storehouse_id){
  400. this.setData({
  401. title_c:this.data.storehouseList.find(v=>v.id==app.globalData.storehouse_id).title
  402. })
  403. }
  404. }
  405. })
  406. }else{
  407. wx.p.request({
  408. url: `${app.globalData.url}wx/fourShop`,
  409. method:'POST',
  410. data:{
  411. openid
  412. }
  413. }).then(res=>{
  414. if(res.data.code==200){
  415. let shopList = res.data.data
  416. this.setData({
  417. shopList:shopList
  418. })
  419. if((app.globalData.typePage==3||app.globalData.typePage==4)&&app.globalData.fourShopId){
  420. this.setData({
  421. title:this.data.shopList.find(v=>v.id==app.globalData.fourShopId).title
  422. })
  423. }
  424. }
  425. })
  426. }
  427. if(app.globalData.typePage==1){
  428. if(app.globalData.set_status){
  429. app.globalData.fourShopId = app.globalData.detailData.four_shop_id;
  430. app.globalData.storehouse_id = app.globalData.detailData.storehouse_id;
  431. app.globalData.address = app.globalData.detailData.address;
  432. app.globalData.area = app.globalData.detailData.area;
  433. app.globalData.contract_person = app.globalData.detailData.contract_person;
  434. app.globalData.contract_phone = app.globalData.detailData.contract_phone;
  435. app.globalData.regional_manager = app.globalData.detailData.regional_manager;
  436. app.globalData.technical_manager = app.globalData.detailData.technical_manager;
  437. app.globalData.company_id = app.globalData.detailData.company_id;
  438. this.setData({
  439. title:app.globalData.detailData.four_shop_name,
  440. set_status : app.globalData.set_status,
  441. is_check: app.globalData.detailData.is_check,
  442. status:app.globalData.detailData.status,
  443. oa_state:app.globalData.oa_state?app.globalData.oa_state:''
  444. })
  445. }else{
  446. this.setData({
  447. set_status : ''
  448. })
  449. //获取缓存
  450. wx.p.request({
  451. url: `${app.globalData.url}wx/getWxConstructionData`,
  452. method:'POST',
  453. data:{
  454. type:1,
  455. openid
  456. }
  457. }).then(res=>{
  458. if(res.data.code==200){
  459. if(res.data.data.data){
  460. let data = JSON.parse(res.data.data.data);
  461. let box = data.stepData.find(v=>v.sort==1);
  462. app.globalData = data;
  463. app.globalData.typePage =1;
  464. app.globalData.set_status = '';
  465. if(box){
  466. this.setData({
  467. title:box.data.title,
  468. set_status:''
  469. })
  470. }
  471. }
  472. }
  473. })
  474. }
  475. }
  476. },
  477. /**
  478. * 生命周期函数--监听页面初次渲染完成
  479. */
  480. onReady() {
  481. },
  482. /**
  483. * 生命周期函数--监听页面显示
  484. */
  485. onShow() {
  486. },
  487. /**
  488. * 生命周期函数--监听页面隐藏
  489. */
  490. onHide() {
  491. },
  492. /**
  493. * 生命周期函数--监听页面卸载
  494. */
  495. onUnload() {
  496. },
  497. /**
  498. * 页面相关事件处理函数--监听用户下拉动作
  499. */
  500. onPullDownRefresh() {
  501. },
  502. /**
  503. * 页面上拉触底事件的处理函数
  504. */
  505. onReachBottom() {
  506. },
  507. /**
  508. * 用户点击右上角分享
  509. */
  510. onShareAppMessage() {
  511. }
  512. })