Tcsm
2023-08-09 1a55d5008d2484e4730a5e8919cdb95e14da98d5
ruoyi-ui/src/views/collection/collectionInfo.vue
@@ -17,16 +17,19 @@
           <el-row :span="12">
             <el-cow >
              <el-form-item label="获得时间" prop="happenTime" label-width="70px" style="background: #FAD1E0;border-radius: 7px 7px 7px 7px;opacity: 1;">
                <el-input v-model="formData.happenTime" placeholder="请输入获得时间" clearable :style="{width: '100%'}" :disabled="dsb">
                <el-input v-model="formData.happenTime" placeholder="请输入获得时间" type="date" clearable :style="{width: '100%'}" :disabled="dsb">
                </el-input>
              </el-form-item>
             </el-cow>
             <el-cow >
               <el-form-item label="类别" prop="type" label-width="40px" style="background: #FAD1E0;border-radius: 7px 7px 7px 7px;opacity: 1;">
                 <el-select v-model="formData.type" placeholder="请选择类别" clearable :style="{width: '100%'}"  >
                 <el-select v-model="formData.type" placeholder="请选择类别" clearable :style="{width: '100%'}"   :disabled="dsb">
                   <el-option v-for="(item, index) in typeOptions" :key="index" :label="item.label" :value="item.value"
                   ></el-option>
                 </el-select>
                 <el-input v-model="newOption" v-if="showInput" placeholder="若未在上述选项中找到对应类别,请在此输入新的类别" @change="addNewOption"></el-input>
              </el-form-item>
             </el-cow>
             <el-cow >
@@ -74,7 +77,8 @@
            :http-request="requestUpload"
            :file-list="fileList"
          >
            <i slot="default" class="el-icon-plus"></i>
            <div v-if="uploading" class="upload-status">正在上传...</div>
            <i v-if="!uploading" slot="default" class="el-icon-plus"></i>
            <div slot="file" slot-scope="{file}">
              <img
                class="el-upload-list__item-thumbnail"
@@ -85,53 +89,33 @@
                :preview-src-list="[file.url]"
              >
              <span class="el-upload-list__item-actions" >
            <span
              v-if="isShow"
              class="el-upload-list__item-preview"
              @click="handlePictureCardPreview(file)"
            >
              <i class="el-icon-zoom-in"></i>
            </span>
            <span
              v-if="isShow"
              class="el-upload-list__item-delete"
              @click="handleDownload(file.url)"
            >
              <i class="el-icon-download"></i>
            </span>
            <span
              v-if="isShow"
              class="el-upload-list__item-delete"
              @click="handleRemove(file)"
            >
              <i class="el-icon-delete"></i>
            </span>
          </span>
                <span
                  class="el-upload-list__item-preview"
                  @click="handlePictureCardPreview(file)"
                >
                  <i class="el-icon-zoom-in"></i>
                </span>
                <span
                  class="el-upload-list__item-delete"
                  @click="handleDownload(file.url)"
                >
                  <i class="el-icon-download"></i>
                </span>
                <span
                  v-if="isShow"
                  class="el-upload-list__item-delete"
                  @click="handleRemove(file)"
                >
                  <i class="el-icon-delete"></i>
                </span>
              </span>
            </div>
          </el-upload>
          <!--<h4 class="form-header">其他附件 </h4>
          <el-upload
            action=""
            :file-list="fileListOther"
            class="upload-demo"
            multiple
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :http-request="requestUpload"
            :show-file-list="true"
          >
            <el-button v-if="isShow" type="primary" >点击上传</el-button>
            <template #tip>
              <div class="el-upload__tip">
              </div>
            </template>
          </el-upload>-->
          <h4 class="form-header">其他附件 </h4>
          <el-upload
            action=""
@@ -140,12 +124,13 @@
            multiple
            list-type="picture-card"
            :on-preview="handleFileCardPreview"
            :on-remove="handleRemove"
            :on-remove="handleRemoveFile"
            :http-request="requestUpload"
            :show-file-list="true"
          >
            <i slot="default" class="el-icon-plus"></i>
            <div v-if="uploading" class="upload-status">正在上传...</div>
            <i v-if="!uploading" slot="default" class="el-icon-plus"></i>
            <div slot="file" slot-scope="{file}">
              <img
                class="el-upload-list__item-thumbnail"
@@ -155,20 +140,19 @@
                fit="cover"
              >
              <span class="el-upload-list__item-actions">
                    <span v-if="isShow"
                    <span
                      class="el-upload-list__item-preview"
                      @click="handleFileCardPreview(file)"
                    >
                      <i class="el-icon-zoom-in"></i>
                    </span>
                    <span
                      v-if="isShow"
                      @click="handleRemove(file)"
                      class="el-upload-list__item-delete"
                      class="el-upload-list__item-delete"
                      @click="handleDownload(file.url)"
                    >
                      <i class="el-icon-download"></i>
                    </span>
                 <i class="el-icon-download"></i>
                 </span>
                    <span
                      v-if="isShow"
                      class="el-upload-list__item-delete"
@@ -191,7 +175,7 @@
    </div>
        <el-dialog  :visible.sync="dialogVisible">
          <img w-full :src="dialogImageUrl" alt="Preview Image" />
          <img w-full :src="dialogImageUrl"    style="width: 700px; height: 700px" alt="Preview Image" />
        </el-dialog>
@@ -203,7 +187,8 @@
import {blobValidate} from "@/utils/ruoyi";
import errorCode from "@/utils/errorCode";
import {Message} from "element-ui";
import {getCollection, updateCollection,download,uploadPic} from "@/api/collection/index";
import {getCollection, updateCollection,download,uploadPic,listType} from "@/api/collection/index";
export default {
  components: {},
@@ -212,7 +197,8 @@
    return {
      cdi:"收藏与荣誉详细信息",
      udi:"收藏与荣誉信息详情",
      fot:[".jpg",".jif"],
      fot:['.bmp','.jpg','.jpeg','.png','.tif','.gif','.pcx','.tga','.exif','.fpx',
        '.svg','.psd','.cdr','.pcd','.dxf','.ufo','.eps','.ai','.aw','.WMF','.webp','.apng'],
      fileList:[
      ],
      fileListOther:[
@@ -221,9 +207,10 @@
      dsb:true,
      btn:false,
      isShow:true,
      uploading: false,
      // 收藏与荣誉表格数据
     collectionList: [],
      typeList:[],
      formData: {
        //收藏与荣誉记录
        id:undefined,
@@ -284,30 +271,9 @@
        }],
      },
      typeOptions: [
        {
          value: '邮票',
          label: '邮票'
        }, {
          value: '日本军刀',
          label: '日本军刀'
        }, {
          value: '茅台酒',
          label: '茅台酒'
        }, {
          value: '红木',
          label: '红木'
        }, {
          value: '纪念品',
          label: '纪念品'
        }, {
          value: '瓷器',
          label: '瓷器'
        }, {
          value: '书籍',
          label: '书籍'
        }
      ],
      typeOptions: [],
      newOption: undefined,
      showInput: false
    }
  },
  computed: {},
@@ -320,12 +286,14 @@
      jd =  this.$route.query.detail
      this.btn= jd
      this.dsb = !jd
      this.showInput=true
      this.isShow=true
      document.title = "修改收藏与荣誉详细信息";
      this.$route.meta.title = "修改收藏与荣誉详细信息";//列表的名称
    }
    else{
      document.title = "查看收藏与荣誉详细信息";
      this.$route.meta.title = "查看收藏与荣誉详细信息";//列表的名称
      document.title = "收藏与荣誉详细信息";
      this.$route.meta.title = "收藏与荣誉详细信息";//列表的名称
      this.isShow=false
    }
@@ -353,6 +321,15 @@
        }
        this.loading = false;
      });
      listType(this.queryParams).then(response => {
          this.typeList = response.data;
          this.total = response.data.total;
          // console.log( this.typeList )
          // 在回调函数中调用 getTypeOptions()
          this.getTypeOptions();
          this.loading = false;
        }
      );
      // this.getCateInfor()
    }
@@ -370,6 +347,31 @@
    //     })
    //   })
    // },
    //类别
    addNewOption() {
      const newOption = this.newOption.trim();
      if (newOption && !this.typeOptions.includes(newOption)) {
        this.typeOptions.push(newOption);
        this.$set(this.formData, 'type', newOption); // 更新formDat.type的值为新的选项
      }
    },
    getTypeOptions() {
      const filteredOptions = this.typeList.filter(item => typeof item === 'string' && item !== '');
      // 创建一个空对象用于存储唯一的字符串选项
      const uniqueOptions = {};
      // 构建下拉选项列表
      this.typeOptions = filteredOptions.reduce((options, option) => {
        if (!uniqueOptions[option]) {
          uniqueOptions[option] = true;
          options.push({
            label: option,
            value: option
          });
        }
        return options;
      }, []);
    },
    submitForm() {
      let ul = this.fileList.map(function (elem){
        return elem.url.replace(process.env.VUE_APP_BASE_TRUE_API,"")
@@ -465,10 +467,11 @@
      var formData = new FormData();
      formData.append('uploadFile', file);
      let _this = this
      this.uploading = true;
      uploadPic(formData).then(response => {
        let pth = response.data.originalFilename.substr(response.data.originalFilename.length-4, response.data.originalFilename.length)
        this.uploading = false;
        this.$modal.msgSuccess("上传成功");
        if(_this.fot.includes(pth) === true)
        {
          _this.fileList.push({name:response.data.fileName, "url":response.data.url})