shipOwnerDetail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="line-container-p24">
  3. <i class="el-icon-arrow-left"></i>
  4. <div
  5. class="dib go-back ml8 pointer"
  6. @click="router.replace('/shipOwnerManage/shipOwnerList')"
  7. >
  8. 返回船东列表
  9. </div>
  10. </div>
  11. <div class="container-title">船东信息</div>
  12. <div class="line-container-p24">
  13. <div class="line">
  14. <div class="info-line">
  15. <div class="info-line-title">船东姓名</div>
  16. <el-input
  17. class="info-line-text"
  18. v-model="shipOwnerDetail.userName"
  19. :disabled="unchangeableShipOwner"
  20. ></el-input>
  21. </div>
  22. <div class="info-line">
  23. <div class="info-line-title">船东手机号</div>
  24. <el-input
  25. class="info-line-text"
  26. v-model="shipOwnerDetail.userPhone"
  27. :disabled="unchangeableShipOwner"
  28. ></el-input>
  29. </div>
  30. </div>
  31. <div class="line">
  32. <div class="info-line">
  33. <div class="info-line-title">船东身份证</div>
  34. <el-input
  35. class="info-line-text"
  36. v-model="shipOwnerDetail.idcardNo"
  37. :disabled="unchangeableShipOwner"
  38. ></el-input>
  39. </div>
  40. </div>
  41. <div class="line">
  42. <div class="info-line aic">
  43. <div class="info-line-title">上传身份证 :</div>
  44. <Uploader
  45. uploaderId="idfront"
  46. :limit="1"
  47. :params="{}"
  48. :actionUrl="store.state.idCardUrl"
  49. :disabled="unchangeableShipOwner"
  50. :fileList="idFrontList"
  51. @onSendFileList="idFrontUploadSuccess"
  52. uploadText="身份证人像面"
  53. class="mr20"
  54. ></Uploader>
  55. <Uploader
  56. uploaderId="idback"
  57. :limit="1"
  58. :params="{}"
  59. :actionUrl="store.state.idCardUrl"
  60. :disabled="unchangeableShipOwner"
  61. :fileList="idBackList"
  62. @onSendFileList="idBackUploadSuccess"
  63. uploadText="身份证国徽面"
  64. ></Uploader>
  65. </div>
  66. </div>
  67. <div class="df aic jcfe" v-if="addShipOwnerBtnVisable">
  68. <el-button type="primary" @click="addShipOwner()">确定</el-button>
  69. </div>
  70. </div>
  71. <div v-if="shipInfoVisable">
  72. <div class="container-title">船舶信息</div>
  73. <div class="line-container-p24">
  74. <div class="line">
  75. <div class="info-line">
  76. <div class="info-line-title">船名</div>
  77. <el-input
  78. class="info-line-text"
  79. v-model="shipDetail.shipname"
  80. :disabled="unchangeableShip"
  81. ></el-input>
  82. <view class="unit"></view>
  83. </div>
  84. <div class="info-line">
  85. <div class="info-line-title">MMSI</div>
  86. <el-input
  87. class="info-line-text"
  88. v-model="shipDetail.mmsi"
  89. :disabled="unchangeableShip"
  90. @blur="searchShip"
  91. ></el-input>
  92. </div>
  93. </div>
  94. <div class="line">
  95. <div class="info-line">
  96. <div class="info-line-title">船长</div>
  97. <el-input
  98. class="info-line-text"
  99. v-model="shipDetail.length"
  100. :disabled="unchangeableShip"
  101. ></el-input>
  102. <view class="unit">米</view>
  103. </div>
  104. <div class="info-line">
  105. <div class="info-line-title">船宽</div>
  106. <el-input
  107. class="info-line-text"
  108. v-model="shipDetail.breadth"
  109. :disabled="unchangeableShip"
  110. ></el-input>
  111. <view class="unit">米</view>
  112. </div>
  113. </div>
  114. <div class="line">
  115. <div class="info-line">
  116. <div class="info-line-title">吨位</div>
  117. <el-input
  118. class="info-line-text"
  119. v-model="shipDetail.loadTons"
  120. :disabled="unchangeableShip"
  121. ></el-input>
  122. <view class="unit">吨</view>
  123. </div>
  124. <div class="info-line">
  125. <div class="info-line-title">船龄</div>
  126. <el-input
  127. class="info-line-text"
  128. v-model="shipDetail.age"
  129. :disabled="unchangeableShip"
  130. ></el-input>
  131. <view class="unit">年</view>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="container-title">船舶证书</div>
  136. <div class="line-container-p24">
  137. <ShipCerts ref="shipCerts"></ShipCerts>
  138. </div>
  139. <div class="container-title">船舶保险</div>
  140. <div class="line-container-p24 mb20"></div>
  141. </div>
  142. </template>
  143. <script setup>
  144. import { ref, h, reactive, toRefs, onMounted } from "vue";
  145. // import { uploadUrl } from "../../apis/config";
  146. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  147. import store from "../../store";
  148. import router from "../../router";
  149. import md5 from "md5";
  150. import api from "../../apis/fetch";
  151. import { useRoute } from "vue-router";
  152. import _ from "lodash";
  153. const route = useRoute();
  154. let shipOwnerDetail = ref({});
  155. let shipDetail = ref({});
  156. let idFrontList = ref([]);
  157. function idFrontUploadSuccess(list) {
  158. if (list.length) {
  159. let { url, response } = list[0];
  160. let { downloadUrl, viewUrl, key } = response.result;
  161. idFrontList.value = [{ url, downloadUrl, viewUrl, key }];
  162. } else {
  163. idFrontList.value = [];
  164. }
  165. }
  166. let idBackList = ref([]);
  167. function idBackUploadSuccess(list) {
  168. if (list.length) {
  169. let { url, response } = list[0];
  170. let { downloadUrl, viewUrl, key } = response.result;
  171. idBackList.value = [{ url, downloadUrl, viewUrl, key }];
  172. } else {
  173. idBackList.value = [];
  174. }
  175. }
  176. function checkShipOwner() {
  177. let { userName, userPhone } = shipOwnerDetail.value;
  178. if (!userName) {
  179. ElNotification.error({
  180. title: "请填写船东姓名",
  181. duration: 1500,
  182. });
  183. return false;
  184. }
  185. if (!userPhone) {
  186. ElNotification.error({
  187. title: "请填写船东手机号",
  188. duration: 1500,
  189. });
  190. return false;
  191. }
  192. return true;
  193. }
  194. async function addShipOwner() {
  195. if (!checkShipOwner()) return;
  196. let postData = shipOwnerDetail.value;
  197. if (idFrontList.value.length) {
  198. let {
  199. downloadUrl: idcardFrontDownloadUrl,
  200. viewUrl: idcardFrontViewUrl,
  201. key: idcardFrontFileKey,
  202. } = idFrontList.value[0];
  203. postData = {
  204. ...postData,
  205. idcardFrontDownloadUrl,
  206. idcardFrontViewUrl,
  207. idcardFrontFileKey,
  208. };
  209. }
  210. if (idBackList.value.length) {
  211. let {
  212. downloadUrl: idcardBackDownloadUrl,
  213. viewUrl: idcardBackViewUrl,
  214. key: idcardBackFileKey,
  215. } = idBackList.value[0];
  216. postData = {
  217. ...postData,
  218. idcardBackDownloadUrl,
  219. idcardBackViewUrl,
  220. idcardBackFileKey,
  221. };
  222. }
  223. let { data } = await api.addShipOwner(postData);
  224. if (data.status == 0) {
  225. ElMessageBox.confirm("添加船东成功,是否添加新船舶?", "添加成功", {
  226. confirmButtonText: "是",
  227. cancelButtonText: "否",
  228. type: "success",
  229. })
  230. .then(() => {
  231. shipInfoVisable.value = true;
  232. unchangeableShipOwner.value = true;
  233. addShipOwnerBtnVisable.value = false;
  234. })
  235. .catch(() => {
  236. router.push("/shipOwnerManage/shipOwnerList");
  237. });
  238. }
  239. }
  240. let shipOwnerId = ref("");
  241. let addShipOwnerBtnVisable = ref(true);
  242. let unchangeableShipOwner = ref(false);
  243. let unchangeableShip = ref(false);
  244. let shipInfoVisable = ref(true);
  245. let shipCerts = ref(null);
  246. async function searchShip(e) {
  247. if (e.target.value.length != 9) return;
  248. let { data } = await api.searchShip({
  249. mmsi: e.target.value,
  250. });
  251. if (data.status == 0) {
  252. shipDetail.value = data.result;
  253. shipCerts.value.initCerts(shipDetail.value.shipCerts);
  254. }
  255. }
  256. onMounted(() => {
  257. if (route.query.shipOwnerId) {
  258. shipOwnerId.value = route.query.shipOwnerId;
  259. getShipOwnerDetail();
  260. unchangeableShipOwner.value = true;
  261. unchangeableShip.value = true;
  262. }
  263. });
  264. </script>
  265. <style scoped>
  266. :deep().el-upload-list__item-thumbnail {
  267. object-fit: contain;
  268. }
  269. .upload-plus-icon {
  270. height: 15%;
  271. color: rgb(139, 147, 156);
  272. line-height: 100px;
  273. font-size: 40px;
  274. font-weight: 200;
  275. }
  276. .upload-text {
  277. height: 25%;
  278. color: rgb(139, 147, 156);
  279. }
  280. :deep().el-upload--picture-card {
  281. border: none;
  282. width: auto;
  283. }
  284. .unit {
  285. width: 40px;
  286. text-align: center;
  287. color: #555;
  288. }
  289. </style>