Browse Source

- 装置信息基础功能代码修改
- 代码生成模板文件修改
- 多部门数据归属处理(部分代码)

wangggziwen 10 months ago
parent
commit
ba95abaa11

+ 1 - 1
rc-admin/src/main/java/com/ruoyi/web/controller/rc/TAuditController.java

@@ -100,7 +100,7 @@ public class TAuditController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody TAudit tAudit)
     {
-        if (StringUtils.isNull(tAudit.getDeptId())) {
+        if (StringUtils.isNull(tAudit.getDeptId()) || "".equals(tAudit.getDeptId())) {
             tAudit.setDeptId(getLoginUser().getDeptId().toString());
         }
         return toAjax(tAuditService.insertTAudit(tAudit));

+ 1 - 1
rc-admin/src/main/java/com/ruoyi/web/controller/rc/TDeptInfoController.java

@@ -101,7 +101,7 @@ public class TDeptInfoController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody TDeptInfo tDeptInfo)
     {
-        if (StringUtils.isNull(tDeptInfo.getDeptId())) {
+        if (StringUtils.isNull(tDeptInfo.getDeptId()) || "".equals(tDeptInfo.getDeptId())) {
             tDeptInfo.setDeptId(getLoginUser().getDeptId().toString());
         }
         return toAjax(tDeptInfoService.insertTDeptInfo(tDeptInfo));

+ 1 - 1
rc-generator/src/main/resources/vm/java/controller.java.vm

@@ -110,7 +110,7 @@ public class ${ClassName}Controller extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody ${ClassName} ${className})
     {
-        if (StringUtils.isNull(${className}.getDeptId())) {
+        if (StringUtils.isNull(${className}.getDeptId()) || "".equals(${className}.getDeptId())) {
             ${className}.setDeptId(getLoginUser().getDeptId().toString());
         }
         return toAjax(${className}Service.insert${ClassName}(${className}));

+ 10 - 10
ruoyi-ui/src/views/rc/audit/index.vue

@@ -1,6 +1,16 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="装置" prop="deptId">
+        <el-select clearable v-model="queryParams.deptId" placeholder="请选择装置">
+          <el-option
+            v-for="dict in deptOptions"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          ></el-option>
+        </el-select>
+      </el-form-item>
       <el-form-item label="年份" prop="year">
         <el-date-picker clearable
                         v-model="queryParams.year"
@@ -25,16 +35,6 @@
           placeholder="请选择审计时间">
         </el-date-picker>
       </el-form-item>
-      <el-form-item label="装置" prop="deptId">
-        <el-select clearable v-model="queryParams.deptId" placeholder="请选择装置">
-          <el-option
-            v-for="dict in deptOptions"
-            :key="dict.dictValue"
-            :label="dict.dictLabel"
-            :value="dict.dictValue"
-          ></el-option>
-        </el-select>
-      </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>

+ 60 - 25
ruoyi-ui/src/views/rc/deptinfo/index.vue

@@ -1,19 +1,21 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
-      <el-form-item label="装置id" prop="deptId">
-        <el-input
-          v-model="queryParams.deptId"
-          placeholder="请输入装置id"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
+      <el-form-item label="装置" prop="deptId">
+        <el-select clearable v-model="queryParams.deptId" placeholder="请选择装置">
+          <el-option
+            v-for="dict in deptOptions"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          ></el-option>
+        </el-select>
       </el-form-item>
       <el-form-item label="年份" prop="year">
         <el-date-picker clearable
           v-model="queryParams.year"
-          type="date"
-          value-format="yyyy-MM-dd"
+          type="year"
+          value-format="yyyy"
           placeholder="请选择年份">
         </el-date-picker>
       </el-form-item>
@@ -71,15 +73,14 @@
 
     <el-table border v-loading="loading" :data="deptinfoList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="id" align="center" prop="id" />
-      <el-table-column label="装置信息" align="center" prop="deptInfo" />
-      <el-table-column label="装置id" align="center" prop="deptId" />
+      <el-table-column label="装置" align="center" prop="deptName" />
       <el-table-column label="年份" align="center" prop="year" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.year, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.year, '{y}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+      <el-table-column label="装置信息" align="center" prop="deptInfo" />
+      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -110,20 +111,27 @@
     <!-- 添加或修改装置信息对话框 -->
     <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="deptInfo">
-          <el-input v-model="form.deptInfo" type="textarea" placeholder="请输入内容" />
-        </el-form-item>
-        <el-form-item label="装置id" prop="deptId">
-          <el-input v-model="form.deptId" placeholder="请输入装置id" />
-        </el-form-item>
         <el-form-item label="年份" prop="year">
           <el-date-picker clearable
-            v-model="form.year"
-            type="date"
-            value-format="yyyy-MM-dd"
-            placeholder="请选择年份">
+                          v-model="form.year"
+                          type="year"
+                          value-format="yyyy"
+                          placeholder="请选择年份">
           </el-date-picker>
         </el-form-item>
+        <el-form-item label="装置信息" prop="deptInfo">
+          <el-input v-model="form.deptInfo" type="textarea" placeholder="请输入内容" />
+        </el-form-item>
+        <el-form-item label="装置" prop="deptId">
+          <el-select clearable multiple v-model="form.deptId" placeholder="请选择装置">
+            <el-option
+              v-for="dict in deptOptions"
+              :key="dict.dictValue"
+              :label="dict.dictLabel"
+              :value="dict.dictValue"
+            ></el-option>
+          </el-select>
+        </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -135,6 +143,7 @@
 
 <script>
 import { listDeptinfo, getDeptinfo, delDeptinfo, addDeptinfo, updateDeptinfo } from "@/api/rc/deptinfo";
+import { listDept } from "@/api/system/dept";
 
 export default {
   name: "Deptinfo",
@@ -170,11 +179,14 @@ export default {
       form: {},
       // 表单校验
       rules: {
-      }
+      },
+      // 装置列表
+      deptOptions: [],
     };
   },
   created() {
     this.getList();
+    this.getDeptList();
   },
   methods: {
     /** 查询装置信息列表 */
@@ -186,6 +198,19 @@ export default {
         this.loading = false;
       });
     },
+    /** 查询装置列表 */
+    getDeptList() {
+      listDept().then(response => {
+        let data = response.data;
+        for (let i = 0; i < data.length; i++) {
+          // 非顶级节点
+          if (data[i].parentId !== 0) {
+            // 插入装置列表
+            this.deptOptions.push({"dictLabel": data[i].deptName, "dictValue": data[i].deptId});
+          }
+        }
+      });
+    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -229,6 +254,12 @@ export default {
       const id = row.id || this.ids
       getDeptinfo(id).then(response => {
         this.form = response.data;
+        // 字符串转数组
+        if (response.data.deptId != null && response.data.deptId != "") {
+          response.data.deptId = response.data.deptId.split(",").map(Number);
+        } else {
+          response.data.deptId = [];
+        }
         this.open = true;
         this.title = "修改装置信息";
       });
@@ -237,6 +268,10 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
+          // 数组转字符串
+          if (this.form.deptId != null) {
+            this.form.deptId = this.form.deptId.toString();
+          }
           if (this.form.id != null) {
             updateDeptinfo(this.form).then(response => {
               this.$modal.msgSuccess("修改成功");