<template>
|
<div class="search-form">
|
|
<!-- 筛选条件 -->
|
<CommForm ref="form"
|
formType="search"
|
:inline="true"
|
:list="formList"
|
:formValues="formValues"
|
:formRules="formRules"
|
:buttons="formButtons"
|
:isShowAll="true"
|
@updateValue="updateValue"
|
@buttonAction="buttonAction"></CommForm>
|
<div class="middle-button">
|
<!-- <el-upload :show-file-list="false"
|
:http-request="uploadFile"
|
:on-change="uploadSucc"
|
class="file-uploader"
|
type="primary"
|
action="customize"
|
multiple>
|
<el-button size="mini"
|
class="upload-btn">上传</el-button>
|
</el-upload> -->
|
<el-button size="small"
|
type="primary"
|
icon="el-icon-download"
|
:loading="excelLoading"
|
@click="exportFile">导出</el-button>
|
</div>
|
|
<!-- 列表 -->
|
<CommTable v-bind="$attrs"
|
:pageInfo="pageInfo"
|
:total="total"
|
:loading="loading"
|
:list="records"
|
:header="tableHeader"
|
@handleCurrentChange="handleCurrentChange"
|
@handleSizeChange="handleSizeChange"></CommTable>
|
|
</div>
|
</template>
|
<script>
|
// 客户实还记录表
|
import XLSX from 'xlsx';
|
import dayjs from 'dayjs';
|
import CommForm from '@/components/CommForm';
|
import CommTable from '@/components/CommTable';
|
import queryCodeValueList from '@/controller/queryCodeValueList';
|
import aipOrConfig from '@/controller/reportByPaymentLog/aipOrConfig';
|
// 获取产品api
|
import qryProdList from '@/controller/qryProdList';
|
import queryFundunitSimpleList from '@/controller/queryFundunitSimpleList';
|
// 导出表头
|
export const AcctPaymentScheduleFields = {
|
申请编号: 'applySerialNo',
|
客户名称: 'customerName',
|
借据状态: 'loanStatus',
|
产品名称: 'productName',
|
贷款机构名称: 'fundUnitNo',
|
};
|
export default {
|
components: {
|
CommForm,
|
CommTable,
|
},
|
props: {
|
model: {
|
type: Object,
|
required: true,
|
},
|
// 初始值
|
initValue: {
|
type: Object,
|
default: () => ({}),
|
},
|
// 默认请求参数
|
fetchInfo: {
|
type: Object,
|
default: () => ({}),
|
},
|
transCode: {
|
type: String,
|
default: '',
|
},
|
|
codeNo: {
|
type: String,
|
default: '',
|
},
|
|
pageId: {
|
type: String,
|
default: '',
|
},
|
},
|
data() {
|
return {
|
loading: false,
|
isShowAll: false,
|
excelLoading: false,
|
tempRecord: {},
|
buttonProp: '',
|
tempInfo: {},
|
formList: [],
|
formRules: {},
|
tableHeader: [],
|
formButtons: [
|
{ text: '重置', type: 'default' },
|
{ text: '搜索' },
|
// { text: '展开', type: 'fold' },
|
],
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
},
|
total: 0,
|
records: [],
|
delRefundModel: null,
|
fileUploadModel: null,
|
};
|
},
|
created() {
|
this.init();
|
},
|
mounted() {},
|
methods: {
|
init() {
|
this.$route.meta.keepAlive = true;
|
const { model, initValue } = this;
|
this.formList = model.getFormList(initValue);
|
this.formRules = model.getFormRules();
|
this.tableHeader = model.getTableList();
|
this.fileUploadModel = aipOrConfig('file');
|
this.setSelectOptions();
|
this.getList();
|
},
|
// 设置表单下拉菜单
|
setSelectOptions() {
|
const { formList } = this;
|
formList.forEach(({ name }) => {
|
if (name === 'productId') {
|
this.qryProdList(name);
|
}
|
|
// 放款资金单元
|
if (name === 'fundUnitNo') {
|
this.queryFundunitSimpleList(name);
|
}
|
// 对客实还日期
|
if (name === 'actualPayDate') {
|
this.updateValue(name, { value: [dayjs().subtract(1, 'month').format('YYYY/MM/DD'), dayjs().format('YYYY/MM/DD')] });
|
}
|
});
|
},
|
|
// 获取列表
|
async getList(params = {}, fun, loading = true) {
|
loading && (this.loading = true);
|
let { pageInfo, formValues, model, fetchInfo } = this;
|
// 自动扣款挂起管理新增查询条件字段loanUpStatus
|
if (formValues.loanUpStatusArray) {
|
formValues.loanUpStatus = formValues.loanUpStatusArray;
|
}
|
const applySerialNoArray = formValues.applySerialNoArray.trim()
|
? formValues.applySerialNoArray.trim().split('\n')
|
: [];
|
const res = await model.request({
|
...fetchInfo,
|
...pageInfo,
|
...formValues,
|
...params,
|
applySerialNoArray,
|
});
|
loading && (this.loading = false);
|
let { list = [], total } = res;
|
if (typeof fun === 'function') {
|
fun(list);
|
} else {
|
this.records = list;
|
this.total = parseInt(total);
|
}
|
},
|
|
// 更新表单数据
|
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 });
|
}
|
},
|
|
// 获取select中options数据
|
async queryCodeValueList(name, info = {}) {
|
const tempModel = queryCodeValueList();
|
const { list } = await tempModel.request(info);
|
this.updateValue(name, { options: list });
|
},
|
|
// 产品名称下拉列表
|
async qryProdList(name) {
|
const tempModel = qryProdList();
|
const { list } = await tempModel.request({ productTypeNo: '' });
|
this.updateValue(name, { options: list });
|
},
|
|
// 资金单元下拉列表
|
async queryFundunitSimpleList(name) {
|
const tempModel = queryFundunitSimpleList();
|
const { list } = await tempModel.request({ productTypeNo: '' });
|
this.updateValue(name, { options: list });
|
},
|
|
async uploadFile(params) {
|
try {
|
let file = params.file;
|
const res = await this.fileUploadModel.request({
|
file,
|
});
|
this.$message.success('上传成功');
|
} catch (error) {}
|
},
|
uploadSucc() {
|
this.getList();
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val;
|
this.getList();
|
},
|
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val;
|
this.getList();
|
},
|
|
// 表单按钮事件处理
|
buttonAction(id) {
|
if (id === 0) {
|
this.resetForm();
|
}
|
if (id === 1) {
|
this.resetList();
|
}
|
if (id === 2) {
|
const { isShowAll } = this;
|
this.isShowAll = !isShowAll;
|
}
|
},
|
|
toShowSucc() {
|
this.getList();
|
},
|
|
resetList() {
|
this.pageInfo.currentPage = 1;
|
this.getList();
|
},
|
|
resetForm() {
|
const { model } = this;
|
this.formList = model.getFormList();
|
this.setSelectOptions();
|
this.getList();
|
},
|
// // 导出
|
// async exportFile() {
|
// this.excelLoading = true
|
// const { fileUploadModel, formValues, pageInfo } = this
|
// await fileUploadModel.request({ ...pageInfo, ...formValues })
|
// this.excelLoading = false;
|
// },
|
// 导出
|
async exportFile(params) {
|
this.excelLoading = true;
|
let url = '';
|
if (location.hostname.includes('10.10')) {
|
url = 'http://10.10.16.128/rlc-mal/paymentLog/downloadPaymentLogReport';
|
} else {
|
url =
|
process.env.VUE_APP_API_ORIGIN +
|
'/rlc-mal/paymentLog/downloadPaymentLogReport';
|
}
|
const { formValues, pageInfo } = this;
|
const applySerialNoArray = formValues.applySerialNoArray.trim()
|
? formValues.applySerialNoArray.trim().split('\n')
|
: [];
|
fetch(url, {
|
credentials: 'include', // 跨域请求中需要带有cookie
|
method: 'POST',
|
headers: new Headers({
|
'Content-Type': 'application/json',
|
}),
|
body: JSON.stringify({
|
...formValues,
|
...pageInfo,
|
applySerialNoArray,
|
}), // 自动修改请求头,formdata的默认请求头的格式是 multipart/form-data
|
}).then(async (res) => {
|
let newRes = res.clone();
|
const resText = await res.text();
|
// for (let [key, value] of res.headers) {
|
// console.log(`${key} : ${value}`);
|
// }
|
if (resText.indexOf('code') != -1) {
|
const t = JSON.parse(resText);
|
this.$message.warning(t.msg);
|
this.excelLoading = false;
|
throw `${t.msg}`;
|
} else {
|
newRes.blob().then((blob) => {
|
var link = document.createElement('a');
|
link.href = window.URL.createObjectURL(blob);
|
link.download = `客户实还记录表${dayjs().format(
|
'YYYYMMDDhhmmss'
|
)}.xlsx`;
|
link.click();
|
window.URL.revokeObjectURL(link.href);
|
});
|
this.$message({
|
message: '导出成功,请等待下载结果文件!',
|
type: 'success',
|
});
|
this.excelLoading = false;
|
}
|
});
|
},
|
},
|
computed: {
|
// 表单值信息
|
formValues() {
|
const { model, formList } = this;
|
return model.getFormValues(formList);
|
},
|
},
|
};
|
</script>
|
<style lang="postcss" scoped>
|
.upload-btn {
|
height: 32px;
|
padding: 9px 15px;
|
color: #fff;
|
border-color: #0081f0;
|
background-color: #0081f0;
|
}
|
</style>
|