小牛集卡web 客户端
chenwei
2021-06-04 7f5659967e4b5864d1c56a6072ebfe3abe4702dc
src/components/agopage/comment/InfoDialog.vue
@@ -1,7 +1,8 @@
<template>
  <div>
    <el-form
  <div >
    <el-alert style="margin-bottom: 10px;" title="完善箱子信息后将不能修改数量" type="warning" :closable="false">
    </el-alert>
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
@@ -28,7 +29,8 @@
      </el-form-item>
      <div v-for="(item, index) in ruleForm.moreBox" :key="index">
        <el-divider>箱子{{ index + 1 }}</el-divider>
        <el-form-item
        <el-form-item
         v-if="(type==1&&self)||type==2"
          label="箱号"
          :prop="'moreBox.' + index + '.ContainerNo'"
          :rules="{
@@ -39,7 +41,7 @@
        >
          <el-input v-model="item.ContainerNo"></el-input>
        </el-form-item>
        <el-form-item
        <el-form-item v-if="type==2"
          label="封号"
          :prop="'moreBox.' + index + '.BoxSeal'"
          :rules="{
@@ -49,6 +51,21 @@
          }"
        >
          <el-input v-model="item.BoxSeal"></el-input>
        </el-form-item>
        <el-form-item
          label="重量"
          :prop="'moreBox.' + index + '.BoxSeal'"
          :rules="{
            required: true,
            message: '请填写重量',
            trigger: 'blur',
          }"
        >
          <el-input
            v-model="item.BoxSeal"
            type="number"
            placeholder="请输入数字"
          ></el-input>
        </el-form-item>
      </div>
@@ -84,69 +101,64 @@
          { required: true, message: "请选择箱主", trigger: "change" },
        ],
      },
      temId:"",
      temId: "",
    };
  },
  props: ["demo", "count"],
  created(){
  props: ["demo", "count","type","self"],
  created() {
    this.$set(this.demo);
  },
  mounted(){
//  this.$set(this.count);
  mounted() {
    //  this.$set(this.count);
  },
  watch: {
    demo:{
       handler(val,oldVal){
      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: "" })
          }
           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;
          }
        }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++){
    demo: {
      handler(val, oldVal) {
        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: "" });
            }
            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;
            }
          } 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: "" });
            }
          }
        }
      }
       },
       deep:true,
        immediate :true
      },
      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;
@@ -157,7 +169,7 @@
    //       console.log("多个箱子");
    //       this.ruleForm.moreBox=[];
    //       for(var i=0;i<val.TempOrderContainer.length;i++){
    //         this.ruleForm.moreBox.push({ ContainerNo: "", BoxSeal: "" })
    //         this.ruleForm.moreBox.push({ ContainerNo: "", BoxSeal: "" })
    //         //  this.ruleForm.moreBox[i].ContainerNo = val.TempOrderContainer[i].ContainerNo;
    //         //  this.ruleForm.moreBox[i].BoxSeal = val.TempOrderContainer[i].BoxSeal;
    //       }
@@ -177,17 +189,16 @@
    //           this.ruleForm.moreBox.push({ ContainerNo: "", BoxSeal: "" });
    //       }
    //     }
    //   }
    // },
    count:{
        handler(val){
          this.ruleForm.index = val;
        },
         deep:true,
        immediate :true
    count: {
      handler(val) {
        this.ruleForm.index = val;
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    infoCancel() {
@@ -199,17 +210,17 @@
    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)
          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;