Sfoglia il codice sorgente

增加输入框类型校验 -zzx

学习?学个屁 7 mesi fa
parent
commit
bb208c2e77

+ 3 - 3
src/router/index.js

@@ -98,21 +98,21 @@ export const asyncRouterMap = [
       path: 'setCommission',
       name: 'setCommission',
       component: () => import('@/views/distribution/peopleManage/setCommission'),
-      meta: {title: '分销佣金设置', icon: 'peopleChannel'},
+      meta: {title: '电站列表', icon: 'peopleChannel'},
       hidden: true
     },
     {
       path: 'settingsPrice',
       name: 'settingsPrice',
       component: () => import('@/views/distribution/peopleManage/settingsPrice'),
-      meta: {title: '代理价设置', icon: 'peopleChannel'},
+      meta: {title: '价设置', icon: 'peopleChannel'},
       hidden: true
     },
     {
       path: 'firstSetPrice',
       name: 'firstSetPrice',
       component: () => import('@/views/distribution/peopleManage/firstSetPrice'),
-      meta: {title: '代理价设置', icon: 'peopleChannel'},
+      meta: {title: '价设置', icon: 'peopleChannel'},
       hidden: true
     },
     {

+ 47 - 14
src/views/distribution/peopleManage/firstSetPrice.vue

@@ -4,7 +4,7 @@
  * @Author: zzx
  * @Date: 2024-11-27 16:08:16
  * @LastEditors: zzx tigerzouzx@foxmail.com
- * @LastEditTime: 2024-11-28 18:00
+ * @LastEditTime: 2024-12-02 18:00
 -->
 <template>
     <div class="app-container">
@@ -40,15 +40,16 @@
                     <template slot-scope="scope">
                         <span class="edit" v-if="scope.row.isEdit === false"
                             @click="toggleEdit(scope.row)">{{ scope.row.secondLevelPrice }}</span>
-                        <el-input v-else v-model="scope.row.secondLevelPrice" :disabled="isAdmin == 3" size="small" style="width: 100px;" @blur="saveEdit(scope.row)">
+                        <el-input v-else v-model="editInput" size="small" oninput="value=value.replace(/[^\d.]/g,'')" style="width: 200px;" @blur="saveEdit(scope.row)">
+                            <i slot="suffix" size="small" class="el-icon-check" @click="confrimEdit(scope.row)"></i>
                             <i slot="suffix" size="small" class="el-icon-close" @click="cancelEdit(scope.row)"></i>
                         </el-input>
                     </template>
                 </el-table-column>
             </el-table>
         </div>
-        <el-divider></el-divider>
-        <el-card class="operate-container" shadow="hover">
+        <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="info" size="small" @click="cancelForbidden">取消</el-button>
@@ -74,6 +75,8 @@ export default {
             dialogList: null,
             dialogListLoading: false,
             total: null,
+            editInput: null,
+            currentEditingRow: null //用于记录当前正在编辑的行
         };
     },
     watch: {},
@@ -86,29 +89,52 @@ export default {
     },
     methods: {
         toggleEdit(row) {
+            if (this.currentEditingRow) {
+                this.currentEditingRow.isEdit = false;
+            }
             row.isEdit = !row.isEdit;
+            this.editInput = row.secondLevelPrice;
+            if (row.isEdit) {
+                this.currentEditingRow = row;
+                
+            } else {
+                this.currentEditingRow = null;
+            }
         },
-        cancelEdit(row) {
-            if (row.firstLevelPrice >= row.platformPrice) {
-                row.firstLevelPrice = 0
+        confrimEdit(row) {
+            if (this.editInput >= row.platformPrice) {
                 return this.$message.error('分销价格必须小于平台价格');
             }
-            if (row.secondLevelPrice <= row.firstLevelPrice) {
-                row.secondLevelPrice = 0
+            if (this.editInput <= row.firstLevelPrice) {
                 return this.$message.error('二级代理价不能小于一级代理价');
             }
+            row.secondLevelPrice = this.editInput
             row.isEdit = false
+            this.currentEditingRow = null;
         },
-        saveEdit(row) {
-            if (row.secondLevelPrice >= row.platformPrice) {
-                row.secondLevelPrice = 0
+        cancelEdit(row) {
+            if (row.firstLevelPrice >= row.platformPrice) {
                 return this.$message.error('分销价格必须小于平台价格');
             }
             if (row.secondLevelPrice <= row.firstLevelPrice) {
-                row.secondLevelPrice = 0
                 return this.$message.error('二级代理价不能小于一级代理价');
             }
             row.isEdit = false
+            this.currentEditingRow = null;
+        },
+        saveEdit(row) {
+            // if (row.secondLevelPrice >= row.platformPrice) {
+            //     row.secondLevelPrice = 0
+            //     return this.$message.error('分销价格必须小于平台价格');
+            // }
+            // if (row.secondLevelPrice <= row.firstLevelPrice) {
+            //     row.secondLevelPrice = 0
+            //     return this.$message.error('二级代理价不能小于一级代理价');
+            // }
+            // row.secondLevelPrice = this.editInput
+            // console.log(this.editInput,'---输入框');
+            // console.log(row.secondLevelPrice,'---默认');
+            // row.isEdit = false
         },
         confirmForbidden() {
             const newArray = this.dialogList.map(item => ({
@@ -149,7 +175,14 @@ export default {
     color: #409EFF;
     cursor: pointer;
 }
+.el-icon-check{
+    font-size: 22px;
+    font-weight: 1000;
+    color: rgb(103,194,58);
+}
 .el-icon-close{
-    font-size: 18px;
+    font-size: 22px;
+    font-weight: 1000;
+    color: rgba(240, 10, 10,0.6);
 }
 </style>

+ 4 - 4
src/views/distribution/peopleManage/setCommission.vue

@@ -4,7 +4,7 @@
  * @Author: zzx
  * @Date: 2024-11-27 16:08:16
  * @LastEditors: zzx tigerzouzx@foxmail.com
- * @LastEditTime: 2024-11-28 18:00
+ * @LastEditTime: 2024-12-02 18:00
 -->
 <template>
     <div class="app-container">
@@ -29,7 +29,7 @@
                         </el-select>
                     </el-form-item>
                     <el-form-item label="充电站ID:">
-                        <el-input v-model="listQuery.stationId" class="input-width" placeholder="请输入充电站ID"
+                        <el-input v-model="listQuery.stationId" type="number" class="input-width" placeholder="请输入充电站ID"
                             clearable></el-input>
                     </el-form-item>
                     <el-form-item label="充电站名称:">
@@ -212,8 +212,8 @@ export default {
         },
 
         handleResetSearch() {
-            this.date = ''
-            this.listQuery = Object.assign({}, defaultListQuery);
+            this.listQuery.stationStatus= null
+            this.listQuery.stationName = null
         },
         handleSearchList() {
             this.listQuery.userId = null

+ 48 - 15
src/views/distribution/peopleManage/settingsPrice.vue

@@ -4,7 +4,7 @@
  * @Author: zzx
  * @Date: 2024-11-27 16:08:16
  * @LastEditors: zzx tigerzouzx@foxmail.com
- * @LastEditTime: 2024-11-28 18:00
+ * @LastEditTime: 2024-12-02 18:00
 -->
 <template>
     <div class="app-container">
@@ -40,8 +40,11 @@
                 <el-table-column label="销售合计价(元)" align="center" prop="platformPrice"></el-table-column>
                 <el-table-column label="一级代理价(元)" align="center" prop="">
                     <template slot-scope="scope">
-                        <span class="edit" v-if="scope.row.isEdit === false" @click="toggleEdit(scope.row)">{{scope.row.firstLevelPrice }}</span>
-                        <el-input v-else v-model="scope.row.firstLevelPrice" size="small" style="width: 100px;" @blur="saveEdit(scope.row)">
+                        <span class="edit" v-if="scope.row.isEdit === false" @click="toggleEdit(scope.row)">{{
+                            scope.row.firstLevelPrice }}</span>
+                        <el-input v-else v-model="editInput" size="small" oninput="value=value.replace(/[^\d.]/g,'')" style="width: 200px;"
+                            @blur="saveEdit(scope.row)">
+                            <i slot="suffix" size="small" class="el-icon-check" @click="confrimEdit(scope.row)"></i>
                             <i slot="suffix" size="small" class="el-icon-close" @click="cancelEdit(scope.row)"></i>
                         </el-input>
                     </template>
@@ -75,6 +78,8 @@ export default {
             dialogList: null,
             dialogListLoading: false,
             total: null,
+            editInput: null,
+            currentEditingRow: null //用于记录当前正在编辑的行
         };
     },
     watch: {},
@@ -86,22 +91,41 @@ export default {
     },
     methods: {
         toggleEdit(row) {
+            if (this.currentEditingRow) {
+                this.currentEditingRow.isEdit = false;
+            }
             row.isEdit = !row.isEdit;
+            this.editInput = row.firstLevelPrice;
+            if (row.isEdit) {
+                this.currentEditingRow = row;
+                
+            } else {
+                this.currentEditingRow = null;
+            }
         },
-        cancelEdit(row) {
-            if (row.firstLevelPrice >= row.platformPrice) {
-                row.firstLevelPrice = 0
+        confrimEdit(row) {
+            if (this.editInput >= row.platformPrice) {
                 return this.$message.error('分销价格必须小于平台价格');
-            }else{
-                row.isEdit=false
             }
+            row.firstLevelPrice = this.editInput;
+            row.isEdit = false
+            //置空当前编辑行记录
+            this.currentEditingRow = null;
         },
-        saveEdit(row) {
-            if (row.firstLevelPrice >= row.platformPrice) {
-                row.firstLevelPrice = 0
+        cancelEdit(row) {
+            if (this.editInput >= row.platformPrice) {
                 return this.$message.error('分销价格必须小于平台价格');
             }
-            row.isEdit=false
+            row.isEdit = false
+            //置空当前编辑行记录
+            this.currentEditingRow = null;
+        },
+        saveEdit(row) {
+            // if (row.firstLevelPrice >= row.platformPrice) {
+            //     row.firstLevelPrice = 0
+            //     return this.$message.error('分销价格必须小于平台价格');
+            // }
+            // row.isEdit=false
         },
         confirmForbidden() {
             const newArray = this.dialogList.map(item => ({
@@ -138,11 +162,20 @@ export default {
 };
 </script>
 <style scoped>
-.edit{
+.edit {
     color: #409EFF;
     cursor: pointer;
 }
-.el-icon-close{
-    font-size: 18px;
+
+.el-icon-check {
+    font-size: 22px;
+    font-weight: 1000;
+    color: rgb(103, 194, 58);
+}
+
+.el-icon-close {
+    font-size: 22px;
+    font-weight: 1000;
+    color: rgba(240, 10, 10, 0.6);
 }
 </style>