| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- <template>
- <div>
- <div class="container-title">船舶信息</div>
- <div
- class="pt10 bgf df jcsb pr20"
- v-if="route.name == 'shipOwnerDetail' || route.name == 'shipDetail'"
- style="max-width: 1200px"
- >
- <el-button-group class="mr20" v-if="route.name == 'shipOwnerDetail'">
- <el-button
- v-for="(item, index) in shipInfos"
- :key="item.code"
- @click="currentIndex = index"
- :disabled="!shipInfoDisabled"
- v-show="item.code"
- :type="index == currentIndex ? 'primary' : ''"
- >
- {{ item.shipname || "新增船舶" }}
- </el-button>
- </el-button-group>
- <div></div>
- <div class="df">
- <div class="df" v-if="shipInfos[currentIndex].code">
- <el-button v-if="shipInfoDisabled" type="primary" @click="showUpdate">
- 更新船舶基础信息
- </el-button>
- <el-button
- v-if="!shipInfoDisabled"
- type="primary"
- @click="confirmUpdate"
- >
- 确认更新
- </el-button>
- <el-button
- v-if="!shipInfoDisabled"
- type="primary"
- @click="cancelUpdate"
- >
- 取消更新
- </el-button>
- <el-button
- v-if="route.name == 'shipOwnerDetail'"
- @click="deleteShip(currentIndex)"
- type="primary"
- class="mr20"
- >
- 删除当前船舶
- </el-button>
- </div>
- <div class="df" v-if="route.name == 'shipOwnerDetail'">
- <el-button
- v-if="shipInfos.length == 0 || shipInfos[currentIndex].code"
- @click="addShip()"
- type="primary"
- >
- 新增船舶
- </el-button>
- <div v-else>
- <el-button
- v-if="shipInfos.length > 1"
- @click="cancelAdd()"
- type="primary"
- >
- 取消新增船舶
- </el-button>
- </div>
- </div>
- </div>
- </div>
- <div class="line-container-p24">
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">认证状态</div>
- <el-tag
- v-if="shipInfos[currentIndex].hhdAuthStatus === 1"
- type="success"
- size="large"
- >
- 已认证
- </el-tag>
- <el-button
- v-if="shipInfos[currentIndex].hhdAuthStatus === 0"
- type="primary"
- @click="authShip()"
- >
- 船员认证
- </el-button>
- </div>
- </div>
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">
- <span class="red">*</span>
- 船名
- </div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].shipname"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit"></view>
- </div>
- <div class="info-line">
- <div class="info-line-title">
- <span class="red">*</span>
- MMSI
- </div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].mmsi"
- :disabled="
- shipInfoDisabled ||
- !!shipInfos[currentIndex].code ||
- !!shipInfos[currentIndex].shipId
- "
- @blur="searchShip($event, currentIndex)"
- ></el-input>
- </div>
- </div>
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">
- <span class="red">*</span>
- 船员姓名
- </div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].contentShipOwnerName"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit"></view>
- </div>
- <div class="info-line">
- <div class="info-line-title">
- <span class="red">*</span>
- 船员手机号
- </div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].contentShipOwnerPhone"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit"></view>
- </div>
- </div>
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">船籍</div>
- <el-select
- style="width: 240px"
- v-model="shipInfos[currentIndex].registryProvince"
- placeholder="请选择船籍"
- :disabled="shipInfoDisabled"
- >
- <el-option
- v-for="item in provinceOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </div>
- </div>
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">船长</div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].length"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit">米</view>
- </div>
- <div class="info-line">
- <div class="info-line-title">船宽</div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].breadth"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit">米</view>
- </div>
- </div>
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">载货吨位</div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].loadTons"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit">吨</view>
- </div>
- <div class="info-line">
- <div class="info-line-title">船龄</div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].age"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit">年</view>
- </div>
- </div>
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">满载吃水</div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].draught"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit">米</view>
- </div>
- <div class="info-line">
- <div class="info-line-title">吨位(总吨)</div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].tonnage"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit">吨</view>
- </div>
- </div>
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">主机功率</div>
- <el-input
- class="info-line-text"
- v-model="shipInfos[currentIndex].monitorRate"
- :disabled="shipInfoDisabled"
- ></el-input>
- <view class="unit">千瓦</view>
- </div>
- <div class="info-line">
- <div class="info-line-title">南京报备</div>
- <el-switch
- v-model="shipInfos[currentIndex].nanjingReport"
- size="large"
- active-text="已报备"
- :active-value="1"
- inactive-text="未报备"
- :inactive-value="0"
- :disabled="shipInfoDisabled"
- />
- </div>
- </div>
- <div class="line">
- <div class="info-line">
- <div class="info-line-title">三峡报备</div>
- <el-switch
- v-model="shipInfos[currentIndex].sanxiaReport"
- size="large"
- active-text="已报备"
- :active-value="1"
- inactive-text="未报备"
- :inactive-value="0"
- :disabled="shipInfoDisabled"
- />
- </div>
- </div>
- </div>
- <div style="max-width: 1200px">
- <div class="container-title">船舶证书</div>
- <div
- v-for="(item, index) in shipInfos[currentIndex].shipCerts"
- :key="item.title"
- style="background: #fff"
- class="pt20"
- >
- <div v-if="item.type == 5" class="container-title fs18 pt10 pb10">
- 船舶保险
- </div>
- <div class="df aic pl40 pb20">
- <div class="c6 fs16 mr30">
- {{ item.typeName }}
- </div>
- </div>
- <div class="ml50 mb20 c7 fs14" v-if="item.type != 0">
- <div
- class="df aic mb10"
- v-for="(item1, index1) in item.certValids"
- :key="item.id"
- >
- <div class="mr10" style="width: 140px">{{ item1.typeName }}</div>
- <el-date-picker
- style="width: 140px; font-size: 13px"
- v-model="item1.startValidTime"
- @change="changeDate($event, item, item1)"
- type="date"
- placeholder="有效期开始时间"
- value-format="YYYY/MM/DD"
- format="YYYY/MM/DD"
- />
- <div style="margin: 0 4px">-</div>
- <el-date-picker
- style="width: 140px; font-size: 13px"
- v-model="item1.endValidTime"
- @change="changeDate($event, item, item1)"
- type="date"
- placeholder="有效期结束时间"
- value-format="YYYY/MM/DD"
- format="YYYY/MM/DD"
- />
- </div>
- </div>
- <div class="df">
- <Uploader
- class="ml50 pb20"
- :uploaderId="'certsId' + 'country'"
- :params="
- shipInfos[currentIndex].code
- ? {
- ...updateParams,
- shipCode: shipInfos[currentIndex].code,
- type: item.type,
- }
- : addParams
- "
- :actionUrl="
- shipInfos[currentIndex].code
- ? store.state.shipCertUpdateUrl
- : store.state.addCertsUrl
- "
- :disabled="disabled"
- :fileList="item.certs"
- @onUploadFileList="uploadSuccess($event, index)"
- @onRemoveFileList="removeSuccess($event, index)"
- ></Uploader>
- </div>
- </div>
- <div
- v-if="!shipInfos[currentIndex].code"
- class="p30 mb30 df jcfe"
- style="background: #fff"
- >
- <el-button :loading="isSubmitLoading" @click="submit" type="primary">
- {{ isSubmitLoading ? "正在添加" : "添加船舶" }}
- </el-button>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { defineComponent, computed, ref, onMounted, watch } from "vue";
- import { ElMessage } from "element-plus";
- import api from "../apis/fetch";
- import _ from "lodash";
- import store from "../store";
- import { useRoute } from "vue-router";
- import router from "../router";
- import { confirm } from "../utils/utils";
- const route = useRoute();
- const props = defineProps({
- certsId: {
- type: String,
- default: "cert",
- },
- disabled: {
- type: Boolean,
- default: false,
- },
- shipInfos: {
- type: Array,
- default: [{}],
- },
- shipOwnerId: [String, Number],
- });
- let currentIndex = ref(0);
- const emit = defineEmits(["submit"]);
- function initCerts(certs) {
- console.log(certs);
- }
- let updateParams = ref({
- loginAccountId: localStorage.loginAccountId,
- });
- let addParams = ref({
- loginAccountId: localStorage.loginAccountId,
- });
- // function uploadSuccess(list, index) {
- function uploadSuccess({ response, file, list }, index) {
- if (response.status == 0) {
- let { key, fileKey, viewUrl, downloadUrl, id } = response.result;
- props.shipInfos[currentIndex.value].shipCerts[index].certs.push({
- fileKey: fileKey || key,
- viewUrl,
- downloadUrl,
- id,
- url: viewUrl,
- });
- }
- }
- async function removeSuccess({ file, fileIndex }, index) {
- if (props.shipInfos[currentIndex.value].code) {
- let { data } = await api.deleteShipCert({ shipCertId: file.id });
- if (data.status == 0) {
- ElMessage({
- message: "删除成功!",
- type: "success",
- });
- props.shipInfos[currentIndex.value].shipCerts[index].certs.splice(
- fileIndex,
- 1
- );
- }
- } else {
- props.shipInfos[currentIndex.value].shipCerts[index].certs.splice(
- fileIndex,
- 1
- );
- }
- }
- async function changeDate(e, item, item1) {
- if (props.shipInfos[currentIndex.value].code) {
- let { data } = await api.updateShipCertValid({
- shipCode: props.shipInfos[currentIndex.value].code,
- type: item.type,
- validType: item1.type,
- startValidTime: item1.startValidTime,
- endValidTime: item1.endValidTime,
- });
- if (data.status == 0) {
- ElMessage({
- message: "更新成功!",
- type: "success",
- });
- }
- }
- }
- function getShipCerts() {
- return shipCerts.value;
- }
- async function searchShip(e) {
- if (e.target.value.length != 9) return;
- const loading = ElLoading.service({
- lock: true,
- text: "正在匹配船舶...",
- background: "rgba(0, 0, 0, 0.7)",
- });
- let { data } = await api.searchShip({
- mmsi: e.target.value,
- });
- loading.close();
- if (data.status == 0) {
- data.result.shipCerts[0].typeName = "船舶主要项目页";
- data.result.shipCerts[1].typeName = "船舶国籍证书";
- data.result.shipCerts[2].typeName = "内河船舶适航证书";
- data.result.shipCerts[3].typeName = "船舶营运证书";
- data.result.shipCerts[4].typeName = "内河船舶最低安全配员证书";
- data.result.shipCerts[5].typeName = "船舶保险";
- for (let i of data.result.shipCerts) {
- for (let j of i.certs) {
- j.url = j.viewUrl;
- }
- }
- data.result.disabled = false;
- if (props.shipInfos[currentIndex.value].shipname)
- data.result.shipname = props.shipInfos[currentIndex.value].shipname;
- props.shipInfos[currentIndex.value] = data.result;
- }
- }
- function deleteShip(index) {
- ElMessageBox.confirm("确认删除船舶?", "提示", {
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(async () => {
- console.log(index);
- let { data } = await api.deleteShip({
- shipCode: props.shipInfos[index].code,
- });
- if (data.status == 0) {
- ElMessage({
- type: "success",
- message: "删除成功",
- });
- props.shipInfos.splice(index, 1);
- currentIndex.value = 0;
- }
- })
- .catch(() => {});
- }
- let cacheIndex = -1;
- async function addShip(item) {
- cacheIndex = _.cloneDeep(currentIndex.value);
- shipInfoDisabled.value = false;
- let { data } = await api.getAddShipCerts({});
- let initShipInfo = {
- shipId: 0,
- disabled: false,
- shipCerts: data.result,
- };
- if (
- props.shipInfos.length &&
- props.shipInfos[props.shipInfos.length - 1].code
- ) {
- props.shipInfos.push(initShipInfo);
- } else {
- props.shipInfos[props.shipInfos.length - 1] = initShipInfo;
- }
- currentIndex.value = props.shipInfos.length - 1;
- }
- function cancelAdd() {
- currentIndex.value = _.cloneDeep(cacheIndex);
- shipInfoDisabled.value = true;
- }
- let isSubmitLoading = ref(false);
- async function submit() {
- if (!props.shipInfos[currentIndex.value].shipname) {
- ElMessage({
- type: "warning",
- message: "请填写船舶名称",
- });
- return;
- }
- if (!props.shipInfos[currentIndex.value].mmsi) {
- ElMessage({
- type: "warning",
- message: "请填写船舶MMSI",
- });
- return;
- }
- if (!props.shipInfos[currentIndex.value].contentShipOwnerName) {
- ElMessage({
- type: "warning",
- message: "请填写船员姓名",
- });
- return;
- }
- if (!props.shipInfos[currentIndex.value].contentShipOwnerPhone) {
- ElMessage({
- type: "warning",
- message: "请填写船员手机号",
- });
- return;
- }
- isSubmitLoading.value = true;
- let { data } = await api.addShip({
- ...props.shipInfos[currentIndex.value],
- shipOwnerId: props.shipOwnerId,
- });
- isSubmitLoading.value = false;
- store.commit("removeAlive", "shipOwnerList");
- if (data.status == 0) {
- ElMessage({
- type: "success",
- message: data.msg,
- duration: 1500,
- });
- router.replace("/shipOwnerManage/shipOwnerList");
- } else {
- ElMessage({
- type: "warning",
- message: data.msg,
- duration: 2500,
- });
- }
- }
- let shipInfoDisabled = ref(true);
- let cacheInfo = ref({});
- function showUpdate() {
- cacheInfo.value = _.cloneDeep(props.shipInfos[currentIndex.value]);
- shipInfoDisabled.value = false;
- }
- async function confirmUpdate() {
- let postData = props.shipInfos[currentIndex.value];
- postData.shipCode = postData.code;
- let { data } = await api.updateShip(postData);
- if (data.status == 0) {
- ElMessage({
- message: data.msg,
- type: "success",
- });
- shipInfoDisabled.value = true;
- } else {
- ElMessage({
- message: data.msg,
- type: "error",
- });
- }
- }
- function cancelUpdate() {
- props.shipInfos[currentIndex.value] = _.cloneDeep(cacheInfo.value);
- shipInfoDisabled.value = true;
- }
- function changeDisable(b) {
- shipInfoDisabled.value = b;
- }
- const provinceOptions = ref([]);
- async function getProvinceSelect() {
- let { data } = await api.getProvinceSelect();
- if (data.status === 0) {
- provinceOptions.value = data.result;
- } else {
- provinceOptions.value = [];
- }
- }
- async function authShip() {
- if (!(await confirm("确认认证船舶?"))) return;
- let { data } = await api.authShip({
- shipCode: route.query.shipCode,
- });
- if (data.status === 0) {
- ElMessage({
- type: "success",
- message: data.msg,
- });
- props.shipInfos[currentIndex.value].hhdAuthStatus = 1;
- } else {
- ElMessage({
- type: "error",
- message: data.msg,
- });
- }
- }
- defineExpose({
- initCerts,
- getShipCerts,
- changeDisable,
- });
- onMounted(() => {
- getProvinceSelect();
- });
- </script>
- <style scoped>
- .unit {
- width: 40px;
- text-align: center;
- color: #555;
- }
- </style>
|