<template>
|
<wd-form ref="form" :model="model" class="relative form_box">
|
<wd-cell-group :border="true">
|
<wd-input
|
v-model="model.poleNumber"
|
label="领用杆号"
|
label-width="100px"
|
prop="poleNumber"
|
placeholder="请输入领用杆号"
|
>
|
<template #suffix>
|
<wd-icon name="scan" @click="openScan" />
|
</template>
|
</wd-input>
|
<wd-input
|
v-model="model.poleWeight"
|
label="杆重"
|
label-width="100px"
|
prop="poleWeight"
|
clearable
|
placeholder="请输入杆重"
|
/>
|
<wd-input
|
v-model="model.poleModel"
|
label="杆型号"
|
label-width="100px"
|
prop="poleModel"
|
clearable
|
placeholder="请输入杆型号"
|
/>
|
<wd-input
|
v-model="model.model"
|
label="规格型号"
|
label-width="100px"
|
prop="model"
|
clearable
|
placeholder="请输入规格型号"
|
/>
|
<wd-input
|
v-model="model.oneLength"
|
label="盘长(m)"
|
label-width="100px"
|
prop="oneLength"
|
clearable
|
placeholder="请输入盘长"
|
/>
|
<wd-input
|
v-model="model.polePackageNumber"
|
label-width="100px"
|
prop="polePackageNumber"
|
clearable
|
placeholder="请输入杆包号"
|
>
|
<template #label>
|
<span style="color: #F56C6C">杆包号</span>
|
</template>
|
</wd-input>
|
<wd-input
|
v-model="model.dishModel"
|
label-width="100px"
|
prop="dishModel"
|
clearable
|
placeholder="请输入盘型号"
|
>
|
<template #label>
|
<span style="color: #F56C6C">盘型号</span>
|
</template>
|
</wd-input>
|
<wd-input
|
v-model="model.actuallyLength"
|
label-width="100px"
|
prop="actuallyLength"
|
clearable
|
placeholder="请输入实际长度"
|
>
|
<template #label>
|
<span style="color: #F56C6C">实际长度(m)</span>
|
</template>
|
</wd-input>
|
<wd-input
|
v-model="model.actuallyWeight"
|
label-width="100px"
|
prop="actuallyWeight"
|
clearable
|
placeholder="请输入实际重量"
|
>
|
<template #label>
|
<span style="color: #F56C6C">实际重量(kg)</span>
|
</template>
|
</wd-input>
|
</wd-cell-group>
|
<wd-toast />
|
<Scan ref="scanRef" />
|
</wd-form>
|
</template>
|
|
<script lang="ts" setup>
|
import useFormData from "@/hooks/useFormData";
|
import { useToast } from "wot-design-uni";
|
import WireApi from "@/api/product/wire";
|
import Scan from "@/components/scan/index.vue";
|
|
const paramsId = ref();
|
const scanRef = ref();
|
const toast = useToast();
|
const { form: model, resetForm } = useFormData({
|
poleNumber: undefined, // 领用杆号
|
poleWeight: undefined, // 杆重
|
poleModel: undefined, // 杆型号
|
model: undefined, // 规格型号
|
polePackageNumber: undefined, // 杆包号
|
dishModel: undefined, // 盘型号
|
oneLength: undefined, // 盘长
|
actuallyLength: undefined, // 实际长度
|
actuallyWeight: undefined, // 实际重量
|
});
|
|
const submit = async () => {
|
const { code } = await WireApi.addWireOutput({
|
wireId: paramsId.value,
|
type: "拉丝",
|
...model,
|
});
|
if (code == 200) {
|
toast.success("提交成功");
|
resetForm()
|
return true;
|
} else {
|
toast.error("提交失败");
|
return false;
|
}
|
};
|
|
const openScan = () => {
|
scanRef.value.triggerScan();
|
};
|
|
// 监听扫码
|
const getScanCode = (code: any) => {
|
console.log("自定义扫描的结果回调函数:", code.code);
|
// console.log("自定义扫描的结果回调函数", JSON.parse(code));
|
const arr = code.code.split(",");
|
model.poleNumber = arr[3]; // 领用杆号
|
model.poleWeight = arr[4]; // 杆重
|
model.poleModel = 'Φ' + arr[1].slice(2); // 杆型号
|
};
|
|
onLoad((options: any) => {
|
paramsId.value = options.id;
|
model.model = options.model;
|
console.log("options", options);
|
model.oneLength = options.oneLength;
|
// 开启广播监听事件
|
uni.$on("scan", getScanCode);
|
});
|
|
onUnload(() => {
|
// 开启广播监听事件
|
uni.$off("scan", getScanCode);
|
});
|
|
defineExpose({
|
submit,
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.submit_btn {
|
position: absolute;
|
bottom: 0;
|
width: 100%;
|
}
|
</style>
|