<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"
|
v-if="powerControl.addControl"
|
@click="editDialog(1)">新增</el-button>
|
<el-button size="small"
|
v-if="powerControl.exportControl"
|
@click="exportFile">导出</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>
|
|
<!-- 新增项目 -->
|
<HouseholdBagProjectEdit :dialogVisible="dialogVisible"
|
:editType="editType"
|
:info="form"
|
:powerControl="powerControl"
|
:commissionDeveloperAll="commissionDeveloperAll"
|
:commissionPorjectAll="commissionPorjectAll"
|
@doAction="formDoAction" />
|
<!-- 编辑项目 -->
|
<!-- <HouseholdBagServiceConfig :data="form"
|
:powerControl="powerControl"
|
:dialogVisible="dialogEditVisible"
|
@doAction="onServiceConfig" /> -->
|
|
</div>
|
</template>
|
<script>
|
/**
|
* 返现佣金-项目管理查询页面
|
*/
|
|
import EditForm from './components/EditForm';
|
import TableList from './components/TableList';
|
import HouseholdBagProjectEdit from '@comprehensive/components/HouseholdBagProjectEdit';
|
import HouseholdBagServiceConfig from '@comprehensive/components/HouseholdBagServiceConfig';
|
|
import qryHouseholdBagProjectList from '@comprehensive/model/qryHouseholdBagProjectList';
|
import getApplyListAll from '@comprehensive/model/getApplyListAll';
|
// import queryCommissionPorjectAll from '@comprehensive/model/queryCommissionPorjectAll';
|
import {
|
getProvinceCodeList,
|
getCityCodeList,
|
getAreaCodeList,
|
exportHouseholdBagProjectList
|
} from '@comprehensive/serve/public';
|
import { alert } from '@comprehensive/utils/comm'
|
|
export default {
|
name: 'LoanApply',
|
components: {
|
TableList,
|
EditForm,
|
HouseholdBagProjectEdit,
|
HouseholdBagServiceConfig,
|
},
|
data() {
|
return {
|
editType: 1,
|
form: {},
|
dialogVisible: false,
|
dialogEditVisible: 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: '搜索' },
|
// { type: 'fold', text: '展开' },
|
],
|
uploadHeader: {
|
'Content-Type': 'multipart/form-data; boundary=ReaquestHeader',
|
},
|
commissionDeveloperAll: [],
|
commissionPorjectAll: [],
|
// 按钮权限控制
|
powerControl:{
|
addControl: false, // 新增
|
editDetail: false, // 修改
|
exportControl: false, // 导出
|
}
|
};
|
},
|
created() {
|
this.setPowerControl();
|
this.init();
|
this.getOptions();
|
},
|
methods: {
|
setPowerControl() {
|
let {powerControl} = this
|
if (process.env.NODE_ENV !== 'development') {
|
powerControl.addControl = this.window.top._server_addOrModifyHouseholdBagProject
|
powerControl.exportControl = this.window.top._server_exportHouseholdBagProjectList
|
} else {
|
powerControl.addControl = true
|
powerControl.exportControl = true
|
}
|
this.powerControl = powerControl
|
},
|
// 页面初始化处理
|
init() {
|
const { query } = this.$route;
|
this.query = query;
|
const listModel = qryHouseholdBagProjectList();
|
const formList = listModel.getFormList(query);
|
this.tableList = listModel.getTableList();
|
this.formRules = listModel.getFormRules();
|
this.formList = formList;
|
this.listModel = listModel;
|
|
this.fetch();
|
// this.queryCommissionPorjectAll();
|
this.getApplyListAll();
|
},
|
|
// 表单事件回调
|
doAction(name, item, { id, label }) {
|
if (name === 'lastAction') {
|
if (id == 1) {
|
// 编辑
|
this.editDialog(0, item);
|
}
|
}
|
},
|
// 还款方式
|
async getApplyListAll() {
|
const res = await getApplyListAll().request({});
|
const { list } = res;
|
this.updateValue('projectSerialNo', { options: list });
|
},
|
// 表单按钮操作
|
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.editType = 1;
|
this.dialogVisible = true;
|
} else {
|
// 编辑
|
this.editType = this.powerControl.addControl? 2 : 3;
|
this.dialogVisible = true;
|
this.form = record;
|
}
|
},
|
// 导出
|
async exportFile() {
|
const { pageInfo, formValues } = this
|
const res = await exportHouseholdBagProjectList({ ...pageInfo, ...formValues })
|
if(res.code == '00'){
|
alert('提交成功',res.msg,() => {})
|
}
|
},
|
formDoAction(type, data = {}) {
|
if (type === 'close') {
|
this.dialogVisible = false;
|
this.fetch();
|
}
|
if (type === 'succ') {
|
this.dialogVisible = false;
|
this.dialogEditVisible = true;
|
this.form = data;
|
this.fetch();
|
// this.init();
|
}
|
},
|
onServiceConfig(type, data = {}) {
|
if (type === 'close') {
|
this.dialogEditVisible = false;
|
this.fetch();
|
}
|
},
|
// 获取当前列表数据
|
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;
|
this.records = list.reduce((pre, curr) => {
|
let arr = [];
|
|
arr.push({ id: 1, label: powerControl.addControl? '编辑' : '查看', disabled: false });
|
|
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();
|
},
|
|
// 更新表单数据
|
updateValue(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 });
|
|
if (info.name === 'projectProvince') {
|
this.getArea('projectCity', info.value);
|
}
|
}
|
},
|
|
getOptions() {
|
const { projectProvince = '', projectCity = '', regions = '' } = this.formValues;
|
console.log('formValues:', this.formValues);
|
|
this.getArea('projectProvince', '', projectProvince === '');
|
if (projectProvince !== '') {
|
this.getArea('projectCity', projectProvince, projectCity === '');
|
}
|
if (projectProvince !== '' && projectCity !== '') {
|
this.getArea('regions', projectCity, regions === '');
|
}
|
},
|
|
updateOptions(name, list, labelKey, valueKey, isResetValue = true) {
|
const valueObj = isResetValue ? { value: '' } : {};
|
this.updateValue(name, {
|
options: list.map((item) => ({
|
label: item[labelKey],
|
value: item[valueKey],
|
})),
|
...valueObj,
|
});
|
},
|
|
async getArea(name, itmeNo, isResetValue = true) {
|
if (name === 'projectProvince') {
|
const { result } = await getProvinceCodeList();
|
this.updateOptions(name, result, 'itemname', 'itemno', isResetValue);
|
}
|
|
if (name === 'projectCity') {
|
const { result } = await getCityCodeList({
|
codeNo: 'AreaCode',
|
itmeNo,
|
});
|
this.updateOptions(name, result, 'itemname', 'itemno', isResetValue);
|
}
|
|
if (name === 'regions') {
|
const { result } = await getAreaCodeList({
|
codeNo: 'AreaCode',
|
itmeNo,
|
});
|
this.updateOptions(name, result, 'itemname', 'itemno', isResetValue);
|
}
|
},
|
// // 项目下拉列表
|
// async queryCommissionPorjectAll() {
|
// const res = await queryCommissionPorjectAll().request({});
|
// const { list } = res;
|
// this.commissionPorjectAll = list;
|
// this.updateValue('projectId', { options: list });
|
// },
|
},
|
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>
|