<template>
|
<div class="mod-config">
|
<basic-container>
|
<a @click="$router.go(-1)"><i class="icon-btn-back"></i></a>
|
<div class="detailtitle">盘点详情</div>
|
<el-form label-width="100px" class="l-mes">
|
<el-form-item label="盘点编号" prop="inyNo">
|
<el-input
|
v-model="inyInfo.inyNo"
|
placeholder="系统自动生成"
|
disabled
|
/>
|
</el-form-item>
|
</el-form>
|
</basic-container>
|
<basic-container>
|
<div class="detailtitle">盘点明细</div>
|
<ttable
|
:table="table"
|
@handleSelectionChange="handleSelectionChange"
|
:prelang="prelang"
|
:options="options"
|
:ajaxFun="ajaxFun"
|
:paramObj="paramObj"
|
:isEdit="isEdit"
|
ref="checkDetailTable"
|
>
|
<template v-if="canEdit" #toolbar>
|
<template v-if="!isEdit">
|
<el-form-item class="btn-group">
|
<el-button @click="goAdd" size="small" type="primary"
|
>新增</el-button
|
>
|
</el-form-item>
|
<el-form-item class="btn-group">
|
<el-button @click="goEdit" size="small" type="primary"
|
>编辑</el-button
|
>
|
</el-form-item>
|
<el-form-item class="btn-group">
|
<el-button @click="goDel" size="small" type="danger"
|
>删除</el-button
|
>
|
</el-form-item>
|
<el-form-item class="btn-group">
|
<el-button @click="goACT1" size="small">取消未盘点的行</el-button>
|
</el-form-item>
|
<el-form-item class="btn-group">
|
<el-button @click="goACT2" size="small">盘点没有差异</el-button>
|
</el-form-item>
|
</template>
|
<template v-else>
|
<el-form-item class="btn-group">
|
<el-button @click="goSave" size="small" type="primary">
|
保存
|
</el-button>
|
</el-form-item>
|
<el-form-item class="btn-group">
|
<el-button @click="goCancel" size="small">取消</el-button>
|
</el-form-item>
|
</template>
|
</template>
|
<template v-else #toolbar> </template>
|
</ttable>
|
<!-- 弹窗, 新增 / 修改 -->
|
<table-form
|
v-if="addOrUpdateVisible"
|
ref="addOrUpdate"
|
@refreshDataList="getData"
|
></table-form>
|
</basic-container>
|
</div>
|
</template>
|
|
<script>
|
import {
|
fetchListDetail,
|
putObjDetail,
|
delObjDetail,
|
cancelNoIny,
|
noDiff
|
} from '@/api/warehouse/check'
|
import TableForm from './check-detail-form'
|
import ttable from '@/views/common/ztt-table.vue'
|
import { mapGetters } from 'vuex'
|
|
export default {
|
data() {
|
const col = (prop, label, config) => {
|
const w = (label.length - 1) * 20 + 15
|
return Object.assign(
|
{
|
minWidth: w < 140 ? 140 : w,
|
prop,
|
label,
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
config
|
)
|
}
|
return {
|
ajaxFun: fetchListDetail,
|
multipleSelection: [],
|
prelang: 'operation',
|
isEdit: false,
|
options: {
|
height: 300, // 默认高度-为了表头固定
|
stripe: true, // 是否为斑马纹 table
|
highlightCurrentRow: false, // 是否要高亮当前行
|
border: true, // 是否有纵向边框
|
lazy: false, // 是否需要懒加载
|
fit: true, // 列的宽度是否自撑开
|
multiSelect: true, //
|
seqNo: true,
|
seqNoFix: true,
|
isRefresh: true, // 是否显示刷新按钮
|
isShowHide: true, // 是否显示显影按钮
|
isSearch: false, // 高级查询按钮
|
defaultOrderBy: { column: 'createTime', direction: 'desc' },
|
cancelRunCreated: true
|
},
|
table: {
|
total: 0,
|
currentPage: 1,
|
pageSize: 20,
|
data: [],
|
// 标题
|
column: [
|
// 零件
|
col('partNo', '零件号'),
|
col('partName', '零件名称'),
|
col('planningMethod', '计划方法'),
|
col('sn', 'SN号'),
|
col('ifsBatchNo', 'IFS批次号'),
|
col('warehouseName', '仓库'),
|
col('locNo', '库位号'),
|
col('stockQuantity', '库存数量'),
|
col('inyQty', '盘点数量'),
|
col('inyDiffQty', '盘点差异数量'),
|
col('commitNum', '扫码提交次数'),
|
col('unit', '单位'),
|
col('updateTime', '更新时间', {
|
searchInfoType: 'datetimerange'
|
})
|
],
|
toolbar: []
|
},
|
addOrUpdateVisible: false,
|
inyInfo: {
|
id: '',
|
inyNo: ''
|
},
|
paramObj: {
|
inventoryMainId: ''
|
}
|
}
|
},
|
components: {
|
ttable,
|
TableForm
|
},
|
computed: {
|
...mapGetters(['permissions']),
|
canEdit() {
|
return this.$route.query.canEdit
|
}
|
},
|
created() {
|
this.init()
|
},
|
methods: {
|
init() {
|
this.inyInfo.id = this.$route.query.id
|
this.inyInfo.inyNo = this.$route.query.inyNo
|
this.paramObj = {
|
inventoryMainId: this.inyInfo.id
|
}
|
this.getData()
|
},
|
// 获取数据列表
|
getData() {
|
this.$nextTick(() => {
|
this.$refs.checkDetailTable.getDataList()
|
})
|
},
|
handleSelectionChange(val) {
|
this.multipleSelection = val
|
},
|
// 新增 / 修改
|
goAdd() {
|
this.addOrUpdateVisible = true
|
this.$nextTick(() => {
|
this.$refs.addOrUpdate.init()
|
})
|
},
|
goEdit() {
|
this.isEdit = true
|
const col = this.table.column.find((e) => e.prop === 'inyQty')
|
col.isEdit = true
|
col.width = '150'
|
col.noShowTip = true
|
},
|
goSave() {
|
const data = this.$refs.checkDetailTable.getTableData()
|
let validateFlag = true
|
let validateMsg = ''
|
const numberReg = /^\d+$|^\d+[.]?\d+$/
|
data.forEach((e, i) => {
|
if (e.inyQty && !numberReg.test(e.inyQty)) {
|
validateFlag = false
|
validateMsg += '第' + (i + 1) + '行,请输入数字。'
|
}
|
})
|
if (!validateFlag) {
|
this.$message.error(validateMsg)
|
return
|
}
|
putObjDetail(data).then(() => {
|
this.goCancel()
|
})
|
},
|
goCancel() {
|
this.isEdit = false
|
const col = this.table.column.find((e) => e.prop === 'inyQty')
|
col.isEdit = false
|
delete col.width
|
delete col.noShowTip
|
this.getData()
|
},
|
// 删除
|
goDel() {
|
if (this.multipleSelection && this.multipleSelection.length > 0) {
|
console.log(this.multipleSelection)
|
this.$confirm(
|
`是否确认删除,共${this.multipleSelection.length}条`,
|
'提示',
|
{
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}
|
)
|
.then(() => {
|
return delObjDetail(this.multipleSelection.map((e) => e.id))
|
})
|
.then((data) => {
|
this.$message.success('删除成功')
|
this.getData()
|
})
|
} else {
|
this.$message.error('请选择盘点明细')
|
}
|
},
|
// 取消未盘点的行
|
goACT1() {
|
this.$confirm('是否确认取消未盘点的行', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(() => {
|
let ids = []
|
if (this.multipleSelection && this.multipleSelection.length > 0) {
|
ids = this.multipleSelection.map((e) => e.id)
|
}
|
return cancelNoIny(ids)
|
})
|
.then((data) => {
|
this.$message.success('删除成功')
|
this.getData()
|
})
|
},
|
// 盘点没有差异
|
goACT2() {
|
if (this.multipleSelection && this.multipleSelection.length > 0) {
|
this.$confirm('是否确认盘点没有差异', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(() => {
|
return noDiff(this.multipleSelection.map((e) => e.id))
|
})
|
.then((data) => {
|
this.$message.success('操作成功')
|
this.getData()
|
})
|
} else {
|
this.$message.error('请选择盘点明细')
|
}
|
}
|
}
|
}
|
</script>
|
<style lang="scss" scoped>
|
.basic-container {
|
position: relative;
|
&:first-child {
|
padding-bottom: 0;
|
.l-mes {
|
width: 30%;
|
margin: 10px 0;
|
}
|
}
|
&:last-child {
|
.detailtitle {
|
margin-bottom: 15px;
|
}
|
>>> .title-division {
|
display: none;
|
}
|
>>> .common-table-div {
|
margin-top: 0px !important;
|
}
|
}
|
}
|
.icon-btn-back {
|
position: absolute;
|
left: 15px;
|
top: 13px;
|
cursor: pointer;
|
}
|
.detailtitle {
|
font-size: 16px;
|
font-weight: 700;
|
line-height: 31px;
|
margin: -15px 0 0 25px;
|
}
|
</style>
|