<template>
|
<div class="app-container">
|
<div>
|
<el-button
|
class="filter-item"
|
style="margin-left: 10px;"
|
type="primary"
|
icon="el-icon-refresh"
|
@click="refreshHandle"
|
>刷新</el-button>
|
<el-date-picker
|
v-model="dateRange"
|
:picker-options="pickerOptions"
|
type="datetimerange"
|
align="right"
|
unlink-panels
|
:clearable="pickClear"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
style="width:25%;"/>
|
<el-select v-model="queryForm.warnlevel" clearable placeholder="请选择警告级别" style="width: 10%">
|
<el-option
|
class="filter-item"
|
@keyup.enter.native="queryHandle"
|
v-for="item in warnLevelList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value">
|
</el-option>
|
</el-select>
|
<el-input v-model="queryForm.customer" class="filter-item" placeholder="购买人" style="width: 12%;"/>
|
<el-input v-model="queryForm.idcard" class="filter-item" placeholder="身份证" style="width: 20%;"/>
|
<el-button
|
class="filter-item"
|
type="primary"
|
icon="el-icon-search"
|
@click="queryHandle"
|
/>
|
</div>
|
<div class="table_content">
|
<el-table
|
v-loading="listLoading"
|
ref="warningTable"
|
:key="tableKey"
|
:data="stockWarningData"
|
border
|
fit
|
highlight-current-row
|
style="width: 100%;"
|
@sort-change="sortWarningChange"
|
>
|
<el-table-column
|
type="selection"
|
align="center"
|
width="80"
|
/>
|
<el-table-column
|
label="警告级别"
|
prop="warnlevel"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.warnlevel }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="姓名"
|
prop="purchasename"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.purchasename }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="身份证"
|
prop="idcard"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.idcard }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="住址"
|
prop="purchaseaddress"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.purchaseaddress }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="报警内容"
|
prop="period"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.warncontent }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="是否处理"
|
prop="ismend"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.ismend | parseSms(scope.row.ismend) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="是否需要发短信"
|
prop="isneed"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.isneed | parseSms(scope.row.isneed) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="是否已发短信"
|
prop="issend"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.issend | parseSms(scope.row.issend) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="更新人"
|
prop="modifiedby"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.modifiedby }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="更新时间"
|
prop="modifieddate"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.modifieddate | parseTime('{y}-{m}-{d}') }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
align="center"
|
width="100"
|
class-name="small-padding fixed-width"
|
><template slot-scope="scope">
|
<el-button
|
type="text"
|
@click="showDetailHandle(scope.row)"
|
>购买明细</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<br>
|
<el-pagination
|
v-show="recordTotal>0"
|
:current-page="currentPage"
|
:page-sizes="[10, 20, 30, 50]"
|
:page-size="pageSize"
|
:total="recordTotal"
|
layout="total, sizes, prev, pager, next, jumper"
|
background
|
style="float:right;"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
/>
|
</div>
|
<el-dialog :visible.sync="purchaseDetailDialogVisible"
|
:modal-append-to-body="false" :close-on-click-modal="false" width="1200px">
|
<el-table
|
v-loading="detailListLoading"
|
:key="detailTableKey"
|
:data="purchaseDetailInfoData"
|
border
|
fit
|
highlight-current-row
|
style="width: 100%;"
|
>
|
<el-table-column label="流向码" prop="directioncode" align="center">
|
<template slot-scope="scope">
|
<span>{{ scope.row.directioncode }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="商品名称" prop="itemname" align="center" >
|
<template slot-scope="scope">
|
<span>{{ scope.row.itemname }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="单价" prop="price" align="center" >
|
<template slot-scope="scope">
|
<span>{{ scope.row.price }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="店铺" prop="shop" align="center" >
|
<template slot-scope="scope">
|
<span>{{ scope.row.shop }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="创建时间"
|
prop="createdat"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.createdat | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
</template>
|
</el-table-column>
|
</el-table>
|
<br>
|
<el-pagination
|
v-show="detailRecordTotal>0"
|
:current-page="detailCurrentPage"
|
:page-sizes="[10, 20, 30, 50]"
|
:page-size="detailPageSize"
|
:total="detailRecordTotal"
|
layout="total, sizes, prev, pager, next, jumper"
|
background
|
style="float:right;"
|
@size-change="handleDetailSizeChange"
|
@current-change="handleDetailCurrentChange"
|
/>
|
</el-dialog>
|
<div style="clear: both;" />
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import { getPurchaseWarningList, getPurchaseDetailList } from '@/api/warning'
|
import { parseTime, computePageCount } from '@/utils'
|
import { parseError } from '@/utils/messageDialog'
|
import Cookies from 'js-cookie'
|
import { Message, MessageBox } from 'element-ui'
|
import { dictionaryAllItems } from '@/api/dictionary';
|
import { checkBtnPermission } from '@/utils/permission'
|
|
export default {
|
name: 'purchase',
|
filters: {
|
parseSms(value) {
|
if (value == 1) {
|
return '是'
|
} else {
|
return '否'
|
}
|
},
|
},
|
computed: {
|
...mapGetters([
|
'userType'
|
])
|
},
|
data() {
|
return {
|
sort:'id',
|
order:'asc',
|
pageSize: 10,
|
recordTotal: 0,
|
currentPage: 1,
|
pageTotal: 0,
|
tableKey: 0,
|
stockWarningData: null,
|
listLoading: true,
|
queryForm: {
|
warnlevel: '',
|
customer:'',
|
idcard:'',
|
starttime:'',
|
endtime:'',
|
},
|
warnLevelList:[
|
{
|
label:"报警",
|
value:"报警",
|
},
|
{
|
label:"预警",
|
value:"预警",
|
}
|
],
|
queryDetailForm:{
|
warnid:null,
|
},
|
purchaseDetailDialogVisible:false,
|
detailSort:'createdat',
|
detailOrder:'desc',
|
detailPageSize: 10,
|
detailRecordTotal: 0,
|
detailCurrentPage: 1,
|
detailPageTotal: 0,
|
detailTableKey: 0,
|
purchaseDetailInfoData: null,
|
detailListLoading: true,
|
dateRange: [],
|
pickClear:false,
|
pickerOptions: {
|
shortcuts: [{
|
text: '最近一周',
|
onClick(picker) {
|
const end = new Date()
|
const start = new Date()
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 6)
|
end.setTime(end.getTime() + 3600 * 1000 * 24)
|
picker.$emit('pick', [start, end])
|
}
|
}, {
|
text: '最近一个月',
|
onClick(picker) {
|
const end = new Date()
|
const start = new Date()
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 29)
|
end.setTime(end.getTime() + 3600 * 1000 * 24)
|
picker.$emit('pick', [start, end])
|
}
|
}, {
|
text: '最近三个月',
|
onClick(picker) {
|
const end = new Date()
|
const start = new Date()
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 89)
|
end.setTime(end.getTime() + 3600 * 1000 * 24)
|
picker.$emit('pick', [start, end])
|
}
|
}, {
|
text: '最近一年',
|
onClick(picker) {
|
const end = new Date()
|
const start = new Date()
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 364)
|
end.setTime(end.getTime() + 3600 * 1000 * 24)
|
picker.$emit('pick', [start, end])
|
}
|
}]
|
},
|
}
|
},
|
created() {
|
this.setDateRange();
|
this.getPurchaseWarningList()
|
},
|
methods: {
|
setDateRange(){
|
const start = new Date()
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
|
let startyear = start.getFullYear();
|
let startmonth = start.getMonth()+1;
|
let startday = start.getDate();
|
let starthour = start.getHours();
|
let startmins = start.getMinutes();
|
let startsecs = start.getSeconds();
|
if (startmonth < 10){
|
startmonth = '0'+startmonth
|
}
|
if (startday < 10){
|
startday = '0' + startday
|
}
|
if (starthour < 10){
|
starthour = '0' + starthour
|
}
|
if (startmins < 10){
|
startmins = '0' + startmins
|
}
|
if (startsecs < 10){
|
startsecs = '0' + startsecs
|
}
|
|
this.dateRange[0] = startyear+'-'+startmonth+'-'+startday+' '+starthour+":"+startmins+":"+startsecs;
|
let enddate = new Date();
|
enddate.setTime(enddate.getTime() + 3600 * 1000 * 24)
|
let endyear = enddate.getFullYear();
|
let endmonth = enddate.getMonth()+1;
|
let endday = enddate.getDate();
|
let endhour = enddate.getHours();
|
let endmins = enddate.getMinutes();
|
let endsecs = enddate.getSeconds();
|
if (endmonth < 10){
|
endmonth = '0'+endmonth
|
}
|
if (endday < 10){
|
endday = '0' + endday
|
}
|
if (endhour < 10){
|
endhour = '0' + endhour
|
}
|
if (endmins < 10){
|
endmins = '0' + endmins
|
}
|
if (endsecs < 10){
|
endsecs = '0' + endsecs
|
}
|
this.dateRange[1] = endyear+'-'+endmonth+'-'+endday+' '+endhour+":"+endmins+":"+endsecs;
|
},
|
getPurchaseWarningList() {
|
const _this = this
|
const params = {}
|
params['sort'] = _this.sort
|
params['order'] = _this.order
|
params['pageIndex'] = _this.currentPage
|
params['pageSize'] = _this.pageSize
|
if (_this.dateRange.length > 0) {
|
let startTime = _this.dateRange[0]
|
let endTime = _this.dateRange[1]
|
|
startTime = new Date(startTime)
|
endTime = new Date(endTime)
|
_this.queryForm.starttime = _this.dateRange[0]
|
_this.queryForm.endtime = _this.dateRange[1]
|
}
|
for (const i in _this.queryForm) {
|
if (_this.queryForm[i] != undefined && _this.queryForm[i].toString() != '') {
|
params[i] = _this.queryForm[i]
|
}
|
}
|
_this.listLoading = true
|
getPurchaseWarningList(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
const result = res.result;
|
_this.recordTotal = result.totalCount
|
_this.pageSize = result.pageSize
|
_this.pageTotal = computePageCount(result.totalCount, result.pageSize)
|
_this.currentPage = result.pageIndex
|
_this.stockWarningData = result.result
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
_this.listLoading = false
|
}).catch(error => {
|
_this.listLoading = false
|
parseError({ error: error, vm: _this })
|
})
|
},
|
refreshHandle: function() {
|
this.getPurchaseWarningList()
|
},
|
queryHandle: function() {
|
this.currentPage = 1
|
this.getPurchaseWarningList()
|
},
|
sortWarningChange: function(param){
|
this.sort = param.prop;
|
this.order = param.order;
|
this.getPurchaseWarningList()
|
},
|
handleSizeChange: function(val) {
|
this.pageSize = val
|
this.currentPage = 1
|
this.getPurchaseWarningList()
|
},
|
handleCurrentChange: function(val) {
|
this.currentPage = val
|
this.getPurchaseWarningList()
|
},
|
getBtnPermission(btnType) {
|
return checkBtnPermission(this.userType, btnType)
|
},
|
showDetailHandle:function(row){
|
this.queryDetailForm.warnid = row.id;
|
this.purchaseDetailDialogVisible = true;
|
this.detailCurrentPage = 1
|
this.getEntryDetailInfoList()
|
},
|
handleDetailSizeChange: function(val) {
|
this.detailPageSize = val
|
this.detailCurrentPage = 1
|
this.getEntryDetailInfoList()
|
},
|
handleDetailCurrentChange: function(val) {
|
this.detailCurrentPage = val
|
this.getEntryDetailInfoList()
|
},
|
getEntryDetailInfoList(){
|
const _this = this
|
const params = {}
|
params['sort'] = _this.detailSort
|
params['order'] = _this.detailOrder
|
params['pageIndex'] = _this.detailCurrentPage
|
params['pageSize'] = _this.detailPageSize
|
for (const i in _this.queryDetailForm) {
|
if (_this.queryDetailForm[i] != undefined && _this.queryDetailForm[i].toString() != '') {
|
params[i] = _this.queryDetailForm[i]
|
}
|
}
|
_this.detailListLoading = true
|
getPurchaseDetailList(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
const result = res.result;
|
_this.detailRecordTotal = result.totalCount
|
_this.detailPageSize = result.pageSize
|
_this.detailPageTotal = computePageCount(result.totalCount, result.pageSize)
|
_this.detailCurrentPage = result.pageIndex
|
_this.purchaseDetailInfoData = result.result
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
_this.detailListLoading = false
|
}).catch(error => {
|
_this.detailListLoading = false
|
parseError({ error: error, vm: _this })
|
})
|
},
|
}
|
}
|
</script>
|