公文管理借入借出功能

main
15036302109 10 months ago
parent ef343ae751
commit e2263a0bfa

@ -1,11 +1,18 @@
package com.ruoyi.web.controller.ehs;
import java.util.Date;
import java.util.List;
import java.util.Arrays;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ehsDocument.domain.EhsDocument;
import com.ruoyi.ehsDocument.service.IEhsDocumentService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -37,6 +44,8 @@ import com.ruoyi.common.core.page.TableDataInfo;
public class EhsDocTransferController extends BaseController {
@Autowired
private IEhsDocTransferService ehsDocTransferService;
@Autowired
private IEhsDocumentService ehsDocumentService;
/**
*
@ -77,6 +86,52 @@ public class EhsDocTransferController extends BaseController {
return toAjax(ehsDocTransferService.save(ehsDocTransfer));
}
/**
*
*/
@ApiOperation("公文借出")
@Log(title = "公文流转", businessType = BusinessType.INSERT)
@Transactional
@PostMapping("/lend")
public AjaxResult lend(@RequestBody EhsDocTransfer ehsDocTransfer) {
EhsDocument ehsDocument = ehsDocumentService.selectEhsDocumentById(ehsDocTransfer.getDocumentId());
if (ehsDocument.getStatus() == 0) {
return AjaxResult.error("该公文已被借出");
}
ehsDocTransfer.setDocTransferStatus(0);
boolean result = ehsDocTransferService.save(ehsDocTransfer);
// 借出成功后,此公文状态变为0-借出
ehsDocument.setStatus(0);
ehsDocumentService.updateById(ehsDocument);
return toAjax(result);
}
/**
*
*/
@ApiOperation("公文归还")
@Log(title = "公文流转", businessType = BusinessType.INSERT)
@Transactional
@GetMapping("/return/{id}")
public AjaxResult returnEhsDoc(@PathVariable("id") Long documentId) {
EhsDocument ehsDocument = ehsDocumentService.selectEhsDocumentById(documentId);
if (ehsDocument.getStatus() == 1){
return AjaxResult.error("该公文已归还");
}
ehsDocument.setStatus(1);
ehsDocumentService.updateById(ehsDocument);
EhsDocTransfer ehsDocTransfer = new EhsDocTransfer();
SysUser user = SecurityUtils.getLoginUser().getUser();
ehsDocTransfer.setTransferUserId(user.getUserId());
ehsDocTransfer.setTransferName(user.getNickName());
ehsDocTransfer.setTransferTime(new Date());
ehsDocTransfer.setDocTransferStatus(ehsDocument.getStatus());
ehsDocTransfer.setDocumentId(documentId);
ehsDocTransfer.setDocumentName(ehsDocument.getDocName());
return toAjax(ehsDocTransferService.save(ehsDocTransfer));
}
/**
*
*/

@ -1,11 +1,17 @@
package com.ruoyi.web.controller.ehs;
import java.util.Date;
import java.util.List;
import java.util.Arrays;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ehsDocTransfer.domain.EhsDocTransfer;
import com.ruoyi.ehsDocTransfer.service.IEhsDocTransferService;
import com.ruoyi.ehsDocument.vo.DocResponseVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -83,6 +89,22 @@ public class EhsDocumentController extends BaseController {
return success(ehsDocumentService.selectEhsDocumentById(id));
}
/**
*
*/
@GetMapping(value = "/formData/{id}")
public AjaxResult getFormData(@PathVariable("id") Long id) {
EhsDocument ehsDocument = ehsDocumentService.selectEhsDocumentById(id);
DocResponseVo docResponseVo = new DocResponseVo();
docResponseVo.setDocumentName(ehsDocument.getDocName());
docResponseVo.setTransferTime(new Date());
SysUser user = SecurityUtils.getLoginUser().getUser();
docResponseVo.setTransferName(user.getNickName());
docResponseVo.setTransferUserId(user.getUserId());
docResponseVo.setDocumentId(ehsDocument.getId());
return success(docResponseVo);
}
/**
* id
*/

@ -48,7 +48,7 @@ public class EhsDocTransfer extends BaseEntity {
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "流转时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date transferTime;

@ -71,4 +71,9 @@ public class EhsDocument extends BaseEntity {
@Excel(name = "收文日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date receiveTime;
/**
*
*/
@Excel(name = "状态")
private Integer status;
}

@ -3,12 +3,16 @@ package com.ruoyi.ehsDocument.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.ruoyi.ehsDocument.mapper.EhsDocumentMapper;
import com.ruoyi.ehsDocument.domain.EhsDocument;
@ -45,11 +49,21 @@ public class EhsDocumentServiceImpl extends ServiceImpl<EhsDocumentMapper, EhsDo
*/
@Override
public List<EhsDocument> selectEhsDocumentList(EhsDocument ehsDocument) {
// 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
List<Long> roleIds = currentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
Long deptParentId = currentUser.getDept().getParentId();
if (!roleIds.contains(1L) &&
deptParentId != null &&
deptParentId.longValue() != 0) {
ehsDocument.setDeptId(currentUser.getDept().getDeptId().longValue());
}
return ehsDocumentMapper.selectEhsDocumentList(ehsDocument);
}
/**
* 稿
*
* @return
*/
@Override

@ -0,0 +1,16 @@
package com.ruoyi.ehsDocument.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class DocResponseVo {
private String transferName;
private Long transferUserId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date transferTime;
private String documentName;
private Long documentId;
}

@ -47,6 +47,7 @@
SELECT t.*
FROM ehs_document d,ehs_doc_transfer t
WHERE d.id = t.document_id AND d.id = #{id}
order by t.transfer_time desc
</select>

@ -12,6 +12,7 @@
<result property="docType" column="doc_type" />
<result property="docNumber" column="doc_number" />
<result property="receiveTime" column="receive_time" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
@ -23,7 +24,7 @@
</resultMap>
<sql id="selectEhsDocumentVo">
select id, doc_name, doc_font, draft_dept, doc_type, doc_number, receive_time, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_document
select id, doc_name, doc_font, draft_dept, doc_type, doc_number, receive_time, status, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_document
</sql>
<select id="selectEhsDocumentList" parameterType="EhsDocument" resultMap="EhsDocumentResult">
@ -31,6 +32,8 @@
<where>
<if test="docName != null and docName != ''"> and doc_name like concat('%', #{docName}, '%')</if>
<if test="docType != null "> and doc_type = #{docType}</if>
<if test="deptId != null">and dept_id = #{deptId}</if>
<if test="status !=null">and status = #{status}</if>
</where>
</select>

@ -26,6 +26,23 @@ export function addEhsDocTransfer(data) {
})
}
// 归还
export function returnEhsDoc(id) {
return request({
url: '/ehs/ehsDocTransfer/return/' + id,
method: 'get'
})
}
// 借出
export function lendEhsDoc(data) {
return request({
url: '/ehs/ehsDocTransfer/lend',
method: 'post',
data: data
})
}
// 修改公文流转
export function updateEhsDocTransfer(data) {
return request({

@ -17,6 +17,13 @@ export function getEhsDocument(id) {
})
}
export function getEhsDocumentById(id) {
return request({
url: '/ehs/ehsDocument/formData/' + id,
method: 'get'
})
}
// 获取拟稿部门下拉列表
export function getAllDraftDept() {
return request({

@ -34,17 +34,10 @@
size="mini"
@click="handleAdd"
v-hasPermi="['ehs:ehsDocument:add']"
>公文登记</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-document"
size="mini"
@click=""
>公文流转</el-button>
>公文登记
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
@ -54,7 +47,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['ehs:ehsDocument:edit']"
>修改</el-button>
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -65,7 +59,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['ehs:ehsDocument:remove']"
>删除</el-button>
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -75,7 +70,8 @@
size="mini"
@click="handleExport"
v-hasPermi="['ehs:ehsDocument:export']"
>导出</el-button>
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -112,18 +108,27 @@
@click="handleUpdate(scope.row)"
v-hasPermi="['ehs:ehsDocument:edit']"
>修改</el-button>-->
<el-button v-show="scope.row.status==1"
type="primary"
plain
size="mini"
@click="handleLend(scope.row)"
>借出
</el-button>
<el-button v-show="scope.row.status==0"
type="primary"
plain
size="mini"
@click="returnDoc(scope.row)"
>归还
</el-button>
<el-button
size="middle"
size="mini"
type="primary"
@click="transferRecord(scope.row)"
>流转记录</el-button>
<!--<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['ehs:ehsDocument:remove']"
>删除</el-button>-->
>流转记录
</el-button>
</template>
</el-table-column>
</el-table>
@ -181,7 +186,8 @@
v-model="form.receiveTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择收文日期">
placeholder="请选择收文日期"
>
</el-date-picker>
</el-form-item>
<el-form-item label="备注" prop="remark">
@ -193,7 +199,7 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!--流转记录会话框-->
<el-dialog :title="title1" :visible.sync="open1" width="600px" append-to-body>
<el-table v-loading="loading" :data="ehsDocTransferList">
<el-table-column label="序号" align="center">
@ -205,31 +211,82 @@
<el-table-column label="流转时间" align="center" prop="transferTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.transferTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.transferTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="流转状态" align="center" prop="docTransferStatus">
&lt;!&ndash; <template slot-scope="scope">
<dict-tag :options="dict.type.doc_status" :value="scope.row.docTransferStatus"/>
</template>&ndash;&gt;
&lt;!&ndash; <el-select v-model="docTransferStatus" placeholder="请选择流转状态" clearable>
<el-option label="未处理" value="0"> </el-option>
<el-option label="已处理" value="1"> </el-option>
</el-select>&ndash;&gt;
</el-table-column>-->
<el-table-column label="流转状态" align="center" prop="docTransferStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.doc_transfer_status" :value="scope.row.docTransferStatus"/>
<span v-if="scope.row.docTransferStatus == '0'"></span>
<span v-else></span>
</template>
</el-table-column>
</el-table>
</el-dialog>
<!--公文借出会话框-->
<el-dialog :title="title2" :visible.sync="open2" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="公文名称" prop="documentName">
<el-input v-model="form.documentName" placeholder="请输入公文名称"/>
</el-form-item>
<el-form-item label="流转人" prop="transferName">
<el-input v-model="form.transferName" placeholder="请输入流转人"/>
</el-form-item>
<!--<el-form-item label="拟稿部门" prop="draftDept">
<el-input v-model="form.draftDept" placeholder="请输入拟稿部门" />
</el-form-item>-->
<el-form-item label="流转时间" prop="transferTime">
<el-date-picker clearable
v-model="form.transferTime"
type="date"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择流转时间"
>
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitLendForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listEhsDocument, getEhsDocument, delEhsDocument, addEhsDocument, updateEhsDocument, getAllDraftDept, getDocTransferById} from "@/api/ehs/ehsDocument";
import { listEhsDocTransfer } from '@/api/ehs/ehsDocTransfer'
import {
listEhsDocument,
getEhsDocument,
delEhsDocument,
addEhsDocument,
updateEhsDocument,
getAllDraftDept,
getDocTransferById,
getEhsDocumentById
} from '@/api/ehs/ehsDocument'
import { addEhsDocTransfer, listEhsDocTransfer, lendEhsDoc, returnEhsDoc } from '@/api/ehs/ehsDocTransfer'
import { parseTime } from '../../../utils/ruoyi'
import dict from '@/utils/dict'
export default {
name: "EhsDocument",
name: 'EhsDocument',
dicts: ['doc_type', 'doc_transfer_status'],
data() {
return {
@ -252,55 +309,57 @@ export default {
//
ehsDocTransferList: [],
//
title: "",
title1: "",
title: '',
title1: '',
title2: '',
//
open: false,
open1: false,
open2: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
docName: null,
docType: null,
docType: null
},
//
form: {},
//
rules: {
rules: {}
}
};
},
created() {
this.getList();
this.getList()
// 稿
this.getAllDraftDept();
this.getAllDraftDept()
},
methods: {
dict,
parseTime,
/** 查询公文管理列表 */
getList() {
this.loading = true;
this.loading = true
listEhsDocument(this.queryParams).then(response => {
this.ehsDocumentList = response.rows;
this.total = response.total;
this.loading = false;
});
this.ehsDocumentList = response.rows
this.total = response.total
this.loading = false
})
},
/** 获取拟稿部门下拉列表 */
getAllDraftDept() {
getAllDraftDept().then((res) => {
console.log(res);
this.ngbmInfo = res.data;
});
console.log(res)
this.ngbmInfo = res.data
})
},
//
cancel() {
this.open = false;
this.open1 = false;
this.reset();
this.open = false
this.open1 = false
this.open2 = false
this.reset()
},
//
reset() {
@ -320,18 +379,18 @@ export default {
deptId: null,
createUserId: null,
updateUserId: null
};
this.resetForm("form");
}
this.resetForm('form')
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
this.resetForm('queryForm')
this.handleQuery()
},
//
handleSelectionChange(selection) {
@ -341,63 +400,100 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "公文登记";
this.reset()
this.open = true
this.title = '公文登记'
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.reset()
const id = row.id || this.ids
getEhsDocument(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改公文";
});
this.form = response.data
this.open = true
this.title = '修改公文'
})
},
/** 借出按钮操作 */
handleLend(row) {
this.reset()
const id = row.id || this.ids
getEhsDocumentById(id).then(response => {
this.form = response.data
this.open2 = true
this.title2 = '借出信息'
})
},
/** 归还操作 */
returnDoc(row) {
const id = row.id || this.ids;
returnEhsDoc(id).then(response => {
this.$modal.msgSuccess('归还成功')
this.getList()
})
/* lendEhsDoc(this.form).then(response => {
this.$modal.msgSuccess('借出成功')
this.open2 = false
this.getList()
}) */
},
/** 流转记录按钮操作 */
transferRecord(row) {
this.reset();
const id = row.id || this.ids;
this.reset()
const id = row.id || this.ids
/** 查询公文流转记录 */
getDocTransferById(id).then(response => {
this.open1 = true;
this.loading = true;
this.title1 = "流转记录";
this.ehsDocTransferList = response.rows;
this.open1 = true
this.loading = true
this.title1 = '流转记录'
this.ehsDocTransferList = response.rows
//this.total1 = response.total;
this.loading = false;
});
this.loading = false
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateEhsDocument(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
this.$modal.msgSuccess('修改成功')
this.open = false
this.getList()
})
} else {
addEhsDocument(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
this.$modal.msgSuccess('新增成功')
this.open = false
this.getList()
})
}
}
});
})
},
/** 提交借出信息 */
submitLendForm() {
this.$refs['form'].validate(valid => {
if (valid) {
lendEhsDoc(this.form).then(response => {
this.$modal.msgSuccess('借出成功')
this.open2 = false
this.getList()
})
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
const ids = row.id || this.ids
this.$modal.confirm('是否确认删除公文管理编号为"' + ids + '"的数据项?').then(function() {
return delEhsDocument(ids);
return delEhsDocument(ids)
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
this.getList()
this.$modal.msgSuccess('删除成功')
}).catch(() => {
})
},
/** 导出按钮操作 */
handleExport() {
@ -406,5 +502,5 @@ export default {
}, `ehsDocument_${new Date().getTime()}.xlsx`)
}
}
};
}
</script>

Loading…
Cancel
Save