浏览代码

支部年度工作计划优化

Wang Zi Wen 2 年之前
父节点
当前提交
8cd472d124

+ 17 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/branch/TBranchPlanController.java

@@ -2,6 +2,9 @@ package com.ruoyi.web.controller.branch;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.ruoyi.branch.domain.TBranchPlanItem;
+import com.ruoyi.branch.service.ITBranchPlanItemService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -34,17 +37,26 @@ public class TBranchPlanController extends BaseController
     @Autowired
     private ITBranchPlanService tBranchPlanService;
 
+    @Autowired
+    private ITBranchPlanItemService tBranchPlanItemService;
+
     /**
      * 查询支部年度工作计划列表
      */
     @PreAuthorize("@ss.hasPermi('branch:plan:list')")
     @GetMapping("/list")
-    public AjaxResult list(TBranchPlan tBranchPlan)
+    public TableDataInfo list(TBranchPlan tBranchPlan)
     {
-//        startPage();
-//        List<TBranchPlan> list = tBranchPlanService.selectTBranchPlanList(tBranchPlan);
-//        return getDataTable(list);
-        return AjaxResult.success(tBranchPlanService.selectTBranchPlanList(tBranchPlan));
+        startPage();
+        List<TBranchPlan> list = tBranchPlanService.selectTBranchPlanList(tBranchPlan);
+        // 查询工作计划条目
+        for (TBranchPlan branchPlan : list) {
+            TBranchPlanItem tBranchPlanItem = new TBranchPlanItem();
+            tBranchPlanItem.setPlanId(branchPlan.getPlanId());
+            List<TBranchPlanItem> tBranchPlanItems = tBranchPlanItemService.selectTBranchPlanItemList(tBranchPlanItem);
+            branchPlan.setItemList(tBranchPlanItems);
+        }
+        return getDataTable(list);
     }
 
     /**

+ 25 - 1
ruoyi-system/src/main/java/com/ruoyi/branch/domain/TBranchPlan.java

@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
+import java.util.List;
+
 /**
  * 支部年度工作计划对象 t_branch_plan
  * 
@@ -30,7 +32,29 @@ public class TBranchPlan extends BaseEntity
     @Excel(name = "部门id")
     private Long deptId;
 
-    public void setPlanId(Long planId) 
+    /** 所属年份 */
+    private String planYear;
+
+    /** 条目 */
+    private List<TBranchPlanItem> itemList;
+
+    public List<TBranchPlanItem> getItemList() {
+        return itemList;
+    }
+
+    public void setItemList(List<TBranchPlanItem> itemList) {
+        this.itemList = itemList;
+    }
+
+    public String getPlanYear() {
+        return planYear;
+    }
+
+    public void setPlanYear(String planYear) {
+        this.planYear = planYear;
+    }
+
+    public void setPlanId(Long planId)
     {
         this.planId = planId;
     }

+ 6 - 1
ruoyi-system/src/main/resources/mapper/branch/TBranchPlanMapper.xml

@@ -13,10 +13,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="deptId"    column="dept_id"    />
+        <result property="planYear"    column="plan_year"    />
     </resultMap>
 
     <sql id="selectTBranchPlanVo">
-        select u.plan_id, u.plan_title, u.del_flag, u.create_by, u.create_time, u.update_by, u.update_time, u.dept_id from t_branch_plan u left join sys_dept d on u.dept_id = d.dept_id
+        select u.plan_id, u.plan_title, u.del_flag, u.create_by, u.create_time, u.update_by, u.update_time, u.dept_id, u.plan_year from t_branch_plan u left join sys_dept d on u.dept_id = d.dept_id
     </sql>
 
     <select id="selectTBranchPlanList" parameterType="TBranchPlan" resultMap="TBranchPlanResult">
@@ -25,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="planId != null "> and u.plan_id = #{planId}</if>
             <if test="planTitle != null  and planTitle != ''"> and u.plan_title like concat('%', #{planTitle}, '%')</if>
             <if test="deptId != null "> and u.dept_id = #{deptId}</if>
+            <if test="planYear != null "> and u.plan_year = #{planYear}</if>
             and u.del_flag = 0
         </where>
         <!-- 数据范围过滤 -->
@@ -51,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="deptId != null">dept_id,</if>
+            <if test="planYear != null">plan_year,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="planId != null">#{planId},</if>
@@ -61,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="deptId != null">#{deptId},</if>
+            <if test="planYear != null">#{planYear},</if>
          </trim>
     </insert>
 
@@ -74,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="deptId != null">dept_id = #{deptId},</if>
+            <if test="planYear != null">plan_year = #{planYear},</if>
         </trim>
         where plan_id = #{planId}
     </update>

+ 90 - 172
ruoyi-ui/src/views/branch/zbjs/plan/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" size="small" v-show="showSearch" label-width="68px">
-      <el-form-item label="年份" prop="planYear">
+      <el-form-item label="所属年份" prop="planYear">
         <el-date-picker clearable size="small" style="width: 200px"
                         v-model="queryParams.planYear"
                         type="year"
@@ -28,75 +28,13 @@
           v-hasPermi="['branch:plan:add']"
         >新增标题</el-button>
       </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="primary"
-          plain
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd"
-          v-hasPermi="['branch:planitem:add']"
-        >新增条目</el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="info"
-          plain
-          icon="el-icon-edit"
-          size="mini"
-          @click="handleListPlan"
-          v-hasPermi="['branch:plan:edit']"
-        >编辑标题</el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="success"
-          plain
-          icon="el-icon-edit"
-          size="mini"
-          :disabled="single"
-          @click="handleUpdate"
-          v-hasPermi="['branch:planitem:edit']"
-        >修改</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="['branch:planitem:remove']"
-        >删除</el-button>
-      </el-col>
-      <!--<el-col :span="1.5">-->
-        <!--<el-button-->
-          <!--type="info"-->
-          <!--plain-->
-          <!--icon="el-icon-upload2"-->
-          <!--size="mini"-->
-          <!--@click="handleImport"-->
-          <!--v-hasPermi="['branch:planitem:edit']"-->
-        <!--&gt;导入</el-button>-->
-      <!--</el-col>-->
-      <!--<el-col :span="1.5">-->
-        <!--<el-button-->
-          <!--type="warning"-->
-          <!--plain-->
-          <!--icon="el-icon-download"-->
-          <!--size="mini"-->
-          <!--@click="handleExport"-->
-          <!--v-hasPermi="['branch:planitem:export']"-->
-        <!--&gt;导出</el-button>-->
-      <!--</el-col>-->
 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="planitemList" @selection-change="handleSelectionChange" :height="clientHeight" border :span-method="objectSpanMethod">
+    <el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange" :height="clientHeight" border :span-method="objectSpanMethod">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="标题" align="center" prop="planId" :formatter="planListFormat" />
-      <el-table-column label="内容" align="center" prop="itemContent" />
+      <el-table-column label="标题" align="center" prop="planTitle" width="200" />
+      <el-table-column label="内容" align="center" prop="itemContent"/>
       <el-table-column label="计划实施时间" align="center" prop="planTime" width="100">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.planTime, '{y}-{m}-{d}') }}</span>
@@ -117,6 +55,7 @@
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
             v-hasPermi="['branch:planitem:edit']"
+            v-if="scope.row.itemId != null"
           >修改</el-button>
           <el-button
             size="mini"
@@ -124,6 +63,32 @@
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
             v-hasPermi="['branch:planitem:remove']"
+            v-if="scope.row.itemId != null"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" fixed="right" width="240" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            type="text"
+            size="mini"
+            icon="el-icon-plus"
+            @click="handleAdd(scope.row)"
+            v-hasPermi="['branch:planitem:add']"
+          >新增条目</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdatePlan(scope.row)"
+            v-hasPermi="['branch:plan:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDeletePlan(scope.row)"
+            v-hasPermi="['branch:plan:remove']"
           >删除</el-button>
         </template>
       </el-table-column>
@@ -140,15 +105,8 @@
     <!-- 添加或修改支部年度工作计划条目对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="标题" prop="planId">
-          <el-select v-model="form.planId" placeholder="请选择标题">
-            <el-option
-              v-for="dict in planList"
-              :key="dict.dictValue"
-              :label="dict.dictLabel"
-              :value="dict.dictValue"
-            ></el-option>
-          </el-select>
+        <el-form-item label="标题" prop="planTitle">
+          <el-input v-model="form.planTitle" disabled />
         </el-form-item>
         <el-form-item label="内容" prop="itemContent">
           <el-input v-model="form.itemContent" placeholder="请输入内容" />
@@ -204,6 +162,13 @@
         <el-form-item label="标题" prop="planTitle">
           <el-input v-model="formPlan.planTitle" placeholder="请输入标题" />
         </el-form-item>
+        <el-form-item label="所属年份" prop="planYear">
+          <el-date-picker clearable size="small" style="width: 200px"
+                          v-model="formPlan.planYear"
+                          type="year"
+                          placeholder="选择年份">
+          </el-date-picker>
+        </el-form-item>
         <el-form-item label="归属部门" prop="deptId">
           <treeselect v-model="formPlan.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
         </el-form-item>
@@ -213,46 +178,6 @@
         <el-button @click="cancelPlan">取 消</el-button>
       </div>
     </el-dialog>
-    <!-- 编辑标题对话框 -->
-    <el-dialog :title="titleListPlan" :visible.sync="openListPlan" width="500px" append-to-body>
-      <el-table :data="planList" border>
-        <el-table-column label="编号" align="center" prop="dictValue" width="80px"/>
-        <el-table-column label="标题" align="center" prop="dictLabel">
-          <template slot-scope="scope">
-            <span v-if="!scope.row.isEdit">{{scope.row.dictLabel}}</span>
-            <span v-if="scope.row.isEdit"><el-input v-model="scope.row.dictLabel" /></span>
-          </template>
-        </el-table-column>
-        <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
-          <template slot-scope="scope">
-            <el-button
-              size="mini"
-              type="text"
-              icon="el-icon-edit"
-              @click="handleUpdatePlan(scope.row)"
-              v-hasPermi="['branch:plan:edit']"
-              v-if="!scope.row.isEdit"
-            >编辑</el-button>
-            <el-button
-              size="mini"
-              type="text"
-              icon="el-icon-check"
-              @click="handleConfirmPlan(scope.row)"
-              v-hasPermi="['branch:plan:edit']"
-              v-if="scope.row.isEdit"
-            >确定</el-button>
-            <el-button
-              size="mini"
-              type="text"
-              icon="el-icon-delete"
-              @click="handleDeletePlan(scope.row)"
-              v-hasPermi="['branch:plan:remove']"
-            >删除</el-button>
-          </template>
-        </el-table-column>
-      </el-table>
-    </el-dialog>
-
     <!-- 用户导入对话框 -->
     <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
         <el-upload
@@ -312,8 +237,7 @@ export default {
       showSearch: true,
       // 总条数
       total: 0,
-      // 支部年度工作计划条目表格数据
-      planitemList: [],
+      planList: [],
       // 弹出层标题
       title: "",
       titlePlan: "",
@@ -327,8 +251,6 @@ export default {
       openListPlan: false,
       // 当前状态字典
       itemStatusOptions: [],
-      // 工作计划列表
-      planList: [],
       // 用户列表
       userList: [],
       // 用户导入参数
@@ -378,6 +300,9 @@ export default {
         planTitle: [
           { required: true, message: "标题不能为空", trigger: "blur" }
         ],
+        planYear: [
+          { required: true, message: "所属年份不能为空", trigger: "blur" }
+        ],
         deptId: [
           { required: true, message: "归属部门不能为空", trigger: "blur" }
         ],
@@ -398,7 +323,6 @@ export default {
     // 设置搜索条件年份为当年
     this.setYear();
     this.getList();
-    this.getPlanList();
     this.getTreeselect();
     this.getDicts("plan_item_status").then(response => {
       this.itemStatusOptions = response.data;
@@ -423,18 +347,6 @@ export default {
         this.userList = userList;
       });
     },
-    /** 查询工作计划列表 */
-    getPlanList() {
-      listPlan().then(response => {
-        let data = response.data;
-        let planList = [];
-        for(let i = 0; i < data.length; i++) {
-          let plan = { "dictValue" : data[i].planId, "dictLabel" : data[i].planTitle, "isEdit": false};
-          planList.push(plan);
-        }
-        this.planList = planList;
-      });
-    },
     /** 计算单元格合并行数 */
     getSpanArr(list) {
       list.forEach(item => {
@@ -451,11 +363,11 @@ export default {
         // 这里跳过已经重复的数据
         i = i + list[i].rowspan - 1;
       }
-      this.planitemList = list;
+      this.planList = list;
     },
     /** 单元格合并 */
     objectSpanMethod({ row, column, rowIndex, columnIndex }) {
-      if (columnIndex === 1) {
+      if (columnIndex === 1 || columnIndex == 8) {
         return {
           rowspan: row.rowspan,
           colspan: 1,
@@ -476,27 +388,39 @@ export default {
         }
         this.userList = userList;
       }).then(() => {
-        return listPlanitem({
+        return listPlan({
           "planYear": this.queryParams.planYear.getFullYear(),
           "deptId": this.queryParams.deptId
         });
       }).then(response => {
-        this.planitemList = response.rows;
-        for (let i = 0; i < this.planitemList.length; i++) {
-          if (this.planitemList[i].personInCharge != null) {
-            let personInCharge = this.planitemList[i].personInCharge.split(",");
-            let personInChargeString = "";
-            for (let j = 0; j < personInCharge.length; j++) {
-              if (j > 0) {
-                personInChargeString += "、" + this.selectDictLabel(this.userList, personInCharge[j]);
-              } else {
-                personInChargeString += this.selectDictLabel(this.userList, personInCharge[j]);
+        let rows = response.rows;
+        let planList = [];
+        for (let i = 0; i < rows.length; i ++) {
+          let itemList = rows[i].itemList;
+            if (itemList.length == 0) {
+              let row = {...rows[i]};
+              planList.push(row);
+            } else {
+              for (let j = 0; j < itemList.length; j++) {
+                if (itemList[j].personInCharge != null) {
+                  let personInCharge = itemList[j].personInCharge.split(",");
+                  let personInChargeString = "";
+                  for (let k = 0; k < personInCharge.length; k++) {
+                    if (k > 0) {
+                      personInChargeString += "、" + this.selectDictLabel(this.userList, personInCharge[k]);
+                    } else {
+                      personInChargeString += this.selectDictLabel(this.userList, personInCharge[k]);
+                    }
+                  }
+                  itemList[j].personInChargeString = personInChargeString;
+                }
+                let row = {...rows[i], ...itemList[j]};
+                planList.push(row);
               }
             }
-            this.planitemList[i].personInChargeString = personInChargeString;
-          }
         }
-        this.getSpanArr(this.planitemList);
+        this.planList = planList;
+        this.getSpanArr(this.planList);
         this.total = response.total;
         this.loading = false;
       });
@@ -511,10 +435,6 @@ export default {
     itemStatusFormat(row, column) {
       return this.selectDictLabel(this.itemStatusOptions, row.itemStatus);
     },
-    // 工作计划字典翻译
-    planListFormat(row, column) {
-      return this.selectDictLabel(this.planList, row.planId);
-    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -573,8 +493,11 @@ export default {
       this.multiple = !selection.length
     },
     /** 新增按钮操作 */
-    handleAdd() {
+    handleAdd(row) {
       this.reset();
+      this.form.planId = row.planId;
+      this.form.planTitle = row.planTitle;
+      this.form.deptId = row.deptId;
       this.open = true;
       this.title = "添加支部年度工作计划条目";
     },
@@ -583,17 +506,14 @@ export default {
       this.openPlan = true;
       this.titlePlan = "添加支部年度工作计划标题";
     },
-    /** 编辑标题按钮操作 */
-    handleListPlan() {
-      this.openListPlan = true;
-      this.titleListPlan = "编辑标题";
-    },
     /** 修改按钮操作 */
     handleUpdate(row) {
+      console.log(row)
       this.reset();
       const itemId = row.itemId || this.ids
       getPlanitem(itemId).then(response => {
         this.form = response.data;
+        this.form.planTitle = row.planTitle;
         if (this.form.personInCharge != null) {
           this.form.personInCharge = this.form.personInCharge.split(",").map(Number);
         }
@@ -602,17 +522,13 @@ export default {
       });
     },
     handleUpdatePlan(row) {
-      row.isEdit = true;
-    },
-    handleConfirmPlan(row) {
-      updatePlan({
-        "planId": row.dictValue,
-        "planTitle": row.dictLabel
-      }).then(response => {
-        this.$modal.msgSuccess("修改成功");
-        row.isEdit = false;
-        this.getPlanList();
-        this.getList();
+      // row.isEdit = true;
+      this.resetPlan();
+      const planId = row.planId || this.ids
+      getPlan(planId).then(response => {
+        this.formPlan = response.data;
+        this.openPlan = true;
+        this.titlePlan = "修改支部年度工作计划标题";
       });
     },
     /** 提交按钮 */
@@ -641,6 +557,9 @@ export default {
     submitFormPlan() {
       this.$refs["formPlan"].validate(valid => {
         if (valid) {
+          if (typeof(this.formPlan.planYear) != 'string') {
+            this.formPlan.planYear = this.formPlan.planYear.getFullYear();
+          }
           if (this.formPlan.planId != null) {
             updatePlan(this.formPlan).then(response => {
               this.$modal.msgSuccess("修改成功");
@@ -652,7 +571,6 @@ export default {
               this.$modal.msgSuccess("新增成功");
               this.openPlan = false;
               this.getList();
-              this.getPlanList();
             });
           }
         }
@@ -678,9 +596,9 @@ export default {
         cancelButtonText: "取消",
         type: "warning"
       }).then(function() {
-        return delPlan(row.dictValue);
+        return delPlan(row.planId);
       }).then(() => {
-        this.getPlanList();
+        this.getList();
         this.$modal.msgSuccess("删除成功");
       })
     },