diff --git a/src/views/assetManage/stocktaking/index.vue b/src/views/assetManage/stocktaking/index.vue
index 566415a..49ade7d 100644
--- a/src/views/assetManage/stocktaking/index.vue
+++ b/src/views/assetManage/stocktaking/index.vue
@@ -2,26 +2,6 @@
-
-
@@ -86,7 +66,7 @@
-
+
@@ -116,7 +96,7 @@
{{ scope.row.takeEnd | parseTime }}
-
+
删除
@@ -124,6 +104,9 @@
结算
+
+ 导出
+
@@ -259,14 +242,37 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+
@@ -408,7 +414,7 @@ import CRUD, { presenter, header, form, crud } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
// import { exportFile } from '@/utils/index'
-// import qs from 'qs'
+import qs from 'qs'
import { mapGetters } from 'vuex'
// user: null, id: null, departmentname: null
@@ -452,13 +458,10 @@ export default {
// ]
},
keyWord: '',
- optionVal: 'billNo',
+ optionVal: 'assetMark',
options: [
- { value: 'billNo', label: '盘点单号' },
- { value: 'departmentname', label: '所属部门' }
- // { value: 'username', label: '使用人' },
- // { value: 'project', label: '项目' },
- // { value: 'useYear', label: '使用年限' }
+ { value: 'assetMark', label: '资产编号' },
+ { value: 'assetName', label: '资产名称' }
],
fetchLoading: false,
showFilterList: false,
@@ -485,7 +488,15 @@ export default {
warehouseId: '',
status: ''
},
- tabIndex: 0
+ tabIndex: 0,
+ taskResult: '',
+ taskResultOptions: [
+ { value: 0, label: '未盘' },
+ { value: 1, label: '正常' },
+ { value: 2, label: '盘亏' }
+ ],
+ assetMark: '',
+ assetName: ''
}
},
computed: {
@@ -542,6 +553,9 @@ export default {
if (!item.settleLoading) {
this.$set(item, 'settleLoading', false)
}
+ if (!item.exportLoading) {
+ this.$set(item, 'exportLoading', false)
+ }
})
},
// 新增前
@@ -592,11 +606,6 @@ export default {
searchChange(val) {
if (val) {
this.keyWord = ''
- this.options.forEach(option => {
- if (option.value !== val) {
- this.crud.query[option.value] = null
- }
- })
}
},
resetQuery() {
@@ -604,7 +613,6 @@ export default {
this.query.billNo = ''
this.query.warehouseId = ''
this.query.status = ''
-
this.crud.toQuery()
},
// 触发单选
@@ -632,6 +640,48 @@ export default {
this.$message({ message: '结算操作失败', type: 'error', offset: 8 })
})
},
+ handleExport(row) {
+ row.exportLoading = true
+ let loadingClosed = false
+
+ const params = { id: row.id }
+ const exportUrl = this.baseApi + '/api/stocktake/exportStockTakeData?' + qs.stringify(params, { indices: false })
+
+ const link = document.createElement('a')
+ link.style.display = 'none'
+ link.href = exportUrl
+
+ document.body.appendChild(link)
+ link.click()
+
+ // 正常关闭
+ const timer = setTimeout(() => {
+ if (!loadingClosed) {
+ loadingClosed = true
+ row.exportLoading = false
+ document.body.removeChild(link)
+ }
+ }, 1500)
+
+ // 兜底最长等待3秒
+ setTimeout(() => {
+ if (!loadingClosed) {
+ clearTimeout(timer)
+ row.exportLoading = false
+ }
+ }, 3000)
+ },
+ doSearch() {
+ if (this.optionVal === 'assetMark') {
+ this.assetMark = this.keyWord
+ this.assetName = ''
+ } else {
+ this.assetName = this.keyWord
+ this.assetMark = ''
+ }
+ this.inventoryPage = 1
+ this.tabIndex === 1 ? this.getStockTakeSuperfluousByTaskId() : this.fetchInventoryList()
+ },
toDelete(datas) {
this.$confirm('此操作将删除当前所选盘点任务' + '你是否还要继续?', '提示', {
confirmButtonText: '继续',
@@ -655,25 +705,6 @@ export default {
}).catch(() => {
})
},
- // doExport(data) {
- // crud.downloadLoading = true
- // this.$confirm('此操作将导出所选数据' + '你是否还要继续?', '提示', {
- // confirmButtonText: '继续',
- // cancelButtonText: '取消',
- // type: 'warning',
- // dangerouslyUseHTMLString: true
- // }).then(() => {
- // const ids = []
- // data.forEach(val => {
- // ids.push(val.fondsId)
- // })
- // const params = {
- // 'fondsIds': ids
- // }
- // exportFile(this.baseApi + '/api/fonds/download?' + qs.stringify(params, { indices: false }))
- // }).catch(() => {
- // })
- // },
// 清空缓存
// clearCacheDatas(datas) {
// this.$confirm('此操作将清空盘点缓存数据' + '你是否还要继续?', '提示', {
@@ -694,7 +725,6 @@ export default {
if (isBtn) {
this.fetchLoading = true
}
-
this.showFilterList = true
const params = {
'departmentname': this.crud.form.departmentname,
@@ -711,8 +741,6 @@ export default {
this.$message({ message: '获取数据失败', type: 'error', offset: 8 })
this.fetchLoading = false
})
- } else {
- return false
}
})
},
@@ -728,47 +756,46 @@ export default {
},
// 处理部门选择变化
handleDepartmentChange() {
- // 重置分页到第一页
this.currentPage = 1
this.fetchAssetsData()
},
// 处理双击行事件
handleRowDblClick(row) {
this.tabIndex = 0
- this.selectedTask = []
- this.selectedTask.push(row)
+ this.selectedTask = [row]
this.detailDialogVisible = true
+
+ this.taskResult = ''
+ this.assetMark = ''
+ this.assetName = ''
+ this.keyWord = ''
this.inventoryPage = 1
- this.inventoryPageSize = 10
- // 获取盘点清单数据
this.fetchInventoryList()
},
changeActiveTab(index) {
this.tabIndex = index
- this.inventoryPage = 1 // 重置页码
- this.inventoryPageSize = 10 // 重置条数
-
- if (this.tabIndex === 1) {
- this.getStockTakeSuperfluousByTaskId()
- } else {
- this.fetchInventoryList()
- }
+ this.inventoryPage = 1
+ this.taskResult = ''
+ this.assetMark = ''
+ this.assetName = ''
+ this.keyWord = ''
+ this.tabIndex === 1 ? this.getStockTakeSuperfluousByTaskId() : this.fetchInventoryList()
},
// 获取盘点清单数据
fetchInventoryList() {
if (!this.selectedTask) return
-
this.inventoryLoading = true
const params = {
- 'taskId': this.selectedTask[0].id,
- 'pageNo': this.inventoryPage,
- 'pageSize': this.inventoryPageSize
+ taskId: this.selectedTask[0].id,
+ pageNo: this.inventoryPage,
+ pageSize: this.inventoryPageSize,
+ taskResult: this.taskResult,
+ assetMark: this.assetMark,
+ assetName: this.assetName
}
FetchStockTakeDetailsByTaskId(params).then(res => {
- console.log('FetchStockTakeDetailsByTaskId', res)
this.inventoryList = res.records
this.inventoryTotal = res.total
-
this.inventoryLoading = false
}).catch(err => {
console.log(err)
@@ -776,19 +803,18 @@ export default {
this.inventoryLoading = false
})
},
-
// 获取盘盈列表数据
getStockTakeSuperfluousByTaskId() {
if (!this.selectedTask) return
-
this.inventoryLoading = true
const params = {
- 'taskId': this.selectedTask[0].id,
- 'pageNo': this.inventoryPage,
- 'pageSize': this.inventoryPageSize
+ taskId: this.selectedTask[0].id,
+ pageNo: this.inventoryPage,
+ pageSize: this.inventoryPageSize,
+ assetMark: this.assetMark,
+ assetName: this.assetName
}
FetchStockTakeSuperfluousByTaskId(params).then(res => {
- console.log('dd', res.data.records)
this.inventoryList = res.data.records
this.inventoryTotal = res.data.total
this.inventoryLoading = false
@@ -802,24 +828,15 @@ export default {
handleInventorySizeChange(size) {
this.inventoryPage = 1
this.inventoryPageSize = size
- if (this.tabIndex === 1) {
- this.getStockTakeSuperfluousByTaskId()
- } else {
- this.fetchInventoryList()
- }
+ this.tabIndex === 1 ? this.getStockTakeSuperfluousByTaskId() : this.fetchInventoryList()
},
// 处理盘点清单当前页码变化
handleInventoryCurrentChange(current) {
this.inventoryPage = current
- if (this.tabIndex === 1) {
- this.getStockTakeSuperfluousByTaskId()
- } else {
- this.fetchInventoryList()
- }
+ this.tabIndex === 1 ? this.getStockTakeSuperfluousByTaskId() : this.fetchInventoryList()
},
// 直接触发新增接口
addStockTakeBill() {
- // 直接调用新增接口,不需要传参
this.addLoading = true
add({}).then(res => {
if (res.data === null) {
@@ -835,7 +852,6 @@ export default {
this.addLoading = false
})
}
-
}
}
@@ -939,5 +955,4 @@ export default {
}
}
}
-