shipOwnerList.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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="请输入船员/手机号"
  7. prefix-icon="el-icon-search"
  8. v-model="term"
  9. clearable
  10. class="mr30"
  11. style="width: 300px"
  12. ></el-input>
  13. <el-button type="primary" @click="getShipOwnerList(1)">查询</el-button>
  14. </div>
  15. <el-button
  16. type="primary"
  17. @click="router.push('/shipOwnerManage/shipOwnerDetail')"
  18. >
  19. 添加船员
  20. </el-button>
  21. <el-dialog title="添加船员" v-model="dialogFormVisible">
  22. <template v-slot:default>
  23. <el-form
  24. :model="ruleForm"
  25. :rules="rules"
  26. ref="form"
  27. label-width="110px"
  28. label-position="left"
  29. >
  30. <el-form-item prop="userName" label="船员姓名">
  31. <el-input
  32. style="width: 280px"
  33. v-model="ruleForm.userName"
  34. ></el-input>
  35. </el-form-item>
  36. <el-form-item prop="phone" label="手机号">
  37. <el-input
  38. style="width: 280px"
  39. v-model="ruleForm.phone"
  40. ></el-input>
  41. </el-form-item>
  42. <el-form-item prop="shipname" label="船名">
  43. <el-input
  44. style="width: 280px"
  45. v-model="ruleForm.shipname"
  46. ></el-input>
  47. </el-form-item>
  48. <el-form-item prop="mmsi" label="MMSI">
  49. <el-input style="width: 280px" v-model="ruleForm.mmsi"></el-input>
  50. </el-form-item>
  51. </el-form>
  52. </template>
  53. <template v-slot:footer>
  54. <div class="dialog-footer">
  55. <el-button @click="resetForm">取 消</el-button>
  56. <el-button type="primary" @click="addShipOwner(ruleForm)">
  57. 确 定
  58. </el-button>
  59. </div>
  60. </template>
  61. </el-dialog>
  62. </div>
  63. <div style="margin-top: 24px">
  64. <el-table border :data="tableData" stripe style="width: 100%">
  65. <el-table-column
  66. type="index"
  67. label="序号"
  68. width="80"
  69. align="center"
  70. ></el-table-column>
  71. <el-table-column
  72. prop="userName"
  73. label="船员名称"
  74. min-width="120"
  75. align="center"
  76. ></el-table-column>
  77. <el-table-column
  78. prop="phone"
  79. label="手机号"
  80. min-width="120"
  81. align="center"
  82. ></el-table-column>
  83. <el-table-column
  84. prop="createTime"
  85. label="创建时间"
  86. min-width="120"
  87. align="center"
  88. >
  89. <template v-slot="scope">
  90. {{ subTimeStr(scope.row.createTime) }}
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="操作" min-width="80" align="center">
  94. <template v-slot="scope">
  95. <el-button
  96. @click="shipOwnerDetail(scope.row.id)"
  97. type="primary"
  98. text
  99. size="small"
  100. >
  101. 查看详情
  102. </el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <div class="df aic jcfe mt40 mr20">
  107. <el-pagination
  108. background
  109. layout="prev, pager, next"
  110. :current-page="currentPage"
  111. :total="total"
  112. @current-change="pageChange"
  113. ></el-pagination>
  114. </div>
  115. </div>
  116. </div>
  117. </template>
  118. <script setup>
  119. import { ref, h, reactive, toRefs, onMounted } from "vue";
  120. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  121. import store from "../../store";
  122. import router from "../../router";
  123. import md5 from "md5";
  124. import api from "../../apis/fetch";
  125. import { subTimeStr } from "../../utils/utils";
  126. let dialogFormVisible = ref(false);
  127. let form = ref(null);
  128. let ruleForm = ref({
  129. userName: "",
  130. phone: "",
  131. shipname: "",
  132. mmsi: "",
  133. });
  134. async function resetForm() {
  135. dialogFormVisible.value = false;
  136. form.value.resetFields();
  137. }
  138. const rules = ref({
  139. userName: [{ required: true, message: "请填写船员名称", trigger: "blur" }],
  140. shipname: [{ required: true, message: "请填写船名", trigger: "blur" }],
  141. mmsi: [{ required: true, message: "请填写MMSI", trigger: "blur" }],
  142. phone: [
  143. { required: true, message: "请填写手机号", trigger: "blur" },
  144. { min: 11, max: 11, message: "请正确填写手机号", trigger: "blur" },
  145. ],
  146. });
  147. async function addShipOwner() {
  148. form.value.validate(async (valid) => {
  149. if (valid) {
  150. let { userName, shipname, mmsi, phone } = ruleForm.value;
  151. let res = await api.addShipOwner({
  152. userName,
  153. shipname,
  154. mmsi,
  155. phone,
  156. });
  157. console.log(res);
  158. if (res.data.status == 0) {
  159. ElNotification.success({
  160. title: "添加成功",
  161. duration: 0,
  162. message: `${userName}:${res.data.msg}`,
  163. type: "success",
  164. });
  165. resetForm();
  166. getShipOwnerList();
  167. } else {
  168. ElNotification.error({
  169. title: "失败",
  170. duration: 3000,
  171. message: res.data.msg,
  172. });
  173. }
  174. } else {
  175. return false;
  176. }
  177. });
  178. }
  179. let currentPage = ref(1);
  180. let term = ref("");
  181. let tableData = ref([]);
  182. let total = ref(0);
  183. async function getShipOwnerList(page) {
  184. currentPage.value = page || currentPage.value;
  185. let res = await api.getShipOwnerList({
  186. currentPage: currentPage.value,
  187. size: 10,
  188. term: term.value,
  189. });
  190. if (res.data.status == 0) {
  191. tableData.value = res.data.result;
  192. total.value = res.data.total;
  193. } else {
  194. tableData.value = [];
  195. total.value = 0;
  196. }
  197. }
  198. async function shipOwnerDetail(shipOwnerId) {
  199. store.commit("addAlive", "shipOwnerList");
  200. router.push({
  201. path: "/shipOwnerManage/shipOwnerDetail",
  202. query: {
  203. shipOwnerId,
  204. },
  205. });
  206. }
  207. function pageChange(e) {
  208. currentPage.value = e;
  209. getShipOwnerList();
  210. }
  211. onMounted(() => {
  212. getShipOwnerList();
  213. });
  214. </script>
  215. <style scoped>
  216. .seach-btn {
  217. display: inline-block;
  218. width: 60px;
  219. height: 38px;
  220. background: #0094fe;
  221. border-radius: 2px;
  222. font-size: 14px;
  223. font-family: PingFangSC-Regular, PingFang SC;
  224. font-weight: 400;
  225. color: #ffffff;
  226. text-align: center;
  227. line-height: 38px;
  228. margin-left: 10px;
  229. cursor: pointer;
  230. }
  231. .cargo-owner-add {
  232. width: 80px;
  233. height: 32px;
  234. border-radius: 2px;
  235. border: 1px solid #0094fe;
  236. font-size: 14px;
  237. font-family: PingFangSC-Regular, PingFang SC;
  238. font-weight: 400;
  239. color: #0094fe;
  240. line-height: 32px;
  241. text-align: center;
  242. cursor: pointer;
  243. }
  244. :deep().el-dialog {
  245. width: 560px;
  246. padding: 20px 50px;
  247. border-radius: 6px;
  248. }
  249. :deep() .el-dialog__title {
  250. font-size: 18px;
  251. font-family: PingFangSC-Regular, PingFang SC;
  252. font-weight: 400;
  253. color: #0094fe;
  254. }
  255. </style>