小牛集卡web 客户端
chenwei
8 days ago 2621fec0d7ce1db0a2302c6c1ac0f08b36ae8a63
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
<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="常规箱子" name="first">
        <div
          class="show-box"
          v-for="(item, index) in commonBox"
          :key="index"
          @click="generalBox(item)"
         
        >
          <div class="box"  :class="{generalactive:item.CntrId==generalActive}">
            <i class="iconfont icon-jizhuangxiang_container"></i>
            <span>{{ item.CntrName }}</span>
            <span>{{ item.CntrSubtitle }}</span>
          </div>
          <!-- <div class="switch">
            <el-switch v-model="value1" active-text="拼车"> </el-switch>
          </div> -->
        </div>
      </el-tab-pane>
      <el-tab-pane label="特种箱" name="second">
        <div
          class="show-box"
          v-for="(sitem, sindex) in allData.SpecialContainerList"
          :key="sindex"
          @click="specialBox(sitem)"
        >
          <div class="box" :class="{generalactive:sitem.CntrId==generalActive}">
            <i class="iconfont icon-jizhuangxiang_container"></i>
            <span>{{ sitem.CntrName }}</span>
            <span>{{ sitem.CntrSubtitle }}</span>
          </div>
          <!-- <div class="switch">
            <el-switch v-model="value1" active-text="拼车"> </el-switch>
          </div> -->
        </div>
      </el-tab-pane>
      <div class="btn">
        <button @click="addBox">添 加</button>
      </div>
    </el-tabs>
  </div>
</template>
<script>
export default {
  data() {
    return {
      activeName: "first",
      value1: true,
      allData: {},
      commonBox: [],
      generalActive:""
    };
  },
  created() {
    this.getBoxList();
  },
  methods: {
    generalBox(item){
       
      if(this.generalActive==""){
           this.generalActive = item.CntrId;
      }else if(this.generalActive==item.CntrId){
        this.generalActive="";
      }else{
        this.generalActive = item.CntrId;
      }
        console.log(this.generalActive);
    },
     specialBox(item){
      
      if(this.generalActive==""){
           this.generalActive = item.CntrId;
      }else if(this.generalActive==item.CntrId){
        this.generalActive="";
      }else{
        this.generalActive = item.CntrId;
      }
       console.log(this.generalActive);
    },
    addBox(){
      if(this.generalActive==""){
        this.$message({message:"请选择箱子",type:"warning"})
      }else{
        this.addNewBox({cnterId:this.generalActive});
           
      }     
    },
    async addNewBox(model){
        
           await this.$axios.post("/api/Order/AddSingeContainner",this.$qs.stringify(model)).then(res=>{
             console.log(res);
             //弹窗里面是属于二级
             this.$parent.$parent.getTempOrder();
             this.$emit("newbox",false);
          
           }).catch(err=>{
             this.$message.error("添加箱子出错啦!");
             console.log(err)
           })
    },
    //请求箱型列表
    async getBoxList() {
      await this.$axios
        .get("/api/HomePage/GetOrderForm")
        .then((res) => {
          var general = res.data.ContainerList;
          for (var j = 0; j < general.length; j++) {
            if (general[j].CnterNub != 0) {
              this.commonBox.push(general[j]);
            }
          }
          this.allData = res.data;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    handleClick(tab, event) {
     
      console.log(tab, event);
    },
  },
};
</script>
<style lang="less" scoped>
.show-box {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.box {
  font-size: 18px;
  border: 1px solid #dfdcdc;
  padding: 5px 10px;
  border-radius: 3px;
  margin-right: 15px;
}
.box i {
  font-size: 20px;
}
.box span:nth-child(2) {
  font-weight: bold;
  margin: 0 5px;
}
.box span:nth-child(3) {
  font-size: 14px;
}
.btn {
  text-align: center;
}
.btn button {
  cursor: pointer;
  border: none;
  outline: none;
  padding: 6px 15px;
  background-color: #f59a23;
  color: #fff;
  font-weight: bold;
  border-radius: 6px;
}
.btn button:hover {
  background-color: #f3a641;
}
.generalactive{
  background-color: #f59a23;
  color: #fff;
}
</style>