index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-view">
  5. <el-input
  6. class="filter-input"
  7. v-model="filters.pageVo.criteria"
  8. placeholder="Search by Rate Name"
  9. prefix-icon="el-icon-search"
  10. clearable/>
  11. <div>
  12. <el-button
  13. @click="onClickSearch"
  14. icon="el-icon-search"
  15. type="primary">
  16. Search
  17. </el-button>
  18. </div>
  19. <div
  20. class="filter-flex-button"
  21. v-if="!$route.meta.onlyView">
  22. <el-button
  23. icon="el-icon-plus"
  24. type="primary"
  25. @click="onClickAdd">
  26. Create Rate
  27. </el-button>
  28. </div>
  29. </div>
  30. </div>
  31. <el-table
  32. v-loading="loading"
  33. :data="table.list">
  34. <el-table-column
  35. align="center"
  36. label="Rate ID"
  37. prop="userPk"
  38. min-width="120">
  39. <template slot-scope="{row}" >
  40. <span
  41. class="link-type"
  42. @click="onClickEdit(row)"
  43. v-if="!$route.meta.onlyView">
  44. {{ row.dynamicRateId }}
  45. </span>
  46. <span v-else>{{ row.dynamicRateId }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. align="center"
  51. label="Rate Name"
  52. prop="rateName"
  53. min-width="120"/>
  54. <el-table-column
  55. align="center"
  56. label="No. of Sites Configured"
  57. prop="assignedSiteCount"
  58. min-width="180">
  59. <template v-slot="{ row }">
  60. <span v-if="$route.meta.onlyView">{{ row.assignedSiteCount }}</span>
  61. <div
  62. class="link-type"
  63. @click="assignRates(row)"
  64. v-else>{{row.assignedSiteCount}}</div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. align="center"
  69. label="Status"
  70. prop="dataStatus"
  71. min-width="120"/>
  72. <el-table-column
  73. align="center"
  74. label="Update Time"
  75. prop="updateTime"
  76. min-width="120"/>
  77. <el-table-column
  78. align="center"
  79. label="Action"
  80. min-width="70"
  81. v-if="!$route.meta.onlyView">
  82. <template v-slot="{ row }">
  83. <el-dropdown
  84. class="action-dropdown"
  85. @command="(v) => handleCommand(v, row)"
  86. v-if="row.dataStatus != 'Inactive'">
  87. <i class="el-icon-more icon-action"></i>
  88. <el-dropdown-menu slot="dropdown">
  89. <el-dropdown-item
  90. command="assignRates">
  91. Assign Sites
  92. </el-dropdown-item>
  93. <el-dropdown-item
  94. command="onClickEdit">
  95. Edit
  96. </el-dropdown-item>
  97. <el-dropdown-item
  98. command="onClickDelete">
  99. Delete
  100. </el-dropdown-item>
  101. </el-dropdown-menu>
  102. </el-dropdown>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <div class="right">
  107. <pagination
  108. v-show="table.total > 0"
  109. :total="table.total"
  110. :page.sync="filters.pageNo"
  111. :limit.sync="filters.pageSize"
  112. @pagination="getTableData" />
  113. </div>
  114. <DialogAssignment
  115. :visible="assign.visible"
  116. :title="'ASSIGN SITES (RATE NAME: ' + assign.item.rateName + ')'"
  117. :rate="assign.item"
  118. @hide="assignRates"/>
  119. </div>
  120. </template>
  121. <script>
  122. import TableAction from '@/components/TableAction.vue'
  123. import Pagination from '@/components/Pagination'
  124. import DialogAssignment from '@/components/DialogAssignment'
  125. import api from '@/http/api/rates'
  126. export default {
  127. components: { Pagination, TableAction, DialogAssignment },
  128. data() {
  129. return {
  130. loading: false,
  131. filters: {
  132. pageNo: 1,
  133. pageSize: 10,
  134. pageVo: {
  135. criteria: ""
  136. }
  137. },
  138. table: {
  139. list: [],
  140. total: 0
  141. },
  142. assign: {
  143. item: {},
  144. visible: false
  145. }
  146. }
  147. },
  148. created() {
  149. this.onClickSearch()
  150. },
  151. methods: {
  152. onClickSearch() {
  153. this.filters.pageNo = 1
  154. this.getTableData()
  155. },
  156. getTableData() {
  157. this.loading = true;
  158. api.getRatePages(this.filters).then(res => {
  159. if (res.data && res.total) {
  160. this.table.total = res.total;
  161. this.table.list = res.data;
  162. } else {
  163. this.table.total = 0;
  164. this.table.list = [];
  165. }
  166. }).catch(err => {
  167. this.$message({
  168. type: 'error',
  169. message: err
  170. })
  171. this.table.total = 0;
  172. this.table.list = [];
  173. }).finally(() => {
  174. this.loading = false;
  175. })
  176. },
  177. handleCommand(cb, item) {
  178. this[cb](item)
  179. },
  180. onClickAdd() {
  181. this.$router.push({
  182. path: "/site-management/rate-add"
  183. })
  184. },
  185. onClickEdit(row) {
  186. this.$router.push({
  187. path: "/site-management/rate-update/" + row.dynamicRateId
  188. })
  189. },
  190. onClickDelete(row) {
  191. this.$confirm('Are you sure you want to delete this rate?', 'Delete', {
  192. confirmButtonText: 'OK',
  193. cancelButtonText: 'Cancel',
  194. type: 'warning'
  195. }).then(res => {
  196. this.deleteDynamicRate(row.dynamicRateId);
  197. })
  198. },
  199. assignRates(row) {
  200. if (row) {
  201. this.assign.item = row;
  202. this.assign.visible = true;
  203. } else {
  204. this.assign.item = {};
  205. this.assign.visible = false;
  206. this.getTableData();
  207. }
  208. },
  209. deleteDynamicRate(id) {
  210. this.loading = true;
  211. api.deleteDynamicRate({
  212. dynamicRateId: id
  213. }).then(res => {
  214. this.$message({
  215. type: 'success',
  216. message: "Delete success."
  217. })
  218. this.getTableData()
  219. }).catch(err => {
  220. this.$message({
  221. type: 'error',
  222. message: err
  223. })
  224. this.loading = false;
  225. })
  226. }
  227. }
  228. }
  229. </script>
  230. <style>
  231. .filter-input {
  232. min-width: 100px;
  233. max-width: 300px;
  234. }
  235. </style>