Browse Source

盘点修改

dev
常熟吴彦祖 14 hours ago
parent
commit
aa7b2d212b
  1. 228
      src/views/modules/factory/partAttribute-add-or-update.vue
  2. 46
      src/views/modules/factory/partAttribute.vue
  3. 14
      src/views/modules/haianWarehouse/warehousePallet/warehousePallet54.vue

228
src/views/modules/factory/partAttribute-add-or-update.vue

@ -1,18 +1,31 @@
<template>
<el-dialog
v-drag
append-to-body
:title="!originalPartNo ? $t('factory.partAttribute.addTitle') : $t('factory.partAttribute.editTitle')"
:close-on-click-modal="false"
:visible.sync="visible"
:show-close="!submitLoading"
:close-on-press-escape="!submitLoading"
width="500px">
<el-form
:model="dataForm"
:rules="dataRule"
:disabled="submitLoading || infoLoading"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="120px">
<el-form-item :label="$t('factory.partAttribute.site')" prop="site">
<el-input v-model="dataForm.site" :placeholder="$t('factory.partAttribute.site')" :disabled="true"></el-input>
<!-- 新增只能选择当前工厂配置的小site,编辑保留原主键;选项加载失败时禁止提交 - rqrq -->
<el-input v-if="originalPartNo" v-model="dataForm.site" disabled></el-input>
<el-select v-else v-model="dataForm.site" filterable clearable
:placeholder="$t('factory.common.select')"
:loading="subSiteLoading" :disabled="subSiteLoading || submitLoading"
style="width: 100%">
<el-option v-for="subSite in subSiteOptions" :key="subSite" :label="subSite" :value="subSite"></el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('factory.partAttribute.partNo')" prop="partNo">
@ -51,9 +64,9 @@
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('factory.partAttribute.height')" prop="weight">
<el-form-item :label="$t('factory.partAttribute.height')" prop="height">
<el-input
v-model="dataForm.height"
v-model.number="dataForm.height"
:placeholder="$t('factory.partAttribute.placeholderHeight')"
:precision="3"
:min="0"
@ -66,7 +79,7 @@
<el-col :span="12">
<el-form-item :label="$t('factory.partAttribute.length')" prop="length">
<el-input
v-model="dataForm.length"
v-model.number="dataForm.length"
:placeholder="$t('factory.partAttribute.placeholderLength')"
:precision="2"
:min="0"
@ -78,7 +91,7 @@
<el-col :span="12">
<el-form-item :label="$t('factory.partAttribute.width')" prop="width">
<el-input
v-model="dataForm.width"
v-model.number="dataForm.width"
:placeholder="$t('factory.partAttribute.placeholderWidth')"
:precision="2"
:min="0"
@ -91,9 +104,9 @@
<el-row :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('factory.partAttribute.weight')" prop="height">
<el-form-item :label="$t('factory.partAttribute.weight')" prop="weight">
<el-input
v-model="dataForm.weight"
v-model.number="dataForm.weight"
:placeholder="$t('factory.partAttribute.placeholderWeight')"
:precision="2"
:min="0"
@ -105,7 +118,7 @@
<el-col :span="12">
<el-form-item :label="$t('factory.partAttribute.diameter')" prop="diameter">
<el-input
v-model="dataForm.diameter"
v-model.number="dataForm.diameter"
:placeholder="$t('factory.partAttribute.placeholderDiameter')"
:precision="2"
:min="0"
@ -119,20 +132,29 @@
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t('factory.common.cancel') }}</el-button>
<el-button type="primary" @click="dataFormSubmit()" :loading="submitLoading">{{ $t('factory.common.confirm') }}</el-button>
<el-button @click="visible = false" :disabled="submitLoading">{{ $t('factory.common.cancel') }}</el-button>
<el-button type="primary" @click="dataFormSubmit()" :loading="submitLoading"
:disabled="submitLoading || infoLoading || !infoReady || subSiteLoading || (!originalPartNo && !subSiteOptions.length)">{{ $t('factory.common.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { getPartAttributeInfo, savePartAttribute, updatePartAttribute } from '@/api/factory/partAttribute'
import { getSubSiteList } from '@/api/base/site'
export default {
data() {
data () {
return {
visible: false,
submitLoading: false,
// 大site仅用于加载及校验归属,小site独立保存在dataForm.site;序号隔离重复打开弹窗的旧响应 - rqrq
parentSite: '',
subSiteOptions: [],
subSiteLoading: false,
infoLoading: false,
infoReady: false,
initSequence: 0,
originalPartNo: '', // 用于记录原始料号,修改时不允许更改
dataForm: {
site: '',
@ -143,12 +165,12 @@ export default {
weight: 0,
length: 0,
width: 0,
height: null,
height: 0,
diameter: 0
},
dataRule: {
site: [
{ required: true, message: this.$t('factory.partAttribute.siteRequired'), trigger: 'blur' },
{ required: true, message: this.$t('factory.partAttribute.siteRequired'), trigger: 'change' },
{ max: 50, message: this.$t('factory.partAttribute.siteLengthLimit'), trigger: 'blur' }
],
partNo: [
@ -183,30 +205,87 @@ export default {
}
},
methods: {
init(site, partNo) {
init (site, partNo) {
if (this.submitLoading) return
// 每次打开重新读取当前大site;新增不默认写大site,编辑使用传入记录的小site主键 - rqrq
const sequence = ++this.initSequence
this.visible = true
this.originalPartNo = partNo || ''
// 重置表单
this.parentSite = String(this.$store.state.user.site || '').trim()
this.subSiteOptions = []
this.subSiteLoading = false
this.infoLoading = false
this.infoReady = !partNo
this.dataForm = {
site: partNo ? site : '',
partNo: partNo || '',
isInWh: 'Y',
isRobotPick: 'N',
isCommonlyUsed: 'Y',
weight: 0,
length: 0,
width: 0,
height: 0,
diameter: 0
}
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
// 设置默认值
this.dataForm.site = site || localStorage.getItem('site') || ''
this.dataForm.isInWh = 'Y'
this.dataForm.isRobotPick = 'N'
this.dataForm.isCommonlyUsed = 'Y'
if (sequence !== this.initSequence) return
this.$refs.dataForm.clearValidate()
if (site && partNo) {
// 修改模式,获取详情
this.getInfo(site, partNo)
this.getInfo(site, partNo, sequence)
} else {
this.loadSubSites(sequence)
}
})
},
// 获取信息
getInfo(site, partNo) {
// 按显式大site逐页读取全部小site,不截断到首页;失败清空选项,防止错误工厂或残留值被保存 - rqrq
async loadSubSites (sequence) {
if (!this.parentSite) {
this.$alert('当前工厂不能为空,请先选择工厂', this.$t('factory.common.tip'))
return
}
const parentSite = this.parentSite
this.subSiteLoading = true
try {
let page = 1
let loadedCount = 0
let totalCount = 0
const options = []
do {
const { data } = await getSubSiteList({ siteId: parentSite, page, size: 200 })
if (sequence !== this.initSequence) return
if (!data || data.code !== 0 || !data.page) {
this.$alert((data && data.msg) || '查询小site失败', this.$t('factory.common.tip'))
return
}
const rows = data.page.list || []
totalCount = Number(data.page.totalCount) || 0
if (!rows.length && loadedCount < totalCount) {
this.$alert('小site列表已变化,请重新打开新增弹窗', this.$t('factory.common.tip'))
return
}
rows.forEach(row => {
const subSite = String(row.subSiteId || '').trim()
if (String(row.siteId || '').trim() === parentSite && subSite && !options.includes(subSite)) options.push(subSite)
})
loadedCount += rows.length
page++
} while (loadedCount < totalCount)
this.subSiteOptions = options
if (!options.length) this.$alert('当前工厂未配置小site,请先维护工厂资料', this.$t('factory.common.tip'))
} catch (error) {
if (sequence === this.initSequence) this.$message.error('查询小site失败,请重新打开新增弹窗')
} finally {
if (sequence === this.initSequence) this.subSiteLoading = false
}
},
// 按原小site和料号读取编辑详情,失败禁止提交默认值,旧弹窗响应不能覆盖当前表单 - rqrq
getInfo (site, partNo, sequence) {
this.infoLoading = true
getPartAttributeInfo({ site, partNo }).then(({ data }) => {
if (sequence !== this.initSequence) return
if (data && data.code === 0 && data.data) {
const info = data.data
this.dataForm.site = info.site
@ -214,56 +293,71 @@ export default {
this.dataForm.isInWh = info.isInWh || 'Y'
this.dataForm.isRobotPick = info.isRobotPick || 'N'
this.dataForm.isCommonlyUsed = info.isCommonlyUsed || 'Y'
this.dataForm.weight = info.weight
this.dataForm.length = info.length
this.dataForm.width = info.width
this.dataForm.height = info.height
this.dataForm.diameter = info.diameter
this.dataForm.weight = info.weight == null ? 0 : Number(info.weight)
this.dataForm.length = info.length == null ? 0 : Number(info.length)
this.dataForm.width = info.width == null ? 0 : Number(info.width)
this.dataForm.height = info.height == null ? 0 : Number(info.height)
this.dataForm.diameter = info.diameter == null ? 0 : Number(info.diameter)
this.infoReady = true
} else {
this.$message.error(data.msg || this.$t('factory.partAttribute.getInfoFailed'))
this.$alert((data && data.msg) || this.$t('factory.partAttribute.getInfoFailed'), this.$t('factory.common.tip'))
}
}).catch(() => {
this.$message.error(this.$t('factory.partAttribute.getInfoFailed'))
if (sequence === this.initSequence) this.$message.error(this.$t('factory.partAttribute.getInfoFailed'))
}).finally(() => {
if (sequence === this.initSequence) this.infoLoading = false
})
},
// 表单提交
dataFormSubmit() {
this.submitLoading = true
const submitData = { ...this.dataForm }
// 处理数值字段,null值不传递
if (submitData.weight === null || submitData.weight === '') {
delete submitData.weight
}
if (submitData.length === null || submitData.length === '') {
delete submitData.length
}
if (submitData.width === null || submitData.width === '') {
delete submitData.width
}
if (submitData.height === null || submitData.height === '') {
delete submitData.height
}
if (submitData.diameter === null || submitData.diameter === '') {
delete submitData.diameter
dataFormSubmit () {
// 加载、重复点击和回车均受同一防护;新增只允许提交本次当前工厂返回的小site - rqrq
if (this.submitLoading || this.subSiteLoading || this.infoLoading || !this.infoReady) return
if (!this.originalPartNo && (this.parentSite !== String(this.$store.state.user.site || '').trim() || !this.subSiteOptions.includes(this.dataForm.site))) {
this.$alert('请选择当前工厂下的小site;工厂已切换时请重新打开新增弹窗', this.$t('factory.common.tip'))
return
}
this.$refs.dataForm.validate(valid => {
if (!valid || this.submitLoading) return
this.submitLoading = true
const apiCall = this.originalPartNo ? updatePartAttribute : savePartAttribute
const submitData = { ...this.dataForm }
// 新增同时传当前大site用于服务端归属校验,site仍是选中的小site,parentSite不落库 - rqrq
if (!this.originalPartNo) submitData.parentSite = this.parentSite
apiCall(submitData).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success(data.msg || this.$t(this.originalPartNo ? 'factory.partAttribute.updateSuccess' : 'factory.partAttribute.createSuccess'))
this.visible = false
this.$emit('refreshDataList')
} else {
this.$message.error(data.msg || this.$t(this.originalPartNo ? 'factory.partAttribute.updateFailed' : 'factory.partAttribute.createFailed'))
// 可选数值清空时不传递,继续沿用后端空值处理,避免将空字符串写入数值列 - rqrq
if (submitData.weight === null || submitData.weight === '') {
delete submitData.weight
}
this.submitLoading = false
}).catch(() => {
this.$message.error(this.$t(this.originalPartNo ? 'factory.partAttribute.updateFailed' : 'factory.partAttribute.createFailed'))
this.submitLoading = false
if (submitData.length === null || submitData.length === '') {
delete submitData.length
}
if (submitData.width === null || submitData.width === '') {
delete submitData.width
}
if (submitData.height === null || submitData.height === '') {
delete submitData.height
}
if (submitData.diameter === null || submitData.diameter === '') {
delete submitData.diameter
}
const apiCall = this.originalPartNo ? updatePartAttribute : savePartAttribute
apiCall(submitData).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success(data.msg || this.$t(this.originalPartNo ? 'factory.partAttribute.updateSuccess' : 'factory.partAttribute.createSuccess'))
this.visible = false
this.$emit('refreshDataList')
} else {
this.$alert((data && data.msg) || this.$t(this.originalPartNo ? 'factory.partAttribute.updateFailed' : 'factory.partAttribute.createFailed'), this.$t('factory.common.tip'))
}
}).catch(() => {
this.$message.error(this.$t(this.originalPartNo ? 'factory.partAttribute.updateFailed' : 'factory.partAttribute.createFailed'))
}).finally(() => {
// 成功、业务失败和网络失败均复位,避免新增按钮永久禁用 - rqrq
this.submitLoading = false
})
})
}
}

46
src/views/modules/factory/partAttribute.vue

@ -32,8 +32,8 @@
</el-select>
</el-form-item>
<el-form-item style="margin-top: 20px;">
<el-button @click="getDataList()" type="primary" icon="el-icon-search">{{ $t('factory.common.search') }}</el-button>
<el-button @click="resetQuery()" type="default" icon="el-icon-refresh">{{ $t('factory.common.reset') }}</el-button>
<el-button @click="getDataList()" :loading="dataListLoading" :disabled="dataListLoading" type="primary" icon="el-icon-search">{{ $t('factory.common.search') }}</el-button>
<el-button @click="resetQuery()" :disabled="dataListLoading" type="default" icon="el-icon-refresh">{{ $t('factory.common.reset') }}</el-button>
<el-button
@click="addOrUpdateHandle()"
@ -149,7 +149,7 @@ import { getPartAttributeList, deletePartAttribute, batchDeletePartAttribute } f
import AddOrUpdate from './partAttribute-add-or-update'
export default {
data() {
data () {
return {
queryForm: {
partNo: '',
@ -170,21 +170,21 @@ export default {
components: {
AddOrUpdate
},
activated() {
activated () {
this.getDataList()
this.calculateTableHeight()
},
mounted() {
mounted () {
this.getDataList()
this.calculateTableHeight()
window.addEventListener('resize', this.calculateTableHeight)
},
beforeDestroy() {
beforeDestroy () {
window.removeEventListener('resize', this.calculateTableHeight)
},
methods: {
// 计算表格高度
calculateTableHeight() {
calculateTableHeight () {
this.$nextTick(() => {
const windowHeight = window.innerHeight
const otherHeight = 280 // 其他元素的高度
@ -192,13 +192,21 @@ export default {
})
},
// 获取数据列表
getDataList() {
// 显式传当前大site,由后端查询所属小site资料;加载中阻止重复查询,失败清空结果并统一复位 - rqrq
getDataList () {
if (this.dataListLoading) return
const site = String(this.$store.state.user.site || '').trim()
if (!site) {
this.dataList = []
this.totalPage = 0
this.$alert('当前工厂不能为空,请先选择工厂', this.$t('factory.common.tip'))
return
}
this.dataListLoading = true
const params = {
page: this.pageIndex,
size: this.pageSize,
site: localStorage.getItem('site'),
site,
...this.queryForm
}
@ -209,19 +217,19 @@ export default {
} else {
this.dataList = []
this.totalPage = 0
this.$message.error(data.msg || this.$t('factory.common.queryFailed'))
this.$alert((data && data.msg) || this.$t('factory.common.queryFailed'), this.$t('factory.common.tip'))
}
this.dataListLoading = false
}).catch(() => {
this.dataList = []
this.totalPage = 0
this.dataListLoading = false
this.$message.error(this.$t('factory.common.queryFailed'))
}).finally(() => {
this.dataListLoading = false
})
},
// 重置查询条件
resetQuery() {
resetQuery () {
this.queryForm = {
partNo: '',
isInWh: '',
@ -233,25 +241,25 @@ export default {
},
// 每页数
sizeChangeHandle(val) {
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle(val) {
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 多选
selectionChangeHandle(val) {
selectionChangeHandle (val) {
this.dataListSelections = val
},
// 新增 / 修改
addOrUpdateHandle(site, partNo) {
addOrUpdateHandle (site, partNo) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(site, partNo)
@ -259,7 +267,7 @@ export default {
},
// 删除
deleteHandle(site, partNo) {
deleteHandle (site, partNo) {
if (site && partNo) {
// 单个删除
this.$confirm(this.$t('factory.partAttribute.deleteSingleConfirm', { partNo }), this.$t('factory.common.tip'), {

14
src/views/modules/haianWarehouse/warehousePallet/warehousePallet54.vue

@ -67,7 +67,7 @@
</download-excel>
</el-form-item>
<el-form-item style="margin-top: 20px;">
<el-button type="primary" @click="openCreateDialog">新增托盘</el-button>
<!-- <el-button type="primary" @click="openCreateDialog">新增托盘</el-button>-->
<el-button type="success" @click="openBatchGenerateDialog">批量新增托盘</el-button>
</el-form-item>
</el-form>
@ -96,12 +96,12 @@
<span>{{ formatColumnValue(scope.row, item) }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="140" align="center" header-align="center">
<template slot-scope="scope">
<a style="margin-right: 10px;" @click="openEditDialog(scope.row)">编辑</a>
<a style="color: #f56c6c;" @click="deleteOne(scope.row)">删除</a>
</template>
</el-table-column>
<!-- <el-table-column fixed="right" label="操作" width="140" align="center" header-align="center">-->
<!-- <template slot-scope="scope">-->
<!-- <a style="margin-right: 10px;" @click="openEditDialog(scope.row)">编辑</a>-->
<!-- <a style="color: #f56c6c;" @click="deleteOne(scope.row)">删除</a>-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table>
<el-pagination

Loading…
Cancel
Save