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

+ 9 - 1
src/common/setup/upload/index.ts

@@ -132,11 +132,15 @@ export function handlePreviewImg() {
  * @returns 
  */
 export function getUploadImg() {
+    // 存储上传的图片
     const imgs = ref<string[]>([])
+    // 存储从服务获取的图片信息,用于展示
     const uploadImgList = ref<FileItem[]>([])
+    // 上传图片
     function uploadImgAction(value: string[]) {
         imgs.value = value
     }
+    // 用于处理从服务获取的图片
     function handleImg(value: string) {
         const arr = value.split(',')
         return arr.map((e, i) => {
@@ -149,5 +153,9 @@ export function getUploadImg() {
         });
 
     }
-    return { imgs, uploadImgAction, uploadImgList, handleImg }
+    // 获取上传的第一张图片
+    function getFirstImg() {
+        return imgs.value.length ? imgs.value[0] : ''
+    }
+    return { imgs, uploadImgAction, uploadImgList, handleImg, getFirstImg }
 }

+ 21 - 24
src/views/information/custom/compoments/add/index.vue

@@ -102,13 +102,8 @@
           </a-col>
           <a-col :span="12">
             <a-form-item label="营业执照">
-              <div class="upload">
-                <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
-                          :transform-file="transformFile">
-                  <a-button class="uploadBtn">上传</a-button>
-                </a-upload>
-                <div class="look">查看附件</div>
-              </div>
+              <UploadImg :visible="visible"
+                         @upload="attachmentUpLoad" />
             </a-form-item>
           </a-col>
           <a-col :span="12">
@@ -170,13 +165,8 @@
           <a-col :span="12">
             <a-form-item label="身份证正面照"
                          name="cardbackphotourl">
-              <div class="upload">
-                <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
-                          :transform-file="transformFile">
-                  <a-button class="uploadBtn">上传</a-button>
-                </a-upload>
-                <div class="look">查看附件</div>
-              </div>
+              <UploadImg :visible="visible"
+                         @upload="cardfrontphotourlUpLoad" />
             </a-form-item>
           </a-col>
           <a-col :span="12">
@@ -191,13 +181,8 @@
           <a-col :span="24">
             <a-form-item label="身份证反面照"
                          name="cardfrontphotourl">
-              <div class="upload">
-                <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
-                          :transform-file="transformFile">
-                  <a-button class="uploadBtn">上传</a-button>
-                </a-upload>
-                <div class="look">查看附件</div>
-              </div>
+              <UploadImg :visible="visible"
+                         @upload="cardbackphotourlUpLoad" />
             </a-form-item>
           </a-col>
           <a-col :span="12">
@@ -286,10 +271,12 @@ 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';
+import UploadImg from '@/common/components/uploadImg/index.vue';
+import { getUploadImg } from '@/common/setup/upload';
 
 export default defineComponent({
     name: 'add-custom',
-    components: {},
+    components: { UploadImg },
     setup(props, context) {
         // 控制关闭弹窗
         const { visible, cancel } = closeModal('custom_info_btn_add');
@@ -300,7 +287,12 @@ export default defineComponent({
         const { formRef, formState, rules } = handleForm();
         // 地址
         const { cityList, districtList, provinceList, getCityList, getDistrictList } = getAddress();
-
+        // 营业执照
+        const { getFirstImg: getAttachmentImg, uploadImgAction: attachmentUpLoad } = getUploadImg();
+        // 背面证件照地址
+        const { getFirstImg: getBackImg, uploadImgAction: cardbackphotourlUpLoad } = getUploadImg();
+        // 正面证件照地址
+        const { getFirstImg: getFrontImg, uploadImgAction: cardfrontphotourlUpLoad } = getUploadImg();
         function isPersonal(): boolean {
             return formState.userinfotype === '1';
         }
@@ -321,7 +313,8 @@ export default defineComponent({
                     remark: param.remark, // 备注
                     mobilephone: param.mobilephone, //  手机号码
                     telphone: param.telphone, // 电话
-                    cardfrontphotourl: param.cardfrontphotourl, // 正面照片
+                    cardfrontphotourl: getFrontImg(), // 正面照片
+                    cardbackphotourl: getBackImg(), // 背面证件照地址
                     cardaddress: param.cardaddress, // 证件地址
                     cityid: param.cityid, //
                     districtid: param.districtid, // 地区
@@ -331,6 +324,7 @@ export default defineComponent({
                     legalpersonname: param.legalpersonname, // 法人姓名(企业)
                     taxpayernum: param.taxpayernum, // 纳税人识别号
                     email: param.email, // email
+                    attachment1: getAttachmentImg(), // 营业执照
                 };
                 requestResultLoadingAndInfo(QueryAddUserInfoApply, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['新增客户资料成功', '新增客户资料失败:']).then(() => {
                     cancel();
@@ -353,6 +347,9 @@ export default defineComponent({
             provinceList,
             getCityList,
             getDistrictList,
+            attachmentUpLoad,
+            cardbackphotourlUpLoad,
+            cardfrontphotourlUpLoad,
         };
     },
 });

+ 15 - 17
src/views/information/spot-contract/components/add/index.vue

@@ -38,7 +38,7 @@
               <a-select class="inlineFormSelect"
                         style="width: 200px"
                         @change="contractChange"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         v-model:value="formState.ContractType"
                         placeholder="请选择合同类型">
                 <a-select-option v-for="item in contractType"
@@ -54,7 +54,7 @@
                          name="BizType">
               <a-select class="inlineFormSelect"
                         style="width: 200px"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         v-model:value="formState.BizType"
                         placeholder="请选择业务类型">
                 <a-select-option v-for="item in businessType"
@@ -71,7 +71,7 @@
                            name="BuyUserID">
                 <a-select class="inlineFormSelect"
                           style="width: 200px"
-                          :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                          :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                           v-model:value="formState.BuyUserID"
                           placeholder="请选择客户">
                   <!-- 客户资料列表 正常 -->
@@ -101,7 +101,7 @@
                 <a-select class="inlineFormSelect"
                           v-model:value="formState.SellUserID"
                           style="width: 200px"
-                          :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                          :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                           placeholder="请选择客户">
                   <!-- 客户资料列表 正常 -->
                   <a-select-option :value="item.userid"
@@ -132,7 +132,7 @@
               <a-select class="inlineFormSelect"
                         style="width: 200px"
                         @change="deliveryGoodsChange"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         v-model:value="formState.DeliveryGoodsID"
                         placeholder="请选择现货品种">
                 <a-select-option v-for="item in deliveryGoodsList"
@@ -148,7 +148,7 @@
                          name="WrStandardID">
               <a-select class="inlineFormSelect"
                         style="width: 200px"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         @change="WrStandardChange"
                         v-model:value="formState.WrStandardID"
                         placeholder="请选择品类">
@@ -165,7 +165,7 @@
                          name="SpotGoodsBrandID">
               <a-select class="inlineFormSelect"
                         style="width: 200px"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         v-model:value="formState.SpotGoodsBrandID"
                         placeholder="请选择品牌">
                 <a-select-option v-for="item in gblist"
@@ -205,7 +205,7 @@
                          name="PriceType">
               <a-select class="inlineFormSelect"
                         style="width: 200px"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         v-model:value="formState.PriceType"
                         placeholder="请选择定价类型">
                 <a-select-option v-for="item in priceType"
@@ -222,7 +222,7 @@
               <a-select class="inlineFormSelect"
                         v-model:value="formState.CurrencyID"
                         style="width: 200px"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         placeholder="请选择结算币种">
                 <a-select-option v-for="item in payCurrency"
                                  :key="item.enumdicid"
@@ -260,7 +260,7 @@
                 <a-select class="inlineFormSelect"
                           v-model:value="formState.GoodsID"
                           style="width: 200px"
-                          :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                          :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                           placeholder="请选择点价合约">
                   <a-select-option v-for="item in goodsList"
                                    :key="item.goodsid"
@@ -358,7 +358,7 @@
               <a-select class="inlineFormSelect"
                         v-model:value="formState.SaleUserID"
                         style="width: 200px"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         placeholder="请选择业务员">
                 <a-select-option v-for="item in businesserList"
                                  :key="item.loginid"
@@ -376,7 +376,7 @@
               <a-select class="inlineFormSelect"
                         v-model:value="formState.MerUserID"
                         style="width: 200px"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         placeholder="请选择跟单员">
                 <a-select-option v-for="item in merchandiserList"
                                  :key="item.loginid"
@@ -391,7 +391,7 @@
                          name="TradeUserID">
               <a-select class="inlineFormSelect"
                         style="width: 200px"
-                        :getPopupContainer="(triggerNode) => triggerNode.parentNode" 
+                        :getPopupContainer="(triggerNode) => triggerNode.parentNode"
                         v-model:value="formState.TradeUserID"
                         placeholder="请选择期货账户">
                 <a-select-option v-for="item in traderList"
@@ -475,7 +475,7 @@ export default defineComponent({
         const merchandiserList = ref<ErmcpLoginUser[]>([]);
         // 现货商品列表
         const goodsList = ref<Goods[]>([]);
-        const { imgs, uploadImgAction } = getUploadImg();
+        const { getFirstImg, uploadImgAction } = getUploadImg();
         watchEffect(() => {
             if (visible.value) {
                 queryCustomList();
@@ -512,9 +512,7 @@ export default defineComponent({
                     Object.assign(param, { StartDate, EndDate });
                 }
                 // 合同附件
-                if (imgs.value.length) {
-                    param.ContractAttachment = imgs.value[0];
-                }
+                param.ContractAttachment = getFirstImg();
                 sendReq(param, loading, OperateType)
                     .then((res) => {
                         context.emit('refresh');

+ 1 - 2
src/views/information/spot-contract/components/modify/index.vue

@@ -467,7 +467,7 @@ export default defineComponent({
         const merchandiserList = ref<ErmcpLoginUser[]>([]);
         // 现货商品列表
         const goodsList = ref<Goods[]>([]);
-        const { imgs, uploadImgAction, uploadImgList, handleImg } = getUploadImg();
+        const { uploadImgAction, uploadImgList, handleImg } = getUploadImg();
         watchEffect(() => {
             if (visible.value) {
                 queryCustomList();
@@ -575,7 +575,6 @@ export default defineComponent({
             traderList,
             businesserList,
             merchandiserList,
-            imgs,
             uploadImgAction,
             uploadImgList,
         };