<template>
  <div>
    <uni-section title="基本信息" type="line"></uni-section>
    <div class="list-cont">
      <div class="list-item">
        <div class="title">计划类型：</div>
        <div>{{ formData.planType }}</div>
      </div>
      <div class="list-item">
        <div class="title">项目名称：</div>
        <div>{{ formData.proName }}</div>
      </div>
      <div class="list-item">
        <div class="title">项目部分：</div>
        <div>{{ formData.proPart }}</div>
      </div>
      <div class="list-item">
        <div class="title">工作内容：</div>
        <div>{{ formData.jobContent }}</div>
      </div>
      <div class="list-item">
        <div class="title">需要日期：</div>
        <div>{{ formData.needDate }}</div>
      </div>
      <div class="list-item">
        <div class="title">计划说明：</div>
        <div>{{ formData.explain }}</div>
      </div>
    </div>
    <uni-section title="申请明细" type="line"></uni-section>
    <div class="list-cont" v-for="(item, index) in tableList" :key="index">
      <div class="list-item">
        <span class="title">类 &nbsp; &nbsp;型：</span>
        <span>{{ item.type }}</span>
      </div>
      <div class="list-item">
        <span class="title">名 &nbsp; &nbsp;称：</span>
        <span>{{ item.name }}</span>
      </div>
      <div class="list-item">
        <span class="title">规 &nbsp; &nbsp;格：</span>
        <span>{{ item.specification }}</span>
      </div>
      <div class="list-item">
        <span class="title">单 &nbsp; &nbsp;位：</span>
        <span>{{ item.unit }}</span>
      </div>
      <div class="list-item">
        <span class="title">需 用 量：</span>
        <span>{{ item.num }}</span>
      </div>
      <div class="list-item">
        <span class="title">需要天数：</span>
        <span>{{ item.date }}</span>
      </div>
      <div class="list-item">
        <span class="title">备 &nbsp; &nbsp;注：</span>
        <span>{{ item.remark }}</span>
      </div>
    </div>

    <!-- btn -->
    <div class="btn-wrap" v-if="opt.isPlan">
      <div style="margin: 0 15px">
        <u-button type="primary" @click="showModal = true">派 车 分 配</u-button>
      </div>
    </div>

    <!-- 弹框 -->
    <u-modal :show="showModal" title="指定派车供应商" showCancelButton @cancel="showModal = false" @confirm="submit">
      <view class="slot-content">
        <div>
          <u-radio-group v-model="radioValue" placement="column">
            <u-radio
              :customStyle="{ marginBottom: '8px' }"
              v-for="(item, index) in radioList"
              :key="index"
              :label="item.name"
              :name="item.value"
            ></u-radio>
          </u-radio-group>
        </div>
      </view>
    </u-modal>

    <!-- 空状态 -->
    <u-empty v-if="tableList.length == 0" mode="data"></u-empty>
  </div>
</template>

<script>
export default {
  props: {
    opt: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      showModal: false,
      radioValue: '',
      formData: {
        planType: '计划类型', // 计划类型
        proName: '项目名称', // 项目名称
        proPart: '项目部分', // 项目部分
        jobContent: '工作内容', // 工作内容
        needDate: '2025-01-01', // 需要日期
        explain: '这是计划说明' // 计划说明
      },
      pageNum: 1,
      pageSize: 10,
      total: 0,
      tableList: [
        {
          type: '类型1',
          name: '名称1',
          specification: '规格1',
          unit: '单位1',
          num: '数量1',
          date: '需要天数1',
          remark: '备注1'
        },
        {
          type: '类型2',
          name: '名称2',
          specification: '规格2',
          unit: '单位2',
          num: '数量2',
          date: '需要天数2',
          remark: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
        }
      ],
      radioList: [
        {
          name: '苹果',
          value: '1',
          disabled: false
        },
        {
          name: '香蕉',
          value: '2',
          disabled: false
        },
        {
          name: '橙子',
          value: '3',
          disabled: false
        },
        {
          name: '榴莲',
          value: '4',
          disabled: false
        }
      ]
    }
  },
  mounted() {
    console.log('🚀 ~ 计划详情 ~ this.opt', this.opt)
  },
  methods: {
    submit() {
      console.log('🚀  ~ submit ~ this.radioValue', this.radioValue)
    }
  }
}
</script>

<style lang="scss" scoped>
page {
  padding-bottom: 70px;
}
.list-cont {
  margin: 15px;
  padding: 15px 0;
  margin-bottom: 15px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);

  .list-item {
    padding: 5px 15px;

    .title {
      color: #999;
    }

    div {
      line-height: 1.9;
    }
    span {
      line-height: 1.5;
    }
  }
}
.btn-wrap {
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  background-color: #fff;
  padding: 15px 0 20px;
}
.slot-content {
  width: 100%;
  height: 100%;
  .item-wrap {
    margin-bottom: 15px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .item {
      width: 45%;
      height: 30px;
      display: flex;
      justify-content: center;
      align-items: center;
      border: 1px solid #e8e8e8;
      border-radius: 30px;
      background-color: #f8f8f8;
      color: #666;
      font-size: 16px;
      font-weight: 500;
      transition: color 0.3s ease, background-color 0.3s ease, border 0.3s ease;

      &.active {
        color: $u-primary;
        background-color: #f8f8f8;
        border: 1px solid $u-primary;
      }
    }
  }
}
</style>
