Merge branch 'main' of http://62.234.3.186:3000/sxyanzhu/YanZhuProject
commit
6d6a08686e
|
@ -5,8 +5,12 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.yanzhu.common.constant.Constants;
|
||||
import com.yanzhu.common.core.domain.entity.SysDept;
|
||||
import com.yanzhu.common.core.domain.entity.SysUser;
|
||||
import com.yanzhu.common.core.redis.RedisCache;
|
||||
import com.yanzhu.system.service.ISysDeptService;
|
||||
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -38,7 +42,8 @@ public class BaseAssetsTypeController extends BaseController
|
|||
{
|
||||
@Autowired
|
||||
private IBaseAssetsTypeService baseAssetsTypeService;
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService sysDeptService;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
|
@ -97,9 +102,30 @@ public class BaseAssetsTypeController extends BaseController
|
|||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BaseAssetsType baseAssetsType)
|
||||
{
|
||||
updateDeptUnit(baseAssetsType);
|
||||
return toAjax(baseAssetsTypeService.insertBaseAssetsType(baseAssetsType));
|
||||
}
|
||||
|
||||
void updateDeptUnit(BaseAssetsType baseAssetsType){
|
||||
long deptId= baseAssetsType.getDeptId();
|
||||
String unit=baseAssetsType.getUnit();
|
||||
if(unit==null || unit.trim().length()==0){
|
||||
unit="";
|
||||
}
|
||||
String[] tmps= unit.split("[|]");
|
||||
baseAssetsType.setUnit("");
|
||||
if(tmps.length>0){
|
||||
baseAssetsType.setUnit(tmps[0]);
|
||||
}
|
||||
if(tmps.length>1){
|
||||
SysDept dept= sysDeptService.selectDeptById(deptId);
|
||||
if(dept!=null){
|
||||
dept.setUnit(tmps[1]);
|
||||
sysDeptService.updateDept(dept);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物资类型
|
||||
*/
|
||||
|
@ -108,6 +134,7 @@ public class BaseAssetsTypeController extends BaseController
|
|||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BaseAssetsType baseAssetsType)
|
||||
{
|
||||
updateDeptUnit(baseAssetsType);
|
||||
return toAjax(baseAssetsTypeService.updateBaseAssetsType(baseAssetsType));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
</el-form-item>
|
||||
|
||||
<el-form-item label="项目名称" prop="defaultDeptId">
|
||||
<el-select v-model="queryParams.defaultDeptId" placeholder="请选择项目名称">
|
||||
<el-option v-for="it in prjOpts" :key="it.deptId" :label="it.deptName" :value="it.deptId" @change="doPrjChange"/>
|
||||
<el-select v-model="queryParams.defaultDeptId" placeholder="请选择项目名称" @change="doPrjChange">
|
||||
<el-option v-for="it in prjOpts" :key="it.deptId" :label="it.deptName" :value="it.deptId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
|
||||
<el-table v-loading="loading" :data="assetsTypeList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="主键" align="center" prop="id" width="55"/>
|
||||
<el-table-column label="主键" align="center" prop="id" width="55" />
|
||||
<el-table-column label="资产类型" align="center" prop="type" width="120">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_process_category" :value="scope.row.type" />
|
||||
|
@ -69,10 +69,10 @@
|
|||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160">
|
||||
<template slot-scope="scope">
|
||||
<template v-if="scope.row.deptId">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['base:assetsType:edit']">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['base:assetsType:remove']">删除</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['base:assetsType:edit']">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['base:assetsType:remove']">删除</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -82,15 +82,15 @@
|
|||
@pagination="getList" />
|
||||
|
||||
<!-- 添加或修改物资类型对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body custom-class="assets-type-dialog">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="公司名称">
|
||||
<el-input v-model="form.compName" disabled/>
|
||||
<el-input v-model="form.compName" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目名称">
|
||||
<el-input v-model="form.deptName" disabled/>
|
||||
<el-input v-model="form.deptName" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="一级分类" prop="type" >
|
||||
<el-form-item label="一级分类" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择资产类型" @change="doLvl1Change">
|
||||
<el-option v-for="dict in dict.type.sys_process_category" :key="dict.value" :label="dict.label"
|
||||
:value="dict.value"></el-option>
|
||||
|
@ -98,16 +98,22 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="二级分类" prop="parentId">
|
||||
<el-select v-model="form.parentId" placeholder="请选择资产类型">
|
||||
<el-option v-for="it in lvl2Opts" :key="it.id" :label="it.name"
|
||||
:value="it.id"></el-option>
|
||||
<el-option v-for="it in lvl2Opts" :key="it.id" :label="it.name" :value="it.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="资产名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入资产名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="资产单位" prop="unit">
|
||||
<el-input v-model="form.unit" placeholder="请输入资产单位" />
|
||||
</el-form-item>
|
||||
<el-form-item label="资产单位" prop="sunit">
|
||||
<el-input v-model="form.sunit" placeholder="请输入资产单位" />
|
||||
</el-form-item>
|
||||
<div class="div-unit">
|
||||
<el-tag v-for="(it, idx) in units" :class="{ 'is-selected': it.sel, 'is-del': it.del }" @close="doCloseTag(it, idx)"
|
||||
:closable="!it.sys" @click="doSelTag(it)" :key="idx">
|
||||
<i class="el-icon-check"></i>
|
||||
{{ it.text }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
|
@ -118,18 +124,19 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { listAssetsType, getAssetsType, delAssetsType, addAssetsType, updateAssetsType,listLevel2 } from "@/api/base/assetsType";
|
||||
import { listAssetsType, getAssetsType, delAssetsType, addAssetsType, updateAssetsType, listLevel2 } from "@/api/base/assetsType";
|
||||
import { listDept } from '@/api/system/dept'
|
||||
export default {
|
||||
name: "AssetsType",
|
||||
dicts: ['sys_process_category', 'sys_is_del'],
|
||||
data() {
|
||||
return {
|
||||
lvlDatas:[],
|
||||
units: [],
|
||||
lvlDatas: [],
|
||||
deptOpts: [],
|
||||
compyOpts: [],
|
||||
prjOpts: [],
|
||||
lvl2Opts:[],
|
||||
lvl2Opts: [],
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
|
@ -150,7 +157,7 @@ export default {
|
|||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
parentId:-1,
|
||||
parentId: -1,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
compyId: null,
|
||||
|
@ -164,7 +171,9 @@ export default {
|
|||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [{ required: true, message: "资产名称不能为空", trigger: "blur" }]
|
||||
}
|
||||
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
@ -173,44 +182,79 @@ export default {
|
|||
this.compyOpts = this.deptOpts.filter(it => it.parentId == 100)
|
||||
if (this.compyOpts.length > 0) {
|
||||
this.queryParams.compyId = this.compyOpts[0].deptId;
|
||||
this.form.compName=this.compyOpts[0].deptName;
|
||||
this.form.compName = this.compyOpts[0].deptName;
|
||||
this.prjOpts = this.deptOpts.filter(it => it.parentId == this.queryParams.compyId);
|
||||
if (this.prjOpts.length > 0) {
|
||||
this.queryParams.defaultDeptId = this.prjOpts[0].deptId;
|
||||
this.form.deptName=this.prjOpts[0].deptName;
|
||||
this.doPrjChange(this.queryParams.defaultDeptId)
|
||||
this.form.deptName = this.prjOpts[0].deptName;
|
||||
this.getList();
|
||||
}
|
||||
}
|
||||
});
|
||||
listLevel2().then(d=>{
|
||||
this.lvlDatas=d.data;
|
||||
listLevel2().then(d => {
|
||||
this.lvlDatas = d.data;
|
||||
})
|
||||
|
||||
},
|
||||
methods: {
|
||||
doLvl1Change(a){
|
||||
this.lvl2Opts=this.lvlDatas.filter(d=>d.type==a);
|
||||
if(this.lvl2Opts.length>0){
|
||||
this.form.parentId=this.lvl2Opts[0].id;
|
||||
}
|
||||
doCloseTag(tag) {
|
||||
if (tag.del) {
|
||||
tag.del = false
|
||||
} else {
|
||||
tag.sel = false
|
||||
tag.del = true
|
||||
}
|
||||
},
|
||||
doSelTag(tag) {
|
||||
if (tag.del) {
|
||||
return;
|
||||
}
|
||||
tag.sel = !tag.sel;
|
||||
},
|
||||
doLvl1Change(a) {
|
||||
this.lvl2Opts = this.lvlDatas.filter(d => d.type == a);
|
||||
if (this.lvl2Opts.length > 0) {
|
||||
this.form.parentId = this.lvl2Opts[0].id;
|
||||
}
|
||||
},
|
||||
doCompyChange(a) {
|
||||
let tmps=this.compyOpts.filter(d=>d.deptId==a);
|
||||
this.form.compName=tmps.length>0?tmps[0].deptName:"";
|
||||
let tmps = this.compyOpts.filter(d => d.deptId == a);
|
||||
this.form.compName = tmps.length > 0 ? tmps[0].deptName : "";
|
||||
this.prjOpts = this.deptOpts.filter(it => it.parentId == this.queryParams.compyId);
|
||||
if (this.prjOpts.length > 0) {
|
||||
this.queryParams.defaultDeptId = this.prjOpts[0].deptId;
|
||||
this.form.deptName=this.prjOpts[0].deptName;
|
||||
this.form.deptName = this.prjOpts[0].deptName;
|
||||
}
|
||||
this.handleQuery();
|
||||
},
|
||||
doPrjChange(a){
|
||||
let tmps=this.prjOpts.filter(d=>d.deptId==a);
|
||||
this.form.deptName=tmps.length>0?tmps[0].deptName:"";
|
||||
doPrjChange(a) {
|
||||
let tmps = this.prjOpts.filter(d => d.deptId == a);
|
||||
let unit = tmps.length > 0 ? tmps[0].unit || "" : "";
|
||||
unit = unit.split(",").filter(d => d).map(d => {
|
||||
return {
|
||||
text: d,
|
||||
sel: false,
|
||||
del: false,
|
||||
sys: false
|
||||
}
|
||||
});
|
||||
|
||||
let sysUnit = "米,包,吨,千克,平方,立方,把,根,个,箱,卷,台,盘,套,桶,捆,床,件,块,片,瓶,双,付,个,辆,项,张,组".split(",").filter(d => d)
|
||||
.map(d => {
|
||||
return {
|
||||
text: d,
|
||||
sel: false,
|
||||
del: false,
|
||||
sys: true
|
||||
}
|
||||
})
|
||||
this.units = [...sysUnit, ...unit];
|
||||
this.form.deptName = tmps.length > 0 ? tmps[0].deptName : "";
|
||||
},
|
||||
/** 查询物资类型列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
this.loading = true;
|
||||
listAssetsType(this.queryParams).then(response => {
|
||||
this.assetsTypeList = response.rows;
|
||||
this.total = response.total;
|
||||
|
@ -230,6 +274,7 @@ export default {
|
|||
deptId: this.queryParams.defaultDeptId,
|
||||
type: null,
|
||||
name: null,
|
||||
sunit: null,
|
||||
unit: null,
|
||||
isDel: null,
|
||||
createBy: null,
|
||||
|
@ -238,20 +283,21 @@ export default {
|
|||
updateTime: null,
|
||||
remark: null
|
||||
};
|
||||
let tmps=this.compyOpts.filter(d=>d.deptId==this.queryParams.compyId);
|
||||
this.form.compName=tmps.length>0?tmps[0].deptName:"";
|
||||
tmps=this.prjOpts.filter(d=>d.deptId==this.form.deptId);
|
||||
this.form.deptName=tmps.length>0?tmps[0].deptName:"";
|
||||
tmps=this.dict.type.sys_process_category
|
||||
if(tmps.length>0){
|
||||
this.form.type=tmps[0].value;
|
||||
this.lvl2Opts=this.lvlDatas.filter(d=>d.type==this.form.type);
|
||||
if(this.lvl2Opts.length>0){
|
||||
this.form.parentId=this.lvl2Opts[0].id;
|
||||
let tmps = this.compyOpts.filter(d => d.deptId == this.queryParams.compyId);
|
||||
this.form.compName = tmps.length > 0 ? tmps[0].deptName : "";
|
||||
tmps = this.prjOpts.filter(d => d.deptId == this.form.deptId);
|
||||
this.form.deptName = tmps.length > 0 ? tmps[0].deptName : "";
|
||||
tmps = this.dict.type.sys_process_category
|
||||
if (tmps.length > 0) {
|
||||
this.form.type = tmps[0].value;
|
||||
this.lvl2Opts = this.lvlDatas.filter(d => d.type == this.form.type);
|
||||
if (this.lvl2Opts.length > 0) {
|
||||
this.form.parentId = this.lvl2Opts[0].id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.resetForm("form");
|
||||
this.doPrjChange(this.queryParams.defaultDeptId)
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
|
@ -265,7 +311,7 @@ export default {
|
|||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(sel) {
|
||||
let selection=sel.filter(d=>d.deptId);
|
||||
let selection = sel.filter(d => d.deptId);
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
|
@ -280,8 +326,23 @@ export default {
|
|||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
let tmps=row.unit.split(",").filter(d=>d);
|
||||
let uns=this.units.map(d=>d.text).join(",")
|
||||
tmps.forEach(it=>{
|
||||
if((","+uns+",").indexOf(","+it+",")==-1){
|
||||
this.units.push({
|
||||
text:it,
|
||||
del:false,
|
||||
sys:false
|
||||
})
|
||||
}
|
||||
});
|
||||
this.units.forEach(it=>{
|
||||
it.sel=(","+row.unit+",").indexOf(","+it.text+",")>=0;
|
||||
});
|
||||
getAssetsType(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.form.sunit="";
|
||||
this.open = true;
|
||||
this.title = "修改物资类型";
|
||||
});
|
||||
|
@ -290,6 +351,16 @@ export default {
|
|||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
let unit = (this.form.sunit + "," + this.units.filter(d => d.sel && !d.del).map(d => d.text).join(",")).split(",").filter(d => d).join(",");
|
||||
let cusUnit = Array.from(new Set((this.form.sunit + "," + this.units.filter(d => !d.sys && !d.del).map(d => d.text).join(",")).split(",").filter(d => d))).join(",");
|
||||
this.form.unit = unit + "|" + cusUnit;
|
||||
let deptId = this.queryParams.defaultDeptId;
|
||||
let tmps = this.prjOpts.filter(d => d.deptId == deptId);
|
||||
if (tmps.length > 0) {
|
||||
tmps[0].unit = cusUnit;
|
||||
}
|
||||
this.doPrjChange(deptId)
|
||||
|
||||
if (this.form.id != null) {
|
||||
updateAssetsType(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
|
@ -325,3 +396,47 @@ export default {
|
|||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.assets-type-dialog {
|
||||
.div-unit {
|
||||
.el-tag {
|
||||
margin-right: 4px;
|
||||
margin-bottom: 4px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
|
||||
.el-icon-check {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&.is-del {
|
||||
position: unset;
|
||||
user-select: none;
|
||||
background-color: #ccc;
|
||||
color: #777;
|
||||
text-decoration: line-through;
|
||||
|
||||
.el-tag__close {
|
||||
color: red;
|
||||
|
||||
&:hover {
|
||||
background-color: red;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.is-selected {
|
||||
.el-icon-check {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
background: #ffba00;
|
||||
border-radius: 0px 0px 4px 0px;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}</style>
|
Loading…
Reference in New Issue