shipList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="full-container-p24">
  3. <div style="display: flex; justify-content: space-between">
  4. <div style="display: flex">
  5. <el-input
  6. placeholder="请输入船名/MMSI/手机号"
  7. prefix-icon="el-icon-search"
  8. v-model="term"
  9. clearable
  10. style="height: 32px; width: 330px; line-height: 32px"
  11. ></el-input>
  12. <div class="seach-btn" @click="getShipList(1)">查询</div>
  13. </div>
  14. </div>
  15. <div style="margin-top: 24px">
  16. <el-table :data="tableData" stripe style="width: 100%">
  17. <el-table-column
  18. type="index"
  19. label="序号"
  20. min-width="80"
  21. align="center"
  22. ></el-table-column>
  23. <el-table-column
  24. prop="shipname"
  25. label="船舶名称"
  26. min-width="100"
  27. align="center"
  28. ></el-table-column>
  29. <el-table-column
  30. prop="mmsi"
  31. label="MMSI"
  32. min-width="100"
  33. align="center"
  34. ></el-table-column>
  35. <el-table-column
  36. prop="length"
  37. label="船长(米)"
  38. min-width="100"
  39. align="center"
  40. ></el-table-column>
  41. <el-table-column
  42. prop="breadth"
  43. label="船宽(米)"
  44. min-width="100"
  45. align="center"
  46. ></el-table-column>
  47. <el-table-column
  48. prop="draught"
  49. label="吃水(米)"
  50. min-width="100"
  51. align="center"
  52. ></el-table-column>
  53. <el-table-column
  54. prop="loadTons"
  55. label="载货吨位(吨)"
  56. min-width="100"
  57. align="center"
  58. ></el-table-column>
  59. <el-table-column
  60. prop="createTime"
  61. label="创建时间"
  62. min-width="200"
  63. align="center"
  64. ></el-table-column>
  65. <el-table-column label="操作" min-width="140" align="center">
  66. <template v-slot="scope">
  67. <el-button
  68. @click="deleteShip(scope.row.code)"
  69. type="primary"
  70. text
  71. size="small"
  72. >
  73. 删除
  74. </el-button>
  75. <el-button
  76. @click="shipDetail(scope.row.code)"
  77. type="primary"
  78. text
  79. size="small"
  80. >
  81. 查看详情
  82. </el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <div class="df aic jcfe mt40 mr20">
  87. <el-pagination
  88. background
  89. layout="prev, pager, next"
  90. :current-page="currentPage"
  91. :total="total"
  92. @current-change="pageChange"
  93. ></el-pagination>
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script setup>
  99. import { ref, h, reactive, toRefs, onMounted } from "vue";
  100. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  101. import store from "../../store";
  102. import router from "../../router";
  103. import md5 from "md5";
  104. import api from "../../apis/fetch";
  105. let currentPage = ref(1);
  106. let term = ref("");
  107. let tableData = ref([]);
  108. let total = ref(0);
  109. async function getShipList(page) {
  110. currentPage.value = page || currentPage.value;
  111. let res = await api.getShipList({
  112. currentPage: currentPage.value,
  113. size: 10,
  114. term: term.value,
  115. });
  116. if (res.data.status == 0) {
  117. tableData.value = res.data.result;
  118. total.value = res.data.total;
  119. } else {
  120. tableData.value = [];
  121. total.value = 0;
  122. }
  123. }
  124. async function shipDetail(shipCode) {
  125. router.push({
  126. path: "/shipManage/shipDetail",
  127. query: {
  128. shipCode,
  129. },
  130. });
  131. }
  132. function pageChange(e) {
  133. currentPage.value = e;
  134. getShipList();
  135. }
  136. function deleteShip(shipCode) {
  137. ElMessageBox.confirm("确认删除船舶?", "提示", {
  138. confirmButtonText: "确认",
  139. cancelButtonText: "取消",
  140. type: "warning",
  141. })
  142. .then(async () => {
  143. let { data } = await api.deleteShip({
  144. shipCode,
  145. });
  146. if (data.status == 0) {
  147. ElMessage({
  148. type: "success",
  149. message: "删除成功",
  150. });
  151. getShipList();
  152. }
  153. })
  154. .catch(() => {});
  155. }
  156. onMounted(() => {
  157. getShipList();
  158. });
  159. </script>
  160. <style scoped>
  161. .seach-btn {
  162. display: inline-block;
  163. width: 60px;
  164. height: 38px;
  165. background: #0094fe;
  166. border-radius: 2px;
  167. font-size: 14px;
  168. font-family: PingFangSC-Regular, PingFang SC;
  169. font-weight: 400;
  170. color: #ffffff;
  171. text-align: center;
  172. line-height: 38px;
  173. margin-left: 10px;
  174. cursor: pointer;
  175. }
  176. .cargo-owner-add {
  177. width: 80px;
  178. height: 32px;
  179. border-radius: 2px;
  180. border: 1px solid #0094fe;
  181. font-size: 14px;
  182. font-family: PingFangSC-Regular, PingFang SC;
  183. font-weight: 400;
  184. color: #0094fe;
  185. line-height: 32px;
  186. text-align: center;
  187. cursor: pointer;
  188. }
  189. :deep().el-dialog {
  190. width: 560px;
  191. padding: 20px 50px;
  192. border-radius: 6px;
  193. }
  194. :deep() .el-dialog__title {
  195. font-size: 18px;
  196. font-family: PingFangSC-Regular, PingFang SC;
  197. font-weight: 400;
  198. color: #0094fe;
  199. }
  200. </style>