1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<template>
<!-- 此组件是ptap组件的补充版本,它是服务于不带角色的回填组件 -->
<div>
<c-row>
<c-col :span="12" style="padding-right: 20px">
<c-col :span="24">
<el-form-item :label="mainInfo.keyLabel" :prop="`${mainInfo.moduleKey}.${mainInfo.keyProp}`">
<c-fullbox>
<c-input v-model="model[mainInfo.moduleKey][mainInfo.keyProp]" maxlength="18" placeholder="请输入"
@keyup.enter.native="showPtapDialog()" @blur="showPtapDialog()"></c-input>
<template slot="footer">
<c-button style="margin: 0 0px 0 10px; padding: 0 0px" size="small" type="primary"
@click="showPtapDialog()">
<i class="el-icon-info" style="font-size:15px"></i>
</c-button>
</template>
</c-fullbox>
</el-form-item>
</c-col>
<c-col :span="24">
<c-form-item :label="mainInfo.otherLabel" :prop="`${mainInfo.moduleKey}.${mainInfo.otherProp}`">
<c-input v-model="model[mainInfo.moduleKey][mainInfo.otherProp]" maxlength="40" placeholder="请输入" disabled
show-word-limit></c-input>
</c-form-item>
</c-col>
</c-col>
<!-- <c-col :span="12" style="padding-left: 20px">
<c-col :span="24">
<c-form-item :label="mainInfo.otherLabel" :prop="`${mainInfo.moduleKey}.${mainInfo.otherProp}`">
<c-input v-model="model[mainInfo.moduleKey][mainInfo.otherProp]" maxlength="40" placeholder="请输入" disabled
show-word-limit></c-input>
</c-form-item>
</c-col>
</c-col> -->
</c-row>
<!-- 弹窗 -->
<el-dialog v-dialogDrag width="80%" :title="dialogTitle" :visible.sync="dialogTableVisible"
v-if="dialogTableVisible">
<div v-if="!loading && tableList.length === 0">暂无数据</div>
<div v-else style="width: 100%;">
<el-table id='tableRef' style="width: 100%;" max-height="300px" v-loading="loading" :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 layout="prev, pager, next, jumper" :total="total" :page-size="pageSize"
:current-page="currentPage" @current-change="currentChange">
</el-pagination>
</div>
</el-dialog>
</div>
</template>
<script>
import { columnMap } from "./ptapColumn.js";
import { getPtaTableDtat, getPtsptaByInr } from "~/service/business/common";
import { get } from 'lodash'
// 机构信息模块
export default {
inject: ["root"],
props: {
model: {
type: Object,
default: () => { }
},
mainInfo: {
type: Object,
default: function () {
return {
moduleKey: '',
keyLabel: '',
keyProp: '',
otherLabel: '',
otherProp: ''
};
}
},
ptytyp: {
//决定弹框的表头
type: String,
default: 'C'
},
bchinr: {
type: String,
default: '00000047'
},
},
data() {
return {
dialogTitle: "", // 弹框标题
dialogTableVisible: false, // 控制弹框的展示和隐藏
loading: false,
total: 0,
currentPage: 1,
pageSizes: [5, 10, 20, 30, 40, 50, 100],
pageSize: 5,
tableList: [],
tableColumn: []
};
},
watch: {},
methods: {
// 表头 头部换行,以 / 作为换行标志
renderheader(h, { column, $index }) {
return h("span", {}, [
h("span", {}, column.label.split("/")[0]),
h("br"),
h("span", {}, column.label.split("/")[1])
]);
},
async showPtapDialog() {
if (this.loading || this.dialogTableVisible) {
return
}
await this.getTableData();
console.log("this.total2----->", this.total)
if (this.total == 1) {
this.dbClickRow(this.tableList[0]);
} else {
// 设置弹框标题
this.dialogTitle = `详情`;
this.dialogTableVisible = true;
this.tableColumn = columnMap[this.ptytyp];
}
// 分层取值
},
currentChange(num) {
console.log("num---->", num)
this.currentPage = num;
this.getTableData();
},
// 获取弹框内的table数据
async getTableData() {
return new Promise(async (resolve) => {
this.loading = true;
this.tableList = [];
this.currentPage = 1;
this.pageSize = 10;
this.total = 0;
// 获取table的表格数据
let params = {
ptytyp: this.ptytyp,
extkey: this.model[this.mainInfo.moduleKey][this.mainInfo.keyProp] || "",
bchinr: this.bchinr,
pageNum: this.currentPage,
pageSize: this.pageSize
};
getPtaTableDtat(params, this.moduleRouter()).then(res => {
if (res.respCode == SUCCESS) {
if (res.data && res.data.list) {
this.total = res.data.total;
console.log("total1----->", this.total);
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}`
}));
this.currentPage = res.data.offset;
this.pageSize = res.data.limit;
resolve(this.tableList)
}
}
this.loading = false; //接口掉完变成false
});
});
},
async dbClickRow(row, column, event) {
let params = {
inr: row.ptainr
};
const response = await getPtsptaByInr(params, this.moduleRouter());
console.log("此行数据------>", row)
if (response.respCode == SUCCESS) {
// 此处为了回填数据时回调
this.$emit('handleChange')
// 回填数据
this.model[this.mainInfo.moduleKey][this.mainInfo.keyProp] = row.ptaobjkey;
this.model[this.mainInfo.moduleKey][this.mainInfo.otherProp] = response.data[this.mainInfo.otherProp];
this.model.branch = row.bchbranch;
this.model.pta.inr = row.ptainr;
this.model.pts.extkey = row.ptaobjkey;
this.model.pts.ennam = response.data.ennam;
this.model.pts.cnnam = response.data.cnnam;
this.model.pts.cnadr = response.data.cnadr;
this.model.pts.enadr = response.data.enadr;
this.model.pts.nam = response.data.nam;
}
this.dialogTableVisible = false;
},
beforeClose(done) {
this.dialogTableVisible = false;
this.currentPage = 1;
done();
}
},
created: function () { }
};
</script>
<style scoped>
.el-dialog__body {
/* min-height: 120%; */
}
.el-table .cell {
white-space: pre-wrap;
}
</style>