Browse Source

编辑区域

master
常熟吴彦祖 7 hours ago
parent
commit
541e0f8ce0
  1. 13
      src/api/haianWarehouse/haianAreaMaintain.js
  2. 255
      src/views/modules/haianWarehouse/warehouse/haianAreaLocation54.vue

13
src/api/haianWarehouse/haianAreaMaintain.js

@ -0,0 +1,13 @@
import { createAPI } from '@/utils/httpRequest.js'
// 海安区域库位:分页查询haian_area - rqrq
export const haiAnAreaList = data => createAPI('/autoWareHourceHaian/haiAnAreaMaintain/list', 'post', data)
// 海安区域库位:当前大site的仓库下拉 - rqrq
export const haiAnAreaWarehouseOptions = data => createAPI('/autoWareHourceHaian/haiAnAreaMaintain/warehouseOptions', 'post', data)
// 海安区域库位:当前大site和所选仓库下的库位下拉 - rqrq
export const haiAnAreaLocationOptions = data => createAPI('/autoWareHourceHaian/haiAnAreaMaintain/locationOptions', 'post', data)
// 海安区域库位:保存非A01区域的仓库和库位 - rqrq
export const haiAnAreaSaveLocation = data => createAPI('/autoWareHourceHaian/haiAnAreaMaintain/saveLocation', 'post', data)

255
src/views/modules/haianWarehouse/warehouse/haianAreaLocation54.vue

@ -0,0 +1,255 @@
<template>
<div class="mod-config">
<el-form :inline="true" label-position="top" @keyup.enter.native="searchTable">
<el-form-item label="区域编码">
<el-input v-model="queryData.searchAreaId" style="width: 140px" clearable placeholder="请输入区域编码"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" :disabled="dataListLoading" @click="searchTable">查询</el-button>
<el-button :disabled="dataListLoading" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table :data="dataList" :height="height" border v-loading="dataListLoading" style="width: 100%;">
<el-table-column prop="areaId" label="区域编码" min-width="100" header-align="center" align="center"></el-table-column>
<el-table-column prop="areaDesc" label="区域名称" min-width="140" header-align="center" align="center" show-overflow-tooltip></el-table-column>
<el-table-column prop="warehouseId" label="仓库" min-width="120" header-align="center" align="center"></el-table-column>
<el-table-column prop="locationId" label="库位" min-width="140" header-align="center" align="center"></el-table-column>
<el-table-column prop="wcsAreaCode" label="WCS区域码" min-width="160" header-align="center" align="center" show-overflow-tooltip></el-table-column>
<el-table-column fixed="right" label="操作" width="120" header-align="center" align="center">
<template slot-scope="scope">
<!-- A01立库不允许改名称和库位,操作列不显示入口 - rqrq -->
<a v-if="scope.row.areaId !== 'A01'" type="text" @click="openEdit(scope.row)">编辑</a>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<el-dialog title="编辑区域" :visible.sync="editVisible" :close-on-click-modal="false" v-drag width="520px">
<el-form :model="editForm" label-position="top">
<el-form-item label="区域编码">
<el-input v-model="editForm.areaId" disabled></el-input>
</el-form-item>
<el-form-item label="区域名称">
<!-- 名称会回写haian_area.area_desc,最长100;A01没有编辑入口 - rqrq -->
<el-input v-model="editForm.areaDesc" maxlength="100" clearable placeholder="请输入区域名称"></el-input>
</el-form-item>
<el-form-item label="仓库">
<el-select v-model="editForm.warehouseId" filterable placeholder="请选择仓库" style="width: 100%" @change="handleWarehouseChange">
<el-option v-for="item in warehouseOptions" :key="item.warehouseId" :label="item.warehouseId" :value="item.warehouseId"></el-option>
</el-select>
</el-form-item>
<el-form-item label="库位">
<el-select v-model="editForm.locationId" filterable placeholder="请选择库位" style="width: 100%" :loading="locationLoading">
<el-option v-for="item in locationOptions" :key="item.locationId" :label="item.locationId" :value="item.locationId"></el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="editVisible = false" :disabled="saveLoading">取消</el-button>
<el-button type="primary" @click="saveLocation" :loading="saveLoading" :disabled="saveLoading">保存</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { haiAnAreaList, haiAnAreaWarehouseOptions, haiAnAreaLocationOptions, haiAnAreaSaveLocation } from '@/api/haianWarehouse/haianAreaMaintain'
export default {
data () {
return {
height: 500,
dataList: [],
dataListLoading: false,
pageIndex: 1,
pageSize: 20,
totalPage: 0,
queryData: {
site: '',
searchAreaId: ''
},
editVisible: false,
saveLoading: false,
locationLoading: false,
warehouseOptions: [],
locationOptions: [],
editForm: {
site: '',
areaId: '',
areaDesc: '',
warehouseId: '',
locationId: ''
}
}
},
activated () {
this.initSiteAndQuery()
this.getHeight()
},
mounted () {
this.initSiteAndQuery()
this.getHeight()
},
methods: {
// 先取登录大site再查询,避免用空site把全部区域查出来 - rqrq
initSiteAndQuery () {
this.queryData.site = this.$store.state.user.site
this.getDataList()
},
getHeight () {
this.$nextTick(() => {
this.height = window.innerHeight - 280
})
},
searchTable () {
this.pageIndex = 1
this.getDataList()
},
resetQuery () {
this.queryData.searchAreaId = ''
this.pageIndex = 1
this.getDataList()
},
getDataList () {
if (!this.queryData.site) {
this.$alert('当前工厂为空,无法查询区域', '错误', { confirmButtonText: '确定' })
return
}
this.dataListLoading = true
haiAnAreaList({
site: this.queryData.site,
searchAreaId: (this.queryData.searchAreaId || '').trim(),
page: this.pageIndex,
limit: this.pageSize
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataList = (data.page && data.page.list) || []
this.totalPage = (data.page && data.page.totalCount) || 0
} else {
this.dataList = []
this.totalPage = 0
this.$alert((data && data.msg) || '查询失败', '错误', { confirmButtonText: '确定' })
}
}).catch(() => {
this.dataList = []
this.totalPage = 0
this.$message.error('查询失败')
}).finally(() => {
this.dataListLoading = false
})
},
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 打开编辑时先装仓库,再按当前仓库装库位,不清空已保存的库位 - rqrq
openEdit (row) {
if (!row || row.areaId === 'A01') {
return
}
this.editForm = {
site: this.queryData.site,
areaId: row.areaId,
areaDesc: row.areaDesc,
warehouseId: row.warehouseId || '',
locationId: row.locationId || ''
}
this.warehouseOptions = []
this.locationOptions = []
this.editVisible = true
this.loadWarehouses(row.warehouseId)
},
loadWarehouses (currentWarehouseId) {
haiAnAreaWarehouseOptions({ site: this.queryData.site }).then(({ data }) => {
if (data && data.code === 0) {
this.warehouseOptions = data.rows || []
if (currentWarehouseId) {
this.loadLocations(currentWarehouseId, false)
}
} else {
this.$alert((data && data.msg) || '查询仓库失败', '错误', { confirmButtonText: '确定' })
}
}).catch(() => {
this.$message.error('查询仓库失败')
})
},
// 仓库变化后立刻清空库位,再按新仓库重新取库位 - rqrq
handleWarehouseChange (warehouseId) {
this.editForm.locationId = ''
this.locationOptions = []
if (warehouseId) {
this.loadLocations(warehouseId, true)
}
},
loadLocations (warehouseId, clearLocation) {
if (clearLocation) {
this.editForm.locationId = ''
}
this.locationLoading = true
haiAnAreaLocationOptions({
site: this.queryData.site,
warehouseId: warehouseId
}).then(({ data }) => {
if (data && data.code === 0) {
this.locationOptions = data.rows || []
} else {
this.locationOptions = []
this.$alert((data && data.msg) || '查询库位失败', '错误', { confirmButtonText: '确定' })
}
}).catch(() => {
this.locationOptions = []
this.$message.error('查询库位失败')
}).finally(() => {
this.locationLoading = false
})
},
saveLocation () {
const areaDesc = (this.editForm.areaDesc || '').trim()
if (!areaDesc) {
this.$alert('区域名称不能为空', '错误', { confirmButtonText: '确定' })
return
}
if (!this.editForm.warehouseId || !this.editForm.locationId) {
this.$alert('仓库和库位都不能为空', '错误', { confirmButtonText: '确定' })
return
}
this.saveLoading = true
// 名称、仓库、库位一起保存;A01由后端再次拒绝,避免只改前端入口 - rqrq
haiAnAreaSaveLocation({
site: this.queryData.site,
areaId: this.editForm.areaId,
areaDesc: areaDesc,
warehouseId: this.editForm.warehouseId,
locationId: this.editForm.locationId
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success('保存成功')
this.editVisible = false
this.getDataList()
} else {
this.$alert((data && data.msg) || '保存失败', '错误', { confirmButtonText: '确定' })
}
}).catch(() => {
this.$message.error('保存失败')
}).finally(() => {
this.saveLoading = false
})
}
}
}
</script>
Loading…
Cancel
Save