王智慧 преди 3 години
родител
ревизия
211192a429
променени са 1 файла, в които са добавени 21 реда и са изтрити 2 реда
  1. 21 2
      src/components/ShipInfo.vue

+ 21 - 2
src/components/ShipInfo.vue

@@ -350,8 +350,27 @@ async function searchShip(e) {
     props.shipInfos[currentIndex.value] = data.result;
   }
 }
-function deleteShip(item) {
-  console.log(item);
+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;
 function addShip(item) {