Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
maintain_service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
刘帅
maintain_service
Commits
c1c96728
You need to sign in or sign up before continuing.
Commit
c1c96728
authored
Jun 16, 2025
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加物资导入功能
parent
cf54279f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
398 additions
and
39 deletions
+398
-39
ErpMaterialController.java
...m/maintain/business/controller/ErpMaterialController.java
+29
-0
ErpMaterialVo.java
...n/java/com/maintain/business/domain/vo/ErpMaterialVo.java
+39
-36
ErpMaterialImportListener.java
...maintain/business/listener/ErpMaterialImportListener.java
+245
-0
ErpMaterialServiceImpl.java
...aintain/business/service/impl/ErpMaterialServiceImpl.java
+1
-0
request.js
maintain-ui/src/utils/request.js
+2
-2
index.vue
maintain-ui/src/views/business/material/index.vue
+82
-1
No files found.
maintain-business/src/main/java/com/maintain/business/controller/ErpMaterialController.java
View file @
c1c96728
package
com
.
maintain
.
business
.
controller
;
package
com
.
maintain
.
business
.
controller
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
com.maintain.business.domain.bo.ErpCarBo
;
import
com.maintain.business.domain.vo.ErpCarVo
;
import
com.maintain.business.listener.ErpCarImportListener
;
import
com.maintain.business.listener.ErpMaterialImportListener
;
import
com.maintain.common.excel.ExcelResult
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.constraints.*
;
import
javax.validation.constraints.*
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
com.maintain.common.annotation.RepeatSubmit
;
import
com.maintain.common.annotation.RepeatSubmit
;
...
@@ -22,6 +29,7 @@ import com.maintain.business.domain.vo.ErpMaterialVo;
...
@@ -22,6 +29,7 @@ import com.maintain.business.domain.vo.ErpMaterialVo;
import
com.maintain.business.domain.bo.ErpMaterialBo
;
import
com.maintain.business.domain.bo.ErpMaterialBo
;
import
com.maintain.business.service.IErpMaterialService
;
import
com.maintain.business.service.IErpMaterialService
;
import
com.maintain.common.core.page.TableDataInfo
;
import
com.maintain.common.core.page.TableDataInfo
;
import
org.springframework.web.multipart.MultipartFile
;
/**
/**
* 物资
* 物资
...
@@ -46,6 +54,27 @@ public class ErpMaterialController extends BaseController {
...
@@ -46,6 +54,27 @@ public class ErpMaterialController extends BaseController {
return
iErpMaterialService
.
queryPageList
(
bo
,
pageQuery
);
return
iErpMaterialService
.
queryPageList
(
bo
,
pageQuery
);
}
}
/**
* 物料导入模板下载
*/
@PostMapping
(
"/importTemplate"
)
public
void
importTemplate
(
ErpMaterialBo
bo
,
HttpServletResponse
response
)
{
ExcelUtil
.
exportExcel
(
new
ArrayList
<>(),
"物料导入"
,
ErpMaterialVo
.
class
,
response
);
}
/**
* 导入数据
*
* @param file 导入文件
* @param updateSupport 是否更新已存在数据
*/
@Log
(
title
=
"物料导入"
,
businessType
=
BusinessType
.
IMPORT
)
@PostMapping
(
value
=
"/importData"
,
consumes
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
public
R
<
Void
>
importData
(
@RequestPart
(
"file"
)
MultipartFile
file
,
boolean
updateSupport
)
throws
Exception
{
ExcelResult
<
ErpMaterialVo
>
result
=
ExcelUtil
.
importExcel
(
file
.
getInputStream
(),
ErpMaterialVo
.
class
,
new
ErpMaterialImportListener
(
updateSupport
));
return
R
.
ok
(
result
.
getAnalysis
());
}
/**
/**
* 导出物资列表
* 导出物资列表
*/
*/
...
...
maintain-business/src/main/java/com/maintain/business/domain/vo/ErpMaterialVo.java
View file @
c1c96728
...
@@ -28,17 +28,6 @@ public class ErpMaterialVo implements Serializable {
...
@@ -28,17 +28,6 @@ public class ErpMaterialVo implements Serializable {
*/
*/
private
Long
id
;
private
Long
id
;
/**
* 物资分类ID
*/
private
Long
materialTypeId
;
/**
* 物资分类名称
*/
@ExcelProperty
(
value
=
"物资分类名称"
)
private
String
materialTypeName
;
/**
/**
* 部门ID
* 部门ID
*/
*/
...
@@ -48,30 +37,35 @@ public class ErpMaterialVo implements Serializable {
...
@@ -48,30 +37,35 @@ public class ErpMaterialVo implements Serializable {
* 部门名称
* 部门名称
*/
*/
private
String
deptName
;
private
String
deptName
;
/**
/**
* 仓库ID
* 仓库
货位
ID
*/
*/
private
Long
warehouseId
;
private
Long
warehouseLocationId
;
/**
/**
*
仓库名称
*
物资编码
*/
*/
private
String
warehouseName
;
@ExcelProperty
(
value
=
"物资编码"
)
private
String
materialCode
;
/**
/**
*
仓库货位ID
*
物资名称
*/
*/
private
Long
warehouseLocationId
;
@ExcelProperty
(
value
=
"物资名称"
)
private
String
materialName
;
/**
/**
*
仓库货位编码
*
物资规格
*/
*/
private
String
warehouseLocationCode
;
@ExcelProperty
(
value
=
"物资规格"
)
private
String
materialSpecifications
;
/**
/**
*
仓库货位类型
*
物资单位
*/
*/
@ExcelProperty
(
value
=
"仓库货位类型"
)
@ExcelProperty
(
value
=
"物资单位"
)
@ColumnWidth
(
30
)
private
String
materialUnit
;
private
String
warehouseLocationType
;
/**
/**
* 供应商ID
* 供应商ID
...
@@ -85,28 +79,37 @@ public class ErpMaterialVo implements Serializable {
...
@@ -85,28 +79,37 @@ public class ErpMaterialVo implements Serializable {
private
String
vendorName
;
private
String
vendorName
;
/**
/**
* 物资
编码
* 物资
分类ID
*/
*/
@ExcelProperty
(
value
=
"物资编码"
)
private
Long
materialTypeId
;
private
String
materialCode
;
/**
/**
* 物资名称
* 物资
分类
名称
*/
*/
@ExcelProperty
(
value
=
"物资名称"
)
@ExcelProperty
(
value
=
"物资
分类
名称"
)
private
String
materialName
;
private
String
material
Type
Name
;
/**
/**
*
物资规格
*
仓库ID
*/
*/
@ExcelProperty
(
value
=
"物资规格"
)
private
Long
warehouseId
;
private
String
materialSpecifications
;
/**
/**
*
物资单位
*
仓库名称
*/
*/
@ExcelProperty
(
value
=
"物资单位"
)
private
String
warehouseName
;
private
String
materialUnit
;
/**
* 仓库货位编码
*/
private
String
warehouseLocationCode
;
/**
* 仓库货位类型
*/
@ExcelProperty
(
value
=
"仓库货位类型"
)
@ColumnWidth
(
30
)
private
String
warehouseLocationType
;
/**
/**
* 物资品牌
* 物资品牌
...
@@ -130,7 +133,7 @@ public class ErpMaterialVo implements Serializable {
...
@@ -130,7 +133,7 @@ public class ErpMaterialVo implements Serializable {
/**
/**
* 质保期(月)
* 质保期(月)
*/
*/
@ExcelProperty
(
value
=
"质保期"
)
@ExcelProperty
(
value
=
"质保期
(月)
"
)
private
Integer
materialWarrantyPeriod
;
private
Integer
materialWarrantyPeriod
;
/**
/**
...
...
maintain-business/src/main/java/com/maintain/business/listener/ErpMaterialImportListener.java
0 → 100644
View file @
c1c96728
package
com
.
maintain
.
business
.
listener
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.maintain.business.domain.*
;
import
com.maintain.business.domain.vo.ErpCarVo
;
import
com.maintain.business.domain.vo.ErpMaterialVo
;
import
com.maintain.business.mapper.*
;
import
com.maintain.common.enums.IsDeleteStatus
;
import
com.maintain.common.excel.ExcelListener
;
import
com.maintain.common.excel.ExcelResult
;
import
com.maintain.common.exception.ServiceException
;
import
com.maintain.common.helper.LoginHelper
;
import
com.maintain.common.utils.StringUtils
;
import
com.maintain.common.utils.ValidatorUtils
;
import
com.maintain.common.utils.spring.SpringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.List
;
/**
* 车辆自定义导入
*
* @author liushuai
*/
@Slf4j
public
class
ErpMaterialImportListener
extends
AnalysisEventListener
<
ErpMaterialVo
>
implements
ExcelListener
<
ErpMaterialVo
>
{
private
final
ErpMaterialMapper
materialMapper
;
private
final
ErpWarehouseMapper
warehouseMapper
;
private
final
ErpMaterialVendorMapper
materialVendorMapper
;
private
final
ErpMaterialTypeMapper
materialTypeMapper
;
private
final
ErpWarehouseLocationMapper
warehouseLocationMapper
;
private
final
Boolean
isUpdateSupport
;
private
final
String
operName
;
private
int
successNum
=
0
;
private
int
failureNum
=
0
;
private
final
StringBuilder
successMsg
=
new
StringBuilder
();
private
final
StringBuilder
failureMsg
=
new
StringBuilder
();
public
ErpMaterialImportListener
(
Boolean
isUpdateSupport
)
{
this
.
materialMapper
=
SpringUtils
.
getBean
(
ErpMaterialMapper
.
class
);
this
.
warehouseMapper
=
SpringUtils
.
getBean
(
ErpWarehouseMapper
.
class
);
this
.
materialVendorMapper
=
SpringUtils
.
getBean
(
ErpMaterialVendorMapper
.
class
);
this
.
materialTypeMapper
=
SpringUtils
.
getBean
(
ErpMaterialTypeMapper
.
class
);
this
.
warehouseLocationMapper
=
SpringUtils
.
getBean
(
ErpWarehouseLocationMapper
.
class
);
this
.
isUpdateSupport
=
isUpdateSupport
;
this
.
operName
=
LoginHelper
.
getUsername
();
}
@Override
public
void
invoke
(
ErpMaterialVo
materialImportVo
,
AnalysisContext
context
)
{
LambdaQueryWrapper
<
ErpMaterial
>
materialLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
materialLambdaQueryWrapper
.
eq
(
ErpMaterial:
:
getMaterialCode
,
materialImportVo
.
getMaterialCode
())
.
eq
(
ErpMaterial:
:
getMaterialName
,
materialImportVo
.
getMaterialName
()).
eq
(
ErpMaterial:
:
getIsDelete
,
IsDeleteStatus
.
NO
.
getCode
());
ErpMaterial
material
=
materialMapper
.
selectOne
(
materialLambdaQueryWrapper
);
try
{
// 验证是否存在
if
(
ObjectUtil
.
isNull
(
material
))
{
material
=
BeanUtil
.
toBean
(
materialImportVo
,
ErpMaterial
.
class
);
ValidatorUtils
.
validate
(
material
);
/**
* 物资类型
*/
if
(
StringUtils
.
isNotEmpty
(
material
.
getMaterialTypeName
()))
{
List
<
ErpMaterialType
>
materialTypes
=
materialTypeMapper
.
selectList
(
new
LambdaQueryWrapper
<
ErpMaterialType
>().
eq
(
ErpMaterialType:
:
getTypeName
,
material
.
getMaterialTypeName
()));
if
(
materialTypes
.
isEmpty
())
{
ErpMaterialType
materialType
=
new
ErpMaterialType
();
materialType
.
setTypeName
(
material
.
getMaterialTypeName
());
materialType
.
setParentId
(
1L
);
materialType
.
setAncestors
(
"0,1"
);
materialTypeMapper
.
insert
(
materialType
);
material
.
setMaterialTypeId
(
materialType
.
getTypeId
());
}
else
{
material
.
setMaterialTypeId
(
materialTypes
.
get
(
0
).
getTypeId
());
}
}
/**
* 物资仓库
*/
if
(
StringUtils
.
isNotEmpty
(
material
.
getWarehouseName
()))
{
ErpWarehouse
erpWarehouse
=
warehouseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ErpWarehouse
>().
eq
(
ErpWarehouse:
:
getName
,
material
.
getWarehouseName
()));
if
(
ObjectUtil
.
isNull
(
erpWarehouse
))
{
ErpWarehouse
warehouse
=
new
ErpWarehouse
();
warehouse
.
setCode
(
material
.
getWarehouseName
());
warehouse
.
setName
(
material
.
getWarehouseName
());
warehouseMapper
.
insert
(
warehouse
);
material
.
setWarehouseId
(
warehouse
.
getId
());
}
else
{
material
.
setWarehouseId
(
erpWarehouse
.
getId
());
}
}
/**
* 供应商
*/
if
(
StringUtils
.
isNotEmpty
(
material
.
getVendorName
()))
{
ErpMaterialVendor
erpMaterialVendor
=
materialVendorMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ErpMaterialVendor
>().
eq
(
ErpMaterialVendor:
:
getVendorName
,
material
.
getVendorName
()));
if
(
ObjectUtil
.
isNull
(
erpMaterialVendor
))
{
ErpMaterialVendor
vendor
=
new
ErpMaterialVendor
();
vendor
.
setVendorName
(
material
.
getVendorName
());
materialVendorMapper
.
insert
(
vendor
);
material
.
setVendorId
(
vendor
.
getId
());
}
else
{
material
.
setVendorId
(
erpMaterialVendor
.
getId
());
}
}
/**
* 仓库货位
*/
if
(
StringUtils
.
isNotEmpty
(
material
.
getWarehouseLocationType
()))
{
ErpWarehouseLocation
warehouseLocation
=
warehouseLocationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ErpWarehouseLocation
>().
eq
(
ErpWarehouseLocation:
:
getLocationType
,
material
.
getWarehouseLocationType
()));
if
(
ObjectUtil
.
isNull
(
warehouseLocation
))
{
ErpWarehouseLocation
location
=
new
ErpWarehouseLocation
();
location
.
setLocationCode
(
material
.
getWarehouseLocationType
());
location
.
setLocationType
(
material
.
getWarehouseLocationType
());
warehouseLocationMapper
.
insert
(
location
);
material
.
setWarehouseLocationCode
(
location
.
getLocationCode
());
material
.
setWarehouseLocationId
(
location
.
getId
());
}
else
{
material
.
setWarehouseLocationCode
(
warehouseLocation
.
getLocationCode
());
material
.
setWarehouseLocationId
(
warehouseLocation
.
getId
());
}
}
materialMapper
.
insert
(
material
);
successNum
++;
successMsg
.
append
(
"<br/>"
).
append
(
successNum
).
append
(
"、物料 "
).
append
(
material
.
getMaterialName
()).
append
(
" 导入成功"
);
}
else
if
(
isUpdateSupport
)
{
Long
materialId
=
material
.
getId
();
material
=
BeanUtil
.
toBean
(
materialImportVo
,
ErpMaterial
.
class
);
material
.
setId
(
materialId
);
ValidatorUtils
.
validate
(
material
);
/**
* 物资类型
*/
if
(
StringUtils
.
isNotEmpty
(
material
.
getMaterialTypeName
()))
{
List
<
ErpMaterialType
>
materialTypes
=
materialTypeMapper
.
selectList
(
new
LambdaQueryWrapper
<
ErpMaterialType
>().
eq
(
ErpMaterialType:
:
getTypeName
,
material
.
getMaterialTypeName
()));
if
(
materialTypes
.
isEmpty
())
{
ErpMaterialType
materialType
=
new
ErpMaterialType
();
materialType
.
setTypeName
(
material
.
getMaterialTypeName
());
materialType
.
setParentId
(
1L
);
materialType
.
setAncestors
(
"0,1"
);
materialTypeMapper
.
insert
(
materialType
);
material
.
setMaterialTypeId
(
materialType
.
getTypeId
());
}
else
{
material
.
setMaterialTypeId
(
materialTypes
.
get
(
0
).
getTypeId
());
}
}
/**
* 物资仓库
*/
if
(
StringUtils
.
isNotEmpty
(
material
.
getWarehouseName
()))
{
ErpWarehouse
erpWarehouse
=
warehouseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ErpWarehouse
>().
eq
(
ErpWarehouse:
:
getName
,
material
.
getWarehouseName
()));
if
(
ObjectUtil
.
isNull
(
erpWarehouse
))
{
ErpWarehouse
warehouse
=
new
ErpWarehouse
();
warehouse
.
setCode
(
material
.
getWarehouseName
());
warehouse
.
setName
(
material
.
getWarehouseName
());
warehouseMapper
.
insert
(
warehouse
);
material
.
setWarehouseId
(
warehouse
.
getId
());
}
else
{
material
.
setWarehouseId
(
erpWarehouse
.
getId
());
}
}
/**
* 供应商
*/
if
(
StringUtils
.
isNotEmpty
(
material
.
getVendorName
()))
{
ErpMaterialVendor
erpMaterialVendor
=
materialVendorMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ErpMaterialVendor
>().
eq
(
ErpMaterialVendor:
:
getVendorName
,
material
.
getVendorName
()));
if
(
ObjectUtil
.
isNull
(
erpMaterialVendor
))
{
ErpMaterialVendor
vendor
=
new
ErpMaterialVendor
();
vendor
.
setVendorName
(
material
.
getVendorName
());
materialVendorMapper
.
insert
(
vendor
);
material
.
setVendorId
(
vendor
.
getId
());
}
else
{
material
.
setVendorId
(
erpMaterialVendor
.
getId
());
}
}
/**
* 仓库货位
*/
if
(
StringUtils
.
isNotEmpty
(
material
.
getWarehouseLocationType
()))
{
ErpWarehouseLocation
warehouseLocation
=
warehouseLocationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ErpWarehouseLocation
>().
eq
(
ErpWarehouseLocation:
:
getLocationType
,
material
.
getWarehouseLocationType
()));
if
(
ObjectUtil
.
isNull
(
warehouseLocation
))
{
ErpWarehouseLocation
location
=
new
ErpWarehouseLocation
();
location
.
setLocationCode
(
material
.
getWarehouseLocationType
());
location
.
setLocationType
(
material
.
getWarehouseLocationType
());
warehouseLocationMapper
.
insert
(
location
);
material
.
setWarehouseLocationId
(
location
.
getId
());
}
else
{
material
.
setWarehouseLocationId
(
warehouseLocation
.
getId
());
}
}
materialMapper
.
updateById
(
material
);
successNum
++;
successMsg
.
append
(
"<br/>"
).
append
(
successNum
).
append
(
"、物料 "
).
append
(
material
.
getMaterialName
()).
append
(
" 更新成功"
);
}
else
{
failureNum
++;
failureMsg
.
append
(
"<br/>"
).
append
(
failureNum
).
append
(
"、物料 "
).
append
(
material
.
getMaterialName
()).
append
(
" 已存在"
);
}
}
catch
(
Exception
e
)
{
failureNum
++;
String
msg
=
"<br/>"
+
failureNum
+
"、物料 "
+
material
.
getMaterialName
()
+
" 导入失败:"
;
failureMsg
.
append
(
msg
).
append
(
e
.
getMessage
());
log
.
error
(
msg
,
e
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
}
@Override
public
ExcelResult
<
ErpMaterialVo
>
getExcelResult
()
{
return
new
ExcelResult
<
ErpMaterialVo
>()
{
@Override
public
String
getAnalysis
()
{
if
(
failureNum
>
0
)
{
failureMsg
.
insert
(
0
,
"很抱歉,导入失败!共 "
+
failureNum
+
" 条数据格式不正确,错误如下:"
);
throw
new
ServiceException
(
failureMsg
.
toString
());
}
else
{
successMsg
.
insert
(
0
,
"恭喜您,数据已全部导入成功!共 "
+
successNum
+
" 条,数据如下:"
);
}
return
successMsg
.
toString
();
}
@Override
public
List
<
ErpMaterialVo
>
getList
()
{
return
null
;
}
@Override
public
List
<
String
>
getErrorList
()
{
return
null
;
}
};
}
}
maintain-business/src/main/java/com/maintain/business/service/impl/ErpMaterialServiceImpl.java
View file @
c1c96728
...
@@ -93,6 +93,7 @@ public class ErpMaterialServiceImpl implements IErpMaterialService {
...
@@ -93,6 +93,7 @@ public class ErpMaterialServiceImpl implements IErpMaterialService {
lqw
.
eq
(
StringUtils
.
isNotBlank
(
bo
.
getIsEnable
()),
ErpMaterial:
:
getIsEnable
,
bo
.
getIsEnable
());
lqw
.
eq
(
StringUtils
.
isNotBlank
(
bo
.
getIsEnable
()),
ErpMaterial:
:
getIsEnable
,
bo
.
getIsEnable
());
lqw
.
eq
(
StringUtils
.
isNotBlank
(
bo
.
getIsUniversal
()),
ErpMaterial:
:
getIsUniversal
,
bo
.
getIsUniversal
());
lqw
.
eq
(
StringUtils
.
isNotBlank
(
bo
.
getIsUniversal
()),
ErpMaterial:
:
getIsUniversal
,
bo
.
getIsUniversal
());
lqw
.
eq
(
ErpMaterial:
:
getIsDelete
,
IsDeleteStatus
.
NO
.
getCode
());
lqw
.
eq
(
ErpMaterial:
:
getIsDelete
,
IsDeleteStatus
.
NO
.
getCode
());
lqw
.
orderByDesc
(
ErpMaterial:
:
getCreateTime
);
return
lqw
;
return
lqw
;
}
}
...
...
maintain-ui/src/utils/request.js
View file @
c1c96728
...
@@ -9,7 +9,7 @@ import { saveAs } from 'file-saver'
...
@@ -9,7 +9,7 @@ import { saveAs } from 'file-saver'
let
downloadLoadingInstance
;
let
downloadLoadingInstance
;
// 是否显示重新登录
// 是否显示重新登录
export
let
isRelogin
=
{
show
:
fals
e
};
export
let
isRelogin
=
{
show
:
tru
e
};
axios
.
defaults
.
headers
[
'
Content-Type
'
]
=
'
application/json;charset=utf-8
'
axios
.
defaults
.
headers
[
'
Content-Type
'
]
=
'
application/json;charset=utf-8
'
// 对应国际化资源文件后缀
// 对应国际化资源文件后缀
...
@@ -19,7 +19,7 @@ const service = axios.create({
...
@@ -19,7 +19,7 @@ const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分
// axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL
:
process
.
env
.
VUE_APP_BASE_API
,
baseURL
:
process
.
env
.
VUE_APP_BASE_API
,
// 超时
// 超时
timeout
:
5
0000
timeout
:
1
0000
})
})
// request拦截器
// request拦截器
...
...
maintain-ui/src/views/business/material/index.vue
View file @
c1c96728
...
@@ -120,6 +120,16 @@
...
@@ -120,6 +120,16 @@
v-hasPermi=
"['business:material:export']"
v-hasPermi=
"['business:material:export']"
>
导出
</el-button>
>
导出
</el-button>
</el-col>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"warning"
plain
icon=
"el-icon-upload2"
size=
"mini"
@
click=
"handleImport"
v-hasPermi=
"['business:material:import']"
>
导入
</el-button>
</el-col>
<right-toolbar
:showSearch.sync=
"showSearch"
@
queryTable=
"getList"
></right-toolbar>
<right-toolbar
:showSearch.sync=
"showSearch"
@
queryTable=
"getList"
></right-toolbar>
</el-row>
</el-row>
...
@@ -310,6 +320,36 @@
...
@@ -310,6 +320,36 @@
<el-button
@
click=
"cancel"
>
取 消
</el-button>
<el-button
@
click=
"cancel"
>
取 消
</el-button>
</div>
</div>
</el-dialog>
</el-dialog>
<!-- 导入对话框 -->
<el-dialog
:title=
"upload.title"
:visible.sync=
"upload.open"
width=
"400px"
append-to-body
>
<el-upload
ref=
"upload"
:limit=
"1"
accept=
".xlsx, .xls"
:headers=
"upload.headers"
:action=
"upload.url + '?updateSupport=' + upload.updateSupport"
:disabled=
"upload.isUploading"
:on-progress=
"handleFileUploadProgress"
:on-success=
"handleFileSuccess"
:auto-upload=
"false"
drag
>
<i
class=
"el-icon-upload"
></i>
<div
class=
"el-upload__text"
>
将文件拖到此处,或
<em>
点击上传
</em></div>
<div
class=
"el-upload__tip text-center"
slot=
"tip"
>
<!-- <div class="el-upload__tip" slot="tip">-->
<!-- <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据-->
<!-- </div>-->
<span>
仅允许导入xls、xlsx格式文件。
</span>
<el-link
type=
"primary"
:underline=
"false"
style=
"font-size:12px;vertical-align: baseline;"
@
click=
"importTemplate"
>
下载模板
</el-link>
</div>
</el-upload>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
type=
"primary"
@
click=
"submitFileForm"
>
确 定
</el-button>
<el-button
@
click=
"upload.open = false"
>
取 消
</el-button>
</div>
</el-dialog>
</div>
</div>
</template>
</template>
...
@@ -321,6 +361,7 @@ import '@riophae/vue-treeselect/dist/vue-treeselect.css'
...
@@ -321,6 +361,7 @@ import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import
{
listWarehouseLocation
}
from
'
../../../api/business/warehouseLocation
'
import
{
listWarehouseLocation
}
from
'
../../../api/business/warehouseLocation
'
import
{
listMaterialVendor
,
listMaterialVendorAll
}
from
'
../../../api/business/materialVendor
'
import
{
listMaterialVendor
,
listMaterialVendorAll
}
from
'
../../../api/business/materialVendor
'
import
{
listSiteWarehouse
,
listWarehouseAll
}
from
'
@/api/business/siteWarehouse
'
import
{
listSiteWarehouse
,
listWarehouseAll
}
from
'
@/api/business/siteWarehouse
'
import
{
getToken
}
from
"
@/utils/auth
"
;
export
default
{
export
default
{
name
:
"
Material
"
,
name
:
"
Material
"
,
...
@@ -375,6 +416,21 @@ export default {
...
@@ -375,6 +416,21 @@ export default {
isUniversal
:
undefined
,
isUniversal
:
undefined
,
isCheck
:
undefined
,
isCheck
:
undefined
,
},
},
// 导入参数
upload
:
{
// 是否显示弹出层
open
:
false
,
// 弹出层标题
title
:
""
,
// 是否禁用上传
isUploading
:
false
,
// 是否更新已经存在的数据
updateSupport
:
0
,
// 设置上传的请求头部
headers
:
{
Authorization
:
"
Bearer
"
+
getToken
()
},
// 上传的地址
url
:
process
.
env
.
VUE_APP_BASE_API
+
"
business/material/importData
"
},
// 表单参数
// 表单参数
form
:
{},
form
:
{},
// 表单校验
// 表单校验
...
@@ -589,7 +645,32 @@ export default {
...
@@ -589,7 +645,32 @@ export default {
this
.
download
(
'
business/material/export
'
,
{
this
.
download
(
'
business/material/export
'
,
{
...
this
.
queryParams
...
this
.
queryParams
},
`物资列表_
${
new
Date
().
getTime
()}
.xlsx`
)
},
`物资列表_
${
new
Date
().
getTime
()}
.xlsx`
)
}
},
/** 导入按钮操作 */
handleImport
()
{
this
.
upload
.
title
=
"
物资导入
"
;
this
.
upload
.
open
=
true
;
},
/** 下载模板操作 */
importTemplate
()
{
this
.
download
(
'
business/material/importTemplate
'
,
{},
`物资导入模板`
)
},
// 文件上传中处理
handleFileUploadProgress
(
event
,
file
,
fileList
)
{
this
.
upload
.
isUploading
=
true
;
},
// 文件上传成功处理
handleFileSuccess
(
response
,
file
,
fileList
)
{
this
.
upload
.
open
=
false
;
this
.
upload
.
isUploading
=
false
;
this
.
$refs
.
upload
.
clearFiles
();
this
.
$alert
(
"
<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>
"
+
response
.
msg
+
"
</div>
"
,
"
导入结果
"
,
{
dangerouslyUseHTMLString
:
true
});
this
.
getList
();
},
// 提交上传文件
submitFileForm
()
{
this
.
$refs
.
upload
.
submit
();
},
}
}
};
};
</
script
>
</
script
>
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