Parcourir la source

修正重置密碼的BUG

osbert il y a 4 ans
Parent
commit
9168d65d7a

+ 9 - 1
TEAMModelOS/ClientApp/src/view/student-account/AddStudent.vue

@@ -173,6 +173,7 @@
 <script>
     import fn from '@/utils/js-fn.js'
     import { mapGetters } from 'vuex'
+// import { delete } from 'vuedraggable'
 
     export default {
         props: {
@@ -391,7 +392,14 @@
                             }) 
                             apiData = temp
                         }
-                        if(apiData.length > 0){
+                        if(apiData.length > 0){                 
+                            // 新增 如果密碼沒被改變就拿掉此Key           
+                            apiData.forEach( (item) =>{
+                                if(item.pw == '******') {
+                                    delete item.pw
+                                }
+                            })
+
                             this.$api.stuAccount.saveAllStudent(this.schoolCode, apiData).then(
                                 (res) => {
                                     if (res.error == null) {

+ 10 - 8
TEAMModelOS/ClientApp/src/view/student-account/Index.vue

@@ -175,7 +175,6 @@ export default {
          */
         resetPW(row) {
             //重置单个学生
-            console.log(row)
             if (row != -1) {
                 this.$Modal.confirm({
                     title: this.$t('重置密碼'),
@@ -206,20 +205,23 @@ export default {
                         content: '<p>确认批量重置' + " <strong style='color:red;'>" + this.selections.length + '</strong>个学生密碼</p>',
                         onOk: () => {
                             this.tableLoading = true
-                            // let ids = this.selections.map(item => {
-                            //     return { id: item.id, pw: item.id }
-                            // })
-                            this.$api.stuAccount.saveAllStudent(this.$store.state.user.schoolCode, this.selections).then(
+                            let apiData = this.selections.map( (item) =>{
+                                let d = item
+                                d.pw = d.id
+                                return d
+                            })
+
+                            this.$api.stuAccount.saveAllStudent(this.$store.state.user.schoolCode, apiData).then(
                                 res => {
                                     this.selections.length = 0
                                     this.$Message.success('重置成功!')
-                                    this.tableLoading = false
                                 },
                                 err => {
                                     this.$Message.error('API ERROR!')
-                                    this.tableLoading = false
                                 }
-                            )
+                            ).finally(() => {
+                                this.tableLoading = false
+                            })
                         }
                     })
                 }