<template>
|
<div>
|
<el-drawer :visible.sync="drawerVisible" :with-header="false" @close="drawerClose(false)" :direction="direction" :destroy-on-close="true" size="1000px" custom-class="drawer-box">
|
<div class="d-b-c pt16 pb16 border-b-e">
|
<div class="f16 fb">{{ form.branch.name }}</div>
|
<div>
|
<el-button size="small" @click="is_edit = false" v-if="is_edit">取消</el-button>
|
<el-button size="small" type="success" @click="onSubmit" v-if="is_edit">完成</el-button>
|
<el-button size="small" type="primary" @click="onEdit" v-else>编辑</el-button>
|
<el-button size="small" @click="drawerClose(false)">关闭</el-button>
|
<!-- <el-dropdown>
|
<el-button size="small">
|
<i class="el-icon-more"></i>
|
</el-button>
|
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-item>修改管理员密码</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown> -->
|
</div>
|
</div>
|
<Edit ref="editForm" v-if="is_edit" :form="form" :areaList="areaList" :branchList="branchList" :user_info="user_info" @success="editSuccess"></Edit>
|
<Detail v-else :detail="detail"></Detail>
|
</el-drawer>
|
</div>
|
</template>
|
|
<script>
|
import BranchApi from '@/api/branch.js';
|
import {formatModel} from '@/utils/base.js'
|
import Edit from './part/edit.vue';
|
import Detail from './part/detail.vue';
|
export default {
|
components: {
|
Edit,
|
Detail
|
},
|
data() {
|
return {
|
drawerVisible: false, // 抽屉是否显示
|
direction: 'rtl', // 抽屉呼出方向
|
/*form表单数据*/
|
form: {
|
branch_id: 0,
|
branch:{
|
user_name: '',
|
name: '',
|
link_name: '',
|
link_phone: '',
|
parent_branch_id: '',
|
province_id: '',
|
city_id: '',
|
region_id: '',
|
address:'',
|
description: '',
|
// category_id: '',
|
// user_id: 0,
|
branch_type: 20,
|
is_recycle: 0,
|
password: '',
|
logo_id: '',
|
},
|
},
|
detail: {},
|
/*是否打开添加弹窗*/
|
open_add: false,
|
branchList: [], // 总会列表
|
// category: [],
|
loading: false,
|
open_user: false,
|
user_info: {},
|
/*省市区*/
|
areaList: [],
|
is_edit: false,
|
};
|
},
|
props: ['open'],
|
watch:{
|
open:function(n, o){
|
this.drawerVisible = this.open;
|
}
|
},
|
|
methods: {
|
/*获取参数*/
|
getData(branch_id) {
|
let self = this;
|
BranchApi.toEditBranch({
|
branch_id: branch_id
|
}, true)
|
.then(res => {
|
self.detail = res.data.model;
|
self.form.branch_id = branch_id;
|
self.form.branch = formatModel(self.form.branch, res.data.model);
|
self.form.branch.branch_type = self.form.branch.branch_type.value;
|
self.form.logo_file_path = self.detail.logo ? self.detail.logo.file_path : '';
|
self.form.branch.password = '';
|
if (self.form.branch.region_id == 0) {
|
self.form.branch.region_id = '';
|
}
|
self.branchList = res.data.branchList;
|
self.areaList = res.data.areaList;
|
if(res.data.model.superUser){
|
self.form.branch.user_id = res.data.model.superUser.user_id;
|
self.form.branch.user_name = res.data.model.superUser.user_name;
|
self.user_info.avatarUrl = res.data.model.superUser.user.avatarUrl;
|
}
|
console.log(self.form)
|
})
|
.catch(error => {
|
|
});
|
},
|
|
onEdit() {
|
this.is_edit = true;
|
console.log(this.form.branch.logo)
|
// this.$refs.editForm.logo_file_path = this.form.branch.logo ? this.form.branch.logo.file_path : '';
|
},
|
|
onSubmit(){
|
let self = this;
|
self.$refs.editForm.onSubmit();
|
setTimeout(()=>{
|
self.getData(self.form.branch_id);
|
},500)
|
},
|
|
// 编辑成功后回调
|
editSuccess() {
|
this.is_edit = false;
|
this.$emit('getTableList');
|
},
|
|
/*关闭抽屉*/
|
drawerClose(e) {
|
this.$emit('closeDrawer', e);
|
},
|
}
|
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.basic-setting-content {}
|
|
.product-add {
|
padding-bottom: 50px;
|
}
|
|
.img {
|
margin-top: 10px;
|
}
|
</style>
|