Commit abca0593 by wangyalan-git

新增物品校验

parent 5d6954ae
...@@ -137,8 +137,7 @@ export const asyncRouterMap = [ ...@@ -137,8 +137,7 @@ export const asyncRouterMap = [
path: 'userList', path: 'userList',
name: 'userList', name: 'userList',
component: () => import('@/views/use/UserList'), component: () => import('@/views/use/UserList'),
meta: { title: '用户列表', icon: 'product-cate' }, meta: { title: '用户列表', icon: 'product-cate' }
hidden: true
}] }]
}, },
{ {
......
...@@ -75,11 +75,11 @@ ...@@ -75,11 +75,11 @@
</el-table-column> </el-table-column>
<el-table-column label="型号" <el-table-column label="型号"
align="center"> align="center">
<template slot-scope="scope">{{scope.row.name}}</template> <template slot-scope="scope">{{scope.row.goodsNo}}</template>
</el-table-column> </el-table-column>
<el-table-column label="物品类别" <el-table-column label="物品类别"
align="center"> align="center">
<template slot-scope="scope">{{scope.row.username}}</template> <template slot-scope="scope">{{scope.row.goodsCategoryName}}</template>
</el-table-column> </el-table-column>
<el-table-column label="数量" <el-table-column label="数量"
align="center"> align="center">
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
</el-table-column> </el-table-column>
<el-table-column label="申领人" <el-table-column label="申领人"
align="center"> align="center">
<template slot-scope="scope">{{scope.row.memberName || '--'}}</template> <template slot-scope="scope">{{$store.getters.type == 1? scope.row.backOutboundName : scope.row.receptOutboundName}}</template>
</el-table-column> </el-table-column>
<el-table-column label="所属部门" <el-table-column label="所属部门"
align="center"> align="center">
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<el-dialog :visible.sync="visible" <el-dialog :visible.sync="visible"
:title="title" :title="title"
center center
width="1000px"> width="1000px"
:close-on-click-modal="false">
<!-- excel表格上传 --> <!-- excel表格上传 -->
<el-upload <el-upload
:auto-upload="false" :auto-upload="false"
...@@ -21,13 +22,13 @@ ...@@ -21,13 +22,13 @@
<el-table <el-table
:data="formData.tableData" :data="formData.tableData"
style="width: 100%" style="width: 100%"
@row-dblclick="dbclick"
:row-class-name="tableRowClassName"> :row-class-name="tableRowClassName">
<el-table-column prop="name" label="物品名称"> <el-table-column prop="name" label="物品名称">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item size="mini" :prop="'tableData.' + scope.$index + '.name'" <el-form-item size="mini" :prop="'tableData.' + scope.$index + '.name'"
:rules="[{required: true,trigger: 'change',message: '物品名称不能为空'}]"> :rules="[{required: true,trigger: 'change',message: '物品名称不能为空'}]">
<el-autocomplete <el-autocomplete
:maxlength="30"
class="input-width" class="input-width"
v-model="scope.row.name" v-model="scope.row.name"
:fetch-suggestions="querySearch" :fetch-suggestions="querySearch"
...@@ -64,7 +65,7 @@ ...@@ -64,7 +65,7 @@
<el-table-column label="物品类别"> <el-table-column label="物品类别">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item size="mini" :prop="'tableData.' + scope.$index + '.goodsCategoryId'" <el-form-item size="mini" :prop="'tableData.' + scope.$index + '.goodsCategoryId'"
:rules="[{required: true,trigger: 'change',message: '物品类别不能为空'}]"> :rules="[{required: true,message: '请选择物品类别',trigger: 'change'}]">
<el-select v-if="scope.row.isOK" v-model="scope.row.goodsCategoryId" <el-select v-if="scope.row.isOK" v-model="scope.row.goodsCategoryId"
class="input-width" class="input-width"
clearable clearable
...@@ -82,7 +83,7 @@ ...@@ -82,7 +83,7 @@
<el-table-column label="数量"> <el-table-column label="数量">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item size="mini" :prop="'tableData.' + scope.$index + '.goodsNum'" <el-form-item size="mini" :prop="'tableData.' + scope.$index + '.goodsNum'"
:rules="[{required: true,trigger: 'blur',message: '数量不能为空'}]"> :rules="[{validator: validateNum,trigger: 'blur'}]">
<el-input v-if="scope.row.isOK" v-model="scope.row.goodsNum" class="input-width" <el-input v-if="scope.row.isOK" v-model="scope.row.goodsNum" class="input-width"
placeholder="数量"></el-input> placeholder="数量"></el-input>
<span v-else>{{scope.row.goodsNum}}</span> <span v-else>{{scope.row.goodsNum}}</span>
...@@ -92,7 +93,7 @@ ...@@ -92,7 +93,7 @@
<el-table-column label="价格(元)"> <el-table-column label="价格(元)">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item size="mini" :prop="'tableData.' + scope.$index + '.prict'" <el-form-item size="mini" :prop="'tableData.' + scope.$index + '.prict'"
:rules="[{required: true,trigger: 'blur',message: '价格不能为空'}]"> :rules="[{validator: validatePrice,trigger: 'blur'}]">
<el-input v-if="scope.row.isOK" v-model="scope.row.prict" class="input-width" <el-input v-if="scope.row.isOK" v-model="scope.row.prict" class="input-width"
placeholder="价格" placeholder="价格"
:disabled="scope.row.id? true: false"></el-input> :disabled="scope.row.id? true: false"></el-input>
...@@ -168,7 +169,31 @@ import XLSX from 'xlsx' ...@@ -168,7 +169,31 @@ import XLSX from 'xlsx'
export default { export default {
name: 'importGoodsModal', name: 'importGoodsModal',
data() { data() {
var validatePrice = (rule, value, callback) => {
if (!value) {
callback(new Error('价格不能为空'))
} else {
let priceReg = /^[0-9]+(.[0-9]{2})?$/
if (!priceReg.test(value)) {
callback(new Error('价格不符合要求'))
}
callback()
}
}
var validateNum = (rule, value, callback) => {
if (!value) {
callback(new Error('数量不能为空'))
} else {
let myReg = /^\d{1,}$/
if (!myReg.test(value)) {
callback(new Error('数量必须为正整数'))
}
callback()
}
}
return { return {
validatePrice:validatePrice,
validateNum:validateNum,
files: null, //文件列表 files: null, //文件列表
visible: false, visible: false,
title: null, title: null,
...@@ -308,15 +333,15 @@ export default { ...@@ -308,15 +333,15 @@ export default {
// 把每一行的索引放进row // 把每一行的索引放进row
row.index = rowIndex; row.index = rowIndex;
}, },
dbclick(row, event, column) { // dbclick(row, event, column) {
console.log('row, event, column',row, event, column) // console.log('row, event, column',row, event, column)
for (var i of this.formData.tableData) { // for (var i of this.formData.tableData) {
i.isOK = false // i.isOK = false
} // }
row.isOK = !row.isOK // row.isOK = !row.isOK
this.formData.tableData.splice(row.index,1,row) // this.formData.tableData.splice(row.index,1,row)
console.log('this.formData.tableData',this.formData.tableData) // console.log('this.formData.tableData',this.formData.tableData)
}, // },
submit(formName) { submit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
...@@ -395,6 +420,9 @@ export default { ...@@ -395,6 +420,9 @@ export default {
fs.splice(0, 1) fs.splice(0, 1)
} }
this.read(f.raw) this.read(f.raw)
this.$nextTick(() => {
this.$refs.formData.clearValidate()
})
}, },
/** /**
* 解析 * 解析
...@@ -407,18 +435,12 @@ export default { ...@@ -407,18 +435,12 @@ export default {
let tables = [] let tables = []
for (var sheet of sheetArray.Sheet1) { for (var sheet of sheetArray.Sheet1) {
let rowTable = {} let rowTable = {}
rowTable.isOK = true
rowTable.name = sheet['物品名称'] rowTable.name = sheet['物品名称']
rowTable.goodsNo = sheet['型号'] rowTable.goodsNo = sheet['型号']
rowTable.goodsNum = sheet['数量'] rowTable.goodsNum = sheet['数量']
rowTable.prict = sheet['价格'] rowTable.prict = sheet['价格']
rowTable.barCode = sheet['条形码'] rowTable.barCode = sheet['条形码']
if (sheet['物品名称']) {
let isExist = this.goodsList.findIndex(item =>
item.name === sheet['物品名称']
)
isExist === -1 && (rowTable.id = null)
isExist !== -1 && (rowTable.id = this.goodsList[isExist].id)
}
if (sheet['物品类别']) { if (sheet['物品类别']) {
let isExist = this.categoryOptions.findIndex(item => let isExist = this.categoryOptions.findIndex(item =>
item.name === sheet['物品类别'] item.name === sheet['物品类别']
...@@ -440,6 +462,21 @@ export default { ...@@ -440,6 +462,21 @@ export default {
isExist === -1 && (rowTable.stockRoomId = null) isExist === -1 && (rowTable.stockRoomId = null)
isExist !== -1 && (rowTable.stockRoomId = this.depotOptions[isExist].id) isExist !== -1 && (rowTable.stockRoomId = this.depotOptions[isExist].id)
} }
if (sheet['物品名称']) {
let isExist = this.goodsList.findIndex(item =>
item.name === sheet['物品名称']
)
isExist === -1 && (rowTable.id = null)
if( isExist !== -1){
rowTable.id = this.goodsList[isExist].id
rowTable.prict = this.goodsList[isExist].prict
rowTable.goodsNo = this.goodsList[isExist].goodsNo
rowTable.barCode = this.goodsList[isExist].barCode
rowTable.goodsCategoryId = this.goodsList[isExist].goodsCategoryId
rowTable.stockRoomId = this.goodsList[isExist].stockRoomId
rowTable.supplierId = this.goodsList[isExist].supplierId
}
}
tables.push(rowTable) tables.push(rowTable)
this.formData.tableData = tables this.formData.tableData = tables
} }
...@@ -465,8 +502,3 @@ export default { ...@@ -465,8 +502,3 @@ export default {
font-size: 10px; font-size: 10px;
} }
</style> </style>
<style>
.no-bottom .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
margin-bottom: 0;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment