zuozhengqing
2023-12-12 b4b3cb3641ecdf56cdfdf3532e5acf4af46fbe48
src/views/overview/AddOverviewDialog.vue
@@ -6,7 +6,7 @@
      <div slot="title" class="dialog-header">
        <span>{{ editCommonConfig.title === "查看" ? editCommonConfig.title : editCommonConfig.title + addName }}</span>
        <div class="header_btns">
          <span class="btn" @click="btnPrint">
          <span class="btn" :style="{cursor:thatCursor,color:thatColor}" @click="btnPrint" :disabled="true">
            <i class="el-icon-printer"></i>
            <span>打印</span>
          </span>
@@ -183,13 +183,13 @@
            </div>
            <!-- 物流信息 -->
            <div v-if="activeName === 'two' && this.workType === 2">
              <el-form label-position="right" :model="shipmentsInfo" label-width="120px" size="mini"
              <el-form :rules="rules2" ref="shipmentsInfo" label-position="right" :model="editConfig.infomation" label-width="120px" size="mini"
                style="margin-top: 20px;">
                <el-col :span="12">
                  <el-form-item label="承运商">
                    <el-select size="mini" :disabled="!showFooter" v-model="editConfig.infomation.logisticCompanyId"
                      placeholder="请选择" style="width: 90%;">
                      <el-option v-for="item in shipmentsInfo.carrier" :key="item.id" :label="item.name" :value="item.id">
                      <el-option v-for="item in editConfig.infomation.carrier" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
@@ -207,7 +207,7 @@
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="联系电话">
                  <el-form-item label="联系电话" prop="receiverPhone">
                    <el-input style="width: 90%;" :disabled="!showFooter"
                      v-model="editConfig.infomation.receiverPhone"></el-input>
                  </el-form-item>
@@ -220,13 +220,13 @@
                </el-col>
                <el-col :span="12">
                  <el-form-item label="重量">
                    <el-input style="width: 90%;" :disabled="!showFooter"
                    <el-input style="width: 90%;" :disabled="!showFooter" type="number"
                      v-model="editConfig.infomation.weight"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="物流重量">
                    <el-input style="width: 90%;" :disabled="!showFooter"
                    <el-input style="width: 90%;" :disabled="!showFooter" type="number"
                      v-model="editConfig.infomation.logisticWeight"></el-input>
                  </el-form-item>
                </el-col>
@@ -257,7 +257,7 @@
      <!-- 尾 -->
      <div slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" size="small" @click="editConfig.visible = false">保并提交审批</el-button> -->
        <el-button type="primary" size="small" @click="saveClick('form')" :disabled="!showFooter">保存</el-button>
        <el-button type="primary" size="small" @click="saveClick" :disabled="!showFooter">保存</el-button>
        <el-button size="small" @click="editConfig.visible = false">取消</el-button>
      </div>
    </el-dialog>
@@ -316,7 +316,18 @@
        operationDate: [{ required: true, message: "请选择日期", trigger: "change" }],
        toLocationId: [{ required: true, message: "请选择仓库位置", trigger: "change" }],
        fromLocationId: [{ required: true, message: "请选择源位置", trigger: "change" }],
        operationTypeId: [{ required: true, message: "请选择入库类型", trigger: "change" }]
        operationTypeId: [{ required: true, message: "请选择入库类型", trigger: "change" }],
      },
      rules2:{
        receiverPhone:  [
          // {required: true, message: "请输入手机号", trigger: "change" },
          {
            pattern:
              /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/,
            message: "请输入正确的手机号",
            trigger: ["blur",'change' ],
          },
        ]
      },
      companyOptions: [], // 公司
      supplierOptions: [],//供应商
@@ -349,14 +360,16 @@
        waybillNumber: '',
        weight: 0,
        logisticWeight: 0,
        receiverPhone:''
      },
      showCancel: false, // 取消是否可以显示
      list: [],
      pdfParams:{}
      pdfParams:{},
      thatCursor:this.workType===3?"no-drop":'pointer',
      thatColor:this.workType===3?'#ccc':'#000'
    }
  },
  created() {
    localStorage.removeItem('pdfParams');
    this.getCompanyList()
    this.setStatusList()
    this.setTableForm()
@@ -371,7 +384,6 @@
  },
  methods: {
    setStatusList() {
      console.log(this.editConfig.infomation, "edit")
      if (this.editConfig.infomation.status === 5) {
        this.list = [
          { label: "草稿", status: "todo", value: 1 },
@@ -523,40 +535,56 @@
    async getLogisticCompanyList() {
      await getLogisticCompanyList().then((res) => {
        if (res.code === 200) {
          this.shipmentsInfo.carrier = res.data
          this.editConfig.infomation.carrier = res.data
        }
      })
    },
    // 保存
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          for (let i = 0; i < this.tableData.length; i++) {
            if (this.tableData[i].productName.length === 0) {
              this.isNoProduct = true
              break
            } else {
              this.isNoProduct = false
            }
          }
          if (this.isNoProduct) {
            this.$message.error("请添加明细行或选择产品不能为空")
    saveClick() {
      let validArr=[]
      if(this.workType === 2){
         console.log("出库")
         validArr=[this.$refs.form.validate(),this.$refs.shipmentsInfo.validate()]
      }else{
        console.log("入库")
        validArr=[this.$refs.form.validate()]
      }
      console.log(validArr,"xxx")
      Promise.all(validArr)
      .then((results) => {
        console.log(results,"执行成功")
        for (let i = 0; i < this.tableData.length; i++) {
          if (this.tableData[i].productName.length === 0) {
            this.isNoProduct = true
            break
          } else {
            let requestUrl = this.editConfig.title === "新建" ? addOperation : updateOperation
            let params = this.saveParams()
            requestUrl({
              ...params
            }).then((res) => {
              console.log(res)
              this.editConfig.visible = false
              if (res.code === 200) {
                this.$message.success("添加成功")
                this.$parent.getData()
              }
            })
            this.isNoProduct = false
          }
        }
        if (this.isNoProduct) {
          this.$message.error("请添加明细行或选择产品不能为空")
        } else {
          let requestUrl = this.editConfig.title === "新建" ? addOperation : updateOperation
          let params = this.saveParams()
          requestUrl({
            ...params
          }).then((res) => {
            console.log(res)
            this.editConfig.visible = false
            if (res.code === 200) {
              if(this.editConfig.title === "新建"){
                this.$message.success("添加成功")
              }else {
                this.$message.success("编辑成功")
              }
              this.$parent.getData()
            }
          })
        }
      })
      .catch((error) => {
        console.error('表单校验未通过:', error);
      });
    },
    saveParams() {
      let data = this.editConfig.infomation
@@ -793,27 +821,32 @@
    },
    //打印
    async btnPrint() {
      localStorage.removeItem('pdfParams');
      try {
        let res = await printReceipts(this.editCommonConfig.infomation.id);
        console.log(res);
        if (res.code === 200) {
          console.log(this.editConfig.infomation.baseOperationType,"类型")
          let pdfParams = {
            url: res.data,
            baseOperationType: this.editConfig.infomation.baseOperationType || undefined,
            cutAfterWidth: this.editConfig.infomation.baseOperationType === 2 ? 50.8 : 53.3
          };
          localStorage.setItem('pdfParams', JSON.stringify(pdfParams));
      if(this.workType!==3){
        localStorage.removeItem('pdfParams');
        try {
          let res = await printReceipts(this.editCommonConfig.infomation.id);
          console.log(res);
          if (res.code === 200) {
            console.log(this.editConfig.infomation.baseOperationType,"类型")
            let pdfParams = {
              url: res.data,
              baseOperationType: this.editConfig.infomation.baseOperationType || undefined,
              cutAfterWidth: this.editConfig.infomation.baseOperationType === 2 ? 50.8 : 53.3
            };
            var { href } = this.$router.resolve({
                path: '/overview/previewExcel',
                query:{
                  ...pdfParams
                }
            });
            window.open(href, '_blank');
          }
        } catch (error) {
          console.error(error);
        }
      } catch (error) {
        console.error(error);
      } finally {
        var { href } = this.$router.resolve({
            name: 'previewExcel',
        });
        window.open(href, '_blank');
      }
    }
  }
}
@@ -837,6 +870,7 @@
    .btn:nth-of-type(2) {
      cursor: no-drop;
      color:#ccc;
    }
  }
}