<template>
|
<div class="contact">
|
<el-button
|
type="primary"
|
icon="el-icon-circle-plus-outline"
|
@click="addcontact"
|
size="medium"
|
>新增</el-button>
|
<el-table
|
stripe
|
:data="contactData"
|
style="margin-top:30px"
|
:cell-style="cell"
|
:header-cell-style="{background:'#f5f5f5',color:'#222222'}"
|
highlight-current-row
|
>
|
<el-table-column min-width="200">
|
<template slot="header">
|
<span>
|
<span class="red-star">*</span>
|
<span style="padding-left:8px">收款账户名称</span>
|
</span>
|
</template>
|
<template slot-scope="{row}">
|
<span style="padding-left:15px" v-show="!row.isEdit">{{row.collectionAccountName}}</span>
|
<el-input
|
style="padding-left:15px"
|
size="small"
|
v-show="row.isEdit"
|
v-model="row.collectionAccountName"
|
placeholder="请输入"
|
require
|
></el-input>
|
</template>
|
</el-table-column><el-table-column min-width="200">
|
<template slot="header">
|
<span>
|
<span class="red-star">*</span>
|
<span style="padding-left:8px">收款账户开户行</span>
|
</span>
|
</template>
|
<template slot-scope="{row}">
|
<span style="padding-left:15px" v-show="!row.isEdit">{{row.collectionBranchBankNameDesc}}</span>
|
<el-select
|
style="padding-left:15px;display:block;"
|
v-model="row.collectionBranchBankName"
|
filterable
|
placeholder="请选择"
|
size="small"
|
v-show="row.isEdit"
|
>
|
<el-option
|
v-for="item in collectionBranchBankNameList"
|
:key="item.itemno"
|
:label="item.itemname"
|
:value="item.itemno"
|
></el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column min-width="200">
|
<template slot="header">
|
<span>
|
<span class="red-star">*</span>
|
<span style="padding-left:8px">收款账户账号</span>
|
</span>
|
</template>
|
<template slot-scope="{row}">
|
<span style="padding-left:15px" v-show="!row.isEdit">{{row.collectionAccountNo}}</span>
|
<el-input
|
style="padding-left:15px"
|
size="small"
|
v-show="row.isEdit"
|
v-model="row.collectionAccountNo"
|
placeholder="请输入"
|
></el-input>
|
</template>
|
</el-table-column>
|
|
<el-table-column min-width="200">
|
<template slot="header">
|
<span>
|
<span class="red-star">*</span>
|
<span style="padding-left:8px">收款金额</span>
|
</span>
|
</template>
|
<template slot-scope="{row}">
|
<span style="padding-left:15px" v-show="!row.isEdit">{{row.stayproceedssum}}</span>
|
<el-input
|
style="padding-left:15px"
|
size="small"
|
v-show="row.isEdit"
|
v-model="row.stayproceedssum"
|
placeholder="请输入"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="管理" min-width="110">
|
<template slot-scope="scope">
|
<el-button type="text" @click.native="handleEdit(scope.row)" v-if="!scope.row.isEdit">修改</el-button>
|
<el-button type="text" @click.native="handleSave(scope.row)" v-else>保存</el-button>
|
<el-button
|
type="text"
|
@click.native="handleCancel(scope.row,scope.$index)"
|
v-if="scope.row.isCancel"
|
>取消</el-button>
|
<el-button type="text" @click.native="handleDelete(scope.row,scope.$index)" v-else>删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</template>
|
<script>
|
import {
|
qryContactList,
|
getDictionaryList,
|
saveContact,
|
delContact
|
} from "@api/product";
|
import common from "@/utils/common";
|
import { setStorage, getStorage } from "@/utils/storage";
|
export default {
|
props: ["show"],
|
data() {
|
return {
|
applyInfo: this.$store.state.product.applyInfo,
|
contactData: [],
|
contactArr: [],
|
initialArr: [],
|
collectionBranchBankNameList: []
|
};
|
},
|
async created() {
|
// 查询账户
|
// this.getContactList();
|
},
|
methods: {
|
cell({ row, column, rowIndex, columnIndex }) {
|
const { applyInfo } = this;
|
const { refuseFlag } = applyInfo;
|
if (refuseFlag == 1) {
|
const { customerInfo } = this.$store.state.product.fields;
|
const { customerRelativeList } = customerInfo;
|
if(customerRelativeList&&customerRelativeList.length){
|
for (let i = 0; i < customerRelativeList.length; i++) {
|
const object = customerRelativeList[i];
|
for (const key in object) {
|
if (row[key] != object[key] && column.property == key) {
|
return { color: "#222", "font-weight": "700" };
|
}
|
}
|
}
|
}
|
}
|
},
|
qryDictionaryList(code) {
|
return new Promise(resolve => {
|
getDictionaryList({
|
codeNo: code
|
}).then(res => {
|
resolve(res.result);
|
});
|
});
|
},
|
// 查询账户
|
getContactList() {
|
qryContactList({
|
applySerialNo: this.applyInfo.serialNo,
|
customerId: this.applyInfo.customerid,
|
relationtype: "03"
|
}).then(res => {
|
this.contactData = [];
|
this.initialArr = [];
|
this.contactArr = res.result;
|
res.result.forEach(val => {
|
const obj = {};
|
for (const key in val) {
|
obj[key] = val[key].value;
|
obj.collectionBranchBankNameDesc = val.collectionBranchBankName.valueDesc;
|
}
|
this.contactData.push(obj);
|
this.initialArr.push(Object.assign({}, obj));
|
});
|
});
|
},
|
// 新增账户
|
addcontact() {
|
for (let i = 0; i < this.contactData.length; i++) {
|
if (this.contactData[i].isEdit) {
|
this.$message.warning("请先保存当前账户再新增");
|
return;
|
}
|
}
|
this.contactData.unshift({
|
collectionAccountName: "",
|
collectionAccountNo: "",
|
collectionBranchBankName: "",
|
applyserialno: this.applyInfo.serialNo,
|
customerid: this.applyInfo.customerid,
|
isEdit: true
|
});
|
},
|
// 保存账户
|
handleSave(row) {
|
if (!row.collectionAccountName) {
|
this.$message.warning("收款账户名称不能为空");
|
return;
|
}
|
if (!/^[\u4e00-\u9fa5]{2,4}$/.test(row.collectionAccountName)) {
|
this.$message.warning("收款账户名称格式不正确");
|
return;
|
}
|
if (!row.collectionAccountNo) {
|
this.$message.warning("收款账户开户行不能为空");
|
return;
|
}
|
|
if (!row.collectionBranchBankName) {
|
this.$message.warning("收款账户开户行不能为空");
|
return;
|
}
|
for (let i = 0; i < this.contactData.length; i++) {
|
if (
|
this.contactData.length > 1 &&
|
!this.contactData[i].isEdit &&
|
row.collectionAccountNo == this.contactData[i].collectionAccountNo &&
|
row.collectionAccountName == this.contactData[i].collectionAccountName
|
) {
|
this.$message.warning("账户已存在,请重新填写");
|
return;
|
}
|
}
|
saveContact(row).then(res => {
|
if (res.code == "00") {
|
this.$message.success("保存成功");
|
this.getContactList();
|
}
|
});
|
},
|
// 修改
|
handleEdit(row) {
|
for (let i = 0; i < this.contactData.length; i++) {
|
if (this.contactData.length > 1 && this.contactData[i].isEdit) {
|
this.$message.warning("请先保存当前账户");
|
return;
|
}
|
}
|
this.$set(row, "isEdit", true);
|
this.$set(row, "isCancel", true);
|
},
|
// 取消
|
handleCancel(row, index) {
|
const arr = [];
|
for (let i = 0; i < this.initialArr.length; i++) {
|
if (i == index) {
|
for (const key in row) {
|
if (
|
key != "isEdit" &&
|
key != "isCancel" &&
|
row[key] != this.initialArr[i][key]
|
) {
|
arr.push(key);
|
}
|
}
|
}
|
}
|
if (arr.length) {
|
common.comfirm("提示", "当前有数据未保存,是否放弃保存?", () => {
|
this.$set(row, "isEdit", false);
|
this.$set(row, "isCancel", false);
|
arr.forEach(val => {
|
for (const key in this.initialArr[index]) {
|
if (this.initialArr[index].hasOwnProperty(val)) {
|
this.contactData[index][key] = this.initialArr[index][key];
|
}
|
}
|
});
|
});
|
} else {
|
this.$set(row, "isEdit", false);
|
this.$set(row, "isCancel", false);
|
}
|
},
|
// 删除
|
handleDelete(row, index) {
|
for (let i = 0; i < this.contactData.length; i++) {
|
if (this.contactData.length == 1 && !this.contactData[i].isEdit) {
|
this.$message.warning("至少保留一个账户信息");
|
return;
|
}
|
}
|
if (row.serialno) {
|
common.comfirm(
|
"提示",
|
`请确认是否需要账户:${row.collectionAccountName}?`,
|
() => {
|
if (row.serialno) {
|
delContact([row.serialno]).then(res => {
|
if (res.code == "00") {
|
this.$message.success("删除成功");
|
this.getContactList();
|
}
|
});
|
}
|
}
|
);
|
} else {
|
this.getContactList();
|
}
|
}
|
}
|
};
|
</script>
|
<style lang="stylus">
|
.contact {
|
>.el-button {
|
padding: 9px 12px;
|
}
|
|
>p {
|
height: 20px;
|
color: #222222;
|
font-weight: 500;
|
font-size: 14px;
|
position: relative;
|
margin-bottom: 30px;
|
|
>span {
|
width: 2px;
|
height: 14px;
|
background-color: #0081F0;
|
position: absolute;
|
left: -10px;
|
top: 50%;
|
transform: translateY(-50%);
|
}
|
}
|
|
.red-star {
|
width: 7px;
|
display: inline-block;
|
vertical-align: middle;
|
color: #FF4300;
|
}
|
}
|
</style>
|