瀏覽代碼

修改新增现货合同

huangbin 4 年之前
父節點
當前提交
68f7e0e5bc
共有 2 個文件被更改,包括 19 次插入14 次删除
  1. 3 3
      src/common/setup/validate/index.ts
  2. 16 11
      src/views/information/spot-contract/components/add/index.vue

+ 3 - 3
src/common/setup/validate/index.ts

@@ -5,9 +5,9 @@
  * @returns 
  */
 export function validateCommon(value: any, errInfo: string) {
-    if (value) {
-        return Promise.resolve();
-    } else {
+    if (value === undefined || value === null || value === '') {
         return Promise.reject(errInfo);
+    } else {
+        return Promise.resolve();
     }
 }

+ 16 - 11
src/views/information/spot-contract/components/add/index.vue

@@ -10,7 +10,7 @@
     <template #footer>
       <a-button key="submit"
                 class="cancelBtn"
-                @click="cancel">保存草稿</a-button>
+                @click="submit">保存草稿</a-button>
       <a-button key="submit"
                 type="primary"
                 :loading="loading"
@@ -81,16 +81,14 @@
               </a-form-item>
             </a-col>
             <a-col :span="12">
-              <a-form-item label="销售方"
-                           name="SellUserID">
+              <a-form-item label="销售方">
                 <span class="white">{{getUserName()}}</span>
               </a-form-item>
             </a-col>
           </template>
           <template v-else>
             <a-col :span="12">
-              <a-form-item label="采购方"
-                           name="BuyUserID">
+              <a-form-item label="采购方">
                 <span class="white">{{getUserName()}}</span>
               </a-form-item>
             </a-col>
@@ -412,13 +410,15 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref } from 'vue';
+import { defineComponent, ref, toRaw } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods';
 import { handleFromState, handleContract, handlevalidate, handleDeliveryGoods, handlePrice, handleDate } from './setup';
 import { getUserName } from '@/services/bus/user';
 import { getGoodsList } from '@/services/bus/goods';
 import { Goods } from '@/services/go/ermcp/goodsInfo/interface';
+import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
+import { FormState } from './interface';
 
 export default defineComponent({
     name: 'add-spot-contract',
@@ -461,11 +461,15 @@ export default defineComponent({
         // 现货商品列表
         const goodsList = ref<Goods[]>([]);
         function submit() {
-            loading.value = true;
-            setTimeout(() => {
-                loading.value = false;
-                cancel();
-            }, 2000);
+            formRef.value
+                .validate()
+                .then(() => {
+                    const param = toRaw(formState);
+                    console.log('values', formState);
+                })
+                .catch((error: ValidateErrorEntity<FormState>) => {
+                    console.log('error', error);
+                });
         }
         initData(() => {
             queryCustomList();
@@ -476,6 +480,7 @@ export default defineComponent({
             visible,
             cancel,
             submit,
+            formRef,
             loading,
             maskClosableFlag: false,
             formState,