<template>
|
<div>
|
<div class="search-form">
|
<EditForm ref="form"
|
formType="search"
|
:inline="true"
|
:list="formList"
|
:buttons="buttons"
|
:isShowAll="isShowAll"
|
:formValues="formValues"
|
:formRules="formRules"
|
@updateValue="updateValue"
|
@buttonAction="buttonAction"></EditForm>
|
</div>
|
|
<p class="export-excle">
|
<el-button size="small"
|
type="primary"
|
icon="el-icon-download"
|
v-if="powerControl.addControl"
|
@click="editDialog(1)">新增</el-button>
|
</p>
|
|
<div class="list-content">
|
<TableList :isAutoIndex="true"
|
:isPaddingRight="false"
|
:loading="loading"
|
:list="records"
|
:header="tableList"
|
:total="total"
|
:pageInfo="pageInfo"
|
@doAction="doAction"
|
@handleCurrentChange="handleCurrentChange"
|
@handleSizeChange="handleSizeChange"></TableList>
|
</div>
|
|
|
<CommissionPorjectEdit :dialogVisible="dialogVisible" :info="form" @doAction="formDoAction" />
|
|
</div>
|
</template>
|
<script>
|
/**
|
* 返现开发商查询页面
|
*/
|
|
import EditForm from './components/EditForm';
|
import TableList from './components/TableList';
|
import CommissionPorjectEdit from '@comprehensive/components/CommissionPorjectEdit';
|
|
import queryCommissionPorject from '@comprehensive/model/queryCommissionPorject';
|
|
export default {
|
name: 'LoanApply',
|
components: {
|
TableList,
|
EditForm,
|
CommissionPorjectEdit
|
},
|
data() {
|
return {
|
title: '新增',
|
form: {},
|
dialogVisible: false,
|
// 是否显示详情页
|
isShowList: true,
|
formList: [],
|
tableList: [],
|
formRules: {},
|
listModel: null,
|
query: {},
|
records: [],
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
},
|
total: 0,
|
serialNo: '',
|
objectType: '',
|
customerID: '',
|
loading: false,
|
uploading: false,
|
// 是否显示所有表单项
|
isShowAll: false,
|
buttons: [{ text: '重置', type: '' }, { text: '搜索' }],
|
uploadHeader: {
|
'Content-Type': 'multipart/form-data; boundary=ReaquestHeader',
|
},
|
// 按钮权限控制
|
powerControl:{
|
addControl: false, // 新增
|
editDetail: false, // 编辑
|
}
|
};
|
},
|
created() {
|
this.setPowerControl();
|
this.init();
|
},
|
methods: {
|
setPowerControl() {
|
let {powerControl} = this
|
if (process.env.NODE_ENV !== 'development') {
|
powerControl.addControl = this.window.top._server_addCommissionPorject// 新增
|
powerControl.editDetail = this.window.top._server_modifyCommissionPorject// 编辑
|
} else {
|
powerControl.addControl = true // 新增
|
powerControl.editDetail = true // 编辑
|
}
|
this.powerControl = powerControl
|
},
|
// 页面初始化处理
|
init() {
|
const { query } = this.$route;
|
this.query = query;
|
const listModel = queryCommissionPorject();
|
const formList = listModel.getFormList(query);
|
this.tableList = listModel.getTableList();
|
this.formRules = listModel.getFormRules();
|
this.formList = formList;
|
this.listModel = listModel;
|
|
this.fetch();
|
},
|
|
// 表单事件回调
|
doAction(name, item, { id, label }) {
|
console.log(name, item, { id, label });
|
if (name === 'lastAction') {
|
console.log(id == 1)
|
if(id == 1) {
|
// 编辑
|
this.editDialog(0, item)
|
}
|
}
|
},
|
// 更新表单数据
|
updateValue(index, info) {
|
console.log(index, info);
|
const { formList } = this;
|
if (isNaN(index)) {
|
// index is name
|
index = formList.findIndex(({ name }) => name === index);
|
}
|
if (!isNaN(index) && index > -1) {
|
const preInfo = formList[index];
|
this.$set(formList, index, { ...preInfo, ...info });
|
}
|
},
|
// 表单按钮操作
|
buttonAction(index, button) {
|
let { listModel, isShowAll } = this;
|
if (index === 0) {
|
// 重置
|
// this.formList = listModel.getFormList()
|
this.init();
|
}
|
if (index === 1) {
|
// 搜索
|
this.pageInfo.currentPage = 1;
|
this.fetch();
|
}
|
if (index === 2) {
|
// 展开/收起
|
this.isShowAll = !isShowAll;
|
}
|
},
|
editDialog(type, record) {
|
if(type === 1) {
|
// 新增
|
this.form = {}
|
this.title = '新增'
|
this.dialogVisible = true
|
} else {
|
// 编辑
|
this.title = '编辑'
|
this.dialogVisible = true
|
this.form = record
|
}
|
},
|
formDoAction(type) {
|
console.log(type)
|
if(type === 'close') {
|
this.dialogVisible = false
|
}
|
if(type === 'succ') {
|
this.dialogVisible = false
|
this.init();
|
}
|
},
|
// 获取当前列表数据
|
async fetch() {
|
try {
|
this.loading = true;
|
let { pageInfo, listModel, formValues, query, powerControl } = this;
|
const { customerPhone, from } = query;
|
const res = await listModel.request({ ...pageInfo, ...formValues });
|
this.loading = false;
|
const { list, total } = res;
|
console.log('--', list)
|
this.records = list.reduce((pre, curr) => {
|
console.log(curr)
|
let arr = [];
|
if(powerControl.editDetail) {
|
arr.push({ id: 1,label: '编辑', disabled: false});
|
} else {
|
arr.push({ id: 0,label: '', disabled: true});
|
}
|
|
pre.push({
|
...curr,
|
buttons: [...arr],
|
});
|
|
return pre;
|
}, []);
|
this.total = total;
|
} catch (error) {
|
this.loading = false;
|
}
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val;
|
this.fetch();
|
},
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val;
|
this.fetch();
|
},
|
},
|
computed: {
|
// 表单值信息
|
formValues() {
|
const { listModel, formList } = this;
|
return listModel.getFormValues(formList);
|
},
|
},
|
// watch: {
|
// $route() {
|
// this.init()
|
// }
|
// }
|
};
|
</script>
|
<style lang="postcss" scoped>
|
.search-form {
|
padding-top: 16px;
|
}
|
.list-content {
|
font-size: 14px;
|
}
|
.export-excle {
|
margin: 0 0 20px 0;
|
}
|
.message {
|
font-size: 12px;
|
color: #666666;
|
padding: 10px 20px;
|
background-color: #fafafa;
|
}
|
.upload-demo {
|
display: inline-block;
|
margin-left: 10px;
|
}
|
</style>
|