parent
c7030888b2
commit
5757d71a60
@ -0,0 +1,57 @@ |
||||
package cn.toesbieya.jxc.controller.sys; |
||||
import cn.toesbieya.jxc.model.entity.SysLocation; |
||||
import cn.toesbieya.jxc.model.vo.UserVo; |
||||
import cn.toesbieya.jxc.model.vo.search.LocationSearch; |
||||
import cn.toesbieya.jxc.service.sys.SysLocationService; |
||||
import cn.toesbieya.jxc.model.vo.R; |
||||
import cn.toesbieya.jxc.util.SessionUtil; |
||||
import org.springframework.util.StringUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import javax.annotation.Resource; |
||||
|
||||
@RestController |
||||
@RequestMapping("system/location") |
||||
public class LocationController { |
||||
@Resource |
||||
private SysLocationService service; |
||||
|
||||
@PostMapping("search") |
||||
public R search(@RequestBody LocationSearch vo) { |
||||
return R.success(service.search(vo)); |
||||
} |
||||
|
||||
@PostMapping("add") |
||||
public R add(@RequestBody SysLocation location) { |
||||
String errMsg = validateCreateParam(location); |
||||
if (errMsg != null) return R.fail("添加失败," + errMsg); |
||||
UserVo user = SessionUtil.get(); |
||||
location.setId(null); |
||||
location.setCreateTime(System.currentTimeMillis()); |
||||
location.setCreatorId(user.getId()); |
||||
location.setCreatorName(user.getNickName()); |
||||
return service.add(location); |
||||
} |
||||
|
||||
@PostMapping("update") |
||||
public R update(@RequestBody SysLocation location) { |
||||
String errMsg = validateUpdateParam(location); |
||||
return errMsg == null ? service.update(location) : R.fail("修改失败," + errMsg); |
||||
} |
||||
|
||||
@PostMapping("del") |
||||
public R del(@RequestBody SysLocation location) { |
||||
if (location.getId() == null) return R.fail("删除失败,参数错误"); |
||||
return service.del(location); |
||||
} |
||||
|
||||
private String validateCreateParam(SysLocation location) { |
||||
if (StringUtils.isEmpty(location.getName())) return "货位名称不能为空"; |
||||
return null; |
||||
} |
||||
|
||||
private String validateUpdateParam(SysLocation location) { |
||||
if (location.getId() == null) return "参数错误"; |
||||
return validateCreateParam(location); |
||||
} |
||||
} |
||||
|
||||
@ -1,12 +1,9 @@ |
||||
package cn.toesbieya.jxc.mapper; |
||||
|
||||
import cn.toesbieya.jxc.model.entity.SysEquipment; |
||||
import cn.toesbieya.jxc.model.vo.result.RegionValueResult; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface SysEquipmentMapper extends BaseMapper<SysEquipment> { |
||||
List<RegionValueResult> getLimitRegion(); |
||||
|
||||
} |
||||
|
||||
@ -0,0 +1,8 @@ |
||||
package cn.toesbieya.jxc.mapper; |
||||
import cn.toesbieya.jxc.model.entity.SysLocation; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
|
||||
public interface SysLocationMapper extends BaseMapper<SysLocation> { |
||||
|
||||
} |
||||
@ -0,0 +1,57 @@ |
||||
package cn.toesbieya.jxc.model.entity; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
@Data |
||||
@Builder |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class SysLocation { |
||||
/** |
||||
* 货位id |
||||
*/ |
||||
private Integer id; |
||||
/** |
||||
* 货位名称 |
||||
*/ |
||||
private String name; |
||||
/** |
||||
* 仓位容量 |
||||
*/ |
||||
private int capacity; |
||||
/** |
||||
* 仓库name |
||||
*/ |
||||
private String storehouseName; |
||||
/** |
||||
* 仓库id |
||||
*/ |
||||
private Integer storehouseId; |
||||
/** |
||||
* 状态,0停用,1启用 |
||||
*/ |
||||
private boolean enable = false; |
||||
/** |
||||
* 创建人id |
||||
*/ |
||||
private Integer creatorId; |
||||
/** |
||||
* 创建人昵称 |
||||
*/ |
||||
private String creatorName; |
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Long createTime; |
||||
/** |
||||
* 修改人id |
||||
*/ |
||||
private Integer updateId; |
||||
/** |
||||
* 修改时间 |
||||
*/ |
||||
private Long updateTime; |
||||
} |
||||
@ -0,0 +1,20 @@ |
||||
package cn.toesbieya.jxc.model.vo; |
||||
|
||||
import cn.toesbieya.jxc.model.entity.SysLocation; |
||||
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 LocationVo extends SysLocation { |
||||
private String regionName; |
||||
|
||||
public LocationVo(SysLocation parent) { |
||||
BeanUtils.copyProperties(parent, this); |
||||
} |
||||
} |
||||
@ -0,0 +1,18 @@ |
||||
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 LocationSearch extends BaseSearch { |
||||
private Integer id; |
||||
private String name; |
||||
private String storehouseName; |
||||
private String creatorName; |
||||
private Boolean enable; |
||||
private Long startTime; |
||||
private Long endTime; |
||||
} |
||||
@ -0,0 +1,106 @@ |
||||
package cn.toesbieya.jxc.service.sys; |
||||
import cn.toesbieya.jxc.annoation.UserAction; |
||||
import cn.toesbieya.jxc.mapper.SysLocationMapper; |
||||
import cn.toesbieya.jxc.model.entity.SysLocation; |
||||
import cn.toesbieya.jxc.model.vo.LocationVo; |
||||
import cn.toesbieya.jxc.model.vo.R; |
||||
import cn.toesbieya.jxc.model.vo.result.PageResult; |
||||
import cn.toesbieya.jxc.model.vo.search.LocationSearch; |
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.github.pagehelper.PageHelper; |
||||
import org.springframework.stereotype.Service; |
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class SysLocationService { |
||||
@Resource |
||||
private SysLocationMapper LocationMapper; |
||||
|
||||
public PageResult<LocationVo> search(LocationSearch vo){ |
||||
Integer id = vo.getId(); |
||||
String name = vo.getName(); |
||||
String storehouseName = vo.getStorehouseName(); |
||||
String creatorName = vo.getCreatorName(); |
||||
Boolean enable = vo.getEnable(); |
||||
Long startTime = vo.getStartTime(); |
||||
Long endTime = vo.getEndTime(); |
||||
|
||||
Wrapper<SysLocation> wrapper = |
||||
Wrappers.lambdaQuery(SysLocation.class) |
||||
.eq(id != null,SysLocation::getId,id) |
||||
.like(!StringUtils.isEmpty(name),SysLocation::getName,name) |
||||
.like(!StringUtils.isEmpty(storehouseName),SysLocation::getStorehouseName,storehouseName) |
||||
.like(!StringUtils.isEmpty(creatorName),SysLocation::getCreatorName,creatorName) |
||||
.eq(enable != null,SysLocation::isEnable,enable) |
||||
.ge(startTime != null,SysLocation::getCreateTime,startTime) |
||||
.le(endTime != null,SysLocation::getCreateTime,endTime) |
||||
.orderByDesc(SysLocation::getCreateTime); |
||||
|
||||
PageHelper.startPage(vo.getPage(), vo.getPageSize()); |
||||
|
||||
List<SysLocation> Locations = LocationMapper.selectList(wrapper); |
||||
|
||||
PageResult<SysLocation> pageResult = new PageResult<>(Locations); |
||||
|
||||
int LocationNum = Locations.size(); |
||||
|
||||
List<LocationVo> list = new ArrayList<>(LocationNum); |
||||
|
||||
Locations.forEach(Location -> { |
||||
list.add(new LocationVo(Location)); |
||||
}); |
||||
|
||||
return new PageResult<>(pageResult.getTotal(),list); |
||||
} |
||||
|
||||
@UserAction("'添加货位:'+ #Location.name") |
||||
public R add(SysLocation Location){ |
||||
if (isNameExist(Location.getName(), null)) { |
||||
return R.fail(String.format("添加失败,货位【%s】已存在", Location.getName())); |
||||
} |
||||
int rows = LocationMapper.insert(Location); |
||||
return rows > 0 ? R.success("添加成功") : R.fail("添加失败"); |
||||
} |
||||
|
||||
@UserAction("'修改货位' + #Location.name") |
||||
public R update(SysLocation Location){ |
||||
Integer id = Location.getId(); |
||||
String name = Location.getName(); |
||||
|
||||
if(isNameExist(name,id)) { |
||||
return R.fail(String.format("修改失败,货位【%s】已存在", name)); |
||||
} |
||||
LocationMapper.update( |
||||
null, |
||||
Wrappers.lambdaUpdate(SysLocation.class) |
||||
.set(SysLocation::getName, name) |
||||
.set(SysLocation::isEnable, Location.isEnable()) |
||||
.eq(SysLocation::getId, id) |
||||
); |
||||
return R.success("修改成功"); |
||||
} |
||||
|
||||
@UserAction("'删除货位:'+ #Location.name") |
||||
public R del(SysLocation Location) { |
||||
int rows = LocationMapper.delete( |
||||
Wrappers.lambdaQuery(SysLocation.class) |
||||
.eq(SysLocation::getId, Location.getId()) |
||||
.eq(SysLocation::isEnable, false) |
||||
); |
||||
return rows > 0 ? R.success("删除成功") : R.fail("删除失败,请刷新重试"); |
||||
} |
||||
|
||||
private boolean isNameExist(String name, Integer id) { |
||||
Integer num = LocationMapper.selectCount( |
||||
Wrappers.lambdaQuery(SysLocation.class) |
||||
.eq(SysLocation::getName, name) |
||||
.ne(id != null, SysLocation::getId, id) |
||||
); |
||||
|
||||
return num != null && num > 0; |
||||
} |
||||
} |
||||
@ -0,0 +1,9 @@ |
||||
import {PostApi} from "@/api/request" |
||||
|
||||
export const search = new PostApi(`/system/location/search`) |
||||
|
||||
export const add = new PostApi(`/system/location/add`) |
||||
|
||||
export const update = new PostApi(`/system/location/update`) |
||||
|
||||
export const del = new PostApi(`/system/location/del`) |
||||
@ -0,0 +1,117 @@ |
||||
<template> |
||||
<el-dialog |
||||
v-drag-dialog |
||||
:visible="value" |
||||
append-to-body |
||||
title="选择供应商" |
||||
width="70%" |
||||
@close="cancel" |
||||
@open="search" |
||||
> |
||||
<el-row> |
||||
<el-button icon="el-icon-search" size="small" type="primary" @click="search">查 询</el-button> |
||||
<el-button size="small" type="primary" @click="confirm">确 定</el-button> |
||||
<el-button plain size="small" @click="closeDialog">取 消</el-button> |
||||
<el-button |
||||
plain |
||||
size="small" |
||||
type="dashed" |
||||
@click="goToSysSupplierPage" |
||||
> |
||||
添加供应商 |
||||
</el-button> |
||||
</el-row> |
||||
|
||||
<el-scrollbar> |
||||
<el-row class="table-container"> |
||||
<liner-progress :show="config.loading"/> |
||||
<el-table |
||||
ref="table" |
||||
:data="tableData" |
||||
current-row-key="id" |
||||
highlight-current-row |
||||
row-key="id" |
||||
@row-click="rowClick" |
||||
@row-dblclick="dbclick" |
||||
> |
||||
<el-table-column align="center" label="#" type="index" width="80"/> |
||||
<el-table-column align="center" label="供应商" prop="name" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="行政区域" prop="regionName" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="地 址" prop="address" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="联系人" prop="linkman" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="联系电话" prop="linkphone" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="创建时间" width="150"> |
||||
<template v-slot="{row}">{{ row.ctime | timestamp2Date }}</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> |
||||
|
||||
<abstract-pagination :model="searchForm" @current-change="pageChange"/> |
||||
</el-row> |
||||
</el-scrollbar> |
||||
</el-dialog> |
||||
</template> |
||||
|
||||
<script> |
||||
import dialogMixin from "@/mixin/dialogMixin" |
||||
import tableMixin from '@/mixin/tablePageMixin' |
||||
import LinerProgress from '@/component/LinerProgress' |
||||
import {search} from "@/api/system/supplier" |
||||
import {elError} from "@/util/message" |
||||
|
||||
export default { |
||||
name: "SupplierSelector", |
||||
|
||||
mixins: [dialogMixin, tableMixin], |
||||
|
||||
components: {LinerProgress}, |
||||
|
||||
props: {value: Boolean}, |
||||
|
||||
data() { |
||||
return { |
||||
searchForm: { |
||||
enable: true |
||||
} |
||||
} |
||||
}, |
||||
|
||||
methods: { |
||||
search() { |
||||
if (!this.value || this.config.loading) return |
||||
this.config.loading = true |
||||
this.row = null |
||||
search |
||||
.request(this.searchForm) |
||||
.then(({data: {list, total}}) => { |
||||
this.searchForm.total = total |
||||
this.tableData = list |
||||
}) |
||||
.finally(() => this.config.loading = false) |
||||
}, |
||||
dbclick(row) { |
||||
this.row = row |
||||
this.confirm() |
||||
}, |
||||
confirm() { |
||||
if (!this.row) return elError('请选择一个供应商') |
||||
this.$emit('select', this.row) |
||||
this.cancel() |
||||
}, |
||||
cancel() { |
||||
this.closeDialog() |
||||
this.tableData = [] |
||||
}, |
||||
goToSysSupplierPage() { |
||||
this.closeDialog() |
||||
this.$emit('jump') |
||||
this.$nextTick(() => this.$router.push('/system/supplier')) |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
@ -0,0 +1,150 @@ |
||||
<template> |
||||
<abstract-dialog :loading="loading" :title="title" :value="value" @close="cancel" @open="open"> |
||||
<abstract-form :model="form" :rules="rules"> |
||||
<el-form-item label="货位名" prop="name"> |
||||
<el-input v-model="form.name" :readonly="!canEdit" maxlength="20"/> |
||||
</el-form-item> |
||||
<el-form-item label="容 量" prop="capacity"> |
||||
<el-input v-model="form.capacity" :readonly="!canEdit" maxlength="20"/> |
||||
</el-form-item> |
||||
<el-form-item label="所属仓库" prop="storehouseId"> |
||||
<storehouse-selector |
||||
v-if="canEdit" |
||||
v-model="form.storehouseId" |
||||
@get-name="e => form.storehouseName = e" |
||||
/> |
||||
<template v-else>{{ form.storehouseName }}</template> |
||||
</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/location" |
||||
import {isEmpty, mergeObj, resetObj} from '@/util' |
||||
import {elConfirm} from "@/util/message" |
||||
import StorehouseSelector from "./StorehouseSelector"; |
||||
|
||||
export default { |
||||
name: "EditDialog", |
||||
|
||||
mixins: [dialogMixin], |
||||
|
||||
components: {AbstractForm, AbstractDialog,StorehouseSelector}, |
||||
|
||||
props: { |
||||
value: Boolean, |
||||
type: {type: String, default: 'see'}, |
||||
data: { |
||||
type: Object, |
||||
default: () => ({}) |
||||
}, |
||||
}, |
||||
|
||||
data() { |
||||
return { |
||||
loading: false, |
||||
form: { |
||||
id: null, |
||||
name: null, |
||||
capacity:null, |
||||
storehouse:null, |
||||
storehouseName:null, |
||||
storehouseId:null, |
||||
enable: false, |
||||
role: null, |
||||
}, |
||||
rules: { |
||||
name: [{required: true, message: '名称不能为空', trigger: 'change'}], |
||||
capacity: [{required: true, message: '容量不能为空', trigger: 'change'}], |
||||
storehouse: [{required: true, message: '仓库不能为空', trigger: 'change'}], |
||||
location: [{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,43 @@ |
||||
<template> |
||||
<el-select :value="value" clearable @clear="() => emit(null)" @input="emit"> |
||||
<el-option |
||||
v-for="item in storehouse" |
||||
:key="item.id" |
||||
:label="item.name" |
||||
:value="item.id" |
||||
/> |
||||
</el-select> |
||||
</template> |
||||
|
||||
<script> |
||||
import {get} from "@/api/system/storehouse" |
||||
|
||||
export default { |
||||
name: "StorehouseSelector", |
||||
|
||||
props: {value: Number}, |
||||
|
||||
data: () => ({storehouse: []}), |
||||
|
||||
methods: { |
||||
init() { |
||||
get.request().then(({data}) => this.storehouse = data) |
||||
}, |
||||
|
||||
emit(v) { |
||||
this.$emit('input', v) |
||||
if (v === 0 || v) { |
||||
let item = this.storehouse.find(i => i.id === v) |
||||
this.$emit('get-name', item ? item.name : null) |
||||
} |
||||
else { |
||||
this.$emit('get-name', null) |
||||
} |
||||
} |
||||
}, |
||||
|
||||
mounted() { |
||||
this.init() |
||||
} |
||||
} |
||||
</script> |
||||
@ -0,0 +1,169 @@ |
||||
<template> |
||||
<list-page :data="listPageConfig"> |
||||
<template v-slot:searchForm> |
||||
<el-form-item label="货位名"> |
||||
<el-input v-model="searchForm.name" clearable maxlength="50"/> |
||||
</el-form-item> |
||||
<el-form-item label="所属仓库"> |
||||
<el-input v-model="searchForm.storehouseName" clearable maxlength="20"/> |
||||
</el-form-item> |
||||
<el-form-item label="状 态"> |
||||
<el-select v-model="searchForm.enable" clearable @clear="searchForm.enable = null"> |
||||
<el-option :value="true" label="启用"/> |
||||
<el-option :value="false" label="禁用"/> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item label="创建时间"> |
||||
<el-date-picker |
||||
v-model="temp.createTime" |
||||
format="yyyy-MM-dd" |
||||
range-separator="-" |
||||
type="daterange" |
||||
value-format="timestamp" |
||||
/> |
||||
</el-form-item> |
||||
</template> |
||||
|
||||
<template v-slot:tableColumn> |
||||
<el-table-column align="center" label="#" type="index" width="80"/> |
||||
<el-table-column align="center" label="货位名" prop="name" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="容 量" prop="capacity" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="所属仓库" prop="storehouseName" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="创建人" prop="creatorName" show-overflow-tooltip/> |
||||
<el-table-column align="center" label="创建时间" width="150"> |
||||
<template v-slot="{row}">{{ row.createTime | timestamp2Date }}</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> |
||||
</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 './component/EditDialog' |
||||
import {add, update, del, search} from "@/api/system/location" |
||||
import {isEmpty} from '@/util' |
||||
import {wic} from "@/util/auth" |
||||
import {elConfirm, elError, elSuccess} from "@/util/message" |
||||
|
||||
export default { |
||||
name: "locationManagement", |
||||
|
||||
mixins: [tableMixin], |
||||
|
||||
components: {ListPage, EditDialog}, |
||||
|
||||
data() { |
||||
return { |
||||
searchForm: { |
||||
name: '', |
||||
storehouse: '', |
||||
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 |
||||
}) |
||||
|
||||
.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