<template>
|
<div class="search-form">
|
<CommForm
|
:inline="true"
|
:list="formList"
|
@updateValue="updateValue"
|
@buttonAction="buttonAction"
|
ref="form"
|
title="利息开票关联信息"
|
:formValues="formValues"
|
:formRules="formRules"
|
:buttons="formButtons"
|
:isShowAll="isShowAll"
|
></CommForm>
|
<div class="middle-button" v-if="isShowAdd">
|
<el-button
|
type="primary"
|
icon="el-icon-circle-plus-outline"
|
@click="addInfo"
|
size="small"
|
>新增关联信息</el-button
|
>
|
</div>
|
<CommTable
|
:pageInfo="pageInfo"
|
:total="total"
|
@doAction="doAction"
|
@handleCurrentChange="handleCurrentChange"
|
@handleSizeChange="handleSizeChange"
|
:loading="loading"
|
:list="records"
|
:header="tableHeader"
|
v-bind="$attrs"
|
></CommTable>
|
|
<el-dialog
|
:visible.sync="dialogTableVisible"
|
custom-class="comm-dialog"
|
:modal-append-to-body="false"
|
width="940px"
|
>
|
<RelativeInterestInvoiceInfo
|
@doAction="doInvoiceAction"
|
:isShow="dialogTableVisible"
|
></RelativeInterestInvoiceInfo>
|
</el-dialog>
|
|
<Dialog
|
v-model="isShowDelete"
|
title="删除确认"
|
:buttons="[{ text: '取消' }, { text: '确定', type: 'primary' }]"
|
@handleClick="clickDelete"
|
:contentText="`请确认是否需要删除${tempRecord.applySerialno} ?`"
|
></Dialog>
|
|
<Dialog
|
v-model="isShowSucc"
|
icon="succ"
|
iconText="提交成功"
|
:close="false"
|
:buttons="[{ text: '确定', type: 'primary' }]"
|
@handleClick="sureSucc"
|
></Dialog>
|
</div>
|
</template>
|
<script>
|
// 开票关联信息
|
import { mapMutations, mapState, mapActions } from "vuex";
|
import CommForm from "@/components/CommForm";
|
import CommTable from "@/components/CommTable";
|
import Dialog from "@/components/Dialog";
|
import RelativeInterestInvoiceInfo from "@/components/RelativeInterestInvoiceInfo"; //新增利息开票关联弹窗
|
import queryRelativeInvoiceInfo from "@/controller/queryRelativeInvoiceInfo"; //利息开票关联信息
|
import queryRelativeDiscountInvoiceInfo from "@/controller/queryRelativeDiscountInvoiceInfo";
|
import addRelativeDiscountInvoice from "@/controller/addRelativeDiscountInvoice";
|
import delRelativeDiscountInvoice from "@/controller/delRelativeDiscountInvoice";
|
import queryProjectList from "@/controller/queryProjectList";
|
import queryCodeValueList from "@/controller/queryCodeValueList";
|
import qryProdList from "@/controller/qryProdList";
|
import submitDiscountInvoice from "@/controller/submitDiscountInvoice";
|
|
const recordButtons = [
|
// {
|
// text: '查看贴息方案',
|
// prop: 'selectDiscountProgramButton'
|
// },
|
{
|
text: "删除",
|
prop: "delButton",
|
},
|
];
|
|
export default {
|
components: {
|
CommForm,
|
CommTable,
|
RelativeInterestInvoiceInfo,
|
Dialog,
|
},
|
props: {
|
conf: {
|
type: Object,
|
default: () => ({}),
|
},
|
},
|
data() {
|
return {
|
loading: false,
|
isShowAll: false,
|
dialogTableVisible: false,
|
isShowSucc: false,
|
isShowDelete: false,
|
projectId: "",
|
query: {},
|
trxnBr: "",
|
formList: [],
|
formRules: {},
|
tableHeader: [],
|
formButtons: [
|
{ text: "重置", type: "default" },
|
{ text: "搜索" },
|
{ text: "展开", type: "fold" },
|
],
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
},
|
total: 0,
|
records: [],
|
detailModel: null,
|
addModel: null,
|
delModel: null,
|
submitDiscountInvoiceModel: null,
|
detailInfo: {},
|
tempRecord: {},
|
};
|
},
|
created() {
|
this.init();
|
},
|
methods: {
|
init() {
|
const { query } = this.$route;
|
const { invoiceSerialno, transCode, pageId } = query;
|
this.query = query;
|
this.invoiceSerialno = invoiceSerialno;
|
// const model = queryRelativeDiscountInvoiceInfo()
|
const model = queryRelativeInvoiceInfo();
|
const submitDiscountInvoiceModel = submitDiscountInvoice({
|
pageId,
|
transCode,
|
});
|
model.computedItem = (item) => {
|
return {
|
...item,
|
action: {
|
buttons: recordButtons.filter(
|
(button) => Number(item[button.prop]) === 1
|
),
|
},
|
};
|
};
|
|
this.formList = model.getFormList();
|
this.formRules = model.getFormRules();
|
this.tableHeader = model.getTableList();
|
this.model = model;
|
this.submitDiscountInvoiceModel = submitDiscountInvoiceModel
|
this.addModel = addRelativeDiscountInvoice();
|
this.delModel = delRelativeDiscountInvoice();
|
this.setSelectOptions();
|
this.getList();
|
},
|
|
// 获取列表
|
async getList() {
|
this.loading = true;
|
let { pageInfo, formValues, model, invoiceSerialno, query } = this;
|
const { phaseNo, transCode } = query;
|
|
const res = await model.request({
|
transCode,
|
phaseNo,
|
invoiceSerialno,
|
...pageInfo,
|
...formValues,
|
|
});
|
this.loading = false;
|
const { list = [], total } = res;
|
this.records = list;
|
this.total = parseInt(total);
|
},
|
|
// 产品名称下拉列表
|
async qryProdList(name) {
|
const tempModel = qryProdList();
|
const { list } = await tempModel.request({ productTypeNo: "" });
|
this.updateValue(name, { 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 });
|
}
|
},
|
|
addInfo() {
|
// const { enterpriseInfo } = this
|
// if (enterpriseInfo.enterpriseName) {
|
// this.dialogTableVisible = true
|
// } else {
|
// this.$message.warning('请先选择合作商信息')
|
// }
|
this.dialogTableVisible = true;
|
},
|
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val;
|
this.getList();
|
},
|
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val;
|
this.getList();
|
},
|
|
// 表格按钮事件处理
|
doAction(item, record) {
|
const { prop } = item;
|
this.tempRecord = { ...record };
|
const { applySerialno } = record;
|
|
// 查看贴息方案
|
if (prop === "selectDiscountProgramButton") {
|
// 详情 按钮操作为打开新详情窗口
|
this.$openWindow("/comm/apply", {
|
isApplyPhase: 2,
|
isHiddenAppoveOpinion: 1,
|
transCode: "DI0002",
|
applySerialno,
|
});
|
}
|
|
// 删除
|
if (prop === "delButton") {
|
this.isShowDelete = true;
|
}
|
},
|
|
// 删除
|
clickDelete(index) {
|
if (index === 0) {
|
this.isShowDelete = false;
|
} else {
|
this.toDelete();
|
}
|
},
|
|
// 表单按钮事件处理
|
buttonAction(id) {
|
if (id === 0) {
|
this.resetForm();
|
}
|
if (id === 1) {
|
this.resetList();
|
}
|
if (id === 2) {
|
const { isShowAll } = this;
|
this.isShowAll = !isShowAll;
|
}
|
},
|
|
// 选择合作商
|
doInvoiceAction(id, records) {
|
if (id === 0) {
|
this.dialogTableVisible = false;
|
}
|
if (id === 1) {
|
this.addRecord(records);
|
}
|
},
|
|
async addRecord(records = []) {
|
if (records.length === 0) {
|
this.$message.warning("请选择开票关联信息");
|
return false;
|
}
|
const { addModel, invoiceSerialno } = this;
|
const { invoiceAmount = 0 } = await addModel.request({
|
invoiceSerialno,
|
optionRelativeDiscountInvoiceInfoRsps: records,
|
});
|
this.setInvoiceAmount(invoiceAmount);
|
this.dialogTableVisible = false;
|
this.resetList();
|
this.updateInfo();
|
},
|
|
async toDelete(records) {
|
const { delModel, tempRecord, invoiceSerialno } = this;
|
const { receivableStatus, serialno } = tempRecord;
|
const { invoiceAmount = 0 } = await delModel.request({
|
invoiceSerialno,
|
receivableStatus,
|
serialno,
|
});
|
this.setInvoiceAmount(invoiceAmount);
|
this.isShowDelete = false;
|
// this.isShowSucc = true;
|
this.resetList();
|
this.updateInfo();
|
},
|
|
// 更新开票基本信息
|
updateInfo() {
|
const { transCode, invoiceSerialno } = this.query;
|
this.queryBaseDiscountInvoiceInfo({
|
transCode,
|
invoiceSerialno,
|
});
|
},
|
|
resetList() {
|
this.pageInfo.currentPage = 1;
|
this.getList();
|
},
|
|
sureSucc() {
|
this.isShowSucc = false;
|
// this.resetList();
|
this.$router.go(-1)
|
},
|
|
// 设置表单下拉菜单
|
setSelectOptions() {
|
const { formList } = this;
|
formList.forEach(({ name }) => {
|
// 项目名称
|
if (name === "projectNameArray") {
|
this.queryProjectList(name);
|
}
|
|
if (name === "productNameArray") {
|
this.qryProdList(name);
|
}
|
|
// 贴息类型
|
if (name === "discountTypeArray") {
|
this.queryCodeValueList(name, {
|
codeNo: "DiscountWay",
|
});
|
}
|
});
|
},
|
|
// 项目名称
|
async queryProjectList(name) {
|
const tempModel = queryProjectList("projectname");
|
const { list } = await tempModel.request({ isAll: "01" });
|
this.updateValue(name, {
|
options: list,
|
});
|
},
|
|
// 获取select中options数据
|
async queryCodeValueList(name, info = {}) {
|
const tempModel = queryCodeValueList();
|
const { list } = await tempModel.request(info);
|
this.updateValue(name, { options: list });
|
},
|
|
resetForm() {
|
const { model } = this;
|
this.formList = model.getFormList();
|
this.setSelectOptions();
|
},
|
// 表单按钮事件处理
|
async submit(isSave = 0) {
|
console.log("利息开票提交");
|
const { submitDiscountInvoiceModel, conf, query } = this;
|
const { transCode, invoiceSerialno } = query;
|
|
// const { edit } = conf;
|
// if (edit !== "Y" || ["101", "102"].includes(pageId)) {
|
// return false;
|
// }
|
try {
|
await submitDiscountInvoiceModel.request({
|
// ...info,
|
transCode,
|
invoiceSerialno,
|
// ...values,
|
});
|
this.isShowSucc = true
|
} catch (err) {
|
console.log(err);
|
}
|
// if (values) {
|
// // const loading = this.$loading({
|
// // fullscreen: true
|
// // })
|
// try {
|
// await model.request({
|
// ...info,
|
// transCode,
|
// invoiceSerialno,
|
// ...values
|
// })
|
// // loading.close()
|
// // this.getDetail()
|
// this.isShowSucc = true
|
// } catch (e) {
|
// // loading.close()
|
// }
|
// } else {
|
// this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
|
// }
|
},
|
...mapMutations(["setInvoiceAmount"]),
|
...mapActions(["queryBaseDiscountInvoiceInfo"]),
|
},
|
computed: {
|
// 表单值信息
|
formValues() {
|
const { model, formList } = this;
|
return model.getFormValues(formList);
|
},
|
isShowAdd() {
|
// 贴息开票申请-修改详情
|
// 财务贴息开票-贴息开票调整
|
const { conf, query } = this;
|
const { edit } = conf;
|
const { isApplyPhase, transCode } = query;
|
return (
|
edit === "Y" && (Number(isApplyPhase) === 1 || transCode === "DI0003")
|
);
|
},
|
...mapState({
|
enterpriseInfo: (state) => state.tabsModule.enterpriseInfo,
|
}),
|
},
|
watch: {
|
invoiceSerialno() {
|
const { invoiceSerialno } = this;
|
if (invoiceSerialno) {
|
this.resetList();
|
}
|
},
|
},
|
};
|
</script>
|
<style lang="postcss" scoped>
|
</style>
|