123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712 |
- let Util = require("../../utils/util");
- Page({
-
- data: {
- images: [],
- signs: [],
- submitting:false,
- worksheetinfo: {},
- chargstations: [],
- chargstationsindex: 0,
- pcitures: [],
- workstatus: [{
- value: 1,
- text: '新建'
- }, {
- value: 2,
- text: '指派人员'
- }, {
- value: 3,
- text: '指派确认'
- }, {
- value: 4,
- text: '施工前安全准备'
- }, {
- value: 5,
- text: '进行中'
- }
- , {
- value: 6,
- text: '完成工作内容'
- }
-
-
-
-
- ],
- workstatusindex: 1,
- workBigclass: [{
- value: 1,
- text: '售后服务'
- }, {
- value: 2,
- text: '工程实施'
- }],
- workBigclassindex: 1,
- wokSmallclass:[{
- value: 1,
- text: '日常巡站'
- }, {
- value: 2,
- text: '紧急维修'
- }, {
- value: 3,
- text: '施工准备'
- }, {
- value: 4,
- text: '工程进程'
- }, {
- value: 5,
- text: '施工过程'
- }, {
- value: 6,
- text: '工程竣工'
- }, {
- value: 7,
- text: '工程验收'
- }],
- wokSmallclassIndex: 1,
- breakdownType: [{
- value: 1,
- text: '车辆导致'
- }, {
- value: 2,
- text: '桩体导致'
- }, {
- value: 3,
- text: '人为导致'
- }, {
- value: 4,
- text: '基础设施问题'
- }, {
- value: 5,
- text: '其他'
- }],
- breakdownTypeindex: 0,
- exceptdate: null,
- excepttime: '00:00',
- exceptparams:{
- placeholder: '请选择时间',
- startDateTime: '2020-01-01 00:00',
- endDateTime: '2040-01-01 00:00',
- pText: Util.formatTimePicker(new Date())
- },
- workEndtimeParams:{
- placeholder: '请选择时间',
- startDateTime: '2020-01-01 00:00',
- endDateTime: '2040-01-01 00:00',
- pText: Util.formatTimePicker(new Date())
-
- },
- finishdate: null,
- finishtime: '00:00',
- accendantids: [],
- userNames:[],
- chargStationName:'',
- chargStationNameClearFlag: true
- },
- bindChargstationsChange: function(e) {
- if (this.data.chargstationsindex != e.detail.value) {
- console.log('picker发送选择改变,携带值为', e.detail.value)
- let chargstationid = this.data.chargstations[e.detail.value].id;
- let worksheetinfo = this.data.worksheetinfo;
- worksheetinfo.accendant = null;
- worksheetinfo.chargStationId = chargstationid;
- this.setData({
- chargstationsindex: e.detail.value,
- worksheetinfo
- })
- }
- },
- bindWorkstatusChange: function(e) {
-
- let workStatus = this.data.workstatus[e.detail.value].value;
- let worksheetinfo = this.data.worksheetinfo;
- worksheetinfo.workStatus = workStatus;
- this.setData({
- workstatusindex: e.detail.value,
- worksheetinfo
- });
- },
- bindWorkBigclassChange: function(e) {
-
- let workBigclass = this.data.workBigclass[e.detail.value].value;
- let worksheetinfo = this.data.worksheetinfo;
- worksheetinfo.workBigclass = workBigclass;
- this.setData({
- workBigclassindex: e.detail.value,
- worksheetinfo
- });
- },
- bindwokSmallclassChange: function(e) {
-
- let wokSmallclass = this.data.wokSmallclass[e.detail.value].value;
- let worksheetinfo = this.data.worksheetinfo;
- worksheetinfo.wokSmallclass = wokSmallclass;
- this.setData({
- wokSmallclassindex: e.detail.value,
- worksheetinfo
- });
- },
- bindBreakdownType(e) {
-
- let breakdownType = this.data.breakdownType[e.detail.value].value;
- let worksheetinfo = this.data.worksheetinfo;
- worksheetinfo.breakdownType = breakdownType;
- this.setData({
- breakdownTypeindex: e.detail.value,
- worksheetinfo
- });
- },
- chargStationNameSelect:function(e){
- let url = `/pages/worksheetinfo/findstation`;
- wx.navigateTo({
- url
- });
- },
- bindAccendantChange: function(e) {
- let accendant = this.data.worksheetinfo.accendant;
- let chargStationId = this.data.worksheetinfo.chargStationId==null?0:this.data.worksheetinfo.chargStationId;
- let url = `/pages/worksheetinfo/accendant?chargstationid=${chargStationId}&accendant=${accendant}`;
- wx.navigateTo({
- url
- });
- },
-
-
-
-
-
-
-
-
-
-
- bindFinishdateChange(e) {
- this.setData({
- finishdate: e.detail.value
- })
- },
- bindFinishtimeChange(e) {
- this.setData({
- finishtime: e.detail.value
- })
- },
- bindMainLocationInput(e) {
- console.log(e);
- let mainLocation = e.detail.value;
- let worksheetinfo = this.data.worksheetinfo;
- worksheetinfo.mainLocation = mainLocation;
- this.setData({
- worksheetinfo
- });
- },
- bindAccendantInput(e){
- let accendant = e.detail.value;
- this.setData({
- "worksheetinfo.accendant":accendant
- });
- },
- bindContentInput(e) {
- let content = e.detail.value;
-
-
- this.setData({
- "worksheetinfo.content":content
- });
- },
- bindWorkSheetSubmit(e) {
- let worksheetinfo = this.data.worksheetinfo;
- worksheetinfo.operatorName = this.data.userNames.length>0?this.data.userNames[0]:"";
- worksheetinfo.pams = this.data.accendantids;
- console.info(this.data.accendantids)
- console.log("783756349857235");
-
- if (this.data.submitting) {
- return;
- }
-
-
-
-
-
-
- worksheetinfo.exceptTime = this.data.exceptparams.pText + ":00";
-
-
-
-
- worksheetinfo.workEndtime = this.data.workEndtimeParams.pText == '0000-00-00 00:00'? null : this.data.workEndtimeParams.pText + ":00";
- console.info(worksheetinfo.exceptTime + ":00")
- console.info(worksheetinfo.finishTime + ":00")
- let images = this.data.images;
- var imgString = [];
-
- var pciString = [];
- this.data.pcitures.forEach((item, index) =>{
- pciString.push(item.src);
- });
- if(worksheetinfo.mainLocation == '' || worksheetinfo.mainLocation == undefined){
- wx.showModal({
- showCancel: false,
- content: '地址不能为空,请填写!',
- confirmColor:'#00AADD',
- });
- return;
- }
-
-
-
-
-
-
-
-
- if(worksheetinfo.accendant == '' || worksheetinfo.accendant == undefined){
- wx.showModal({
- showCancel: false,
- content: '运维人员不能为空,请填写!',
- confirmColor:'#00AADD',
- });
- return;
- }
- if(worksheetinfo.content == '' || worksheetinfo.content == undefined){
- wx.showModal({
- showCancel: false,
- content: '工作内容不能为空,请填写!',
- confirmColor:'#00AADD',
- });
- return;
- }
- let signs = this.data.signs;
- console.log(signs.length == 0);
- let that = this
- var signString = [];
- if (signs.length == 0) {
-
-
-
-
-
-
-
-
-
- } else {
- signs.forEach((item, index) => {
- wx.uploadFile({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/editWorkSheetImg',
- filePath: signs[index],
- name: 'imageFileName',
- success: function(res) {
- let result = JSON.parse(res.data);
- if (result.code == 500) {
- wx.showModal({
- showCancel: false,
- content: result.msg,
- confirmColor:'#00AADD',
- });
- } else {
- signString.push(result.msg);
- console.log(signString);
- }
- }
- });
- });
- }
- var uploadSignOverFlag = setInterval(function() {
- if (signString.length == signs.length) {
- clearInterval(uploadSignOverFlag);
-
- that.setData({
- submitting: true
- });
- console.log("1111");
- console.log(that.data.submitting);
- if (images.length == 0) {
- if (worksheetinfo.pciture) {
- console.log(worksheetinfo.pciture);
- worksheetinfo.pciture = (pciString.concat(imgString).concat(signString)).join(",");
-
- console.log(worksheetinfo.pciture);
- }
- wx.showLoading({
- title: '提交中...',
- })
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/saveWorkSheet',
- data: worksheetinfo,
- method: 'POST',
- success(res) {
-
- if (res.data.code == 500) {
- wx.showModal({
- showCancel: false,
- content: res.data.msg,
- confirmColor:'#00AADD',
- });
- } else {
- wx.navigateBack();
- wx.hideLoading()
-
- that.setData({
- submitting: false
- });
- }
- }
- });
- } else {
- images.forEach((item, index) => {
- wx.uploadFile({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/editWorkSheetImg',
- filePath: images[index],
- name: 'imageFileName',
- success: function(res) {
- let result = JSON.parse(res.data);
- if (result.code == 500) {
- wx.showModal({
- showCancel: false,
- content: result.msg,
- confirmColor:'#00AADD',
- });
- } else {
- imgString.push(result.msg);
- console.log(imgString);
- if (index == (images.length - 1)) {
- var uploadImgOverFlag = setInterval(function() {
- if (imgString.length == images.length) {
- clearInterval(uploadImgOverFlag);
-
- worksheetinfo.pciture = (pciString.concat(imgString).concat(signString)).join(",");
-
- wx.showLoading({title: "提交中...."})
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/saveWorkSheet',
- data: worksheetinfo,
- method: 'POST',
- success(res) {
-
- if (res.data.code == 500) {
- wx.showModal({
- showCancel: false,
- content: res.data.msg,
- confirmColor:'#00AADD',
- });
- } else {
- wx.navigateBack();
- wx.hideLoading()
-
- that.setData({
- submitting: false
- });
- }
- }
- });
- }
- }, 100);
- }
- }
- },
- fail: function(data) {
- console.log(data);
- }
- });
- });
- }
- }
- }, 100);
- },
- openImage(e) {
-
- var imgCount = (9 - this.data.pcitures.length) < 0 ? 0 : 9 - this.data.pcitures.length;
- console.log(imgCount);
- wx.chooseImage({
- count: 9 - (this.data.pcitures.length + this.data.images.length),
-
-
- success: res => {
-
- var images = this.data.images.concat(res.tempFilePaths);
-
- images = images.length <= imgCount ? images : images.slice(0, imgCount);
- if (images.length >= imgCount || imgCount<= 0){
- wx.showToast({
- title: '最多9张图片',
- icon:'none'
- });
- }
- this.setData({
-
- images
- });
- }
- });
- },
- removeImage(e) {
-
-
- let idx = e.currentTarget.dataset.idx;
- var images = this.data.images;
- images.splice(idx, 1);
- this.setData({
- images
- });
- },
- removePciture(e) {
-
-
-
- let idx = e.currentTarget.dataset.idx;
- var pcitures = this.data.pcitures;
- pcitures.splice(idx, 1);
- this.setData({
- pcitures
- });
- },
- removeSign(e) {
-
-
- let idx = e.currentTarget.dataset.idx;
- var signs = this.data.signs;
- signs.splice(idx, 1);
- this.setData({
- signs
- });
- },
- handleImagePreview(e) {
- const idx = e.target.dataset.idx
- const images = this.data.images
-
- wx.previewImage({
- current: images[idx],
- urls: images,
- })
- },
- handleSignPreview(e) {
- const idx = e.target.dataset.idx
- const signs = this.data.signs
-
-
-
- wx.previewImage({
- current: signs[idx],
- urls: signs,
- })
- },
- clear_chargStationName(e){
- let worksheetinfo = this.data.worksheetinfo;
- worksheetinfo.chargStationId = null;
- worksheetinfo.pams = [];
- worksheetinfo.accendant = '';
- worksheetinfo.mainLocation = '';
- this.setData({
- worksheetinfo,
- chargStationNameClearFlag: true
- });
- },
- bindworkEndtimeParamsChange(e){
- let workEndtimeParams = this.data.workEndtimeParams;
- workEndtimeParams.pText = e.detail
- this.setData({
- workEndtimeParams:workEndtimeParams
- })
- console.info("workEndtimeParams " + workEndtimeParams.pText)
- },
- bindExceptparamsChange(e){
- let exceptparams = this.data.exceptparams;
- exceptparams.pText = e.detail
- this.setData({
- exceptparams:exceptparams
- })
- console.info("exceptparams " + exceptparams.pText)
- },
-
- onLoad: function(options) {
-
-
-
-
-
-
-
-
-
-
- console.info('sdfsdf')
- this.setData({
- 'exceptparams.pText' : Util.formatTimePicker(new Date()),
-
- })
-
- let worksheetinfo = {
- workStatus: 1,
- workBigclass: 1,
- wokSmallclass: 1,
- breakdownType: 1,
- chargStationId: null,
- }
- this.setData({
- worksheetinfo: worksheetinfo
- });
- this.setData({
- workstatusindex: 0,
- workBigclassindex: 0,
- wokSmallclassindex: 0,
- chargstationsindex: 0,
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.setData({
- breakdownTypeindex: 0
- });
-
-
- let userInfo = wx.getStorageSync('userInfo');
- let isLogin = wx.getStorageSync('isLogin');
- let that = this;
- if (userInfo && isLogin) {
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/userChargStationsWeb',
- data: {
- userId: userInfo.userId,
- pagenum: 1,
- pagesize: 1,
- },
- method: 'POST',
- success(res) {
-
- let {
- rows: chargstations
- } = res.data;
- let chargStationName='';
- let chargStationId=null;
- chargstations.forEach((item, index) => {
- chargStationName = item.chargStationName
-
- });
- let worksheetinfo = that.data.worksheetinfo;
- worksheetinfo.chargStationId = chargStationId;
- worksheetinfo.accendant = userInfo.userName
- that.data.accendantids.push(userInfo.userId);
- that.setData({
-
- worksheetinfo,
- });
- }
- });
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- openSign(e) {
- let url = `/pages/sign/sign`;
- wx.navigateTo({
- url
- });
- },
-
- onReady: function() {
- },
-
- onShow: function() {
- },
-
- onHide: function() {
- },
-
- onUnload: function() {
- },
-
- onPullDownRefresh: function() {
- },
-
- onReachBottom: function() {
- },
-
- onShareAppMessage: function() {
- }
- })
|