Ver código fonte

项目管理

dev01 1 ano atrás
pai
commit
6574411b40
3 arquivos alterados com 190 adições e 101 exclusões
  1. 17 0
      src/api/system/project.js
  2. 172 100
      src/views/project/list/index.vue
  3. 1 1
      src/views/system/user/index.vue

+ 17 - 0
src/api/system/project.js

@@ -18,4 +18,21 @@ export function getUser(userId) {
   })
 }
 
+// 新增项目
+export function addProject(data) {
+  return request({
+    url: '/api/project/add',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改项目
+export function updateProject(data) {
+  return request({
+    url: '/api/project/update',
+    method: 'put',
+    data: data
+  })
+}
 

+ 172 - 100
src/views/project/list/index.vue

@@ -24,12 +24,14 @@
             <el-input v-model="queryParams.name" placeholder="请输入项目名称" clearable style="width: 240px"
               @keyup.enter.native="handleQuery" />
           </el-form-item>
-
+          <el-form-item label="研发人员" prop="superiorId">
+            <el-autocomplete v-model="superiorName" value-key="nickName" :fetch-suggestions="getDatas"
+              :filter-multiple="true" clearable placeholder="请输入关键字" @select="selectUser" />
+          </el-form-item>
           <el-form-item label="项目年份" prop="projectYear">
-            <el-date-picker v-model="queryParams.projectYear" type="year" placeholder="选择项目年份">
+            <el-date-picker v-model="queryParams.projectYear" value-format="yyyy" type="year" placeholder="选择项目年份">
             </el-date-picker>
           </el-form-item>
-
           <el-form-item label="是否跨年" prop="crossYear">
             <el-select v-model="queryParams.crossYear" placeholder="是否跨年" clearable style="width: 240px">
               <el-option v-for="dict in year" :key="dict.value" :label="dict.label" :value="dict.value" />
@@ -50,6 +52,14 @@
             <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
               v-hasPermi="['system:user:add']">新增</el-button>
           </el-col>
+          <el-col :span="1.5">
+            <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport"
+              v-hasPermi="['system:user:import']">导入</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
+              v-hasPermi="['system:user:export']">导出</el-button>
+          </el-col>
           <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
         </el-row>
 
@@ -68,25 +78,24 @@
           <el-table-column label="项目名称" align="center" key="name" prop="name" v-if="columns[3].visible"
             :show-overflow-tooltip="true" />
           <el-table-column label="负责人" align="center" key="adminName" prop="adminName" v-if="columns[4].visible" />
-
-          <el-table-column label="参与人员" align="center" key="staffName" prop="staffName" v-if="columns[5].visible" />
-          <el-table-column label="项目状态" align="center" key="projectStatus" prop="projectStatus" v-if="columns[6].visible">
-            <!-- <template slot-scope="scope">
-              <span>{{ ["", ""][scope.row.projectStatus] }}</span>
-            </template> -->
-          </el-table-column>
+          <el-table-column label="参与研发人员" align="center" key="staffName" prop="staffName" v-if="columns[5].visible" />
+          <el-table-column label="项目状态" align="center" key="projectStatus" prop="projectStatus"
+            v-if="columns[6].visible"></el-table-column>
+          <el-table-column label="累积工时" align="center" key="duration" prop="duration"
+            v-if="columns[6].visible"></el-table-column>
           <el-table-column label="创建年份" align="center" key="createYear" prop="createYear" v-if="columns[7].visible" />
-          <el-table-column label="创建时间" align="center" key="createTime" prop="createTime" v-if="columns[8].visible"
-            width="100">
+          <el-table-column label="起止时间" align="center" key="startTime" prop="startTime" v-if="columns[8].visible">
             <template slot-scope="scope">
-              <span>{{ parseTime(scope.row.createTime) }}</span>
+              <div>{{ scope.row.startTime }}</div>
+              <div>至</div>
+              <div>{{ scope.row.endTime }}</div>
             </template>
           </el-table-column>
-          <!-- <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
+          <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
             <template slot-scope="scope" v-if="scope.row.userId !== 1">
               <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                 v-hasPermi="['system:user:edit']">修改</el-button>
-              <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
+              <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                 v-hasPermi="['system:user:remove']">删除</el-button>
               <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"
                 v-hasPermi="['system:user:resetPwd', 'system:user:edit']">
@@ -97,9 +106,9 @@
                   <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
                     v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>
                 </el-dropdown-menu>
-              </el-dropdown>
+              </el-dropdown> -->
             </template>
-          </el-table-column> -->
+          </el-table-column>
         </el-table>
 
         <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@@ -108,80 +117,67 @@
     </el-row>
 
     <!-- 添加或修改用户配置对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
+    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-row>
           <el-col :span="12">
-            <el-form-item label="用户昵称" prop="nickName">
-              <el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" />
+            <el-form-item label="项目编号" prop="projectNumber">
+              <el-input v-model="form.projectNumber" placeholder="请输入项目编号" maxlength="30" />
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="归属部门" prop="deptId">
-              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
+            <el-form-item label="项目名称" prop="name">
+              <el-input v-model="form.name" placeholder="请输入项目名称" maxlength="30" />
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="12">
-            <el-form-item label="手机号码" prop="phonenumber">
-              <el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11" />
+            <el-form-item label="起止时间">
+              <el-date-picker v-model="dateRange1" style="width:250px" value-format="yyyy-MM-dd" type="daterange"
+                range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="邮箱" prop="email">
-              <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row>
-          <el-col :span="12">
-            <el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName">
-              <el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
-              <el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password />
+            <el-form-item label="是否跨年" prop="crossYear">
+              <el-select v-model="form.crossYear" style="width:250px" placeholder="请选择是否跨年">
+                <el-option v-for="dict in year" :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="用户性别">
-              <el-select v-model="form.sex" placeholder="请选择性别">
-                <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 label="项目年份" prop="projectYear">
+              <el-date-picker v-model="form.projectYear" style="width: 250px" value-format="yyyy" type="year"
+                placeholder="选择项目年份">
+              </el-date-picker>
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="状态">
-              <el-radio-group v-model="form.status">
-                <el-radio v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.value">{{ dict.label
-                }}</el-radio>
-              </el-radio-group>
+            <el-form-item label="创建年份" prop="createYear">
+              <el-date-picker v-model="form.createYear" style="width:250px" value-format="yyyy" type="year"
+                placeholder="选择创建年份">
+              </el-date-picker>
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="12">
-            <el-form-item label="岗位">
-              <el-select v-model="form.postIds" multiple placeholder="请选择岗位">
-                <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 label="负责人" prop="superiorName1">
+              <!-- <el-input v-model="form.projectNumber" placeholder="请选择项目负责人" maxlength="30" /> -->
+              <el-autocomplete v-model="superiorName1" style="width:250px" value-key="nickName"
+                :fetch-suggestions="getDatas1" :filter-multiple="true" clearable placeholder="请输入关键字"
+                @select="selectUser1" />
             </el-form-item>
           </el-col>
-          <el-col :span="12">
-            <el-form-item label="角色">
-              <el-select v-model="form.roleIds" multiple placeholder="请选择角色">
-                <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-col :span="12">
+            <el-form-item label="项目成员" prop="name">
+              <el-input v-model="form.name" placeholder="请输入项目名称" maxlength="30" />
             </el-form-item>
-          </el-col>
+          </el-col> -->
         </el-row>
+
         <el-row>
           <el-col :span="24">
             <el-form-item label="备注">
@@ -196,11 +192,33 @@
       </div>
     </el-dialog>
 
+    <!-- 项目导入对话框 -->
+    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
+      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
+        :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
+        :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
+        <div class="el-upload__tip text-center" slot="tip">
+          <div class="el-upload__tip" slot="tip">
+            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
+          </div>
+          <span>仅允许导入xls、xlsx格式文件。</span>
+          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
+            @click="importTemplate">下载模板</el-link>
+        </div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">确 定</el-button>
+        <el-button @click="upload.open = false">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-import { listProject, } from "@/api/system/project";
+import { listProject, addProject, updateProject } from "@/api/system/project";
+import { selectName, } from "@/api/system/user";
 import { getToken } from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@@ -211,6 +229,8 @@ export default {
   components: { Treeselect },
   data() {
     return {
+      superiorName: "",
+      superiorName1: "",
       // 遮罩层
       loading: true,
       // 选中数组
@@ -237,6 +257,7 @@ export default {
       initPassword: undefined,
       // 日期范围
       dateRange: [],
+      dateRange1: [],
       // 岗位选项
       postOptions: [],
       // 角色选项
@@ -261,7 +282,7 @@ export default {
         // 设置上传的请求头部
         headers: { Authorization: "Bearer " + getToken() },
         // 上传的地址
-        url: process.env.VUE_APP_BASE_API + "/system/user/importData"
+        url: process.env.VUE_APP_BASE_API + "/api/project/importData"
       },
       // 查询参数
       queryParams: {
@@ -280,18 +301,19 @@ export default {
         { key: 2, label: `是否跨年`, visible: true },
         { key: 3, label: `项目名称`, visible: true },
         { key: 4, label: `负责人`, visible: true },
-        { key: 5, label: `参与人员`, visible: true },
+        { key: 5, label: `参与研发人员`, visible: true },
         { key: 6, label: `项目状态`, visible: true },
-        { key: 7, label: `创建年份`, visible: true },
-        { key: 8, label: `创建时间`, visible: true },
+        { key: 7, label: `累积工时`, visible: true },
+        { key: 8, label: `创建年份`, visible: true },
+        { key: 9, label: `起止时间`, visible: true },
       ],
       // 表单校验
       rules: {
-        userName: [
+        projectNumber: [
           { required: true, message: "用户名称不能为空", trigger: "blur" },
           { min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur' }
         ],
-        nickName: [
+        name: [
           { required: true, message: "用户昵称不能为空", trigger: "blur" }
         ],
         password: [
@@ -329,10 +351,28 @@ export default {
     });
   },
   methods: {
+    // 根据查询关键词,获取匹配的下拉列表数据  
+    getDatas(query, cb) {
+      selectName(query, 0).then(response => {
+        cb(response.data)
+      });
+    },
+    getDatas1(query, cb) {
+      selectName(query, 2).then(response => {
+        cb(response.data)
+      });
+    },
+    selectUser(item) {
+      this.queryParams.superiorId = item.userId
+      this.superiorName = item.nickName
+    },
+    selectUser1(item) {
+      this.form.aid = item.userId
+      this.form.adminName = item.nickName
+    },
     /** 查询用户列表 */
     getList() {
       this.loading = true;
-      console.log("====", this.queryParams)
       listProject(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
         this.userList = response.rows;
         this.total = response.total;
@@ -364,18 +404,17 @@ export default {
     // 表单重置
     reset() {
       this.form = {
-        userId: undefined,
-        deptId: undefined,
-        userName: undefined,
-        nickName: undefined,
-        password: undefined,
-        phonenumber: undefined,
-        email: undefined,
-        sex: undefined,
-        status: "0",
+        aid: undefined,
+        adminName: undefined,
+        name: undefined,
+        projectStatus: 1,
+        projectNumber: undefined,
+        projectYear: undefined,
+        createYear: undefined,
+        crossYear: undefined,
         remark: undefined,
-        postIds: [],
-        roleIds: []
+        startTime: undefined,
+        endTime: undefined,
       };
       this.resetForm("form");
     },
@@ -389,6 +428,7 @@ export default {
       this.dateRange = [];
       this.resetForm("queryForm");
       this.queryParams.deptId = undefined;
+      this.superiorName = undefined
       // this.$refs.tree.setCurrentKey(null);
       this.handleQuery();
     },
@@ -403,41 +443,73 @@ export default {
       this.reset();
       this.open = true;
       this.title = "新增项目";
-      // getUser().then(response => {
-      //   this.postOptions = response.posts;
-      //   this.roleOptions = response.roles;
-      //   this.open = true;
-      //   this.title = "添加用户";
-      //   this.form.password = this.initPassword;
-      // });
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
-      const userId = row.userId || this.ids;
-      // getUser(userId).then(response => {
-      //   this.form = response.data;
-      //   this.postOptions = response.posts;
-      //   this.roleOptions = response.roles;
-      //   this.$set(this.form, "postIds", response.postIds);
-      //   this.$set(this.form, "roleIds", response.roleIds);
-      //   this.open = true;
-      //   this.title = "修改用户";
-      //   this.form.password = "";
-      // });
+      this.open = true;
+      this.title = "修改项目";
+      this.form = {
+        id: row.id,
+        aid: row.aid,
+        adminName: row.adminName,
+        name: row.name,
+        projectStatus: row.projectStatus,
+        projectNumber: row.projectNumber,
+        projectYear: row.projectYear,
+        createYear: row.createYear,
+        crossYear: row.crossYear,
+        remark: row.remark,
+      };
+      this.dateRange1 = [row.startTime || "", row.endTime || ""]
+      this.superiorName1 = row.adminName;
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      this.download('api/project/export', {
+        ...this.queryParams
+      }, `project_${new Date().getTime()}.xlsx`)
+    },
+    /** 导入按钮操作 */
+    handleImport() {
+      this.upload.title = "项目导入";
+      this.upload.open = true;
+    },
+    /** 下载模板操作 */
+    importTemplate() {
+      this.download('api/project/importTemplate', {
+      }, `project_template_${new Date().getTime()}.xlsx`)
+    },
+    // 文件上传中处理
+    handleFileUploadProgress(event, file, fileList) {
+      this.upload.isUploading = true;
+    },
+    // 文件上传成功处理
+    handleFileSuccess(response, file, fileList) {
+      this.upload.open = false;
+      this.upload.isUploading = false;
+      this.$refs.upload.clearFiles();
+      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
+      this.getList();
+    },
+    // 提交上传文件
+    submitFileForm() {
+      this.$refs.upload.submit();
     },
     /** 提交按钮 */
     submitForm: function () {
       this.$refs["form"].validate(valid => {
+        this.form.startTime = this.dateRange1[0]
+        this.form.endTime = this.dateRange1[1]
         if (valid) {
-          if (this.form.userId != undefined) {
-            updateUser(this.form).then(response => {
+          if (this.form.id != undefined) {
+            updateProject(this.form).then(response => {
               this.$modal.msgSuccess("修改成功");
               this.open = false;
               this.getList();
             });
           } else {
-            addUser(this.form).then(response => {
+            addProject(this.form).then(response => {
               this.$modal.msgSuccess("新增成功");
               this.open = false;
               this.getList();

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

@@ -187,7 +187,7 @@
           <el-col :span="12">
             <el-form-item label="上级" prop="superiorId">
               <el-autocomplete v-model="form.superiorName" value-key="nickName" :fetch-suggestions="getDatas"
-                :filter-multiple="true" clearable placeholder="请输入关键字" @select="selectUser" />
+                :filter-multiple="true" clearable placeholder="请输入姓名" @select="selectUser" />
             </el-form-item>
           </el-col>
         </el-row>