AssignmentDialog.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible="visible"
  5. :before-close="onHide"
  6. custom-class="points-assign-dialog">
  7. <div class="filter-container filter-view">
  8. <el-select
  9. style="min-width: 70px; max-width: 120px;"
  10. clearable
  11. v-model="filter.pageCriteria.assignmentStatus"
  12. placeholder="Status"
  13. @change="onSearch">
  14. <el-option
  15. v-for="(item, index) in statusOptions"
  16. :key="index"
  17. :label="item"
  18. :value="item"/>
  19. </el-select>
  20. <div style="flex: 1; min-width: 150px; max-width: 300px;">
  21. <el-input
  22. clearable
  23. v-model="filter.pageCriteria.criteria"
  24. placeholder="Search by Site Name or Service Provider"
  25. @keyup.enter.native="onSearch"/>
  26. </div>
  27. <el-button
  28. type="primary"
  29. @click="onSearch">
  30. Search
  31. </el-button>
  32. </div>
  33. <div class="assign-table-actions">
  34. <el-button
  35. type="danger"
  36. :disabled="selectRow.length == 0"
  37. :loading="loading.unassign"
  38. @click="unassignSites">
  39. Batch Un-assign
  40. </el-button>
  41. <el-button
  42. type="accent"
  43. :disabled="selectRow.length == 0"
  44. :loading="loading.assign"
  45. @click="assignSites">
  46. Batch Assign
  47. </el-button>
  48. </div>
  49. <div class="table-view" v-loading="table.loading">
  50. <el-table
  51. :data="table.data"
  52. height="100%"
  53. class="no-border"
  54. @selection-change="changeSelection"
  55. v-if="visible">
  56. <el-table-column
  57. align="center"
  58. label="Site Name"
  59. prop="siteName"
  60. min-width="130"/>
  61. <el-table-column
  62. align="center"
  63. label="Charger Id"
  64. prop="chargeBoxId"
  65. min-width="150"/>
  66. <el-table-column
  67. align="center"
  68. label="Connector Id"
  69. prop="connectorId"
  70. min-width="150"/>
  71. <el-table-column
  72. align="center"
  73. label="Assignment Status"
  74. prop="assignmentStatus"
  75. min-width="150"/>
  76. <el-table-column
  77. align="center"
  78. label="Select"
  79. type="selection"/>
  80. </el-table>
  81. </div>
  82. <div class="center" style="margin-bottom: -20px;">
  83. <Pagination
  84. v-show="table.total"
  85. :total="table.total"
  86. :page.sync="filter.pageNum"
  87. :limit.sync="filter.pageSize"
  88. @pagination="getTableData"/>
  89. </div>
  90. </el-dialog>
  91. </template>
  92. <script>
  93. import apiBase from '@/api/apiBase';
  94. import api from '@/api/apiMaintain.js';
  95. import Pagination from '@/components/Pagination'
  96. export default {
  97. name: "MaintainAssignmentDialog",
  98. props: {
  99. title: {
  100. type: String,
  101. default: ""
  102. },
  103. visible: {
  104. type: Boolean,
  105. default: false
  106. },
  107. item: {
  108. type: Object,
  109. default: () => ({})
  110. }
  111. },
  112. components: {Pagination},
  113. data() {
  114. return {
  115. filter: {
  116. pageNum: 1,
  117. pageSize: 10,
  118. pageCriteria: {
  119. criteria: "",
  120. downtimeId: "",
  121. assignmentStatus: ""
  122. }
  123. },
  124. table: {
  125. data: [],
  126. total: 0,
  127. loading: false
  128. },
  129. loading: {
  130. assign: false,
  131. unassign: false
  132. },
  133. selectRow: [],
  134. statusOptions:[]
  135. };
  136. },
  137. mounted() {
  138. this.getStatusOptions();
  139. },
  140. watch: {
  141. visible: {
  142. handler(n, o) {
  143. if (n) {
  144. this.filter.pageCriteria.downtimeId = this.item.downtimeId;
  145. this.onSearch();
  146. }
  147. }
  148. }
  149. },
  150. methods: {
  151. onHide() {
  152. this.$emit("hide");
  153. },
  154. onSearch() {
  155. this.filter.pageNo = 1;
  156. this.getTableData();
  157. },
  158. getStatusOptions() {
  159. apiBase.getAssignStatusOptions().then(res => {
  160. if (res.data) {
  161. this.statusOptions = res.data
  162. }
  163. }).catch(error => {
  164. this.$message({
  165. type: 'error',
  166. message: error
  167. })
  168. })
  169. },
  170. getTableData() {
  171. this.selectRow = []
  172. this.table.loading = true;
  173. api.getMaintainAssignPages(this.filter).then(res => {
  174. if (res.data.totalRow && res.data.records) {
  175. this.table.total = res.data.totalRow;
  176. this.table.data = res.data.records;
  177. } else {
  178. this.table.total = 0;
  179. this.table.data = [];
  180. }
  181. this.table.loading = false;
  182. }).catch(error => {
  183. this.$message({
  184. type: 'error',
  185. message: error
  186. })
  187. this.table.total = 0;
  188. this.table.data = [];
  189. this.table.loading = false;
  190. })
  191. },
  192. changeSelection(val) {
  193. this.selectRow = val;
  194. },
  195. getSelectIds() {
  196. const ids = [];
  197. this.selectRow.forEach(item => {
  198. ids.push(item.connectorPk)
  199. })
  200. return ids;
  201. },
  202. assignSites() {
  203. const params = {
  204. downtimeId: this.item.downtimeId,
  205. connectorPks: this.getSelectIds()
  206. }
  207. this.loading.assign = true;
  208. api.assignMaintainConnector(params).then(res => {
  209. this.$message({
  210. type: 'success',
  211. message: res.msg || "Success"
  212. })
  213. this.getTableData()
  214. }).catch(error => {
  215. this.$message({
  216. type: 'error',
  217. message: error
  218. })
  219. }).finally(() => {
  220. this.loading.assign = false;
  221. })
  222. },
  223. unassignSites() {
  224. const params = {
  225. downtimeId: this.item.downtimeId,
  226. connectorPks: this.getSelectIds()
  227. }
  228. this.loading.unassign = true;
  229. api.unassignMaintainConnector(params).then(res => {
  230. this.$message({
  231. type: 'success',
  232. message: res.msg || "Success"
  233. })
  234. this.getTableData()
  235. }).catch(error => {
  236. this.$message({
  237. type: 'error',
  238. message: error
  239. })
  240. }).finally(() => {
  241. this.loading.unassign = false;
  242. })
  243. }
  244. }
  245. }
  246. </script>
  247. <style scoped>
  248. >>> .points-assign-dialog {
  249. width: 65vw;
  250. height: 90vh;
  251. display: flex;
  252. max-width: 1200px;
  253. flex-direction: column;
  254. margin-top: 5vh !important;
  255. }
  256. >>> .points-assign-dialog .el-dialog__header {
  257. padding: 20px 20px 0;
  258. font-weight: bold;
  259. }
  260. >>> .points-assign-dialog .el-dialog__body {
  261. flex: 1;
  262. padding: 20px;
  263. display: flex;
  264. overflow: hidden;
  265. flex-direction: column;
  266. }
  267. .assign-table-actions {
  268. display: flex;
  269. padding-top: 5px;
  270. flex-wrap: wrap-reverse;
  271. align-items: center;
  272. justify-content: flex-end;
  273. }
  274. .points-assign-dialog .table-view {
  275. flex: 1;
  276. overflow-y: auto;
  277. padding-top: 10px;
  278. margin-bottom: -10px;
  279. }
  280. @media screen and (max-width: 1200px) {
  281. .points-assign-dialog {
  282. width: 70vw;
  283. }
  284. }
  285. @media screen and (max-width: 1000px) {
  286. .points-assign-dialog {
  287. width: 80vw;
  288. }
  289. }
  290. @media screen and (max-width: 800px) {
  291. .points-assign-dialog {
  292. width: 90vw;
  293. }
  294. }
  295. @media screen and (max-width: 700px) {
  296. .points-assign-dialog {
  297. width: 99vw;
  298. }
  299. }
  300. @media screen and (max-width: 320px) {
  301. .points-assign-dialog {
  302. width: 100%;
  303. min-width: 300px;
  304. }
  305. }
  306. </style>