Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
manage
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vanke
manage
Commits
abca0593
Commit
abca0593
authored
Jun 29, 2020
by
wangyalan-git
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增物品校验
parent
5d6954ae
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
49 deletions
+115
-49
index.js
src/router/index.js
+1
-2
WarehouseAdmin.vue
src/views/inv/WarehouseAdmin.vue
+3
-3
addGoodsModal.vue
src/views/inv/modules/addGoodsModal.vue
+53
-18
importGoodsModal.vue
src/views/inv/modules/importGoodsModal.vue
+58
-26
No files found.
src/router/index.js
View file @
abca0593
...
...
@@ -137,8 +137,7 @@ export const asyncRouterMap = [
path
:
'userList'
,
name
:
'userList'
,
component
:
()
=>
import
(
'@/views/use/UserList'
),
meta
:
{
title
:
'用户列表'
,
icon
:
'product-cate'
},
hidden
:
true
meta
:
{
title
:
'用户列表'
,
icon
:
'product-cate'
}
}]
},
{
...
...
src/views/inv/WarehouseAdmin.vue
View file @
abca0593
...
...
@@ -75,11 +75,11 @@
</el-table-column>
<el-table-column
label=
"型号"
align=
"center"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
name
}}
</
template
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
goodsNo
}}
</
template
>
</el-table-column>
<el-table-column
label=
"物品类别"
align=
"center"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
usern
ame
}}
</
template
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
goodsCategoryN
ame
}}
</
template
>
</el-table-column>
<el-table-column
label=
"数量"
align=
"center"
>
...
...
@@ -87,7 +87,7 @@
</el-table-column>
<el-table-column
label=
"申领人"
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
label=
"所属部门"
align=
"center"
>
...
...
src/views/inv/modules/addGoodsModal.vue
View file @
abca0593
...
...
@@ -2,7 +2,8 @@
<el-dialog
:visible
.
sync=
"visible"
:title=
"title"
center
width=
"1000px"
>
width=
"1000px"
:close-on-click-modal=
"false"
>
<!-- start -->
<el-row
style=
"padding: 10px 0;text-align: left;"
>
<el-button
type=
"primary"
size=
"medium"
@
click=
"handleAdd"
>
新增
</el-button>
...
...
@@ -13,13 +14,14 @@
<el-table
:data=
"formData.tableData"
style=
"width: 100%"
@
row-dblclick=
"dbclick
"
:row-class-name=
"tableRowClassName"
>
<el-table-column
prop=
"name"
label=
"物品名称
"
>
:row-class-name=
"tableRowClassName
"
>
<el-table-column
prop=
"name"
label=
"物品名称"
align=
"left"
style=
"justify-content: flex-start;
"
>
<template
slot-scope=
"scope"
>
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.name'"
:rules=
"[
{required: true,trigger: 'change',message: '物品名称不能为空'}]">
<el-autocomplete
:maxlength=
"30"
class=
"input-width"
v-model=
"scope.row.name"
:fetch-suggestions=
"querySearch"
...
...
@@ -33,7 +35,8 @@
</el-table-column>
<el-table-column
label=
"型号"
>
<
template
slot-scope=
"scope"
>
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.goodsNo'"
:rules=
"[
{required: true,trigger: 'blur',message: '型号不能为空'}]">
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.goodsNo'"
:rules=
"[
{required: true,trigger: 'blur',message: '型号不能为空'}]">
<el-input
v-if=
"scope.row.isOK"
v-model=
"scope.row.goodsNo"
class=
"input-width"
placeholder=
"型号"
:disabled=
"scope.row.id? true: false"
></el-input>
...
...
@@ -43,7 +46,8 @@
</el-table-column>
<el-table-column
label=
"条形码"
>
<
template
slot-scope=
"scope"
>
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.barCode'"
:rules=
"[
{required: true,trigger: 'blur',message: '条形码不能为空'}]">
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.barCode'"
:rules=
"[
{required: true,trigger: 'blur',message: '条形码不能为空'}]">
<el-input
v-if=
"scope.row.isOK"
v-model=
"scope.row.barCode"
class=
"input-width"
placeholder=
"条形码"
:disabled=
"scope.row.id? true: false"
></el-input>
...
...
@@ -54,7 +58,7 @@
<el-table-column
label=
"物品类别"
>
<
template
slot-scope=
"scope"
>
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.goodsCategoryId'"
:rules=
"[
{required: true,trigger: 'change',message: '
物品
类别不能为空'}]">
:rules=
"[
{required: true,trigger: 'change',message: '类别不能为空'}]">
<el-select
v-if=
"scope.row.isOK"
v-model=
"scope.row.goodsCategoryId"
class=
"input-width"
clearable
...
...
@@ -71,7 +75,8 @@
</el-table-column>
<el-table-column
label=
"数量"
>
<
template
slot-scope=
"scope"
>
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.goodsNum'"
:rules=
"[
{required: true,trigger: 'blur',message: '数量不能为空'}]">
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.goodsNum'"
:rules=
"[
{validator: validateNum,trigger: 'blur'}]">
<el-input
v-if=
"scope.row.isOK"
v-model=
"scope.row.goodsNum"
class=
"input-width"
placeholder=
"数量"
></el-input>
<span
v-else
>
{{
scope
.
row
.
goodsNum
}}
</span>
...
...
@@ -80,7 +85,8 @@
</el-table-column>
<el-table-column
label=
"价格(元)"
>
<
template
slot-scope=
"scope"
>
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.prict'"
:rules=
"[
{required: true,trigger: 'blur',message: '价格不能为空'}]">
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.prict'"
:rules=
"[
{validator: validatePrice,trigger: 'blur'}]">
<el-input
v-if=
"scope.row.isOK"
v-model=
"scope.row.prict"
class=
"input-width"
placeholder=
"价格"
:disabled=
"scope.row.id? true: false"
></el-input>
...
...
@@ -154,7 +160,31 @@ import { getSuppliersList } from '@/api/supplier'
export
default
{
name
:
'addGoodsModal'
,
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
{
validatePrice
:
validatePrice
,
validateNum
:
validateNum
,
visible
:
false
,
title
:
null
,
loading
:
false
,
...
...
@@ -231,9 +261,9 @@ export default {
isOK
:
true
},)
},
tableRowClassName
({
row
,
rowIndex
})
{
tableRowClassName
({
row
,
rowIndex
})
{
// 把每一行的索引放进row
row
.
index
=
rowIndex
;
row
.
index
=
rowIndex
},
// dbclick(row, event, column) {
// for (var i of this.formData.tableData) {
...
...
@@ -242,19 +272,14 @@ export default {
// row.isOK = !row.isOK
// },
submit
(
formName
)
{
// if (!this.formData.tableData.length || !this.formData.tableData[0].name) {
// this.$message.warning('请添加物品')
// return
// }
this
.
$refs
[
formName
].
validate
((
valid
)
=>
{
if
(
valid
)
{
let
data
=
this
.
formData
.
tableData
alert
(
JSON
.
stringify
(
data
))
addGoodList
({
vankeGoodsList
:
this
.
formData
.
tableData
}).
then
(
res
=>
{
this
.
$emit
(
'ok'
)
this
.
visible
=
false
})
}
else
{
}
else
{
this
.
$message
.
warning
(
'请检查必填项'
)
}
})
...
...
@@ -270,7 +295,7 @@ export default {
return
''
}
let
name
=
null
console
.
log
(
'arr,id'
,
arr
,
id
)
console
.
log
(
'arr,id'
,
arr
,
id
)
if
(
type
)
{
name
=
arr
.
filter
(
item
=>
item
.
id
==
id
)[
0
].
supplierName
}
else
{
...
...
@@ -320,4 +345,14 @@ export default {
.no-bottom
.el-form-item--mini.el-form-item
,
.el-form-item--small.el-form-item
{
margin-bottom
:
0
;
}
.no-bottom
.el-form-item__error
{
position
:
relative
;
top
:
0
;
margin
:
5px
0
;
}
.no-bottom
.el-table
th
,
.el-table
td
{
vertical-align
:
top
;
}
</
style
>
src/views/inv/modules/importGoodsModal.vue
View file @
abca0593
...
...
@@ -2,7 +2,8 @@
<el-dialog
:visible
.
sync=
"visible"
:title=
"title"
center
width=
"1000px"
>
width=
"1000px"
:close-on-click-modal=
"false"
>
<!-- excel表格上传 -->
<el-upload
:auto-upload=
"false"
...
...
@@ -21,13 +22,13 @@
<el-table
:data=
"formData.tableData"
style=
"width: 100%"
@
row-dblclick=
"dbclick"
:row-class-name=
"tableRowClassName"
>
<el-table-column
prop=
"name"
label=
"物品名称"
>
<template
slot-scope=
"scope"
>
<el-form-item
size=
"mini"
:prop=
"'tableData.' + scope.$index + '.name'"
:rules=
"[
{required: true,trigger: 'change',message: '物品名称不能为空'}]">
<el-autocomplete
:maxlength=
"30"
class=
"input-width"
v-model=
"scope.row.name"
:fetch-suggestions=
"querySearch"
...
...
@@ -64,7 +65,7 @@
<el-table-column
label=
"物品类别"
>
<
template
slot-scope=
"scope"
>
<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"
class=
"input-width"
clearable
...
...
@@ -82,7 +83,7 @@
<el-table-column
label=
"数量"
>
<
template
slot-scope=
"scope"
>
<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"
placeholder=
"数量"
></el-input>
<span
v-else
>
{{
scope
.
row
.
goodsNum
}}
</span>
...
...
@@ -92,7 +93,7 @@
<el-table-column
label=
"价格(元)"
>
<
template
slot-scope=
"scope"
>
<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"
placeholder=
"价格"
:disabled=
"scope.row.id? true: false"
></el-input>
...
...
@@ -168,7 +169,31 @@ import XLSX from 'xlsx'
export
default
{
name
:
'importGoodsModal'
,
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
{
validatePrice
:
validatePrice
,
validateNum
:
validateNum
,
files
:
null
,
//文件列表
visible
:
false
,
title
:
null
,
...
...
@@ -308,15 +333,15 @@ export default {
// 把每一行的索引放进row
row
.
index
=
rowIndex
;
},
dbclick
(
row
,
event
,
column
)
{
console
.
log
(
'row, event, column'
,
row
,
event
,
column
)
for
(
var
i
of
this
.
formData
.
tableData
)
{
i
.
isOK
=
false
}
row
.
isOK
=
!
row
.
isOK
this
.
formData
.
tableData
.
splice
(
row
.
index
,
1
,
row
)
console
.
log
(
'this.formData.tableData'
,
this
.
formData
.
tableData
)
},
//
dbclick(row, event, column) {
//
console.log('row, event, column',row, event, column)
//
for (var i of this.formData.tableData) {
//
i.isOK = false
//
}
//
row.isOK = !row.isOK
//
this.formData.tableData.splice(row.index,1,row)
//
console.log('this.formData.tableData',this.formData.tableData)
//
},
submit
(
formName
)
{
this
.
$refs
[
formName
].
validate
((
valid
)
=>
{
if
(
valid
)
{
...
...
@@ -395,6 +420,9 @@ export default {
fs
.
splice
(
0
,
1
)
}
this
.
read
(
f
.
raw
)
this
.
$nextTick
(()
=>
{
this
.
$refs
.
formData
.
clearValidate
()
})
},
/**
* 解析
...
...
@@ -407,18 +435,12 @@ export default {
let
tables
=
[]
for
(
var
sheet
of
sheetArray
.
Sheet1
)
{
let
rowTable
=
{}
rowTable
.
isOK
=
true
rowTable
.
name
=
sheet
[
'物品名称'
]
rowTable
.
goodsNo
=
sheet
[
'型号'
]
rowTable
.
goodsNum
=
sheet
[
'数量'
]
rowTable
.
prict
=
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
[
'物品类别'
])
{
let
isExist
=
this
.
categoryOptions
.
findIndex
(
item
=>
item
.
name
===
sheet
[
'物品类别'
]
...
...
@@ -440,6 +462,21 @@ export default {
isExist
===
-
1
&&
(
rowTable
.
stockRoomId
=
null
)
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
)
this
.
formData
.
tableData
=
tables
}
...
...
@@ -465,8 +502,3 @@ export default {
font-size
:
10px
;
}
</
style
>
<
style
>
.no-bottom
.el-form-item--mini.el-form-item
,
.el-form-item--small.el-form-item
{
margin-bottom
:
0
;
}
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment