<template>
  <div>
    <div
      v-for="(item, index) in list"
      :key="index"
      class="border border-solid border-gray-100 shadow rounded mb-2 p-4"
    >
      <component :is="DataCalc">
        <template #title>
          <div class="flex items-center justify-between">
            <!-- <div v-if="list.length <= 1"></div> -->
            <el-button type="primary" link @click="list.splice(index, 0, {})">
              <Plus class="w-4" />
              <span>新增计算</span>
            </el-button>
            <el-button
              v-if="list.length > 1"
              type="danger"
              link
              @click="list.splice(index, 1)"
              ><Delete class="w-4" /><span>删除该计算</span></el-button
            >
          </div>
        </template>
      </component>
    </div>
  </div>
</template>

<script setup>
import { ref, shallowRef, defineAsyncComponent } from "vue";
import { ElMessage } from "element-plus";
import {
  Plus,
  ArrowUp,
  ArrowDown,
  Delete,
  QuestionFilled
} from "@element-plus/icons-vue";
const DataCalc = defineAsyncComponent(() => import("./DataCalc.vue"));

const list = ref([{}]);
</script>

<style lang="scss" scoped></style>
