huangbin 4 лет назад
Родитель
Сommit
cf75734c81

+ 27 - 34
src/views/business/plan/components/add/index.vue

@@ -143,21 +143,20 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref, toRaw } from 'vue';
+import { defineComponent, ref } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { formatTime, initData } from '@/common/methods/index';
 import { getPayCurrencyTypeEnumList, getSpotContractTypeEnumList } from '@/common/constants/enumsList';
 import { AllEnums } from '@/services/go/commonService/interface';
 import { getMiddleGoodsD, handleForm, handleTrader } from '../setup';
-import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
-import { FormState } from '@/views/information/spot-contract/components/interface';
 import { ErmcpHedgePlanReq } from '@/services/proto/hedgeplan/interface';
 import { getLongTypeLoginID } from '@/services/bus/login';
 import { LongType } from '@/services/socket/login/interface';
-import APP from '@/services';
 import { hedgePlanReq } from '@/services/proto/hedgeplan';
 import { getAreaUserId } from '@/services/bus/user';
 import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { validateAction } from '@/common/setup/form';
+import { FormState } from '../interface';
 
 export default defineComponent({
     name: 'add-custom',
@@ -176,37 +175,31 @@ export default defineComponent({
 
         const loading = ref<boolean>(false);
         function submit(OperateType: 1 | 2) {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const loginId = getLongTypeLoginID() as LongType;
-                    const userid = getAreaUserId();
-                    const reqParam: ErmcpHedgePlanReq = {
-                        HedgePlanNo: param.HedgePlanNo, // 计划类型
-                        ContractType: param.ContractType, // 计划类型
-                        DeliveryGoodsID: Number(param.DeliveryGoodsID),
-                        WRStandardID: Number(param.WRStandardID), // 现货品种
-                        PlanQty: Number(param.PlanQty), // 计划数量
-                        OperateType: OperateType,
-                        Currencyid: param.Currencyid,
-                        ConvertFactor: param.ConvertFactor,
-                        ApplyId: Number(loginId),
-                        PlanTime: formatTime(new Date(), 's'),
-                        ProductType: 1,
-                        Biztype: 1,
-                        AreaUserID: userid,
-                        Remark: param.Remark,
-                        Tradeuserid: param.Tradeuserid, // 交易用户id
-                    };
-                    requestResultLoadingAndInfo(hedgePlanReq, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['提交申请成功', '提交申请失败:']).then(() => {
-                        context.emit('refresh');
-                        cancel();
-                    });
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const loginId = getLongTypeLoginID() as LongType;
+                const userid = getAreaUserId();
+                const reqParam: ErmcpHedgePlanReq = {
+                    HedgePlanNo: param.HedgePlanNo, // 计划类型
+                    ContractType: param.ContractType, // 计划类型
+                    DeliveryGoodsID: Number(param.DeliveryGoodsID),
+                    WRStandardID: Number(param.WRStandardID), // 现货品种
+                    PlanQty: Number(param.PlanQty), // 计划数量
+                    OperateType: OperateType,
+                    Currencyid: param.Currencyid,
+                    ConvertFactor: param.ConvertFactor,
+                    ApplyId: Number(loginId),
+                    PlanTime: formatTime(new Date(), 's'),
+                    ProductType: 1,
+                    Biztype: 1,
+                    AreaUserID: userid,
+                    Remark: param.Remark,
+                    Tradeuserid: param.Tradeuserid, // 交易用户id
+                };
+                requestResultLoadingAndInfo(hedgePlanReq, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['提交申请成功', '提交申请失败:']).then(() => {
+                    context.emit('refresh');
+                    cancel();
                 });
+            });
         }
         initData(() => {
             getDG();

+ 27 - 34
src/views/business/plan/components/modify/index.vue

@@ -140,23 +140,22 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, PropType, ref, toRaw, watchEffect } from 'vue';
+import { defineComponent, PropType, ref, watchEffect } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { formatTime, initData } from '@/common/methods/index';
 import { getPayCurrencyTypeEnumList, getSpotContractTypeEnumList } from '@/common/constants/enumsList';
 import { AllEnums } from '@/services/go/commonService/interface';
 import { getMiddleGoodsD, handleForm, handleTrader } from '../setup';
-import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
-import { FormState } from '@/views/information/spot-contract/components/interface';
+import { FormState } from '../interface';
 import { ErmcpHedgePlanReq } from '@/services/proto/hedgeplan/interface';
 import { getLongTypeLoginID } from '@/services/bus/login';
 import { LongType } from '@/services/socket/login/interface';
-import APP from '@/services';
 import { mergeTwoObj } from '@/utils/objHandle';
 import { Ermcp3HedgePlan } from '@/services/go/ermcp/plan/interface';
 import { getAreaUserId } from '@/services/bus/user';
 import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 import { hedgePlanReq } from '@/services/proto/hedgeplan';
+import { validateAction } from '@/common/setup/form';
 
 export default defineComponent({
     name: 'plan_uncommitted_modify',
@@ -189,37 +188,31 @@ export default defineComponent({
             }
         });
         function submit(OperateType: 1 | 2) {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const loginId = getLongTypeLoginID() as LongType;
-                    const userid = getAreaUserId();
-                    const reqParam: ErmcpHedgePlanReq = {
-                        HedgePlanNo: param.HedgePlanNo, // 计划类型
-                        ContractType: param.ContractType, // 计划类型
-                        DeliveryGoodsID: Number(param.DeliveryGoodsID),
-                        WRStandardID: Number(param.WRStandardID), // 现货品种
-                        PlanQty: Number(param.PlanQty), // 计划数量
-                        OperateType: OperateType,
-                        ConvertFactor: param.ConvertFactor,
-                        Currencyid: param.Currencyid,
-                        ApplyId: Number(loginId),
-                        PlanTime: formatTime(new Date(), 's'),
-                        ProductType: 1,
-                        Biztype: 1,
-                        AreaUserID: userid,
-                        Remark: param.Remark,
-                        Tradeuserid: param.Tradeuserid, // 交易用户id
-                    };
-                    requestResultLoadingAndInfo(hedgePlanReq, reqParam, loading, ['修改计划成功', '修改计划失败:']).then(() => {
-                        context.emit('refresh');
-                        cancel();
-                    });
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const loginId = getLongTypeLoginID() as LongType;
+                const userid = getAreaUserId();
+                const reqParam: ErmcpHedgePlanReq = {
+                    HedgePlanNo: param.HedgePlanNo, // 计划类型
+                    ContractType: param.ContractType, // 计划类型
+                    DeliveryGoodsID: Number(param.DeliveryGoodsID),
+                    WRStandardID: Number(param.WRStandardID), // 现货品种
+                    PlanQty: Number(param.PlanQty), // 计划数量
+                    OperateType: OperateType,
+                    ConvertFactor: param.ConvertFactor,
+                    Currencyid: param.Currencyid,
+                    ApplyId: Number(loginId),
+                    PlanTime: formatTime(new Date(), 's'),
+                    ProductType: 1,
+                    Biztype: 1,
+                    AreaUserID: userid,
+                    Remark: param.Remark,
+                    Tradeuserid: param.Tradeuserid, // 交易用户id
+                };
+                requestResultLoadingAndInfo(hedgePlanReq, reqParam, loading, ['修改计划成功', '修改计划失败:']).then(() => {
+                    context.emit('refresh');
+                    cancel();
                 });
+            });
         }
         initData(() => {
             getDG();

+ 12 - 18
src/views/information/account_info/compoments/add-business/index.vue

@@ -77,12 +77,12 @@
 
 <script lang="ts">
 import { closeModal } from '@/common/setup/modal/index';
-import { defineComponent, ref, toRaw, watchEffect } from 'vue';
-import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
+import { defineComponent, ref, watchEffect } from 'vue';
 import { handleBusinessForm } from '../setup';
 import { BusinessFormState } from '../interface';
 import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 import { loginAccountOperate } from '@/services/proto/accountinfo';
+import { validateAction } from '@/common/setup/form';
 
 export default defineComponent({
     name: 'add-business-info',
@@ -104,23 +104,17 @@ export default defineComponent({
             }
         });
         function submit() {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const reqParam = {
-                        operatetype: 1,
-                    };
-                    delete param.userid;
-                    Object.assign(reqParam, param);
-                    requestResultLoadingAndInfo(loginAccountOperate, reqParam, loading, ['新增账户成功', '新增账户失败:']).then(() => {
-                        cancel();
-                        context.emit('refresh');
-                    });
-                })
-                .catch((error: ValidateErrorEntity<BusinessFormState>) => {
-                    console.log('error', error);
+            validateAction<BusinessFormState>(formRef, formState).then((param) => {
+                const reqParam = {
+                    operatetype: 1,
+                };
+                delete param.userid;
+                Object.assign(reqParam, param);
+                requestResultLoadingAndInfo(loginAccountOperate, reqParam, loading, ['新增账户成功', '新增账户失败:']).then(() => {
+                    cancel();
+                    context.emit('refresh');
                 });
+            });
         }
         return {
             formState,

+ 32 - 39
src/views/information/custom/compoments/add/index.vue

@@ -276,16 +276,16 @@
 
 <script lang="ts">
 import { closeModal } from '@/common/setup/modal/index';
-import { defineComponent, ref, toRaw } from 'vue';
+import { defineComponent, ref } from 'vue';
 import { getCardType, handleForm } from './setup';
 import { AllEnums } from '@/services/go/commonService/interface';
 import { FormState } from './interface';
-import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
 import { getAddress } from '@/services/go/adress';
 import { AddUserInfoApplyReq } from '@/services/go/ermcp/customInfo/interface';
 import { getUserId } from '@/services/bus/account';
 import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 import { QueryAddUserInfoApply } from '@/services/go/ermcp/customInfo';
+import { validateAction } from '@/common/setup/form';
 
 export default defineComponent({
     name: 'add-custom',
@@ -306,45 +306,38 @@ export default defineComponent({
         }
 
         function submit(OperateType: 1 | 2) {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const reqParam: AddUserInfoApplyReq = {
-                        customername: param.customername, // 必填
-                        userid: 1, // 写死 必填
-                        memberareaid: getUserId(),
-                        userinfotype: Number(param.userinfotype),
-                        username: param.customername,
-                        userstate: OperateType, // 1: 保存草稿 2: 新增
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const reqParam: AddUserInfoApplyReq = {
+                    customername: param.customername, // 必填
+                    userid: 1, // 写死 必填
+                    memberareaid: getUserId(),
+                    userinfotype: Number(param.userinfotype),
+                    username: param.customername,
+                    userstate: OperateType, // 1: 保存草稿 2: 新增
 
-                        // 以上必填
-                        cardtype: param.cardtype, // 证件类型
-                        cardnum: param.cardnum, // 证件号码
-                        nickname: param.nickname, // 昵称
-                        remark: param.remark, // 备注
-                        mobilephone: param.mobilephone, //  手机号码
-                        telphone: param.telphone, // 电话
-                        cardfrontphotourl: param.cardfrontphotourl, // 正面照片
-                        cardaddress: param.cardaddress, // 证件地址
-                        cityid: param.cityid, //
-                        districtid: param.districtid, // 地区
-                        // countryid: param.,9
-                        provinceid: param.provinceid, //省
-                        contactname: param.contactname, // 联系人
-                        legalpersonname: param.legalpersonname, // 法人姓名(企业)
-                        taxpayernum: param.taxpayernum, // 纳税人识别号
-                        email: param.email, // email
-                    };
-                    requestResultLoadingAndInfo(QueryAddUserInfoApply, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['修改客户资料成功', '修改客户资料失败:']).then(() => {
-                        cancel();
-                        context.emit('refresh');
-                    });
-                    console.log('values', formState);
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
+                    // 以上必填
+                    cardtype: param.cardtype, // 证件类型
+                    cardnum: param.cardnum, // 证件号码
+                    nickname: param.nickname, // 昵称
+                    remark: param.remark, // 备注
+                    mobilephone: param.mobilephone, //  手机号码
+                    telphone: param.telphone, // 电话
+                    cardfrontphotourl: param.cardfrontphotourl, // 正面照片
+                    cardaddress: param.cardaddress, // 证件地址
+                    cityid: param.cityid, //
+                    districtid: param.districtid, // 地区
+                    // countryid: param.,9
+                    provinceid: param.provinceid, //省
+                    contactname: param.contactname, // 联系人
+                    legalpersonname: param.legalpersonname, // 法人姓名(企业)
+                    taxpayernum: param.taxpayernum, // 纳税人识别号
+                    email: param.email, // email
+                };
+                requestResultLoadingAndInfo(QueryAddUserInfoApply, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['修改客户资料成功', '修改客户资料失败:']).then(() => {
+                    cancel();
+                    context.emit('refresh');
                 });
+            });
         }
         return {
             formState,

+ 35 - 42
src/views/information/custom/compoments/modify/index.vue

@@ -276,17 +276,17 @@
 
 <script lang="ts">
 import { closeModal } from '@/common/setup/modal/index';
-import { defineComponent, PropType, ref, toRaw, watchEffect } from 'vue';
+import { defineComponent, PropType, ref, watchEffect } from 'vue';
 import { getCardType, handleForm, initFormState } from '../add/setup';
 import { AllEnums } from '@/services/go/commonService/interface';
 import { FormState } from '../add/interface';
-import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
 import { getAddress } from '@/services/go/adress';
 import { ModifyUserInfoApplyReq, QueryCustomInfoType } from '@/services/go/ermcp/customInfo/interface';
 import { getUserId } from '@/services/bus/account';
 import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 import { QueryModifyUserInfoApply } from '@/services/go/ermcp/customInfo';
 import { mergeTwoObj } from '@/utils/objHandle';
+import { validateAction } from '@/common/setup/form';
 
 export default defineComponent({
     name: 'modify-custom',
@@ -311,12 +311,12 @@ export default defineComponent({
             return formState.userinfotype === '1';
         }
 
-        const userid = ref<number>(0)
-        const countryid = ref<number>(0)
+        const userid = ref<number>(0);
+        const countryid = ref<number>(0);
         watchEffect(() => {
             if (visible.value) {
-                userid.value = props.selectedRow.userid
-                countryid.value = props.selectedRow.countryid
+                userid.value = props.selectedRow.userid;
+                countryid.value = props.selectedRow.countryid;
                 mergeTwoObj(formState, props.selectedRow);
                 const { provinceid, cityid } = props.selectedRow;
                 provinceid ? getCityList(provinceid) : (formState.provinceid = undefined);
@@ -324,43 +324,36 @@ export default defineComponent({
             }
         });
         function submit(OperateType: 1 | 2) {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const reqParam: ModifyUserInfoApplyReq = {
-                        customername: param.customername, // 必填
-                        userid: userid.value,
-                        memberareaid: getUserId(),
-                        userinfotype: Number(param.userinfotype),
-                        username: param.customername,
-                        userstate: OperateType, // 1: 保存草稿 2: 新增
-                        cardtype: param.cardtype, // 证件类型
-                        cardnum: param.cardnum, // 证件号码
-                        nickname: param.nickname, // 昵称
-                        remark: param.remark, // 备注
-                        mobilephone: param.mobilephone, //  手机号码
-                        telphone: param.telphone, // 电话
-                        cardfrontphotourl: param.cardfrontphotourl, // 正面照片
-                        cardaddress: param.cardaddress, // 证件地址
-                        cityid: param.cityid, //
-                        districtid: param.districtid, // 地区
-                        countryid: countryid.value,
-                        provinceid: param.provinceid, //省
-                        contactname: param.contactname, // 联系人
-                        legalpersonname: param.legalpersonname, // 法人姓名(企业)
-                        taxpayernum: param.taxpayernum, // 纳税人识别号
-                        email: param.email, // email
-                    };
-                    requestResultLoadingAndInfo(QueryModifyUserInfoApply, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['新增客户资料成功', '新增客户资料失败:']).then(() => {
-                        cancel();
-                        context.emit('refresh');
-                    });
-                    console.log('values', formState);
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const reqParam: ModifyUserInfoApplyReq = {
+                    customername: param.customername, // 必填
+                    userid: userid.value,
+                    memberareaid: getUserId(),
+                    userinfotype: Number(param.userinfotype),
+                    username: param.customername,
+                    userstate: OperateType, // 1: 保存草稿 2: 新增
+                    cardtype: param.cardtype, // 证件类型
+                    cardnum: param.cardnum, // 证件号码
+                    nickname: param.nickname, // 昵称
+                    remark: param.remark, // 备注
+                    mobilephone: param.mobilephone, //  手机号码
+                    telphone: param.telphone, // 电话
+                    cardfrontphotourl: param.cardfrontphotourl, // 正面照片
+                    cardaddress: param.cardaddress, // 证件地址
+                    cityid: param.cityid, //
+                    districtid: param.districtid, // 地区
+                    countryid: countryid.value,
+                    provinceid: param.provinceid, //省
+                    contactname: param.contactname, // 联系人
+                    legalpersonname: param.legalpersonname, // 法人姓名(企业)
+                    taxpayernum: param.taxpayernum, // 纳税人识别号
+                    email: param.email, // email
+                };
+                requestResultLoadingAndInfo(QueryModifyUserInfoApply, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['新增客户资料成功', '新增客户资料失败:']).then(() => {
+                    cancel();
+                    context.emit('refresh');
                 });
+            });
         }
         return {
             formState,

+ 40 - 46
src/views/information/goods/components/add/index.vue

@@ -276,19 +276,20 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref, toRaw, watchEffect } from 'vue';
+import { defineComponent, ref } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods/index';
 import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue';
 import { handleFromState, handleGoodsGroup } from './setup';
-import { RuleObject, ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
+import { RuleObject } from 'ant-design-vue/es/form/interface';
 import { FormState, WRSConvertDetailEx } from './interface';
 import { validateCommon } from '@/common/setup/validate';
 import { getGoodsUnitEnumList } from '@/common/constants/enumsList';
 import { getGoodsUnitEnumItemName } from '@/common/constants/enumsName';
-import {requestResultLoadingAndInfo} from "@/common/methods/request/resultInfo";
-import {DeliveryGoodsApplyReq} from "@/services/proto/delivery/interface";
-import {addDeliveryGoodsApply} from "@/services/proto/delivery";
+import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { DeliveryGoodsApplyReq } from '@/services/proto/delivery/interface';
+import { addDeliveryGoodsApply } from '@/services/proto/delivery';
+import { validateAction } from '@/common/setup/form';
 
 /**
  * 检验单位
@@ -318,48 +319,41 @@ export default defineComponent({
         // 单位列表
         const unitList = getGoodsUnitEnumList();
         function submit() {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const unitid = param.unitid === undefined ? 0 : param.unitid
-                    const reqParam: DeliveryGoodsApplyReq = {
-                        deliverygoodscode: param.deliverygoodscode,
-                        deliverygoodsname: param.deliverygoodsname,
-                        unitid: unitid,
-                        type: 1,
-                        remark: param.remark,
-                        gldwrstandards: param.gldwrstandards.map(value => {
-                            const gldunitid = value.unitid === undefined ? 0 : value.unitid
-                            const convertfactors: any = value.convertfactor === null ? 0 : value.convertfactor
-                            return {
-                                wrstandardid: value.wrstandardid,
-                                wrstandardname: value.wrstandardname,
-                                unitid: gldunitid,
-                                convertfactor: (convertfactors as string) ? Number(convertfactors) : convertfactors
-                            }
-                        }),
-                        glddgfactoryItems: param.glddgfactoryItems,
-                        wrsconvertdetails: param.wrsconvertdetails.map(value => {
-                            const middlegoodsid = value.middlegoodsid === undefined ? 0 : value.middlegoodsid
-                            const convertratio: any = value.convertratio === null ? 0 : value.convertratio
-                            const wrsunitid = value.unitid === null ? 0 : value.unitid
-                            return {
-                                middlegoodsid: middlegoodsid,
-                                convertratio: (convertratio as string) ? Number(convertratio) : convertratio,
-                                unitid: wrsunitid
-                            }
-                        })
-                    }
-                    requestResultLoadingAndInfo(addDeliveryGoodsApply, reqParam, loading, ['新增现货品种成功', '新增现货品种失败:']).then(() => {
-                        cancel();
-                        context.emit('refresh');
-                    });
-                    console.log('param', param);
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const unitid = param.unitid === undefined ? 0 : param.unitid;
+                const reqParam: DeliveryGoodsApplyReq = {
+                    deliverygoodscode: param.deliverygoodscode,
+                    deliverygoodsname: param.deliverygoodsname,
+                    unitid: unitid,
+                    type: 1,
+                    remark: param.remark,
+                    gldwrstandards: param.gldwrstandards.map((value) => {
+                        const gldunitid = value.unitid === undefined ? 0 : value.unitid;
+                        const convertfactors: any = value.convertfactor === null ? 0 : value.convertfactor;
+                        return {
+                            wrstandardid: value.wrstandardid,
+                            wrstandardname: value.wrstandardname,
+                            unitid: gldunitid,
+                            convertfactor: (convertfactors as string) ? Number(convertfactors) : convertfactors,
+                        };
+                    }),
+                    glddgfactoryItems: param.glddgfactoryItems,
+                    wrsconvertdetails: param.wrsconvertdetails.map((value) => {
+                        const middlegoodsid = value.middlegoodsid === undefined ? 0 : value.middlegoodsid;
+                        const convertratio: any = value.convertratio === null ? 0 : value.convertratio;
+                        const wrsunitid = value.unitid === null ? 0 : value.unitid;
+                        return {
+                            middlegoodsid: middlegoodsid,
+                            convertratio: (convertratio as string) ? Number(convertratio) : convertratio,
+                            unitid: wrsunitid,
+                        };
+                    }),
+                };
+                requestResultLoadingAndInfo(addDeliveryGoodsApply, reqParam, loading, ['新增现货品种成功', '新增现货品种失败:']).then(() => {
+                    cancel();
+                    context.emit('refresh');
                 });
+            });
         }
 
         // 表单

+ 24 - 28
src/views/information/goods/components/hedgingModify/index.vue

@@ -63,17 +63,18 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, PropType, ref, toRaw } from 'vue';
+import { defineComponent, PropType, ref } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods/index';
 import { initMG } from '../../list/hedging-variety/setup';
 import { Ermcp3MiddleGoodsDetail2 } from '@/services/go/ermcp/goodsInfo/interface';
 import { getGoodsUnitEnumItemName } from '@/common/constants/enumsName';
 import { handleForm } from './setup';
-import {deliveryGoodsCancel, ermsMiddelGoodsEdit} from '@/services/proto/delivery';
-import { message } from 'ant-design-vue';
+import { ermsMiddelGoodsEdit } from '@/services/proto/delivery';
 import { ErmsMiddelGoodsEditReq } from '@/services/proto/delivery/interface';
-import {requestResultLoadingAndInfo} from "@/common/methods/request/resultInfo";
+import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { validateAction } from '@/common/setup/form';
+import { FormState } from './interface';
 
 export default defineComponent({
     name: 'modify-custom',
@@ -92,31 +93,26 @@ export default defineComponent({
 
         const loading = ref<boolean>(false);
         function submit() {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const { middlegoodsid, goodsunitid, relatedgoodsid, evaluateratio, qtydecimalplace, relatedgoodstype, goodsgroupid, remark } = props.selctedMG.mg;
-                    const param: ErmsMiddelGoodsEditReq = {
-                        middlegoodsid, // uint64 套保品种ID
-                        goodsunitid, // int32 单位ID
-                        relatedgoodsid, // uint64 关联交易商品ID
-                        evaluateratio, // double 估价系数
-                        qtydecimalplace, // int32 数量小数位
-                        // modifierid,// uint64 修改人
-                        relatedgoodstype, // int32 关联商品类型 - 1:期货合约 2:现货品种
-                        needhedgeratio: formState.needhedgeratio as number, // double 套保比率
-                        // areauserid?,// uint64 机构用户ID
-                        goodsgroupid, // uint64 关联期货品种ID
-                        remark, // string 备注
-                    };
-                    requestResultLoadingAndInfo(ermsMiddelGoodsEdit, param, loading, ['修改成功', '修改失败:']).then(() => {
-                        cancel();
-                        context.emit('refresh');
-                    });
-                })
-                .catch((error: any) => {
-                    console.log('error', error);
+            validateAction<FormState>(formRef, formState).then(() => {
+                const { middlegoodsid, goodsunitid, relatedgoodsid, evaluateratio, qtydecimalplace, relatedgoodstype, goodsgroupid, remark } = props.selctedMG.mg;
+                const param: ErmsMiddelGoodsEditReq = {
+                    middlegoodsid, // uint64 套保品种ID
+                    goodsunitid, // int32 单位ID
+                    relatedgoodsid, // uint64 关联交易商品ID
+                    evaluateratio, // double 估价系数
+                    qtydecimalplace, // int32 数量小数位
+                    // modifierid,// uint64 修改人
+                    relatedgoodstype, // int32 关联商品类型 - 1:期货合约 2:现货品种
+                    needhedgeratio: formState.needhedgeratio as number, // double 套保比率
+                    // areauserid?,// uint64 机构用户ID
+                    goodsgroupid, // uint64 关联期货品种ID
+                    remark, // string 备注
+                };
+                requestResultLoadingAndInfo(ermsMiddelGoodsEdit, param, loading, ['修改成功', '修改失败:']).then(() => {
+                    cancel();
+                    context.emit('refresh');
                 });
+            });
         }
         initData(() => {});
         return {

+ 3 - 0
src/views/information/goods/components/hedgingModify/interface.ts

@@ -0,0 +1,3 @@
+export interface FormState {
+    needhedgeratio: number | null
+}

+ 1 - 3
src/views/information/goods/components/hedgingModify/setup.ts

@@ -1,14 +1,12 @@
 import { ermsMiddelGoodsEdit } from "@/services/proto/delivery";
 import { ErmsMiddelGoodsEditReq } from "@/services/proto/delivery/interface";
 import { reactive, ref, UnwrapRef } from "vue";
+import { FormState } from './interface';
 /**
  * 表单
  * @returns 
  */
 export function handleForm() {
-    interface FormState {
-        needhedgeratio: number | null
-    }
     const formRef = ref();
     const formState: UnwrapRef<FormState> = reactive({
         needhedgeratio: null,

+ 307 - 312
src/views/information/goods/components/modify/index.vue

@@ -1,297 +1,298 @@
 <template>
-    <!-- 修改现货品种 -->
-    <a-modal class="commonModal addSpotVariety"
-             title="修改现货品种"
-             v-if="visible"
-             v-model:visible="visible"
-             centered
-             :maskClosable="maskClosableFlag"
-             @cancel="cancel"
-             width="890px">
-        <template #footer>
-            <a-button key="submit"
-                      type="primary"
-                      :loading="loading"
-                      @click="submit">完成
-            </a-button>
-        </template>
-        <a-form class="inlineForm"
-                ref="formRef"
-                :model="formState"
-                :rules="rules">
-            <fieldset class="formFieldSet">
-                <legend>基本信息</legend>
-                <a-row :gutter="24">
-                    <a-col :span="12">
-                        <a-form-item label="现货品种名称"
-                                     name="deliverygoodsname">
-                            <a-input class="dialogInput"
-                                     v-model:value="formState.deliverygoodsname"
-                                     style="width: 200px"
-                                     placeholder="请输入现货品种名称"/>
-                        </a-form-item>
-                    </a-col>
-                    <a-col :span="12">
-                        <a-form-item label="现货品种代码"
-                                     name="deliverygoodscode">
-                            <a-input class="dialogInput"
-                                     style="width: 200px"
-                                     v-model:value="formState.deliverygoodscode"
-                                     placeholder="请输入现货品种代码"/>
-                        </a-form-item>
-                    </a-col>
-                </a-row>
-                <a-row :gutter="24">
-                    <a-col :span="24">
-                        <a-form-item label="单位"
-                                     name="unitid">
-                            <a-select class="inlineFormSelect"
-                                      style="width: 200px"
-                                      v-model:value="formState.unitid"
-                                      placeholder="请选择单位">
-                                <a-select-option v-for="item in unitList"
-                                                 :value="item.enumitemname"
-                                                 :key="item.autoid">
-                                    {{ item.enumdicname }}
-                                </a-select-option>
-                            </a-select>
-                        </a-form-item>
-                    </a-col>
-                </a-row>
-                <a-row :gutter="24">
-                    <a-col :span="24">
-                        <a-form-item label="备注"
-                                     name="remark">
-                            <a-input class="dialogInput"
-                                     v-model:value="formState.remark"
-                                     style="width: 588px"
-                                     placeholder="请输入备注"/>
-                        </a-form-item>
-                    </a-col>
-                </a-row>
-            </fieldset>
-            <fieldset class="formFieldSet">
-                <legend>品类信息</legend>
-                <a-row :gutter="24"
-                       class="dialogRowTitle">
-                    <a-col :span="6">
+  <!-- 修改现货品种 -->
+  <a-modal class="commonModal addSpotVariety"
+           title="修改现货品种"
+           v-if="visible"
+           v-model:visible="visible"
+           centered
+           :maskClosable="maskClosableFlag"
+           @cancel="cancel"
+           width="890px">
+    <template #footer>
+      <a-button key="submit"
+                type="primary"
+                :loading="loading"
+                @click="submit">完成
+      </a-button>
+    </template>
+    <a-form class="inlineForm"
+            ref="formRef"
+            :model="formState"
+            :rules="rules">
+      <fieldset class="formFieldSet">
+        <legend>基本信息</legend>
+        <a-row :gutter="24">
+          <a-col :span="12">
+            <a-form-item label="现货品种名称"
+                         name="deliverygoodsname">
+              <a-input class="dialogInput"
+                       v-model:value="formState.deliverygoodsname"
+                       style="width: 200px"
+                       placeholder="请输入现货品种名称" />
+            </a-form-item>
+          </a-col>
+          <a-col :span="12">
+            <a-form-item label="现货品种代码"
+                         name="deliverygoodscode">
+              <a-input class="dialogInput"
+                       style="width: 200px"
+                       v-model:value="formState.deliverygoodscode"
+                       placeholder="请输入现货品种代码" />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item label="单位"
+                         name="unitid">
+              <a-select class="inlineFormSelect"
+                        style="width: 200px"
+                        v-model:value="formState.unitid"
+                        placeholder="请选择单位">
+                <a-select-option v-for="item in unitList"
+                                 :value="item.enumitemname"
+                                 :key="item.autoid">
+                  {{ item.enumdicname }}
+                </a-select-option>
+              </a-select>
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item label="备注"
+                         name="remark">
+              <a-input class="dialogInput"
+                       v-model:value="formState.remark"
+                       style="width: 588px"
+                       placeholder="请输入备注" />
+            </a-form-item>
+          </a-col>
+        </a-row>
+      </fieldset>
+      <fieldset class="formFieldSet">
+        <legend>品类信息</legend>
+        <a-row :gutter="24"
+               class="dialogRowTitle">
+          <a-col :span="6">
             <span>
               <span class="red">*</span>
               品类
             </span>
-                    </a-col>
-                    <a-col :span="6">
+          </a-col>
+          <a-col :span="6">
             <span>
               <span class="red">*</span>
               单位
             </span>
-                    </a-col>
-                    <a-col :span="6">
+          </a-col>
+          <a-col :span="6">
             <span>
               <span class="red">*</span>
               标仓系数
             </span>
-                    </a-col>
-                    <a-col :span="6">
+          </a-col>
+          <a-col :span="6">
             <span>
               操作
             </span>
-                    </a-col>
-                    <template v-for="(domain, index) in formState.gldwrstandards"
-                              :key="domain.index + 'domain'">
-                        <a-col :span="6">
-                            <a-form-item :name="['gldwrstandards',index, 'wrstandardname', ]"
-                                         :rules="rules.gldwrstandards.wrstandardname">
-                                <a-input class="dialogInput"
-                                         v-model:value="domain.wrstandardname"
-                                         placeholder="请输入品类"></a-input>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="6">
-                            <a-form-item :name="['gldwrstandards',index,'unitid' ]"
-                                         :rules="rules.gldwrstandards.unitid">
-                                <a-select class="inlineFormSelect"
-                                          v-model:value="domain.unitid"
-                                          placeholder="请选择单位">
-                                    <a-select-option v-for="item in unitList"
-                                                     :value="item.enumitemname"
-                                                     :key="item.autoid">
-                                        {{ item.enumdicname }}
-                                    </a-select-option>
-                                </a-select>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="6">
-                            <a-form-item :name="['gldwrstandards',index,'convertfactor']"
-                                         :rules="rules.gldwrstandards.convertfactor">
-                                <a-input-number class="dialogInput"
-                                                style="width: 200px"
-                                                v-model:value="domain.convertfactor"
-                                                placeholder="请输入标仓系数"></a-input-number>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="6"
-                               class="tc">
-                            <a-button class="plusBtn"
-                                      @click="deleteOne('gldwrstandards', index)"
-                                      v-if="index > 0">
-                                <template #icon>
-                                    <MinusOutlined/>
-                                </template>
-                            </a-button>
-                            <a-button class="minusBtn"
-                                      @click="addOne('gldwrstandards')">
-                                <template #icon>
-                                    <PlusOutlined/>
-                                </template>
-                            </a-button>
-                        </a-col>
-                    </template>
-                </a-row>
-            </fieldset>
-            <fieldset class="formFieldSet">
-                <legend>品牌信息</legend>
-                <a-row :gutter="24"
-                       class="dialogRowTitle dialogRowTitle2">
-                    <a-col :span="12">
+          </a-col>
+          <template v-for="(domain, index) in formState.gldwrstandards"
+                    :key="domain.index + 'domain'">
+            <a-col :span="6">
+              <a-form-item :name="['gldwrstandards',index, 'wrstandardname', ]"
+                           :rules="rules.gldwrstandards.wrstandardname">
+                <a-input class="dialogInput"
+                         v-model:value="domain.wrstandardname"
+                         placeholder="请输入品类"></a-input>
+              </a-form-item>
+            </a-col>
+            <a-col :span="6">
+              <a-form-item :name="['gldwrstandards',index,'unitid' ]"
+                           :rules="rules.gldwrstandards.unitid">
+                <a-select class="inlineFormSelect"
+                          v-model:value="domain.unitid"
+                          placeholder="请选择单位">
+                  <a-select-option v-for="item in unitList"
+                                   :value="item.enumitemname"
+                                   :key="item.autoid">
+                    {{ item.enumdicname }}
+                  </a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
+            <a-col :span="6">
+              <a-form-item :name="['gldwrstandards',index,'convertfactor']"
+                           :rules="rules.gldwrstandards.convertfactor">
+                <a-input-number class="dialogInput"
+                                style="width: 200px"
+                                v-model:value="domain.convertfactor"
+                                placeholder="请输入标仓系数"></a-input-number>
+              </a-form-item>
+            </a-col>
+            <a-col :span="6"
+                   class="tc">
+              <a-button class="plusBtn"
+                        @click="deleteOne('gldwrstandards', index)"
+                        v-if="index > 0">
+                <template #icon>
+                  <MinusOutlined />
+                </template>
+              </a-button>
+              <a-button class="minusBtn"
+                        @click="addOne('gldwrstandards')">
+                <template #icon>
+                  <PlusOutlined />
+                </template>
+              </a-button>
+            </a-col>
+          </template>
+        </a-row>
+      </fieldset>
+      <fieldset class="formFieldSet">
+        <legend>品牌信息</legend>
+        <a-row :gutter="24"
+               class="dialogRowTitle dialogRowTitle2">
+          <a-col :span="12">
             <span>
               <span class="red">*</span>
               品牌
             </span>
-                    </a-col>
-                    <a-col :span="12">
+          </a-col>
+          <a-col :span="12">
             <span>
               操作
             </span>
-                    </a-col>
-                    <template v-for="(domain, index) in formState.glddgfactoryItems"
-                              :key="domain.index + 'domain'">
-                        <a-col :span="12">
-                            <a-form-item :name="['glddgfactoryItems',index,'dgfactoryitemvalue']"
-                                         :rules="rules.glddgfactoryItems.dgfactoryitemvalue">
-                                <a-input class="dialogInput"
-                                         v-model:value="domain.dgfactoryitemvalue"
-                                         placeholder="请输入品牌"></a-input>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="12">
-                            <a-button class="plusBtn"
-                                      @click="deleteOne('glddgfactoryItems', index)"
-                                      v-if="index > 0">
-                                <template #icon>
-                                    <MinusOutlined/>
-                                </template>
-                            </a-button>
-                            <a-button class="minusBtn"
-                                      @click="addOne('glddgfactoryItems')">
-                                <template #icon>
-                                    <PlusOutlined/>
-                                </template>
-                            </a-button>
-                        </a-col>
-                    </template>
-                </a-row>
-            </fieldset>
-            <fieldset class="formFieldSet">
-                <legend>套保品种信息</legend>
-                <a-row :gutter="24"
-                       class="dialogRowTitle">
-                    <a-col :span="6">
+          </a-col>
+          <template v-for="(domain, index) in formState.glddgfactoryItems"
+                    :key="domain.index + 'domain'">
+            <a-col :span="12">
+              <a-form-item :name="['glddgfactoryItems',index,'dgfactoryitemvalue']"
+                           :rules="rules.glddgfactoryItems.dgfactoryitemvalue">
+                <a-input class="dialogInput"
+                         v-model:value="domain.dgfactoryitemvalue"
+                         placeholder="请输入品牌"></a-input>
+              </a-form-item>
+            </a-col>
+            <a-col :span="12">
+              <a-button class="plusBtn"
+                        @click="deleteOne('glddgfactoryItems', index)"
+                        v-if="index > 0">
+                <template #icon>
+                  <MinusOutlined />
+                </template>
+              </a-button>
+              <a-button class="minusBtn"
+                        @click="addOne('glddgfactoryItems')">
+                <template #icon>
+                  <PlusOutlined />
+                </template>
+              </a-button>
+            </a-col>
+          </template>
+        </a-row>
+      </fieldset>
+      <fieldset class="formFieldSet">
+        <legend>套保品种信息</legend>
+        <a-row :gutter="24"
+               class="dialogRowTitle">
+          <a-col :span="6">
             <span>
               <span class="red">*</span>
               套保品种
             </span>
-                    </a-col>
-                    <a-col :span="6">
+          </a-col>
+          <a-col :span="6">
             <span>
               <span class="red">*</span>
               单位
             </span>
-                    </a-col>
-                    <a-col :span="6">
+          </a-col>
+          <a-col :span="6">
             <span>
               <span class="red">*</span>
               套保系数
             </span>
-                    </a-col>
-                    <a-col :span="6">
+          </a-col>
+          <a-col :span="6">
             <span>
               操作
             </span>
-                    </a-col>
-                    <template v-for="(domain, index) in formState.wrsconvertdetails"
-                              :key="domain.index + 'domain'">
-                        <a-col :span="6">
-                            <a-form-item :name="['wrsconvertdetails',index,'middlegoodsid']"
-                                         :rules="rules.wrsconvertdetails.middlegoodsid">
-                                <a-select class="inlineFormSelect"
-                                          @change="middleChange(domain.middlegoodsid, domain)"
-                                          v-model:value="domain.middlegoodsid"
-                                          placeholder="请选择套保品种">
-                                    <a-select-option v-for="item in goodsGroup"
-                                                     :value="item.goodsgroupid"
-                                                     :key="item.goodsgroupid">
-                                        {{ item.goodsgroupname }}
-                                    </a-select-option>
-                                </a-select>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="6">
-                            <a-form-item :name="['wrsconvertdetails', index, 'unitidName']">
-                                <a-input class="dialogInput"
-                                         readonly
-                                         v-model:value="domain.unitidName"
-                                         placeholder="选择套保品种后自动填入"></a-input>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="6">
-                            <a-form-item :name="['wrsconvertdetails', index, 'convertratio']"
-                                         :rules="rules.wrsconvertdetails.convertratio">
-                                <a-input-number class="dialogInput"
-                                                style="width: 200px"
-                                                v-model:value="domain.convertratio"
-                                                placeholder="请输入套保系数"></a-input-number>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="6"
-                               class="tc">
-                            <a-button class="plusBtn"
-                                      @click="deleteOne('wrsconvertdetails', index)"
-                                      v-if="index > 0">
-                                <template #icon>
-                                    <MinusOutlined/>
-                                </template>
-                            </a-button>
-                            <a-button class="minusBtn"
-                                      @click="addOne('wrsconvertdetails')">
-                                <template #icon>
-                                    <PlusOutlined/>
-                                </template>
-                            </a-button>
-                        </a-col>
-                    </template>
-                </a-row>
-            </fieldset>
-        </a-form>
-    </a-modal>
+          </a-col>
+          <template v-for="(domain, index) in formState.wrsconvertdetails"
+                    :key="domain.index + 'domain'">
+            <a-col :span="6">
+              <a-form-item :name="['wrsconvertdetails',index,'middlegoodsid']"
+                           :rules="rules.wrsconvertdetails.middlegoodsid">
+                <a-select class="inlineFormSelect"
+                          @change="middleChange(domain.middlegoodsid, domain)"
+                          v-model:value="domain.middlegoodsid"
+                          placeholder="请选择套保品种">
+                  <a-select-option v-for="item in goodsGroup"
+                                   :value="item.goodsgroupid"
+                                   :key="item.goodsgroupid">
+                    {{ item.goodsgroupname }}
+                  </a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
+            <a-col :span="6">
+              <a-form-item :name="['wrsconvertdetails', index, 'unitidName']">
+                <a-input class="dialogInput"
+                         readonly
+                         v-model:value="domain.unitidName"
+                         placeholder="选择套保品种后自动填入"></a-input>
+              </a-form-item>
+            </a-col>
+            <a-col :span="6">
+              <a-form-item :name="['wrsconvertdetails', index, 'convertratio']"
+                           :rules="rules.wrsconvertdetails.convertratio">
+                <a-input-number class="dialogInput"
+                                style="width: 200px"
+                                v-model:value="domain.convertratio"
+                                placeholder="请输入套保系数"></a-input-number>
+              </a-form-item>
+            </a-col>
+            <a-col :span="6"
+                   class="tc">
+              <a-button class="plusBtn"
+                        @click="deleteOne('wrsconvertdetails', index)"
+                        v-if="index > 0">
+                <template #icon>
+                  <MinusOutlined />
+                </template>
+              </a-button>
+              <a-button class="minusBtn"
+                        @click="addOne('wrsconvertdetails')">
+                <template #icon>
+                  <PlusOutlined />
+                </template>
+              </a-button>
+            </a-col>
+          </template>
+        </a-row>
+      </fieldset>
+    </a-form>
+  </a-modal>
 </template>
 
 <script lang="ts">
-import {defineComponent, PropType, ref, toRaw, watchEffect} from 'vue';
-import {closeModal} from '@/common/setup/modal/index';
-import {initData} from '@/common/methods/index';
-import {PlusOutlined, MinusOutlined} from '@ant-design/icons-vue';
-import {handleFromState, handleGoodsGroup} from './setup';
-import {RuleObject, ValidateErrorEntity} from 'ant-design-vue/es/form/interface';
-import {FormState, WRSConvertDetailEx} from './interface';
-import {validateCommon} from '@/common/setup/validate';
-import {initDG} from '../../list/spot-variety/setup';
-import {ErmcpDeliveryGoodsDetailEx, ErmcpDeliveryGoods} from '@/services/go/ermcp/goodsInfo/interface';
-import {mergeTwoObj} from '@/utils/objHandle';
-import {getGoodsUnitEnumList} from '@/common/constants/enumsList';
-import {requestResultLoadingAndInfo} from "@/common/methods/request/resultInfo";
-import {addDeliveryGoodsApply, ermsMiddelGoodsEdit} from "@/services/proto/delivery";
-import {DeliveryGoodsApplyReq} from "@/services/proto/delivery/interface";
+import { defineComponent, PropType, ref, watchEffect } from 'vue';
+import { closeModal } from '@/common/setup/modal/index';
+import { initData } from '@/common/methods/index';
+import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue';
+import { handleFromState, handleGoodsGroup } from './setup';
+import { RuleObject } from 'ant-design-vue/es/form/interface';
+import { FormState, WRSConvertDetailEx } from './interface';
+import { validateCommon } from '@/common/setup/validate';
+import { initDG } from '../../list/spot-variety/setup';
+import { ErmcpDeliveryGoodsDetailEx } from '@/services/go/ermcp/goodsInfo/interface';
+import { mergeTwoObj } from '@/utils/objHandle';
+import { getGoodsUnitEnumList } from '@/common/constants/enumsList';
+import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { addDeliveryGoodsApply } from '@/services/proto/delivery';
+import { DeliveryGoodsApplyReq } from '@/services/proto/delivery/interface';
+import { validateAction } from '@/common/setup/form';
 
 interface Obj {
     [props: string]: any;
@@ -325,7 +326,7 @@ export default defineComponent({
     },
     setup(props, context) {
         // 控制关闭弹窗
-        const {visible, cancel} = closeModal('goods_info_spot_normal_modify');
+        const { visible, cancel } = closeModal('goods_info_spot_normal_modify');
         // 下单方法
         const loading = ref<boolean>(false);
 
@@ -334,71 +335,65 @@ export default defineComponent({
 
         // 表单
         const formRef = ref();
-        const {formState, addOne, deleteOne} = handleFromState();
+        const { formState, addOne, deleteOne } = handleFromState();
         const rules = {
-            deliverygoodsname: [{required: true, message: '请输入现货品种名称', trigger: 'blur'}],
+            deliverygoodsname: [{ required: true, message: '请输入现货品种名称', trigger: 'blur' }],
             // unitid: [{ required: true, message: '请选择单位', trigger: 'change' }],
-            unitid: [{required: true, validator: validateUnit, trigger: 'change'}],
+            unitid: [{ required: true, validator: validateUnit, trigger: 'change' }],
             gldwrstandards: {
-                unitid: {required: true, validator: validateUnit, trigger: 'change'},
-                wrstandardname: {required: true, message: '请输入品类', trigger: 'blur'},
-                convertfactor: {required: true, message: '请输入标仓系数', trigger: 'blur'},
+                unitid: { required: true, validator: validateUnit, trigger: 'change' },
+                wrstandardname: { required: true, message: '请输入品类', trigger: 'blur' },
+                convertfactor: { required: true, message: '请输入标仓系数', trigger: 'blur' },
             },
             glddgfactoryItems: {
-                dgfactoryitemvalue: {required: true, message: '请输入品牌', trigger: 'blur'},
+                dgfactoryitemvalue: { required: true, message: '请输入品牌', trigger: 'blur' },
             },
             wrsconvertdetails: {
-                middlegoodsid: {required: true, validator: valideteWR, trigger: 'change'},
-                convertratio: {required: true, message: '请输入套保系数', trigger: 'blur'},
+                middlegoodsid: { required: true, validator: valideteWR, trigger: 'change' },
+                convertratio: { required: true, message: '请输入套保系数', trigger: 'blur' },
             },
         };
 
         function submit() {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const unitid = param.unitid === undefined ? 0 : param.unitid
-                    const reqParam: DeliveryGoodsApplyReq = {
-                        deliverygoodsid: param.deliverygoodsid,
-                        unitid: unitid,
-                        deliverygoodsname: param.deliverygoodsname,
-                        deliverygoodscode: param.deliverygoodscode,
-                        type: 2,
-                        remark: param.remark,
-                        gldwrstandards: param.gldwrstandards.map(value => {
-                            const gldunitid = value.unitid === undefined ? 0 : value.unitid
-                            const convertfactors: any = value.convertfactor === null ? 0 : value.convertfactor
-                            return {
-                                wrstandardid: value.wrstandardid,
-                                wrstandardname: value.wrstandardname,
-                                unitid: gldunitid,
-                                convertfactor: (convertfactors as string) ? Number(convertfactors) : convertfactors
-                            }
-                        }),
-                        glddgfactoryItems: param.glddgfactoryItems,
-                        wrsconvertdetails: param.wrsconvertdetails.map(value => {
-                            const middlegoodsid = value.middlegoodsid === undefined ? 0 : value.middlegoodsid
-                            const convertratio: any = value.convertratio === null ? 0 : value.convertratio
-                            const wrsunitid = value.unitid === null ? 0 : value.unitid
-                            return {
-                                middlegoodsid: middlegoodsid,
-                                convertratio: convertratio ? Number(convertratio) : convertratio,
-                                unitid: wrsunitid
-                            }
-                        })
-                    }
-                    requestResultLoadingAndInfo(addDeliveryGoodsApply, reqParam, loading, ['修改现货品种成功', '修改现货品种失败:']).then(() => {
-                        cancel();
-                        context.emit('refresh');
-                    });
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const unitid = param.unitid === undefined ? 0 : param.unitid;
+                const reqParam: DeliveryGoodsApplyReq = {
+                    deliverygoodsid: param.deliverygoodsid,
+                    unitid: unitid,
+                    deliverygoodsname: param.deliverygoodsname,
+                    deliverygoodscode: param.deliverygoodscode,
+                    type: 2,
+                    remark: param.remark,
+                    gldwrstandards: param.gldwrstandards.map((value) => {
+                        const gldunitid = value.unitid === undefined ? 0 : value.unitid;
+                        const convertfactors: any = value.convertfactor === null ? 0 : value.convertfactor;
+                        return {
+                            wrstandardid: value.wrstandardid,
+                            wrstandardname: value.wrstandardname,
+                            unitid: gldunitid,
+                            convertfactor: (convertfactors as string) ? Number(convertfactors) : convertfactors,
+                        };
+                    }),
+                    glddgfactoryItems: param.glddgfactoryItems,
+                    wrsconvertdetails: param.wrsconvertdetails.map((value) => {
+                        const middlegoodsid = value.middlegoodsid === undefined ? 0 : value.middlegoodsid;
+                        const convertratio: any = value.convertratio === null ? 0 : value.convertratio;
+                        const wrsunitid = value.unitid === null ? 0 : value.unitid;
+                        return {
+                            middlegoodsid: middlegoodsid,
+                            convertratio: convertratio ? Number(convertratio) : convertratio,
+                            unitid: wrsunitid,
+                        };
+                    }),
+                };
+                requestResultLoadingAndInfo(addDeliveryGoodsApply, reqParam, loading, ['修改现货品种成功', '修改现货品种失败:']).then(() => {
+                    cancel();
+                    context.emit('refresh');
                 });
+            });
         }
 
-        const {goodsGroup, getGoodsGroup} = handleGoodsGroup();
+        const { goodsGroup, getGoodsGroup } = handleGoodsGroup();
 
         /**
          * 切换套保品种时候,获取对应的单位
@@ -413,29 +408,29 @@ export default defineComponent({
 
         watchEffect(() => {
             if (props.selctedDeliveryGoods.data.deliverygoodsname) {
-                const {data, gblist, gmlist, mgList} = props.selctedDeliveryGoods;
+                const { data, gblist, gmlist, mgList } = props.selctedDeliveryGoods;
                 mergeTwoObj(formState, props.selctedDeliveryGoods);
                 mergeTwoObj(formState, data);
                 // 单位
                 formState.unitid = data.agreeunit;
                 // 品类
                 formState.gldwrstandards = gmlist.map((e) => {
-                    const {wrstandardid, wrstandardname, convertfactor, unitid} = e;
-                    return {wrstandardid, wrstandardname, convertfactor: convertfactor.toString(), unitid};
+                    const { wrstandardid, wrstandardname, convertfactor, unitid } = e;
+                    return { wrstandardid, wrstandardname, convertfactor: convertfactor.toString(), unitid };
                 });
                 // 品牌
                 formState.glddgfactoryItems = gblist.map((e) => {
-                    const {brandid, brandname} = e;
-                    return {dgfactoryitemid: brandid, dgfactoryitemvalue: brandname};
+                    const { brandid, brandname } = e;
+                    return { dgfactoryitemid: brandid, dgfactoryitemvalue: brandname };
                 });
                 // 套保信息
                 formState.wrsconvertdetails = mgList.map((e) => {
-                    const {goodsgroupid, goodsunitid, enumdicname} = e.mg;
+                    const { goodsgroupid, goodsunitid, enumdicname } = e.mg;
                     return {
                         middlegoodsid: goodsgroupid,
                         unitid: goodsunitid,
                         unitidName: enumdicname,
-                        convertratio: e.convertratio.toString()
+                        convertratio: e.convertratio.toString(),
                     };
                 });
             }

+ 32 - 38
src/views/information/spot-contract/components/add/index.vue

@@ -423,6 +423,7 @@ import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
 import { handleAccountManager } from '../setup';
 import { Moment } from 'moment';
 import { handleFormRule, handleContract, handleDeliveryGoods, handleAmout, handlePrice, handleDate, handleFromState } from '../setup';
+import { validateAction } from '@/common/setup/form';
 
 export default defineComponent({
     name: 'add-spot-contract',
@@ -459,42 +460,35 @@ export default defineComponent({
         const goodsList = ref<Goods[]>([]);
 
         function submit(OperateType: 1 | 2) {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const id = getUsrId();
-                    isSell.value ? (param.SellUserID = id) : (param.BuyUserID = id);
-                    const fn = (value: Moment) => {
-                        return formatTime(value, 'd') + ' ' + '00:00:00';
-                    };
-                    // 交收期
-                    const dDate = deliveryDate.value;
-                    if (dDate.length) {
-                        const DeliveryStartDate = fn(dDate[0]);
-                        const DeliveryEndDate = fn(dDate[1]);
-                        Object.assign(param, { DeliveryStartDate, DeliveryEndDate });
-                    }
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const id = getUsrId();
+                isSell.value ? (param.SellUserID = id) : (param.BuyUserID = id);
+                const fn = (value: Moment) => {
+                    return formatTime(value, 'd') + ' ' + '00:00:00';
+                };
+                // 交收期
+                const dDate = deliveryDate.value;
+                if (dDate.length) {
+                    const DeliveryStartDate = fn(dDate[0]);
+                    const DeliveryEndDate = fn(dDate[1]);
+                    Object.assign(param, { DeliveryStartDate, DeliveryEndDate });
+                }
 
-                    // 点价期
-                    const pDate = priceDate.value;
-                    if (pDate.length && param.PriceType !== 1) {
-                        // 点价日期[2:点价3:暂定价]
-                        const StartDate = fn(pDate[0]);
-                        const EndDate = fn(pDate[1]);
-                        Object.assign(param, { StartDate, EndDate });
-                    }
-
-                    sendReq(param, loading, OperateType)
-                        .then((res) => {
-                            context.emit('refresh');
-                            cancel();
-                        })
-                        .catch((err) => {});
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
-                });
+                // 点价期
+                const pDate = priceDate.value;
+                if (pDate.length && param.PriceType !== 1) {
+                    // 点价日期[2:点价3:暂定价]
+                    const StartDate = fn(pDate[0]);
+                    const EndDate = fn(pDate[1]);
+                    Object.assign(param, { StartDate, EndDate });
+                }
+                sendReq(param, loading, OperateType)
+                    .then((res) => {
+                        context.emit('refresh');
+                        cancel();
+                    })
+                    .catch((err) => {});
+            });
         }
 
         initData(() => {
@@ -544,8 +538,8 @@ export default defineComponent({
 
 <style lang="less">
 .add-spot-contract {
-  .ant-upload-list-item-name{
-    padding: 0 20PX;
-  }
+    .ant-upload-list-item-name {
+        padding: 0 20px;
+    }
 }
 </style>;

+ 3 - 4
src/views/information/spot-contract/components/check/index.vue

@@ -234,7 +234,8 @@ import { Modal } from 'ant-design-vue';
 import { handleForm } from './setup';
 import { handleAccountManager } from '../setup';
 import { GldErmcpSpotContractOperateReq, SpotContractOperateReq } from '@/services/proto/spotcontract/interface';
-import Long from 'long';
+import { validateAction } from '@/common/setup/form';
+import { FormState } from './interface';
 
 export default defineComponent({
     name: 'spot-contract-detail',
@@ -254,14 +255,12 @@ export default defineComponent({
         // 表单
         const { rules, formState, formRef } = handleForm();
         function submit() {
-            formRef.value.validate().then(() => {
+            validateAction<FormState>(formRef, formState).then((param) => {
                 Modal.confirm({
                     title: '是否确认审核通过',
                     okText: '审核通过',
                     cancelText: '取消',
                     onOk() {
-                        const param = toRaw(formState);
-
                         const reqs: GldErmcpSpotContractOperateReq = {
                             SpotContractID: props.selectedRow.spotcontractid,
                             OperateType: 4,

+ 29 - 34
src/views/information/spot-contract/components/modify/index.vue

@@ -421,6 +421,7 @@ import { Moment } from 'moment';
 import { handleFormRule, handleContract, handleDeliveryGoods, handleAmout, handlePrice, handleDate, handleFromState } from '../setup';
 import { addContractReq } from '@/views/information/spot-contract/components/add/setup';
 import { mergeTwoObj } from '@/utils/objHandle';
+import { validateAction } from '@/common/setup/form';
 
 export default defineComponent({
     name: 'modify-spot-contract',
@@ -470,42 +471,36 @@ export default defineComponent({
             }
         });
         function submit() {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const id = getUsrId();
-                    isSell.value ? (param.SellUserID = id) : (param.BuyUserID = id);
-                    const fn = (value: Moment) => {
-                        return formatTime(value, 'd') + ' ' + '00:00:00';
-                    };
-                    // 交收期
-                    const dDate = deliveryDate.value;
-                    if (dDate.length) {
-                        const DeliveryStartDate = fn(dDate[0]);
-                        const DeliveryEndDate = fn(dDate[1]);
-                        Object.assign(param, { DeliveryStartDate, DeliveryEndDate });
-                    }
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const id = getUsrId();
+                isSell.value ? (param.SellUserID = id) : (param.BuyUserID = id);
+                const fn = (value: Moment) => {
+                    return formatTime(value, 'd') + ' ' + '00:00:00';
+                };
+                // 交收期
+                const dDate = deliveryDate.value;
+                if (dDate.length) {
+                    const DeliveryStartDate = fn(dDate[0]);
+                    const DeliveryEndDate = fn(dDate[1]);
+                    Object.assign(param, { DeliveryStartDate, DeliveryEndDate });
+                }
 
-                    // 点价期
-                    const pDate = priceDate.value;
-                    if (pDate.length && param.PriceType !== 1) {
-                        // 点价日期[2:点价3:暂定价]
-                        const StartDate = fn(pDate[0]);
-                        const EndDate = fn(pDate[1]);
-                        Object.assign(param, { StartDate, EndDate });
-                    }
+                // 点价期
+                const pDate = priceDate.value;
+                if (pDate.length && param.PriceType !== 1) {
+                    // 点价日期[2:点价3:暂定价]
+                    const StartDate = fn(pDate[0]);
+                    const EndDate = fn(pDate[1]);
+                    Object.assign(param, { StartDate, EndDate });
+                }
 
-                    sendReq(param, loading, 2)
-                        .then((res) => {
-                            context.emit('refresh');
-                            cancel();
-                        })
-                        .catch((err) => {});
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
-                });
+                sendReq(param, loading, 2)
+                    .then((res) => {
+                        context.emit('refresh');
+                        cancel();
+                    })
+                    .catch((err) => {});
+            });
         }
         initData(() => {
             queryCustomList();

+ 19 - 31
src/views/information/warehouse-info/compoments/add/index.vue

@@ -143,6 +143,7 @@ import { ErmcpWareHouseInfo } from '@/services/go/ermcp/warehouse-info/interface
 import { getWarehouseTypeEnumList } from '@/common/constants/enumsList';
 import { addWarehouseApply } from '@/services/proto/warehouse';
 import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { validateAction } from '@/common/setup/form';
 
 export default defineComponent({
     name: 'warehouse_info_btn_add',
@@ -160,38 +161,25 @@ export default defineComponent({
         const warehouseType = ref<AllEnums[]>(getWarehouseTypeEnumList());
         const { formRef, formState, rules } = handleForm();
         function submit() {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const reqParam: WarehouseApplyReq = {
-                        type: 1, // int32 类型 1 新增 2 修改
-                        warehouseid: param.warehouseid, // uint64 仓库ID
-                        warehousecode: param.warehousecode, // string 仓库代码
-                        warehousename: param.warehousename, // string 仓库名称
-                        warehousetype: undefined === param.warehousetype ? 0 : (param.warehousetype as number), // int32 仓库类型 - 1 厂库  2 自有库  3 合作库
-                        provinceid: undefined === param.provinceid ? 0 : (param.provinceid as number), // uint64 省
-                        cityid: undefined === param.cityid ? 0 : (param.cityid as number), // uint64 市
-                        districtid: undefined === param.districtid ? 0 : (param.districtid as number), // int32 区
-                        address: param.address, // string 详细地址
-                        contactname: param.contactname, // string 联系人
-                        contactnum: param.contactnum, // string 联系电话
-                    };
-                    requestResultLoadingAndInfo(addWarehouseApply, reqParam, loading, ['新建仓库成功', '新建仓库失败']).then(() => {
-                        cancel();
-                        context.emit('refresh');
-                    });
-                    // warehouseApply(reqParam, loading)
-                    //     .then((res) => {
-                    //         cancel();
-                    //         context.emit('refresh');
-                    //     })
-                    //     .catch((err) => {});
-                    console.log('param', param);
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const reqParam: WarehouseApplyReq = {
+                    type: 1, // int32 类型 1 新增 2 修改
+                    warehouseid: param.warehouseid, // uint64 仓库ID
+                    warehousecode: param.warehousecode, // string 仓库代码
+                    warehousename: param.warehousename, // string 仓库名称
+                    warehousetype: undefined === param.warehousetype ? 0 : (param.warehousetype as number), // int32 仓库类型 - 1 厂库  2 自有库  3 合作库
+                    provinceid: undefined === param.provinceid ? 0 : (param.provinceid as number), // uint64 省
+                    cityid: undefined === param.cityid ? 0 : (param.cityid as number), // uint64 市
+                    districtid: undefined === param.districtid ? 0 : (param.districtid as number), // int32 区
+                    address: param.address, // string 详细地址
+                    contactname: param.contactname, // string 联系人
+                    contactnum: param.contactnum, // string 联系电话
+                };
+                requestResultLoadingAndInfo(addWarehouseApply, reqParam, loading, ['新建仓库成功', '新建仓库失败']).then(() => {
+                    cancel();
+                    context.emit('refresh');
                 });
+            });
         }
         return {
             visible,

+ 22 - 28
src/views/information/warehouse-info/compoments/modify/index.vue

@@ -136,12 +136,12 @@ import { defineComponent, PropType, ref, toRaw, watchEffect } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { getAddress } from '@/services/go/adress';
 import { handleForm, FormState, warehouseApply } from '../setup';
-import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
 import { AllEnums } from '@/services/go/commonService/interface';
 import { WarehouseApplyReq } from '@/services/proto/warehouse/interface';
 import { ErmcpWareHouseInfo } from '@/services/go/ermcp/warehouse-info/interface';
 import { mergeTwoObj } from '@/utils/objHandle';
 import { getWarehouseTypeEnumList } from '@/common/constants/enumsList';
+import { validateAction } from '@/common/setup/form';
 
 export default defineComponent({
     name: 'warehouse_info_btn_modify',
@@ -167,33 +167,27 @@ export default defineComponent({
             }
         });
         function submit() {
-            formRef.value
-                .validate()
-                .then(() => {
-                    const param = toRaw(formState);
-                    const reqParam: WarehouseApplyReq = {
-                        type: 2, // int32 类型 1 新增 2 修改
-                        warehouseid: props.selectedRow.autoid, // uint64 仓库ID
-                        warehousecode: props.selectedRow.warehousecode, // string 仓库代码
-                        warehousename: param.warehousename, // string 仓库名称
-                        warehousetype: undefined === param.warehousetype ? 0 : (param.warehousetype as number), // int32 仓库类型 - 1 厂库  2 自有库  3 合作库
-                        provinceid: undefined === param.provinceid ? 0 : (param.provinceid as number), // uint64 省
-                        cityid: undefined === param.cityid ? 0 : (param.cityid as number), // uint64 市
-                        districtid: undefined === param.districtid ? 0 : (param.districtid as number), // int32 区
-                        address: param.address, // string 详细地址
-                        contactname: param.contactname, // string 联系人
-                        contactnum: param.contactnum, // string 联系电话
-                    };
-                    warehouseApply(reqParam, loading)
-                        .then((res) => {
-                            cancel();
-                            context.emit('refresh');
-                        })
-                        .catch((err) => {});
-                })
-                .catch((error: ValidateErrorEntity<FormState>) => {
-                    console.log('error', error);
-                });
+            validateAction<FormState>(formRef, formState).then((param) => {
+                const reqParam: WarehouseApplyReq = {
+                    type: 2, // int32 类型 1 新增 2 修改
+                    warehouseid: props.selectedRow.autoid, // uint64 仓库ID
+                    warehousecode: props.selectedRow.warehousecode, // string 仓库代码
+                    warehousename: param.warehousename, // string 仓库名称
+                    warehousetype: undefined === param.warehousetype ? 0 : (param.warehousetype as number), // int32 仓库类型 - 1 厂库  2 自有库  3 合作库
+                    provinceid: undefined === param.provinceid ? 0 : (param.provinceid as number), // uint64 省
+                    cityid: undefined === param.cityid ? 0 : (param.cityid as number), // uint64 市
+                    districtid: undefined === param.districtid ? 0 : (param.districtid as number), // int32 区
+                    address: param.address, // string 详细地址
+                    contactname: param.contactname, // string 联系人
+                    contactnum: param.contactnum, // string 联系电话
+                };
+                warehouseApply(reqParam, loading)
+                    .then((res) => {
+                        cancel();
+                        context.emit('refresh');
+                    })
+                    .catch((err) => {});
+            });
         }
         function provinceChange(id: number) {
             getCityList(id);