|
@@ -0,0 +1,127 @@
|
|
|
|
+<template>
|
|
|
|
+ <div>
|
|
|
|
+ <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit"> </byForm>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup>
|
|
|
|
+import byForm from "@/components/byForm/index";
|
|
|
|
+import { useRoute } from "vue-router";
|
|
|
|
+// import { ElMessage } from "element-plus";
|
|
|
|
+
|
|
|
|
+const route = useRoute();
|
|
|
|
+// 接收父组件的传值
|
|
|
|
+const props = defineProps({
|
|
|
|
+ queryData: Object,
|
|
|
|
+});
|
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
|
+const formData = reactive({
|
|
|
|
+ data: {},
|
|
|
|
+});
|
|
|
|
+const judgeStatus = () => {
|
|
|
|
+ if (route.query.processType == 20 || route.query.processType == 10) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ if (props.queryData.recordList && props.queryData.recordList.length > 0) {
|
|
|
|
+ let data = props.queryData.recordList.filter((item) => item.status === 2 && item.nodeType !== 1);
|
|
|
|
+ if (data && data.length > 0) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+};
|
|
|
|
+const formOption = reactive({
|
|
|
|
+ inline: true,
|
|
|
|
+ labelWidth: 100,
|
|
|
|
+ itemWidth: 100,
|
|
|
|
+ rules: [],
|
|
|
|
+ disabled: false,
|
|
|
|
+});
|
|
|
|
+const formConfig = computed(() => {
|
|
|
|
+ return [
|
|
|
|
+ {
|
|
|
|
+ type: "title",
|
|
|
|
+ title: "申购单",
|
|
|
|
+ label: "",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: "title",
|
|
|
|
+ title: "申购清单",
|
|
|
|
+ label: "",
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
+});
|
|
|
|
+const rules = ref({
|
|
|
|
+ countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
|
|
|
|
+ sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
|
|
|
|
+});
|
|
|
|
+const handleSubmit = async (flag) => {
|
|
|
|
+ if (flag) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ let status = await proxy.$refs.submit.handleSubmit(() => {});
|
|
|
|
+ if (status) {
|
|
|
|
+ // if (!(formData.data.contractProductList && formData.data.contractProductList.length > 0)) {
|
|
|
|
+ // ElMessage("请添加至少一件商品");
|
|
|
|
+ // return false;
|
|
|
|
+ // }
|
|
|
|
+ // if (formData.data.contractShipmentList && formData.data.contractShipmentList.length > 0) {
|
|
|
|
+ // for (let i = 0; i < formData.data.contractProductList.length; i++) {
|
|
|
|
+ // let data = formData.data.contractShipmentList.filter((item) => item.productId === formData.data.contractProductList[i].productId);
|
|
|
|
+ // if (data && data.length > 0) {
|
|
|
|
+ // let quantity = 0;
|
|
|
|
+ // for (let j = 0; j < data.length; j++) {
|
|
|
|
+ // quantity = parseFloat(Number(quantity) + Number(data[j].quantity));
|
|
|
|
+ // }
|
|
|
|
+ // if (quantity > formData.data.contractProductList[i].quantity) {
|
|
|
|
+ // ElMessage("出货数量不能大于商品数量");
|
|
|
|
+ // return false;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ const errorDiv = document.getElementsByClassName("is-error");
|
|
|
|
+ errorDiv[0].scrollIntoView();
|
|
|
|
+ }, 0);
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+const getFormData = () => {
|
|
|
|
+ return proxy.deepClone(formData.data);
|
|
|
|
+};
|
|
|
|
+watch(
|
|
|
|
+ () => props.queryData,
|
|
|
|
+ (newValue) => {
|
|
|
|
+ console.log(proxy.deepClone(newValue));
|
|
|
|
+ // formOption.disabled = judgeStatus();
|
|
|
|
+ // if (props.queryData && ["10", "20", "30"].includes(route.query.processType)) {
|
|
|
|
+ // for (var text in props.queryData) {
|
|
|
|
+ // formData.data[text] = props.queryData[text];
|
|
|
|
+ // }
|
|
|
|
+ // if (formData.data.countryId) {
|
|
|
|
+ // getCityData(formData.data.countryId, "20");
|
|
|
|
+ // }
|
|
|
|
+ // if (formData.data.provinceId) {
|
|
|
|
+ // getCityData(formData.data.provinceId, "30");
|
|
|
|
+ // }
|
|
|
|
+ // getDecisionAids();
|
|
|
|
+ // }
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ deep: true,
|
|
|
|
+ }
|
|
|
|
+);
|
|
|
|
+onMounted(() => {});
|
|
|
|
+// 向父组件暴露
|
|
|
|
+defineExpose({ getFormData, handleSubmit });
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+::v-deep(.el-input-number .el-input__inner) {
|
|
|
|
+ text-align: left;
|
|
|
|
+}
|
|
|
|
+</style>
|