<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-select v-model="queryForm.enterprisetype" clearable placeholder="请选择企业类型">
|
<el-option
|
class="filter-item"
|
@keyup.enter.native="queryHandle"
|
v-for="item in enterpriseTypeList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value">
|
</el-option>
|
</el-select>
|
<el-select v-model="queryForm.warntype" clearable placeholder="请选择警告类型">
|
<el-option
|
class="filter-item"
|
@keyup.enter.native="queryHandle"
|
v-for="item in warnTypeList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value">
|
</el-option>
|
</el-select>
|
<el-button
|
class="filter-item"
|
type="primary"
|
icon="el-icon-search"
|
@click="queryHandle"
|
/>
|
</div>
|
<br/>
|
<div class="table_content">
|
<el-table
|
v-loading="listLoading"
|
ref="warningTable"
|
:key="tableKey"
|
:data="warningData"
|
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="warntype"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.warntype }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="企业类型"
|
prop="enterprisetype"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.enterprisetype }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="计算周期(天)"
|
prop="period"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.period }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="预警值"
|
prop="minimum"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.minimum }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="报警值"
|
prop="maximum"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.maximum }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="报警是否开启短信通知"
|
prop="maximum"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.issms | parseSms(scope.row.issms) }}</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="240"
|
class-name="small-padding fixed-width"
|
>
|
<template slot-scope="scope">
|
<el-button
|
v-if="getBtnPermission('edit')"
|
type="text"
|
@click="showEditHandle(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="dialogFormVisible"
|
:modal-append-to-body="false"
|
:close-on-click-modal="false"
|
width="600px"
|
>
|
<el-form
|
ref="dataForm"
|
:rules="dataFormRules"
|
:model="dataForm"
|
label-position="right"
|
label-width="100px"
|
style="margin-left:50px;width:500px;"
|
element-loading-text="保存中..."
|
>
|
<el-form-item
|
label="警告类型:"
|
prop="type"
|
>
|
{{dataForm.warntype}}
|
</el-form-item>
|
<el-form-item
|
label="计算周期(天):"
|
prop="period"
|
>
|
<el-input v-model="dataForm.period" type="number"></el-input>
|
</el-form-item>
|
<el-form-item
|
label="预警值:"
|
prop="minimum"
|
>
|
<el-input v-model="dataForm.minimum" type="number"></el-input>
|
</el-form-item>
|
<el-form-item
|
label="报警值:"
|
prop="maximum"
|
>
|
<el-input v-model="dataForm.maximum" type="number"></el-input>
|
</el-form-item>
|
<el-form-item
|
label="报警短信通知:"
|
prop="issms"
|
>
|
<el-radio-group v-model="dataForm.issms">
|
<el-radio :label="1">是</el-radio>
|
<el-radio :label="0">否</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-form>
|
<div
|
slot="footer"
|
class="dialog-footer"
|
>
|
<el-button @click="dialogFormVisible = false">取消</el-button>
|
<el-button
|
type="primary"
|
@click="updateHandle()"
|
>确认</el-button>
|
</div>
|
</el-dialog>
|
<el-dialog
|
:visible.sync="dialogStockFormVisible"
|
:modal-append-to-body="false"
|
:close-on-click-modal="false"
|
width="600px"
|
>
|
<el-form
|
ref="dataForm"
|
:rules="dataFormRules"
|
:model="dataForm"
|
label-position="right"
|
label-width="100px"
|
style="margin-left:50px;width:500px;"
|
element-loading-text="保存中..."
|
>
|
<el-form-item
|
label="警告类型:"
|
prop="type"
|
>
|
{{dataForm.warntype}}
|
</el-form-item>
|
<el-form-item
|
label="企业类型:"
|
prop="type"
|
>
|
{{dataForm.enterprisetype}}
|
</el-form-item>
|
<el-form-item
|
label="预警值:"
|
prop="minimum"
|
>
|
<el-input v-model="dataForm.minimum" type="number"></el-input>
|
</el-form-item>
|
<el-form-item
|
label="报警值:"
|
prop="maximum"
|
>
|
<el-input v-model="dataForm.maximum" type="number"></el-input>
|
</el-form-item>
|
<el-form-item
|
label="报警短信通知:"
|
prop="issms"
|
>
|
<el-radio-group v-model="dataForm.issms">
|
<el-radio :label="1">是</el-radio>
|
<el-radio :label="0">否</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-form>
|
<div
|
slot="footer"
|
class="dialog-footer"
|
>
|
<el-button @click="dialogStockFormVisible = false">取消</el-button>
|
<el-button
|
type="primary"
|
@click="updateStockHandle()"
|
>确认</el-button>
|
</div>
|
</el-dialog>
|
<div style="clear: both;" />
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import { getWarningList, editWarningInfo } 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: 'warning',
|
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,
|
warningData: null,
|
listLoading: true,
|
queryForm: {
|
warntype: '',
|
enterprisetype:'',
|
},
|
enterpriseTypeList:[],
|
warnTypeList:[],
|
|
dataForm: {
|
id: '',
|
warntype: '',
|
period: '',
|
enterprisetype: '',
|
issms: '',
|
minimum: '',
|
maximum: '',
|
},
|
dialogFormVisible: false,
|
dialogStockFormVisible: false,
|
dataFormRules: {
|
minimum: [{ required: true, message: '预警值不能为空', trigger: 'blur' }],
|
maximum: [{ required: true, message: '报警值不能为空', trigger: 'blur' }],
|
},
|
|
|
}
|
},
|
created() {
|
this.getWarningList()
|
this.getDictionaryEnterpriseType()
|
this.getDictionaryWarnType()
|
},
|
methods: {
|
getWarningList() {
|
const _this = this
|
const params = {}
|
params['sort'] = _this.sort
|
params['order'] = _this.order
|
params['pageIndex'] = _this.currentPage
|
params['pageSize'] = _this.pageSize
|
for (const i in _this.queryForm) {
|
if (_this.queryForm[i] != undefined && _this.queryForm[i].toString() != '') {
|
params[i] = _this.queryForm[i]
|
}
|
}
|
_this.listLoading = true
|
getWarningList(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.warningData = result.result
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
_this.listLoading = false
|
}).catch(error => {
|
_this.listLoading = false
|
parseError({ error: error, vm: _this })
|
})
|
},
|
getDictionaryEnterpriseType() {
|
const _this = this
|
if (_this.enterpriseTypeList && _this.enterpriseTypeList.length > 0) {
|
return
|
}
|
const params = {}
|
params['dictionaryType'] = '安全监管分类'
|
dictionaryAllItems(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.enterpriseTypeList = res.result
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
},
|
getDictionaryWarnType() {
|
const _this = this
|
if (_this.warnTypeList && _this.warnTypeList.length > 0) {
|
return
|
}
|
const params1 = {}
|
params1['dictionaryType'] = '警告类型'
|
dictionaryAllItems(params1).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.warnTypeList = res.result
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
},
|
refreshHandle: function() {
|
this.getWarningList()
|
},
|
queryHandle: function() {
|
this.currentPage = 1
|
this.getWarningList()
|
},
|
sortWarningChange: function(param){
|
this.sort = param.prop;
|
this.order = param.order;
|
this.getWarningList()
|
},
|
handleSizeChange: function(val) {
|
this.pageSize = val
|
this.currentPage = 1
|
this.getWarningList()
|
},
|
handleCurrentChange: function(val) {
|
this.currentPage = val
|
this.getWarningList()
|
},
|
getBtnPermission(btnType) {
|
return checkBtnPermission(this.userType, btnType)
|
},
|
resetDataForm() {
|
this.dataForm = {
|
id: '',
|
warntype: '',
|
period: '',
|
enterprisetype: '',
|
issms: '',
|
minimum: '',
|
maximum: '',
|
}
|
},
|
showEditHandle: function(row) {
|
this.resetDataForm()
|
this.dataForm.id = row.id
|
this.dataForm.warntype = row.warntype
|
this.dataForm.period = row.period
|
this.dataForm.enterprisetype = row.enterprisetype
|
this.dataForm.issms = row.issms
|
this.dataForm.minimum = row.minimum
|
this.dataForm.maximum = row.maximum
|
if (this.dataForm.warntype == '购买超量'){
|
this.dialogFormVisible = true
|
this.$nextTick(() => {
|
this.$refs['dataForm'].clearValidate()
|
})
|
}else {
|
this.dialogStockFormVisible = true
|
}
|
},
|
updateHandle() {
|
this.$refs['dataForm'].validate((valid) => {
|
const _this = this
|
if (valid) {
|
editWarningInfo(_this.dataForm).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.dialogFormVisible = false
|
_this.$message({
|
message: '更新成功',
|
type: 'success'
|
})
|
_this.getWarningList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
}
|
})
|
},
|
updateStockHandle() {
|
this.$refs['dataForm'].validate((valid) => {
|
const _this = this
|
if (valid) {
|
editWarningInfo(_this.dataForm).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.dialogStockFormVisible = false
|
_this.$message({
|
message: '更新成功',
|
type: 'success'
|
})
|
_this.getWarningList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
}
|
})
|
},
|
|
}
|
}
|
</script>
|