<template>
|
<div>
|
<div class="search-form">
|
<EditForm
|
ref="form"
|
formType="search"
|
:inline="true"
|
:list="formList"
|
:buttons="buttons"
|
:isShowAll="isShowAll"
|
:formValues="formValues"
|
:formRules="formRules"
|
@buttonAction="buttonAction"
|
@updateValue="updateValue"
|
></EditForm>
|
</div>
|
|
<p class="export-excle">
|
<el-button
|
size="small"
|
type="primary"
|
icon="el-icon-download"
|
@click="download(1)"
|
>导出Excel</el-button
|
>
|
<el-button
|
size="small"
|
type="primary"
|
icon="el-icon-download"
|
@click="download(2)"
|
>导出业务确认单</el-button
|
>
|
<el-upload
|
action=""
|
class="upload-demo"
|
:show-file-list="false"
|
:headers="uploadHeader"
|
:http-request="handleUpload"
|
>
|
<el-button
|
icon="el-icon-upload2"
|
size="small"
|
type="primary"
|
:loading="uploading"
|
>佣金发放结果导入</el-button
|
>
|
</el-upload>
|
<el-upload
|
action=""
|
class="upload-demo"
|
:show-file-list="false"
|
:headers="uploadHeader"
|
:http-request="handleCommissionUpload"
|
>
|
<el-button
|
icon="el-icon-upload2"
|
size="small"
|
type="primary"
|
:loading="uploading1"
|
>手工单导入</el-button
|
>
|
</el-upload>
|
</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>
|
</div>
|
</template>
|
<script>
|
/**
|
* 返现佣金贷查询页面
|
*/
|
|
import EditForm from "./components/EditForm";
|
import TableList from "./components/TableList";
|
import qryCommissionApplyList from "@comprehensive/model/qryCommissionApplyList";
|
import getAllCityAreaList from "@comprehensive/model/getAllCityAreaList";
|
import { comfirm, alert } from "@comprehensive/utils/comm";
|
import { MessageBox } from "element-ui";
|
import {
|
cancelCommissionApply,
|
exportCommissionExcel,
|
exportCommissionBusAckExcel,
|
importCommissionExcel,
|
importCommissionApplyExcel
|
} from "@comprehensive/serve/public";
|
|
const queryFlag = "02";
|
|
export default {
|
name: "LoanApply",
|
components: {
|
TableList,
|
EditForm,
|
},
|
data() {
|
return {
|
// 是否显示详情页
|
isShowList: true,
|
formList: [],
|
tableList: [],
|
formRules: {},
|
listModel: null,
|
query: {},
|
records: [],
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
},
|
total: 0,
|
serialNo: "",
|
objectType: "",
|
customerID: "",
|
loading: false,
|
uploading: false,
|
uploading1: false,
|
// 是否显示所有表单项
|
isShowAll: false,
|
buttons: [
|
{ text: "重置", type: "" },
|
{ text: "搜索" },
|
{ type: "fold", text: "展开" },
|
],
|
uploadHeader: {
|
"Content-Type": "multipart/form-data; boundary=ReaquestHeader",
|
},
|
};
|
},
|
created() {
|
this.init();
|
},
|
methods: {
|
// 页面初始化处理
|
init() {
|
const { query } = this.$route;
|
this.query = query;
|
const listModel = qryCommissionApplyList();
|
const formList = listModel.getFormList(query);
|
this.tableList = listModel.getTableList();
|
this.formRules = listModel.getFormRules();
|
this.formList = formList;
|
this.listModel = listModel;
|
|
this.fetch();
|
this.getAllCityAreaList();
|
},
|
// 表单按钮操作
|
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;
|
}
|
},
|
|
// 表单事件回调
|
doAction(name, item, { label }) {
|
console.log(arguments);
|
console.log(name, item, { label });
|
if (name === "lastAction") {
|
const { objectType } = item;
|
const detailInfo = { ...item, objecttype: objectType };
|
|
if (label == "取消申请") {
|
this.onCancelCommissionApply(item.serialno);
|
}
|
if (label == "查看合同") {
|
const url = `${process.env.VUE_APP_API_ORIGIN}/rlc-cts/server/oss?bucket=${item.bucketname}&ossKey=${item.documentid}`;
|
var a = document.createElement("a");
|
a.setAttribute("href", url);
|
a.setAttribute("target", "_blank");
|
a.setAttribute("id", "openwin");
|
document.body.appendChild(a);
|
//if(!document.getElementById(id)) document.body.appendChild(a);
|
a.click();
|
document.getElementById("openwin").remove();
|
}
|
}
|
},
|
// 导出excle
|
async download(type) {
|
let { formValues } = this;
|
let res = null;
|
switch (type) {
|
case 1:
|
res = await exportCommissionExcel({ ...formValues });
|
break;
|
case 2:
|
res = await exportCommissionBusAckExcel({ ...formValues });
|
break;
|
}
|
if (res.code == "00") {
|
alert("提交成功", res.msg, () => {});
|
}
|
},
|
// 佣金发放结果导入
|
async handleUpload(file) {
|
console.log(file);
|
if (this.uploading) return;
|
if (file.file) {
|
try {
|
this.uploading = true;
|
const formData = new FormData();
|
formData.append("file", file.file);
|
const res = await importCommissionExcel(formData)
|
// importCommissionExcel(formData).then((res) => {
|
if (res.code === "00") {
|
this.uploading = true;
|
this.fetch();
|
this.$alert(res.msg, "导入结果", {
|
showConfirmButton: false,
|
dangerouslyUseHTMLString: true
|
});
|
}
|
this.uploading = false;
|
// });
|
} catch (error) {
|
this.uploading = false;
|
}
|
}
|
},
|
|
// 手工单导入
|
async handleCommissionUpload(file) {
|
console.log(file);
|
if (this.uploading1) return;
|
if (file.file) {
|
try {
|
this.uploading1 = true;
|
const formData = new FormData();
|
formData.append("file", file.file);
|
const res = await importCommissionApplyExcel(formData)
|
if (res.code === "00") {
|
this.uploading1 = true;
|
this.fetch();
|
this.$alert(res.msg, "导入结果", {
|
showConfirmButton: false,
|
dangerouslyUseHTMLString: true
|
});
|
}
|
this.uploading1 = false;
|
// });
|
} catch (error) {
|
this.uploading1 = false;
|
}
|
}
|
},
|
// 取消申请
|
async onCancelCommissionApply(serialno) {
|
this.$confirm(
|
"取消后,本条记录将会失效,且客户可从公众号重新申请,请确认!!!",
|
"取消申请",
|
{
|
confirmButtonText: "确定取消",
|
cancelButtonText: "暂不取消",
|
center: true,
|
}
|
)
|
.then(async () => {
|
const res = await cancelCommissionApply({
|
serialno: serialno,
|
});
|
if (res.code == "00") {
|
this.fetch();
|
}
|
})
|
.catch(() => {});
|
},
|
// 业务城市下拉列表
|
async getAllCityAreaList() {
|
const res = await getAllCityAreaList().request({ queryFlag });
|
const { list } = res;
|
this.updateValue("businesscity", { options: list });
|
},
|
// 更新表单数据
|
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 });
|
}
|
},
|
// 获取当前列表数据
|
async fetch() {
|
try {
|
this.loading = true;
|
let { pageInfo, listModel, formValues, query } = 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({ label: "取消申请", disabled: curr.status != 0 });
|
if (curr.documentid) {
|
arr.push({ label: "查看合同" });
|
}
|
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>
|