| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <template>
- <el-dialog
- title="选择对账单"
- custom-class="ele-dialog-form long-dialog-form"
- :visible.sync="accountstatementDialogFlag"
- :before-close="handleClose"
- :close-on-click-modal="false"
- top="5vh"
- :close-on-press-escape="false"
- append-to-body
- width="70%"
- >
- <el-card shadow="never">
- <search @search="reload"></search>
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="datasource"
- row-key="id"
- height="calc(100vh - 500px)"
- class="dict-table"
- :selection.sync="selection"
- :row-click-checked="!multiple"
- :row-click-checked-intelligent="!multiple"
- @selection-change="handleSelectionChange"
- >
- <!-- 表头工具栏 -->
- <template v-slot:action="{ row }">
- <el-button size="mini" type="text" @click="handleSelect(row)"
- >对账明细</el-button
- >
- </template>
- </ele-pro-table>
- </el-card>
- <div slot="footer">
- <el-button size="small" @click="handleSubmit">选择</el-button>
- <el-button size="small" @click="handleClose">关闭</el-button>
- </div>
- <!-- 对账明细 -->
- <accountInfoDialog
- ref="accountInfoDialogRef"
- v-if="accountInfoDialogFlag"
- :account-info-dialog-flag.sync="accountInfoDialogFlag"
- @getAccountInfo="getAccountInfo"
- ></accountInfoDialog>
- </el-dialog>
- </template>
- <script>
- import search from './accountstatementSearch.vue';
- import { getAccountstatementList } from '@/api/saleManage/accountstatement';
- import accountInfoDialog from './accountInfoDialog.vue';
- export default {
- components: {
- search,
- accountInfoDialog
- },
- props: {
- form: {
- type: Object,
- default: () => {
- return {};
- }
- },
- type: {
- type: Number,
- default: 1
- },
- accountstatementDialogFlag: {
- default: false,
- type: Boolean
- },
- // 选择模式:true 多选(复选框列),false 单选(radio 列)
- multiple: {
- type: Boolean,
- default: false
- },
- contactData: {
- type: Object,
- default: () => {
- return {};
- }
- }
- },
- data() {
- return {
- currentIndex: null,
- accountInfoDialogFlag: false,
- selection: [],
- currentRow: {},
- radio: null
- };
- },
- computed: {
- columns() {
- // element-ui 原生不支持 type="radio",统一用 selection 复选框列,
- // 单选/多选通过 handleSelectionChange 约束选中数量实现
- const selectColumn = {
- type: 'selection',
- width: 55,
- align: 'center',
- fixed: 'left'
- };
- return [
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- selectColumn,
- // {
- // action: 'action',
- // slot: 'action',
- // align: 'center',
- // label: '操作',
- // fixed: 'left'
- // },
- {
- prop: 'statementNo',
- label: '对账单编码',
- align: 'center',
- slot: 'statementNo',
- showOverflowTooltip: true,
- minWidth: 200
- },
- {
- prop: 'contactName',
- label: '客户名称',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 180
- },
- {
- prop: 'startDate',
- label: '对账开始日期',
- align: 'center',
- slot: 'startDate',
- showOverflowTooltip: true,
- minWidth: 200
- },
- {
- prop: 'endDate',
- label: '对账结束日期',
- align: 'center',
- slot: 'endDate',
- showOverflowTooltip: true,
- minWidth: 200
- },
- {
- prop: 'amountTotalPrice',
- label: '总金额',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 130
- },
- {
- prop: 'amountReceivablePrice',
- label: '应收金额',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 130
- },
- {
- prop: 'amountPayablePrice',
- label: '应付金额',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 130
- },
- {
- prop: 'createTime',
- label: '创建时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 170
- }
- ];
- }
- },
- methods: {
- init(item = {}, currentIndex = '') {
- this.currentIndex = currentIndex;
- // if (item.id) {
- // this.radio = item.id;
- // }
- },
- getAccountInfo(item) {
- this.currentRow.children = item;
- this.$emit('getAccountData', this.currentRow);
- this.handleClose();
- },
- /* 表格数据源 */
- datasource({ page, limit, where, order }) {
- if (this.contactData.id) {
- where['contactId'] = this.contactData.id;
- }
- return getAccountstatementList({
- pageNum: page,
- size: limit,
- ...where,
- reviewStatus: 2,
- type: String(this.type)
- });
- },
- /* 刷新表格 */
- reload(where) {
- this.$refs.table.reload({ pageNum: 1, where: where });
- },
- handleSelect(row, index) {
- this.currentRow = row;
- this.accountInfoDialogFlag = true;
- this.$nextTick(() => {
- this.$refs.accountInfoDialogRef.init(row, index);
- });
- },
- handleSubmit(){
- console.log(this.selection);
- this.$emit('getAccountData', this.selection);
- this.handleClose();
- },
- // 选择变化:多选直接透传;单选只保留最后选中的一项
- handleSelectionChange(selection) {
- let result = selection;
- if (!this.multiple && selection.length > 1) {
- // 单选模式:只保留最新选中的一项,回写表格勾选状态
- const last = selection[selection.length - 1];
- result = [last];
- this.$refs.table.clearSelection();
- this.$refs.table.toggleRowSelection(last, true);
- }
- this.selection = result;
- this.$emit('selectionChange', result);
- },
- handleClose() {
- this.$emit('update:accountstatementDialogFlag', false);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .tree_col {
- border: 1px solid #eee;
- padding: 10px 0;
- box-sizing: border-box;
- height: 500px;
- overflow: auto;
- }
- .table_col {
- padding-left: 10px;
- ::v-deep .el-table th.el-table__cell {
- background: #f2f2f2;
- }
- }
- .pagination {
- text-align: right;
- padding: 10px 0;
- }
- .btns {
- text-align: center;
- padding: 10px 0;
- }
- .topsearch {
- margin-bottom: 15px;
- }
- </style>
|