123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528 |
- // StepPage/pages/first/first.js
- import Dialog from '../../../miniprogram_npm/@vant/weapp/dialog/dialog';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- show_m:false,
- shopList:[],
- storehouseList:[],
- set_status:'',
- searchList:[],
- searchListC:[],
- searchValue:'',
- searchValueC:"",
- show:false,
- show_c:false,
- title_c:"",
- title:'',
- type:'',
- is_check:0,
- status:0,
- oa_state:'',
- oa_remark:'',
- oa_state_m:'',
- is_o:true
- },
- handleChangeRemark(e){
- this.setData({
- oa_remark:e.detail
- })
- },
- onSure() {
- let app = getApp();
- let openid = app.globalData.openID;
- if (this.data.is_o) {
- this.setData({
- is_o:false
- })
- let data = {
- id:app.globalData.oa_id,
- state:this.data.oa_state_m,
- remark:this.data.oa_remark
- }
- wx.p.request({
- url: `${app.globalData.url}wx/oaCheck`,
- method:'POST',
- data:{
- openid,
- ...data
- }
- }).then(res=>{
- if(res.data.code === 200){
-
- this.setData({ show_m: false });
- this.initData()
- if(this.data.oa_state_m){
- this.handleReturn();
- }
- }
- wx.showToast({
- icon:'none',
- title: res.data.msg,
- })
- setTimeout(()=>{
- this.setData({
- is_o:true
- })
- },2000)
- })
- }
- },
- initData(){
- let app = getApp();
- let openid = app.globalData.openID;
- let order_number = app.globalData.detailData.order_number;
- if(app.globalData.typePage==1){
- wx.p.request({
- url: `${app.globalData.url}wx/constructionDetail`,
- method:'POST',
- data:{
- order_number,
- openid
- }
- }).then(res1=>{
- if(res1.data.code==200){
- this.setData({
- status:res1.data.data.status
- })
- app.globalData.detailData.status = res1.data.data.status;
- if ( res1.data.data.status === 1 ) {
- wx.p.request({
- url: `${app.globalData.url}wx/oaOrderState`,
- method:'POST',
- data:{
- menu_id:224,
- order_no:res1.data.data.order_number,
- openid
- }
- }).then(req=>{
- if (req.data.code==200) {
- app.globalData.oa_state = req.data.data.state;
- app.globalData.oa_id = req.data.data.id
- }else{
- app.globalData.oa_state = '';
- app.globalData.oa_id = ''
- }
- this.setData({
- oa_state:app.globalData.oa_state
- })
- })
- }
- }
- })
- }else{
- wx.p.request({
- url: `${app.globalData.url}wx/inventoryDetail`,
- method:'POST',
- data:{
- order_number,
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- this.setData({
- status:res1.data.data.status
- })
- app.globalData.detailData.status = res1.data.data.status;
- if(res.data.data.status==1){
- wx.p.request({
- url: `${app.globalData.url}wx/oaOrderState`,
- method:'POST',
- data:{
- menu_id:249,
- order_no:res.data.data.order_number,
- openid
- }
- }).then(req=>{
- if (req.data.code==200) {
- app.globalData.oa_state = req.data.data.state;
- app.globalData.oa_id = req.data.data.id
- }else{
- app.globalData.oa_state = '';
- app.globalData.oa_id = ''
- }
- })
- }
- }
- })
- }
- },
- onClose() {
- this.setData({
- show_m: false,
- // oa_remark:''
- });
- },
- handleSearch(){
- this.setData({
- show:true,
- searchList:this.data.shopList
- })
- },
- handleSearchC(){
- this.setData({
- show_c:true,
- searchListC:this.data.storehouseList
- })
- },
- handleCancel(){
- this.setData({
- show:false
- })
- },
- handleCancelC(){
- this.setData({
- show_c:false
- })
- },
- onSearch(event){
- let arr = this.data.shopList.filter(v=>v.title.indexOf(event.detail)!=-1);
- this.setData({
- searchList:arr
- })
- },
- onSearchC(event){
- let arr = this.data.storehouseList.filter(v=>v.title.indexOf(event.detail)!=-1);
- this.setData({
- searchListC:arr
- })
- },
- handleReturn(){
- let app = getApp();
- app.globalData.fourShopId = '';
- app.globalData.storehouse_id = '';
- app.globalData.address = '';
- app.globalData.area = '';
- app.globalData.contract_person = '';
- app.globalData.contract_phone = '';
- app.globalData.regional_manager = '';
- app.globalData.technical_manager ='';
- app.globalData.company_id = '';
- if(this.data.set_status&&app.globalData.typePage==1){
- app.globalData.set_status = '';
- wx.redirectTo({
- url: '../report/ShiList/ShiList',
- })
- }else if(this.data.set_status&&app.globalData.typePage==2){
- app.globalData.set_status = '';
- wx.redirectTo({
- url:'../report/PanList/PanList'
- })
- }else{
- wx.redirectTo({
- url: '../../../pages/zero/zero',
- })
- }
- },
- handleCheck(){
- Dialog.confirm({
- title: '审核',
- message: '确认审核吗?',
- })
- .then(() => {
- let app = getApp();
- let openid = app.globalData.openID;
- if(app.globalData.typePage==1){
- wx.p.request({
- url: `${app.globalData.url}wx/checkAll`,
- method:'POST',
- data:{
- order_number:app.globalData.detailData.order_number,
- openid,
- opt_case: 5,
- menu_id:224
- }
- }).then(res=>{
- if(res.data.code==200){
- wx.showToast({
- title: res.data.msg
- })
- this.initData()
- }else{
- wx.showModal({
- content: res.data.msg,
- showCancel:false,
- confirmText:'返回'
- })
- }
- })
- }else if(app.globalData.typePage==2){
- wx.p.request({
- url: `${app.globalData.url}wx/checkAll`,
- method:'POST',
- data:{
- order_number:app.globalData.detailData.order_number,
- openid,
- opt_case: 10,
- menu_id:249
- }
- }).then(res=>{
- if(res.data.code==200){
- wx.showToast({
- title: res.data.msg
- })
- this.initData()
- }else{
- wx.showModal({
- content: res.data.msg,
- showCancel:false,
- confirmText:'返回'
- })
- }
- })
- }
- })
- .catch(() => {
- // on cancel
- });
- },
- handlePassModal(e){
- this.setData({
- show_m:true,
- oa_state_m:e.currentTarget.dataset.item
- })
- },
- handleNext(){
- let app = getApp()
- if(!app.globalData.storehouse_id){
- return
- }
- if(this.data.type==2){
- wx.redirectTo({
- url: '../pan/pan',
- })
- }else{
- if(this.data.title){
- let app = getApp();
- if(app.globalData.set_status){
- if(app.globalData.typePage==1){
- wx.redirectTo({
- url: '../second/second',
- })
- }else if(app.globalData.typePage==4){
- wx.redirectTo({
- url: '../tui/tui',
- })
- }
- }else{
- if(app.globalData.typePage==1){
- let openid = app.globalData.openID;
- app.globalData.stepData = app.globalData.stepData.filter(v=>v.sort!=1);
- app.globalData.stepData=[{
- sort:1,
- data:{
- title:this.data.title
- }
- }]
- wx.p.request({
- url: `${app.globalData.url}wx/saveWxConstructionData`,
- method:'POST',
- data:{
- openid,
- type:1,
- data:JSON.stringify(app.globalData)
- }
- }).then(res=>{
- if(res.data.code==200){
- wx.redirectTo({
- url: '../second/second',
- })
- }
- })
- }else if(app.globalData.typePage==4){
- wx.redirectTo({
- url: '../tui/tui',
- })
- }
- }
- }
- }
- },
- handleChoose(item){
- let app = getApp();
- app.globalData.fourShopId = item.target.dataset.item.id;
- app.globalData.storehouse_id = item.target.dataset.item.storehouse_id;
- app.globalData.address = item.target.dataset.item.address;
- app.globalData.area = item.target.dataset.item.area;
- app.globalData.contract_person = item.target.dataset.item.contract_person;
- app.globalData.contract_phone = item.target.dataset.item.contract_phone;
- app.globalData.regional_manager = item.target.dataset.item.regional_manager;
- app.globalData.technical_manager = item.target.dataset.item.technical_manager;
- app.globalData.company_id = item.target.dataset.item.company_id;
- this.setData({
- show:false,
- title:item.target.dataset.item.title
- })
- },
- handleChooseC(item){
- let app = getApp();
- app.globalData.storehouse_id = item.target.dataset.item.id;
- app.globalData.title_c = item.target.dataset.item.title;
- this.setData({
- show_c:false,
- title_c:item.target.dataset.item.title
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let app = getApp();
- let openid = app.globalData.openID;
- this.setData({
- type:app.globalData.typePage
- })
- if(app.globalData.typePage==2){
- wx.p.request({
- url: `${app.globalData.url}wx/storehouseList`,
- method:'POST',
- data:{
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- let storehouseList = res.data.data.data
- this.setData({
- storehouseList:storehouseList,
- set_status:app.globalData.set_status?app.globalData.set_status:''
- })
- if(app.globalData.set_status){
- app.globalData.storehouse_id = app.globalData.detailData.storehouse_id;
- this.setData({
- is_check: app.globalData.detailData.is_check,
- status:app.globalData.detailData.status,
- oa_state:app.globalData.oa_state?app.globalData.oa_state:''
- })
- console.log(this.data)
- }
- if(app.globalData.storehouse_id){
- this.setData({
- title_c:this.data.storehouseList.find(v=>v.id==app.globalData.storehouse_id).title
- })
- }
- }
- })
- }else{
- wx.p.request({
- url: `${app.globalData.url}wx/fourShop`,
- method:'POST',
- data:{
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- let shopList = res.data.data
- this.setData({
- shopList:shopList
- })
- if((app.globalData.typePage==3||app.globalData.typePage==4)&&app.globalData.fourShopId){
- this.setData({
- title:this.data.shopList.find(v=>v.id==app.globalData.fourShopId).title
- })
- }
- }
- })
- }
- if(app.globalData.typePage==1){
- if(app.globalData.set_status){
- app.globalData.fourShopId = app.globalData.detailData.four_shop_id;
- app.globalData.storehouse_id = app.globalData.detailData.storehouse_id;
- app.globalData.address = app.globalData.detailData.address;
- app.globalData.area = app.globalData.detailData.area;
- app.globalData.contract_person = app.globalData.detailData.contract_person;
- app.globalData.contract_phone = app.globalData.detailData.contract_phone;
- app.globalData.regional_manager = app.globalData.detailData.regional_manager;
- app.globalData.technical_manager = app.globalData.detailData.technical_manager;
- app.globalData.company_id = app.globalData.detailData.company_id;
- this.setData({
- title:app.globalData.detailData.four_shop_name,
- set_status : app.globalData.set_status,
- is_check: app.globalData.detailData.is_check,
- status:app.globalData.detailData.status,
- oa_state:app.globalData.oa_state?app.globalData.oa_state:''
- })
- }else{
- this.setData({
- set_status : ''
- })
- //获取缓存
- wx.p.request({
- url: `${app.globalData.url}wx/getWxConstructionData`,
- method:'POST',
- data:{
- type:1,
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- if(res.data.data.data){
- let data = JSON.parse(res.data.data.data);
- let box = data.stepData.find(v=>v.sort==1);
- app.globalData = data;
- app.globalData.typePage =1;
- app.globalData.set_status = '';
- if(box){
- this.setData({
- title:box.data.title,
- set_status:''
- })
- }
- }
- }
- })
- }
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|