Просмотр исходного кода

Manual settlement fix
https://dev.wormwood.com.sg/zentao/task-view-853.html

wudebin 6 месяцев назад
Родитель
Сommit
ad88fd1ae0

+ 149 - 0
Strides-Admin/src/views/transaction/end_transaction_dialog.vue

@@ -0,0 +1,149 @@
+<template>
+  <el-dialog
+    class="dialog-end-transaction"
+    :visible="visible"
+    :before-close="e => hideDialog(false)"
+    title="End Transaction">
+    <el-form
+      ref="endForm"
+      :model="form"
+      :rules="rules"
+      label-position="top">
+      <div class="form-row">
+        <el-form-item
+          prop="stopReason"
+          class="form-item"
+          label="Stop Reason:">
+          <el-input
+            v-model="form.stopReason"
+            class="flex-item"
+            type="textarea"
+            :autosize="autosize"
+            maxlength="30"/>
+        </el-form-item>
+      </div>
+      <div class="flexcc" style="margin-top: 50px;">
+        <el-button
+          type="primary"
+          style="margin: 0 10px;"
+          @click="onClickEnd"
+          :loading="endLoading">
+          End Transaction
+        </el-button>
+      </div>
+    </el-form>
+  </el-dialog>
+</template>
+
+<script>
+import api from '../../http/api/transaction'
+export default {
+  name: "EndTransactionDialog",
+  props: {
+    visible: {
+      type: Boolean,
+      default: false
+    },
+    id: {
+      type: String|Number,
+      default: ''
+    }
+  },
+  data() {
+    return {
+      form: {
+        stopReason: "",
+        transactionPk: ""
+      },
+      rules: {
+        stopReason: {
+          required: true,
+          message: "Stop reason is required",
+          trigger: "blur"
+        },
+      },
+      autosize: {
+        minRows: 3,
+        maxRows: 6,
+      },
+      endLoading: false
+    };
+  },
+  watch: {
+    id(n, o) {
+      if (this.visible && n) {
+        this.form.transactionPk = this.id;
+      }
+    }
+  },
+  mounted() {
+    
+  },
+  methods: {
+    hideDialog(success) {
+      this.stopReason = "";
+      this.$emit("hide", success || false);
+    },
+    onSubmit() {
+      this.$refs['endForm'].validate((valid) => {
+        if (valid) {
+          this.onClickEnd();
+        }
+      })
+    },
+    onClickEnd() {
+      this.$confirm('This operation only for settling abnormal transactions and will not end charging. Select Confirm to proceed.', 'Warning', {
+        confirmButtonText: 'Confirm',
+        cancelButtonText: 'Cancel',
+        type: 'warning'
+      }).then(res => {
+        this.endTransaction();
+      })
+    },
+    endTransaction() {
+      this.endLoading = true;
+      api.endTransaction(this.form).then(res => {
+        this.$message({
+          type: 'success',
+          message: 'Operation Successfully!'
+        })
+        this.hideDialog(true)
+      }).catch(err => {
+        this.$message({
+          type: 'error',
+          message: err
+        })
+      }).finally(() => {
+        this.endLoading = false
+      })
+    },
+  }
+}
+</script>
+
+<style scoped>
+.dialog-end-transaction {
+  display: flex;
+  align-items: center;
+  flex-direction: column;
+  justify-content: center;
+}
+.dialog-end-transaction >>> .el-dialog {
+  width: 100%;
+  max-width: 400px;
+  margin-top: 0 !important;
+}
+.dialog-end-transaction >>> .el-form {
+  padding-right: 10px;
+}
+.form-row {
+  display: flex;
+  flex-wrap: wrap;
+  padding: 0 0 10px;
+}
+.form-item {
+  flex: 1;
+  margin-left: 10px;
+  margin-bottom: 10px;
+}
+</style>

+ 21 - 4
Strides-Admin/src/views/transaction/view_transaction.vue

@@ -253,6 +253,9 @@
             @pagination="handlePageChange" />
             @pagination="handlePageChange" />
         </div>
         </div>
       </el-form>
       </el-form>
+      <end-dialog
+        v-bind="endDialog"
+        @hide="hideDialog"/>
     </div>
     </div>
   </div>
   </div>
 </template>
 </template>
@@ -260,9 +263,10 @@
 <script>
 <script>
   import Pagination from '@/components/Pagination'
   import Pagination from '@/components/Pagination'
   import api from '../../http/api/transaction'
   import api from '../../http/api/transaction'
+  import EndDialog from './end_transaction_dialog.vue'
   
   
   export default {
   export default {
-    components: { Pagination },
+    components: { EndDialog, Pagination },
     data() {
     data() {
       return {
       return {
         page: 1,
         page: 1,
@@ -272,7 +276,11 @@
         loading: false,
         loading: false,
         measurand: "",
         measurand: "",
         endLoading: false,
         endLoading: false,
-        optionsMeasurand: []
+        optionsMeasurand: [],
+        endDialog: {
+          id: "",
+          visible: false
+        }
       }
       }
     },
     },
     created() {
     created() {
@@ -316,13 +324,22 @@
         })
         })
       },
       },
       onClickEnd() {
       onClickEnd() {
-        this.$confirm('This operation only for settling abnormal transactions and will not end charging. Select Confirm to proceed.', 'Warning', {
+        this.endDialog.id = this.$route.params.id;
+        this.endDialog.visible = true;
+        
+        /*this.$confirm('This operation only for settling abnormal transactions and will not end charging. Select Confirm to proceed.', 'Warning', {
           confirmButtonText: 'Confirm',
           confirmButtonText: 'Confirm',
           cancelButtonText: 'Cancel',
           cancelButtonText: 'Cancel',
           type: 'warning'
           type: 'warning'
         }).then(res => {
         }).then(res => {
           this.endTransaction();
           this.endTransaction();
-        })
+        })*/
+      },
+      hideDialog(success) {
+        this.endDialog.visible = false;
+        if (success) {
+          this.getDeatil()
+        }
       },
       },
       endTransaction() {
       endTransaction() {
         this.endLoading = true;
         this.endLoading = true;