<style scoped>
|
.title {
|
height: 60px;
|
line-height: 60px;
|
}
|
|
.bodys {
|
height: 100%;
|
}
|
|
.search {
|
background-color: #fff;
|
height: 80px;
|
display: flex;
|
align-items: center;
|
}
|
|
.search_thing {
|
width: 350px;
|
display: flex;
|
align-items: center;
|
}
|
|
.search_label {
|
width: 110px;
|
font-size: 14px;
|
text-align: right;
|
}
|
|
.search_input {
|
width: calc(100% - 110px);
|
}
|
|
.table {
|
margin-top: 10px;
|
background-color: #fff;
|
width: calc(100% - 40px);
|
height: calc(100% - 60px - 80px - 10px - 40px);
|
padding: 20px;
|
}
|
.table-item{
|
border-radius: 8px 8px 8px 8px;
|
box-shadow: 4px 4px 8px 0px rgba(51,51,51,0.04);
|
border: 1px solid #EEEEEE;
|
box-sizing: border-box;
|
padding: 14px 12px;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
}
|
</style>
|
|
<template>
|
<div class="capacity-scope">
|
<div>
|
<el-row class="title">
|
<el-col :span="12" style="text-align: left">
|
<el-radio-group v-model="radio" @input="selectorSwitch" size="medium" fill="#3A7BFA">
|
<el-radio-button label="0">资质明细</el-radio-button>
|
<el-radio-button label="1">资质总览</el-radio-button>
|
</el-radio-group>
|
</el-col>
|
<el-col :span="12" style="text-align: right;" v-if="radio==0">
|
<el-button size="medium" type="primary" @click="openAdd" v-if="addPower">资质更新</el-button>
|
<el-button size="medium" icon="el-icon-delete" @click="handleDel" v-if="delPower">删除</el-button>
|
</el-col>
|
</el-row>
|
</div>
|
<div v-if="radio==0" class="bodys">
|
<div class="search">
|
<div class="search_thing">
|
<div class="search_label">资质名称:</div>
|
<div class="search_input">
|
<el-select v-model="itemParameterData.entity.name" placeholder="选择资质名称" size="small" @change="refreshTable()">
|
<el-option v-for="item in qualificationsList" :key="item.value" :label="item.label" :value="item.value">
|
</el-option>
|
</el-select>
|
</div>
|
</div>
|
<div class="search_thing" style="padding-left: 30px;">
|
<el-button size="small" @click="refresh()">重 置</el-button>
|
<el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
|
</div>
|
</div>
|
<div class="table">
|
<ValueTable ref="itemParameterTable" :url="$api.certification.getCertificationDetail"
|
:componentData="itemParameterData" :delUrl="$api.certification.delCertificationDetail" :key="upIndex" />
|
</div>
|
</div>
|
<div class="bodys">
|
<div class="search" v-if="radio==1">
|
<div class="search_thing">
|
<div class="search_label">资质名称:</div>
|
<div class="search_input">
|
<el-select v-model="entity.name" placeholder="选择资质名称" size="small">
|
<el-option v-for="item in qualificationsList" :key="item.value" :label="item.label" :value="item.value">
|
</el-option>
|
</el-select>
|
</div>
|
</div>
|
<div class="search_thing" style="padding-left: 30px;">
|
<el-button size="small" @click="refresh()">重 置</el-button>
|
<el-button size="small" type="primary" @click="list=[],refreshTable()">查 询</el-button>
|
</div>
|
</div>
|
<div class="table" v-if="radio==1" v-loading="pageLoading" @scroll="scrollFn">
|
<el-row :gutter="16">
|
<el-col :span="6" v-for="(m,i) in list" :key="i" :xs="24" :sm="12" :md="8" :lg="6" :xl="6" style="margin-bottom: 16px;">
|
<div class="table-item">
|
<el-image style="width: 102px;height: 102px;margin-right: 20px;border-radius: 16px;" :src="javaApi+'/img/'+m.imageUrl">
|
<div slot="error" class="image-error" style="width: 100px;
|
height: 100px;
|
border-radius: 16px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
border: 1px solid #EEEEEE;">
|
<i class="el-icon-picture-outline" style="font-size:30px;color:#666666;"></i>
|
</div>
|
</el-image>
|
<div class="table-item-right" style="flex: 1;font-size: 12px;color: #666666;">
|
<p style="line-height: 26px;">资质名称:<span style="color: #3A7BFA;">{{ m.name }}</span></p>
|
<p style="line-height: 26px;">颁发时间:{{m.recentlyTime}}</p>
|
<p style="line-height: 26px;">到期时间:{{m.expireTime}}</p>
|
<p>
|
<span>状态:</span>
|
<el-tag :type="m.state==0?'danger':'success'" size="small">{{ m.state==0?'失效':'有效' }}</el-tag>
|
</p>
|
</div>
|
</div>
|
</el-col>
|
</el-row>
|
<div v-if="list.length<1&&!pageLoading&&!isLoding" style="color:#909399;font-size:14px;text-align: center;margin-top:200px" >暂无数据</div>
|
<div v-if="list.length>0">
|
<el-button
|
v-if="isLoding"
|
type="text"
|
style="display: flex; margin: 0 auto; color: #909399"
|
><i class="el-icon-loading" style="font-size:20px"></i
|
></el-button>
|
<el-button
|
type="text"
|
v-if="finishLoding"
|
style="display: flex; margin: 0 auto; color: #909399"
|
>已经没有更多啦~</el-button
|
>
|
</div>
|
</div>
|
</div>
|
<el-dialog title="资质更新" :visible.sync="qualificationsConnectVisible" width="400px">
|
<div class="search_thing" style="margin-bottom: 16px;">
|
<div class="search_label" style="width:120px"><span class="required-span">* </span>资质名称:</div>
|
<div class="search_input">
|
<el-select v-model="formData.name" placeholder="请选择" style="width: 100%;" size="small" clearable>
|
<el-option
|
v-for="item in qualificationsList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value">
|
</el-option>
|
</el-select>
|
</div>
|
</div>
|
<div class="search_thing" style="margin-bottom: 16px;">
|
<div class="search_label" style="width:120px"><span class="required-span">* </span>资质编码:</div>
|
<div class="search_input">
|
<el-input
|
size="small"
|
placeholder="请输入"
|
clearable
|
v-model="formData.code"></el-input>
|
</div>
|
</div>
|
<div class="search_thing" style="margin-bottom: 16px;">
|
<div class="search_label" style="width:120px"><span class="required-span">* </span>颁发机构:</div>
|
<div class="search_input">
|
<el-input
|
size="small"
|
placeholder="请输入"
|
clearable
|
v-model="formData.organization"></el-input>
|
</div>
|
</div>
|
<div class="search_thing" style="margin-bottom: 16px;">
|
<div class="search_label" style="width:120px">资质说明:</div>
|
<div class="search_input">
|
<el-input
|
size="small"
|
placeholder="请输入"
|
clearable
|
v-model="formData.explanation"></el-input>
|
</div>
|
</div>
|
|
|
<div class="search_thing" style="margin-bottom: 16px;">
|
<div class="search_label" style="width:120px"><span class="required-span">* </span>颁发时间:</div>
|
<div class="search_input">
|
<el-date-picker style="width:100%" v-model="formData.dateOfIssuance"
|
type="datetime"
|
size="small"
|
format="yyyy-MM-dd HH:mm:ss"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
clearable
|
placeholder="选择日期">
|
</el-date-picker>
|
</div>
|
</div>
|
<div class="search_thing" style="margin-bottom: 16px;">
|
<div class="search_label" style="width:120px"><span class="required-span">* </span>到期时间:</div>
|
<div class="search_input">
|
<el-date-picker style="width:100%" v-model="formData.expireTime"
|
type="datetime"
|
size="small"
|
format="yyyy-MM-dd HH:mm:ss"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
clearable
|
placeholder="选择日期">
|
</el-date-picker>
|
</div>
|
</div>
|
<div class="search_thing" style="margin-bottom: 16px;">
|
<div class="search_label" style="width:120px">资质图片:</div>
|
<div class="search_input">
|
<el-upload
|
ref="upload"
|
:action="action"
|
:on-success="m=>handleSuccessUpImg(m,'imageUrl')"
|
accept='image/jpg,image/jpeg,image/png'
|
:multiple="false"
|
:limit="1"
|
:headers="headers" :on-change="beforeUpload"
|
:on-error="onError">
|
<el-button slot="trigger" size="small" type="primary">选取图片</el-button>
|
</el-upload>
|
</div>
|
</div>
|
<div class="search_thing" style="margin-bottom: 16px;">
|
<div class="search_label" style="width:120px">资质附件:</div>
|
<div class="search_input">
|
<el-upload
|
ref="upload1"
|
:action="action"
|
:on-success="m=>handleSuccessUpImg(m,'fileUrl')"
|
accept='image/jpg,image/jpeg,image/png,application/pdf,.doc,.docx' :headers="headers" :multiple="false" :limit="1" :on-change="beforeUpload1"
|
:on-error="onError1">
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
</el-upload>
|
</div>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="qualificationsConnectVisible = false">取 消</el-button>
|
<el-button type="primary" @click="confirmQualifications" :loading="loading">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import ValueTable from '../tool/value-table.vue'
|
export default {
|
components: {
|
ValueTable
|
},
|
data() {
|
return {
|
radio: '0',
|
itemParameterData: {
|
entity: {
|
name: null,
|
// orderBy: {
|
// field: 'id',
|
// order: 'asc'
|
// }
|
},
|
isIndex: false,
|
showSelect: true,
|
select: true,
|
row: 2,
|
do: [{
|
id: '',
|
font: '附件下载',
|
type: 'text',
|
method: 'handleDownLoad',
|
field: []
|
}],
|
tagField: {
|
state: {
|
select: [
|
{
|
value: 0,
|
label: '失效',
|
type: 'danger'
|
},{
|
value: 1,
|
label: '有效',
|
type: 'success'
|
}
|
]
|
},
|
},
|
selectField: {
|
inspectionItemType: {
|
select: []
|
},
|
},
|
requiredAdd: [],
|
requiredUp: [],
|
needSort: ['firstIssuanceDate', 'latestIssuanceDate', 'expireTime', 'name'],
|
},
|
itemParameterEntityCopy: {},
|
upIndex: 0,
|
addPower: true,
|
delPower:true,
|
select: 0,
|
qualificationsList:[],
|
qualificationsConnectVisible:false,
|
formData:{},
|
loading:false,
|
pageLoading:false,
|
isLoding: false, // 加载中,loading图标,默认为true
|
finishLoding: false, // 加载完成,显示已经没有更多了
|
entity:{
|
name: null,
|
// orderBy: {field: "id", order: "asc"}
|
},
|
currentPage: 1, // 当前页
|
pageSize: 16, // 一页16条
|
total: '',
|
list:[],
|
}
|
},
|
computed: {
|
headers() {
|
return {
|
'token': sessionStorage.getItem('token')
|
}
|
},
|
action() {
|
return this.javaApi + this.$api.deviceScope.uploadFile
|
}
|
},
|
mounted() {
|
this.itemParameterEntityCopy = this.HaveJson(this.itemParameterData.entity)
|
this.selectEnumByCategory()
|
this.getPower('0')
|
},
|
methods: {
|
selectorSwitch(radio) {
|
if(radio === '1'){
|
this.list = [];
|
this.refreshTable();
|
}
|
},
|
refreshTable(e) {
|
if (this.radio === '0') {
|
this.$refs['itemParameterTable'].selectList(e)
|
} else {
|
if(this.currentPage>1){
|
this.isLoding = true
|
}else{
|
this.pageLoading = true
|
}
|
if(this.list.length==0){
|
window.addEventListener("scroll", this.throttle(this.scrollFn, 20000));
|
}
|
this.$axios.post(this.$api.certification.getCertificationDetail,{
|
page: {
|
current: this.currentPage,
|
size: this.pageSize
|
},
|
entity: this.entity
|
}, {
|
headers: {
|
'Content-Type': 'application/json'
|
}
|
}).then(res => {
|
if(res.code==200){
|
this.total = res.data.body.total
|
let list = res.data.body.records;
|
if(list.length==0){
|
this.finishLoding = true;
|
}else{
|
if(list.length<this.pageSize){
|
this.finishLoding = true;
|
}
|
this.list = this.list.concat(list)
|
if(this.total==this.list.length){
|
this.finishLoding = true;
|
}
|
}
|
}
|
this.pageLoading = false
|
this.isLoding = false;
|
})
|
}
|
},
|
refresh() {
|
if(this.radio === '0'){
|
this.itemParameterData.entity = this.HaveJson(this.itemParameterEntityCopy)
|
this.upIndex++
|
}else{
|
this.finishLoding = false;
|
this.currentPage= 1;
|
this.list=[];
|
this.entity={
|
name: null,
|
// orderBy: {field: "id", order: "asc"}
|
};
|
this.refreshTable()
|
}
|
},
|
openAdd() {
|
// this.$refs.itemParameterTable.openAddDia(this.$api.certification.addCertificationDetail);
|
this.qualificationsConnectVisible = true;
|
this.$nextTick(()=>{
|
this.$refs.upload.clearFiles()
|
this.$refs.upload1.clearFiles()
|
})
|
this.formData = {};
|
},
|
selectEnumByCategory() {
|
this.$axios.post(this.$api.enums.selectEnumByCategory, {
|
category: "资质名称"
|
}).then(res => {
|
// this.itemParameterData.selectField.inspectionItemType.select = res.data
|
this.qualificationsList = res.data
|
})
|
},
|
handleDel(){
|
this.$refs.itemParameterTable.batchDelete();
|
},
|
handleDownLoad(row){
|
let url = row.fileUrl;
|
const link = document.createElement('a');
|
link.href = this.javaApi + '/img/'+ url;
|
document.body.appendChild(link);
|
link.target = '_blank';
|
link.click();
|
},
|
handleSuccessUpImg(response,name) {
|
if (response.code == 200) {
|
this.formData[name] = response.data.url;
|
}
|
},
|
beforeUpload(file) {
|
if (file.size > 1024 * 1024 * 10) {
|
this.$message.error('上传文件不超过10M');
|
this.$refs.upload.clearFiles()
|
return false;
|
} else {
|
return true;
|
}
|
},
|
onError(err, file, fileList) {
|
this.$message.error('上传失败')
|
this.$refs.upload.clearFiles()
|
},
|
beforeUpload1(file) {
|
if (file.size > 1024 * 1024 * 10) {
|
this.$message.error('上传文件不超过10M');
|
this.$refs.upload1.clearFiles()
|
return false;
|
} else {
|
return true;
|
}
|
},
|
onError1(err, file, fileList) {
|
this.$message.error('上传失败')
|
this.$refs.upload1.clearFiles()
|
},
|
confirmQualifications(){
|
if(!this.formData.name){
|
this.$message.error('未填写资质名称');
|
return
|
}
|
if(!this.formData.code){
|
this.$message.error('未填写资质编码');
|
return
|
}
|
if(!this.formData.organization){
|
this.$message.error('未填写颁发机构');
|
return
|
}
|
if(!this.formData.expireTime){
|
this.$message.error('未填写到期颁发时间');
|
return
|
}
|
if(!this.formData.imageUrl){
|
this.$message.error('未上传资质图片');
|
return
|
}
|
if(!this.formData.fileUrl){
|
this.$message.error('未上传资质附件');
|
return
|
}
|
this.loading = true;
|
this.$axios.post(this.$api.certification.addCertificationDetail, {
|
...this.formData
|
}, {
|
headers: {
|
'Content-Type': 'application/json'
|
}
|
}).then(res => {
|
this.loading = false
|
if (res.code == 201) return
|
this.$message.success('已提交')
|
this.refreshTable('page')
|
this.qualificationsConnectVisible = false
|
})
|
},
|
// 权限分配
|
getPower(radio) {
|
let power = JSON.parse(sessionStorage.getItem('power'))
|
let add = false
|
let del = false
|
for (var i = 0; i < power.length; i++) {
|
if (power[i].menuMethod == 'delCertificationDetail') {
|
del = true
|
}
|
if (power[i].menuMethod == 'addCertificationDetail') {
|
add = true
|
}
|
}
|
this.addPower = add
|
this.delPower = del
|
},
|
// 滚动触底加载
|
scrollFn() {
|
let clientHeight = document.documentElement.clientHeight - 18; //可视区域
|
let scrollHeight = document.body.scrollHeight; // 滚动文档高度
|
let scrollTop = parseInt(document.documentElement.scrollTop); // 已滚动的高度
|
let height = 300;
|
if (
|
scrollTop + clientHeight >= scrollHeight - height &&
|
scrollHeight != 0
|
) {
|
if (!this.finishLoding&&this.currentPage*this.pageSize<this.total) {
|
this.currentPage = this.currentPage + 1;
|
this.refreshTable();
|
}
|
} else {
|
return false;
|
}
|
},
|
throttle(fn, wait) {
|
// 封装函数进行节流
|
var timer = null;
|
return function () {
|
var context = this;
|
var args = arguments;
|
if (!timer) {
|
timer = setTimeout(function () {
|
fn.apply(context, args);
|
timer = null;
|
}, wait);
|
}
|
};
|
},
|
},
|
destroyed() {
|
window.removeEventListener("scroll", this.throttle(), false);
|
},
|
}
|
</script>
|