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
| <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="is_edit = true" 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" :user_info="user_info" :branchList="branchList" @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: '',
| user_id: 0,
| branch_type: 20,
| is_recycle: 0,
| password: '',
| },
| },
| 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.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;
| }
| })
| .catch(error => {
|
| });
| },
|
| 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>
|
|