index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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="120"/>
  59. <el-table-column
  60. align="center"
  61. label="Status"
  62. prop="dataStatus"
  63. min-width="120"/>
  64. <el-table-column
  65. align="center"
  66. label="Update Time"
  67. prop="updateTime"
  68. min-width="120"/>
  69. <el-table-column
  70. align="center"
  71. label="Action"
  72. min-width="70"
  73. v-if="!$route.meta.onlyView">
  74. <template v-slot="{ row }">
  75. <el-dropdown
  76. class="action-dropdown"
  77. @command="(v) => handleCommand(v, row)"
  78. v-if="row.dataStatus != 'Inactive'">
  79. <i class="el-icon-more icon-action"></i>
  80. <el-dropdown-menu slot="dropdown">
  81. <el-dropdown-item
  82. command="assignRates">
  83. Assign Sites
  84. </el-dropdown-item>
  85. <el-dropdown-item
  86. command="onClickEdit">
  87. Edit
  88. </el-dropdown-item>
  89. <el-dropdown-item
  90. command="onClickDelete">
  91. Delete
  92. </el-dropdown-item>
  93. </el-dropdown-menu>
  94. </el-dropdown>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <div class="right">
  99. <pagination
  100. v-show="table.total > 0"
  101. :total="table.total"
  102. :page.sync="filters.pageNo"
  103. :limit.sync="filters.pageSize"
  104. @pagination="getTableData" />
  105. </div>
  106. <DialogAssignment
  107. :visible="assign.visible"
  108. :title="'ASSIGN SITES (RATE NAME: ' + assign.item.rateName + ')'"
  109. :rate="assign.item"
  110. @hide="assignRates"/>
  111. </div>
  112. </template>
  113. <script>
  114. import TableAction from '@/components/TableAction.vue'
  115. import Pagination from '@/components/Pagination'
  116. import DialogAssignment from '@/components/DialogAssignment'
  117. import api from '@/http/api/rates'
  118. export default {
  119. components: { Pagination, TableAction, DialogAssignment },
  120. data() {
  121. return {
  122. loading: false,
  123. filters: {
  124. pageNo: 1,
  125. pageSize: 10,
  126. pageVo: {
  127. criteria: ""
  128. }
  129. },
  130. table: {
  131. list: [],
  132. total: 0
  133. },
  134. assign: {
  135. item: {},
  136. visible: false
  137. }
  138. }
  139. },
  140. created() {
  141. this.onClickSearch()
  142. },
  143. methods: {
  144. onClickSearch() {
  145. this.filters.pageNo = 1
  146. this.getTableData()
  147. },
  148. getTableData() {
  149. this.loading = true;
  150. api.getRatePages(this.filters).then(res => {
  151. if (res.data && res.total) {
  152. this.table.total = res.total;
  153. this.table.list = res.data;
  154. }
  155. }).catch(err => {
  156. this.$message({
  157. type: 'error',
  158. message: err
  159. })
  160. this.table.total = 0;
  161. this.table.list = [];
  162. }).finally(() => {
  163. this.loading = false;
  164. })
  165. },
  166. handleCommand(cb, item) {
  167. this[cb](item)
  168. },
  169. onClickAdd() {
  170. this.$router.push({
  171. path: "/site-management/rate-add"
  172. })
  173. },
  174. onClickEdit(row) {
  175. this.$router.push({
  176. path: "/site-management/rate-update/" + row.dynamicRateId
  177. })
  178. },
  179. onClickDelete(row) {
  180. this.$confirm('Are you sure you want to delete this rate?', 'Delete', {
  181. confirmButtonText: 'OK',
  182. cancelButtonText: 'Cancel',
  183. type: 'warning'
  184. }).then(res => {
  185. this.deleteDynamicRate(row.dynamicRateId);
  186. })
  187. },
  188. assignRates(row) {
  189. if (row) {
  190. this.assign.item = row;
  191. this.assign.visible = true;
  192. } else {
  193. this.assign.item = {};
  194. this.assign.visible = false;
  195. this.getTableData();
  196. }
  197. },
  198. deleteDynamicRate(id) {
  199. this.loading = true;
  200. api.deleteDynamicRate({
  201. dynamicRateId: id
  202. }).then(res => {
  203. this.$message({
  204. type: 'success',
  205. message: "Delete success."
  206. })
  207. this.getTableData()
  208. }).catch(err => {
  209. this.$message({
  210. type: 'error',
  211. message: err
  212. })
  213. this.loading = false;
  214. })
  215. }
  216. }
  217. }
  218. </script>
  219. <style>
  220. .filter-input {
  221. min-width: 100px;
  222. max-width: 300px;
  223. }
  224. </style>