hairmess_create.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div id="hairmess">
  3. <admin-frame topType="2" @back="back" :rightArrow="false" :usePage="false" :useNav="false">
  4. <template v-slot:info>
  5. <van-form>
  6. <van-field name="file_url" label="文件">
  7. <template #input>
  8. <van-uploader
  9. :fileList="form.file_url"
  10. :max-count="1"
  11. :after-read="(file) => toUpload(file, 'file_url')"
  12. @delete="(file) => toDelete(file, 'file_url')"
  13. accept="file"
  14. />
  15. </template>
  16. </van-field>
  17. <van-field v-model="form.create_number" center clearable label="专利申请号" placeholder="请输入专利申请号">
  18. <template #button>
  19. <van-button size="small" type="primary" @click="searchPatent">查询</van-button>
  20. </template>
  21. </van-field>
  22. <van-field v-model="form.patent_name" name="专利名称" label="专利名称" readonly />
  23. <van-field v-model="form.to_name" name="接收人" label="接收人" readonly />
  24. <van-col span="24" class="btn">
  25. <van-button type="danger" size="small" @click="back">取消发送</van-button>
  26. <van-button type="info" size="small" @click="onSubmit">确认发送</van-button>
  27. </van-col>
  28. </van-form>
  29. </template>
  30. </admin-frame>
  31. </div>
  32. </template>
  33. <script>
  34. import adminFrame from '@frame/src/components/mobile-frame/mobile-main.vue';
  35. import { mapState, createNamespacedHelpers } from 'vuex';
  36. const { mapActions: patentwarning } = createNamespacedHelpers('patentwarning');
  37. const { mapActions: patentapply } = createNamespacedHelpers('patentapply');
  38. const { mapActions: upload } = createNamespacedHelpers('upload');
  39. export default {
  40. name: 'hairmess',
  41. props: {},
  42. components: {
  43. adminFrame,
  44. },
  45. data: function () {
  46. return {
  47. form: {},
  48. };
  49. },
  50. async created() {},
  51. methods: {
  52. ...upload(['upload']),
  53. ...patentwarning(['query', 'create']),
  54. ...patentapply({ patentapplyQuery: 'query' }),
  55. // 确认发送
  56. async onSubmit() {
  57. let data = this.form;
  58. let res = await this.create(data);
  59. if (this.$checkRes(res)) {
  60. this.$toast({ type: `success`, message: `操作成功` });
  61. this.back();
  62. } else {
  63. this.$toast({ type: `success`, message: `${res.errmsg}` });
  64. }
  65. },
  66. // 查询专利申请
  67. async searchPatent(create_number) {
  68. let info = { create_number: this.form.create_number ? this.form.create_number : create_number };
  69. let res = await this.patentapplyQuery({ ...info });
  70. if (this.$checkRes(res)) {
  71. let data = { file_url: this.form.file_url };
  72. if (res.total > 0) {
  73. for (const val of res.data) {
  74. data.create_number = val.create_number;
  75. data.patent_id = val.id;
  76. data.patent_name = val.name;
  77. data.to_id = val.user_id;
  78. data.to_name = val.apply_name;
  79. }
  80. }
  81. this.$set(this, `form`, data);
  82. }
  83. },
  84. async toUpload({ file }, model) {
  85. // 上传,赋值
  86. const res = await this.upload({ file, dir: 'file' });
  87. if (this.$checkRes(res)) {
  88. this.$set(this.form, model, [{ name: res.name, url: res.uri }]);
  89. let create_number = file.name.substring(0, file.name.lastIndexOf('.'));
  90. this.searchPatent(create_number);
  91. }
  92. },
  93. toDelete(file, model) {
  94. const index = this.form[model].findIndex((f) => _.isEqual(f, file));
  95. this.form[model].splice(index, 1);
  96. },
  97. // 返回
  98. back() {
  99. this.$router.push({ path: '/patent/admin/examine/hairmess' });
  100. },
  101. },
  102. computed: {
  103. ...mapState(['user']),
  104. },
  105. metaInfo() {
  106. return { title: this.$route.meta.title };
  107. },
  108. watch: {
  109. test: {
  110. deep: true,
  111. immediate: true,
  112. handler(val) {},
  113. },
  114. },
  115. };
  116. </script>
  117. <style lang="less" scoped>
  118. .btn {
  119. text-align: center;
  120. .van-button {
  121. margin: 10px;
  122. }
  123. }
  124. </style>