certsManage.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="full-container-p24">
  3. <div class="mb20" style="margin-left: 200px">
  4. <el-button-group class="mr30">
  5. <el-button
  6. :type="type == 2 ? 'primary' : ''"
  7. @click="(currentPage = 1), (type = 2), getCertList()"
  8. >
  9. {{ nextMonthStr }}
  10. </el-button>
  11. <el-button
  12. :type="type == 8 ? 'primary' : ''"
  13. @click="(currentPage = 1), (type = 8), getCertList()"
  14. >
  15. {{ nextNextMonthStr }}
  16. </el-button>
  17. <el-button
  18. :type="type == 9 ? 'primary' : ''"
  19. @click="(currentPage = 1), (type = 9), getCertList()"
  20. >
  21. {{ nextNextNextMonthStr }}
  22. </el-button>
  23. <el-button
  24. :type="type == 0 ? 'primary' : ''"
  25. @click="(currentPage = 1), (type = 0), getCertList()"
  26. >
  27. 已过期
  28. </el-button>
  29. <el-button
  30. :type="type == 3 ? 'primary' : ''"
  31. @click="(currentPage = 1), (type = 3), getCertList()"
  32. >
  33. 全部
  34. </el-button>
  35. </el-button-group>
  36. </div>
  37. <div class="df">
  38. <div class="btns mr20 mt50">
  39. <div v-for="(item, index) in certTypes" :key="item.id">
  40. <el-button
  41. :type="certType == item.type ? 'primary' : ''"
  42. @click="
  43. (currentPage = 1),
  44. (certType = item.type),
  45. (currentTypeIndex = index),
  46. (validType = 1);
  47. getCertList();
  48. "
  49. class="btn"
  50. >
  51. {{ item.typeName }}
  52. </el-button>
  53. </div>
  54. </div>
  55. <div>
  56. <el-select
  57. style="width: 240px"
  58. v-if="currentTypeIndex == 1"
  59. v-model="validType"
  60. @change="changeSelect"
  61. class="mb10 tac"
  62. placeholder="有效期类型"
  63. >
  64. <el-option
  65. v-for="item in certTypes[currentTypeIndex].validTypes"
  66. :key="item.type"
  67. :label="item.typeName"
  68. :value="item.type"
  69. />
  70. </el-select>
  71. <el-table border :data="tableData" stripe style="width: 900px">
  72. <el-table-column
  73. align="center"
  74. type="index"
  75. label="序号"
  76. width="80"
  77. />
  78. <el-table-column
  79. align="center"
  80. prop="shipname"
  81. label="船名"
  82. min-width="120"
  83. />
  84. <el-table-column
  85. align="center"
  86. prop="shipRegistryProvince"
  87. label="船籍"
  88. min-width="80"
  89. />
  90. <el-table-column
  91. v-if="certType == 6"
  92. align="center"
  93. prop="crewName"
  94. label="船员姓名"
  95. min-width="120"
  96. />
  97. <el-table-column
  98. v-if="certType != 6"
  99. align="center"
  100. prop="shipOwnerName"
  101. label="船员姓名"
  102. min-width="120"
  103. />
  104. <el-table-column
  105. v-if="certType != 6"
  106. align="center"
  107. prop="shipOwnerPhone"
  108. label="手机号"
  109. min-width="140"
  110. />
  111. <el-table-column
  112. align="center"
  113. prop="endValidTime"
  114. label="有效期"
  115. min-width="120"
  116. >
  117. <template v-slot="scope">
  118. {{ subTimeStr(scope.row.endValidTime) }}
  119. </template>
  120. </el-table-column>
  121. <el-table-column align="center" label="详情" min-width="120">
  122. <template #default="scope">
  123. <el-button
  124. v-if="certType == 6"
  125. type="primary"
  126. text
  127. @click="goToShipOwnerDetail(scope.row.id)"
  128. >
  129. 详情
  130. </el-button>
  131. <el-button
  132. v-else
  133. type="primary"
  134. text
  135. @click="goToShipDetail(scope.row.shipCode)"
  136. >
  137. 详情
  138. </el-button>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <div class="df aic jcfe mt40 mr20">
  143. <el-pagination
  144. :current-page="currentPage"
  145. @current-change="pageChange"
  146. background
  147. layout="prev, pager, next"
  148. :total="total"
  149. />
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </template>
  155. <script setup>
  156. import { ref, h, reactive, toRefs, onMounted } from "vue";
  157. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  158. import store from "../../store";
  159. import router from "../../router";
  160. import md5 from "md5";
  161. import api from "../../apis/fetch";
  162. import { useRoute } from "vue-router";
  163. import _ from "lodash";
  164. import { subTimeStr } from "../../utils/utils";
  165. const route = useRoute();
  166. let type = ref(2);
  167. let certType = ref(1);
  168. let tableData = ref([]);
  169. let total = ref(0);
  170. let currentPage = ref(1);
  171. const monthNames = [
  172. "一月",
  173. "二月",
  174. "三月",
  175. "四月",
  176. "五月",
  177. "六月",
  178. "七月",
  179. "八月",
  180. "九月",
  181. "十月",
  182. "十一月",
  183. "十二月",
  184. ];
  185. function getMonthName(monthOffset) {
  186. const currentMonth = new Date().getMonth();
  187. const newMonth = (currentMonth + monthOffset) % 12;
  188. return monthNames[newMonth] + "到期";
  189. }
  190. const nextMonthStr = ref(getMonthName(1));
  191. const nextNextMonthStr = ref(getMonthName(2));
  192. const nextNextNextMonthStr = ref(getMonthName(3));
  193. async function getCertList() {
  194. let { data } = await api.getCertList({
  195. type: type.value,
  196. certType: certType.value,
  197. validType: validType.value,
  198. currentPage: currentPage.value,
  199. size: 10,
  200. });
  201. if (data.status == 0) {
  202. total.value = data.total;
  203. tableData.value = data.result;
  204. } else {
  205. total.value = 0;
  206. tableData.value = [];
  207. }
  208. }
  209. function pageChange(e) {
  210. currentPage.value = e;
  211. getCertList();
  212. }
  213. function goToShipDetail(shipCode) {
  214. router.push({
  215. path: "/shipManage/shipDetail",
  216. query: {
  217. shipCode,
  218. },
  219. });
  220. }
  221. function goToShipOwnerDetail(shipOwnerId) {
  222. router.push({
  223. path: "/shipOwnerManage/shipOwnerDetail",
  224. query: {
  225. shipOwnerId,
  226. },
  227. });
  228. }
  229. let certTypes = ref([
  230. {
  231. validTypes: [],
  232. },
  233. ]);
  234. async function getCertListType() {
  235. let { data } = await api.getCertListType({});
  236. certTypes.value = data.result.filter((item) => {
  237. return item.typeName != "船舶保险";
  238. });
  239. }
  240. let currentTypeIndex = ref(0);
  241. let validType = ref(1);
  242. function changeSelect(e) {
  243. validType.value = e;
  244. getCertList();
  245. }
  246. onMounted(() => {
  247. getCertList();
  248. getCertListType();
  249. });
  250. </script>
  251. <style scoped>
  252. .btn {
  253. height: 50px;
  254. width: 180px;
  255. border-radius: 0;
  256. }
  257. </style>