<template>
  <child-view>
    <div class="mt-2">
      <user-initiate :showTitle="false" :formContent="form" />
    </div>
  </child-view>
</template>

<script lang="ts">
import childView from '@/layouts/childView.vue'
import Vue from 'vue'
import UserInitiate from '../initiate_comp/user_initiate.vue'
import { service } from '@/service/index'
import { mapState } from 'vuex'
export default Vue.extend({
  components: { childView, UserInitiate },
  data() {
    return {
      form: {}
    }
  },
  computed: {
    ...mapState({
      storeForm: (state: any) => state.app.form
    })
  },
  methods: {
    getDetails() {
      service.voteDetails({
        execer: 'user.p.szhtest.rankvote',
        funcName: 'GetRankVoteInfo',
        payload: {
          voteID: this.$route.query.voteID as string
        }
      }).then(res => {
        const result = {
          name: res.result.name,
          description: res.result.description,
          url: res.result.url,
          type: res.result.type,
          startHeight: res.result.startHeight,
          endHeight: res.result.endHeight,
          options: res.result.voteOptions,
          members: res.result.members,
          isOpen: res.result.isOpen,
          numType: res.result.numType
        }
        this.$store.commit('app/SET_FORM', result)
        this.form = result
      })
    }
  },
  created() {
    if (!this.storeForm.name) {
      this.getDetails()
    }
  },
})
</script>