فهرست منبع

新增 货主子账号邮箱

wzg 1 سال پیش
والد
کامیت
0978770a9d
2فایلهای تغییر یافته به همراه101 افزوده شده و 20 حذف شده
  1. 4 0
      src/apis/fetch.js
  2. 97 20
      src/views/cargoOwnerManage/cargoOwnerCompanyDetail.vue

+ 4 - 0
src/apis/fetch.js

@@ -296,6 +296,10 @@ export default {
   addCargoOwnerAccount(data) {
     return $http("/cargoOwner/detail/account/add", data);
   },
+  // 修改货主公司账号
+  editCargoOwnerAccount(data) {
+    return $http("/cargoOwner/detail/account/change", data);
+  },
 
   // 添加代理公司
   addAgencyCompany(data) {

+ 97 - 20
src/views/cargoOwnerManage/cargoOwnerCompanyDetail.vue

@@ -32,7 +32,7 @@
       <el-button
         v-if="!expiredTimeEditable"
         @click="editExpiredTime"
-        size="mini"
+        size="small"
         type="primary"
       >
         修改
@@ -40,7 +40,7 @@
       <el-button
         v-if="expiredTimeEditable"
         @click="submitExpiredTime"
-        size="mini"
+        size="small"
         type="primary"
       >
         提交
@@ -48,7 +48,7 @@
       <el-button
         v-if="expiredTimeEditable"
         @click="cancelExpiredTime"
-        size="mini"
+        size="small"
       >
         取消
       </el-button>
@@ -67,11 +67,11 @@
         ></el-input>
         <div class="seach-btn" @click="getCargoOwnerAccountList(1)">查询</div>
       </div>
-      <div class="cargo-owner-add" @click="dialogFormVisible = true">
+      <el-button type="primary" @click="dialogFormVisible = true">
         添加账号
-      </div>
+      </el-button>
       <el-dialog
-        title="添加账号"
+        :title="ruleForm.id ? '编辑账号' : '添加账号'"
         v-model="dialogFormVisible"
         @closed="resetForm"
       >
@@ -79,7 +79,7 @@
           <el-form
             :model="ruleForm"
             :rules="rules"
-            ref="form"
+            ref="ruleFormRef"
             label-width="110px"
             label-position="left"
           >
@@ -96,9 +96,16 @@
               <el-input
                 style="width: 280px"
                 v-model="ruleForm.phone"
+                :disabled="!!ruleForm.id"
+              ></el-input>
+            </el-form-item>
+            <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="密码">
+            <el-form-item v-if="!ruleForm.id" prop="password" label="密码">
               <el-input
                 style="width: 280px"
                 v-model="ruleForm.password"
@@ -122,10 +129,21 @@
         </template>
         <template v-slot:footer>
           <div class="dialog-footer">
-            <el-button @click="resetForm">取 消</el-button>
-            <el-button type="primary" @click="addCargoOwnerAccount(ruleForm)">
+            <el-button @click="resetForm">取消</el-button>
+            <el-button
+              v-if="!ruleForm.id"
+              type="primary"
+              @click="addCargoOwnerAccount('add')"
+            >
               确认添加
             </el-button>
+            <el-button
+              v-else
+              type="primary"
+              @click="editCargoOwnerAccount('update')"
+            >
+              确认修改
+            </el-button>
           </div>
         </template>
       </el-dialog>
@@ -151,8 +169,8 @@
           align="center"
         ></el-table-column>
         <el-table-column
-          prop="password"
-          label="密码"
+          prop="email"
+          label="邮箱"
           min-width="160"
           align="center"
         ></el-table-column>
@@ -176,6 +194,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
@@ -203,9 +228,9 @@
           查询
         </div>
       </div>
-      <div class="cargo-owner-add" @click="dialogFormVisible2 = true">
+      <el-button type="primary" @click="dialogFormVisible2 = true">
         关联代理公司
-      </div>
+      </el-button>
       <el-dialog
         title="关联代理公司"
         v-model="dialogFormVisible2"
@@ -310,7 +335,7 @@ let term = ref("");
 let currentPage = ref(1);
 let total = ref(0);
 let dialogFormVisible = ref(false);
-let form = ref(null);
+let ruleFormRef = ref(null);
 
 async function getCargoOwnerAccountList(page) {
   currentPage.value = page || currentPage.value;
@@ -332,6 +357,7 @@ async function getCargoOwnerAccountList(page) {
 const ruleForm = ref({
   userName: "",
   phone: "",
+  email: "",
   password: "",
   cargo: "",
 });
@@ -341,6 +367,7 @@ const rules = ref({
     { required: true, message: "请填写手机号", trigger: "blur" },
     { min: 11, max: 11, message: "请正确填写手机号", trigger: "blur" },
   ],
+  email: [{ required: true, message: "请填写邮箱", trigger: "blur" }],
   password: [{ required: false, message: "请填写密码", trigger: "blur" }],
   cargo: [{ required: true, message: "请选择货种", trigger: "blur" }],
 });
@@ -357,7 +384,7 @@ async function getCargoList() {
 function resetForm() {
   dialogFormVisible.value = false;
 
-  form.value.resetFields();
+  ruleForm.value = {};
 }
 
 function pageChange(e) {
@@ -366,18 +393,23 @@ function pageChange(e) {
 }
 
 async function addCargoOwnerAccount() {
-  form.value.validate(async (valid) => {
+  ruleFormRef.value.validate(async (valid) => {
     if (valid) {
-      let { userName, phone, password, cargo } = ruleForm.value;
-
+      let { userName, phone, email, password, cargo } = ruleForm.value;
+      const loading = ElLoading.service({
+        lock: true,
+        text: "正在提交...",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
       let res = await api.addCargoOwnerAccount({
         cargoOwnerId: route.query.id,
         userName,
         phone,
+        email,
         password,
         cargo,
       });
-      console.log(res);
+      loading.close();
       if (res.data.status == 0) {
         ElNotification.success({
           title: "添加成功",
@@ -399,6 +431,43 @@ async function addCargoOwnerAccount() {
     }
   });
 }
+async function editCargoOwnerAccount() {
+  ruleFormRef.value.validate(async (valid) => {
+    if (valid) {
+      let { id: cargoOwnerLoginAccountId, userName, email } = ruleForm.value;
+      const loading = ElLoading.service({
+        lock: true,
+        text: "正在提交...",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
+      let res = await api.editCargoOwnerAccount({
+        cargoOwnerId: route.query.id,
+        cargoOwnerLoginAccountId,
+        userName,
+        email,
+      });
+      loading.close();
+      if (res.data.status == 0) {
+        ElNotification.success({
+          title: "修改成功",
+          duration: 2000,
+          message: `${userName}:${res.data.msg}`,
+          type: "success",
+        });
+        resetForm();
+        getCargoOwnerAccountList();
+      } else {
+        ElNotification.error({
+          title: "失败",
+          duration: 3000,
+          message: res.data.msg,
+        });
+      }
+    } else {
+      return false;
+    }
+  });
+}
 
 let tableData2 = ref([]);
 let term2 = ref("");
@@ -501,6 +570,14 @@ function cancelExpiredTime() {
   expiredTimeEditable.value = false;
 }
 
+function showEdit(row) {
+  console.log(row);
+  dialogFormVisible.value = true;
+  ruleForm.value = {
+    ...row,
+  };
+}
+
 onMounted(() => {
   getCargoOwnerCompanyDetail();
   getCargoOwnerAccountList();