Compare commits
2 Commits
ad6568e0b4
...
b6034d30e3
| Author | SHA1 | Date |
|---|---|---|
|
|
b6034d30e3 | 4 years ago |
|
|
5f50bf0572 | 4 years ago |
@ -0,0 +1,64 @@ |
|||||||
|
package cn.toesbieya.jxc.controller.sys; |
||||||
|
|
||||||
|
import cn.toesbieya.jxc.model.entity.SysStorehouse; |
||||||
|
import cn.toesbieya.jxc.model.vo.R; |
||||||
|
import cn.toesbieya.jxc.model.vo.UserVo; |
||||||
|
import cn.toesbieya.jxc.model.vo.search.StorehouseSearch; |
||||||
|
import cn.toesbieya.jxc.service.sys.SysStorehouseService; |
||||||
|
import cn.toesbieya.jxc.util.SessionUtil; |
||||||
|
import org.springframework.util.StringUtils; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("system/storehouse") |
||||||
|
public class StorehouseController { |
||||||
|
@Resource |
||||||
|
private SysStorehouseService service; |
||||||
|
|
||||||
|
@PostMapping("search") |
||||||
|
public R search(@RequestBody StorehouseSearch vo) { |
||||||
|
return R.success(service.search(vo)); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("add") |
||||||
|
public R add(@RequestBody SysStorehouse storehouse) { |
||||||
|
String errMsg = validateCreateParam(storehouse); |
||||||
|
if (errMsg != null) return R.fail("添加失败," + errMsg); |
||||||
|
|
||||||
|
//添加创建人、创建时间
|
||||||
|
UserVo user = SessionUtil.get(); |
||||||
|
storehouse.setCreatorId(user.getId()); |
||||||
|
storehouse.setCreateTime(System.currentTimeMillis()); |
||||||
|
|
||||||
|
return service.add(storehouse); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("update") |
||||||
|
public R update(@RequestBody SysStorehouse storehouse) { |
||||||
|
String errMsg = validateUpdateParam(storehouse); |
||||||
|
return errMsg == null ? service.update(storehouse) : R.fail("修改失败," + errMsg); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("del") |
||||||
|
public R del(@RequestBody SysStorehouse storehouse) { |
||||||
|
if (storehouse.getId() == null) return R.fail("删除失败,参数错误"); |
||||||
|
return service.del(storehouse); |
||||||
|
} |
||||||
|
|
||||||
|
private String validateCreateParam(SysStorehouse storehouse) { |
||||||
|
if (StringUtils.isEmpty(storehouse.getId())) return "仓库编号不能为空"; |
||||||
|
if (StringUtils.isEmpty(storehouse.getName())) return "仓库名称不能为空"; |
||||||
|
if (storehouse.getLevel() == null) return "仓库级别不能为空"; |
||||||
|
if (storehouse.getType() == null) return "仓库类型不能为空"; |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
private String validateUpdateParam(SysStorehouse storehouse) { |
||||||
|
if (storehouse.getId() == null) return "参数错误"; |
||||||
|
return validateCreateParam(storehouse); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
package cn.toesbieya.jxc.mapper; |
||||||
|
|
||||||
|
import cn.toesbieya.jxc.model.entity.SysStorehouse; |
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
|
||||||
|
public interface SysStorehouseMapper extends BaseMapper<SysStorehouse> { |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,67 @@ |
|||||||
|
package cn.toesbieya.jxc.model.entity; |
||||||
|
|
||||||
|
import cn.toesbieya.jxc.enumeration.StorehouseLevelEnum; |
||||||
|
import cn.toesbieya.jxc.enumeration.StorehouseTypeEnum; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import javax.persistence.Column; |
||||||
|
/** |
||||||
|
* |
||||||
|
* @author 强子烨 |
||||||
|
* @version 1.0 |
||||||
|
* @since 2022-02-28 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class SysStorehouse { |
||||||
|
|
||||||
|
/** |
||||||
|
* 仓库编码 |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private String id; |
||||||
|
/** |
||||||
|
* 名称 |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private String name; |
||||||
|
/** |
||||||
|
* 级别,1一级(默认)、2二级 |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private Integer level = StorehouseLevelEnum.ONE.getCode(); |
||||||
|
/** |
||||||
|
* 类型,1常温(默认),2冷藏 |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private Integer type = StorehouseTypeEnum.NPT.getCode(); |
||||||
|
/** |
||||||
|
* 状态,0停用,1启用 |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private boolean enable = false; |
||||||
|
|
||||||
|
/** |
||||||
|
* 备注 |
||||||
|
*/ |
||||||
|
private String remark; |
||||||
|
/** |
||||||
|
* 创建人id |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private Integer creatorId; |
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private Long createTime; |
||||||
|
/** |
||||||
|
* 修改人id |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private Integer updateId; |
||||||
|
/** |
||||||
|
* 修改时间 |
||||||
|
*/ |
||||||
|
@Column |
||||||
|
private Long updateTime; |
||||||
|
} |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
package cn.toesbieya.jxc.model.vo; |
||||||
|
|
||||||
|
import cn.toesbieya.jxc.model.entity.SysStorehouse; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
import lombok.ToString; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
|
||||||
|
@Data |
||||||
|
@NoArgsConstructor |
||||||
|
@ToString(callSuper = true) |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class StorehouseVo extends SysStorehouse { |
||||||
|
|
||||||
|
public StorehouseVo(SysStorehouse parent){ |
||||||
|
BeanUtils.copyProperties(parent,this); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package cn.toesbieya.jxc.model.vo.search; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import lombok.ToString; |
||||||
|
|
||||||
|
@Data |
||||||
|
@ToString(callSuper = true) |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class StorehouseSearch extends BaseSearch { |
||||||
|
|
||||||
|
private String id; |
||||||
|
private String name; |
||||||
|
private Integer level; |
||||||
|
private Integer type; |
||||||
|
private Boolean enable; |
||||||
|
private Long startTime; |
||||||
|
private Long endTime; |
||||||
|
} |
||||||
@ -0,0 +1,118 @@ |
|||||||
|
package cn.toesbieya.jxc.service.sys; |
||||||
|
|
||||||
|
import cn.toesbieya.jxc.annoation.UserAction; |
||||||
|
import cn.toesbieya.jxc.mapper.SysStorehouseMapper; |
||||||
|
import cn.toesbieya.jxc.model.entity.SysStorehouse; |
||||||
|
import cn.toesbieya.jxc.model.vo.R; |
||||||
|
import cn.toesbieya.jxc.model.vo.StorehouseVo; |
||||||
|
import cn.toesbieya.jxc.model.vo.result.PageResult; |
||||||
|
import cn.toesbieya.jxc.model.vo.search.StorehouseSearch; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import com.github.pagehelper.PageHelper; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.util.StringUtils; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Service |
||||||
|
public class SysStorehouseService { |
||||||
|
@Resource |
||||||
|
private SysStorehouseMapper storehouseMapper; |
||||||
|
|
||||||
|
public List<SysStorehouse> get() { |
||||||
|
return storehouseMapper.selectList( |
||||||
|
Wrappers.lambdaQuery(SysStorehouse.class) |
||||||
|
.eq(SysStorehouse::isEnable, true) |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public PageResult<StorehouseVo> search(StorehouseSearch vo){ |
||||||
|
String id = vo.getId(); |
||||||
|
String name = vo.getName(); |
||||||
|
Integer level = vo.getLevel(); |
||||||
|
Integer type = vo.getType(); |
||||||
|
Boolean enable = vo.getEnable(); |
||||||
|
Long startTime = vo.getStartTime(); |
||||||
|
Long endTime = vo.getEndTime(); |
||||||
|
|
||||||
|
Wrapper<SysStorehouse> wrapper = |
||||||
|
Wrappers.lambdaQuery(SysStorehouse.class) |
||||||
|
.like(false, SysStorehouse::getId, id) |
||||||
|
.like(!StringUtils.isEmpty(name), SysStorehouse::getName, name) |
||||||
|
.eq(level != null, SysStorehouse::getLevel, level) |
||||||
|
.eq(type != null, SysStorehouse::getType, type) |
||||||
|
|
||||||
|
.eq(enable != null, SysStorehouse::isEnable, enable) |
||||||
|
.ge(startTime != null, SysStorehouse::getCreateTime, startTime) |
||||||
|
.le(endTime != null, SysStorehouse::getCreateTime, endTime) |
||||||
|
.orderByDesc(SysStorehouse::getCreateTime); |
||||||
|
|
||||||
|
PageHelper.startPage(vo.getPage(), vo.getPageSize()); |
||||||
|
|
||||||
|
List<SysStorehouse> storehouses = storehouseMapper.selectList(wrapper); |
||||||
|
|
||||||
|
PageResult<SysStorehouse> pageResult = new PageResult<>(storehouses); |
||||||
|
|
||||||
|
int storehouseNum = storehouses.size(); |
||||||
|
|
||||||
|
List<StorehouseVo> list = new ArrayList<>(storehouseNum); |
||||||
|
|
||||||
|
storehouses.forEach(storehouse -> list.add(new StorehouseVo(storehouse))); |
||||||
|
|
||||||
|
return new PageResult<>(pageResult.getTotal(), list); |
||||||
|
} |
||||||
|
|
||||||
|
@UserAction("'添加仓库:'+ #storehouse.name") |
||||||
|
public R add(SysStorehouse storehouse) { |
||||||
|
if (isNameExist(storehouse.getName(), null)) { |
||||||
|
return R.fail(String.format("添加失败,仓库【%s】已存在", storehouse.getName())); |
||||||
|
} |
||||||
|
int rows = storehouseMapper.insert(storehouse); |
||||||
|
return rows > 0 ? R.success("添加成功") : R.fail("添加失败"); |
||||||
|
} |
||||||
|
|
||||||
|
@UserAction("'修改仓库:'+ #storehouse.name") |
||||||
|
public R update(SysStorehouse storehouse) { |
||||||
|
String id = storehouse.getId(); |
||||||
|
String name = storehouse.getName(); |
||||||
|
|
||||||
|
if (isNameExist(name, id)) { |
||||||
|
return R.fail(String.format("修改失败,供应商【%s】已存在", name)); |
||||||
|
} |
||||||
|
|
||||||
|
storehouseMapper.update( |
||||||
|
null, |
||||||
|
Wrappers.lambdaUpdate(SysStorehouse.class) |
||||||
|
.set(SysStorehouse::getName, name) |
||||||
|
.set(SysStorehouse::getLevel, storehouse.getLevel()) |
||||||
|
.set(SysStorehouse::getType, storehouse.getType()) |
||||||
|
.set(SysStorehouse::isEnable, storehouse.isEnable()) |
||||||
|
//添加修改人 .set(SysStorehouse::getUpdateId, storehouse.getRegion())
|
||||||
|
//添加修改时间 .set(SysStorehouse::getUpdateTime, storehouse.isEnable())
|
||||||
|
.eq(SysStorehouse::getId, id) |
||||||
|
); |
||||||
|
return R.success("修改成功"); |
||||||
|
} |
||||||
|
|
||||||
|
@UserAction("'删除仓库:'+ #storehouse.name") |
||||||
|
public R del(SysStorehouse storehouse) { |
||||||
|
int rows = storehouseMapper.delete( |
||||||
|
Wrappers.lambdaQuery(SysStorehouse.class) |
||||||
|
.eq(SysStorehouse::getId, storehouse.getId()) |
||||||
|
.eq(SysStorehouse::isEnable, false) |
||||||
|
); |
||||||
|
return rows > 0 ? R.success("删除成功") : R.fail("删除失败,请刷新重试"); |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isNameExist(String name, String id) { |
||||||
|
Integer num = storehouseMapper.selectCount( |
||||||
|
Wrappers.lambdaQuery(SysStorehouse.class) |
||||||
|
.eq(SysStorehouse::getName, name) |
||||||
|
.ne(!StringUtils.isEmpty(id), SysStorehouse::getId, id) |
||||||
|
); |
||||||
|
return num != null && num > 0; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,9 @@ |
|||||||
|
import {PostApi} from "@/api/request" |
||||||
|
|
||||||
|
export const search = new PostApi(`/system/storehouse/search`) |
||||||
|
|
||||||
|
export const add = new PostApi(`/system/storehouse/add`) |
||||||
|
|
||||||
|
export const update = new PostApi(`/system/storehouse/update`) |
||||||
|
|
||||||
|
export const del = new PostApi(`/system/storehouse/del`) |
||||||
@ -0,0 +1,154 @@ |
|||||||
|
<template> |
||||||
|
<abstract-dialog :loading="loading" :title="title" :value="value" @close="cancel" @open="open"> |
||||||
|
<abstract-form :model="form" :rules="rules"> |
||||||
|
<el-form-item label="编 码" prop="id"> |
||||||
|
<el-input v-model="form.id" :readonly="!canEdit" maxlength="20"/> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="名 称" prop="name"> |
||||||
|
<el-input v-model="form.name" :readonly="!canEdit" maxlength="20"/> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="级 别" prop="level"> |
||||||
|
<el-select v-model="form.level" clearable @clear="form.level=null"> |
||||||
|
<el-option :value="1" label="一级"/> |
||||||
|
<el-option :value="2" label="二级"/> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="类 型" prop="type"> |
||||||
|
<el-select v-model="form.type" clearable @clear="form.type=null"> |
||||||
|
<el-option :value="1" label="常温"/> |
||||||
|
<el-option :value="2" label="冷藏"/> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="状 态" prop="enable"> |
||||||
|
<el-radio-group v-model="form.enable" :disabled="!canEdit"> |
||||||
|
<el-radio :label="true">启用</el-radio> |
||||||
|
<el-radio :label="false">禁用</el-radio> |
||||||
|
</el-radio-group> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="备 注" prop="remark"> |
||||||
|
<el-input |
||||||
|
v-model="form.remark" |
||||||
|
:rows="4" |
||||||
|
:readonly="!canEdit" |
||||||
|
maxlength="200" |
||||||
|
show-word-limit |
||||||
|
type="textarea" |
||||||
|
/> |
||||||
|
</el-form-item> |
||||||
|
</abstract-form> |
||||||
|
|
||||||
|
<template v-slot:footer> |
||||||
|
<el-button plain size="small" @click="closeDialog">取 消</el-button> |
||||||
|
<el-button v-if="canEdit" size="small" type="primary" @click="confirm">确 定</el-button> |
||||||
|
</template> |
||||||
|
</abstract-dialog> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import dialogMixin from "@/mixin/dialogMixin" |
||||||
|
import AbstractForm from "@/component/abstract/Form" |
||||||
|
import AbstractDialog from '@/component/abstract/Dialog' |
||||||
|
import {add, update} from "@/api/system/storehouse" |
||||||
|
import {isEmpty, mergeObj, resetObj} from '@/util' |
||||||
|
import {elConfirm} from "@/util/message" |
||||||
|
|
||||||
|
export default { |
||||||
|
name: "EditDialog", |
||||||
|
|
||||||
|
mixins: [dialogMixin], |
||||||
|
|
||||||
|
components: {AbstractForm, AbstractDialog}, |
||||||
|
|
||||||
|
props: { |
||||||
|
value: Boolean, |
||||||
|
type: {type: String, default: 'see'}, |
||||||
|
data: { |
||||||
|
type: Object, |
||||||
|
default: () => ({}) |
||||||
|
}, |
||||||
|
}, |
||||||
|
|
||||||
|
data() { |
||||||
|
return { |
||||||
|
loading: false, |
||||||
|
form: { |
||||||
|
id: null, |
||||||
|
name: null, |
||||||
|
level: null, |
||||||
|
type: null, |
||||||
|
enable: false, |
||||||
|
remark: null |
||||||
|
}, |
||||||
|
rules: { |
||||||
|
id: [{required: true, message: '编号不能为空', trigger: 'change'}], |
||||||
|
level: [{required: true, message: '级别不能为空', trigger: 'change'}], |
||||||
|
type: [{required: true, message: '类型不能为空', trigger: 'change'}], |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
computed: { |
||||||
|
title() { |
||||||
|
if (isEmpty(this.type)) return '' |
||||||
|
switch (this.type) { |
||||||
|
case 'see': |
||||||
|
return '仓库信息' |
||||||
|
case 'add': |
||||||
|
return '添加仓库' |
||||||
|
case 'edit': |
||||||
|
return '编辑仓库' |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
confirmMessage() { |
||||||
|
switch (this.type) { |
||||||
|
case 'add': |
||||||
|
return `确认添加新的仓库【${this.form.name}】?` |
||||||
|
case 'edit': |
||||||
|
return `确认提交对【${this.data.name}】作出的修改?` |
||||||
|
default: |
||||||
|
return '' |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
canEdit() { |
||||||
|
return ['add', 'edit'].includes(this.type) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
methods: { |
||||||
|
|
||||||
|
open() { |
||||||
|
if (this.type !== 'add') mergeObj(this.form, this.data) |
||||||
|
}, |
||||||
|
|
||||||
|
clearForm() { |
||||||
|
resetObj(this.form) |
||||||
|
this.$nextTick(() => this.$refs.form.clearValidate()) |
||||||
|
}, |
||||||
|
|
||||||
|
cancel() { |
||||||
|
this.closeDialog() |
||||||
|
this.clearForm() |
||||||
|
}, |
||||||
|
|
||||||
|
confirm() { |
||||||
|
if (this.loading) return |
||||||
|
this.$refs.form.validate(v => { |
||||||
|
if (!v) return |
||||||
|
elConfirm(this.confirmMessage) |
||||||
|
.then(() => { |
||||||
|
this.loading = true |
||||||
|
return this.type === 'add' ? add.request(this.form) : update.request(this.form) |
||||||
|
}) |
||||||
|
.then(({msg}) => { |
||||||
|
this.$emit('success', msg) |
||||||
|
}) |
||||||
|
.finally(() => { |
||||||
|
this.loading = false |
||||||
|
}) |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
@ -0,0 +1,180 @@ |
|||||||
|
<template> |
||||||
|
<list-page :data="listPageConfig"> |
||||||
|
<template v-slot:searchForm> |
||||||
|
<el-form-item label="编 码"> |
||||||
|
<el-input v-model="searchForm.id" clearable maxlength="100"/> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="名 称"> |
||||||
|
<el-input v-model="searchForm.name" clearable maxlength="100"/> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="级 别"> |
||||||
|
<el-select v-model="searchForm.level" clearable @clear="searchForm.level=null"> |
||||||
|
<el-option :value="1" label="一级"/> |
||||||
|
<el-option :value="2" label="二级"/> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="类 型"> |
||||||
|
<el-select v-model="searchForm.type" clearable @clear="searchForm.type=null"> |
||||||
|
<el-option :value="1" label="常温"/> |
||||||
|
<el-option :value="2" label="冷藏"/> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="状 态"> |
||||||
|
<el-select v-model="searchForm.enable" clearable @clear="searchForm.enable=null"> |
||||||
|
<el-option :value="0" label="停用"/> |
||||||
|
<el-option :value="1" label="启用"/> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
</template> |
||||||
|
|
||||||
|
<template v-slot:tableColumn> |
||||||
|
<el-table-column align="center" label="编 码" prop="id" width="80"/> |
||||||
|
<el-table-column align="center" label="名 称" prop="name" show-overflow-tooltip/> |
||||||
|
<el-table-column align="center" label="级 别" show-overflow-tooltip> |
||||||
|
<template v-slot="{row}">{{ row.level == 1 ? '一级' : '二级' }}</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column align="center" label="类 型" show-overflow-tooltip> |
||||||
|
<template v-slot="{row}">{{ row.type == 1 ? '常温' : '冷藏' }}</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<el-table-column align="center" label="状 态" width="120"> |
||||||
|
<template v-slot="{row}"> |
||||||
|
<span :class="row.enable ? 'success' : 'error'" class="dot"/> |
||||||
|
<span>{{ row.enable ? '启用' : '禁用' }}</span> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<el-table-column align="center" label="创建人" prop="pname" show-overflow-tooltip/> |
||||||
|
<el-table-column align="center" label="创建时间" width="150"> |
||||||
|
<template v-slot="{row}">{{ row.ptime | timestamp2Date }}</template> |
||||||
|
</el-table-column> |
||||||
|
</template> |
||||||
|
|
||||||
|
<edit-dialog v-model="editDialog" :data="row" :type="type" @success="success"/> |
||||||
|
</list-page> |
||||||
|
</template> |
||||||
|
<script> |
||||||
|
import tableMixin from '@/mixin/tablePageMixin' |
||||||
|
import ListPage from '@/view/_common/ListPage' |
||||||
|
import EditDialog from './EditDialog' |
||||||
|
import {add, update, del, search} from "@/api/system/storehouse" |
||||||
|
import {isEmpty} from '@/util' |
||||||
|
import {wic} from "@/util/auth" |
||||||
|
import {elConfirm, elError, elSuccess} from "@/util/message" |
||||||
|
|
||||||
|
export default { |
||||||
|
name: "storehouseManagement", |
||||||
|
|
||||||
|
mixins: [tableMixin], |
||||||
|
|
||||||
|
components: {ListPage, EditDialog }, |
||||||
|
|
||||||
|
data() { |
||||||
|
return { |
||||||
|
searchForm: { |
||||||
|
id: '', |
||||||
|
name: '', |
||||||
|
level: '', |
||||||
|
type: '', |
||||||
|
enable: null, |
||||||
|
}, |
||||||
|
temp: { |
||||||
|
createTime: [] |
||||||
|
}, |
||||||
|
editDialog: false |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
computed: { |
||||||
|
...wic({add, update, del}), |
||||||
|
|
||||||
|
listPageConfig() { |
||||||
|
return { |
||||||
|
pageLoading: this.config.operating, |
||||||
|
buttons: [ |
||||||
|
this.canAdd && {icon: 'el-icon-plus', e: this.add, content: '添 加'}, |
||||||
|
{icon: 'el-icon-view', e: this.see, content: '查 看'}, |
||||||
|
this.canUpdate && {icon: 'el-icon-edit', e: this.edit, content: '编 辑'}, |
||||||
|
this.canDel && {icon: 'el-icon-delete', e: this.del, content: '删 除'} |
||||||
|
], |
||||||
|
dataLoading: this.config.loading, |
||||||
|
search: { |
||||||
|
props: {model: this.searchForm}, |
||||||
|
on: {search: this.search} |
||||||
|
}, |
||||||
|
table: { |
||||||
|
props: {data: this.tableData}, |
||||||
|
on: {'row-click': this.rowClick} |
||||||
|
}, |
||||||
|
pagination: { |
||||||
|
props: {model: this.searchForm}, |
||||||
|
on: {'current-change': this.pageChange} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
methods: { |
||||||
|
mergeSearchForm() { |
||||||
|
return { |
||||||
|
...this.searchForm, |
||||||
|
startTime: this.temp.createTime ? this.temp.createTime[0] : null, |
||||||
|
endTime: this.temp.createTime ? this.temp.createTime[1] + 86400000 : null |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
search() { |
||||||
|
if (this.config.loading) return |
||||||
|
this.config.loading = true |
||||||
|
this.row = null |
||||||
|
this.type = 'see' |
||||||
|
search |
||||||
|
.request(this.mergeSearchForm()) |
||||||
|
.then(({data: {list, total}}) => { |
||||||
|
this.searchForm.total = total |
||||||
|
this.tableData = list |
||||||
|
console.log(list,total) |
||||||
|
}) |
||||||
|
|
||||||
|
.finally(() => this.config.loading = false) |
||||||
|
}, |
||||||
|
|
||||||
|
add() { |
||||||
|
this.row = null |
||||||
|
this.type = 'add' |
||||||
|
this.editDialog = true |
||||||
|
}, |
||||||
|
|
||||||
|
see() { |
||||||
|
if (isEmpty(this.row)) return elError('请选择要查看的仓库') |
||||||
|
this.type = 'see' |
||||||
|
this.editDialog = true |
||||||
|
}, |
||||||
|
|
||||||
|
edit() { |
||||||
|
if (isEmpty(this.row)) return elError('请选择要编辑的仓库') |
||||||
|
this.type = 'edit' |
||||||
|
this.editDialog = true |
||||||
|
}, |
||||||
|
|
||||||
|
del() { |
||||||
|
if (isEmpty(this.row)) return elError('请选择要删除的仓库') |
||||||
|
if (this.row.enable) return elError('已启用的仓库不能删除') |
||||||
|
if (this.config.operating) return |
||||||
|
elConfirm(`确定删除仓库【${this.row.name}】?`) |
||||||
|
.then(() => { |
||||||
|
this.config.operating = true |
||||||
|
return del.request({id: this.row.id, name: this.row.name}) |
||||||
|
}) |
||||||
|
.then(() => this.success('删除成功')) |
||||||
|
.finally(() => this.config.operating = false) |
||||||
|
}, |
||||||
|
|
||||||
|
success(msg) { |
||||||
|
elSuccess(msg) |
||||||
|
this.editDialog = false |
||||||
|
this.search() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
Loading…
Reference in new issue