first commit
This commit is contained in:
12
store/index.js
Normal file
12
store/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// 页面路径:store/index.js
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import equip from '@/store/modules/equip'
|
||||
|
||||
Vue.use(Vuex)
|
||||
export default new Vuex.Store({
|
||||
modules:{
|
||||
equip
|
||||
}
|
||||
})
|
||||
149
store/modules/equip.js
Normal file
149
store/modules/equip.js
Normal file
@@ -0,0 +1,149 @@
|
||||
import config from "@/libs/config/config.js"
|
||||
|
||||
export default {
|
||||
state: {
|
||||
timestamp: 1608820295,//初始时间戳
|
||||
currentData:{
|
||||
id:null,
|
||||
number:null,
|
||||
type:null,
|
||||
},
|
||||
currentDataDetails:{
|
||||
docId: "",
|
||||
docIds:[],
|
||||
latitude: "",
|
||||
longitude: "",
|
||||
pictureId: null,
|
||||
remarks: "",
|
||||
subjectId: null,
|
||||
},
|
||||
oldDataDetails:{
|
||||
docId: "",
|
||||
docIds:[],
|
||||
latitude: "",
|
||||
longitude: "",
|
||||
pictureId: null,
|
||||
remarks: "",
|
||||
subjectId: null,
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
timeString(state) {//时间戳转换后的时间
|
||||
var date = new Date(state.timestamp);
|
||||
var year = date.getFullYear();
|
||||
var mon = date.getMonth()+1;
|
||||
var day = date.getDate();
|
||||
var hours = date.getHours();
|
||||
var minu = date.getMinutes();
|
||||
var sec = date.getSeconds();
|
||||
var trMon = mon<10 ? '0'+mon : mon
|
||||
var trDay = day<10 ? '0'+day : day
|
||||
return year+'-'+trMon+'-'+trDay+" "+hours+":"+minu+":"+sec;
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
updateTime(state){//更新当前时间戳
|
||||
state.timestamp = Date.now()
|
||||
},
|
||||
set(state,payload){
|
||||
state.currentData=payload.data;
|
||||
},
|
||||
setDtails(state,payload){
|
||||
state.currentDataDetails=payload.data;
|
||||
},
|
||||
queryCurrentDataDetails(state,payload){
|
||||
console.log("==========================queryCurrentDataDetails")
|
||||
console.log(state.currentData)
|
||||
uni.$u.post(config.api + '/xfhrshInternet/service/selPicture', {
|
||||
subjectId:state.currentData.id
|
||||
}).then(res => {
|
||||
console.log(typeof res)
|
||||
console.log(res)
|
||||
if(res.code==0){
|
||||
if(res.data.length>0){
|
||||
state.currentDataDetails=res.data[0];
|
||||
}else{
|
||||
state.currentDataDetails=state.oldDataDetails;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
updateEquipDetails(state,payload){
|
||||
let _data=JSON.parse(JSON.stringify(payload.data))
|
||||
delete _data.number
|
||||
delete _data.type
|
||||
console.log(_data)
|
||||
_data.subjectId=_data.id
|
||||
delete _data.id
|
||||
if(_data.latitude){
|
||||
_data.latitude=String(_data.latitude)
|
||||
}else{
|
||||
_data.latitude=state.currentDataDetails.latitude
|
||||
}
|
||||
if(_data.longitude){
|
||||
_data.longitude=String(_data.longitude)
|
||||
}else{
|
||||
_data.longitude=state.currentDataDetails.longitude
|
||||
}
|
||||
if(_data.remarks){
|
||||
|
||||
}else{
|
||||
_data.remarks=state.currentDataDetails.remarks
|
||||
}
|
||||
if(_data.docId){
|
||||
|
||||
}else{
|
||||
_data.docId=state.currentDataDetails.docId
|
||||
}
|
||||
|
||||
|
||||
console.log("=================================state.currentDataDetails")
|
||||
console.log(state.currentDataDetails)
|
||||
if(state.currentDataDetails){
|
||||
if(state.currentDataDetails.pictureId!=null){
|
||||
_data.pictureId=state.currentDataDetails.pictureId;
|
||||
}
|
||||
}
|
||||
_data.subjectId=state.currentData.id
|
||||
uni.$u.post(config.api + '/xfhrshInternet/service/insertPicture', _data).then(res => {
|
||||
console.log(typeof res)
|
||||
console.log(res)
|
||||
if(res.code==0){
|
||||
uni.showToast({
|
||||
icon: "success",
|
||||
title: "操作成功"
|
||||
})
|
||||
uni.$emit('updateCamera', {
|
||||
cameara: {}
|
||||
})
|
||||
}else{
|
||||
uni.showToast({
|
||||
icon: "error",
|
||||
title: res.message
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
setCurrentEquip(context , payload){
|
||||
context.commit('set',payload)
|
||||
},
|
||||
setCurrentEquipDtails(context , payload){
|
||||
context.commit('setDtails',payload)
|
||||
},
|
||||
updateEquipDetails(context , payload){
|
||||
context.commit('updateEquipDetails',payload)
|
||||
setTimeout(()=>{
|
||||
context.commit('queryCurrentDataDetails',payload)
|
||||
},500)
|
||||
},
|
||||
queryCurrentDataDetails(context , payload){
|
||||
context.commit('queryCurrentDataDetails',payload)
|
||||
},
|
||||
updateCurrentDataDetails(context , payload){
|
||||
context.commit('updateCurrentDataDetails',payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user