feige
2023-09-10 8319f67b9bec1d19c06eaa4216f0f34c67e3afb1
ruoyi-ui/src/views/collection/index.vue
@@ -69,22 +69,13 @@
      </el-form-item>
      <el-form-item label="类别" prop="type">
        <el-select
          v-model="queryParams.type"
          placeholder="所有类别"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        >
          <el-option
            v-for="item in typeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        <el-select v-model="queryParams.type" placeholder="所有类别" clearable
                   style="width: 240px" @keyup.enter.native="handleQuery">
          <el-option v-for="item in typeOptions"
                     :key="item.value" :label="item.label" :value="item.value"/>
        </el-select>
      </el-form-item>
      <el-cntainer>
        <el-col :span="9" >
          <el-form-item>
@@ -189,14 +180,14 @@
      </el-row>
    </div>
    <el-table v-loading="loading" :data="collectionList" :row-key="getRowId" ref="multipleTable" @selection-change="handleSelectionChange" :row-class-name="tableRowClassName" style="background: #FFEFF2;  border-radius: 14px 14px 14px 14px;">
      <el-table-column type="selection" :reserve-selection="true" width="25"  align="center" />
      <el-table-column type="selection" :reserve-selection="true" width="55"  align="center" />
      <el-table-column fixed label="序号" sortable type="index" :index="(queryParams.pageNum-1)*queryParams.pageSize+1" width="60"/>
      <el-table-column label="获得时间" prop="happenTime" sortable width="100" align="center">
        <template slot-scope="scope">{{scope.row.happenTime? scope.row.happenTime: '————'}}</template>
      </el-table-column>
      <el-table-column label="类别" prop="type" sortable width="120" align="center">
        <template slot-scope="scope">{{ getSrc(scope.row.type) }}</template>
<!--        <template slot-scope="scope">{{scope.row.type? scope.row.type: '————'}}</template>-->
<!--        <template slot-scope="scope">{{ getSrc(scope.row.type) }}</template>-->
        <template slot-scope="scope">{{scope.row.type? scope.row.type: '————'}}</template>
      </el-table-column>
      <el-table-column label="名称" prop="name" sortable :show-overflow-tooltip="true" width="120" align="center" >
        <template slot-scope="scope">{{scope.row.name? scope.row.name: '————'}}</template>
@@ -218,6 +209,9 @@
      <el-table-column label="备注" prop="remark" sortable width="90" align="center">
        <template slot-scope="scope">{{scope.row.remark? scope.row.remark: '————'}}</template>
      </el-table-column>
      <el-table-column label="是否是本家庭记录" prop="ownData" sortable width="150px" >
        <template slot-scope="scope">{{scope.row.ownData === 0 ? '否': '是'}}</template>
      </el-table-column>
      <el-table-column label="电子文件" prop="url" width="180" align="center">
        <template slot-scope="scope" >
@@ -228,7 +222,7 @@
              alt=""
              style="width: 35px; height: 35px;"
              fit="cover"
              v-if="!(scope.row.url === ',' || scope.row.url === null)"
              v-if="!(scope.row.url === '' || scope.row.url === ',' || scope.row.url === null)"
            >
            <img
              v-else
@@ -290,13 +284,16 @@
<!--          <el-input v-model="formDat.happenTime" placeholder="请输入获得时间" clearable :style="{width: '100%'}" ></el-input>-->
<!--        </el-form-item>-->
        <el-form-item label="获得时间" prop="happenTime">
          <el-input v-model='formDat.happenTime' type='date' clearable placeholder='选择日期'></el-input>
          <el-date-picker v-model="formDat.happenTime" type="date" placeholder="请选择日期"
             :editable="false" :clearable="false" :style="{width: '100%'}"  value-format="yyyy-MM-dd"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="类别" prop="type">
          <el-select v-model="formDat.type" placeholder="请选择类别" clearable :style="{width: '100%'}"  >
            <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-form-item label="名称" prop="name">
          <el-input v-model="formDat.name" placeholder="请输入名称" clearable :style="{width: '100%'}" >
@@ -323,7 +320,7 @@
          <el-input v-model="formDat.remark" placeholder="请输入备注" clearable :style="{width: '100%'}" ></el-input>
        </el-form-item>
        <h4 class="form-header">电子文件 </h4>
        <h4 class="form-header">相关图片 </h4>
        <el-upload
          action="#"
          list-type="picture-card"
@@ -373,6 +370,7 @@
          :show-file-list="true"
        >
          <el-button type="primary">点击上传</el-button>
          <div v-if="uploading" class="upload-status">正在上传...</div>
          <template #tip>
            <div class="el-upload__tip">
            </div>
@@ -403,8 +401,8 @@
//导入接口函数
import {listCollection, getCollection, addCollection,updateCollection, delCollection,uploadPic,downloadModel} from "@/api/collection/index";
import {enload} from "@/api/doctor";
import {listCollection,listType, getCollection, addCollection,updateCollection, delCollection,uploadPic,downloadModel,enload} from "@/api/collection/index";
import {Message} from "element-ui";
@@ -430,6 +428,7 @@
      total: 0,
      // 收藏与荣誉表格数据
      collectionList: [],
      typeList:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
@@ -443,16 +442,14 @@
      // 日期范围
      dateRange: [],
      // 数据范围选项
      fot:[".jpg",".jif"],
      fileList:[
      ],
      fileListOther:[
      ],
      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:[],
      dsb:true,
      btn:false,
      fit:['fill'],
      uploading: false,
      formDat: {
        //收藏与荣誉记录
        id:undefined,
@@ -533,35 +530,15 @@
          trigger: 'blur'
        }],
      },
      typeOptions: [
        {
          value: '邮票',
          label: '邮票'
        }, {
          value: '日本军刀',
          label: '日本军刀'
        }, {
          value: '茅台酒',
          label: '茅台酒'
        }, {
          value: '红木',
          label: '红木'
        }, {
          value: '纪念品',
          label: '纪念品'
        }, {
          value: '瓷器',
          label: '瓷器'
        }, {
          value: '书籍',
          label: '书籍'
        }
      ],
      typeOptions: [],
      newOption: undefined,
      showInput: true
    };
  },
  created() {
    this.getList();
    this.getCateInfor()
    this.getTypeOptions();
    // this.getCateInfor()
    // for (let i = 0; i < this.contactList.length; i++) {
    //   this.formDat[i] = this.contactList[i];
    // }
@@ -584,6 +561,14 @@
        return "statistics-warning-row";
      }
    },
    //类别
    addNewOption() {
      const newOption = this.newOption.trim();
      if (newOption && !this.typeOptions.includes(newOption)) {
        this.typeOptions.push(newOption);
        this.$set(this.formDat, 'type', newOption); // 更新formDat.type的值为新的选项
      }
    },
    /** 查询记录列表 */
    getList() {
      this.loading = true;
@@ -596,23 +581,48 @@
          //  alert(123)
          //   console.log(response.data)
          this.collectionList = response.data.data;
          this.total = response.data.total;
          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;
        }
      );
    },
    /** 查询类别信息 */
    getCateInfor()
    {
      let _this = this
      getCategory().then(response=>{
    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;
      }, []);
        response.data.itemValues.replace("{","").replace("}","").split(",").map(elem=>{
          _this.typeOptions.push({"label":elem.split(":")[0], "value":elem.split(":")[0]})
        })
      })
    },
    // /** 查询类别信息 */
    // getCateInfor()
    // {
    //   let _this = this
    //   getCategory().then(response=>{
    //
    //     response.data.itemValues.replace("{","").replace("}","").split(",").map(elem=>{
    //       _this.typeOptions.push({"label":elem.split(":")[0], "value":elem.split(":")[0]})
    //     })
    //   })
    // },
    //类别选择
    getSrc(type) {
      if (type === '邮票') {
@@ -761,8 +771,13 @@
      Object.keys(this.formDat).forEach(key => {
        this.formDat[key] = '';
      });
      this.handleRemove(this.fileList[0]);
      this.handleRemoveFile(this.fileListOther[0]);
      for(let i = 0; i <= this.fileList.length; i++)
      {
        this.handleRemove(this.fileList[0]);
      }
      for(let i = 0; i < this.fileListOther.length; i++){
        this.handleRemoveFile(this.fileListOther[0]);
      }
    },
    requestUpload(params)
    {
@@ -770,10 +785,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})