Просмотр исходного кода

feat: EK-880: 管理员增加“Country”属性

tyler 9 месяцев назад
Родитель
Сommit
bbfe71ec41
3 измененных файлов с 33 добавлено и 4 удалено
  1. 1 0
      src/lang/en.js
  2. 1 0
      src/lang/zh.js
  3. 31 4
      src/views/admin/edit.vue

+ 1 - 0
src/lang/en.js

@@ -876,6 +876,7 @@ export default {
     loginAccount: 'Login account',
     name: 'Name',
     pleaseSelectRole: 'Please select a role',
+    pleaseSelectCountry: 'Please select country',
     password: 'password',
     confirmPassword: 'Confirm password',
     bindIp: 'Bind IP',

+ 1 - 0
src/lang/zh.js

@@ -866,6 +866,7 @@ export default {
     loginAccount: '登录账号',
     name: '姓名',
     pleaseSelectRole: '请选择角色',
+    pleaseSelectCountry: '请选择国家',
     password: '密码',
     confirmPassword: '确认密码',
     bindIp: '绑定IP',

+ 31 - 4
src/views/admin/edit.vue

@@ -13,6 +13,11 @@
             <el-option v-for="item in roles" :key="item.ID" :label="item.ROLE_NAME" :value="item.ID" />
           </el-select>
         </el-form-item>
+        <el-form-item :label="$t('transportationConfig.countryName')"><!-- 国家 -->
+          <el-select v-model="form.countryId" multiple :placeholder="$t('Administrator.pleaseSelectCountry')">
+            <el-option v-for="item in countries" :key="item.ID" :label="item.NAME" :value="item.ID" />
+          </el-select>
+        </el-form-item>
         <el-form-item :label="$t('Administrator.password')"><!-- 密码 -->
           <el-input v-model="form.password" type="password" />
         </el-form-item>
@@ -46,6 +51,8 @@
 </template>
 <script>
 import { adminAddAndEditAndChangePassword, adminAdd, adminEdit } from '@/api/filter'
+import {getCountries} from "@/api/site";
+import {isArray} from "@/utils/validate";
 export default {
   name: 'RoleAdd',
   data() {
@@ -59,12 +66,14 @@ export default {
         bindIp: '',
         roleId: null,
         password: null,
-        surePassword: null
+        surePassword: null,
+        countryId: []
       },
       loading: true,
       submitButtonStat: false,
       isEdit: false,
-      roles: null
+      roles: null,
+      countries: []
     }
   },
   computed: {
@@ -112,6 +121,7 @@ export default {
     } else {
       this.loading = false
     }
+    this.getCountries()
   },
   methods: {
     onSubmit() {
@@ -122,6 +132,16 @@ export default {
       } else if (this.$route.name === 'admin_change-password') {
         path = 'admin/change-password'
       }
+
+      console.log(this.form.countryId)
+      if (!(isArray(this.form.countryId) && this.form.countryId.length > 0)){
+        this.$message({
+          message: this.$t('Administrator.pleaseSelectCountry'),
+          type: 'error'
+        })
+        this.submitButtonStat = false
+        return false;
+      }
       adminAddAndEditAndChangePassword(path, this.form).then(response => {
         this.submitButtonStat = false
         console.log(response)
@@ -138,7 +158,14 @@ export default {
           type: 'error'
         })
       })
-    }
+    },
+    getCountries(){
+      getCountries().then(response => {
+        this.countries = response
+      }).catch(err => {
+
+      })
+    },
   }
 }
 </script>
@@ -162,7 +189,7 @@ export default {
     /deep/ .el-form-item__label {
       width:150px !important;
     }
-    /deep/ .el-input__inner { 
+    /deep/ .el-input__inner {
       width: 150px;
     }
     /* .el-input {