<template>
  <!-- 优化运行 -->
  <div style="height: 100%;">
    <el-card class="custom-card">
      <template #header>
        <span>优化运行</span>
      </template>
      <div class="container">
        <div class="container-item" @click="startRun">
          <img src="@/assets/img/start.png" class="container-img" alt="Experiment Icon" />
          <span class="container-text">开始</span>
        </div>
        <div class="container-item">
          <img src="@/assets/img/stop.png" class="container-img" alt="Experiment Icon" />
          <span class="container-text">停止</span>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { request, enPassword } from "@/utils/request";
import { ElMessage, ElMessageBox } from 'element-plus'

import { useProjectStore } from '@/store/project'

const emit = defineEmits(['saveAllData'])

const projectStore = useProjectStore()

const props = defineProps({
  type: {
    type: Number,
    default:0
  }
})

const pid = computed(() => projectStore.pid)


const startRun = () => {
  emit('saveAllData')
  const params = {
    transCode: 'AC00006',
    pid: pid.value,
    type: props.type
  };
  request(params)
    .then((res) => {
      ElMessage.success('开始运行')
    })
    .catch((err) => {
      console.error(err);
      ElMessage.error(err.returnMsg);
    })
}



</script>

<style scoped>
.container {
  width: 100%;
  height: 100%;
  overflow: hidden;

  display: flex;
}

.container-item {
  width: 50%;

  display: flex;
  flex-direction: column;
  align-items: center;

  .container-img {
    height: 70%;
    cursor: pointer;
    position: relative;
    top: 10px;
  }

  .container-text {
    cursor: pointer;
  }
}
</style>