@@ -340,10 +360,6 @@
export default {
props: {
- formType:{
- type:String,
- default:'add'
- },
source: {
//展示来源:manage 管理平台 visiual 可视化平台
type: String,
@@ -352,9 +368,16 @@
},
data() {
+ let orgOptionProps = {
+ multiple: false,
+ value: 'agencyId',
+ label: 'agencyName',
+ children: 'subAgencyList',
+ checkStrictly: true
+ }
return {
+ formType:'',
btnDisable: false,
-
formData: {
name: "",
idType: null,
@@ -373,8 +396,11 @@
occupation: "",
retireTime: "",
remark: "",
- agencyId: this.$store.state.user.agencyId,
+ agencyId:'',
},
+ agencyIdTemp:[],
+ orgOptionProps ,
+ orgOptions: [],
genderList,
binaryOptionList,
dataRule: {
@@ -400,8 +426,9 @@
watch: {},
components: {},
- async created() {
- await this.getDicts();
+ created() {
+ this.getDicts();
+ this.getOrgTreeList()
},
async mounted() {
this.startLoading();
@@ -418,8 +445,9 @@
const url = `/actual/base/resiCategorized/subsistenceAllowance/detail/${categorizedResiId}`;
const { data, code, msg } = await requestGet(url);
if (code === 0) {
- console.log(data);
this.formData = { ...data };
+ await this.setAgencyIdFromLastLayerId(data.agencyId)
+ console.log(this.agencyIdTemp);
} else {
this.$message.error(msg);
}
@@ -491,6 +519,48 @@
resetData() {
this.formData = {};
},
+ getOrgTreeList () {
+ this.$http
+ .post('/gov/org/customeragency/agencygridtree', {})
+ .then(({ data: res }) => {
+ if (res.code !== 0) {
+ return this.$message.error(res.msg)
+ } else {
+ console.log('获取组织树成功', res.data)
+ this.orgOptions = []
+ this.orgOptions.push(res.data)
+ }
+ })
+ .catch(() => {
+ return this.$message.error('网络错误')
+ })
+ },
+ findPathInOptions(agencyId, options) {
+ console.log(agencyId,options);
+ for (let i = 0; i < options.length; i++) {
+ console.log(options[i]);
+ if (options[i].agencyId === agencyId) {
+ console.log(agencyId);
+ return [agencyId];
+ } else if (options[i].subAgencyList) {
+ const pathFromChild = this.findPathInOptions(agencyId, options[i].subAgencyList
+);
+ if (pathFromChild.length) {
+ return [options[i].agencyId].concat(pathFromChild);
+ }
+ }
+ }
+ return [];
+ },
+
+ async setAgencyIdFromLastLayerId(lastLayerId) {
+ console.log(lastLayerId,'事件');
+ this.agencyIdTemp = await this.findPathInOptions(lastLayerId, this.orgOptions);
+ },
+ handleChangeAgency(val){
+ this.formData.agencyId = val[val.length -1]
+ console.log(this.formData.agencyId);
+ },
// 开启加载动画
startLoading() {
loading = Loading.service({
@@ -509,7 +579,7 @@
};
-