小牛集卡web 客户端
chenwei
9 days ago e41faf1640e2e71febf4ba347a301e0c043b6ce9
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<template>
  <div >
    <el-alert style="margin-bottom: 10px;" title="完善箱子信息后将不能修改数量" type="warning" :closable="false">
    </el-alert>
    <el-form 
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="提单号" prop="BolCode">
        <el-input v-model="ruleForm.BolCode"></el-input>
      </el-form-item>
      <el-form-item label="进舱编号" prop="TradeCode">
        <el-input v-model="ruleForm.TradeCode"></el-input>
      </el-form-item>
      <el-form-item label="船代" prop="ShipAgent">
        <el-select v-model="ruleForm.ShipAgent" placeholder="请选择船代">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="箱主" prop="ContainerOwner">
        <el-select v-model="ruleForm.ContainerOwner" placeholder="请选择箱主">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <div v-for="(item, index) in ruleForm.moreBox" :key="index">
        <el-divider>箱子{{ index + 1 }}</el-divider>
        <el-form-item 
         v-if="(type==1&&self)||type==2"
          label="箱号"
          :prop="'moreBox.' + index + '.ContainerNo'"
          :rules="{
            required: true,
            message: '请填写箱号',
            trigger: 'blur',
          }"
        >
          <el-input v-model="item.ContainerNo"></el-input>
        </el-form-item>
        <el-form-item v-if="type==2"
          label="封号"
          :prop="'moreBox.' + index + '.BoxSeal'"
          :rules="{
            required: true,
            message: '请填写封号',
            trigger: 'blur',
          }"
        >
          <el-input v-model="item.BoxSeal"></el-input>
        </el-form-item>
        <el-form-item
          label="重量"
          :prop="'moreBox.' + index + '.Weight'"
          :rules="{
            required: true,
            message: '请填写重量',
            trigger: 'blur',
          }"
        >
          <el-input
            v-model="item.Weight"
            type="number"
            placeholder="请输入数字"
          ></el-input>
        </el-form-item>
      </div>
 
      <el-form-item>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
        <el-button type="primary" @click="submitForm('ruleForm')"
          >确 定</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ruleForm: {
        BolCode: "",
        TradeCode: "",
        ShipAgent: "",
        ContainerOwner: "",
        moreBox: [],
      },
      rules: {
        BolCode: [{ required: true, message: "请输入提单号", trigger: "blur" }],
        TradeCode: [
          { required: true, message: "请输入进舱编号", trigger: "blur" },
        ],
        ShipAgent: [
          { required: true, message: "请选择船代", trigger: "change" },
        ],
        ContainerOwner: [
          { required: true, message: "请选择箱主", trigger: "change" },
        ],
      },
      temId: "",
      self:false
    };
  },
  props: ["demo", "count","type"],
  created() {
    this.$set(this.demo);
  },
  mounted() {
    //  this.$set(this.count);
  },
  watch: {
    demo: {
      handler(val, oldVal) {
        console.log("箱子弹窗的值",val)
        //根据是否为自备箱进行增加或删除输入项
        this.self = val.SelfBox
        this.temId = val.TempOrderID;
        if (val.TempOrderContainer.length != 0) {
          this.ruleForm.BolCode = val.TempOrderContainer[0].BolCode;
          this.ruleForm.TradeCode = val.TempOrderContainer[0].TradeCode;
          this.ruleForm.ShipAgent = val.TempOrderContainer[0].ShipAgent;
          this.ruleForm.ContainerOwner =
            val.TempOrderContainer[0].ContainerOwner;
          if (val.TempOrderContainer.length > 1) {
            console.log("多个箱子");
            this.ruleForm.moreBox = [];
            for (var i = 0; i < val.TempOrderContainer.length; i++) {
              this.ruleForm.moreBox.push({ ContainerNo: "", BoxSeal: "" ,Weight:""});
            }
            for (var j = 0; j < this.ruleForm.moreBox.length; j++) {
              this.ruleForm.moreBox[j].ContainerNo =
                val.TempOrderContainer[j].ContainerNo;
              this.ruleForm.moreBox[j].BoxSeal =
                val.TempOrderContainer[j].BoxSeal;
                 this.ruleForm.moreBox[j].Weight =
                val.TempOrderContainer[j].Weight;
            }
          } else {
            console.log("单个箱子");
            this.ruleForm.moreBox = [{ ContainerNo: "", BoxSeal: "",Weight:"" }];
            this.ruleForm.moreBox[0].ContainerNo =
              val.TempOrderContainer[0].ContainerNo;
            this.ruleForm.moreBox[0].BoxSeal =
              val.TempOrderContainer[0].BoxSeal;
              this.ruleForm.moreBox[0].Weight =
              val.TempOrderContainer[0].Weight;
          }
          console.log(this.ruleForm);
        } else {
          if ((val.ContainerNub)*(val.Container.CnterNub) == 1) {
            this.ruleForm.moreBox = [{ ContainerNo: "", BoxSeal: "",Weight:""  }];
          } else {
            this.ruleForm.moreBox = [];
            for (var i = 0; i < (val.ContainerNub)*(val.Container.CnterNub); i++) {
              this.ruleForm.moreBox.push({ ContainerNo: "", BoxSeal: "",Weight:""  });
            }
          }
        }
      },
      deep: true,
      immediate: true,
    },
    // demo(val) {
    //   console.log(val)
 
    //   this.temId = val.TempOrderID;
    //   if (val.TempOrderContainer.length != 0) {
    //     this.ruleForm.BolCode = val.TempOrderContainer[0].BolCode;
    //     this.ruleForm.TradeCode = val.TempOrderContainer[0].TradeCode;
    //     this.ruleForm.ShipAgent = val.TempOrderContainer[0].ShipAgent;
    //     this.ruleForm.ContainerOwner = val.TempOrderContainer[0].ContainerOwner;
    //     if(val.TempOrderContainer.length>1){
    //       console.log("多个箱子");
    //       this.ruleForm.moreBox=[];
    //       for(var i=0;i<val.TempOrderContainer.length;i++){
    //         this.ruleForm.moreBox.push({ ContainerNo: "", BoxSeal: "" })
    //         //  this.ruleForm.moreBox[i].ContainerNo = val.TempOrderContainer[i].ContainerNo;
    //         //  this.ruleForm.moreBox[i].BoxSeal = val.TempOrderContainer[i].BoxSeal;
    //       }
    //     }else{
    //       console.log("单个箱子")
    //         this.ruleForm.moreBox = [{ ContainerNo: "", BoxSeal: "" }];
    //       //  this.ruleForm.moreBox[0].ContainerNo = val.TempOrderContainer[0].ContainerNo;
    //       //    this.ruleForm.moreBox[0].BoxSeal = val.TempOrderContainer[0].BoxSeal;
    //     }
    //     console.log(this.ruleForm);
    //   }else{
    //     if(val.ContainerNub==1){
    //          this.ruleForm.moreBox = [{ ContainerNo: "", BoxSeal: "" }];
    //     }else{
    //        this.ruleForm.moreBox = [];
    //       for(var i=0;i<val.ContainerNub;i++){
    //           this.ruleForm.moreBox.push({ ContainerNo: "", BoxSeal: "" });
    //       }
    //     }
 
    //   }
    // },
    count: {
      handler(val) {
        this.ruleForm.index = val;
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    infoCancel() {
      this.$emit("info", "");
    },
    infoSure() {
      this.$emit("info", this.boxInfo);
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$confirm("完善箱子信息后将不能修改数量", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.ruleForm.id = this.temId;
              this.$emit("info", this.ruleForm);
              
            })
            .catch(() => {});
          console.log(this.ruleForm);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>
<style lang="less" scoped>
.info {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.info span {
  width: 75px;
  text-align: right;
  margin-right: 6px;
}
.info {
  /deep/.el-input {
    width: 300px;
  }
}
.btns {
  display: flex;
  justify-content: flex-end;
}
</style>