首页 > 其他分享 >若依table显示图片

若依table显示图片

时间:2023-03-11 11:23:39浏览次数:45  
标签:form ids 若依 eso table null true response 图片

在若依项目中使用预览图,并显示图片。

<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="患者姓名" prop="patientName">
        <el-input
          v-model="queryParams.patientName"
          placeholder="请输入患者姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="主治医师" prop="doctorName">
        <el-input
          v-model="queryParams.doctorName"
          placeholder="请输入主治医师"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        <el-date-picker clearable
          v-model="queryParams.createTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['eso:eso:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['eso:eso:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['eso:eso:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['eso:eso:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="esoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="患者姓名" align="center" prop="patientName" />
      <el-table-column label="主治医师" align="center" prop="doctorName" />
<!--      <el-table-column label="原始图片路径" align="center" prop="oriPic" />-->
      <el-table-column label="原始图片路径" align="center" prop="oriPic">
        <template v-slot:default="scope">
<!--          <el-image :src="require('@/assets/eso_image/original/'+scope.row.oriPic)" :preview-src-list="srcList">/>-->
          <el-image
            style="width: 100px; height: 100px"
            :src="require('@/assets/eso_image/original/'+scope.row.oriPic)"
            :preview-src-list="[require('@/assets/eso_image/original/'+scope.row.oriPic)]">
          </el-image>
        </template>
      </el-table-column>
<!--      <el-table-column label="指导图片路径" align="center" prop="segPic" />-->
      <el-table-column label="指导图片路径" align="center" prop="segPic">
        <template v-slot:default="scope">
<!--          <el-image :src="require('@/assets/eso_image/segmented/'+scope.row.segPic)"/>-->
          <el-image
            style="width: 100px; height: 100px"
            :src="require('@/assets/eso_image/segmented/'+scope.row.segPic)"
            :preview-src-list="[require('@/assets/eso_image/segmented/'+scope.row.segPic)]">
          </el-image>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['eso:eso:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['eso:eso:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改分割展示对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="患者姓名" prop="patientName">
          <el-input v-model="form.patientName" placeholder="请输入患者姓名" />
        </el-form-item>
        <el-form-item label="主治医师" prop="doctorName">
          <el-input v-model="form.doctorName" placeholder="请输入主治医师" />
        </el-form-item>
        <el-form-item label="原始图片路径" prop="oriPic">
          <el-input v-model="form.oriPic" placeholder="请输入原始图片路径" />
        </el-form-item>
        <el-form-item label="指导图片路径" prop="segPic">
          <el-input v-model="form.segPic" placeholder="请输入指导图片路径" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listEso, getEso, delEso, addEso, updateEso } from "@/api/eso/eso";

export default {
  name: "Eso",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 分割展示表格数据
      esoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        patientName: null,
        doctorName: null,
        createTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        patientName: [
          { required: true, message: "患者姓名不能为空", trigger: "blur" }
        ],
        doctorName: [
          { required: true, message: "主治医师不能为空", trigger: "blur" }
        ],
        oriPic: [
          { required: true, message: "原始图片路径不能为空", trigger: "blur" }
        ],
        segPic: [
          { required: true, message: "指导图片路径不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ]
      },
      srcList: [
        "../assets/eso_image/original/1.png"
        // 'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        // 'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
      ]
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询分割展示列表 */
    getList() {

      // console.log('@/assets/eso_image/original/'+'logo.png');
      this.loading = true;
      listEso(this.queryParams).then(response => {
        this.esoList = response.rows;
        this.total = response.total;
        this.loading = false;
        // console.log(response.rows,"table");
      });

    },

    getAddList(str){
      console.log(str);
      return str;
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        patientName: null,
        doctorName: null,
        oriPic: null,
        segPic: null,
        createTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
      console.log(this.esoList,"esoList")

    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加分割展示";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getEso(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改分割展示";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateEso(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addEso(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除分割展示编号为"' + ids + '"的数据项?').then(function() {
        return delEso(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('eso/eso/export', {
        ...this.queryParams
      }, `eso_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

标签:form,ids,若依,eso,table,null,true,response,图片
From: https://www.cnblogs.com/chenyi502/p/17205526.html

相关文章