liangjin
2021-03-22 39f63c38738cd40b142458708dee9bfbf8d1db1a
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<template>
<div class="stores-detail h-100-g">
 
  <v-navbar title="门店详情" fixed rightText='保存' @right-click="Save"></v-navbar>
 
  <div class="cell-group">
    <v-cell v-model="form.storeName" :max="20" label='门店名称' :readonly="true" icon='iconyonghu' placeholder='门店名称'></v-cell>
    <v-cell  label='所在地区'  icon='icondingwei'  placeholder='所在地区' @click.native="isShowArea = true;">
      <div slot="v-cell-right" class="flex-center-g">
        <div>{{form.areaText}}</div>
        <svg class="icon" aria-hidden="true" style="width:18px;height:18px;fill:#999;">
          <use xlink:href="#iconyou"></use>
        </svg>
      </div>
    </v-cell>
    <v-cell v-model="form.dtlAddr" :max="30" label='详细地址'  icon='icontishi' placeholder='详细地址'></v-cell>
  </div>
 
 
  <div class="cell-group">
    <v-cell v-model="form.priName" :max="6" label='负责人姓名' :readonly="true" placeholder='负责人姓名'></v-cell>
    <v-cell v-model="form.priMblNo" :max="11" type="tel" label='负责人手机号' :readonly="true" placeholder='负责人手机号'></v-cell>
    <v-cell v-model="form.priEmail" :max="50" label='联系邮箱' :readonly="true" placeholder='联系邮箱'></v-cell>
    <v-cell v-model="form.priIdNo" :max="18" label='负责人身份证号' :readonly="true" placeholder='负责人身份证号'></v-cell>
    <v-cell v-model="form.outChanNo" :max="18" label='渠道编码' :readonly="true" placeholder='渠道编码'></v-cell>
  </div>
 
 
  <footer class="flex-center-g footer">
    <van-button class="btn left" @click="freeze">{{ menText }}</van-button>
    <van-button class="btn right" @click="$router.push('/main/home')">订单查询</van-button>
  </footer>
 
 
  <van-dialog
      class="setting-box-dialog"
      v-model="dialogShow"
      show-cancel-button
      :message='Msg'
      @confirm="onConfirm"
  >
  </van-dialog>
 
 
  <van-popup v-model="isShowArea" position="bottom" :close-on-click-overlay="false">
    <van-area ref='Area' :area-list='areaList' @cancel="closeAreaModal" @confirm="setAreaValue"></van-area>
  </van-popup>
 
</div>
</template>
 
<script>
  import { mapState } from 'vuex';
  export default {
    name: "stores-detail",
    data(){
      return {
        isShowArea:false,
        dialogShow:false,
        menText:'',
        Status:null,
        Msg:'',
        Btn:false,
 
        form:{
          areaText:'',//地区文字展示
          storeName:'', //门店名称
          dtlAddr:'',   //详细地址
          priName:'',   //负责人姓名
          priEmail:'',  //联系邮箱
          priMblNo:'',  //负责人手机
          priIdNo:'',  //负责人身份证号
          provCode: '',
          cityCode: '',
          areaCode: '',
          outChanNo:'',
        },
 
        rule:[
          {key:"dtlAddr",message:"请输入详细地址",type:"isEmpty"},
        ]
      }
    },
    computed:{
      ...mapState(['areaList'])
    },
    created(){
      this.init();
    },
    methods:{
      init(){
        this.$api.storeDtl({storeId: this.$route.query.storeId}).then((res) => {
          let data = res.body,
              addr = data.addr;
          this.Status = data.freezeStatus;
          data.freezeStatus ? this.menText = '冻结门店':this.menText = '启用门店';
          this.form = {
            areaText:addr.province.name + '-' + addr.city.name + '-' + addr.area.name,  //地区文字展示
            storeName:data.storeName, //门店名称
            dtlAddr:addr.dtlAddr,   //详细地址
            priName:data.priName,   //负责人姓名
            priEmail:data.priEmail,  //联系邮箱
            priMblNo:data.priMblNo,  //负责人手机
            priIdNo:data.priIdNo,  //负责人身份证号
            provCode: addr.province.code,
            cityCode: addr.city.code,
            areaCode: addr.area.code,
            provName:addr.province.name,
            cityName:addr.city.name,
            areaName:addr.area.name,
            outChanNo:data.outChanNo
          }
        })
      },
 
 
      freeze(){
        this.dialogShow = !this.dialogShow;
        this.Msg = `请问是否确认${this.Status ? '冻结' : '启用'}该门店?`;
      },
 
 
      //冻结/启用  门店
      onConfirm() {
        if(this.Btn2){return}
        this.Btn2 = true;
        this.$api.channSwitchStatus({
            orgId: this.$route.query.storeId,
            orgType: 4,
            statusType: this.Status ? 0 : 1
          })
          .then((res) => {
            this.Btn2 = false;
            this.$notify_success(`${ this.Status ? '冻结' : '启用'}门店成功`)
            this.Status =  this.Status ? 0 : 1;
            this.menText = this.Status ? '冻结门店' :'启用门店';
          });
      },
 
 
      // 保存门店
      Save(){
        if(this.Btn){return}
        this.Btn = true;
        let list = {
          addr:{
            province:{
              code:this.form.provCode,
              name:this.form.provName
            },
            city:{
              code:this.form.cityCode,
              name:this.form.cityName
            },
            area:{
              code:this.form.areaCode,
              name:this.form.areaName
            },
            dtlAddr:this.form.dtlAddr
          },
          storeId:this.$route.query.storeId
        };
 
        if(this.$validator(list.addr,this.rule).check(item=>{
          this.$notify(item.message);
        })){
          this.$api.storeEdit(list).then((res) => {
            this.Btn = false;
            this.$notify_success('保存成功!');
          });
        }
      },
 
 
 
      //关闭地区弹窗
      closeAreaModal(){
        this.isShowArea = false;
        this.$refs.Area.reset()
      },
 
      //保存 地区选择
      setAreaValue(arr){
        this.form.areaText = arr[0].name + '-' +arr[1].name +'-'+ arr[2].name;
        this.form.provCode= arr[0].code;
        this.form.cityCode= arr[1].code;
        this.form.areaCode= arr[2].code;
        this.isShowArea = false;
        this.$refs.Area.reset()
      },
 
 
 
    }
  }
</script>
 
<style scoped lang="less">
.stores-detail{
  background-color: @c-bg-f5;
  padding-top: 44px;
 
  .cell-group {
    margin: 10px 8px 0;
  }
 
 
 
 
 
 
  .footer{
    margin-top: 60px;
    padding-bottom: 30px;
    .btn{
      width: 170px;
      height: 44px;
      border: none;
      font-size: @font-16;
      &.left{
        background-color: @c-bg-eee;
        color: @c-text-666;
        border-radius:22px 0px 0px 22px;
      }
      &.right{
        background-color: @c-bg-default;
        color: @c-text-fff;
        border-radius:0px 22px 22px 0px;
      }
    }
  }
 
 
 
}
</style>