Sfoglia il codice sorgente

提交用户分组代码

Lijy 9 mesi fa
parent
commit
74079b1e3a

+ 2 - 1
fhKeeper/formulahousekeeper/timesheet/src/i18n/en.json

@@ -29,7 +29,8 @@
     "caiwushenhe": "Financial review",
     "basicDataManagement": "Basic data management",
     "budgetReview": "Estimated working hours review",
-    "projectFormSettings": "Project Form Settings"
+    "projectFormSettings": "Project Form Settings",
+    "userGroupManagement": "User group management"
   },
   "role": {
     "ordinaryEmployees": "Ordinary employees",

+ 2 - 1
fhKeeper/formulahousekeeper/timesheet/src/i18n/zh.json

@@ -29,7 +29,8 @@
     "projectFormSettings": "项目表单设置",
     "budgetReview": "预估工时审核",
     "gongshitongji": "工时统计表",
-    "caiwushenhe": "财务审核"
+    "caiwushenhe": "财务审核",
+    "userGroupManagement": "用户分组管理"
   },
   "role": {
     "ordinaryEmployees": "普通员工",

+ 5 - 0
fhKeeper/formulahousekeeper/timesheet/src/permissions.js

@@ -145,6 +145,9 @@ const StringUtil = {
         importAudit: false, // 查看导审记录 //
 
         customDataAll: false,// 查看全公司数值-自定义数值统计模块
+
+        // 用户分组管理
+        userGroupManage: false,
         
     }
     // console.log(arr);
@@ -277,6 +280,8 @@ const StringUtil = {
         arr[i] == '查看全部立项申请'  ? obj.projectApprovalView = true : ''
         arr[i] == '管理全部立项申请'  ? obj.projectApprovalEdit = true : ''
         arr[i] == '审核立项申请' ? obj.projectApprovalCheck = true : ''
+
+        arr[i] == '用户分组管理' ? obj.userGroupManage = true : ''
     }
     return obj
   }

+ 4 - 0
fhKeeper/formulahousekeeper/timesheet/src/routes.js

@@ -96,6 +96,9 @@ import budgetReview from './views/project/budgetReview'
 // 财务审核
 import financeAudit from './views/financeAudit/financeAudit.vue'
 
+// 用户分组管理
+import userGrouping from './views/userGrouping/userGrouping.vue'
+
 Vue.use(Router)
 
 export const fixedRouter = [
@@ -505,6 +508,7 @@ export const allRouters = [//组织架构
         children: [
             { path: '/timetype', component: timetype, name: '系统基础设置', iconCls: 'iconfont firerock-iconxitong-', meta: { text: 'navigation.basicSystemSettings' }},
             { path: '/role', component: quanx, name: '角色权限管理', iconCls: 'iconfont firerock-iconquanxian1', meta: { text: 'navigation.roleRightsManagement' } },
+            { path: '/userGrouping', component: userGrouping, name: '用户分组管理', iconCls: 'iconfont firerock-iconquanxian1', meta: { text: 'navigation.userGroupManagement' } },
             { path: '/projectForm', component: projectForm, name: '项目表单设置', iconCls: 'iconfont firerock-iconquanxian1', meta: { text: 'navigation.projectFormSettings' } },
         ],
         // 其他信息

+ 72 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -279,6 +279,7 @@
                 <el-button size="small" type="primary" @click="handJue">{{ $t('modifyingRoles') }}</el-button>
                 <el-button size="small" type="primary" @click="workingHoursDialogClick()">{{ $t('xiuZhengGongShiSuoShuBuMen') }}</el-button>
                 <el-button size="small" type="primary" @click="handleSelectionUser()">{{ $t('piLiangQiYongYuanGong') }}</el-button>
+                <el-button size="small" type="primary" @click="showUserGroupVisable()">批量修改分组</el-button>
                
                 
                 
@@ -348,6 +349,21 @@
             </div>
         </el-dialog>
 
+        <!-- 批量修改用户分组 -->
+        <el-dialog :title="$t('changes')" :visible.sync="userGroupVisable" v-if="userGroupVisable" width="600px">
+            <el-form model="" label-width="20%">
+                <el-form-item label="用户分组">
+                    <el-select v-model="userGroupId" :placeholder="$t('defaultText.pleaseChoose')" style="width: 100%">
+                        <el-option v-for="(item, index) in userGroupList" :key="index" :label="item.groupName" :value="item.id"></el-option>
+                    </el-select>
+                </el-form-item>
+            </el-form>
+            <div slot="footer" class="dialog-footer">
+                <el-button @click="userGroupVisable = false">{{ $t('btn.cancel') }}</el-button>
+                <el-button type="primary" :disabled="!userGroupId" :loading="userGroupLoading" @click="editUserGroup()">{{ $t('btn.determine') }}</el-button>
+            </div>
+        </el-dialog>
+
         <!-- 新增部门 -->
         <el-dialog :title="depTitle" :visible.sync="departmentVisible" width="500px" >
             <el-form ref="depForm" :model="depForm" :rules="depRules" label-width="100px">
@@ -478,6 +494,11 @@
                           </el-option>
                       </el-select>
                   </el-form-item>
+                  <el-form-item label="用户分组" prop="groupId" v-if="permissions.userGroupManage">
+                    <el-select v-model="insertForm.groupId" :placeholder="$t('defaultText.pleaseChoose')" style="width: 100%">
+                      <el-option v-for="item in userGroupList" :label="item.groupName" :value="item.id" :key="item.id"></el-option>
+                    </el-select>
+                  </el-form-item>
                   <el-form-item :label="item.name" v-for="item,index in userCustomConfig" :key="item.id">
                       <el-select v-if="item.type == 0" v-model="insertForm[suoying[index]]" :placeholder="$t('defaultText.pleaseChoose')" clearable style="width: 100%">
                           <el-option v-for="option in item.itemList" :label="option.name" :value="option.name" :key="option.id">
@@ -1170,6 +1191,12 @@ export default {
       whiteListAll: [],
       whiteListAllTwo: [],
       specialHolidaysDialog: false,
+
+      // 用户分组
+      userGroupList: [],
+      userGroupId: '',
+      userGroupVisable: false,
+      userGroupLoading: false,
     };
   },
   watch: {
@@ -2861,7 +2888,8 @@ export default {
                 plate5: res.data.plate5,
                 jobNumber: res.data.jobNumber,
                 onlyAuditOnce: res.data.onlyAuditOnce,
-                reportDeptIdsList: res.data.userReportDeptList || []
+                reportDeptIdsList: res.data.userReportDeptList || [],
+                groupId: res.data.userGroupId || ''
               };
               this.$set(this.insertForm, 'inductionDate', res.data.inductionDate)
               this.getUserCustomConfig(1);
@@ -2977,6 +3005,9 @@ export default {
           // }
 
           // console.log(form, 'form')
+          if(this.permissions.userGroupManage) {
+            form.groupId = this.insertForm.groupId;
+          } 
 
           if (this.insertForm.id != null) {
             form.id = this.insertForm.id;
@@ -3867,6 +3898,15 @@ export default {
             }
         },error => {})
     },
+    getUserGrpupList() {
+      this.http.post('/user-group/list',{
+        },res => {
+            if(res.code == 'ok'){
+                let list = res.data
+                this.userGroupList = list
+            }
+        },error => {})
+    },
     // 企业微信选人搜索
     echartDepartment() {
         if(this.wxFilterText != '') {
@@ -3932,6 +3972,34 @@ export default {
         if (!value) return true;
         return data.label.indexOf(value) !== -1;
     },
+    showUserGroupVisable() {
+      if (this.handleSelectionZzjgDate.length == 0) {
+        this.$message(this.$t('pleaseselectpersonnel'));
+        return;
+      }
+      this.userGroupId = ''
+      this.userGroupVisable = true
+    },
+    editUserGroup() {
+      this.userGroupLoading = true
+      let ids = this.handleSelectionZzjgDate.map(item => item.id).join(',')
+      this.http.post("/user/batchSetUserGroup", {
+        userIds: ids,
+        groupId: this.userGroupId
+      },
+      res => {
+        this.userGroupLoading = false
+        if (res.code == "ok") {
+          this.$message({
+              message: this.$t('caoZuoChengGong'),
+              type: "success"
+          });
+          this.userGroupVisable = false
+          this.getUser()
+        }
+      },
+      error => { this.userGroupLoading = false });
+    }
   },
   mounted() {
     this.deactiveDate = util.formatDate.format(new Date(), "yyyy-MM-dd");
@@ -3951,6 +4019,9 @@ export default {
     }
     this.statesPush();
     this.getWhiteListAll()
+    if(this.permissions.userGroupManage) {
+      this.getUserGrpupList()
+    }
     // 获取企业微信的参数
     // if(this.user.companyId == '1081' || this.user.companyId == '7') {
     //   this.agentConfig()

+ 231 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/userGrouping/userGrouping.vue

@@ -0,0 +1,231 @@
+<template>
+  <div class="userGroping">
+    <div class="userGroping-title">
+      <div>用户分组管理</div>
+      <div>
+        <el-button type="text" icon="el-icon-circle-plus-outline" @click="showGroupVisable()">创建分组</el-button>
+      </div>
+    </div>
+    <div class="userGroping-table">
+      <el-table :data="tableData" border v-loading="tableLoading" style="width: 100%; height: 100%">
+        <el-table-column align="center" prop="groupName" label="分组名称"></el-table-column>
+        <el-table-column align="center" prop="noProjectPercent" label="非项目工时占比上限(%)"></el-table-column>
+        <el-table-column align="center" prop="operation" label="操作" width="160">
+          <template slot-scope="scope">
+            <el-button size="small" @click="showGroupVisable(scope.row)">编辑</el-button>
+            <el-button size="small" type="danger" @click="deteleGroup(scope.row)">删除</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+
+    <!-- 创建/编辑分组 -->
+    <el-dialog title="新增/编辑分组" :visible.sync="editGroupVisable" width="800px" :before-close="handleClose">
+      <div class="groupForm">
+        <div class="groupFormItem">
+          <div class="label">分组名称</div>
+          <el-input v-model.trim="editGroupForm.groupName" size="small" placeholder="请输入" clearable
+            class="flex1"></el-input>
+        </div>
+        <div class="groupFormItem">
+          <div class="label">非项目占比(%)</div>
+          <el-input-number v-model="editGroupForm.noProjectPercent" size="small" controls-position="right"
+            :precision="0" :min="0" :max="100" class="flex1 textNumber" style="text-align: left;"></el-input-number>
+        </div>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="editGroupVisable = false">取 消</el-button>
+        <el-button type="primary" @click="editGroup()" :loading="editGroupBtnLoading"
+          :disabled="editGroupForm.groupName && !editGroupForm.noProjectPercent">确 定</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+export default {
+  props: {},
+  components: {},
+  data() {
+    return {
+      prefix: "/user-group/",
+      tableLoading: false,
+      editGroupVisable: false,
+      editGroupBtnLoading: false,
+      tableData: [],
+      editGroupForm: {
+        id: '',
+        companyId: '',
+        groupName: '',
+        noProjectPercent: 0,
+      }
+    };
+  },
+  computed: {},
+  watch: {},
+  created() { },
+  mounted() {
+    this.getTableList()
+  },
+  methods: {
+    deteleGroup(row) {
+      this.$confirm(`确定删除【${row.groupName}】?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.postData("delete", { id: row.id }).then(res => {
+          if (res.code != 'ok') {
+            this.messages(res.msg)
+            return
+          }
+          this.messages('删除成功', 'success')
+          this.getTableList()
+        })
+      });
+    },
+    editGroup() {
+      let formVal = this.getFromValue(this.editGroupForm)
+      this.editGroupBtnLoading = true
+      this.postData("addOrUpdate", { ...formVal }).then(res => {
+        if (res.code != 'ok') {
+          this.messages(res.msg)
+          return
+        }
+        this.messages('创建成功', 'success')
+        this.editGroupVisable = false
+        this.getTableList()
+      }).finally(() => {
+        this.editGroupBtnLoading = false
+      });
+    },
+    getTableList() {
+      this.tableLoading = true
+      this.postData("list", {}).then(res => {
+        if (res.code != 'ok') {
+          this.messages(res.msg)
+          return
+        }
+        this.tableData = res.data
+      }).finally(() => {
+        this.tableLoading = false
+      });
+    },
+    showGroupVisable(row = false) {
+      if (!row) {
+        // 清空
+        this.editGroupForm = {
+          id: '',
+          companyId: '',
+          groupName: '',
+          noProjectPercent: 0,
+        }
+        this.editGroupVisable = true
+        return
+      }
+
+      this.editGroupForm = {
+        ...row,
+        noProjectPercent: row.noProjectPercent || 0
+      }
+      this.editGroupVisable = true
+    },
+
+    messages(test = '', type = "error") {
+      this.$message({
+        message: test,
+        type: type,
+      });
+    },
+    getFromValue(formData) {
+      const result = {};
+      for (const key in formData) {
+        if (formData[key]) {
+          result[key] = formData[key];
+        }
+      }
+      return result;
+    },
+    // 封装 post 请求
+    postData(url, params) {
+      return new Promise((resolve, reject) => {
+        this.http.post(`${this.prefix}${url}`, { ...params }, (res) => {
+          resolve(res);
+        }, (error) => {
+          this.$message({
+            message: error,
+            type: "error",
+          });
+          this.messages(error)
+          reject(error);
+        }
+        );
+      });
+    },
+  },
+};
+</script>
+
+<style scoped lang="scss">
+.userGroping {
+  width: 100%;
+  height: 100%;
+  box-sizing: border-box;
+  display: flex;
+  flex-direction: column;
+
+  .userGroping-title {
+    background: #f2f2f2;
+    padding: 10px 20px;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+  }
+
+  .userGroping-table {
+    flex: 1;
+  }
+
+  .groupForm {
+    .groupFormItem {
+      margin-bottom: 15px;
+      display: flex;
+      align-items: center;
+      flex-direction: row;
+
+      &:last-child {
+        margin-bottom: 0;
+      }
+
+      .label {
+        width: 120px;
+        text-align: right;
+        margin-right: 10px;
+      }
+
+      .textNumber {
+        text-align: left;
+      }
+
+      .flex1 {
+        flex: 1;
+      }
+    }
+  }
+
+  div {
+    box-sizing: border-box;
+  }
+
+
+}
+</style>
+<style lang="scss">
+.userGroping {
+  .groupFormItem {
+    .el-input-number .el-input__inner {
+      text-align: left !important;
+    }
+  }
+}
+</style>