<template>
  <div id="detail">
    <admin-frame @search="search" :limit="limit" :total="total" topType="2" @back="back" :rightArrow="false" :useNav="false">
      <template v-slot:info>
        <list-gzj :list="list"></list-gzj>
      </template>
    </admin-frame>
  </div>
</template>

<script>
import listGzj from '@/layout/apply/list-gzj.vue';
import adminFrame from '@frame/src/components/mobile-frame/mobile-main.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: patentwarning } = createNamespacedHelpers('patentwarning');
export default {
  name: 'detail',
  props: {},
  components: {
    adminFrame,
    listGzj,
  },
  data: function () {
    return {
      list: [],
      limit: 5,
      total: 0,
    };
  },
  async created() {
    await this.search();
  },
  methods: {
    ...patentwarning(['query']),
    async search({ skip = 0, limit = this.limit, ...info } = {}) {
      if (this.create_number) {
        info.name = this.name;
        info.create_number = this.create_number;
        info.to_id = this.user._id;
        let res = await this.query({ skip, limit, ...info });
        if (this.$checkRes(res)) {
          this.$set(this, `list`, res.data);
          this.$set(this, `total`, res.total);
        }
      } else {
        this.$toast({ type: `warn`, message: `专利暂无申请号，无法查询数据` });
      }
    },
    // 返回
    back() {
      window.history.back();
    },
  },
  computed: {
    ...mapState(['user']),
    name() {
      return this.$route.query.name;
    },
    create_number() {
      return this.$route.query.create_number;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

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