Преглед изворни кода

新增 代理子账号邮箱

wzg пре 1 година
родитељ
комит
3555f9f287

+ 5 - 0
src/apis/fetch.js

@@ -272,6 +272,11 @@ export default {
     return $http("/proxy/detail/account/add", data);
   },
 
+  // 修改代理子账户
+  editAgencySubAccount(data) {
+    return $http("/proxy/detail/account/change", data);
+  },
+
   // 获取货主公司列表
   getCargoOwnerCompanyList(data) {
     return $http("/cargoOwner/list", data);

+ 124 - 29
src/views/agencyManage/agencyCompanyDetail.vue

@@ -17,6 +17,8 @@
       <div class="show-input">{{ contactName }}</div>
       <div class="normal-label">联系人手机号</div>
       <div class="show-input">{{ contactPhone }}</div>
+      <div class="normal-label">联系人邮箱</div>
+      <div class="show-input">{{ contactEmail }}</div>
     </div>
     <div class="df aic mt20">
       <div class="normal-label">过期时间</div>
@@ -28,12 +30,10 @@
         value-format="YYYY/MM/DD"
         placeholder="过期时间"
         :disabled="!expiredTimeEditable"
-        size="small"
       ></el-date-picker>
       <el-button
         v-if="!expiredTimeEditable"
         @click="editExpiredTime"
-        size="mini"
         type="primary"
       >
         修改
@@ -41,16 +41,11 @@
       <el-button
         v-if="expiredTimeEditable"
         @click="submitExpiredTime"
-        size="mini"
         type="primary"
       >
         提交
       </el-button>
-      <el-button
-        v-if="expiredTimeEditable"
-        @click="cancelExpiredTime"
-        size="mini"
-      >
+      <el-button v-if="expiredTimeEditable" @click="cancelExpiredTime">
         取消
       </el-button>
     </div>
@@ -66,13 +61,19 @@
           clearable
           style="height: 32px; width: 330px; line-height: 32px"
         ></el-input>
-        <div class="seach-btn" @click="getAgencySubAccountList(1)">查询</div>
+        <el-button
+          class="ml20"
+          type="primary"
+          @click="getAgencySubAccountList(1)"
+        >
+          查询
+        </el-button>
       </div>
-      <div class="cargo-owner-add" @click="dialogFormVisible = true">
+      <el-button class="ml20" type="primary" @click="dialogFormVisible = true">
         添加代理子账户
-      </div>
+      </el-button>
       <el-dialog
-        title="添加代理子账户"
+        :title="ruleForm.id ? '编辑代理子账户' : '添加代理子账户'"
         v-model="dialogFormVisible"
         @closed="resetForm"
       >
@@ -80,7 +81,7 @@
           <el-form
             :model="ruleForm"
             :rules="rules"
-            ref="form"
+            ref="ruleFormRef"
             label-width="110px"
             label-position="left"
           >
@@ -90,20 +91,26 @@
                 v-model="ruleForm.userName"
               ></el-input>
             </el-form-item>
-            <el-form-item prop="phone" label="手机号">
+            <el-form-item prop="phone" label="手机号" v-if="!ruleForm.id">
               <el-input
                 style="width: 280px"
                 v-model="ruleForm.phone"
               ></el-input>
             </el-form-item>
-            <el-form-item prop="password" label="密码">
+            <el-form-item prop="email" label="邮箱">
+              <el-input
+                style="width: 280px"
+                v-model="ruleForm.email"
+              ></el-input>
+            </el-form-item>
+            <el-form-item prop="password" label="密码" v-if="!ruleForm.id">
               <el-input
                 style="width: 280px"
                 v-model="ruleForm.password"
                 placeholder="(不填自动生成)"
               ></el-input>
             </el-form-item>
-            <el-form-item prop="isAdmin" label="管理员">
+            <el-form-item prop="isAdmin" label="管理员" v-if="!ruleForm.id">
               <el-select v-model="ruleForm.isAdmin" placeholder="是否管理员">
                 <el-option label="否" value="0" />
                 <el-option label="是" value="1" />
@@ -114,9 +121,20 @@
         <template v-slot:footer>
           <div class="dialog-footer">
             <el-button @click="resetForm">取 消</el-button>
-            <el-button type="primary" @click="addAgencySubAccount(ruleForm)">
+            <el-button
+              v-if="!ruleForm.id"
+              type="primary"
+              @click="addAgencySubAccount(ruleForm)"
+            >
               确 定
             </el-button>
+            <el-button
+              v-else
+              type="primary"
+              @click="editAgencySubAccount(ruleForm)"
+            >
+              修改
+            </el-button>
           </div>
         </template>
       </el-dialog>
@@ -142,8 +160,8 @@
           align="center"
         ></el-table-column>
         <el-table-column
-          prop="password"
-          label="密码"
+          prop="email"
+          label="邮箱"
           min-width="160"
           align="center"
         ></el-table-column>
@@ -168,6 +186,13 @@
             {{ scope.row.roleName || "暂无职位" }}
           </template>
         </el-table-column>
+        <el-table-column label="操作" min-width="160" align="center">
+          <template v-slot="scope">
+            <el-button type="primary" size="small" @click="showEdit(scope.row)">
+              编辑
+            </el-button>
+          </template>
+        </el-table-column>
       </el-table>
       <div style="width: 100%; text-align: right; margin-top: 43px">
         <el-pagination
@@ -191,13 +216,17 @@
           clearable
           style="width: 330px"
         ></el-input>
-        <div class="seach-btn" @click="getCargoOwnerCompanyByAgencyCompany(1)">
+        <el-button
+          class="ml20"
+          type="primary"
+          @click="getCargoOwnerCompanyByAgencyCompany(1)"
+        >
           查询
-        </div>
+        </el-button>
       </div>
-      <div class="cargo-owner-add" @click="dialogFormVisible2 = true">
+      <el-button class="ml20" type="primary" @click="dialogFormVisible2 = true">
         关联货主公司
-      </div>
+      </el-button>
       <el-dialog
         title="关联货主公司"
         v-model="dialogFormVisible2"
@@ -258,6 +287,12 @@
           min-width="160"
           align="center"
         ></el-table-column>
+        <el-table-column
+          prop="contactEmail"
+          label="联系人邮箱"
+          min-width="160"
+          align="center"
+        ></el-table-column>
         <el-table-column
           prop="copId"
           label="操作"
@@ -289,7 +324,12 @@
 </template>
 <script setup>
 import { ref, h, reactive, toRefs, onMounted } from "vue";
-import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
+import {
+  ElNotification,
+  ElMessageBox,
+  ElMessage,
+  ElLoading,
+} from "element-plus";
 import store from "../../store";
 import router from "../../router";
 import { useRoute } from "vue-router";
@@ -298,16 +338,17 @@ import { subTimeStr } from "../../utils/utils";
 
 const route = useRoute();
 let dialogFormVisible = ref(false);
-let form = ref(null);
+let ruleFormRef = ref(null);
 let ruleForm = ref({
   userName: "",
   phone: "",
+  email: "",
   password: "",
   isAdmin: "",
 });
 async function resetForm() {
   dialogFormVisible.value = false;
-  form.value.resetFields();
+  ruleForm.value = {};
 }
 const rules = ref({
   userName: [
@@ -317,19 +358,26 @@ const rules = ref({
     { required: true, message: "请填写手机号", trigger: "blur" },
     { min: 11, max: 11, message: "请正确填写手机号", trigger: "blur" },
   ],
+  email: [{ required: true, message: "请填写邮箱", trigger: "blur" }],
 });
 async function addAgencySubAccount() {
-  form.value.validate(async (valid) => {
+  ruleFormRef.value.validate(async (valid) => {
     if (valid) {
-      let { userName, phone, password, isAdmin } = ruleForm.value;
+      let { userName, phone, email, password, isAdmin } = ruleForm.value;
+      const loading = ElLoading.service({
+        lock: true,
+        text: "正在提交...",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
       let res = await api.addAgencySubAccount({
         proxyId: route.query.id,
         userName,
         phone,
+        email,
         password,
         isAdmin,
       });
-      console.log(res);
+      loading.close();
       if (res.data.status == 0) {
         ElNotification.success({
           title: "添加成功",
@@ -351,6 +399,44 @@ async function addAgencySubAccount() {
     }
   });
 }
+
+function editAgencySubAccount() {
+  ruleFormRef.value.validate(async (valid) => {
+    if (valid) {
+      let { id: proxyLoginAccountId, userName, email } = ruleForm.value;
+      const loading = ElLoading.service({
+        lock: true,
+        text: "正在提交...",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
+      let res = await api.editAgencySubAccount({
+        proxyId: route.query.id,
+        proxyLoginAccountId,
+        userName,
+        email,
+      });
+      loading.close();
+      if (res.data.status == 0) {
+        ElNotification.success({
+          title: "修改成功",
+          duration: 0,
+          message: `${userName}:${res.data.msg}`,
+          type: "success",
+        });
+        resetForm();
+        getAgencySubAccountList();
+      } else {
+        ElNotification.error({
+          title: "失败",
+          duration: 3000,
+          message: res.data.msg,
+        });
+      }
+    } else {
+      return false;
+    }
+  });
+}
 let currentPage = ref(1);
 let term = ref("");
 let tableData = ref([]);
@@ -379,6 +465,7 @@ function pageChange(e) {
 let proxyName = ref();
 let contactName = ref();
 let contactPhone = ref();
+let contactEmail = ref();
 async function getAgencyCompanyDetail() {
   let res = await api.getAgencyCompanyDetail({
     proxyId: route.query.id,
@@ -387,6 +474,7 @@ async function getAgencyCompanyDetail() {
     proxyName.value = res.data.result.proxyName;
     contactName.value = res.data.result.contactName;
     contactPhone.value = res.data.result.contactPhone;
+    contactEmail.value = res.data.result.contactEmail;
     expiredTime.value = res.data.result.expiredTime;
   } else {
     console.log(res);
@@ -523,6 +611,13 @@ function cancelExpiredTime() {
   expiredTimeEditable.value = false;
 }
 
+function showEdit(row) {
+  dialogFormVisible.value = true;
+  ruleForm.value = {
+    ...row,
+  };
+}
+
 onMounted(() => {
   getAgencyCompanyDetail();
   getCargoOwnerCompanyByAgencyCompany();

+ 29 - 5
src/views/agencyManage/agencyCompanyList.vue

@@ -9,11 +9,13 @@
           clearable
           style="width: 330px"
         ></el-input>
-        <div class="seach-btn" @click="getAgencyCompanyList(1)">查询</div>
+        <el-button class="ml20" type="primary" @click="getAgencyCompanyList(1)">
+          查询
+        </el-button>
       </div>
-      <div class="cargo-owner-add" @click="dialogFormVisible = true">
+      <el-button class="ml20" type="primary" @click="dialogFormVisible = true">
         添加代理公司
-      </div>
+      </el-button>
       <el-dialog title="添加代理公司" v-model="dialogFormVisible">
         <template v-slot:default>
           <el-form
@@ -41,6 +43,12 @@
                 v-model="ruleForm.contactPhone"
               ></el-input>
             </el-form-item>
+            <el-form-item prop="contactEmail" label="联系人邮箱">
+              <el-input
+                style="width: 280px"
+                v-model="ruleForm.contactEmail"
+              ></el-input>
+            </el-form-item>
             <el-form-item prop="expiredTime" label="过期时间">
               <el-date-picker
                 v-model="ruleForm.expiredTime"
@@ -89,6 +97,12 @@
           min-width="160"
           align="center"
         ></el-table-column>
+        <el-table-column
+          prop="contactEmail"
+          label="联系人邮箱"
+          min-width="160"
+          align="center"
+        ></el-table-column>
         <el-table-column
           prop="createTime"
           label="入驻时间"
@@ -143,6 +157,7 @@ const ruleForm = ref({
   companyName: "",
   contactName: "",
   contactPhone: "",
+  contactEmail: "",
 });
 const rules = ref({
   companyName: [
@@ -153,6 +168,9 @@ const rules = ref({
     { required: false, message: "请填写手机号", trigger: "blur" },
     { min: 11, max: 11, message: "请正确填写手机号", trigger: "blur" },
   ],
+  contactEmail: [
+    { required: false, message: "请填写联系人邮箱", trigger: "blur" },
+  ],
   expiredTime: [
     { required: false, message: "请填写过期时间", trigger: "blur" },
   ],
@@ -181,12 +199,18 @@ function resetForm() {
 async function addAgencyCompany() {
   form.value.validate(async (valid) => {
     if (valid) {
-      let { companyName, contactName, contactPhone, expiredTime } =
-        ruleForm.value;
+      let {
+        companyName,
+        contactName,
+        contactPhone,
+        contactEmail,
+        expiredTime,
+      } = ruleForm.value;
       let res = await api.addAgencyCompany({
         companyName,
         contactName,
         contactPhone,
+        contactEmail,
         expiredTime,
       });
       console.log(res);