<template>
  <div>
    <div class="dialog-h-content scroll-h">

      <div v-if="initLoading"
           class="m-row">
        <div class="m-info">
          <div class="info-prop">
            <span class="info-title-2">服务类别：</span>
            <span>{{ fmData.serviceCategory || "--" }}</span>
          </div>

          <div class="info-prop">
            <span class="info-title-2">项目名称：</span>
            <span>{{ fmData.serviceName || "--" }}</span>
          </div>

          <div class="info-prop">
            <span class="info-title-2">服务内容：</span>
            <span>{{ fmData.serviceContent|| "--"}}</span>
          </div>

          <div class="info-prop">
            <span class="info-title-2">政策级别：</span>
            <span>{{ fmData.policyLevelName|| "--"}}</span>
          </div>

          <div class="info-prop">
            <span class="info-title-2">政策依据：</span>
            <span>{{ fmData.policyGround|| "--"}}</span>
          </div>

          <div class="info-prop">
            <span class="info-title-2">附件：</span>
            <file-list v-if="fmData.attachmentList.length>0"
                       :fileList="fmData.attachmentList"></file-list>
            <span v-else>--</span>

          </div>

        </div>
      </div>

    </div>
    <div class="div-btn">
      <el-button size="small"
                 @click="handleCancle">关 闭</el-button>

    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { requestPost } from "@/js/dai/request";
import fileList from '@/views/components/fileList'

export default {
  props: {
    formId: {
      type: String,
      default: "",
    },

  },

  data () {
    return {

      customerId: localStorage.getItem("customerId"),

      initLoading: false,

      fmData: {},

      levelOptions: [
        {
          value: "0",
          label: "市级",
        },
        {
          value: "1",
          label: "区级",
        },
        {
          value: "2",
          label: "街道级",
        },
      ],
      categoryOptions: [],
    };
  },
  components: { fileList },
  computed: {

  },
  watch: {},

  async mounted () {
    this.initForm();
  },

  methods: {
    async initForm () {
      this.getCategoryOpitons();

      await this.getInfo();
      this.initLoading = true
    },

    async getInfo () {
      const url = "/heart/icServiceProject/serviceProjectDetail";

      const params = {
        serviceProjectId: this.formId,
      };

      const { data, code, msg } = await requestPost(url, params);
      if (code === 0) {
        this.fmData = { ...this.fmData, ...data };
        if (this.fmData.attachmentList)
          this.fmData.attachmentList.forEach(element => {
            element.type = element.format
          });
      } else {
        this.$message.error(msg);
      }
    },

    async getCategoryOpitons () {
      const url = "/sys/dict/data/dictlist";
      const params = {
        dictType: "ic_service_type",
      };
      const { data, code, msg } = await requestPost(url, params);
      if (code === 0) {
        this.categoryOptions = data || [];
      } else {
        this.$message.error(msg);
      }
    },



    watchImg (src) {
      window.open(src);
    },



    handleCancle () {
      this.$emit("diaDetailClose");
    },
  },
};
</script>

<style lang="scss" scoped >
@import "@/assets/scss/modules/management/detail-main.scss";
</style>
