ThreeCode.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div>
  3. <div class="communal-list">
  4. <div class="communal-title">
  5. <div>机场三字码资料</div>
  6. <div class="communal-box">
  7. <el-input @input="Inquireclick()" placeholder="三字码/城市/机场" v-model="input" clearable
  8. style="width: 350px;">
  9. </el-input>
  10. <router-link to="/home/ThreeCodeOperation">
  11. <el-button type="primary" style="margin-left: 10px;">新增</el-button>
  12. </router-link>
  13. </div>
  14. </div>
  15. <template>
  16. <el-table :data="tableDatas.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border
  17. style="width: 100%" v-loading="loading" element-loading-text="拼命加载中...">
  18. <el-table-column prop="num" label="序 号" width="55">
  19. <template slot-scope="scope">
  20. {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
  21. </template>
  22. </el-table-column>
  23. <el-table-column prop="three" label="三字码" width="80">
  24. </el-table-column>
  25. <el-table-column prop="four" label="四字码" width="90">
  26. </el-table-column>
  27. <el-table-column prop="country" label="国家" width="150">
  28. </el-table-column>
  29. <el-table-column prop="city" label="城市" width="180">
  30. </el-table-column>
  31. <el-table-column prop="airPort" label="机场" width="200">
  32. </el-table-column>
  33. <el-table-column prop="airPort_En" label="机场英文" width="300">
  34. </el-table-column>
  35. <el-table-column label="操作">
  36. <template slot-scope="scope">
  37. <el-button size="mini" @click="upDate(scope.$index, scope.row)">编辑</el-button>
  38. <el-button size="mini" type="danger" @click="del(scope.$index, scope.row)">删除</el-button>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. </template>
  43. <div class="block">
  44. <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
  45. :current-page="currentPage" :page-sizes="[10, 12, 15, 20]" :page-size="pageSize"
  46. layout="total, sizes, prev, pager, next" :total="tableDatas.length">
  47. </el-pagination>
  48. </div>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. loading: false,
  57. tableDatas: [],
  58. tableData: [],
  59. currentPage: 1, // 当前页码
  60. pageSize: 12,// 每页的数据条数
  61. input: '',
  62. token: '',
  63. userId: 0
  64. }
  65. },
  66. methods: {
  67. //每页条数改变时触发 选择一页显示多少行
  68. handleSizeChange(val) {
  69. this.currentPage = 1;
  70. this.pageSize = val;
  71. },
  72. //当前页改变时触发 跳转其他页
  73. handleCurrentChange(val) {
  74. this.currentPage = val;
  75. },
  76. ThreeCode() {
  77. this.loading = true
  78. var url = "/api/Resource/QuerThreeCode"
  79. var that = this
  80. this.$axios({
  81. method: 'post',
  82. url: url,
  83. headers: {
  84. Authorization: 'Bearer ' + this.token
  85. },
  86. data: {
  87. portType: 1,
  88. }
  89. }).then(function (res) {
  90. console.log(res)
  91. debugger
  92. if (res.data.code == 200) {
  93. debugger
  94. that.tableData = res.data.data;
  95. that.tableDatas = that.tableData;
  96. }
  97. that.loading = false
  98. }).catch(function (error) {
  99. that.loading = false
  100. that.$message.error("网络错误,请稍后重试");
  101. });
  102. },
  103. //搜索框处理
  104. Inquireclick() {
  105. var newarr = [];
  106. if (this.input == "") {
  107. newarr = this.tableData;
  108. } else {
  109. for (var i = 0; i < this.tableData.length; i++) {
  110. if (this.tableData[i].airPort.indexOf(this.input) != -1) {
  111. newarr.push(this.tableData[i]);
  112. } else if (this.tableData[i].three.indexOf(this.input) != -1) {
  113. newarr.push(this.tableData[i]);
  114. } else if (this.tableData[i].city.indexOf(this.input) != -1) {
  115. newarr.push(this.tableData[i]);
  116. }
  117. }
  118. }
  119. this.tableDatas = newarr;
  120. },
  121. upDate(index, row) {
  122. this.$router.push({
  123. path: "/home/ThreeCodeOperation",
  124. query: { id: row.id }
  125. })
  126. },
  127. del(index, row) {
  128. var url = "/api/Resource/DelThreeCode"
  129. var that = this
  130. this.$axios({
  131. method: 'post',
  132. url: url,
  133. headers: {
  134. Authorization: 'Bearer ' + this.token
  135. },
  136. data: {
  137. Id: row.id,
  138. DeleteUserId: this.userId
  139. }
  140. }).then(function (res) {
  141. console.log(res)
  142. debugger
  143. if (res.data.code == 200) {
  144. debugger
  145. that.$message({
  146. message: '删除成功',
  147. type: 'success'
  148. });
  149. that.ThreeCode();
  150. } else {
  151. that.$message.error('删除失败!');
  152. }
  153. that.loading = false
  154. }).catch(function (error) {
  155. that.loading = false
  156. that.$message.error("网络错误,请稍后重试");
  157. });
  158. }
  159. },
  160. mounted() {
  161. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  162. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  163. this.ThreeCode();
  164. }
  165. }
  166. </script>
  167. <style>
  168. .communal-list {
  169. background-color: #fff;
  170. padding: 10px;
  171. box-shadow: 0 0 5px #0005;
  172. border-radius: 10px;
  173. }
  174. .communal-title {
  175. display: flex;
  176. font-size: 17px;
  177. font-weight: 600;
  178. color: #555;
  179. margin-top: 8px;
  180. margin-bottom: 10px;
  181. justify-content: space-between;
  182. align-items: center;
  183. }
  184. .communal-box {
  185. display: flex;
  186. }
  187. .communal-box>button {
  188. margin-left: 10px;
  189. padding: 8px 20px;
  190. }
  191. </style>