Bläddra i källkod

20241206测试版本 -zzx

学习?学个屁 6 månader sedan
förälder
incheckning
1af4874d6f

+ 5 - 2
src/views/distribution/peopleManage/firstSetPrice.vue

@@ -52,7 +52,7 @@
         <el-divider v-if="isAdmin!=3"></el-divider>
         <el-card class="operate-container" shadow="hover" v-if="isAdmin!=3">
             <div style="text-align: center;">
-                <el-button type="primary" size="small" @click="confirmForbidden">提交</el-button>
+                <el-button type="primary" size="small" :loading="confirmLoading" @click="confirmForbidden">提交</el-button>
                 <el-button type="info" size="small" @click="cancelForbidden">取消</el-button>
             </div>
         </el-card>
@@ -77,7 +77,8 @@ export default {
             dialogListLoading: false,
             total: null,
             editInput: null,
-            currentEditingRow: null //用于记录当前正在编辑的行
+            currentEditingRow: null, //用于记录当前正在编辑的行
+            confirmLoading: false
         };
     },
     watch: {},
@@ -146,7 +147,9 @@ export default {
                 stationId: this.listQuery.stationId,
                 time: item.time
             }))
+            this.confirmLoading = true
             settingsPrice(newArray).then((res) => {
+                this.confirmLoading = false
                 if (res.code == 200) {
                     this.$message.success('设置成功');
                     this.getList();

+ 6 - 3
src/views/distribution/peopleManage/settingsPrice.vue

@@ -56,7 +56,7 @@
         <el-divider></el-divider>
         <el-card class="operate-container" shadow="hover">
             <div style="text-align: center;">
-                <el-button type="primary" size="small" @click="confirmForbidden">提交</el-button>
+                <el-button type="primary" size="small" :loading="confirmLoading" @click="confirmForbidden">提交</el-button>
                 <el-button type="info" size="small" @click="cancelForbidden">取消</el-button>
             </div>
         </el-card>
@@ -81,7 +81,8 @@ export default {
             dialogListLoading: false,
             total: null,
             editInput: null,
-            currentEditingRow: null //用于记录当前正在编辑的行
+            currentEditingRow: null, //用于记录当前正在编辑的行
+            confirmLoading: false
         };
     },
     watch: {},
@@ -109,7 +110,7 @@ export default {
             if (this.editInput >= row.platformPrice) {
                 return this.$message.error('价格必须小于平台价格');
             }
-            if(this.editInput<=new Big(row.platformPrice).minus(new Big(row.addServicePrice))){
+            if(this.editInput<=row.platformPrice-row.addServicePrice){
               return this.$message.error('一级代理价不合理,不在底价和销售价区间');
             }
             if (this.editInput <= 0) {
@@ -144,7 +145,9 @@ export default {
                 stationId: this.listQuery.stationId,
                 time: item.time
             }))
+            this.confirmLoading = true;
             settingsPrice(newArray).then((res) => {
+                this.confirmLoading = false;
                 if (res.code == 200) {
                     this.$message.success('设置成功');
                     this.getList();

+ 214 - 235
src/views/ums/admin/index.vue

@@ -4,17 +4,10 @@
       <div>
         <i class="el-icon-search"></i>
         <span>筛选搜索</span>
-        <el-button
-          style="float:right"
-          type="primary"
-          @click="handleSearchList()"
-          size="small">
+        <el-button style="float:right" type="primary" @click="handleSearchList()" size="small">
           查询搜索
         </el-button>
-        <el-button
-          style="float:right;margin-right: 15px"
-          @click="handleResetSearch()"
-          size="small">
+        <el-button style="float:right;margin-right: 15px" @click="handleResetSearch()" size="small">
           重置
         </el-button>
       </div>
@@ -32,93 +25,67 @@
       <el-button size="mini" class="btn-add" @click="handleAdd()" style="margin-left: 20px">添加</el-button>
     </el-card>
     <div class="table-container">
-      <el-table ref="adminTable"
-                :data="list"
-                style="width: 100%;"
-                v-loading="listLoading" border>
+      <el-table ref="adminTable" :data="list" style="width: 100%;" v-loading="listLoading" border>
         <el-table-column label="编号" width="100" align="center">
-          <template slot-scope="scope">{{scope.row.id}}</template>
+          <template slot-scope="scope">{{ scope.row.id }}</template>
         </el-table-column>
         <el-table-column label="帐号" align="center">
-          <template slot-scope="scope">{{scope.row.username}}</template>
+          <template slot-scope="scope">{{ scope.row.username }}</template>
         </el-table-column>
         <el-table-column label="姓名" align="center">
-          <template slot-scope="scope">{{scope.row.nickName}}</template>
+          <template slot-scope="scope">{{ scope.row.nickName }}</template>
         </el-table-column>
         <el-table-column label="邮箱" align="center">
-          <template slot-scope="scope">{{scope.row.email}}</template>
+          <template slot-scope="scope">{{ scope.row.email }}</template>
         </el-table-column>
         <el-table-column label="添加时间" width="160" align="center">
-          <template slot-scope="scope">{{scope.row.createTime | formatDateTime}}</template>
+          <template slot-scope="scope">{{ scope.row.createTime | formatDateTime }}</template>
         </el-table-column>
         <el-table-column label="最后登录" width="160" align="center">
-          <template slot-scope="scope">{{scope.row.loginTime | formatDateTime}}</template>
+          <template slot-scope="scope">{{ scope.row.loginTime | formatDateTime }}</template>
         </el-table-column>
         <el-table-column label="是否启用" width="140" align="center">
           <template slot-scope="scope">
-            <el-switch
-              @change="handleStatusChange(scope.$index, scope.row)"
-              :active-value="1"
-              :inactive-value="0"
+            <el-switch @change="handleStatusChange(scope.$index, scope.row)" :active-value="1" :inactive-value="0"
               v-model="scope.row.status">
             </el-switch>
           </template>
         </el-table-column>
         <el-table-column label="操作" width="180" align="center">
           <template slot-scope="scope">
-            <el-button size="mini"
-                       type="text"
-                       @click="handleSelectRole(scope.$index, scope.row)">分配角色
+            <el-button size="mini" type="text" @click="handleSelectRole(scope.$index, scope.row)">分配角色
             </el-button>
-            <el-button size="mini"
-                       type="text"
-                       @click="handleUpdate(scope.$index, scope.row)">
+            <el-button size="mini" type="text" @click="handleUpdate(scope.$index, scope.row)">
               编辑
             </el-button>
-            <el-button size="mini"
-                       type="text"
-                       @click="handleDelete(scope.$index, scope.row)">删除
+            <el-button size="mini" type="text" @click="handleDelete(scope.$index, scope.row)">删除
             </el-button>
           </template>
         </el-table-column>
       </el-table>
     </div>
     <div class="pagination-container">
-      <el-pagination
-        background
-        @size-change="handleSizeChange"
-        @current-change="handleCurrentChange"
-        layout="total, sizes,prev, pager, next,jumper"
-        :current-page.sync="listQuery.pageNum"
-        :page-size="listQuery.pageSize"
-        :page-sizes="[10,15,20]"
-        :total="total">
+      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
+        layout="total, sizes,prev, pager, next,jumper" :current-page.sync="listQuery.pageNum"
+        :page-size="listQuery.pageSize" :page-sizes="[10, 15, 20]" :total="total">
       </el-pagination>
     </div>
-    <el-dialog
-      :title="isEdit?'编辑用户':'添加用户'"
-      :visible.sync="dialogVisible"
-      width="40%">
-      <el-form :model="admin"
-               ref="adminForm"
-               label-width="150px" size="small">
-        <el-form-item label="帐号:">
+    <el-dialog :title="isEdit ? '编辑用户' : '添加用户'" :visible.sync="dialogVisible" width="40%">
+      <el-form :model="admin" ref="adminForm" :rules="rules" label-width="150px" size="small">
+        <el-form-item label="帐号:" prop="username">
           <el-input v-model="admin.username" style="width: 250px"></el-input>
         </el-form-item>
-        <el-form-item label="姓名:">
+        <el-form-item label="姓名:" prop="nickName">
           <el-input v-model="admin.nickName" style="width: 250px"></el-input>
         </el-form-item>
-        <el-form-item label="邮箱:">
+        <el-form-item label="邮箱:" prop="email">
           <el-input v-model="admin.email" style="width: 250px"></el-input>
         </el-form-item>
-        <el-form-item label="密码:">
-          <el-input v-model="admin.password"  type="password" style="width: 250px"></el-input>
+        <el-form-item label="密码:" prop="password">
+          <el-input v-model="admin.password" type="password" style="width: 250px"></el-input>
         </el-form-item>
         <el-form-item label="备注:">
-          <el-input v-model="admin.note"
-                    type="textarea"
-                    :rows="5"
-                    style="width: 250px"></el-input>
+          <el-input v-model="admin.note" type="textarea" :rows="5" style="width: 250px"></el-input>
         </el-form-item>
         <el-form-item label="是否启用:">
           <el-radio-group v-model="admin.status">
@@ -132,16 +99,9 @@
         <el-button type="primary" @click="handleDialogConfirm()" size="small">确 定</el-button>
       </span>
     </el-dialog>
-    <el-dialog
-      title="分配角色"
-      :visible.sync="allocDialogVisible"
-      width="30%">
-      <el-select v-model="allocRoleIds" multiple placeholder="请选择" size="small" style="width: 80%">
-        <el-option
-          v-for="item in allRoleList"
-          :key="item.id"
-          :label="item.name"
-          :value="item.id">
+    <el-dialog title="分配角色" :visible.sync="allocDialogVisible" width="30%">
+      <el-select v-model="allocRoleIds" placeholder="请选择" size="small" style="width: 80%">
+        <el-option v-for="item in allRoleList" :key="item.id" :label="item.name" :value="item.id">
         </el-option>
       </el-select>
       <span slot="footer" class="dialog-footer">
@@ -152,193 +112,212 @@
   </div>
 </template>
 <script>
-  import {fetchList,createAdmin,updateAdmin,updateStatus,deleteAdmin,getRoleByAdmin,allocRole} from '@/api/login';
-  import {fetchAllRoleList} from '@/api/role';
-  import {formatDate} from '@/utils/date';
+import { fetchList, createAdmin, updateAdmin, updateStatus, deleteAdmin, getRoleByAdmin, allocRole } from '@/api/login';
+import { fetchAllRoleList } from '@/api/role';
+import { formatDate } from '@/utils/date';
 
-  const defaultListQuery = {
-    pageNum: 1,
-    pageSize: 10,
-    keyword: null
-  };
-  const defaultAdmin = {
-    id: null,
-    username: null,
-    password: null,
-    nickName: null,
-    email: null,
-    note: null,
-    status: 1
-  };
-  export default {
-    name: 'adminList',
-    data() {
-      return {
-        listQuery: Object.assign({}, defaultListQuery),
-        list: null,
-        total: null,
-        listLoading: false,
-        dialogVisible: false,
-        admin: Object.assign({}, defaultAdmin),
-        isEdit: false,
-        allocDialogVisible: false,
-        allocRoleIds:[],
-        allRoleList:[],
-        allocAdminId:null
+const defaultListQuery = {
+  pageNum: 1,
+  pageSize: 10,
+  keyword: null
+};
+const defaultAdmin = {
+  id: null,
+  username: null,
+  password: null,
+  nickName: null,
+  email: null,
+  note: null,
+  status: 1
+};
+export default {
+  name: 'adminList',
+  data() {
+    return {
+      listQuery: Object.assign({}, defaultListQuery),
+      list: null,
+      total: null,
+      listLoading: false,
+      dialogVisible: false,
+      admin: Object.assign({}, defaultAdmin),
+      isEdit: false,
+      allocDialogVisible: false,
+      allocRoleIds: [],
+      allRoleList: [],
+      allocAdminId: null,
+      rules: {
+        username: [{ required: true, message: '请输入账号', trigger: 'blur' }],
+        nickName: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
+        email: [{ required: true, message: '请输入邮箱', trigger: 'blur' },
+        { required: true, type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }],
+        password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
       }
+    }
+  },
+  created() {
+    this.getList();
+    this.getAllRoleList();
+  },
+  filters: {
+    formatDateTime(time) {
+      if (time == null || time === '') {
+        return 'N/A';
+      }
+      let date = new Date(time);
+      return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
+    }
+  },
+  methods: {
+    handleResetSearch() {
+      this.listQuery = Object.assign({}, defaultListQuery);
     },
-    created() {
+    handleSearchList() {
+      this.listQuery.pageNum = 1;
       this.getList();
-      this.getAllRoleList();
     },
-    filters: {
-      formatDateTime(time) {
-        if (time == null || time === '') {
-          return 'N/A';
-        }
-        let date = new Date(time);
-        return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
-      }
+    handleSizeChange(val) {
+      this.listQuery.pageNum = 1;
+      this.listQuery.pageSize = val;
+      this.getList();
     },
-    methods: {
-      handleResetSearch() {
-        this.listQuery = Object.assign({}, defaultListQuery);
-      },
-      handleSearchList() {
-        this.listQuery.pageNum = 1;
-        this.getList();
-      },
-      handleSizeChange(val) {
-        this.listQuery.pageNum = 1;
-        this.listQuery.pageSize = val;
-        this.getList();
-      },
-      handleCurrentChange(val) {
-        this.listQuery.pageNum = val;
-        this.getList();
-      },
-      handleAdd() {
-        this.dialogVisible = true;
-        this.isEdit = false;
-        this.admin = Object.assign({},defaultAdmin);
-      },
-      handleStatusChange(index, row) {
-        this.$confirm('是否要修改该状态?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          updateStatus(row.id, {status: row.status}).then(response => {
+    handleCurrentChange(val) {
+      this.listQuery.pageNum = val;
+      this.getList();
+    },
+    handleAdd() {
+      this.dialogVisible = true;
+      this.isEdit = false;
+      this.admin = Object.assign({}, defaultAdmin);
+    },
+    handleStatusChange(index, row) {
+      this.$confirm('是否要修改该状态?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        updateStatus(row.id, { status: row.status }).then(response => {
+          if (response.code === 200) {
             this.$message({
-              type: 'success',
-              message: '修改成功!'
-            });
-          });
-        }).catch(() => {
-          this.$message({
-            type: 'info',
-            message: '取消修改'
+            type: 'success',
+            message: '修改成功!'
           });
-          this.getList();
+          }
+        });
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '取消修改'
         });
-      },
-      handleDelete(index, row) {
-        this.$confirm('是否要删除该用户?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          deleteAdmin(row.id).then(response => {
+        this.getList();
+      });
+    },
+    handleDelete(index, row) {
+      this.$confirm('是否要删除该用户?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        deleteAdmin(row.id).then(response => {
+          if (response.code === 200) {
             this.$message({
-              type: 'success',
-              message: '删除成功!'
-            });
-            this.getList();
+            type: 'success',
+            message: '删除成功!'
           });
-        });
-      },
-      handleUpdate(index, row) {
-        this.dialogVisible = true;
-        this.isEdit = true;
-        this.admin = Object.assign({},row);
-      },
-      handleDialogConfirm() {
-        this.$confirm('是否要确认?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          if (this.isEdit) {
-            updateAdmin(this.admin.id,this.admin).then(response => {
-              this.$message({
-                message: '修改成功!',
-                type: 'success'
-              });
-              this.dialogVisible =false;
-              this.getList();
-            })
-          } else {
-            createAdmin(this.admin).then(response => {
-              this.$message({
-                message: '添加成功!',
-                type: 'success'
-              });
-              this.dialogVisible =false;
-              this.getList();
-            })
+          this.getList();
           }
-        })
-      },
-      handleAllocDialogConfirm(){
-        this.$confirm('是否要确认?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          let params = new URLSearchParams();
-          params.append("adminId", this.allocAdminId);
-          params.append("roleIds", this.allocRoleIds);
-          allocRole(params).then(response => {
+        });
+      });
+    },
+    handleUpdate(index, row) {
+      this.dialogVisible = true;
+      this.isEdit = true;
+      this.admin = Object.assign({}, row);
+    },
+    handleDialogConfirm() {
+      this.$refs['adminForm'].validate(valid => {
+        if (valid) {
+          this.$confirm('是否要确认?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }).then(() => {
+            if (this.isEdit) {
+              updateAdmin(this.admin.id, this.admin).then(response => {
+                if (response.code === 200) {
+                  this.$message({
+                  message: '修改成功!',
+                  type: 'success'
+                });
+                this.dialogVisible = false;
+                this.getList();
+                }
+              })
+            } else {
+              createAdmin(this.admin).then(response => {
+                if (response.code === 200) {
+                  this.$message({
+                  message: '添加成功!',
+                  type: 'success'
+                });
+                this.dialogVisible = false;
+                this.getList();
+                }
+              })
+            }
+          })
+        }
+      })
+    },
+    handleAllocDialogConfirm() {
+      this.$confirm('是否要确认?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        let params = new URLSearchParams();
+        params.append("adminId", this.allocAdminId);
+        params.append("roleIds", this.allocRoleIds);
+        allocRole(params).then(response => {
+          if (response.code == 200) {
             this.$message({
               message: '分配成功!',
               type: 'success'
             });
-            this.allocDialogVisible = false;
-          })
+          }
+          this.allocDialogVisible = false;
         })
-      },
-      handleSelectRole(index,row){
-        this.allocAdminId = row.id;
-        this.allocDialogVisible = true;
-        this.getRoleListByAdmin(row.id);
-      },
-      getList() {
-        this.listLoading = true;
-        fetchList(this.listQuery).then(response => {
-          this.listLoading = false;
-          this.list = response.data.list;
-          this.total = response.data.total;
-        });
-      },
-      getAllRoleList() {
-        fetchAllRoleList().then(response => {
-          this.allRoleList = response.data;
-        });
-      },
-      getRoleListByAdmin(adminId) {
-        getRoleByAdmin(adminId).then(response => {
-          let allocRoleList = response.data;
-          this.allocRoleIds=[];
-          if(allocRoleList!=null&&allocRoleList.length>0){
-            for(let i=0;i<allocRoleList.length;i++){
-              this.allocRoleIds.push(allocRoleList[i].id);
-            }
+      })
+    },
+    handleSelectRole(index, row) {
+      this.allocAdminId = row.id;
+      this.allocDialogVisible = true;
+      this.getRoleListByAdmin(row.id);
+    },
+    getList() {
+      this.listLoading = true;
+      fetchList(this.listQuery).then(response => {
+        this.listLoading = false;
+        this.list = response.data.list;
+        this.total = response.data.total;
+      });
+    },
+    getAllRoleList() {
+      fetchAllRoleList().then(response => {
+        this.allRoleList = response.data;
+      });
+    },
+    getRoleListByAdmin(adminId) {
+      getRoleByAdmin(adminId).then(response => {
+        let allocRoleList = response.data;
+        this.allocRoleIds = [];
+        if (allocRoleList != null && allocRoleList.length > 0) {
+          for (let i = 0; i < allocRoleList.length; i++) {
+            this.allocRoleIds.push(allocRoleList[i].name);
           }
-        });
-      }
+        }
+      });
     }
   }
+}
 </script>
 <style></style>
-
-