|
@@ -0,0 +1,201 @@
|
|
|
+<template>
|
|
|
+ <div class="form">
|
|
|
+ <van-nav-bar
|
|
|
+ :title="$t('inventoryCount.name')"
|
|
|
+ :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, reactive, getCurrentInstance, onMounted } from "vue";
|
|
|
+import { showSuccessToast, showFailToast } from "vant";
|
|
|
+import { useRoute } from "vue-router";
|
|
|
+import testForm from "@/components/testForm/index.vue";
|
|
|
+const proxy = getCurrentInstance().proxy;
|
|
|
+const route = useRoute();
|
|
|
+const formDom = ref(null);
|
|
|
+const formData = reactive({
|
|
|
+ data: {},
|
|
|
+});
|
|
|
+const rules = {
|
|
|
+ qualifiedCount: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: proxy.t("inventoryCount.qualityQualifiedCanNotBeEmpty"),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ noQualifiedCount: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: proxy.t("inventoryCount.qualityUnQualifiedCanNotBeEmpty"),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+};
|
|
|
+const formOption = reactive({
|
|
|
+ readonly: false, //用于控制整个表单是否只读
|
|
|
+ disabled: false,
|
|
|
+ labelAlign: "top",
|
|
|
+ scroll: true,
|
|
|
+ labelWidth: "62pk",
|
|
|
+ submitBtnText: proxy.t("common.submit"),
|
|
|
+ btnConfig: {
|
|
|
+ isNeed: true,
|
|
|
+ label: proxy.t("common.details"),
|
|
|
+ prop: "list",
|
|
|
+ plain: true,
|
|
|
+ listConfig: [
|
|
|
+ {
|
|
|
+ type: "picker",
|
|
|
+ label: proxy.t("inventoryCount.goodsName"),
|
|
|
+ prop: "productId",
|
|
|
+ itemType: "onePicker",
|
|
|
+ showPicker: false,
|
|
|
+ readonly: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: "name",
|
|
|
+ value: "id",
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
+ changeFn: function (option, item, index, currentSonIndex) {
|
|
|
+ console.log(option, item, index, currentSonIndex, "ww");
|
|
|
+ formData.data.list[index][item.prop] = option.selectedOptions[0].id;
|
|
|
+ formData.data.list[index][item.prop + "Name"] =
|
|
|
+ option.selectedOptions[0].name;
|
|
|
+ formDom.value.btnConfigCopy.listConfig[
|
|
|
+ currentSonIndex
|
|
|
+ ].showPicker = false;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "text",
|
|
|
+ label: proxy.t("inventoryCount.stockNumber"),
|
|
|
+ prop: "quantity",
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "number",
|
|
|
+ label: proxy.t("inventoryCount.inventoryNumber"),
|
|
|
+ prop: "quantity",
|
|
|
+ readonly: false,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ clickFn: () => {
|
|
|
+ if (formData.data.list && formData.data.list.length > 0) {
|
|
|
+ formData.data.list.push({
|
|
|
+ productId: "",
|
|
|
+ quantity: "",
|
|
|
+ checkQuantity: "",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ formData.data.list = [
|
|
|
+ {
|
|
|
+ productId: "",
|
|
|
+ quantity: "",
|
|
|
+ checkQuantity: "",
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+});
|
|
|
+const formConfig = reactive([
|
|
|
+ {
|
|
|
+ type: "picker",
|
|
|
+ label: proxy.t("inventoryCount.inventoryWarehouse"),
|
|
|
+ prop: "warehouseId",
|
|
|
+ itemType: "onePicker",
|
|
|
+ showPicker: false,
|
|
|
+ readonly: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: "name",
|
|
|
+ value: "id",
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
+ changeFn: function (option, item, index) {
|
|
|
+ formData.data[item.prop] = option.selectedOptions[0].id;
|
|
|
+ formData.data[item.prop + "Name"] = option.selectedOptions[0].name;
|
|
|
+ formConfig[index].showPicker = false;
|
|
|
+ },
|
|
|
+ },
|
|
|
+]);
|
|
|
+const onClickLeft = () => history.back();
|
|
|
+const productData = ref([]);
|
|
|
+const getDict = () => {
|
|
|
+ proxy.post("/warehouse/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
|
|
|
+ formConfig[0].data = res.data.rows;
|
|
|
+ });
|
|
|
+ proxy
|
|
|
+ .post("/productInfo/page", { pageNum: 1, pageSize: 9999, definition: "" })
|
|
|
+ .then((res) => {
|
|
|
+ formOption.btnConfig.listConfig[0].data = res.data.rows;
|
|
|
+ productData.value = res.data.rows;
|
|
|
+ });
|
|
|
+};
|
|
|
+onMounted(() => {
|
|
|
+ getDict();
|
|
|
+ if (route.query && route.query.id) {
|
|
|
+ proxy.post("/stockCheck/detail", { id: route.query.id }).then((res) => {
|
|
|
+ console.log(res, "aaa");
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ let data = { ...formData.data };
|
|
|
+ if (Number(data.qualifiedCount) + Number(data.noQualifiedCount) > 0) {
|
|
|
+ if (
|
|
|
+ Number(data.qualifiedCount) +
|
|
|
+ Number(data.noQualifiedCount) +
|
|
|
+ Number(data.sumQualityCount) >
|
|
|
+ Number(data.count)
|
|
|
+ ) {
|
|
|
+ return showFailToast(
|
|
|
+ proxy.t(
|
|
|
+ "inventoryCount.qualityInspectionQuantityNotBeGreaterThanArrivalNumber"
|
|
|
+ )
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ let obj = {
|
|
|
+ arrivalDetailId: data.arrivalDetailId,
|
|
|
+ qualifiedCount: data.qualifiedCount,
|
|
|
+ noQualifiedCount: data.noQualifiedCount,
|
|
|
+ };
|
|
|
+ delete data.arrivalDetailId;
|
|
|
+ delete data.qualifiedCount;
|
|
|
+ delete data.noQualifiedCount;
|
|
|
+ data.qualityDetailList = [obj];
|
|
|
+ proxy.post("/quality/add", data).then(
|
|
|
+ () => {
|
|
|
+ showSuccessToast(proxy.t("common.operationSuccessful"));
|
|
|
+ setTimeout(() => {
|
|
|
+ onClickLeft();
|
|
|
+ }, 500);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ return showFailToast(err.message);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return showFailToast(
|
|
|
+ proxy.t("inventoryCount.qualityInspectionQuantityCannotBeZero")
|
|
|
+ );
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|