Commit 9d62c95a by wangyalan-git

报表日期修改

parent b2e78f39
...@@ -63,10 +63,10 @@ ...@@ -63,10 +63,10 @@
<el-card class="filter-container mt15" <el-card class="filter-container mt15"
shadow="never"> shadow="never">
<el-row type="flex" class="btn-groups" justify="end"> <el-row type="flex" class="btn-groups" justify="end">
<el-button type="primary" @click="handleAdd">新增</el-button> <el-button type="primary" @click="handleAdd">新增</el-button>
<el-button type="success" @click="handleScanPut">扫码入库</el-button> <el-button type="success" @click="handleScanPut">扫码入库</el-button>
<el-button type="info" @click="handleScanOut">扫码出库</el-button> <el-button type="info" @click="handleScanOut">扫码出库</el-button>
<el-button type="warning" @click="handleImport">导入</el-button> <el-button type="warning" @click="handleImport">导入</el-button>
</el-row> </el-row>
<div class="table-container"> <div class="table-container">
<el-table :data="list" <el-table :data="list"
...@@ -111,12 +111,16 @@ ...@@ -111,12 +111,16 @@
<el-table-column label="操作" <el-table-column label="操作"
align="center"> align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" <div style="margin-bottom: 10px;">
type="warning" <el-button size="mini"
@click="handleUpdate(scope.row)">修改</el-button> type="warning"
@click="handleUpdate(scope.row)">修改
</el-button>
</div>
<el-button size="mini" <el-button size="mini"
type="danger" type="danger"
@click="handleDelete(scope.row.id)">删除</el-button> @click="handleDelete(scope.row.id)">删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -134,7 +138,7 @@ ...@@ -134,7 +138,7 @@
</el-pagination> </el-pagination>
</div> </div>
</el-card> </el-card>
<!-- 弹窗--> <!-- 弹窗-->
<add-goods-modal ref="addGoods" @ok="getList"></add-goods-modal> <add-goods-modal ref="addGoods" @ok="getList"></add-goods-modal>
<import-goods-modal ref="importGoods" @ok="getList"></import-goods-modal> <import-goods-modal ref="importGoods" @ok="getList"></import-goods-modal>
<scan-put-storage ref="scanPut" @ok="getList"></scan-put-storage> <scan-put-storage ref="scanPut" @ok="getList"></scan-put-storage>
...@@ -144,8 +148,8 @@ ...@@ -144,8 +148,8 @@
</template> </template>
<script> <script>
import moment from 'moment' import moment from 'moment'
import { getGoodsList,getGoodsCategoryList,getStockRooms, updateGoods } from '@/api/inventory' import { getGoodsList, getGoodsCategoryList, getStockRooms, updateGoods } from '@/api/inventory'
import {getSuppliersList} from '@/api/supplier' import { getSuppliersList } from '@/api/supplier'
import AddGoodsModal from './modules/addGoodsModal' import AddGoodsModal from './modules/addGoodsModal'
import ImportGoodsModal from './modules/importGoodsModal' import ImportGoodsModal from './modules/importGoodsModal'
import ScanPutStorage from './modules/scanPutStorage' import ScanPutStorage from './modules/scanPutStorage'
...@@ -218,37 +222,37 @@ export default { ...@@ -218,37 +222,37 @@ export default {
this.multipleSelection = vals this.multipleSelection = vals
}, },
// 删除 // 删除
handleDelete(id){ handleDelete(id) {
this.$confirm('是否删除该物品?', '提示', { this.$confirm('是否删除该物品?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
updateGoods({id: id,deleteStatus: 0 }).then(res=>{ updateGoods({ id: id, deleteStatus: 0 }).then(res => {
this.getList() this.getList()
}) })
}).catch(() => { }).catch(() => {
}); })
}, },
// 修改 // 修改
handleUpdate(row){ handleUpdate(row) {
this.$refs.updateStore.update(row) this.$refs.updateStore.update(row)
}, },
// 物品类别 // 物品类别
getGoodsCategoryList(){ getGoodsCategoryList() {
getGoodsCategoryList().then(res=>{ getGoodsCategoryList().then(res => {
this.categoryOptions = res.data.list this.categoryOptions = res.data.list
}) })
}, },
// 供应商 // 供应商
getSuppliersList(){ getSuppliersList() {
getSuppliersList().then(res=>{ getSuppliersList().then(res => {
this.supplierOptions = res.data.list this.supplierOptions = res.data.list
}) })
}, },
// 库房 // 库房
getStockRooms(){ getStockRooms() {
getStockRooms({status: 1}).then(res=>{ getStockRooms({ status: 1 }).then(res => {
this.depotOptions = res.data.list this.depotOptions = res.data.list
}) })
}, },
...@@ -257,8 +261,8 @@ export default { ...@@ -257,8 +261,8 @@ export default {
this.listLoading = true this.listLoading = true
//请求数据 //请求数据
console.log('listQuery', this.listQuery) console.log('listQuery', this.listQuery)
if(this.$store.getters.type == 2){ if (this.$store.getters.type == 2) {
this.listQuery.stockRoomId = this.$store.getters.stockRoomId this.listQuery.stockRoomId = this.$store.getters.stockRoomId
} }
getGoodsList(this.listQuery).then(res => { getGoodsList(this.listQuery).then(res => {
this.listLoading = false this.listLoading = false
...@@ -269,18 +273,18 @@ export default { ...@@ -269,18 +273,18 @@ export default {
}) })
}, },
// 新增 // 新增
handleAdd(){ handleAdd() {
this.$refs.addGoods.add() this.$refs.addGoods.add()
}, },
// 扫码入库 // 扫码入库
handleScanPut(){ handleScanPut() {
this.$refs.scanPut.add() this.$refs.scanPut.add()
}, },
handleScanOut(){ handleScanOut() {
this.$refs.scanOut.add() this.$refs.scanOut.add()
}, },
// 导入 // 导入
handleImport(){ handleImport() {
this.$refs.importGoods.add() this.$refs.importGoods.add()
} }
} }
...@@ -301,7 +305,8 @@ export default { ...@@ -301,7 +305,8 @@ export default {
.input-width { .input-width {
width: 180px; width: 180px;
} }
.btn-groups button{
.btn-groups button {
width: 100px; width: 100px;
} }
</style> </style>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
:value="item.id"></el-option> :value="item.id"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="出库日期:" > <el-form-item label="出库日期:">
<el-date-picker <el-date-picker
v-model="dataRange" v-model="dataRange"
type="daterange" type="daterange"
...@@ -145,7 +145,7 @@ export default { ...@@ -145,7 +145,7 @@ export default {
var tDate = today.getDate() var tDate = today.getDate()
tMonth = this.doHandleMonth(tMonth + 1) tMonth = this.doHandleMonth(tMonth + 1)
tDate = this.doHandleMonth(tDate) tDate = this.doHandleMonth(tDate)
console.log('tYear + \'-\' + tMonth + \'-\' + tDate',tYear + '-' + tMonth + '-' + tDate) console.log('tYear + \'-\' + tMonth + \'-\' + tDate', tYear + '-' + tMonth + '-' + tDate)
return tYear + '-' + tMonth + '-' + tDate return tYear + '-' + tMonth + '-' + tDate
}, },
doHandleMonth(month) { doHandleMonth(month) {
...@@ -156,9 +156,9 @@ export default { ...@@ -156,9 +156,9 @@ export default {
return m return m
}, },
formatEveryDay() { formatEveryDay() {
let start1 = this.getDay(-7) let start1 = this.getDay(-6)
let end1 = this.getDay(0) let end1 = this.getDay(0)
console.log('start1','end1',start1,end1) console.log('start1', 'end1', start1, end1)
let dateList = [] let dateList = []
var startTime = this.getDate(start1) var startTime = this.getDate(start1)
var endTime = this.getDate(end1) var endTime = this.getDate(end1)
...@@ -169,8 +169,8 @@ export default { ...@@ -169,8 +169,8 @@ export default {
dateList.push(year + '-' + month + '-' + day) dateList.push(year + '-' + month + '-' + day)
startTime.setDate(startTime.getDate() + 1) startTime.setDate(startTime.getDate() + 1)
} }
console.log(' this.dataRange',dateList, this.dataRange) console.log(' this.dataRange', dateList, this.dataRange)
this.dataRange = [dateList[0],dateList[dateList.length-1]] this.dataRange = [dateList[0], dateList[dateList.length - 1]]
}, },
getDate(datestr) { getDate(datestr) {
var temp = datestr.split('-') var temp = datestr.split('-')
...@@ -178,6 +178,34 @@ export default { ...@@ -178,6 +178,34 @@ export default {
console.log('date', date) console.log('date', date)
return date return date
}, },
//获取两日期之间日期列表函数
getdiffdate(stime, etime) {
//初始化日期列表,数组
var diffdate = new Array()
var i = 0
//开始日期小于等于结束日期,并循环
while (stime <= etime) {
diffdate[i] = stime
//获取开始日期时间戳
var stime_ts = new Date(stime).getTime()
console.log('当前日期:' + stime + '当前时间戳:' + stime_ts)
//增加一天时间戳后的日期
var next_date = stime_ts + (24 * 60 * 60 * 1000)
//拼接年月日,这里的月份会返回(0-11),所以要+1
var next_dates_y = new Date(next_date).getFullYear() + '-'
var next_dates_m = (new Date(next_date).getMonth() + 1 < 10) ? '0' + (new Date(next_date).getMonth() + 1) + '-' : (new Date(next_date).getMonth() + 1) + '-'
var next_dates_d = (new Date(next_date).getDate() < 10) ? '0' + new Date(next_date).getDate() : new Date(next_date).getDate()
stime = next_dates_y + next_dates_m + next_dates_d
//增加数组key
i++
}
return diffdate
},
handleOpenCate(visible) { handleOpenCate(visible) {
if (visible) { if (visible) {
this.getGoodsCategoryList() this.getGoodsCategoryList()
...@@ -210,16 +238,18 @@ export default { ...@@ -210,16 +238,18 @@ export default {
}) })
}, },
getList() { getList() {
if(!this.listQuery.goodsId){ if (!this.listQuery.goodsId) {
this.$message.warning('请选择物品') this.$message.warning('请选择物品')
return return
} }
getRecipientList({ dateList: this.dataRange, goodsId: this.listQuery.goodsId }).then(res => { let dateList = this.getdiffdate(this.dataRange[0], this.dataRange[1])
console.log('dateList', dateList)
getRecipientList({ dateList: dateList, goodsId: this.listQuery.goodsId }).then(res => {
this.chartData.rows = res.data this.chartData.rows = res.data
}) })
}, },
handleResetSearch() { handleResetSearch() {
this.dataRange = null this.dataRange = null
this.listQuery = Object.assign({}, defaultListQuery) this.listQuery = Object.assign({}, defaultListQuery)
this.getList() this.getList()
}, },
......
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