|
|
@@ -62,6 +62,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</section>
|
|
|
+
|
|
|
</div>
|
|
|
</div>
|
|
|
@endsection
|
|
|
@@ -102,50 +103,38 @@
|
|
|
let audioTag=$('<audio id="audio'+i+'" src="" autoplay></audio>');
|
|
|
body.append(audioTag);
|
|
|
}
|
|
|
- let _this=this;
|
|
|
- _this.measuringMachines.forEach(function(machine){
|
|
|
- _this.measuringMachinesIndex[machine.name]=machine;
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
+ this.measuringMachines.forEach((machine)=>{
|
|
|
+ this.measuringMachinesIndex[machine.name] = machine;
|
|
|
+ })
|
|
|
initEcho();
|
|
|
- Echo.channel('{{$laravelEchoPrefix}}package').listen('WeighedEvent',(e)=>{
|
|
|
- let package=e.package;
|
|
|
- let _this=this;
|
|
|
- let audio=document.getElementById("audio"+_this.currentAudioIndex);
|
|
|
- if (_this.currentAudioIndex==_this.amount){
|
|
|
- _this.currentAudioIndex=1;
|
|
|
- }else{
|
|
|
- _this.currentAudioIndex=_this.currentAudioIndex+1;
|
|
|
+ Echo.channel('{{$laravelEchoPrefix}}package').listen('WeighedEvent',e=>{
|
|
|
+ let item = e.package;
|
|
|
+ let audio = document.getElementById('audio'+this.currentAudioIndex);
|
|
|
+ if (this.currentAudioIndex === this.amount){
|
|
|
+ this.currentAudioIndex = 1;
|
|
|
+ } else {
|
|
|
+ this.currentAudioIndex = this.currentAudioIndex +1;
|
|
|
}
|
|
|
- if (package && package.measuring_machine && package.measuring_machine.name ===_this.package.measuringMachine){
|
|
|
- if (package.id ===_this.package.id){
|
|
|
- _this.package.measuringMachine_status=package.measuring_machine.status;
|
|
|
- _this.measuringMachinesIndex[package.measuring_machine.name].status=package.measuring_machine.status;
|
|
|
- tempTip.setDuration(2000);
|
|
|
- tempTip.showSuccess('暂无新数据');
|
|
|
- return;
|
|
|
+ if (item && item.measuring_machine && item.measuring_machine.name === this.package.measuringMachine){
|
|
|
+ if (item.id === this.package.id){
|
|
|
+ this.package.measuringMachine_status = item.measuring_machine.status;
|
|
|
+ this.measuringMachinesIndex[item.measuring_machine.name].status = item.measuring_machine.status;
|
|
|
+ window.tempTip.setDuration(2000);
|
|
|
+ window.tempTip.showSuccess('暂无新数据');
|
|
|
+ return ;
|
|
|
}
|
|
|
- _this.updateData(_this,package);
|
|
|
- let logistic_name = package.order ? (package.order.logistic ? package.order.logistic.name : '') : '';
|
|
|
- if (_this.logisticAudioURL[logistic_name]){
|
|
|
- audio.src=_this.logisticAudioURL[logistic_name];
|
|
|
+ this.updateData(item);
|
|
|
+ let logistic_name = item.order ? (item.order.logistic ? item.order.logistic.name : '') : '';
|
|
|
+ let logistic_number = item.logistic_number;
|
|
|
+ if (this.logisticAudioURL[logistic_name]){
|
|
|
+ audio.src=this.logisticAudioURL[logistic_name];
|
|
|
setTimeout(()=>{
|
|
|
audio.play();
|
|
|
},0);
|
|
|
- }else {
|
|
|
- window.tempTip.setDuration(3000);
|
|
|
- window.axios.post("{{url('package/weigh/measureMonitor/speech')}}",{logistic:logistic_name})
|
|
|
- .then(function (response) {
|
|
|
- if (response.data){
|
|
|
- _this.logisticAudioURL[logistic_name]=response.data;
|
|
|
- audio.src=response.data;
|
|
|
- setTimeout(()=>{
|
|
|
- audio.play();
|
|
|
- },0);
|
|
|
- }else window.tempTip.show('没有对应快递名称!');
|
|
|
- }).catch(function (err) {
|
|
|
- window.tempTip.show('语音合成发生错误:'+err);
|
|
|
- });
|
|
|
+ } else {
|
|
|
+ this.speech(logistic_name,logistic_number);
|
|
|
}
|
|
|
window.tempTip.setDuration(1000);
|
|
|
window.tempTip.showSuccess('刷新成功!');
|
|
|
@@ -154,36 +143,63 @@
|
|
|
},
|
|
|
methods:{
|
|
|
clickMeasuringMachine(e){
|
|
|
- let _this=this;
|
|
|
- window.axios.post('{{url('package/weigh/measureMonitor/data')}}',{id:e})
|
|
|
- .then(function (response) {
|
|
|
- if (response.data.id){
|
|
|
- let orderPackage=response.data;
|
|
|
- _this.updateData(_this,orderPackage);
|
|
|
- _this.package.measuringMachine=orderPackage.measuring_machine ? orderPackage.measuring_machine.name : ''; }else {
|
|
|
+ let url = '{{route('measureMonitor.dataApi')}}';
|
|
|
+ let data = {id:e};
|
|
|
+ window.axios.post(url,data).then(res =>{
|
|
|
+ if (res.data.id){
|
|
|
+ let orderPackage=res.data;
|
|
|
+ this.updateData(orderPackage);
|
|
|
+ this.package.measuringMachine= orderPackage.measuring_machine ? orderPackage.measuring_machine.name : '';
|
|
|
+ }else {
|
|
|
tempTip.setDuration(3000);
|
|
|
tempTip.showSuccess('暂无数据!');
|
|
|
}
|
|
|
- })
|
|
|
- .catch(function (err) {
|
|
|
+ }).catch(err=>{
|
|
|
tempTip.setDuration(4000);
|
|
|
tempTip.show('切换设备错误:'+err);
|
|
|
});
|
|
|
},
|
|
|
- updateData(_this,package){
|
|
|
- _this.package.id=package.id;
|
|
|
- _this.package.logistic_number=package.logistic_number;
|
|
|
- _this.package.orderno = package.order ? package.order.code : '';
|
|
|
- _this.package.weight=package.weight;
|
|
|
- _this.package.owner=package.order ? (package.order.owner ? package.order.owner.name : '') : '';
|
|
|
- _this.package.paperBox=package.paper_box ? package.paper_box.name : '';
|
|
|
- _this.package.recipient=package.order ? package.order.recipient : '';
|
|
|
- _this.package.status=package.status;
|
|
|
- _this.package.weighed_at=package.weighed_at;_this.package.bulk=package.bulk;
|
|
|
- _this.package.logistic_name=package.order ? (package.order.logistic ? package.order.logistic.name : '') : '';
|
|
|
- _this.package.measuringMachine_status=package.measuring_machine ? package.measuring_machine.status : '';
|
|
|
- _this.measuringMachinesIndex[package.measuring_machine ? package.measuring_machine.name : ''].status=package.measuring_machine ? package.measuring_machine.status : '离线';
|
|
|
- }
|
|
|
+ updateData(item){
|
|
|
+ this.package.id=item.id;
|
|
|
+ this.package.logistic_number=item.logistic_number;
|
|
|
+ this.package.orderno = item.order ? item.order.code : '';
|
|
|
+ this.package.weight=item.weight;
|
|
|
+ this.package.owner=item.order ? (item.order.owner ? item.order.owner.name : '') : '';
|
|
|
+ this.package.paperBox=item.paper_box ? item.paper_box.name : '';
|
|
|
+ this.package.recipient=item.order ? item.order.recipient : '';
|
|
|
+ this.package.status=item.status;
|
|
|
+ this.package.weighed_at=item.weighed_at;
|
|
|
+ this.package.bulk=item.bulk;
|
|
|
+ this.package.logistic_name=item.order ? (item.order.logistic ? item.order.logistic.name : '') : '';
|
|
|
+ this.package.measuringMachine_status=item.measuring_machine ? item.measuring_machine.status : '';
|
|
|
+ this.measuringMachinesIndex[item.measuring_machine ? item.measuring_machine.name : ''].status = item.measuring_machine ? item.measuring_machine.status : '离线';
|
|
|
+ },
|
|
|
+ speech(logistic_name,logistic_number){
|
|
|
+ let audio = document.getElementById('audio'+this.currentAudioIndex);
|
|
|
+ window.tempTip.setDuration(3000);
|
|
|
+ let url = '{{route('measureMonitor.speechApi')}}';
|
|
|
+ let data = {logistic:logistic_name,logistic_number:logistic_number};
|
|
|
+ window.axios.post(url,data).then(res=>{
|
|
|
+ if(res.data.success){
|
|
|
+ let name =res.data.data.name;
|
|
|
+ let path = res.data.data.path;
|
|
|
+ this.logisticAudioURL[name] = path;
|
|
|
+ audio.src = path;
|
|
|
+ setTimeout(()=>{
|
|
|
+ audio.play();
|
|
|
+ },0);
|
|
|
+ }else {
|
|
|
+ if (res.data.data){
|
|
|
+ audio.src = res.data.data.path;
|
|
|
+ setTimeout(()=>{
|
|
|
+ audio.play();
|
|
|
+ },0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch(err=>{
|
|
|
+ window.tempTip.show('语音合成发生错误:'+err);
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
});
|
|
|
</script>
|