<template>
|
<div>
|
<CreateForms
|
ref="financeForms"
|
:isReset="true"
|
:isView="isView"
|
:screenWidth="screenWidth"
|
:isShowBorder="isShowBorder"
|
:formItems="formItems"
|
:defValues="defValues"
|
:formRules="formRules"
|
@handleSelOnChange="handleSelOnChange"
|
@handleInputChange="handleInputChange"
|
/>
|
</div>
|
</template>
|
|
<script>
|
import CreateForms from "@/views/components/CreateForms";
|
|
import {
|
getDictionaryList,
|
getProvinceCodeList,
|
getCityCodeList,
|
getAreaCodeList
|
} from "@/http/api.js";
|
|
import { individualCusBasicInfo } from "../config/formItem.config";
|
import { indiviualCusBasicInfoDefault } from "../config/defValues.config";
|
import { stockInfoRules } from "../config/rules.config";
|
export default {
|
components: {
|
CreateForms
|
},
|
props: {
|
formItems: {
|
type: Array,
|
default: () => []
|
},
|
defValues: {
|
type: Object,
|
default: () => {}
|
},
|
formRules: {
|
type: Object,
|
default: () => {}
|
},
|
isView: {
|
type: String,
|
default: ""
|
},
|
isShowBorder: {
|
type: String,
|
default: ""
|
},
|
addorupdate: {
|
type: [String],
|
default: ""
|
},
|
screenWidth: {
|
type: Number,
|
default: () => {
|
return 1280;
|
}
|
}
|
},
|
data() {
|
return {
|
// formItems: [...individualCusBasicInfo],
|
// defValues: { ...indiviualCusBasicInfoDefault },
|
// formRules: { ...stockInfoRules },
|
tempValue: ""
|
};
|
},
|
created() {
|
this.init();
|
},
|
watch: {
|
// 户籍
|
"defValues.kosekiProvince": {
|
handler(value, oldValue) {
|
if (value) {
|
this.getCityCodeList("kosekiCity", value);
|
}
|
if (value !== oldValue && oldValue) {
|
this.defValues.kosekiCity = "";
|
}
|
}
|
},
|
"defValues.kosekiCity": {
|
handler(value, oldValue) {
|
if (value) {
|
this.getAreaCodeList("kosekiCounty", value);
|
}
|
if (value !== oldValue && oldValue) {
|
this.defValues.kosekiCounty = "";
|
}
|
}
|
},
|
// 单位
|
"defValues.companyProvince": {
|
handler(value, oldValue) {
|
if (value) {
|
this.getCityCodeList("companyCity", value);
|
}
|
if (value !== oldValue && oldValue) {
|
this.defValues.companyCity = "";
|
}
|
}
|
},
|
"defValues.companyCity": {
|
handler(value, oldValue) {
|
if (value) {
|
this.getAreaCodeList("companyCounty", value);
|
}
|
if (value !== oldValue && oldValue) {
|
this.defValues.companyCounty = "";
|
}
|
}
|
},
|
// 家庭
|
"defValues.familyProvince": {
|
handler(value, oldValue) {
|
if (value) {
|
this.getCityCodeList("familyCity", value);
|
}
|
if (value !== oldValue && oldValue) {
|
this.defValues.familyCity = "";
|
}
|
}
|
},
|
"defValues.familyCity": {
|
handler(value, oldValue) {
|
if (value) {
|
this.getAreaCodeList("familyCounty", value);
|
}
|
if (value !== oldValue && oldValue) {
|
this.defValues.familyCounty = "";
|
}
|
}
|
},
|
// 常住
|
"defValues.permanentProvince": {
|
handler(value, oldValue) {
|
if (value) {
|
this.getCityCodeList("permanentCity", value);
|
}
|
if (value !== oldValue && oldValue) {
|
this.defValues.permanentCity = "";
|
}
|
}
|
},
|
"defValues.permanentCity": {
|
handler(value, oldValue) {
|
if (value) {
|
this.getAreaCodeList("permanentCounty", value);
|
}
|
if (value !== oldValue && oldValue) {
|
this.defValues.permanentCounty = "";
|
}
|
}
|
}
|
},
|
methods: {
|
init() {
|
const { formItems } = this;
|
formItems.forEach(({ name }) => {
|
if (
|
name === "headShip" ||
|
name === "contenttype" ||
|
name === "spousecertType" ||
|
name === "marriage" ||
|
name === "sex" ||
|
name === "idcardAuthority" ||
|
name === "unitproperties" ||
|
name === 'isIndividualhouseHold'
|
) {
|
this.getDictionaryList(name);
|
}
|
if (
|
name === "kosekiProvince" ||
|
name === "companyProvince" ||
|
name === "familyProvince" ||
|
name === "permanentProvince"
|
) {
|
this.getProvinceCodeList(name);
|
}
|
});
|
},
|
async getDictionaryList(name) {
|
// if (name === 'isIndividualhouseHold') {
|
// console.log(name)
|
// }
|
let codeNo = null;
|
if (name === "contenttype" || name === 'spousecertType') {
|
codeNo = "CertType";
|
} else if (name === 'isIndividualhouseHold') {
|
codeNo = 'YesNo'
|
}
|
else if (name === "headShip") {
|
codeNo = "WorkType1";
|
} else if (name === "unitproperties") {
|
codeNo = "UnitProperTies";
|
} else {
|
codeNo = name.substring(0, 1).toUpperCase() + name.substring(1);
|
}
|
// console.log('codeNo',codeNo)
|
const { result } = await getDictionaryList({ codeNo });
|
const list = result.map(item => {
|
return {
|
label: item.itemname,
|
value: item.itemno
|
};
|
});
|
this.updateValue(name, { options: list });
|
},
|
async getProvinceCodeList(name) {
|
const { result } = await getProvinceCodeList({});
|
const list = result.map(item => {
|
return {
|
label: item.itemName,
|
value: item.itemNo
|
};
|
});
|
this.updateValue(name, { options: list });
|
},
|
async getCityCodeList(name, value) {
|
const { result } = await getCityCodeList({
|
codeNo: "AreaCode",
|
itmeNo: value
|
});
|
const list = result.map(item => {
|
return {
|
label: item.itemName,
|
value: item.itemNo
|
};
|
});
|
this.updateValue(name, { options: list });
|
},
|
async getAreaCodeList(name, value) {
|
const { result } = await getAreaCodeList({
|
codeNo: "AreaCode",
|
itmeNo: value
|
});
|
const list = result.map(item => {
|
return {
|
label: item.itemName,
|
value: item.itemNo
|
};
|
});
|
this.updateValue(name, { options: list });
|
},
|
updateValue(index, info) {
|
const { formItems } = this;
|
const nameIndex = formItems.findIndex(({ name }) => name === index);
|
if (nameIndex > -1) {
|
const preInfo = formItems[nameIndex];
|
this.$set(formItems, nameIndex, { ...preInfo, ...info });
|
}
|
},
|
handleSelOnChange(name, value) {},
|
handleInputChange() {}
|
}
|
};
|
</script>
|
|
<style scoped>
|
</style>
|