index.vue 5.5 KB

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