AssignmentDialog.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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"
  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="Address"
  64. prop="address"
  65. min-width="120"/>
  66. <el-table-column
  67. align="center"
  68. label="Service Provider"
  69. min-width="140">
  70. <template slot-scope="{row}">
  71. <div v-for="item in row.serviceProviders" :key="item">{{item}}</div>
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. align="center"
  76. label="Assignment Status"
  77. prop="assignmentStatus"
  78. min-width="150"/>
  79. <el-table-column
  80. align="center"
  81. label="Select"
  82. type="selection"/>
  83. </el-table>
  84. </div>
  85. <div class="center" style="margin-bottom: -20px;">
  86. <Pagination
  87. v-show="table.total"
  88. :total="table.total"
  89. :page.sync="filter.pageNum"
  90. :limit.sync="filter.pageSize"
  91. @pagination="getTableData"/>
  92. </div>
  93. </el-dialog>
  94. </template>
  95. <script>
  96. import apiBase from '@/api/apiBase';
  97. import api from '@/api/apiIdle.js';
  98. import Pagination from '@/components/Pagination'
  99. export default {
  100. name: "AssignmentDialog",
  101. props: {
  102. title: {
  103. type: String,
  104. default: "ASSIGN SITES"
  105. },
  106. visible: {
  107. type: Boolean,
  108. default: false
  109. },
  110. item: {
  111. type: Object,
  112. default: () => ({})
  113. }
  114. },
  115. components: {Pagination},
  116. data() {
  117. return {
  118. filter: {
  119. pageNum: 1,
  120. pageSize: 10,
  121. pageCriteria: {
  122. criteria: "",
  123. dynamicIdleFeeId: "",
  124. assignmentStatus: ""
  125. }
  126. },
  127. table: {
  128. data: [],
  129. total: 0,
  130. loading: false
  131. },
  132. loading: {
  133. assign: false,
  134. unassign: false
  135. },
  136. selectRow: [],
  137. statusOptions:[]
  138. };
  139. },
  140. mounted() {
  141. this.getStatusOptions();
  142. },
  143. watch: {
  144. visible: {
  145. handler(n, o) {
  146. if (n) {
  147. this.filter.pageCriteria.dynamicIdleFeeId = this.item.dynamicIdleFeeId;
  148. this.onSearch();
  149. }
  150. }
  151. }
  152. },
  153. methods: {
  154. onHide() {
  155. this.$emit("hide");
  156. },
  157. onSearch() {
  158. this.filter.pageNo = 1;
  159. this.getTableData();
  160. },
  161. getStatusOptions() {
  162. apiBase.getAssignStatusOptions().then(res => {
  163. if (res.data) {
  164. this.statusOptions = res.data
  165. }
  166. }).catch(error => {
  167. this.$message({
  168. type: 'error',
  169. message: error
  170. })
  171. })
  172. },
  173. getTableData() {
  174. this.selectRow = []
  175. this.table.loading = true;
  176. api.getAssignIdleConfigPages(this.filter).then(res => {
  177. if (res.data.totalRow && res.data.records) {
  178. this.table.total = res.data.totalRow;
  179. this.table.data = res.data.records;
  180. } else {
  181. this.table.total = 0;
  182. this.table.data = [];
  183. }
  184. this.table.loading = false;
  185. }).catch(error => {
  186. this.$message({
  187. type: 'error',
  188. message: error
  189. })
  190. this.table.total = 0;
  191. this.table.data = [];
  192. this.table.loading = false;
  193. })
  194. },
  195. changeSelection(val) {
  196. this.selectRow = val;
  197. },
  198. getSelectIds() {
  199. const ids = [];
  200. this.selectRow.forEach(item => {
  201. ids.push(item.sitePk)
  202. })
  203. return ids;
  204. },
  205. assignSites() {
  206. const params = {
  207. dynamicIdleFeeId: this.item.dynamicIdleFeeId,
  208. //tenantId: this.item.tenantId,
  209. sitePks: this.getSelectIds()
  210. }
  211. this.loading.assign = true;
  212. api.assignIdleConfig(params).then(res => {
  213. this.$message({
  214. type: 'success',
  215. message: res.msg || "Success"
  216. })
  217. this.getTableData()
  218. }).catch(error => {
  219. this.$message({
  220. type: 'error',
  221. message: error
  222. })
  223. }).finally(() => {
  224. this.loading.assign = false;
  225. })
  226. },
  227. unassignSites() {
  228. const params = {
  229. dynamicIdleFeeId: this.item.dynamicIdleFeeId,
  230. //tenantId: this.item.tenantId,
  231. sitePks: this.getSelectIds()
  232. }
  233. this.loading.unassign = true;
  234. api.unassignIdleConfig(params).then(res => {
  235. this.$message({
  236. type: 'success',
  237. message: res.msg || "Success"
  238. })
  239. this.getTableData()
  240. }).catch(error => {
  241. this.$message({
  242. type: 'error',
  243. message: error
  244. })
  245. }).finally(() => {
  246. this.loading.unassign = false;
  247. })
  248. }
  249. }
  250. }
  251. </script>
  252. <style scoped>
  253. >>> .points-assign-dialog {
  254. width: 65vw;
  255. height: 90vh;
  256. display: flex;
  257. max-width: 1200px;
  258. flex-direction: column;
  259. margin-top: 5vh !important;
  260. }
  261. >>> .points-assign-dialog .el-dialog__header {
  262. padding: 20px 20px 0;
  263. font-weight: bold;
  264. }
  265. >>> .points-assign-dialog .el-dialog__body {
  266. flex: 1;
  267. padding: 20px;
  268. display: flex;
  269. overflow: hidden;
  270. flex-direction: column;
  271. }
  272. .assign-table-actions {
  273. display: flex;
  274. padding-top: 5px;
  275. flex-wrap: wrap-reverse;
  276. align-items: center;
  277. justify-content: flex-end;
  278. }
  279. .points-assign-dialog .table-view {
  280. flex: 1;
  281. overflow-y: auto;
  282. padding-top: 10px;
  283. margin-bottom: -10px;
  284. }
  285. @media screen and (max-width: 1200px) {
  286. .points-assign-dialog {
  287. width: 70vw;
  288. }
  289. }
  290. @media screen and (max-width: 1000px) {
  291. .points-assign-dialog {
  292. width: 80vw;
  293. }
  294. }
  295. @media screen and (max-width: 800px) {
  296. .points-assign-dialog {
  297. width: 90vw;
  298. }
  299. }
  300. @media screen and (max-width: 700px) {
  301. .points-assign-dialog {
  302. width: 99vw;
  303. }
  304. }
  305. @media screen and (max-width: 320px) {
  306. .points-assign-dialog {
  307. width: 100%;
  308. min-width: 300px;
  309. }
  310. }
  311. </style>