shipList.vue 6.5 KB

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