BeneficiaryCty.vue 3.87 KB
<template>
	<div>
		<c-col :span="24">
			<el-form-item label="受益人国别" :prop="`${grp}.rec.countrycod`">
				<c-fullbox>
					<c-input 
						v-model.trim="model[grp].rec.countrycod" 
						:disabled="disabled" 
						placeholder="请输入受益人国别" 
						@keyup.enter.native="showBenCtyDialog()"
						@blur="showBenCtyDialog()"
						@input="bcyInput"
						@change="modifyCountrycod()"
						:customModifykey="`${grp}.rec.countrycod`"
						clearable
					></c-input>
					<template slot="footer">
						<c-button type="primary" size="small" :disabled="disabled" icon="el-icon-search" style="margin-left:5px;padding: 0 12px;" @click="showBenCtyDialog()">
						</c-button>
					</template>
				</c-fullbox>
			</el-form-item>
		</c-col>
		<!-- 弹窗 -->
		<el-dialog v-dialogDrag width="80%" :visible.sync="dialogTableVisible" title="收支申报国家信息表" destroy-on-close v-if="dialogTableVisible">
			<div v-if="!loading && tableList.length === 0">暂无数据</div>
			<div v-else style="width: 100%;height: 100%;">
				<el-table height="calc(100% - 32px)" :data="tableList"   @row-dblclick="dbClickRow" >
					<el-table-column v-for="(item,key) in tableColumn" :key="key" :prop="item.prop" :label="item.label">
					</el-table-column>
				</el-table>
				<el-pagination 
					layout="prev, pager, next, jumper, ->, sizes, total" 
					:page-sizes="pageSizes" 
					:page-size="pageSize" 
					:current-page="currentPage"
				  :total="total" 
					@size-change="sizeChange" 
					@current-change="currentChange"
				></el-pagination>
			</div>
		</el-dialog>
	</div>
</template>

<script>
import { getBopCtyCountryData } from "~/service/business/common";
import commonDepend from '~/mixin/commonDepend.js'

export default {
	inject: ["root"],
	mixins: [commonDepend],
  props: {
    model: {
      type: Object,
      default: () => {}
    },
    grp: {
      type: String,
      required: true
		},
		disabled: {
			type: Boolean,
			default: false
		}
  },
  data() {
    return {
      dialogTableVisible: false,
      tableList: [],
      loading: true,
      total: 0,
      currentPage: 1, // 页数
      pageSizes: [5, 10, 20, 30, 40, 50, 100],
      pageSize: 5, // 条数
      tableColumn: [
        { prop: "cod", label: "国家/地区编号" },
        { prop: "numcod", label: "国家/地区数字代码" },
        { prop: "txt", label: "国家/地区简称" },
        { prop: "fultxt", label: "国家/地区全称" }
      ]
    };
  },

  methods: {
   async showBenCtyDialog() {
			this.currentPage = 1;
		  await	this.getTableData();
			if(this.total ==1){
				this.dbClickRow(this.tableList[0])
			}else{
        this.dialogTableVisible = true;
			}
    },
    async getTableData() {
      this.loading = true;
      this.tableList = [];
      let params = {
        countryCod: this.model[this.grp].rec.countrycod || "",
        pageNum: this.currentPage,
        pageSize: this.pageSize
      };
      const res = await getBopCtyCountryData(params);
      if (res.respCode == SUCCESS) {
        if (res.data && res.data.list) {
          this.total = res.data.total;
          this.tableList = res.data.list;
        }
      }
      this.loading = false;
		},
		bcyInput(){
			this.model[this.grp].payeecountcode=this.model[this.grp].rec.countrycod
		},
    //回填数据
    dbClickRow(row) {
      this.model[this.grp].rec.countrycod = row.cod;
			this.modifyCountrycod()
			this.dialogTableVisible = false;
      this.$emit('handleChange')
		},
		modifyCountrycod(){
			this.customAddModify(this.model[this.grp].rec,'countrycod')
		},
    sizeChange(num) {
			console.log(111,num)
      this.pageSize = num;
      this.getTableData();
    },
    currentChange(num) {
			console.log(222,num)
			this.currentPage = num;
      this.getTableData();
    }
  }
};
</script>

<style scoped lang="less">
::v-deep .el-dialog__body {
	height: calc(100% - 55px)
}
.el-table .cell {
  white-space: pre-wrap;
}
</style>