OverwriteOCPI.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <el-dialog
  3. :visible="visible"
  4. :before-close="e => hideDialog()"
  5. title="Manual Overwrite"
  6. custom-class="overwrite-ocpi-dialog">
  7. <el-form
  8. ref="form"
  9. :model="form"
  10. :rules="rules"
  11. label-position="right"
  12. label-width="240px">
  13. <el-form-item
  14. label="Current OCPP Status:"
  15. prop="transactionId">
  16. <el-input
  17. v-model="form.currentOcppStatus"
  18. class="flex-item"
  19. readonly
  20. style="max-width: 320px;"/>
  21. </el-form-item>
  22. <el-form-item
  23. label="Current OCPI Status:"
  24. prop="transactionId">
  25. <el-input
  26. v-model="form.currentOcpiStatus"
  27. class="flex-item"
  28. readonly
  29. style="max-width: 320px;"/>
  30. </el-form-item>
  31. <el-form-item
  32. label="Latest OCPI Status:"
  33. prop="latestOcpiStatus">
  34. <el-select
  35. v-model="form.latestOcpiStatus"
  36. class="flex-item"
  37. style="max-width: 320px;">
  38. <el-option
  39. v-for="(item, index) in options.status"
  40. :key="index"
  41. :label="item"
  42. :value="item"/>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item
  46. label="Latest OCPI Status Expire Time:"
  47. prop="latestOcpiStatusExpireTime">
  48. <el-date-picker
  49. v-model="form.latestOcpiStatusExpireTime"
  50. class="flex-item"
  51. type="datetime"
  52. format="yyyy-MM-dd HH:mm"
  53. value-format="yyyy-MM-dd HH:mm"
  54. style="width: 100%; max-width: 320px;"/>
  55. </el-form-item>
  56. <el-form-item
  57. label="Action Reason:"
  58. prop="actionReason">
  59. <el-input
  60. v-model="form.actionReason"
  61. class="flex-item"
  62. :autosize="autosize"
  63. maxlength="5000"
  64. type="textarea"
  65. style="max-width: 320px;"/>
  66. </el-form-item>
  67. <div class="center buttons">
  68. <el-button
  69. type="primary"
  70. class="cancel-button"
  71. @click="hideDialog()">
  72. Back
  73. </el-button>
  74. <el-button
  75. @click="onClickSave"
  76. type="primary"
  77. :loading="loading.save">
  78. &nbsp;Save&nbsp;
  79. </el-button>
  80. </div>
  81. </el-form>
  82. </el-dialog>
  83. </template>
  84. <script>
  85. import api from '../../../http/api/charge'
  86. export default {
  87. name: "DialogOverwriteOCPI",
  88. props: {
  89. visible: {
  90. type: Boolean,
  91. default: false
  92. },
  93. item: {
  94. type: Object,
  95. default: () => ({})
  96. }
  97. },
  98. data() {
  99. return {
  100. loading: {
  101. save: false
  102. },
  103. form: {
  104. connectorPk: "",
  105. currentOcppStatus: "",
  106. currentOcpiStatus: "",
  107. latestOcpiStatus: "",
  108. latestOcpiStatusExpireTime: "",
  109. actionReason: ""
  110. },
  111. rules: {
  112. latestOcpiStatus: {
  113. required: true,
  114. trigger: 'change',
  115. message: 'Please select status'
  116. },
  117. latestOcpiStatusExpireTime: {
  118. required: true,
  119. trigger: 'change',
  120. message: 'Please select date time'
  121. },
  122. },
  123. options: {
  124. status: []
  125. },
  126. autosize: {
  127. minRows: 3,
  128. maxRows: 10,
  129. },
  130. };
  131. },
  132. mounted() {
  133. this.getStatusOptions();
  134. },
  135. watch: {
  136. item: {
  137. immediate: true,
  138. handler(value) {
  139. if (value) {
  140. this.form.connectorPk = this.item.connectorPk;
  141. this.form.currentOcpiStatus = this.item.ocpiStatus;
  142. this.form.currentOcppStatus = this.item.status;
  143. }
  144. }
  145. },
  146. },
  147. methods: {
  148. hideDialog(success) {
  149. this.$emit("hide", success || false);
  150. this.form.latestOcpiStatus = "";
  151. this.form.latestOcpiStatusExpireTime = "";
  152. this.form.actionReason = "";
  153. this.$nextTick(() => {
  154. this.$refs['form'].clearValidate();
  155. })
  156. },
  157. getStatusOptions() {
  158. api.getOCPIStatusOptions().then(res => {
  159. if (res.data) {
  160. this.options.status = res.data
  161. }
  162. }).catch(err => {
  163. })
  164. },
  165. onClickSave() {
  166. this.$refs['form'].validate(result => {
  167. if (result) {
  168. this.manualOverwrite()
  169. }
  170. })
  171. },
  172. manualOverwrite() {
  173. this.loading.save = true;
  174. api.overwriteOCPIStatus(this.form).then(res => {
  175. this.loading.save = false;
  176. this.$message({
  177. message: 'Overwrite successfully',
  178. type: 'success'
  179. })
  180. this.hideDialog(true);
  181. }).catch(err => {
  182. this.loading.save = false;
  183. this.$message({
  184. type: 'error',
  185. message: err
  186. })
  187. });
  188. }
  189. },
  190. }
  191. </script>
  192. <style scoped>
  193. >>> .overwrite-ocpi-dialog {
  194. max-width: 620px;
  195. }
  196. </style>