yz3456
2024-04-15 28301a7a64c7092e985d2c4f261d4892245995de
ruoyi-ui/src/views/pet/petnote.vue
@@ -0,0 +1,719 @@
<template>
  <div class="app-container" style="opacity: 1;">
    <div class="box1"><h2>{{name}}的备忘本</h2></div>
    <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="['system:role:add']"
        >新增</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="['system:role: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="['family:note:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExportTemplate"
          v-hasPermi="['family:note:export']"
        >导入模板下载</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-upload
          action=""
          class="upload-demo"
          :show-file-list="false"
          :http-request="handleEnport"
        >
          <el-button size="mini"   type="primary"
                     plain
                    icon="el-icon-top"  >导入</el-button>
        </el-upload>
      </el-col>
    </el-row>
    <el-table v-loading="loading" :data="PetNoteList"  @selection-change="handleSelectionChange" :row-class-name="tableRowClassName" style="background: #FFEFF2;  border-radius: 14px 14px 14px 14px;width: 100%;">
      <el-table-column type="selection" width="55"  align="center" />
      <el-table-column  label="序号" sortable type="index" :index="(queryParams.pageNum-1)*queryParams.pageSize+1" width="80px"/>
      <el-table-column label="日期" prop="happenTime" sortable width="200px" align="center">
        <template slot-scope="scope">{{scope.row.happenTime? scope.row.happenTime: '————'}}</template>
      </el-table-column>
      <el-table-column label="题名" prop="title" sortable width="120px" />
      <el-table-column label="提醒时间" prop="remindTime" sortable width="200px" align="center">
        <template slot-scope="scope">{{scope.row.remindTime? scope.row.remindTime: '————'}}</template>
      </el-table-column>
      <el-table-column label="备注" prop="remark" sortable width="200px" />
      <el-table-column label="电子文件" prop="url" width="120px" >
        <template slot-scope="scope" >
          <div  @click="handleCheck(scope.row)">
            <img
              class="el-upload-list__item-thumbnail"
              src="../../assets/images/deviceLis.png"
              alt=""
              style="width: 35px; height: 35px;"
              fit="cover"
              v-if="!(scope.row.url === '' || scope.row.url === ',' || scope.row.url === null)"
            >
            <img
              v-else
              class="el-upload-list__item-thumbnail"
              src="../../assets/images/deviceA.png"
              alt=""
              style="width: 35px; height: 35px;"
              fit="cover"
            ></div>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope" v-if="scope.row.roleId !== 1">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['familymodel:economy:info']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            class="button_delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:role:remove']"
          > <sapn v-html="'\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'"></sapn></el-button>
          <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['familymodel:property:info']">
            <el-button size="mini" type="text" icon="el-icon-d-arrow-right"  @click="handleCheck(scope.row)">查看详情</el-button>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
      style="background: #FEF7FC;"
    />
    <!-- 添加或修改资产信息配置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="elForm" :model="formDat" :rules="rules" size="medium" label-width="100px">
        <el-form-item label="时间" prop="happenTime">
          <el-date-picker
            v-model='formDat.happenTime'
            type='date'
            placeholder='选择日期'
         value-format="yyyy-MM-dd"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="题名" prop="title">
          <el-input v-model="formDat.title" placeholder="请输入题名" clearable :style="{width: '100%'}" >
          </el-input>
        </el-form-item>
        <el-form-item label="提醒时间" prop="remindTime">
          <el-date-picker
            v-model='formDat.remindTime'
            type='date'
            placeholder='选择日期'
         value-format="yyyy-MM-dd"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="formDat.remark" placeholder="请输入备注" clearable :style="{width: '100%'}" >
          </el-input>
        </el-form-item>
        <h4 class="form-header">相关图片 </h4>
        <el-upload
          action="#"
          list-type="picture-card"
          multiple
          :http-request="requestUpload"
          :file-list="fileList"
        :on-change="handleChange"
        :auto-upload="false"
           ref="upload"
        >
          <i slot="default" class="el-icon-plus"></i>
          <div slot="file" slot-scope="{file}">
            <img
              class="el-upload-list__item-thumbnail"
              :src="file.url"
              alt=""
              style="width: 126px; height: 126px"
              fit="cover"
              :preview-src-list="[file.url]"
            >
            <span class="el-upload-list__item-actions">
        <span
          class="el-upload-list__item-preview"
          @click="handlePictureCardPreview(file)"
        >
          <i class="el-icon-zoom-in"></i>
        </span>
        <span
          v-if="!disabled"
          class="el-upload-list__item-delete"
          @click="handleRemove(file)"
        >
          <i class="el-icon-delete"></i>
        </span>
      </span>
          </div>
        </el-upload>
      <el-button
               style="margin-left: 10px"
               size="small"
               type="success"
               @click="picUpload"
             >上传到服务器</el-button>
        <h4 class="form-header">其他附件 </h4>
        <el-upload
          action=""
          :file-list="fileListOther"
          class="upload-demo"
          multiple
          :on-remove="handleRemoveFile"
          :show-file-list="true"
        ref="upload1"
        :on-change="handleChange1"
        :auto-upload="false"
        list-type="picture-card"
          :http-request="requestUpload1"
        >
          <el-button type="primary">点击上传</el-button>
          <template #tip>
            <div class="el-upload__tip">
            </div>
          </template>
        </el-upload>
<el-button
                style="margin-left: 10px"
                size="small"
                type="success"
                @click="fileUpload"
              >上传到服务器</el-button>
      </el-form>
      <h4 class="form-header"> </h4>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitDataScope">确 定</el-button>
        <el-button @click="cancelData">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 分配角色数据权限对话框 -->
    <el-dialog :title="title" :visible.sync="openDataScope" width="500px" append-to-body>
    </el-dialog>
  </div>
</template>
<script>
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role";
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
//在system/note/index.js中导入接口函数  --接好了
import {listPetnote,addPetnote,enload,delPetnote,updatenotePet,getPetList, uploadPic} from "@/api/pet/index";
import { TimeSelect } from "element-ui";
export default {
  name: "Role",
  dicts: ['sys_normal_disable'],
  data() {
    return {
      // 遮罩层
      name:'',
      disabled: false,
      loading: true,
      formData:{},
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 家大事记表格数据
      memoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层(数据权限)
      openDataScope: false,
      menuExpand: false,
      menuNodeAll: false,
      deptExpand: true,
      deptNodeAll: false,
      // 日期范围
      dateRange: [],
      // 数据范围选项
      // 数据范围选项
      fot:['.bmp','.jpg','.jpeg','.png','.tif','.gif','.pcx','.tga','.exif','.fpx',
        '.svg','.psd','.cdr','.pcd','.dxf','.ufo','.eps','.ai','.aw','.WMF','.webp','.apng'],
      fileList:[
      ],
      fileList1:[],
           uploadFileList: [],
            uploadFileList1: [],
      fileListOther:[],
      dsb:true,
      btn:false,
      PetNoteList:{},
      petList:{},
      formDat: {
        fid:undefined,
        remindTime:undefined,
        url:'',
        title: undefined,
        happenTime: undefined,
      },
      // 菜单列表
      menuOptions: [],
      // 部门列表
      deptOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 表单校验
      rules: {
        happenTime: [{
          required: true,
          message: '请选择日期选择',
          trigger: 'change'
        }],
        remindTime: [{
          required: true,
          message: '请选择日期选择',
          trigger: 'change'
        }],
        title: [{
          required: true,
          message: '请输入内容',
          trigger: 'blur'
        }],
        fid: [{
          required: true,
          // message: '请输入内容',
          // trigger: 'blur'
        }],
        remark: [{
          // required: true,
          message: '请输入备注',
          trigger: 'blur'
        }],
      },
      typeOptions: [],
    };
  },
  created() {
    this.getList()
  },
  methods: {
    // 取消按钮
    cancelData() {
      this.open = false;
      this.reset();
    },
    //隔行变色
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 0) {
        return "statistics-warning-row1";
      } else {
        return "statistics-warning-row";
      }
    },
    /** 查询角色列表 */
    getList() {
      const id = this.$route.params && this.$route.params.id;
      getPetList(id).then(response =>{
        this.name = response.data.name;
      })
      const pid = id;
      this.loading = true;
      listPetnote({pid}).then(response => {
        this.PetNoteList = response.data.data;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    handleRemove(file) {
      for(let i = 0; i < this.fileList.length; i++)
      {
        if(this.fileList[i].url==file.url)
        {
          this.$delete(this.fileList,i);
             this.$delete(this.uploadFileList,i);
             }
            //alert(this.formData.url)
      }
    },
   handleRemoveFile(file) {
     for(let i = 0; i < this.fileListOther.length; i++)
     {
       if(this.fileListOther[i].url==file.url)
      {
         this.$delete(this.fileListOther,i);
        this.$delete(this.uploadFileList1,i);
        }
     }
   },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    getRowId(row)
    {
      return row.id
    },
    // 取消按钮(数据权限)
    cancelDataScope() {
      this.openDataScope = false;
      this.reset();
    },
    // 表单重置
    reset() {
      if (this.$refs.menu != undefined) {
        this.$refs.menu.setCheckedKeys([]);
      }
      this.menuExpand = false,
        this.menuNodeAll = false,
        this.deptExpand = true,
        this.deptNodeAll = false,
        this.form = {
          roleId: undefined,
          roleName: undefined,
          roleKey: undefined,
          roleSort: 0,
          status: "0",
          menuIds: [],
          deptIds: [],
          menuCheckStrictly: true,
          deptCheckStrictly: true,
          remark: undefined
        };
      this.resetForm("form");
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      console.log(this.ids)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增备忘本";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      const id = row.id;
      let jd = true
      this.$router.push({
        path:"/familymodel/pet/noteInfo/" + id,
        query:{
          detail:jd
        }
      });
    },
    /** 查看详细信息 */
    handleCheck(row){
      const id = row.id;
      this.$router.push("/familymodel/pet/noteInfo/" + id);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    /** 提交按钮(数据权限) */
    submitDataScope: function() {
      const pid = this.$route.params && this.$route.params.id;
      // let ul = this.fileList.map(function (elem){
      //   return elem.url.replace(process.env.VUE_APP_BASE_TRUE_API,"")
      // }).join(",")
      // let uls = this.fileListOther.map(function (elem){
      //   return elem.url.replace(process.env.VUE_APP_BASE_TRUE_API,"")
      // }).join(",")
      this.formDat.pid = pid;
      // console.log(this.formDat,'formDatformDatformDatformDat')
      // this.formDat.url = ul+","+uls
      this.$refs["elForm"].validate(valid => {
        if (valid) {
      //   alert(33)
          addPetnote(this.formDat).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.open = false;
            this.getList();
          });
        }
      });
      //清空formDat对象的数据
      Object.keys(this.formDat).forEach(key => {
        this.formDat[key] = '';
      });
    },
    handleChange(file, fileList1) {
          //定义一个全局数组uploadFileList来做存储
        // this.uploadFileList.push(file.raw);
         console.log("=========5555=========")
         console.log(file)
       //  console.log(this.uploadFileList)
       //  this.fileList = fileList
       //alert(file)
           this.uploadFileList.push(file.raw);
            this.fileList.push({name:file.name,url:file.url})
       //alert(fileList1.length)
       },
       handleChange1(file, fileOtherList1) {
          //定义一个全局数组uploadFileList来做存储
       this.uploadFileList1.push(file.raw);
        this.fileListOther.push({name:file.name,url:file.url})
        // this.uploadFileList.push(file.raw);
         console.log("=========5555=========")
         //console.log(file)
       //  console.log(this.uploadFileList)
       //  this.fileList = fileList
       },
       fileUpload(){
       //   var file = params.file;
          var formData = new FormData();
       //   this.$refs.upload1.submit();
          // formData.append('uploadFile', file);
          if(this.uploadFileList1.length==0){
               this.$modal.msgSuccess("文档上传列表不能为空!");
               return
          }
          this.uploadFileList1.forEach((elem)=>{
             formData.append("files", elem)
          })
          let _this = this
          this.uploading = true;
          uploadPic(formData).then(response => {
          _this.uploadFileList1 = []
          _this.formDat.url = _this.formDat.url+","+response.fileNames
          _this.$modal.msgSuccess("文件上传成功!");
            })
       },
       picUpload()
       {
          var formData = new FormData();
          //alert(976)
          //this.$refs.upload.submit();
          //alert(8)
          //alert(this.uploadFileList.length)
       if(this.uploadFileList.length==0){
            this.$modal.msgSuccess("图片上传列表不能为空!");
            return}
       //console.log(this.uploadFileList)
          this.uploadFileList.forEach((elem)=>{
             formData.append("files", elem)
          })
          //alert(90)
          let _this = this
          //alert(9)
           uploadPic(formData).then(response => {
          //   alert("dds")
             _this.formDat.url = _this.formDat.url+","+response.fileNames
           alert(_this.formDat.url)
            _this.uploadFileList = []
            _this.$modal.msgSuccess("图片上传成功");
         });
        // console.log(this.formDat,'formDatformDatformDatformDat')
       },
        requestUpload(params) {
    //alert(98)
     //    this.uploadFileList.push(params.file);
        },
        requestUpload1(params)
        {
          //     this.uploadFileList1.push(params.file);
        },
    /** 删除按钮操作 */
    handleDelete(row) {
      const Ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除所选数据项?').then(function() {
        return delPetnote(Ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const pid = this.$route.params && this.$route.params.id;
      const queryParams = {
        pid: pid,
        ...this.queryParams
      };
      if (Object.keys(queryParams).length === 1 && 'pid' in queryParams) {
        this.download('/family/zfPetNote/export', queryParams, `zfPetNote_${new Date().getTime()}.xlsx`);
      } else {
        const Ids = this.ids;
        if (Ids.length === 0) {
          this.download('/family/zfPetNote/export', this.queryParams, `zfPetNote_${new Date().getTime()}.xlsx`);
        } else {
          this.download('/family/zfPetNote/export1/' + Ids, {}, `zfPetNote_${new Date().getTime()}.xlsx`);
        }
      }
    },
    //导入模板下载
    handleExportTemplate(){
      this.download('/family/zfPetNote/model', {
      }, `PetNote_${new Date().getTime()}.xlsx`)
    },
    /** 导入操作*/
    handleEnport(params, pid) {
      this.pid = this.$route.params && this.$route.params.id;
      var file = params.file;
      var formData = new FormData();
      formData.append('excelImport', file);
      formData.append('pid', pid); // 添加导入到哪个 ID 的信息
      console.log(this.pid);
      let _this = this;
      enload(formData)
        .then(response => {
          _this.getList();
          Message({ message: "导入成功", type: 'warning' });
        })
        .catch(error => {
          Message({ message: "导入失败", type: 'error' });
        });
    }
  },
  //  弹窗
  handleShow(scope){
    this.openDataScope = true
    this.getList()
  }
};
</script>
<style>
.el-table__row.statistics-warning-row {
  background: #EBFFF2;
}
.el-table__row.statistics-warning-row1 {
  background: #FFEFF2;
}
.button1 {
  background:center no-repeat url('../../assets/icons/add1.png') ;
  /* margin-left: 69.5vw; */
  margin-left: 95%;
}
.button_delete {
  background: center no-repeat url('../../assets/images/删除2.png') ;
  /* margin-left: 66vw; */
  width: 5px;
}
.box1,.button1{
  display: inline-block;
}
</style>