378 lines
8.6 KiB
Vue
Raw Normal View History

2024-07-02 13:24:20 +08:00
<template>
<view class="box-container">
2024-07-02 13:24:20 +08:00
<!-- 功能筛选区 -->
<uni-card :is-shadow="false">
2024-07-02 13:24:20 +08:00
<uni-forms label-width="100">
<!-- 选择小车 -->
<uni-forms-item label="AGV小车">
<uni-data-select v-model="agvCode" :localdata="agvChouseOptions" :clear="false"></uni-data-select>
</uni-forms-item>
<!-- 点位筛选 -->
<uni-forms-item label="起点筛选">
<uni-data-select v-model="startAreaCode" :localdata="areaOptions" :clear="false"
@change="getStartLocationDict()"></uni-data-select>
2024-07-02 13:24:20 +08:00
</uni-forms-item>
<!-- 起始点位 -->
<uni-forms-item label="起始点位">
<uni-data-select v-model="start_point" :localdata="startLocationOptions"
2024-07-02 13:24:20 +08:00
:clear="false"></uni-data-select>
</uni-forms-item>
<!-- 点位筛选 -->
<uni-forms-item label="终点筛选">
<uni-data-select v-model="endAreaCode" :localdata="areaOptions" :clear="false"
@change="getEndLocationDict()"></uni-data-select>
</uni-forms-item>
2024-07-02 13:24:20 +08:00
<!-- 结束点位 -->
<uni-forms-item label="结束点位">
<uni-data-select v-model="end_point" :localdata="endLocationOptions"
:clear="false"></uni-data-select>
2024-07-02 13:24:20 +08:00
</uni-forms-item>
<!-- 任务状态 -->
<uni-forms-item label="当前任务">
<view v-if="reqCode === ''">
<u-tag text="无任务" size="large" type="info"></u-tag>
</view>
<view v-else>
<u-tag :text="reqCode" size="large" type="primary"></u-tag>
</view>
</uni-forms-item>
<!-- 按钮区域 -->
<u-row customStyle="margin-bottom: 10px" :gutter="40">
<u-col span="6">
<u-button :disabled="loading" :loading="loading" shape="circle" type="success" text="执行任务"
@click="doStartAgv"></u-button>
2024-07-02 13:24:20 +08:00
</u-col>
<u-col span="6">
<u-button :disabled="loading" :loading="loading" shape="circle" type="error" text="取消任务"
@click="doStopAgv"></u-button>
2024-07-02 13:24:20 +08:00
</u-col>
</u-row>
<view style="margin-top: 60px;">
<u-button :disabled="loading" :loading="loading" shape="circle" type="info" text="清空任务记录"
@click="clearTask"></u-button>
2024-07-02 13:24:20 +08:00
</view>
</uni-forms>
</uni-card>
<u-toast ref="uToast"></u-toast>
</view>
</template>
<script>
import {
go_workshop,
emergency_stop_agv
2024-07-02 13:24:20 +08:00
} from '@/api/materialManagement/MaterialRequsition.js';
import {
queryMmAgvLocation
} from '@/api/materialManagement/MmAgvLocation.js';
export default {
data() {
return {
loading: false,
// 区域区分
startAreaCode: 0,
endAreaCode: 0,
2024-07-02 13:24:20 +08:00
areaOptions: [{
value: 0,
text: '全部'
},
{
value: 2,
text: '毛坯上料起点'
2024-07-02 13:24:20 +08:00
},
{
value: 3,
text: '毛坯上料终点'
2024-07-02 13:24:20 +08:00
},
{
value: 4,
text: '成品下线起点'
2024-07-02 13:24:20 +08:00
},
{
value: 5,
text: '成品下线终点'
},
{
value: 6,
text: '成品下线区二楼终点'
},
{
value: 7,
text: '一楼成品仓库交接区'
},
{
value: 8,
text: '二楼成品仓库交接区'
},
{
value: 9,
text: '外箱上料起点'
},
{
value: 10,
text: '外箱上料终点'
2024-07-02 13:24:20 +08:00
},
],
// 开始点位
start_point: '',
// 结束点位
end_point: '',
// AGV点位地址
startLocationOptions: [],
endLocationOptions: [],
2024-07-02 13:24:20 +08:00
// 任务code
reqCode: '',
// AGV小车选择列表
agvChouseOptions: [{
value: '1743',
text: '涂装1号AGV'
},
{
value: '1744',
text: '涂装2号AGV'
}
],
// AGV小车选择
agvCode: '1743'
};
},
watch: {},
filters: {},
mounted() {
// this.init();
},
onShow() {
this.init();
},
methods: {
init() {
this.loading = true;
this.getDict();
this.getTaskStorage();
this.loading = false;
},
getDict() {
this.getAreaOptions();
this.getStartLocationDict();
this.getEndLocationDict();
},
getAreaOptions() {
const query = {
pageNum: 1,
pageSize: 1000,
areaCode: 0
}
queryMmAgvLocation(query).then((res) => {
const {
code,
data
} = res;
if (code === 200) {
let options = [{
value: 0,
text: '全部'
}];
this.areaOptions = options.concat(this.formatAreaDict(data.result));
}
});
},
formatAreaDict(list) {
try {
const newList = list.map(item => {
return {
value: item.areaCode,
text: item.area
}
})
const _newList = newList
.filter((item, index) => newList
.findIndex(i => i.value === item.value) ===
index);
return _newList;
} catch (e) {
this.$refs.uToast.show({
type: 'error',
message: '字典数据解析异常!' + e.message
});
return [];
}
},
getStartLocationDict() {
2024-07-02 13:24:20 +08:00
const query = {
pageNum: 1,
pageSize: 1000,
areaCode: this.startAreaCode
2024-07-02 13:24:20 +08:00
}
queryMmAgvLocation(query).then((res) => {
const {
code,
data
} = res;
if (code === 200) {
this.startLocationOptions = this.formatDict(data.result);
if (this.startLocationOptions.length > 0) {
this.start_point = this.startLocationOptions[0].value;
} else {
this.start_point = '';
2024-07-02 13:24:20 +08:00
}
}
});
},
getEndLocationDict() {
const query = {
pageNum: 1,
pageSize: 1000,
areaCode: this.endAreaCode
}
queryMmAgvLocation(query).then((res) => {
const {
code,
data
} = res;
if (code === 200) {
this.endLocationOptions = this.formatDict(data.result);
if (this.endLocationOptions.length > 0) {
this.end_point = this.endLocationOptions[0].value;
} else {
this.end_point = '';
2024-07-02 13:24:20 +08:00
}
}
});
},
formatDict(list) {
try {
const newList = list.map(item => {
return {
value: item.coordinate,
text: item.coordinate
}
})
return newList;
} catch (e) {
this.$refs.uToast.show({
type: 'error',
message: '字典数据解析异常!' + e.message
});
return [];
}
},
// 任务启动
doStartAgv() {
if (this.loading) {
return;
}
if (this.start_point == '' || this.end_point == '') {
this.$refs.uToast.show({
type: 'error',
message: '起点或者终点不能为空'
});
return;
}
const query = {
start_point: this.start_point,
end_point: this.end_point,
agvCode: this.agvCode
};
this.loading = true;
setTimeout(() => {
this.loading = false;
}, 30000);
go_workshop(query).then((res) => {
if (res.code == 200) {
try {
let json = JSON.parse(res.data);
this.reqCode = json.data;
this.$refs.uToast.show({
type: 'success',
message: 'agv起动成功' + this.reqCode
});
this.saveTaskStorage();
} catch (e) {
this.$refs.uToast.show({
type: 'error',
message: 'agv起动失败' + this.reqCode
});
}
}
this.loading = false;
});
},
// 取消任务
doStopAgv() {
if (this.loading) {
return;
}
if (this.reqCode === '') {
this.$refs.uToast.show({
type: 'error',
message: '无任务编号,无法取消!'
});
return;
}
const query = {
reqCode: this.reqCode
};
this.loading = true;
setTimeout(() => {
this.loading = false;
}, 30000);
emergency_stop_agv(query).then((res) => {
2024-07-02 13:24:20 +08:00
if (res.code == 200) {
this.reqCode = '';
this.$refs.uToast.show({
type: 'success',
message: '成功取消任务:' + res.data
});
this.cancelTaskStorage();
}
this.loading = false;
});
},
// 保存任务缓存
saveTaskStorage() {
try {
const data = {
start_point: this.start_point,
end_point: this.end_point,
agvCode: this.agvCode,
reqCode: this.reqCode
}
uni.setStorageSync('AGVRemoteControlTaskData', JSON.stringify(data))
} catch (err) {
}
},
// 获取任务缓存
getTaskStorage() {
try {
const data = JSON.parse(uni.getStorageSync('AGVRemoteControlTaskData'));
if (data != null) {
this.start_point = data.start_point;
this.end_point = data.end_point;
this.agvCode = data.agvCode;
this.reqCode = data.reqCode;
}
} catch (err) {
}
},
// 清空任务缓存
cancelTaskStorage() {
uni.removeStorageSync('AGVRemoteControlTaskData');
2024-07-02 13:24:20 +08:00
},
// 清空任务记录
clearTask() {
this.cancelTaskStorage();
this.reqCode = '';
}
}
};
</script>
<style scoped>
.box-container{
background-color: white;
height: 644px;
}
2024-07-02 13:24:20 +08:00
</style>