Browse Source

采购合同-款项登记

huangbin 4 years ago
parent
commit
e364df7593

+ 13 - 28
src/views/business/purchase/components/funds/index.vue

@@ -88,7 +88,7 @@
       <a-form class="inlineForm"
       <a-form class="inlineForm"
               ref="formRef"
               ref="formRef"
               :model="formState"
               :model="formState"
-              :rules="formStateRules">
+              :rules="rules">
         <a-row :gutter="24">
         <a-row :gutter="24">
           <a-col :span="12">
           <a-col :span="12">
             <a-form-item label="点价价格"
             <a-form-item label="点价价格"
@@ -153,8 +153,9 @@ import { getPriceTypeName } from '@/views/business/purchase/setup';
 import { operationContractReq } from '@/services/proto/contract';
 import { operationContractReq } from '@/services/proto/contract';
 import { message } from 'ant-design-vue';
 import { message } from 'ant-design-vue';
 import { objectToUint8Array } from '@/utils/objHandle';
 import { objectToUint8Array } from '@/utils/objHandle';
-import {FundsReq, InvoiceReq} from "@/services/proto/contract/interface";
-import {fundsReq, invoiceReq} from "@/views/business/purchase/components/setup";
+import { FundsReq, InvoiceReq } from '@/services/proto/contract/interface';
+import { fundsReq, invoiceReq } from '@/views/business/purchase/components/setup';
+import { handleForm } from './setup';
 
 
 export default defineComponent({
 export default defineComponent({
     name: 'purchase_pending_funds',
     name: 'purchase_pending_funds',
@@ -165,41 +166,25 @@ export default defineComponent({
             default: {},
             default: {},
         },
         },
     },
     },
-    setup(props,context) {
+    setup(props, context) {
         const { visible, cancel } = closeModal('purchase_pending_funds');
         const { visible, cancel } = closeModal('purchase_pending_funds');
         const loading = ref<boolean>(false);
         const loading = ref<boolean>(false);
-        const formRef = ref();
-        const formState = reactive({ PricedPrice: 0, PricedQty: 0 });
-        const numberIstrue = (rule: any, value: any) => {
-            if (!value) {
-                return Promise.reject(new Error('请输入正确的值'));
-            } else {
-                return Promise.resolve();
-            }
-        };
-        const formStateRules = {
-            PricedPrice: [{ required: true, validator: numberIstrue, trigger: 'blur', type: 'number' }],
-            PricedQty: [{ required: true, validator: numberIstrue, trigger: 'blur', type: 'number' }],
-        };
+        const { rules, formState, formRef } = handleForm();
         function submit() {
         function submit() {
             const wrapEl = unref(formRef);
             const wrapEl = unref(formRef);
             wrapEl.validate().then(() => {
             wrapEl.validate().then(() => {
                 loading.value = true;
                 loading.value = true;
-                const params : FundsReq = {
+                const params: FundsReq = {
                     PayAmount: 98,
                     PayAmount: 98,
-                    DeductAmount: 90
-                }
+                    DeductAmount: 90,
+                };
                 // 发出发票登记
                 // 发出发票登记
-                fundsReq(
-                    props.selectedRow.spotcontractid,
-                    params,
-                    loading)
+                fundsReq(props.selectedRow.spotcontractid, params, loading)
                     .then(() => {
                     .then(() => {
                         cancel();
                         cancel();
-                        context.emit('refresh')
+                        context.emit('refresh');
                     })
                     })
-                    .catch((err) => {
-                    });
+                    .catch((err) => {});
             });
             });
         }
         }
 
 
@@ -211,7 +196,7 @@ export default defineComponent({
             formRef,
             formRef,
             formState,
             formState,
             formatValue,
             formatValue,
-            formStateRules,
+            rules,
             getPriceTypeName,
             getPriceTypeName,
         };
         };
     },
     },

+ 21 - 0
src/views/business/purchase/components/funds/setup.ts

@@ -0,0 +1,21 @@
+import { reactive, ref, UnwrapRef } from "vue";
+/**
+ * 表单
+ * @returns 
+ */
+export function handleForm() {
+    interface FormState {
+        PayAmount: number | null
+        DeductAmount: number | null
+    }
+    const formRef = ref();
+    const formState: UnwrapRef<FormState> = reactive({
+        PayAmount: null,
+        DeductAmount: null,
+    })
+    const rules = {
+        // PricedPrice: [{ required: true, message: '请输入点价价格', trigger: 'blur', type: 'number' }],
+        // PricedQty: [{ required: true, message: '请输入点价数量', trigger: 'blur', type: 'number' }],
+    }
+    return { rules, formState, formRef }
+}

+ 2 - 2
src/views/business/purchase/components/settlement/setup.ts

@@ -27,8 +27,8 @@ export function handleForm() {
         Remark: ''
         Remark: ''
     })
     })
     const rules = {
     const rules = {
-        PricedPrice: [{ required: true, message: '请输入点价价格', trigger: 'blur', type: 'number' }],
-        PricedQty: [{ required: true, message: '请输入点价数量', trigger: 'blur', type: 'number' }],
+        // PricedPrice: [{ required: true, message: '请输入点价价格', trigger: 'blur', type: 'number' }],
+        // PricedQty: [{ required: true, message: '请输入点价数量', trigger: 'blur', type: 'number' }],
     }
     }
     return { rules, formState, formRef, checkedObj }
     return { rules, formState, formRef, checkedObj }
 }
 }