<template>
|
<basic-container>
|
<avue-crud :option="option"
|
:table-loading="loading"
|
:data="data"
|
:page.sync="page"
|
:permission="permissionList"
|
:before-open="beforeOpen"
|
v-model="form"
|
ref="crud"
|
@row-update="rowUpdate"
|
@row-save="rowSave"
|
@row-del="rowDel"
|
@search-change="searchChange"
|
@search-reset="searchReset"
|
@selection-change="selectionChange"
|
@current-change="currentChange"
|
@size-change="sizeChange"
|
@refresh-change="refreshChange"
|
@on-load="onLoad">
|
<!--按钮自定义-Begin-->
|
<template slot="menuLeft">
|
<el-button type="danger"
|
size="small"
|
icon="el-icon-delete"
|
plain
|
v-if="permission.application_delete"
|
@click="handleDelete">删 除
|
</el-button>
|
</template>
|
<template slot-scope="{type,size,row,index}" slot="menu">
|
<el-button icon="el-icon-edit" :size="size" :type="type" @click="$refs.crud.rowEdit(row,index)">编 辑</el-button>
|
<el-button icon="el-icon-tickets" :size="size" :type="type" @click="polishApplication(row.id)">补正</el-button>
|
<el-button v-if="permit" icon="el-icon-tickets" :size="size" :type="type">受 理</el-button>
|
<el-button v-if="permit" icon="el-icon-tickets" :size="size" :type="type" @click="rejectApplication(row)">不予受理</el-button>
|
<!-- <el-button icon="el-icon-delete" :size="size" :type="type">车辆变更</el-button>-->
|
<!-- <el-button icon="el-icon-delete" :size="size" :type="type">延 期</el-button>-->
|
<!-- <el-button icon="el-icon-delete" :size="size" :type="type">撤 销</el-button>-->
|
</template>
|
<!--按钮自定义-End-->
|
|
<!--cell自定义-Begin-->
|
<template slot-scope="{row}" slot="no">
|
<a href="#javascript" style="color: #337ab7" @click="$refs.crud.rowView(row)">{{row.no}}</a>
|
</template>
|
<template slot-scope="{row}" slot="enterpriseName">
|
<a href="#javascript" style="color: #337ab7" @click="getEnterpriseDetail(row.userId)">{{row.enterpriseName}}</a>
|
</template>
|
<!--cell自定义-End-->
|
</avue-crud>
|
|
<!--不予受理的表单-->
|
<reject v-if="rejectVisible" ref="reject" @refreshLoad="refreshLoad"></reject>
|
</basic-container>
|
</template>
|
|
<script>
|
import {getPage, getDetail, add, update, remove} from "@/api/application/application";
|
import {getDetailByUserId} from "@/api/enterprise/enterprise"
|
import option from "@/const/application/application";
|
import enterpriseOption from "@/const/enterprise/enterprise"
|
import {mapGetters} from "vuex";
|
import Reject from "@/views/application/reject";
|
|
export default {
|
components: {Reject},
|
data() {
|
return {
|
form: {},
|
basicInfoForm:{},
|
query: {},
|
loading: true,
|
page: {
|
pageSize: 10,
|
currentPage: 1,
|
total: 0
|
},
|
selectionList: [],
|
option: option,
|
data: [],
|
rejectVisible:false
|
};
|
},
|
computed: {
|
...mapGetters(["permission",'userInfo']),
|
permissionList() {
|
return {
|
addBtn: this.vaildData(this.permission.application_add, true),
|
viewBtn: this.vaildData(this.permission.application_view, true),
|
delBtn: this.vaildData(this.permission.application_delete, true),
|
editBtn: this.vaildData(this.permission.application_edit, true)
|
};
|
},
|
ids() {
|
let ids = [];
|
this.selectionList.forEach(ele => {
|
ids.push(ele.id);
|
});
|
return ids.join(",");
|
},
|
permit(){
|
return this.userInfo.role_name == 'admin' || this.userInfo.role_name == 'administrator' ? true:false
|
}
|
},
|
methods: {
|
rowSave(row, done, loading) {
|
row.userId = this.userInfo.user_id
|
add(row).then(() => {
|
this.onLoad(this.page);
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
done();
|
}, error => {
|
loading();
|
window.console.log(error);
|
});
|
},
|
rowUpdate(row, index, done, loading) {
|
update(row).then(() => {
|
this.onLoad(this.page);
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
done();
|
}, error => {
|
loading();
|
console.log(error);
|
});
|
},
|
rowDel(row) {
|
this.$confirm("确定将选择数据删除?", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
return remove(row.id);
|
})
|
.then(() => {
|
this.onLoad(this.page);
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
});
|
},
|
handleDelete() {
|
if (this.selectionList.length === 0) {
|
this.$message.warning("请选择至少一条数据");
|
return;
|
}
|
this.$confirm("确定将选择数据删除?", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
return remove(this.ids);
|
})
|
.then(() => {
|
this.onLoad(this.page);
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
this.$refs.crud.toggleSelection();
|
});
|
},
|
beforeOpen(done, type) {
|
if (["edit", "view"].includes(type)) {
|
getDetail(this.form.id).then(res => {
|
let data = res.data.data
|
this.form = data
|
this.init()
|
});
|
}
|
done();
|
},
|
searchReset() {
|
this.query = {};
|
this.onLoad(this.page);
|
},
|
searchChange(params, done) {
|
this.query = params;
|
this.page.currentPage = 1;
|
this.onLoad(this.page, params);
|
done();
|
},
|
selectionChange(list) {
|
this.selectionList = list;
|
},
|
selectionClear() {
|
this.selectionList = [];
|
this.$refs.crud.toggleSelection();
|
},
|
currentChange(currentPage){
|
this.page.currentPage = currentPage;
|
},
|
sizeChange(pageSize){
|
this.page.pageSize = pageSize;
|
},
|
refreshChange() {
|
this.onLoad(this.page, this.query);
|
},
|
onLoad(page, params = {}) {
|
this.loading = true;
|
if (this.userInfo.role_name != 'admin' && this.userInfo.role_name !="administrator"){
|
params.userId = this.userInfo.user_id
|
}
|
getPage(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
const data = res.data.data;
|
this.page.total = data.total;
|
this.data = data.records;
|
//转换数据类型
|
this.data.forEach(e=>{
|
e.status = e.status.toString()
|
})
|
this.loading = false;
|
this.selectionClear();
|
});
|
},
|
//给form表单中的字段赋值
|
init(){
|
let basic = this.form.basicInfoEntity
|
let basicId = basic.id
|
let plan = this.form.planEntity
|
let planId = plan.id
|
let scheme = this.form.schemeEntity
|
let schemeId = scheme.id
|
let car= this.form.carEntity
|
let catId = car.id
|
let goods = this.form.goodsEntity
|
let goodsId = goods.id
|
let form = this.form
|
//保留原form中的字段
|
let common = Object.assign({},form)
|
|
form = Object.assign(form,basic)
|
form = Object.assign(form,plan)
|
form = Object.assign(form,scheme)
|
form = Object.assign(form,car)
|
form = Object.assign(form,goods)
|
|
//覆盖回原form
|
form = Object.assign(form,common)
|
|
this.form.basicInfoEntity.id = basicId
|
this.form.planEntity.id = planId
|
this.form.schemeEntity.id = schemeId
|
this.form.carEntity.id =catId
|
this.form.goodsEntity.id = goodsId
|
},
|
//完善信息
|
polishApplication(id){
|
let that = this
|
getDetail(id).then(res => {
|
let data = res.data.data
|
this.form = data
|
this.init()
|
|
this.option.group.forEach(group=>{
|
group.column.forEach(item=>{
|
item.disabled = true
|
})
|
})
|
|
this.$DialogForm.show({
|
title: '完善信息',
|
width: '70%',
|
data:that.form,
|
option: this.option,
|
callback:(res)=>{
|
update(res.data).then(() => {
|
this.onLoad(this.page);
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
res.close()
|
})
|
this.option.group.forEach(group=>{
|
group.column.forEach(item=>{
|
item.disabled = false
|
})
|
})
|
}
|
})
|
});
|
},
|
//不予受理
|
rejectApplication(row){
|
this.rejectVisible = true
|
this.$nextTick(()=>{
|
this.$refs.reject.init(row)
|
})
|
},
|
//获取企业信息
|
getEnterpriseDetail(userId){
|
getDetailByUserId(userId).then(res=>{
|
if (res.data.code == 200){
|
let enterpriseDetail = res.data.data
|
|
enterpriseOption.detail = true
|
this.$DialogForm.show({
|
title: '完善信息',
|
width: '70%',
|
data:enterpriseDetail,
|
option: enterpriseOption,
|
callback:()=>{
|
enterpriseOption.detail = false
|
}
|
})
|
}
|
})
|
},
|
|
//刷新页面
|
refreshLoad(){
|
this.onLoad(this.page, this.query);
|
}
|
|
}
|
};
|
</script>
|
|
<style>
|
</style>
|