|
@@ -0,0 +1,255 @@
|
|
|
+<template>
|
|
|
+ <div class="form">
|
|
|
+ <van-nav-bar :title="'报损管理'" :left-text="$t('common.back')" left-arrow @click-left="onClickLeft">
|
|
|
+ </van-nav-bar>
|
|
|
+
|
|
|
+ <testForm v-model="formData.data" :formOption="formOption" :formConfig="formConfig" :rules="rules" @onSubmit="onSubmit" ref="formDom">
|
|
|
+ </testForm>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { ref, getCurrentInstance, onMounted, reactive } from "vue";
|
|
|
+import { showSuccessToast, showToast, showFailToast } from "vant";
|
|
|
+
|
|
|
+import { useRoute } from "vue-router";
|
|
|
+import { getUserInfo } from "@/utils/auth";
|
|
|
+import testForm from "@/components/testForm/index.vue";
|
|
|
+const proxy = getCurrentInstance().proxy;
|
|
|
+const route = useRoute();
|
|
|
+const show = ref(false);
|
|
|
+const typeModal = ref(false);
|
|
|
+const unitModal = ref(false);
|
|
|
+const classification = ref([]);
|
|
|
+const formData = reactive({
|
|
|
+ data: {
|
|
|
+ prodOrderId: "",
|
|
|
+ respUserSet: [],
|
|
|
+ },
|
|
|
+});
|
|
|
+const formDom = ref(null);
|
|
|
+const formOption = reactive({
|
|
|
+ readonly: false, //用于控制整个表单是否只读
|
|
|
+ disabled: false,
|
|
|
+ labelAlign: "top",
|
|
|
+ scroll: true,
|
|
|
+ labelWidth: "62pk",
|
|
|
+ hiddenSubmitBtn: false,
|
|
|
+});
|
|
|
+const formConfig = reactive([
|
|
|
+ {
|
|
|
+ type: "picker",
|
|
|
+ label: "类型",
|
|
|
+ prop: "type",
|
|
|
+ itemType: "onePicker",
|
|
|
+ showPicker: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: "label",
|
|
|
+ value: "value",
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ {
|
|
|
+ label: "补单",
|
|
|
+ value: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "丢失",
|
|
|
+ value: 2,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "picker",
|
|
|
+ label: "发起时间",
|
|
|
+ prop: "repoTime",
|
|
|
+ itemType: "datePickerTime",
|
|
|
+ needDefault: true,
|
|
|
+ showPicker: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "multipleChoice",
|
|
|
+ itemType: "multiple",
|
|
|
+ prop: "respUserSet",
|
|
|
+ label: "责任人",
|
|
|
+ showPicker: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: "text",
|
|
|
+ value: "value",
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "picker",
|
|
|
+ label: "生产订单",
|
|
|
+ prop: "prodOrderId",
|
|
|
+ itemType: "onePicker",
|
|
|
+ showPicker: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: "label",
|
|
|
+ value: "value",
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
+ changeFn: (val, data) => {
|
|
|
+ proxy.formChange(val, data, formData);
|
|
|
+ if (val.selectedValues[0]) {
|
|
|
+ let current = data.data.find((x) => x.value == val.selectedValues[0]);
|
|
|
+ if (current) {
|
|
|
+ proxy
|
|
|
+ .post("/contractProductBom/getList", {
|
|
|
+ contractId: current.contractId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ formConfig[4].data = res.data.map((x) => ({
|
|
|
+ ...x,
|
|
|
+ label: x.productName,
|
|
|
+ value: x.materialId,
|
|
|
+ }));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.showPicker = false;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "picker",
|
|
|
+ label: "物品名称",
|
|
|
+ prop: "materialId",
|
|
|
+ itemType: "onePicker",
|
|
|
+ showPicker: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: "label",
|
|
|
+ value: "value",
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
+ changeFn: (val, data) => {
|
|
|
+ proxy.formChange(val, data, formData);
|
|
|
+ if (val.selectedValues[0]) {
|
|
|
+ let current = data.data.find((x) => x.value == val.selectedValues[0]);
|
|
|
+ if (current) {
|
|
|
+ formData.data.productCode = current.productCode;
|
|
|
+ formData.data.productQuantity = current.quantity;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.showPicker = false;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "text",
|
|
|
+ label: "物品编码",
|
|
|
+ prop: "productCode",
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "text",
|
|
|
+ label: "物品数量",
|
|
|
+ prop: "productQuantity",
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ label: "数量",
|
|
|
+ prop: "quantity",
|
|
|
+ itemType: "digit",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "textarea",
|
|
|
+ label: "备注",
|
|
|
+ prop: "remark",
|
|
|
+ },
|
|
|
+]);
|
|
|
+const rules = {
|
|
|
+ type: [{ required: true, message: "请选择类型" }],
|
|
|
+ repoTime: [{ required: true, message: "请选择发起时间" }],
|
|
|
+ respUserSet: [{ required: true, message: "请选择责任人" }],
|
|
|
+ prodOrderId: [{ required: true, message: "请选择生产订单" }],
|
|
|
+ materialId: [{ required: true, message: "请选择物品名称" }],
|
|
|
+ quantity: [{ required: true, message: "请输入数量" }],
|
|
|
+ remark: [{ required: true, message: "请输入备注" }],
|
|
|
+};
|
|
|
+const userList = ref([]);
|
|
|
+const prodOrderList = ref([]);
|
|
|
+const getDict = () => {
|
|
|
+ proxy
|
|
|
+ .get("/tenantUser/list", {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 9999,
|
|
|
+ keyword: "",
|
|
|
+ tenantId: getUserInfo().tenantId,
|
|
|
+ companyId: getUserInfo().companyId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ formConfig[2].data = res.rows.map((item) => {
|
|
|
+ return {
|
|
|
+ text: item.nickName,
|
|
|
+ value: item.userId,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ proxy
|
|
|
+ .post("produceOrder/page", {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 9999,
|
|
|
+ produceStatus: "0,1",
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ prodOrderList.value = res.data.rows.map((x) => ({
|
|
|
+ ...x,
|
|
|
+ label: x.code,
|
|
|
+ value: x.id,
|
|
|
+ }));
|
|
|
+ formConfig[3].data = prodOrderList.value;
|
|
|
+ });
|
|
|
+};
|
|
|
+getDict();
|
|
|
+
|
|
|
+const getDetail = () => {
|
|
|
+ proxy
|
|
|
+ .post("/reportLossesDetails/detail", {
|
|
|
+ id: route.query.id,
|
|
|
+ })
|
|
|
+ .then(
|
|
|
+ (res) => {
|
|
|
+ formData.data = res.data;
|
|
|
+ formData.data.respUserSet = res.data.respUserSet.split(",");
|
|
|
+ setTimeout(() => {
|
|
|
+ formDom.value.formDataShowLabelOne();
|
|
|
+ }, 200);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ onClickLeft();
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+const onClickLeft = () => history.back();
|
|
|
+const onSubmit = () => {
|
|
|
+ if (Number(formData.data.quantity) < 1) {
|
|
|
+ return showFailToast("数量不能为0");
|
|
|
+ }
|
|
|
+ if (Number(formData.data.quantity) > Number(formData.data.productQuantity)) {
|
|
|
+ return showFailToast("数量不可大于物品数量");
|
|
|
+ }
|
|
|
+ formData.data.respUserSet = formData.data.respUserSet.join(",");
|
|
|
+ proxy.post("/reportLossesDetails/add", formData.data).then(() => {
|
|
|
+ showSuccessToast(proxy.t("common.addSuccess"));
|
|
|
+ setTimeout(() => {
|
|
|
+ proxy.$router.push("/main/supplementaryOrder");
|
|
|
+ }, 500);
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ if (route.query && route.query.id) {
|
|
|
+ // formData.data = { ...route.query };
|
|
|
+ getDetail();
|
|
|
+ formOption.readonly = true;
|
|
|
+ formOption.hiddenSubmitBtn = true;
|
|
|
+ }
|
|
|
+});
|
|
|
+</script>
|