Files
rd_mes_uniapp/pages/les/deliveryMaterial.vue
2025-12-22 09:48:01 +08:00

127 lines
3.4 KiB
Vue

<template>
<view>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-forms-item label="发货点位:" :labelWidth='100' name="srcLocationCode">
<uni-easyinput type="text" v-model="formData.srcLocationCode" />
</uni-forms-item>
<uni-forms-item label="目的点位:" :labelWidth='100' name="destLocationCode">
<uni-easyinput type="text" v-model="destLocationCode" />
</uni-forms-item>
<uni-forms-item label="机器人类型:" :labelWidth='100' name="robotType">
<uni-data-select placeholder="请选择机器类型" v-model="formData.robotType" :localdata="RobotData" />
</uni-forms-item>
<uni-forms-item label="容器类型:" :labelWidth='100' name="ctnrTyp" v-if="formData.robotType == 2">
<uni-easyinput type="text" v-model="formData.ctnrTyp" />
</uni-forms-item>
</uni-forms>
<uni-row :gutter="10">
<uni-col :span="12">
<u-button type="success" @click="handleDelivery">配送</u-button>
</uni-col>
<uni-col :span="12">
<u-button type="primary" @click="handleCancle">取消</u-button>
</uni-col>
</uni-row>
</view>
</template>
<script>
import RobotType from "@/utils/enums/RobotType";
import { delivery, cancel } from "@/api/les/lesMaterialDelivery.js"
export default {
onLoad(option) {
const form = JSON.parse(option.formData);
this.formData.taskTyp = form.taskType;
this.formData.id = form.id;
this.formData.srcLocationCode = form.srcLocationCode;
this.destLocationCode = form.destLocationCode;
},
data() {
return {
formData: {
id: null,
srcLocationCode: null,
taskTyp: null,
robotType: null,
ctnrTyp: null,
},
destLocationCode: null,
RobotData: [
{ value: RobotType.LATENT_MOBILE_ROBOT, text: "潜伏车" },
{ value: RobotType.LATENT_FORKLIFT_AGV, text: "潜伏叉车" },
],
/** 校验规则 */
rules: {
srcLocationCode: {
rules: [{
required: true,
errorMessage: '请输入发货点位',
}, ]
},
RobotType: {
rules: [{
required: true,
errorMessage: '请选择机器人类型',
}, ]
},
},
}
},
methods: {
handleDelivery() {
const _this = this;
this.$refs.form.validate().then(res => {
if (_this.formData.srcLocationCode && this.formData.robotType) {
_this.$modal.loading('提交中')
delivery(_this.formData).then(res => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("提交成功!");
_this.reset();
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else {
_this.$modal.msg("请将信息补充完整")
}
})
},
handleCancle() {
const _this = this;
const arr = [];
arr.push(_this.formData.id);
this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定取消该任务吗?',
success: function(res) {
if (res.confirm) {
_this.$modal.loading('取消中')
cancel(arr).then(res => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("取消成功!");
_this.reset();
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
})
},
reset() {
this.formData = {
id: null,
srcLocationCode: null,
taskTyp: null,
robotType: null,
ctnrTyp: null,
};
this.destLocationCode = null;
}
}
}
</script>