BusinessCty.vue 4.71 KB
Newer Older
fukai committed
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
<template>
	<div>
		<c-fullbox>
			<c-input v-model="model" :disabled="disabled" placeholder="" @keyup.enter.native="showBenCtyDialog()" @change="handleChange"></c-input>
			<template slot="footer">
				<c-button type="primary" size="small" :disabled="disabled" icon="el-icon-search" style="margin-left: 10px;padding: 0 12px;" @click="showBenCtyDialog()">
				</c-button>
			</template>
		</c-fullbox>
		<!-- 弹窗 -->
		<el-dialog v-dialogDrag width="64%" :visible.sync="dialogTableVisible" :append-to-body="true" :title="rmb ? '跨境人民币申报国家信息表' : '收支申报国家信息表'" destroy-on-close v-if="dialogTableVisible" @close="handleClose">
			<div style="width: 100%;height: 100%;">
				<c-col :span="24">
					<c-col :span="8">
						<el-form-item label="国家/地区编号">
							<c-input v-model="formData.cod" @input="handleSearch"></c-input>
						</el-form-item>
					</c-col>
					<c-col :span="8">
						<el-form-item label="国家/地区数字代码">
							<c-input v-model="formData.numcod" @input="handleSearch"></c-input>
						</el-form-item>
					</c-col>
					<c-col :span="8">
						<el-form-item label="国家/地区简称">
							<c-input v-model="formData.txt" @input="handleSearch"></c-input>
						</el-form-item>
					</c-col>
				</c-col>
				<el-table height="calc(100% - 52px)" :data="tableList" @row-dblclick="dbClickRow">
					<el-table-column
						v-for="(item,key) in tableColumn"
						:key="key"
						:prop="item.prop"
						:label="item.label"
						:width="item.width"
						 :sortable="['cod', 'numcod', 'txt'].includes(item.prop)"
					>
					</el-table-column>
				</el-table>
			</div>
		</el-dialog>
	</div>
</template>

<script>
import { getBopCtyCountryData } from "~/service/business/common";
import commonDepend from "~/mixin/commonDepend.js";
import { getCnyctyCod } from "~/service/business/rmb";
export default {
  inject: ["root"],
  mixins: [commonDepend],
  props: {
    value: {
      type: [String],
      default: ""
    },
    disabled: {
      type: Boolean,
      default: false
    },
    customModifykey: {
      type: String,
      default: null
    },
    rmb: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
			dialogTableVisible: false,
      tableList: [],
			markTableList: [],
      loading: true,
      tableColumn: [
        { prop: "cod", label: "国家/地区编号", width: '180' },
        { prop: "numcod", label: "国家/地区数字代码", width: '200' },
        { prop: "txt", label: "国家/地区简称", width: 'auto' },
        { prop: "fultxt", label: "国家/地区全称", width: 'auto' }
			],
			formData: {
				cod: '',
				numcod: '',
				txt: '',
			}
    };
  },

  computed: {
    model: {
      get() {
        return this.value;
      },
      set(newVal) {
        this.$emit("input", newVal);
      }
    }
  },

  methods: {
    async showBenCtyDialog() {
			await this.getTableData(true);
			if (this.tableList.length == 1) {
				this.model = this.tableList[0].cod;
			} else {
				this.dialogTableVisible = true;
			}
		},
		handleSearch() {
			this.tableList = this.markTableList.filter((item) => {
				return item.cod.startsWith(this.formData.cod) && item.numcod.startsWith(this.formData.numcod) && item.txt.startsWith(this.formData.txt)
			})
		},
		initFilter() {
			this.tableList = this.markTableList.filter((item) => {
				return item.cod.includes(this.model) || item.numcod.includes(this.model) || item.txt.includes(this.model)
			})
		},
    getTableData(type) {
			return new Promise(async (resolve) => {
				this.loading = true;
				this.tableList = [];
				let params = {
					countryCod: "",
					pageNum: 1,
					pageSize: 10000
				};
				//报送国别查询码值不同
				const res = this.rmb
					? await getCnyctyCod(params)
					: await getBopCtyCountryData(params);
				if (res.respCode == SUCCESS) {
					if (res.data && res.data.list) {
						this.markTableList = res.data.list;
						this.tableList = res.data.list;
						if (type && this.model) {
							this.initFilter()
						}
						resolve(this.tableList)
					}
				}
				this.loading = false;
			})
		},
		handleClose() {
			this.dialogTableVisible = false;
			this.resetFormData()
		},
    //回填数据
    dbClickRow(row) {
      this.model = row.cod;
      this.dialogTableVisible = false;
      this.handleChange();
			this.$emit("handleChange");
			this.resetFormData()
		},
		resetFormData () {
			this.formData.cod = ''
			this.formData.numcod = ''
			this.formData.txt = ''
		},
    handleChange() {
      if (!this.customModifykey) {
        // 添加isModify属性
        this.changeModify();
      }
    }
  }
};
</script>

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