guhongwei há 3 anos atrás
pai
commit
67912ce94d

+ 1 - 1
src/views/patent/mech/message/notice.vue

@@ -33,7 +33,7 @@ export default {
   methods: {
     ...patentnotice(['query']),
     async search({ skip = 0, limit = this.limit, ...info } = {}) {
-      info.to_id = this.user._id;
+      info.send_id = this.user._id;
       let res = await this.query({ skip, limit, ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `list`, res.data);

+ 24 - 0
src/views/patent/mech/message/parts/form-1.vue

@@ -13,6 +13,17 @@
             </template>
           </van-field>
           <van-field v-model="form.content" name="content" rows="2" autosize label="发送内容" type="textarea" placeholder="发送内容" />
+          <van-field name="notice_file" label="通知文件" :rules="[{ required: false, message: '通知文件' }]">
+            <template #input>
+              <van-uploader
+                :fileList="form.notice_file"
+                :max-count="1"
+                :after-read="(file) => toUpload(file, 'notice_file')"
+                @delete="(file) => toDelete(file, 'notice_file')"
+                accept="file"
+              />
+            </template>
+          </van-field>
           <div style="margin: 16px">
             <van-button round block type="info" native-type="submit">提交</van-button>
           </div>
@@ -23,6 +34,7 @@
 </template>
 
 <script>
+const { mapActions: upload } = createNamespacedHelpers('upload');
 import { mapState, createNamespacedHelpers } from 'vuex';
 export default {
   name: 'form-1',
@@ -35,9 +47,21 @@ export default {
   },
   created() {},
   methods: {
+    ...upload(['upload']),
     onSubmit(values) {
       this.$emit('onSubmit', values);
     },
+    async toUpload({ file }, model) {
+      // 上传,赋值
+      const res = await this.upload({ file, dir: 'analysis' });
+      if (this.$checkRes(res)) {
+        this.$set(this.form, model, [{ name: res.name, url: res.uri }]);
+      }
+    },
+    toDelete(file, model) {
+      const index = this.form[model].findIndex((f) => _.isEqual(f, file));
+      this.form[model].splice(index, 1);
+    },
   },
   computed: {
     ...mapState(['user']),