<template>
|
<div class="app-container">
|
|
<div style="margin-bottom: 20px">
|
<el-button
|
class="filter-item"
|
style="margin-left: 10px;"
|
type="primary"
|
icon="el-icon-refresh"
|
@click="refreshHandle"
|
>刷新</el-button>
|
<el-button
|
v-if="getBtnPermission('add')"
|
class="filter-item"
|
style="margin-left: 10px;"
|
type="primary"
|
icon="el-icon-plus"
|
@click="showCreateHandle"
|
>新增</el-button>
|
<el-button
|
v-if="getBtnPermission('import')"
|
class="filter-item"
|
style="margin-left: 10px;"
|
type="primary"
|
icon="el-icon-upload2"
|
@click="showImportHandle"
|
>导入</el-button>
|
<el-button
|
v-if="getBtnPermission('delete')"
|
class="filter-item"
|
style="margin-left: 10px;"
|
type="primary"
|
icon="el-icon-minus"
|
@click="bashDeleteHandle"
|
>批量删除</el-button>
|
<el-select v-model="queryForm.type" clearable placeholder="请选择检查类型">
|
<el-option
|
class="filter-item"
|
@keyup.enter.native="queryHandle"
|
v-for="item in checkTypeList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value">
|
</el-option>
|
</el-select>
|
<el-input
|
v-model="queryForm.content"
|
class="filter-item"
|
placeholder="输入检查内容"
|
style="width: 400px;"
|
clearable
|
@keyup.enter.native="queryHandle"
|
/>
|
<el-button
|
class="filter-item"
|
type="primary"
|
icon="el-icon-search"
|
@click="queryHandle"
|
/>
|
</div>
|
<div class="table_content">
|
<el-table
|
v-loading="listLoading"
|
ref="selfCheckTable"
|
:key="tableKey"
|
:data="selfCheckData"
|
border
|
fit
|
highlight-current-row
|
style="width: 100%;"
|
@sort-change="sortSelfCheckChange"
|
>
|
<el-table-column
|
type="selection"
|
align="center"
|
width="80"
|
/>
|
<el-table-column
|
label="检查类型"
|
prop="type"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.type }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="检查内容"
|
prop="content"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.content }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="参考判断"
|
prop="standard"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.standard }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="排序"
|
prop="sort"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.sort }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="备注"
|
prop="description"
|
align="center"
|
sortable="custom"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.description }}</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>
|
<el-button
|
v-if="getBtnPermission('delete')"
|
type="text"
|
style="color:red;"
|
@click="deleteHandle(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
|
:title="dialogStatus==='create'?'新增':'编辑'"
|
:visible.sync="dialogFormVisible"
|
:modal-append-to-body="false"
|
:close-on-click-modal="false"
|
width="700px"
|
>
|
<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"
|
>
|
<el-select
|
v-model.trim="dataForm.type"
|
placeholder="请选择检查类型"
|
style="width:100%;"
|
>
|
<el-option
|
v-for="(item,index) in checkTypeList"
|
:label="item.text"
|
:value="item.text"
|
:key="index"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item
|
label="检查内容:"
|
prop="content"
|
>
|
<el-input
|
:autosize="{ minRows: 2, maxRows: 4}"
|
v-model.trim="dataForm.content"
|
type="textarea"
|
/>
|
</el-form-item>
|
<el-form-item
|
label="参考判断:"
|
prop="standard"
|
>
|
<el-radio-group v-model="dataForm.standard">
|
<el-radio label="Y">Y</el-radio>
|
<el-radio label="N">N</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item
|
label="排序值"
|
prop="sort"
|
>
|
<el-input-number
|
v-model.number="dataForm.sort"
|
:min="0"
|
:max="100"
|
/>
|
</el-form-item>
|
<el-form-item
|
label="备注:"
|
prop="description"
|
>
|
<el-input
|
:autosize="{ minRows: 2, maxRows: 4}"
|
v-model.trim="dataForm.description"
|
type="textarea"
|
/>
|
</el-form-item>
|
</el-form>
|
<div
|
slot="footer"
|
class="dialog-footer"
|
>
|
<el-button @click="dialogFormVisible = false">取消</el-button>
|
<el-button
|
type="primary"
|
@click="dialogStatus==='create'?createHandle():updateHandle()"
|
>确认</el-button>
|
</div>
|
</el-dialog>
|
<el-dialog
|
:visible.sync="importDialogFormVisible"
|
:modal-append-to-body="false"
|
:close-on-click-modal="false"
|
title="自定义检查内容导入"
|
width="700px"
|
>
|
<el-form
|
ref="importForm"
|
label-position="right"
|
label-width="120px"
|
style="margin-left:50px;width:500px;"
|
element-loading-text="导入中..."
|
>
|
<el-form-item label="导入文件:">
|
<input ref="importLabInput" type="file" accept=".xls, .xlsx" >
|
</el-form-item>
|
<el-form-item label="excel参考模板:">
|
<el-button type="text" @click="viewHandle">下载模板</el-button>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="importDialogFormVisible = false">取消</el-button>
|
<el-button :disabled="importDisabled" type="primary" @click="importHandle()">导入</el-button>
|
</div>
|
</el-dialog>
|
<div style="clear: both;" />
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import { selfCheckList, createSelfCheck, deleteSelfCheck, updateSelfCheck, bashDeleteSelfCheck, importSelfCheck } from '@/api/patrol'
|
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'
|
const exampleFile = require('@/assets/example/selfcheck.xlsx')
|
|
export default {
|
name: 'selfcheck',
|
filters: {
|
},
|
computed: {
|
...mapGetters([
|
'userType'
|
])
|
},
|
data() {
|
return {
|
sort:'createddate',
|
order:'desc',
|
pageSize: 10,
|
recordTotal: 0,
|
currentPage: 1,
|
pageTotal: 0,
|
tableKey: 0,
|
selfCheckData: null,
|
listLoading: true,
|
dataForm: {
|
id: '',
|
type: '',
|
content: '',
|
standard: '',
|
description: '',
|
sort: ''
|
},
|
queryForm: {
|
type: '',
|
content:'',
|
},
|
checkTypeList:[],
|
dialogFormVisible: false,
|
dialogStatus: '',
|
dataFormRules: {
|
type: [{ required: true, message: '检查类型不能为空', trigger: 'blur' }],
|
content: [{ required: true, message: '检查内容不能为空', trigger: 'blur' }],
|
standard: [{ required: true, message: '参考判断不能为空', trigger: 'blur' }],
|
sort: [{ required: true, message: '序号不能为空', trigger: 'blur' }]
|
},
|
|
importDisabled : false,
|
importDialogFormVisible : false,
|
|
}
|
},
|
created() {
|
this.getSelfCheckList()
|
this.getDictionaryCheckType()
|
},
|
methods: {
|
getSelfCheckList() {
|
const _this = this
|
const params = {}
|
params['sort'] = _this.sort
|
params['order'] = _this.order
|
params['pageIndex'] = _this.currentPage
|
params['pageSize'] = _this.pageSize
|
params['type'] = _this.queryForm.type
|
params['content'] = _this.queryForm.content
|
_this.listLoading = true
|
selfCheckList(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.selfCheckData = result.result
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
_this.listLoading = false
|
}).catch(error => {
|
_this.listLoading = false
|
parseError({ error: error, vm: _this })
|
})
|
},
|
getDictionaryCheckType() {
|
const _this = this
|
if (_this.checkTypeList && _this.checkTypeList.length > 0) {
|
return
|
}
|
const params = {}
|
params['dictionaryType'] = '安全监管分类'
|
dictionaryAllItems(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.checkTypeList = res.result
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
},
|
createHandle: function() {
|
const _this = this
|
this.$refs['dataForm'].validate((valid) => {
|
if (valid) {
|
createSelfCheck(_this.dataForm).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.dialogFormVisible = false
|
_this.$message({
|
message: '创建成功',
|
type: 'success'
|
})
|
_this.getSelfCheckList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
}
|
})
|
},
|
bashDeleteHandle() {
|
const selections = this.$refs.selfCheckTable.selection
|
if (selections.length == 0) {
|
parseError({ error: '请选中需要删除的信息', vm: this })
|
return
|
}
|
MessageBox.confirm('确定删除选中的信息', '确定删除', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
this.bashDeleteSelfCheckAction(selections)
|
}).catch((error) => {
|
console.log(error, '已取消删除')
|
})
|
},
|
bashDeleteSelfCheckAction: function(rows) {
|
const _this = this
|
const params = {}
|
const ids = []
|
for (const row of rows) {
|
ids.push(row.id)
|
}
|
params['ids'] = ids
|
bashDeleteSelfCheck(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.$message({
|
message: '删除成功',
|
type: 'success'
|
})
|
_this.getSelfCheckList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
},
|
deleteHandle: function(row) {
|
const _this = this
|
MessageBox.confirm('确定删除' + row.name + '信息', '确定删除', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
_this.deleteAction(row)
|
}).catch(() => {
|
console.log('已取消删除')
|
})
|
},
|
deleteAction: function(row) {
|
const _this = this
|
const params = {}
|
params['id'] = row.id
|
deleteSelfCheck(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.$message({
|
message: '删除成功',
|
type: 'success'
|
})
|
_this.getSelfCheckList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
},
|
refreshHandle: function() {
|
this.getSelfCheckList()
|
},
|
queryHandle: function() {
|
this.currentPage = 1
|
this.getSelfCheckList()
|
},
|
resetDataForm() {
|
this.dataForm = {
|
id: '',
|
type: '',
|
content: '',
|
standard: '',
|
description: '',
|
sort: ''
|
}
|
},
|
|
sortSelfCheckChange: function(param){
|
this.sort = param.prop;
|
this.order = param.order;
|
this.getSelfCheckList()
|
},
|
showCreateHandle() {
|
this.resetDataForm()
|
this.dialogStatus = 'create'
|
this.dialogFormVisible = true
|
this.$nextTick(() => {
|
this.$refs['dataForm'].clearValidate()
|
})
|
},
|
updateHandle() {
|
this.$refs['dataForm'].validate((valid) => {
|
const _this = this
|
if (valid) {
|
updateSelfCheck(_this.dataForm).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.dialogFormVisible = false
|
_this.$message({
|
message: '更新成功',
|
type: 'success'
|
})
|
_this.getSelfCheckList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
}
|
})
|
},
|
showEditHandle: function(row) {
|
this.resetDataForm()
|
this.dialogStatus = 'editor'
|
this.dataForm.type = row.type
|
this.dataForm.id = row.id
|
this.dataForm.content = row.content
|
this.dataForm.description = row.description
|
this.dataForm.standard = row.standard
|
this.dataForm.sort = row.sort
|
this.dialogFormVisible = true
|
this.$nextTick(() => {
|
this.$refs['dataForm'].clearValidate()
|
})
|
},
|
handleSizeChange: function(val) {
|
this.pageSize = val
|
this.currentPage = 1
|
this.getSelfCheckList()
|
},
|
handleCurrentChange: function(val) {
|
this.currentPage = val
|
this.getSelfCheckList()
|
},
|
getBtnPermission(btnType) {
|
return checkBtnPermission(this.userType, btnType)
|
},
|
showImportHandle() {
|
this.importDisabled = false
|
this.importDialogFormVisible = true
|
},
|
viewHandle() {
|
window.open(exampleFile, '_blank')
|
},
|
importHandle() {
|
const _this = this
|
const formData = new FormData()
|
const files = this.$refs['importLabInput'].files
|
if (files && files.length > 0) {
|
formData.append('file', files[0])
|
}
|
importSelfCheck(formData)
|
.then((response) => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.importDialogFormVisible = false
|
_this.$message({
|
message: '导入成功',
|
type: 'success'
|
})
|
_this.getSelfCheckList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
})
|
.catch((error) => {
|
parseError({ error: error, vm: _this })
|
})
|
},
|
}
|
}
|
</script>
|