|
@@ -0,0 +1,125 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="detailPW">
|
|
|
|
+ <van-row>
|
|
|
|
+ <van-col span="24" class="main">
|
|
|
|
+ <van-form @submit="onSubmit" label-width="4em">
|
|
|
|
+ <van-field readonly clickable name="title" :value="form.title" label="选择展会" placeholder="点击选择" @click="showPicker = true" />
|
|
|
|
+ <van-popup v-model="showPicker" position="bottom">
|
|
|
|
+ <van-picker show-toolbar :columns="dockList" value-key="title" @confirm="onConfirm" @cancel="showPicker = false" />
|
|
|
|
+ </van-popup>
|
|
|
|
+ <van-field v-model="form.content" rows="2" autosize label="信息内容" type="textarea" placeholder="请输入信息内容" />
|
|
|
|
+ <van-field name="uploader" label="图片">
|
|
|
|
+ <template #input>
|
|
|
|
+ <van-uploader :fileList="img_url" :max-count="1" @delete="file => toDelete(file, 'img_url')" :after-read="file => toUpload(file, 'img_url')" />
|
|
|
|
+ </template>
|
|
|
|
+ </van-field>
|
|
|
|
+ <van-field name="uploader" label="视频">
|
|
|
|
+ <template #input>
|
|
|
|
+ <van-uploader :fileList="file_url" :max-count="1" @delete="file => toDelete(file, 'file_url')" :after-read="file => toUpload(file, 'file_url')" />
|
|
|
|
+ </template>
|
|
|
|
+ </van-field>
|
|
|
|
+ <div style="margin: 16px;">
|
|
|
|
+ <van-button round block type="info" native-type="submit">上传</van-button>
|
|
|
|
+ </div>
|
|
|
|
+ </van-form>
|
|
|
|
+ </van-col>
|
|
|
|
+ </van-row>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: dock } = createNamespacedHelpers('dock');
|
|
|
|
+const { mapActions: dockImgtxt } = createNamespacedHelpers('dockImgtxt');
|
|
|
|
+const { mapActions: upload } = createNamespacedHelpers('upload');
|
|
|
|
+export default {
|
|
|
|
+ name: 'detailPW',
|
|
|
|
+ props: {},
|
|
|
|
+ components: {},
|
|
|
|
+ data: function() {
|
|
|
|
+ return {
|
|
|
|
+ // 选择展会
|
|
|
|
+ dockList: [],
|
|
|
|
+ showPicker: false,
|
|
|
|
+ form: {},
|
|
|
|
+ img_url: [],
|
|
|
|
+ file_url: [],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.search();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...dock(['query']),
|
|
|
|
+ ...dockImgtxt(['create']),
|
|
|
|
+ ...upload(['upload']),
|
|
|
|
+ async search() {
|
|
|
|
+ let res = await this.query();
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `dockList`, res.data);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async onSubmit() {
|
|
|
|
+ let data = this.getFile(this.form);
|
|
|
|
+ let res = await this.create(data);
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$notify({
|
|
|
|
+ message: '信息上传成功',
|
|
|
|
+ type: 'success',
|
|
|
|
+ });
|
|
|
|
+ this.form = {};
|
|
|
|
+ } else {
|
|
|
|
+ this.$notify({
|
|
|
|
+ message: res.errmsg,
|
|
|
|
+ type: 'danger',
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ onConfirm(value) {
|
|
|
|
+ let data = {
|
|
|
|
+ user_id: value.user_id,
|
|
|
|
+ dock_id: value._id,
|
|
|
|
+ title: value.title,
|
|
|
|
+ };
|
|
|
|
+ this.$set(this, `form`, data);
|
|
|
|
+ this.showPicker = false;
|
|
|
|
+ },
|
|
|
|
+ async toUpload({ file }, model) {
|
|
|
|
+ // 上传,赋值
|
|
|
|
+ const res = await this.upload({ file, dir: 'file' });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, model, [{ name: res.name, url: res.uri }]);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ toDelete(file, model) {
|
|
|
|
+ const index = this[model].findIndex(f => _.isEqual(f, file));
|
|
|
|
+ this[model].splice(index, 1);
|
|
|
|
+ },
|
|
|
|
+ // 处理文件
|
|
|
|
+ getFile(data) {
|
|
|
|
+ let img_url = this.img_url.find(i => i);
|
|
|
|
+ if (img_url) data.img_url = img_url.url;
|
|
|
|
+ else data.img_url = '';
|
|
|
|
+ let file_url = this.file_url.find(i => i);
|
|
|
|
+ if (file_url) data.file_url = file_url.url;
|
|
|
|
+ else data.file_url = '';
|
|
|
|
+ return data;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState(['user']),
|
|
|
|
+ },
|
|
|
|
+ metaInfo() {
|
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ test: {
|
|
|
|
+ deep: true,
|
|
|
|
+ immediate: true,
|
|
|
|
+ handler(val) {},
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="less" scoped></style>
|