浏览代码

LY 用户签名

ly 3 年之前
父节点
当前提交
12431ec3ae

+ 1 - 0
master/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java

@@ -68,6 +68,7 @@ public class SysProfileController extends BaseController
             loginUser.getUser().setEmail(user.getEmail());
             loginUser.getUser().setSex(user.getSex());
             loginUser.getUser().setHomeType(user.getHomeType());
+            loginUser.getUser().setSignUrl(user.getSignUrl());
             tokenService.setLoginUser(loginUser);
             return AjaxResult.success();
         }

+ 6 - 6
master/src/main/resources/mybatis/intact/TIntactHiGjMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.project.intact.mapper.TIntactHiGjMapper">
-    
+
     <resultMap type="TIntactHiGj" id="TIntactHiGjResult">
         <result property="id"    column="id"    />
         <result property="plantCode"    column="plant_code"    />
@@ -84,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectTIntactHiGjList" parameterType="TIntactHiGj" resultMap="TIntactHiGjResult">
         <include refid="selectTIntactHiGjVo"/>
-        <where>  
+        <where>
             <if test="plantCode != null  and plantCode != ''"> and plant_code = #{plantCode}</if>
             <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
             <if test="devname != null  and devname != ''"> and devname like concat(concat('%', #{devname}), '%')</if>
@@ -149,7 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <!-- 数据范围过滤 -->
         ${params.dataScope}
     </select>
-    
+
     <select id="selectTIntactHiGjById" parameterType="Long" resultMap="TIntactHiGjResult">
         <include refid="selectTIntactHiGjVo"/>
         where id = #{id}
@@ -162,7 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         and d.del_flag = 0
     </select>
 
-        
+
     <insert id="insertTIntactHiGj" parameterType="TIntactHiGj">
         <selectKey keyProperty="id" resultType="long" order="BEFORE">
             SELECT seq_t_intacthi_gj.NEXTVAL as id FROM DUAL
@@ -377,5 +377,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="deleteTIntactHiGjByDevId" parameterType="Long">
         update t_intacthi_gj set del_flag = 2 where dev_id = #{devId} and hi_type = 1
     </update>
-    
-</mapper>
+
+</mapper>

+ 1 - 1
ui/src/views/system/user/index.vue

@@ -339,7 +339,7 @@
         </el-row>
         <el-row>
           <el-col :span="24">
-            <el-form-item :label="$t('签名')"  prop="locationUrl">
+            <el-form-item :label="$t('签名')"  prop="signUrl">
               <el-upload
                 class="avatar-uploader"
                 :action="signPic.url"

+ 1 - 0
ui/src/views/system/user/profile/index.vue

@@ -86,6 +86,7 @@ export default {
     getUser() {
       getUserProfile().then(response => {
         this.user = response.data;
+        this.user.imageUrl = process.env.VUE_APP_BASE_API +  this.user.signUrl
         this.roleGroup = response.roleGroup;
         this.postGroup = response.postGroup;
       });

+ 70 - 1
ui/src/views/system/user/profile/userInfo.vue

@@ -28,6 +28,20 @@
         ></el-option>
       </el-select>
     </el-form-item>
+    <el-form-item :label="$t('签名')">
+        <el-upload
+          v-if="imageUrl"
+          class="avatar-uploader"
+          :action="signPic.url"
+          :headers="signPic.headers"
+          :show-file-list="false"
+          :on-success="handleAvatarSuccess"
+          :before-upload="beforeAvatarUpload"
+        >
+          <img v-if="user.imageUrl" :src="user.imageUrl" class="avatar">
+          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+        </el-upload>
+    </el-form-item>
     <el-form-item>
       <el-button type="primary" size="mini" @click="submit">保存</el-button>
       <el-button type="danger" size="mini" @click="close">关闭</el-button>
@@ -37,6 +51,7 @@
 
 <script>
 import { updateUserProfile } from "@/api/system/user";
+import {getToken} from "@/utils/auth";
 
 export default {
   props: {
@@ -47,6 +62,14 @@ export default {
   data() {
     return {
       homeTypeOptions: [],
+      signPic: {
+        fileList: [],
+        // 设置上传的请求头部
+        headers: { Authorization: "Bearer " + getToken() },
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/system/user/uploadFile",
+      },
+      imageUrl: true,
       // 表单校验
       rules: {
         nickName: [
@@ -89,7 +112,53 @@ export default {
     close() {
       this.$store.dispatch("tagsView/delView", this.$route);
       this.$router.push({ path: "/index" });
-    }
+    },
+    handleAvatarSuccess(res, file) {
+      this.$set(this.user, 'imageUrl', URL.createObjectURL(file.raw))
+      this.imageUrl = false
+      this.user.signUrl = res.msg
+      this.imageUrl = true
+    },
+    beforeAvatarUpload(file) {
+      const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
+      const isLt2M = file.size / 1024 / 1024 < 2;
+      if (!isJPG) {
+        this.$message.error('上传图片只能是 JPG、png 格式!');
+      }
+      if (!isLt2M) {
+        this.$message.error('上传图片大小不能超过 2MB!');
+      }
+      return isJPG && isLt2M;
+    },
+    handlePictureCardPreview(file) {
+      this.dialogImageUrl = file.url;
+      this.dialogVisible = true;
+    },
   }
 };
 </script>
+<style>
+.avatar-uploader .el-upload {
+  border: 1px dashed #d9d9d9;
+  border-radius: 6px;
+  cursor: pointer;
+  position: relative;
+  overflow: hidden;
+}
+.avatar-uploader .el-upload:hover {
+  border-color: #409EFF;
+}
+.avatar-uploader-icon {
+  font-size: 28px;
+  color: #8c939d;
+  width: 178px;
+  height: 178px;
+  line-height: 178px;
+  text-align: center;
+}
+.avatar {
+  width: 178px;
+  height: 178px;
+  display: block;
+}
+</style>