Jelajahi Sumber

agency-photo

sunjh 6 tahun lalu
induk
melakukan
ef4bdca1f9

+ 11 - 1
src/components/authen/AgencyAuthentication.vue

@@ -188,7 +188,17 @@ export default {
             }, trigger: 'blur'
           },
         ],
-
+        agencyPhoto: [
+          {
+            validator: (rule, value, callback) => {
+              if (value == null || value == '') {
+                callback(new Error('机构logo不可为空'))
+              } else {
+                callback()
+              }
+            }, trigger: 'blur'
+          },
+        ]
       }
     }
   },

+ 11 - 0
src/components/authen/AgencyAuthenticationCreate.vue

@@ -170,6 +170,17 @@ export default {
             }, trigger: 'blur'
           },
         ],
+        agencyPhoto: [
+          {
+            validator: (rule, value, callback) => {
+              if (value == null || value == '') {
+                callback(new Error('机构logo不可为空'))
+              } else {
+                callback()
+              }
+            }, trigger: 'blur'
+          },
+        ]
 
       }
     }

+ 44 - 25
src/components/cheat/AgencyAdd.vue

@@ -32,7 +32,7 @@
           </el-checkbox-group>
           <!--<span v-if="!isModifyMode">{{agency.ability}}</span>-->
         </el-form-item>
-        <el-form-item label="测评机构资源" prop="resource">
+        <el-form-item label="测评机构资源" prop="evaluationAgencyResourceList">
           <span v-for="item in agency.evaluationAgencyResourceList" :key="item.id">
             资源类型:&nbsp;<el-select size="small" v-model="item.type" placeholder="请选择"
                                   style="width: 15%;margin-bottom: 10px"
@@ -55,7 +55,7 @@
           <el-button type="primary" icon="el-icon-circle-plus" plain size="mini" @click="addAgencyResource">添加资源
           </el-button>
         </el-form-item>
-        <el-form-item prop="file" label="机构logo">
+        <el-form-item prop="photoUrl" label="机构logo">
           <el-upload
             v-if="isModifyMode"
             class="avatar-uploader"
@@ -230,6 +230,17 @@ export default {
             }, trigger: 'blur'
           },
         ],
+        photoUrl: [
+          {
+            validator: (rule, value, callback) => {
+              if (value == null || value == '') {
+                callback(new Error('机构logo不可为空'))
+              } else {
+                callback()
+              }
+            }, trigger: 'blur'
+          },
+        ]
       },
       tableData: [{
         date: '2016-05-02',
@@ -272,29 +283,37 @@ export default {
     //提交表单
     submitInfo () {
       //this.showDialog()
-      this.showLoading()
-      const newAgency = {
-        mobile: this.agency.mobile,
-        evaluationAgencyName: this.agency.name,
-        bankAccount: this.agency.bankAccount,
-        address: this.agency.address,
-        evaluationAgencyAbilityList: this.agency.evaluationAgencyAbilityList,
-        evaluationAgencyResourceList: this.agency.evaluationAgencyResourceList,
-        agencyPhoto: this.agency.photoUrl,
-        email: this.agency.email
-      }
-      Http.post(Apis.USER.ADD_AGENCY, newAgency).then((res) => {
-        this.hideLoading()
-        console.log(res)
-        // console.log(res.data)
-        //res = res.data
-        this.agency.password = res.userVO.password
-        this.agency.username = res.userVO.userName
-        this.agency.mobile = res.userVO.mobile
-        this.showDialog()
-      }).catch(error => {
-        this.hideLoading()
-        notify('error', error.data)
+
+      this.$refs['agency'].validate(valid => {
+        if (valid) {
+          this.showLoading()
+          const newAgency = {
+            mobile: this.agency.mobile,
+            evaluationAgencyName: this.agency.name,
+            bankAccount: this.agency.bankAccount,
+            address: this.agency.address,
+            evaluationAgencyAbilityList: this.agency.evaluationAgencyAbilityList,
+            evaluationAgencyResourceList: this.agency.evaluationAgencyResourceList,
+            agencyPhoto: this.agency.photoUrl,
+            email: this.agency.email
+          }
+          Http.post(Apis.USER.ADD_AGENCY, newAgency).then((res) => {
+            this.hideLoading()
+            console.log(res)
+            // console.log(res.data)
+            //res = res.data
+            this.agency.password = res.userVO.password
+            this.agency.username = res.userVO.userName
+            this.agency.mobile = res.userVO.mobile
+            this.showDialog()
+          }).catch(error => {
+            this.hideLoading()
+            notify('error', error.data)
+          })
+        } else {
+          notify('error', '表单填写错误!')
+          return false
+        }
       })
     },
     //取消修改表单,表单进入不可编辑状态,不再使用