资产优化
This commit is contained in:
parent
f2b1115bd9
commit
31e1d0b4cc
@ -52,8 +52,7 @@
|
||||
"vuex": "3.6.0",
|
||||
"xlsx": "^0.18.5",
|
||||
"element-china-area-data": "^6.1.0",
|
||||
"mammoth": "^1.9.0",
|
||||
"qrcode.vue": "^3.6.0"
|
||||
"mammoth": "^1.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "4.4.6",
|
||||
|
@ -2,24 +2,10 @@ import request from '@/utils/request'
|
||||
|
||||
// 查询资产分类列表
|
||||
export function listClassification(query) {
|
||||
// 将驼峰命名转换为下划线命名
|
||||
const params = {}
|
||||
if (query) {
|
||||
Object.keys(query).forEach(key => {
|
||||
if (key === 'classificationCode') {
|
||||
params.classification_code = query[key]
|
||||
} else if (key === 'classificationName') {
|
||||
params.classification_name = query[key]
|
||||
} else {
|
||||
params[key] = query[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/asset/classifications/list',
|
||||
method: 'get',
|
||||
params: params
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
@ -43,8 +29,8 @@ export function addClassification(data) {
|
||||
// 修改资产分类
|
||||
export function updateClassification(data) {
|
||||
return request({
|
||||
url: '/asset/classifications/' + data.id,
|
||||
method: 'put',
|
||||
url: '/asset/classifications/update/' + data.id,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -52,8 +38,8 @@ export function updateClassification(data) {
|
||||
// 删除资产分类
|
||||
export function delClassification(id, lastModUserId) {
|
||||
return request({
|
||||
url: '/asset/classifications/' + id,
|
||||
method: 'delete',
|
||||
url: '/asset/classifications/delete/' + id,
|
||||
method: 'post',
|
||||
params: lastModUserId ? { lastModUserId } : {}
|
||||
})
|
||||
}
|
||||
@ -62,7 +48,7 @@ export function delClassification(id, lastModUserId) {
|
||||
export function disableClassification(id, lastModUserId) {
|
||||
return request({
|
||||
url: '/asset/classifications/' + id + '/status/disable',
|
||||
method: 'put',
|
||||
method: 'post',
|
||||
params: lastModUserId ? { lastModUserId } : {}
|
||||
})
|
||||
}
|
||||
@ -71,7 +57,7 @@ export function disableClassification(id, lastModUserId) {
|
||||
export function enableClassification(id, lastModUserId) {
|
||||
return request({
|
||||
url: '/asset/classifications/' + id + '/status/enable',
|
||||
method: 'put',
|
||||
method: 'post',
|
||||
params: lastModUserId ? { lastModUserId } : {}
|
||||
})
|
||||
}
|
||||
@ -79,8 +65,8 @@ export function enableClassification(id, lastModUserId) {
|
||||
// 批量删除资产分类
|
||||
export function delClassificationBatch(ids, lastModUserId) {
|
||||
return request({
|
||||
url: '/asset/classifications/batch',
|
||||
method: 'delete',
|
||||
url: '/asset/classifications/deleteBatch',
|
||||
method: 'post',
|
||||
data: ids,
|
||||
params: lastModUserId ? { lastModUserId } : {}
|
||||
})
|
||||
@ -88,47 +74,20 @@ export function delClassificationBatch(ids, lastModUserId) {
|
||||
|
||||
// 获取资产分类树形结构
|
||||
export function getClassificationTree(query) {
|
||||
// 将驼峰命名转换为下划线命名
|
||||
const params = {}
|
||||
if (query) {
|
||||
Object.keys(query).forEach(key => {
|
||||
if (key === 'classificationCode') {
|
||||
params.classification_code = query[key]
|
||||
} else if (key === 'classificationName') {
|
||||
params.classification_name = query[key]
|
||||
} else {
|
||||
params[key] = query[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/asset/classifications/tree',
|
||||
method: 'get',
|
||||
params: params
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 根据父ID查询子分类
|
||||
export function getChildClassifications(parentId, query) {
|
||||
// 将驼峰命名转换为下划线命名
|
||||
const params = {}
|
||||
if (query) {
|
||||
Object.keys(query).forEach(key => {
|
||||
if (key === 'classificationCode') {
|
||||
params.classification_code = query[key]
|
||||
} else if (key === 'classificationName') {
|
||||
params.classification_name = query[key]
|
||||
} else {
|
||||
params[key] = query[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/asset/classifications/children/' + parentId,
|
||||
method: 'get',
|
||||
params: params
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
@ -142,23 +101,10 @@ export function checkClassificationInUse(id) {
|
||||
|
||||
// 导出资产分类
|
||||
export function exportClassification(query) {
|
||||
// 将驼峰命名转换为下划线命名
|
||||
const params = {}
|
||||
if (query) {
|
||||
Object.keys(query).forEach(key => {
|
||||
if (key === 'classificationCode') {
|
||||
params.classification_code = query[key]
|
||||
} else if (key === 'classificationName') {
|
||||
params.classification_name = query[key]
|
||||
} else {
|
||||
params[key] = query[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/asset/classifications/export',
|
||||
method: 'get',
|
||||
params: params
|
||||
params: query
|
||||
})
|
||||
}
|
@ -29,8 +29,8 @@ export function addAsset(data) {
|
||||
// 修改资产
|
||||
export function updateAsset(data) {
|
||||
return request({
|
||||
url: `/asset/${data.assetCode}`,
|
||||
method: 'put',
|
||||
url: `/asset/update/${data.assetCode}`,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -39,7 +39,7 @@ export function updateAsset(data) {
|
||||
export function deleteAsset(assetCode) {
|
||||
return request({
|
||||
url: '/asset/delete',
|
||||
method: 'delete',
|
||||
method: 'post',
|
||||
params: { assetCode }
|
||||
})
|
||||
}
|
||||
@ -48,7 +48,7 @@ export function deleteAsset(assetCode) {
|
||||
export function deleteAssets(assetCodes) {
|
||||
return request({
|
||||
url: '/asset/batch/delete',
|
||||
method: 'delete',
|
||||
method: 'post',
|
||||
data: { assetCodes }
|
||||
})
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export function getLabelTemplate(id) {
|
||||
// 新增资产标签
|
||||
export function addLabelTemplate(data) {
|
||||
return request({
|
||||
url: '/asset/label',
|
||||
url: '/asset/label/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
@ -29,8 +29,8 @@ export function addLabelTemplate(data) {
|
||||
// 修改资产标签
|
||||
export function updateLabelTemplate(id, data) {
|
||||
return request({
|
||||
url: '/asset/label/' + id,
|
||||
method: 'put',
|
||||
url: '/asset/label/update' + id,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -39,7 +39,7 @@ export function updateLabelTemplate(id, data) {
|
||||
export function deleteLabelTemplate(id) {
|
||||
return request({
|
||||
url: '/asset/label/template/' + id,
|
||||
method: 'delete'
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ export function deleteLabelTemplate(id) {
|
||||
export function setDefaultTemplate(id) {
|
||||
return request({
|
||||
url: '/asset/label/template/default/' + id,
|
||||
method: 'put'
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2,24 +2,10 @@ import request from '@/utils/request'
|
||||
|
||||
// 查询资产位置列表
|
||||
export function listLocation(query) {
|
||||
// 将驼峰命名转换为下划线命名
|
||||
const params = {}
|
||||
if (query) {
|
||||
Object.keys(query).forEach(key => {
|
||||
if (key === 'locationCode') {
|
||||
params.location_code = query[key]
|
||||
} else if (key === 'locationName') {
|
||||
params.location_name = query[key]
|
||||
} else {
|
||||
params[key] = query[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/asset/locations/list',
|
||||
method: 'get',
|
||||
params: params
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
@ -43,8 +29,8 @@ export function addLocation(data) {
|
||||
// 修改资产位置
|
||||
export function updateLocation(data) {
|
||||
return request({
|
||||
url: '/asset/locations/' + data.id,
|
||||
method: 'put',
|
||||
url: '/asset/locations/update/' + data.id,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -52,8 +38,8 @@ export function updateLocation(data) {
|
||||
// 删除资产位置
|
||||
export function delLocation(id, lastModUserId) {
|
||||
return request({
|
||||
url: '/asset/locations/' + id,
|
||||
method: 'delete',
|
||||
url: '/asset/locations/delete/' + id,
|
||||
method: 'post',
|
||||
params: lastModUserId ? { lastModUserId } : {}
|
||||
})
|
||||
}
|
||||
@ -62,7 +48,7 @@ export function delLocation(id, lastModUserId) {
|
||||
export function disableLocation(id, lastModUserId) {
|
||||
return request({
|
||||
url: '/asset/locations/' + id + '/status/disable',
|
||||
method: 'put',
|
||||
method: 'post',
|
||||
params: lastModUserId ? { lastModUserId } : {}
|
||||
})
|
||||
}
|
||||
@ -71,7 +57,7 @@ export function disableLocation(id, lastModUserId) {
|
||||
export function enableLocation(id, lastModUserId) {
|
||||
return request({
|
||||
url: '/asset/locations/' + id + '/status/enable',
|
||||
method: 'put',
|
||||
method: 'post',
|
||||
params: lastModUserId ? { lastModUserId } : {}
|
||||
})
|
||||
}
|
||||
@ -79,8 +65,8 @@ export function enableLocation(id, lastModUserId) {
|
||||
// 批量删除资产位置
|
||||
export function delLocationBatch(ids, lastModUserId) {
|
||||
return request({
|
||||
url: '/asset/locations/batch',
|
||||
method: 'delete',
|
||||
url: '/asset/locations/batch/delete',
|
||||
method: 'post',
|
||||
data: ids,
|
||||
params: lastModUserId ? { lastModUserId } : {}
|
||||
})
|
||||
@ -88,47 +74,19 @@ export function delLocationBatch(ids, lastModUserId) {
|
||||
|
||||
// 获取资产位置树形结构
|
||||
export function getLocationTree(query) {
|
||||
// 将驼峰命名转换为下划线命名
|
||||
const params = {}
|
||||
if (query) {
|
||||
Object.keys(query).forEach(key => {
|
||||
if (key === 'locationCode') {
|
||||
params.location_code = query[key]
|
||||
} else if (key === 'locationName') {
|
||||
params.location_name = query[key]
|
||||
} else {
|
||||
params[key] = query[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/asset/locations/tree',
|
||||
method: 'get',
|
||||
params: params
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 根据父ID查询子位置
|
||||
export function getChildLocations(parentId, query) {
|
||||
// 将驼峰命名转换为下划线命名
|
||||
const params = {}
|
||||
if (query) {
|
||||
Object.keys(query).forEach(key => {
|
||||
if (key === 'locationCode') {
|
||||
params.location_code = query[key]
|
||||
} else if (key === 'locationName') {
|
||||
params.location_name = query[key]
|
||||
} else {
|
||||
params[key] = query[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/asset/locations/children/' + parentId,
|
||||
method: 'get',
|
||||
params: params
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
@ -147,30 +105,16 @@ export function checkLocationCode(id, locationCode) {
|
||||
method: 'get',
|
||||
params: {
|
||||
id: id,
|
||||
location_code: locationCode
|
||||
locationCode: locationCode
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 导出资产位置
|
||||
export function exportLocation(query) {
|
||||
// 将驼峰命名转换为下划线命名
|
||||
const params = {}
|
||||
if (query) {
|
||||
Object.keys(query).forEach(key => {
|
||||
if (key === 'locationCode') {
|
||||
params.location_code = query[key]
|
||||
} else if (key === 'locationName') {
|
||||
params.location_name = query[key]
|
||||
} else {
|
||||
params[key] = query[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/asset/locations/export',
|
||||
method: 'get',
|
||||
params: params
|
||||
params: query
|
||||
})
|
||||
}
|
@ -366,7 +366,7 @@ export default {
|
||||
listClassification(this.queryParams).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
// 转换API返回数据结构为驼峰命名
|
||||
this.classList = this.convertSnakeToCamel(res.data.list)
|
||||
this.classList = this.convertSnakeToCamel(res.data.data)
|
||||
this.total = res.data.total
|
||||
} else {
|
||||
this.$message.error(res.msg || '获取分类列表失败')
|
||||
@ -422,7 +422,7 @@ export default {
|
||||
pageSize: this.queryParams.pageSize
|
||||
}).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
this.classList = this.convertSnakeToCamel(res.data.list)
|
||||
this.classList = this.convertSnakeToCamel(res.data.data)
|
||||
this.total = res.data.total
|
||||
} else {
|
||||
this.$message.error(res.msg || '获取子分类列表失败')
|
||||
@ -555,28 +555,21 @@ export default {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 先检查分类是否被使用
|
||||
checkClassificationInUse(row.id).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE && res.data) {
|
||||
this.$message.error('该分类已被使用,无法删除')
|
||||
return
|
||||
}
|
||||
// 未被使用,执行删除操作
|
||||
const lastModUserId = this.$store.getters.userId || ''
|
||||
delClassification(row.id, lastModUserId).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
this.$message.success('删除成功')
|
||||
// 重新获取树形结构,确保更新多级分类
|
||||
this.getTree()
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(res.msg || '删除失败')
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('删除操作失败', error)
|
||||
this.$message.error('系统错误,删除失败')
|
||||
})
|
||||
})
|
||||
// 执行删除操作
|
||||
delClassification(row.id).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
this.$message.success('删除成功')
|
||||
// 重新获取树形结构,确保更新多级分类
|
||||
this.getTree()
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(res.msg || '删除失败')
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('删除操作失败', error)
|
||||
this.$message.error('系统错误,删除失败')
|
||||
})
|
||||
|
||||
}).catch(() => {})
|
||||
},
|
||||
/** 状态修改按钮操作 */
|
||||
|
@ -451,7 +451,7 @@ export default {
|
||||
this.loading = true
|
||||
listAssets(this.queryParams).then(response => {
|
||||
if (response.code === API_SUCCESS_CODE) {
|
||||
this.assetList = response.data.list || []
|
||||
this.assetList = response.data.data || []
|
||||
this.total = response.data.total
|
||||
}
|
||||
this.loading = false
|
||||
|
@ -247,7 +247,7 @@ export default {
|
||||
}
|
||||
checkLocationCode(this.form.id, value).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
if (res.data) {
|
||||
if (!res.data) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('该位置编码已存在'))
|
||||
@ -390,7 +390,7 @@ export default {
|
||||
listLocation(this.queryParams).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
// 转换API返回数据结构为驼峰命名
|
||||
this.locationList = this.convertSnakeToCamel(res.data.list)
|
||||
this.locationList = this.convertSnakeToCamel(res.data.data)
|
||||
this.total = res.data.total
|
||||
} else {
|
||||
this.$message.error(res.msg || '获取位置列表失败')
|
||||
@ -412,7 +412,7 @@ export default {
|
||||
pageSize: this.queryParams.pageSize
|
||||
}).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
this.locationList = this.convertSnakeToCamel(res.data.list)
|
||||
this.locationList = this.convertSnakeToCamel(res.data.data)
|
||||
this.total = res.data.total
|
||||
} else {
|
||||
this.$message.error(res.msg || '获取子位置列表失败')
|
||||
@ -549,27 +549,20 @@ export default {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 先检查位置是否被使用
|
||||
checkLocationInUse(row.id).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE && res.data) {
|
||||
this.$message.error('该位置已被使用,无法删除')
|
||||
return
|
||||
// 未被使用,执行删除操作
|
||||
const lastModUserId = this.$store.getters.userId || ''
|
||||
delLocation(row.id, lastModUserId).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
this.$message.success('删除成功')
|
||||
// 重新获取树形结构,确保更新多级结构
|
||||
this.getTree()
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(res.msg || '删除失败')
|
||||
}
|
||||
// 未被使用,执行删除操作
|
||||
const lastModUserId = this.$store.getters.userId || ''
|
||||
delLocation(row.id, lastModUserId).then(res => {
|
||||
if (res.code === API_SUCCESS_CODE) {
|
||||
this.$message.success('删除成功')
|
||||
// 重新获取树形结构,确保更新多级结构
|
||||
this.getTree()
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error(res.msg || '删除失败')
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('删除操作失败', error)
|
||||
this.$message.error('系统错误,删除失败')
|
||||
})
|
||||
}).catch(error => {
|
||||
console.error('删除操作失败', error)
|
||||
this.$message.error('系统错误,删除失败')
|
||||
})
|
||||
}).catch(() => {})
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user