dev01 1 year ago
parent
commit
6b3c2491fa

+ 34 - 34
src/components/ImageUpload/index.vue

@@ -15,25 +15,23 @@
       :headers="headers"
       :file-list="fileList"
       :on-preview="handlePictureCardPreview"
-      :class="{hide: this.fileList.length >= this.limit}"
+      :class="{ hide: this.fileList.length >= this.limit }"
     >
       <i class="el-icon-plus"></i>
     </el-upload>
-    
+
     <!-- 上传提示 -->
     <div class="el-upload__tip" slot="tip" v-if="showTip">
-      请上传
-      <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
-      <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
+      <template v-if="fileSize">
+        大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
+      </template>
+      <template v-if="fileType">
+        格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b>
+      </template>
       的文件
     </div>
 
-    <el-dialog
-      :visible.sync="dialogVisible"
-      title="预览"
-      width="800"
-      append-to-body
-    >
+    <el-dialog :visible.sync="dialogVisible" title="预览" width="800" append-to-body>
       <img
         :src="dialogImageUrl"
         style="display: block; max-width: 100%; margin: 0 auto"
@@ -55,7 +53,7 @@ export default {
     },
     // 大小限制(MB)
     fileSize: {
-       type: Number,
+      type: Number,
       default: 5,
     },
     // 文件类型, 例如['png', 'jpg', 'jpeg']
@@ -66,8 +64,8 @@ export default {
     // 是否显示提示
     isShowTip: {
       type: Boolean,
-      default: true
-    }
+      default: true,
+    },
   },
   data() {
     return {
@@ -81,7 +79,7 @@ export default {
       headers: {
         Authorization: "Bearer " + getToken(),
       },
-      fileList: []
+      fileList: [],
     };
   },
   watch: {
@@ -89,14 +87,14 @@ export default {
       handler(val) {
         if (val) {
           // 首先将值转为数组
-          const list = Array.isArray(val) ? val : this.value.split(',');
+          const list = Array.isArray(val) ? val : this.value.split(",");
           // 然后将数组转为对象数组
-          this.fileList = list.map(item => {
+          this.fileList = list.map((item) => {
             if (typeof item === "string") {
               if (item.indexOf(this.baseUrl) === -1) {
-                  item = { name: this.baseUrl + item, url: this.baseUrl + item };
+                item = { name: this.baseUrl + item, url: this.baseUrl + item };
               } else {
-                  item = { name: item, url: item };
+                item = { name: item, url: item };
               }
             }
             return item;
@@ -107,8 +105,8 @@ export default {
         }
       },
       deep: true,
-      immediate: true
-    }
+      immediate: true,
+    },
   },
   computed: {
     // 是否显示提示
@@ -125,7 +123,7 @@ export default {
         if (file.name.lastIndexOf(".") > -1) {
           fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
         }
-        isImg = this.fileType.some(type => {
+        isImg = this.fileType.some((type) => {
           if (file.type.indexOf(type) > -1) return true;
           if (fileExtension && fileExtension.indexOf(type) > -1) return true;
           return false;
@@ -135,7 +133,9 @@ export default {
       }
 
       if (!isImg) {
-        this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`);
+        this.$modal.msgError(
+          `文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`
+        );
         return false;
       }
       if (this.fileSize) {
@@ -167,8 +167,8 @@ export default {
     },
     // 删除图片
     handleDelete(file) {
-      const findex = this.fileList.map(f => f.name).indexOf(file.name);
-      if(findex > -1) {
+      const findex = this.fileList.map((f) => f.name).indexOf(file.name);
+      if (findex > -1) {
         this.fileList.splice(findex, 1);
         this.$emit("input", this.listToString(this.fileList));
       }
@@ -202,25 +202,25 @@ export default {
           strs += list[i].url.replace(this.baseUrl, "") + separator;
         }
       }
-      return strs != '' ? strs.substr(0, strs.length - 1) : '';
-    }
-  }
+      return strs != "" ? strs.substr(0, strs.length - 1) : "";
+    },
+  },
 };
 </script>
 <style scoped lang="scss">
 // .el-upload--picture-card 控制加号部分
 ::v-deep.hide .el-upload--picture-card {
-    display: none;
+  display: none;
 }
 // 去掉动画效果
 ::v-deep .el-list-enter-active,
 ::v-deep .el-list-leave-active {
-    transition: all 0s;
+  transition: all 0s;
 }
 
-::v-deep .el-list-enter, .el-list-leave-active {
-    opacity: 0;
-    transform: translateY(0);
+::v-deep .el-list-enter,
+.el-list-leave-active {
+  opacity: 0;
+  transform: translateY(0);
 }
 </style>
-

+ 23 - 4
src/layout/components/Sidebar/Logo.vue

@@ -11,7 +11,11 @@
   >
     <transition name="sidebarLogoFade">
       <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
-        <img v-if="logo" :src="logo" class="sidebar-logo" />
+        <img
+          v-if="company.companyLogo"
+          :src="realSrc(company.companyLogo)"
+          class="sidebar-logo"
+        />
         <h1
           v-else
           class="sidebar-title"
@@ -22,11 +26,15 @@
                 : variables.logoLightTitleColor,
           }"
         >
-          {{ title }}
+          {{ company.companyFullName }}
         </h1>
       </router-link>
       <router-link v-else key="expand" class="sidebar-logo-link" to="/">
-        <img v-if="logo" :src="logo" class="sidebar-logo" />
+        <img
+          v-if="company.companyLogo"
+          :src="realSrc(company.companyLogo)"
+          class="sidebar-logo"
+        />
         <h1
           class="sidebar-title"
           :style="{
@@ -36,7 +44,7 @@
                 : variables.logoLightTitleColor,
           }"
         >
-          {{ title }}
+          {{ company.companyFullName }}
         </h1>
       </router-link>
     </transition>
@@ -46,6 +54,7 @@
 <script>
 import logoImg from "@/assets/logo/logo.png";
 import variables from "@/assets/styles/variables.scss";
+import { mapGetters } from "vuex";
 
 export default {
   name: "SidebarLogo",
@@ -56,6 +65,7 @@ export default {
     },
   },
   computed: {
+    ...mapGetters(["company"]),
     variables() {
       return variables;
     },
@@ -69,6 +79,14 @@ export default {
       logo: logoImg,
     };
   },
+  methods: {
+    realSrc(src) {
+      if (!src) {
+        return;
+      }
+      return process.env.VUE_APP_BASE_API + src;
+    },
+  },
 };
 </script>
 
@@ -98,6 +116,7 @@ export default {
     & .sidebar-logo {
       width: 32px;
       height: 32px;
+      border-radius: 50%;
       vertical-align: middle;
       margin-right: 5px;
     }

+ 1 - 0
src/store/getters.js

@@ -11,6 +11,7 @@ const getters = {
   nickname: state => state.user.nickname,
   introduction: state => state.user.introduction,
   roles: state => state.user.roles,
+  company: state => state.user.company,
   permissions: state => state.user.permissions,
   permission_routes: state => state.permission.routes,
   topbarRouters:state => state.permission.topbarRouters,

+ 8 - 2
src/store/modules/user.js

@@ -8,7 +8,8 @@ const user = {
     nickname: '',
     avatar: '',
     roles: [],
-    permissions: []
+    permissions: [],
+    company: {},
   },
 
   mutations: {
@@ -29,7 +30,10 @@ const user = {
     },
     SET_PERMISSIONS: (state, permissions) => {
       state.permissions = permissions
-    }
+    },
+    SET_COMPANY: (state, company) => {
+      state.company = company
+    },
   },
 
   actions: {
@@ -65,6 +69,7 @@ const user = {
           commit('SET_NAME', user.userName)
           commit('SET_NICKNAME', user.nickName)
           commit('SET_AVATAR', avatar)
+          commit('SET_COMPANY', res.company)
           resolve(res)
         }).catch(error => {
           reject(error)
@@ -79,6 +84,7 @@ const user = {
           commit('SET_TOKEN', '')
           commit('SET_ROLES', [])
           commit('SET_PERMISSIONS', [])
+          commit('SET_COMPANY', {})
           removeToken()
           resolve()
         }).catch(error => {

+ 4 - 20
src/views/project/list/index.vue

@@ -318,30 +318,14 @@ export default {
       // 表单校验
       rules: {
         projectNumber: [
-          { required: true, message: "用户名称不能为空", trigger: "blur" },
-          { min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur' }
+          { required: true, message: "项目编号不能为空", trigger: "blur" },
         ],
         name: [
-          { required: true, message: "用户昵称不能为空", trigger: "blur" }
+          { required: true, message: "项目名称不能为空", trigger: "blur" }
         ],
-        password: [
-          { required: true, message: "用户密码不能为空", trigger: "blur" },
-          { min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' }
+        aid:[
+          { required: true, message: "负责人不能为空", trigger: "blur" }
         ],
-        email: [
-          {
-            type: "email",
-            message: "请输入正确的邮箱地址",
-            trigger: ["blur", "change"]
-          }
-        ],
-        phonenumber: [
-          {
-            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
-            message: "请输入正确的手机号码",
-            trigger: "blur"
-          }
-        ]
       }
     };
   },

+ 65 - 3
src/views/system/dept/index.vue

@@ -67,7 +67,6 @@
       :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
     >
       <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
-      <!-- <el-table-column prop="deptName" label="公司名称" width="260"></el-table-column> -->
       <el-table-column
         prop="maxDuration"
         align="center"
@@ -90,6 +89,21 @@
           <span>{{ parseTime(scope.row.createTime) }}</span>
         </template>
       </el-table-column>
+      <el-table-column label="logo" align="center" prop="companyLogo">
+        <template slot-scope="scope">
+          <el-image
+            style="width: 50px; height: 50px"
+            :src="realSrc(scope.row.companyLogo)"
+            :preview-src-list="[realSrc(scope.row.companyLogo)]"
+          >
+          </el-image>
+        </template>
+      </el-table-column>
+      <el-table-column
+        prop="companyFullName"
+        align="center"
+        label="简称"
+      ></el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -122,7 +136,13 @@
     </el-table>
 
     <!-- 添加或修改部门对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
+    <el-dialog
+      :title="title"
+      :visible.sync="open"
+      width="700px"
+      append-to-body
+      :close-on-click-modal="false"
+    >
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-row>
           <el-col :span="24" v-if="form.parentId !== 0">
@@ -132,6 +152,7 @@
                 :options="deptOptions"
                 :normalizer="normalizer"
                 placeholder="选择上级部门"
+                @select="treeSelectChange"
               />
             </el-form-item>
           </el-col>
@@ -152,6 +173,21 @@
             </el-form-item>
           </el-col>
         </el-row>
+        <el-row v-if="isERP">
+          <el-col :span="12">
+            <el-form-item label="企业logo" prop="companyLogo">
+              <ImageUpload v-model="form.companyLogo" :limit="1" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="企业简称" prop="companyFullName">
+              <el-input
+                v-model="form.companyFullName"
+                placeholder="限制8个字符以内,如科德研发工时系统"
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
         <el-row>
           <el-col :span="12">
             <el-form-item label="负责人" prop="leader">
@@ -199,7 +235,7 @@
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <div style="color: red; line-height: 36px; margin-left:10px">
+            <div style="color: red; line-height: 36px; margin-left: 10px">
               注:默认最高工时为8
             </div>
           </el-col>
@@ -231,6 +267,7 @@ export default {
   components: { Treeselect },
   data() {
     return {
+      isERP: false,
       // 遮罩层
       loading: true,
       // 显示搜索条件
@@ -259,6 +296,14 @@ export default {
         parentId: [{ required: true, message: "上级部门不能为空", trigger: "blur" }],
         deptName: [{ required: true, message: "部门名称不能为空", trigger: "blur" }],
         orderNum: [{ required: true, message: "显示排序不能为空", trigger: "blur" }],
+        companyLogo: [{ required: true, message: "请上传企业logo", trigger: "blur" }],
+        companyFullName: [
+          {
+            required: true,
+            message: "限制8个字符以内,如科德研发工时系统",
+            trigger: "blur",
+          },
+        ],
         email: [
           {
             type: "email",
@@ -338,6 +383,9 @@ export default {
       this.title = "添加部门";
       listDept().then((response) => {
         this.deptOptions = this.handleTree(response.data, "deptId");
+        this.form.parentId = response.data[0].deptId;
+        // parentId == 100为创建公司
+        this.isERP = response.data[0].parentId == 100;
       });
     },
     /** 展开/折叠操作 */
@@ -371,6 +419,10 @@ export default {
     /** 提交按钮 */
     submitForm: function () {
       this.$refs["form"].validate((valid) => {
+        if (!this.isERP) {
+          delete this.form["companyLogo"];
+          delete this.form["companyFullName"];
+        }
         if (valid) {
           if (this.form.deptId != undefined) {
             updateDept(this.form).then((response) => {
@@ -401,6 +453,16 @@ export default {
         })
         .catch(() => {});
     },
+    /**图片显示处理 */
+    realSrc(src) {
+      if (!src) {
+        return;
+      }
+      return process.env.VUE_APP_BASE_API + src;
+    },
+    treeSelectChange(value) {
+      this.isERP = value.parentId == 100;
+    },
   },
 };
 </script>

+ 63 - 68
src/views/system/user/index.vue

@@ -55,18 +55,18 @@
               @keyup.enter.native="handleQuery"
             />
           </el-form-item>
-          <el-form-item label="职位" prop="postId">
+          <el-form-item label="职位" prop="roleId">
             <el-select
-              v-model="queryParams.postId"
+              v-model="queryParams.roleId"
               placeholder="请选择职位"
               clearable
               style="width: 240px"
             >
               <el-option
-                v-for="item in postOptions"
-                :key="item.postId"
-                :label="item.postName"
-                :value="item.postId"
+                v-for="item in roleOptions"
+                :key="item.roleId"
+                :label="item.roleName"
+                :value="item.roleId"
               />
             </el-select>
           </el-form-item>
@@ -283,8 +283,8 @@
           <el-table-column
             label="职位"
             align="center"
-            key="postName"
-            prop="postName"
+            key="roleName"
+            prop="roleName"
             v-if="columns[4].visible"
             :show-overflow-tooltip="true"
           />
@@ -488,6 +488,56 @@
           </el-col>
         </el-row>
         <el-row>
+          <!-- <el-col :span="12">
+            <el-form-item label="岗位" prop="postIds">
+              <el-select
+                v-model="form.postIds"
+                multiple
+                placeholder="请选择岗位"
+                style="width: 240px"
+              >
+                <el-option
+                  v-for="item in postOptions"
+                  :key="item.postId"
+                  :label="item.postName"
+                  :value="item.postId"
+                  :disabled="item.status == 1"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col> -->
+          <el-col :span="12">
+            <el-form-item label="角色" prop="roleIds">
+              <el-select
+                v-model="form.roleIds"
+                multiple
+                placeholder="请选择角色"
+                style="width: 240px"
+              >
+                <el-option
+                  v-for="item in roleOptions"
+                  :key="item.roleId"
+                  :label="item.roleName"
+                  :value="item.roleId"
+                  :disabled="item.status == 1"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="用户性别">
+              <el-select v-model="form.sex" placeholder="请选择性别" style="width: 240px">
+                <el-option
+                  v-for="dict in dict.type.sys_user_sex"
+                  :key="dict.value"
+                  :label="dict.label"
+                  :value="dict.value"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
           <el-col :span="12">
             <el-form-item label="工号" prop="jobNumber">
               <el-input
@@ -530,10 +580,10 @@
         </el-row>
         <el-row>
           <el-col :span="12">
-            <el-form-item label="用户性别">
-              <el-select v-model="form.sex" placeholder="请选择性别" style="width: 240px">
+            <el-form-item label="兼职/全职" prop="fullJob">
+              <el-select v-model="form.fullJob" placeholder="请选择" style="width: 240px">
                 <el-option
-                  v-for="dict in dict.type.sys_user_sex"
+                  v-for="dict in dict.type.sys_user_fulljob"
                   :key="dict.value"
                   :label="dict.label"
                   :value="dict.value"
@@ -555,60 +605,6 @@
           </el-col>
         </el-row>
         <el-row>
-          <el-col :span="12">
-            <el-form-item label="岗位" prop="postIds">
-              <el-select
-                v-model="form.postIds"
-                multiple
-                placeholder="请选择岗位"
-                style="width: 240px"
-              >
-                <el-option
-                  v-for="item in postOptions"
-                  :key="item.postId"
-                  :label="item.postName"
-                  :value="item.postId"
-                  :disabled="item.status == 1"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="角色" prop="roleIds">
-              <el-select
-                v-model="form.roleIds"
-                multiple
-                placeholder="请选择角色"
-                style="width: 240px"
-              >
-                <el-option
-                  v-for="item in roleOptions"
-                  :key="item.roleId"
-                  :label="item.roleName"
-                  :value="item.roleId"
-                  :disabled="item.status == 1"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-        </el-row>
-
-        <el-row>
-          <el-col :span="12">
-            <el-form-item label="兼职/全职" prop="fullJob">
-              <el-select v-model="form.fullJob" placeholder="请选择" style="width: 240px">
-                <el-option
-                  v-for="dict in dict.type.sys_user_fulljob"
-                  :key="dict.value"
-                  :label="dict.label"
-                  :value="dict.value"
-                ></el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-        </el-row>
-
-        <el-row>
           <el-col :span="24">
             <el-form-item label="备注">
               <el-input
@@ -811,7 +807,6 @@ export default {
             trigger: "blur",
           },
         ],
-        postIds: [{ required: true, message: "岗位不能为空", trigger: "blur" }],
         roleIds: [{ required: true, message: "角色不能为空", trigger: "blur" }],
         fullJob: [{ required: true, message: "是否全职", trigger: "blur" }],
         email: [
@@ -932,7 +927,7 @@ export default {
         sex: undefined,
         status: "0",
         remark: undefined,
-        postIds: [],
+        // postIds: [],
         roleIds: [],
       };
       this.resetForm("form");
@@ -988,7 +983,7 @@ export default {
         this.form = response.data;
         this.postOptions = response.posts;
         this.roleOptions = response.roles;
-        this.$set(this.form, "postIds", response.postIds);
+        // this.$set(this.form, "postIds", response.postIds);
         this.$set(this.form, "roleIds", response.roleIds);
         this.open = true;
         this.title = "修改用户";