ip_white_list.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="body-wrapper">
  3. <el-form class="form-wrapper" :inline="true" :model="formInline">
  4. <el-row>
  5. <el-col :span="8">
  6. <el-form-item label="IP地址">
  7. <el-input v-model="formInline.ipUrl" placeholder="请输入"></el-input>
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="8">
  11. <el-form-item>
  12. <el-button type="primary" class="query-btn" @click="onSubmit">查询</el-button>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="success" @click="handleAdd">添加白名单</el-button>
  16. </el-form-item>
  17. </el-col>
  18. </el-row>
  19. </el-form>
  20. <el-table :data="tableData" style="background: #2a2a2a;border-color: #333;">
  21. <el-table-column
  22. label="序号"
  23. type="index"
  24. :index="indexMethod">
  25. </el-table-column>
  26. <el-table-column v-for="(item, index) in columns" :key="index" :label="item.label" :prop="item.key">
  27. </el-table-column>
  28. <el-table-column
  29. label="操作"
  30. width="200">
  31. <template slot-scope="scope" style="display: inline-block">
  32. <el-button type="primary" @click="handleAudit(scope.row)" slot="reference">修改</el-button>
  33. <el-popconfirm title="确定删除吗?" @confirm="deleteRow(scope.row)">
  34. <el-button type="danger" slot="reference">删除</el-button>
  35. </el-popconfirm>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <div class="table-pagination">
  40. <el-pagination :background="false" layout="total, prev, pager, next" :total="total" @current-change="handlePageChange"
  41. :current-page.sync="pageNum" :page-size.sync="pageSize">
  42. </el-pagination>
  43. </div>
  44. <el-dialog
  45. :title="title"
  46. :visible.sync="dialogVisible"
  47. width="60%"
  48. custom-class="audit-dialog">
  49. <el-form label-position="left" label-width="80px" :model="formLabelAlign">
  50. <el-form-item label="IP地址">
  51. <el-input v-model="formLabelAlign.ipUrl"></el-input>
  52. </el-form-item>
  53. </el-form>
  54. <span slot="footer" class="dialog-footer">
  55. <el-button @click="dialogVisible = false">取 消</el-button>
  56. <el-button type="primary" @click="handleConfirm">确 定</el-button>
  57. </span>
  58. </el-dialog>
  59. </div>
  60. </template>
  61. <script>
  62. import api from "@/api/audit.js";
  63. export default {
  64. components: {},
  65. data() {
  66. return {
  67. columns: [
  68. {
  69. label: 'IP地址',
  70. key: 'resourceName'
  71. },
  72. {
  73. label: '最后操作时间',
  74. key: 'resourceType'
  75. }
  76. ],
  77. tableData: [],
  78. total: 0,
  79. pageSize: 10,
  80. pageNum: 1,
  81. radio: '2',
  82. dialogVisible: false,
  83. formInline: {
  84. ipUrl: ''
  85. },
  86. formLabelAlign: {
  87. ipUrl: ''
  88. },
  89. selRow: undefined,
  90. title: ''
  91. }
  92. },
  93. mounted() {
  94. this.getTableData()
  95. },
  96. watch: {
  97. },
  98. methods: {
  99. handleAudit(row) {
  100. this.title = '修改白名单'
  101. this.formLabelAlign.ipUrl = row.resourceName
  102. this.dialogVisible = true
  103. },
  104. indexMethod(index) {
  105. return this.pageSize * (this.pageNum - 1) + index + 1
  106. },
  107. handleAdd () {
  108. this.title = '添加白名单'
  109. this.formLabelAlign.ipUrl = ''
  110. this.dialogVisible = true
  111. },
  112. onSubmit () {
  113. this.getTableData()
  114. },
  115. deleteRow (record) {
  116. console.log(record)
  117. },
  118. handlePageChange() {
  119. this.getTableData()
  120. },
  121. handleConfirm() {
  122. api.applyResource({idUrl: this.ipUrl}).then(res => {
  123. if(res.success) {
  124. this.dialogVisible = false
  125. this.$message({
  126. message: '添加成功!',
  127. type: 'success'
  128. })
  129. this.getTableData()
  130. }
  131. })
  132. },
  133. getTableData() {
  134. const {pageNum, pageSize} = this
  135. api.applyList({pageNum, pageSize, ipUrl: this.formInline.ipUrl}).then(res => {
  136. this.tableData = []
  137. res.data.records.map((item, index) => {
  138. const newItem = {...item}
  139. newItem.applyTypeText = this.getApplyTypeText(item.applyType)
  140. this.tableData.push(newItem)
  141. })
  142. this.total = res.data.total
  143. })
  144. },
  145. getApplyTypeText(val) {
  146. if (!val){
  147. return '未申请'
  148. }
  149. const textMap = {
  150. 1: '待审批',
  151. 2: '审批通过',
  152. 3: '审批驳回'
  153. }
  154. return textMap[val]
  155. },
  156. handleSearch() {
  157. this.pageNum = 1
  158. this.getTableData()
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss" scoped>
  164. .form-wrapper {
  165. margin-bottom: 20px;
  166. }
  167. /deep/ .el-input__inner {
  168. background: #2d3744;
  169. border: none;
  170. border-radius: 0;
  171. }
  172. /deep/ .el-select {
  173. height: 40px;
  174. .el-input__inner {
  175. height: 40px;
  176. }
  177. .el-input__prefix, .el-input__suffix {
  178. height: 40px;
  179. }
  180. /* 下面设置右侧按钮居中 */
  181. .el-input__suffix {
  182. top: 0px;
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. flex-wrap: nowrap;
  187. flex-direction: row;
  188. align-content: flex-start;
  189. }
  190. /* 输入框加上上下边是 32px + 2px =34px */
  191. .el-input__icon {
  192. line-height: 0px;
  193. }
  194. }
  195. /deep/ .form-wrapper .el-button {
  196. background: linear-gradient(90deg,#0158d9,#3c97e4);
  197. width: 100px;
  198. height: 40px;
  199. }
  200. .body-wrapper {
  201. padding: 20px;
  202. background: #0c0c0c;
  203. .button-block{
  204. text-align: right;
  205. margin-bottom: 20px;
  206. }
  207. .table-pagination{
  208. text-align: right;
  209. }
  210. .search-card{
  211. margin-bottom: 20px;
  212. text-align: center;
  213. .input-wrapper{
  214. width: 36%;
  215. }
  216. }
  217. }
  218. .audit-dialog{
  219. .mg-bt{
  220. margin-bottom: 24px;
  221. }
  222. .label{
  223. text-align: right;
  224. }
  225. /deep/ .el-input__inner{
  226. background: white;
  227. }
  228. }
  229. </style>