<template>
  <div id="index">
    <admin-frame topType="2" @back="back" :usePage="false" :rightArrow="false" :useNav="false">
      <template v-slot:info>
        <trans-create :form="form" @onSubmit="onSubmit"></trans-create>
      </template>
    </admin-frame>
  </div>
</template>

<script>
import transCreate from '@/layout/trans/trans-create.vue';
import adminFrame from '@frame/src/components/mobile-frame/mobile-main.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: patenttrans } = createNamespacedHelpers('patenttrans');
const { mapActions: upload } = createNamespacedHelpers('upload');
const moment = require('moment');
export default {
  name: 'index',
  props: {},
  components: {
    adminFrame,
    transCreate,
  },
  data: function () {
    return {
      form: {
        promise_file: { province: '吉林省', city: '长春市', end_date: moment(new Date()).format('YYYY-MM-DD') },
      },
    };
  },
  created() {},
  methods: {
    ...upload(['upload']),
    ...patenttrans(['fetch', 'create', 'update']),
    // 提交
    async onSubmit({ data }) {
      let res = await this.create(data);
      if (this.$checkRes(res)) {
        this.$toast({ type: `success`, message: `操作完成` });
        this.back();
      }
    },
    // 返回
    back() {
      this.$router.push({ path: '/patent/admin/patent/trans' });
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

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