<template> <div class="eibs-tab"> <c-row> <c-col :span="12"> <el-form-item label="交易类型" prop="trntyp"> <c-select style="width: 100%" v-model="model.trntyp" @change="handleChangeTrntyp" placeholder="请选择交易类型" dbCode="BUSTXT" :filterKey="['DF','FP']" /> </el-form-item> </c-col> <c-col :span="12"> <el-form-item label="报文类型" prop="swttyp"> <c-select style="width: 100%" v-model="model.swttyp" placeholder="请选择报文类型" dbCode="STXSWT" /> </el-form-item> </c-col> </c-row> <c-row> <c-col :span="12"> <el-form-item label="模板编号" prop="extkey"> <c-input v-model="model.extkey" placeholder="请输入模板编号" /> </el-form-item> </c-col> <c-col :span="12"> <el-form-item label="模板名称" prop="nam"> <c-input v-model="model.nam" placeholder="请输入模板名称" /> </el-form-item> </c-col> </c-row> <c-row> <c-col :span="12"> <el-form-item label="包买商" prop="ptyextkey" v-if="model.trntyp === 'FP'"> <c-input style="width: 100%" v-model="model.ptyextkey" placeholder="请输入包买商" /> </el-form-item> </c-col> <c-col :span="12"> <el-form-item label="代付行" prop="ptyextkey" v-if="model.trntyp == 'DF'"> <c-input style="width: 100%" v-model="model.ptyextkey" placeholder="请输入选代付行" /> </el-form-item> </c-col> <c-col :span="12"> <el-form-item label="境内境外" prop="fromflg" v-if="model.trntyp == 'DF'"> <c-select style="width: 100%" v-model="model.fromflg" placeholder="请选择境内境外" dbCode="DFUFLG" /> </el-form-item> </c-col> </c-row> <c-col :span="24"> <span style="float: left"> <el-button type="primary" ref="stxInsertBtn" v-if="isShowAddBtn" size="small" @click="stxAdd">新增</el-button> </span> <span style="float: right"> <el-button size="small" @click="handleReset">重置</el-button> <el-button type="primary" icon="el-icon-search" size="small" :loading="searchLoading" @click="onSearch()">查询 </el-button> </span> </c-col> <c-col :span="24"> <c-paging-table :data="stxData" :columns="stxColumns" :pageNumber="model.pageNum" :pageSize="model.pageSize" :total="model.total" v-on:queryFunc="queryFunc" :border="true"> <c-table-column fixed="right" prop="op" label="操作" width="240px"> <template slot-scope="{ scope }"> <c-button style="margin-left: 5px" size="small" type="info" ref="stxDisplayBtn" @click="stxDisplay(scope.row)">详情</c-button> <c-button style="margin-left: 5px" size="small" type="primary" ref="stxUpdateBtn" v-if="isShowUpdBtn" @click="stxEdit(scope.row)">修改</c-button> <c-button size="small" style="margin-left: 5px" type="danger" ref="stxDeleteBtn" v-if="isShowDelBtn" @click="stxDelete(scope.row)">删除</c-button> </template> </c-table-column> </c-paging-table> </c-col> <el-dialog :title="dialogNam[operaTyp]" :visible.sync="dialogFlg" :modal-append-to-body="false" :close-on-click-modal="false" width="70%"> <el-form :model="dataForm" :rules="rules" ref="dataForm" label-suffix=" :" :disabled="isDisabled"> <c-col :span="12" style="padding-right: 20px;"> <c-col :span="20"> <el-form-item label="交易类型" :label-width="formLabelWidth" prop="trntyp"> <c-select :disabled="operaTyp == 'edit'" autocomplete="off" v-model="dataForm.trntyp" placeholder="请选择交易类型" dbCode="BUSTXT" :filterKey="['DF','FP']" @change="getArgList()" /> </el-form-item> </c-col> <c-col :span="20"> <el-form-item label="模板编号" :label-width="formLabelWidth" prop="extkey"> <c-fullbox> <c-input :disabled="operaTyp == 'edit'" v-model="dataForm.extkey" maxlength="16" placeholder="请输入模板编号" /> <template slot="footer"> <c-button style="margin: 0 0" :disabled="operaTyp == 'edit'" size="small" type="primary" @click="getReference">获取</c-button> </template> </c-fullbox> </el-form-item> </c-col> <c-col :span="20"> <el-form-item label="包买商" :label-width="formLabelWidth" prop="ptyextkey" v-if="dataForm.trntyp === 'FP'"> <c-input style="width: 100%" v-model="dataForm.ptyextkey" @keyup.enter.native="showPtapDialog()" @blur="handleExtkeyBlur()" @clear="clear()" @input="extkeyInput()" placeholder="请输入包买商" /> </el-form-item> </c-col> <c-col :span="20"> <el-form-item label="代付行" :label-width="formLabelWidth" prop="ptyextkey" v-if="dataForm.trntyp == 'DF'"> <c-input style="width: 100%" v-model="dataForm.ptyextkey" @keyup.enter.native="showPtapDialog()" @blur="handleExtkeyBlur()" @clear="clear()" @input="extkeyInput()" placeholder="请输入代付行" /> </el-form-item> </c-col> <c-col :span="20"> <el-form-item label="境内境外" :label-width="formLabelWidth" prop="fromflg" v-if="dataForm.trntyp == 'DF'"> <c-select style="width: 100%" v-model="dataForm.fromflg" placeholder="请选境内境外" dbCode="DFUFLG" /> </el-form-item> </c-col> </c-col> <c-col :span="12" style="padding-right: 20px;"> <c-col :span="20"> <el-form-item label="报文类型" :label-width="formLabelWidth" prop="swttyp"> <c-select :disabled="operaTyp == 'edit'" style="width: 100%" v-model="dataForm.swttyp" placeholder="请选择报文类型" dbCode="STXSWT" /> </el-form-item> </c-col> <c-col :span="20"> <el-form-item label="模板名称" :label-width="formLabelWidth" prop="nam"> <c-input v-model="dataForm.nam" placeholder="请输入模板名称" /> </el-form-item> </c-col> <c-col :span="20"> <el-form-item label="变量名称" :label-width="formLabelWidth" prop="lgargs"> <el-select v-model="dataForm.lgargs" style="width: 100%" filterable> <el-option v-for="item in argCodes" :key="item.value" :label="item.value+' - '+item.label" :value="item.value" /> </el-select> </el-form-item> </c-col> </c-col> <c-col :span="24"> <c-col :span="12"> <el-form-item label="全行可见" :label-width="formLabelWidth" prop="opnflg"> <el-radio-group v-model="dataForm.opnflg" @change="onChange"> <el-radio label="Y">是</el-radio> <el-radio label="N">否</el-radio> </el-radio-group> </el-form-item> </c-col> </c-col> <c-col :span="24"> <c-col :span="12"> <el-form-item label="分支机构" :label-width="formLabelWidth" prop="objextkey" v-if="dataForm.opnflg==='N'"> <c-select style="width: 75%" v-model="dataForm.objextkey" placeholder="请选择分支机构" @change="changUsr"> <el-option v-for="item in bchData" :key="item.bchname" :label="item.branch + ' ' + item.bchname" :value="item.branch"> <span style="float: left">{{ item.branch }} - {{ item.bchname }}</span> </el-option> </c-select> </el-form-item> </c-col> <!-- <c-col :span="10"> <el-form-item label="客户号" :label-width="formLabelWidth" prop="usrextkey" v-if="dataForm.opnflg==='N'"> <c-fullbox> <c-input v-model="dataForm.usrextkey" placeholder="" /> <template slot="footer"> <c-button style="margin: 0 0" size="small" type="primary" @click="showPty()">获取</c-button> </template> </c-fullbox> </el-form-item> </c-col> --> </c-col> <c-col :span="22"> <el-form-item label="SWIFT报文模板" :label-width="formLabelWidth" prop="swttxt"> <c-xml-format-editor v-model="dataForm.swttxt" :disabled="isDisabled" placeholder="" :insertParams="{isShowInsertFn: true, insertContent: dataForm.lgargs ? '{'+dataForm.lgargs+'}' : ''}" :isShowScale="true"> </c-xml-format-editor> </el-form-item> </c-col> </el-form> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="commitAdd" v-if="operaTyp == 'add'">提 交</el-button> <el-button type="primary" @click="commitEdit" v-if="operaTyp == 'edit'">提 交</el-button> <el-button @click="dialogFlg = false" v-if="operaTyp != 'info'">取 消</el-button> <el-button @click="dialogFlg = false" v-if="operaTyp == 'info'">返 回</el-button> </div> </el-dialog> <!-- 代付行弹窗 --> <el-dialog title="代付行详情" v-dialogDrag width="64%" :visible.sync="dialogTableVisible" destroy-on-close :close-on-click-modal="false" :close-on-press-escape="false" :show-close="true" v-if="dialogTableVisible" :modal-append-to-body="false" :append-to-body="true"> <div v-if="!tableLoading && tableList.length === 0">暂无数据</div> <div v-else style="width: 100%;height: 100%;"> <el-table id='tableRef' height="calc(100% - 32px)" style="width: 100%;" v-loading="tableLoading" :data="tableList" @row-dblclick="dbClickRow" :before-close="beforeClose"> <el-table-column v-for="(item,key) in tableColumn" :key="key" :prop="item.prop" :render-header="renderheader" :label="item.label"> </el-table-column> </el-table> <el-pagination class="eContainer-pagination" layout="prev, pager, next, jumper, ->, sizes, total" :page-sizes="ptyModel.pageSizes" :page-size="ptyModel.pageSize" :current-page="ptyModel.currentPage" :total="ptyModel.total" @size-change="sizeChange" @current-change="currentChange"></el-pagination> </div> </el-dialog> </div> </template> <script> import codes from "~/config/CodeTable"; import { queryByPage, add, queryById, edit, deleteById, getExtkey, getBchlist, getPtyList } from "~/service/manage/stx.js"; import Stx, { Pattern, columnMap } from "./Stx.js"; import { listInfo } from "~/service/manage/gtxarg.js"; import GtxargModel from "~/page/Statics/GtxArg/GtxargModel.js"; import { getPtaTableDtat } from "~/service/business/common"; import commonFunctions from "~/mixin/commonFunctions.js"; import commonDepend from "~/mixin/commonDepend.js"; export default { mixins: [commonFunctions, commonDepend], props: ["data"], inject: ["root"], data() { return { rules: Pattern, model: new Stx().data, argCodes: [], gtxargModel: new GtxargModel().data.gtxarg, stxData: [], stxColumns: [ { abel: "交易类型", prop: "trntyp", width: "130%" }, { label: "报文类型", prop: "swttyp", width: "200%" }, { label: "模板编号", prop: "extkey", width: "150%" }, { label: "模板名称", prop: "nam", width: "300%" }, { label: "交易对手", prop: "ptyextkey", width: "130%" }, { label: "全行可见", prop: "opnflg", width: "120%" } ], dataForm: new Stx().data, dialogNam: { add: "SWIFT报文模板--新增", edit: "SWIFT报文模板--修改", info: "SWIFT报文模板--查看" }, bchData: [], ptyData: [], ptyColumns: [ { label: "客户号", prop: "extkey", width: "180px" }, { label: "中文名称", prop: "cnnam", width: "180px" }, { label: "英文名称", prop: "ennam", width: "180px" } ], ptyDialog: false, operaTyp: "", isDisabled: false, isShowAddBtn: false, isShowUpdBtn: false, isShowDelBtn: false, searchLoading: false, dialogFlg: false, formLabelWidth: "150px", dialogTitle: "", // 弹框标题 dialogTableVisible: false, // 控制弹框的展示和隐藏 tableLoading: false, ptyModel: { currentPage: 1, // 页数 pageSizes: [5, 10, 20, 30, 40, 50, 100], pageSize: 10, // 条数 total: 0 }, tableList: [], tableColumn: [], markExtkey: "", visible: false }; }, //初始化查询 created() { this.model.pageSize = PageSize; this.model.pageNum = 1; this.onDblstxSearch(); this.onbchSearch(); }, activated() { const { update } = this.$route.params; if (update) { this.onDblstxSearch(); } }, computed: { isShowObj() { let currentOrg = this.$store.state.UserContext.currentOrg; if (currentOrg.departmentNumber != "1000") { return true; } else { return false; } } }, mounted() { this.getHiddenButtonVue(); }, methods: { getHiddenButtonVue() { const loading = this.loading(); this.$buttonControlService.hiddenBtnList().then(res => { // 新增 let hasInsert = res.some(item => { return item.ITEMID === "stxInsertBtn"; }); if (hasInsert) { this.isShowAddBtn = false; } else { this.isShowAddBtn = true; } // 修改 let hasUpdate = res.some(item => { return item.ITEMID === "stxUpdateBtn"; }); if (hasUpdate) { this.isShowUpdBtn = false; } else { this.isShowUpdBtn = true; } // 删除 let hasDelete = res.some(item => { return item.ITEMID === "stxDeleteBtn"; }); if (hasDelete) { this.isShowDelBtn = false; } else { this.isShowDelBtn = true; } loading.close(); }); }, showPty() { let params = { usrextkey: this.dataForm.extkey, // ptynam: this.ptyModel.ptynam, pageNum: this.ptyModel.pageNum, pageSize: this.ptyModel.pageSize, total: this.ptyModel.total }; this.ptyData = null; getPtyList(params).then(res => { if (res.respCode == SUCCESS) { const list = res.data.list; this.ptyData = list; this.ptyModel.pageNum = res.data.pageNumber; this.ptyModel.pageSize = res.data.pageSize; this.ptyModel.total = res.data.total; } }); this.ptyDialog = true; // } }, changUsr() { this.dataForm.usrextkey = ""; }, // 根据交易类型获取SWIFT报文模板变量列表 getArgList() { this.gtxargModel.trntyp = this.dataForm.trntyp; if (this.gtxargModel.trntyp == "" || this.gtxargModel.trntyp == null) { this.argCodes = []; } else { listInfo(this.gtxargModel).then(res => { this.argCodes = res.data.map(item => ({ value: item.cod, label: item.name + " (" + item.path + ")" })); }); } }, getCodesByKey(key) { return codes[key] || []; }, onbchSearch() { getBchlist().then(res => { if (res.respCode == SUCCESS) { this.$set(this, "bchData", res.data); } }); }, onChange() { if (this.dataForm.opnflg == "Y") { (this.dataForm.objextkey = ""), (this.dataForm.usrextkey = ""); } else { let currentOrg = this.$store.state.UserContext.currentOrg; if (currentOrg.departmentNumber != "1000") { //this.dataForm.objextkey = currentOrg.departmentNumber } } }, handleChangeTrntyp() { this.model.swttyp = ""; this.model.extkey = ""; this.model.nam = ""; this.model.fromflg = ""; this.model.purpos = ""; this.model.ptyextkey = ""; this.model.dfuflg = ""; }, handleReset() { //this.root.$refs.modelForm.resetFields() this.model.trntyp = ""; this.model.swttyp = ""; this.model.extkey = ""; this.model.nam = ""; this.model.fromflg = ""; this.model.purpos = ""; this.model.ptyextkey = ""; this.model.dfuflg = ""; }, handleReset11() { this.ptyModel.extkey = ""; this.ptyModel.ptynam = ""; }, onSearch() { this.model.pageSize = PageSize; this.model.pageNum = 1; this.onDblstxSearch(); }, onDblstxSearch() { this.searchLoading = true; let currentOrg = this.$store.state.UserContext.currentOrg; if (currentOrg.departmentNumber != "1000") { this.model.objextkey = currentOrg.departmentNumber; } queryByPage(this.model).then(res => { /** * pageNumber: 0 * pageSize: 0 * total: 69 * totalPage: 0 */ if (res.respCode == SUCCESS) { const list = res.data.list; this.stxData = list; this.model.pageNum = res.data.pageNumber; this.model.pageSize = res.data.pageSize; this.model.total = res.data.total; this.searchLoading = false; } else { this.searchLoading = false; } }); }, queryFunc(pageNumber, pageSize) { this.model.pageNum = pageNumber; this.model.pageSize = pageSize; this.onDblstxSearch(); }, queryFuncPty(pageNumber, pageSize) { this.ptyModel.pageNum = pageNumber; this.ptyModel.pageSize = pageSize; this.showPty(); }, useInfo(row) { this.dataForm.usrextkey = row.extkey; this.ptyDialog = false; }, //新增弹窗 stxAdd() { this.operaTyp = "add"; this.dialogFlg = true; this.isDisabled = false; this.dataForm = new Stx().data; }, //新增提交 commitAdd() { this.$refs["dataForm"].validate(valid => { if (valid) { add(this.dataForm) .then(res => { if (res.errorCode == "AAAAAA" || res.respCode == "AAAAAA") { this.$notify.success("添加成功!"); this.dialogFlg = false; this.onDblstxSearch(); console.log("==1"); } else { this.$notify.error("添加失败!"); console.log("==2"); } }) .catch(err => { //this.$notify.error("添加失败!"); console.log("==3"); }); } else { this.$message.info("请检查输入项!"); return false; } }); }, //查看弹窗 stxDisplay(row) { queryById(row) .then(res => { this.dataForm = res.data; console.log("this.dataForm-1------------"); console.log(this.dataForm); this.operaTyp = "info"; this.isDisabled = true; this.dialogFlg = true; }) .catch(err => { this.$notify.error("数据查询失败"); }); }, //修改弹窗 stxEdit(row) { queryById(row) .then(res => { this.dataForm = res.data; console.log("this.dataForm-1------------"); console.log(this.dataForm); this.operaTyp = "edit"; this.isDisabled = false; this.dialogFlg = true; this.getArgList(); }) .catch(err => { this.$notify.error("数据查询失败"); }); }, commitEdit() { this.$refs["dataForm"].validate(valid => { if (valid) { edit(this.dataForm) .then(res => { if (res.errorCode == "AAAAAA" || res.respCode == "AAAAAA") { this.$notify.success("修改成功!"); this.dialogFlg = false; this.onDblstxSearch(); } else { this.$notify.error("修改失败!"); } }) .catch(err => { //this.$notify.error("修改失败!"); }); } else { console.log("error submit!!"); return false; } }); }, stxDelete(row) { this.$confirm("是否确认删除?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }) .then(() => { deleteById(row) .then(res => { if (res.errorCode == "AAAAAA" || res.respCode == "AAAAAA") { this.$notify.success("删除成功!"); this.dialogFlg = false; this.onDblstxSearch(); } else { this.$notify.error("删除失败!"); } }) .catch(err => { //this.$notify.error("删除失败!"); }); }) .catch(() => { this.$message({ type: "info", message: "已取消删除" }); }); }, getReference() { console.log("getReference--index"); let validateFieldList = []; this.$refs.dataForm.validateField( //这里要放数组,数组中写上要校验的字段 ["trntyp", "swttyp"], async valid => { if (!valid) { //校验通过走这里,每通过一次,会往这个数组里加一个"" validateFieldList.push(valid); console.log("validateFieldList--"); console.log(validateFieldList); //因为我这里总共校验了三个字段,所有最终三个字段都校验成功之后,数组中会有三个"" if ( validateFieldList.length == 2 && validateFieldList.every(item => item === "") ) { //这里写校验通过的业务逻辑 getExtkey(this.dataForm) .then(res => { if (res.data.extkey.length <= 0) { this.$notify.success("获取模板编号失败, 请重新获取!"); console.log(res); } else { this.$notify.success("获取模板编号成功!"); console.log(res); this.dataForm.extkey = res.data.extkey; } }) .catch(err => { //this.$notify.error("获取模板编号失败!"); }); } else { console.log("校验不通过"); } } else { console.log("校验不通过~"); } } ); }, // extkey输入框失焦 handleExtkeyBlur(e) { let extkey = this.dataForm.ptyextkey; if (extkey && extkey !== this.markExtkey) { this.showPtapDialog(); } }, // 弹框 async showPtapDialog() { if (this.tableLoading || this.dialogTableVisible) { return; } const value = this.dataForm.ptyextkey; // 分层取值 await this.getTableData(value); if (this.total == 1) { this.dbClickRow(this.tableList[0]); } else { // 设置弹框标题 this.dialogTableVisible = true; this.tableColumn = columnMap["C"]; this.$nextTick(() => { this.root.$refs["modelForm"].validateField([`ptyextkey`]); }); } }, // 获取弹框内的table数据 async getTableData(value) { return new Promise(async resolve => { this.tableLoading = true; this.tableList = []; // 获取table的表格数据 let params = { ptytyp: "B", extkey: value || "", pageNum: this.ptyModel.currentPage, pageSize: this.ptyModel.pageSize }; const loading = this.loading(); const res = await getPtaTableDtat(params, this.moduleRouter()); loading.close(); if (res.respCode == SUCCESS) { if (res.data && res.data.list) { this.ptyModel.total = res.data.total; // this.tableList = res.data.list; this.tableList = res.data.list.map(it => ({ ...it, // 添加新key将Party Number和Address Number换行 partyNumberAndAdressNumber: `${it.ptaptyextkey || ""}\n${it.ptaobjkey || ""}`, bchbranchAndBchbchname: `${it.bchbranch || ""}\n${it.bchbchname || ""}`, adrnam1AndPtanam1: `${it.adrnam1 || ""}\n${it.ptanam1 || ""}`, adradr1AndAdrstr1: `${it.adradr1 || ""}\n${it.adrstr1 || ""}`, adrstr2Andadrloccty: `${it.adrstr2 || ""}\n${it.adrloccty || ""}`, adrloczipAndadrloctxt: `${it.adrloczip || ""}\n${it.adrloctxt || ""}` })); resolve(this.tableList); } } this.tableLoading = false; //接口掉完变成false }); }, async dbClickRow(row, column, event) { this.markExtkey = row.ptaptyextkey; this.dataForm.ptyextkey = row.ptaptyextkey; this.$nextTick(() => { this.root.$refs["modelForm"].validateField([`ptyextkey`]); }); this.dialogTableVisible = false; }, //extkey清空时 extkeyInput() { if (!this.dataForm.ptyextkey) { this.markExtkey = ""; this.clear(); } }, // 清除 clear() { this.$emit("clear"); this.$nextTick(() => { this.root.$refs["modelForm"].validateField([`ptyextkey`]); }); }, // 关闭弹框 handleCloseDialogTable() { this.dialogTableVisible = false; }, beforeClose(done) { this.dialogTableVisible = false; this.ptyModel.currentPage = 1; done(); }, sizeChange(num) { this.pageSize = num; const value = this.dataForm.ptyextkey; this.getTableData(value); }, currentChange(num) { this.ptyModel.currentPage = num; const value = this.dataForm.ptyextkey; this.getTableData(value); } } }; </script> <style scoped> </style>