<template>
  <div id="list">
    <van-row>
      <van-col span="24" class="main">
        <van-col span="24" class="list" v-for="(item, index) in list" :key="index">
          <van-col span="24" class="title textOver">
            {{ item.name }}
          </van-col>
          <van-col span="24" class="other">
            <van-col span="24" class="otherInfo">
              类型：<span>{{ item.type || '暂无' }}</span>
            </van-col>
            <van-col span="24" class="otherInfo">
              服务形式：<span>{{ item.servicetype || '暂无' }}</span>
            </van-col>
          </van-col>
          <van-col span="24" style="text-align: center">
            <van-button type="info" @click="toView(item)" size="small">详细信息</van-button>
          </van-col>
        </van-col>
      </van-col>
    </van-row>
    <van-dialog class="dialog" v-model="dialog.show" :title="dialog.title" :show-confirm-button="false" show-cancel-button cancel-button-text="返回">
      <info-1 :info="info"></info-1>
    </van-dialog>
  </div>
</template>

<script>
import info1 from './info.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('usual');
export default {
  name: 'list',
  props: { list: { type: Array, default: () => [] } },
  components: { info1 },
  data: function () {
    return {
      dialog: { show: false, title: '详细信息' },
      info: {},
    };
  },
  created() {},
  methods: {
    ...mapActions(['fetch']),
    async toView(data) {
      const res = await this.fetch({ table: 'Lote', id: data.id });
      if (this.$checkRes(res)) {
        this.$set(this, 'info', res.data);
        this.dialog.show = true;
      }
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .list {
    background-color: #fff;
    margin: 0 0 8px 0;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #f1f1f1;
    .title {
      font-size: 16px;
      font-weight: bold;
      margin: 0 0 5px 0;
    }
    .other {
      margin: 0 0 5px 0;
      .otherInfo {
        font-size: 14px;
        color: #666;
        margin: 0 0 5px 0;
        span {
          color: #000;
        }
      }
    }
    .btn {
      text-align: center;
      .van-button {
        margin: 0 5px;
      }
    }
  }
}
.dialog {
  /deep/.van-dialog__content {
    max-height: 350px;
    overflow-y: auto;
  }
}
</style>
