yxh
2023-09-01 a2f16cbdc7b6ee0623d9071e1b7ab41285667eed
src/views/project/travelexpenseapply/travelexpensedetail/index.vue
@@ -960,14 +960,32 @@
        <div v-if="this.previewpdf" class="pdfimgmin">
          <!-- <img :src="pdfimg" /> -->
          <el-image
            style="width: 100px; height: 100px"
            style="width: 95%; height: 90%"
            :src="pdfimg"
            :preview-src-list="pdfimgsrcList"
          >
            <!-- <div slot="error" class="image-slot">
              <i class="el-icon-picture-outline"></i>
            </div> -->
          </el-image>
        </div>
        <div v-else class="pdfimgmins">{{ hintitle }}</div>
      </div>
    </el-dialog>
    <el-dialog title="提示" :visible.sync="Savereminder" width="30%">
      <el-alert
        :title="
          '您已添加' +
            totalquantity +
            '条数据,为防止数据丢失是否提交保存再继续添加。'
        "
        type="warning"
      >
      </el-alert>
      <span slot="footer" class="dialog-footer">
        <el-button @click="unsave">取 消</el-button>
        <el-button type="primary" @click="Savenow">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
@@ -1054,6 +1072,9 @@
        label: ""
      },
      pdfimgsrcList: [],
      Savereminder: false, //提醒保存弹框
      Reminderquantity: 0, //提醒数量
      totalquantity: 0, //总数量
      hintitle: "选中左侧已上传文件预览查看",
      atpresent: "",
@@ -1071,6 +1092,8 @@
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 网络请求头
      Networkheader: null,
      // 当前单据ID
      curId: 0,
@@ -1165,6 +1188,8 @@
  },
  created() {
    this.Getnetworkheader();
    //获取记录列表
    // this.getList();
@@ -1222,7 +1247,20 @@
  methods: {
    handleUploadError() {},
    // 获取请求头
    Getnetworkheader() {
      console.log(window.location.href);
      let string = window.location.href;
      if (string.includes("9091")) {
        const index = string.indexOf("9091");
        this.Networkheader = string.slice(0, index + 4); // 截取9091及其前部字符
        console.log(this.Networkheader);
      } else {
        const index = string.indexOf("8032");
        this.Networkheader = string.slice(0, index + 4); // 截取8032及其前部字符
        console.log(this.Networkheader);
      }
    },
    remove(file, fileList) {
      const rbDetails = [...this.rbDetails];
      this.fileListto.splice(this.fileListto.indexOf(file), 1);
@@ -1236,13 +1274,19 @@
    //文件上传成功回调
    uploadSccess(response, file, fileList) {
      this.rbDetails;
      //获取票据信息位置
      if (response.code == 200) {
        this.form.filename = file.raw.name;
        this.$modal.msgSuccess(response.msg);
        this.fileListto.push({ name: file.name, url: response.url });
        this.fileListto.push({
          name: file.name,
          url: response.fileName
        });
        // this.fileListto.push({
        //   name: file.name,
        //   url: response.url
        // });
        this.rbDetails[this.atpresent].annexfilesList = this.fileListto;
      } else {
        console.log(response.msg);
@@ -1252,8 +1296,14 @@
    Filepopup(index, rows, row) {
      this.atpresent = index;
      this.pdfVisible = true;
      console.log(this.rbDetails[index]);
      if (this.rbDetails[index].annexfilesList) {
        this.fileListto = this.rbDetails[index].annexfilesList;
        console.log(this.fileListto);
        this.pdfimg = this.Networkheader + "/prod-api" + this.fileListto[0].url;
        console.log(this.pdfimg);
        this.pdfimgsrcList = [];
        this.pdfimgsrcList.push(this.pdfimg);
      } else {
        this.fileListto = [];
        this.pdfimg = "";
@@ -1273,11 +1323,12 @@
      } else if (name[1] == "jpg" || "png") {
        this.previewpdf = true;
        if (item.url) {
          this.pdfimg = item.url;
          this.pdfimgsrcList=[]
          this.pdfimgsrcList.push(item.url);
          this.pdfimg = this.Networkheader + "/prod-api" + item.url;
          this.pdfimgsrcList = [];
          this.pdfimgsrcList.push(this.pdfimg);
          console.log(this.pdfimg);
        } else {
          this.pdfimg = item.response.url;
          this.pdfimg = this.Networkheader + "/prod-api" + item.response.url;
        }
      } else {
        this.hintitle = "当前文件暂不支持预览";
@@ -1578,6 +1629,7 @@
      this.loading = true;
      listReimbursement(this.queryParams).then(response => {
        this.reimbursementList = response.rows;
        console.log(this.reimbursementList);
        this.total = response.total;
        this.loading = false;
      });
@@ -1717,6 +1769,7 @@
        //获取报销明细信息
        getReimbursementdetaillist(curId).then(res => {
          this.rbDetails = res.data;
          console.log(this.rbDetails);
          if (this.rbDetails.length == 0) {
            this.addDetailRow(0);
          }
@@ -2094,6 +2147,100 @@
        })
        .catch(() => {});
    },
    // 取消提醒
    unsave() {
      this.Savereminder = false;
      this.Reminderquantity = 0;
    },
    // 接受提醒立刻保存
    Savenow() {
      this.Savereminder = false;
      this.Reminderquantity = 0;
      this.totalquantity = 0;
      this.$refs["form"].validate(valid => {
        if (valid) {
          //票据文件处理
          let list = this.fileListto;
          console.log(list);
          //校验请款金额合计是否等于报销单金额
          if (
            this.form.amountrequested !=
            this.rbPayees.reduce(
              (amount, item) => amount + Number(item.amount),
              0.0
            )
          ) {
            this.$message({
              message:
                "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!",
              type: "warning"
            });
            return;
          }
          const rbDetails = [...this.rbDetails];
          const rbPayees = [...this.rbPayees];
          if (this.form.id != null) {
            console.log(this.form);
            updateReimbursement(this.form);
            //   .then(res => {
            //保存明细
            for (let i = 0; i < rbDetails.length; i++) {
              if (rbDetails[i].rbid != null) {
                updateReimbursementdetail(rbDetails[i]);
              } else {
                //rbid关联主表Id
                rbDetails[i].rbid = this.form.id;
                addReimbursementdetail(rbDetails[i]);
              }
            }
            //保存账户
            for (let i = 0; i < rbPayees.length; i++) {
              if (rbPayees[i].rbid != null) {
                updateReimbursementpayee(rbPayees[i]);
              } else {
                //rbid关联主表Id
                rbPayees[i].rbid = this.form.id;
                addReimbursementpayee(rbPayees[i]);
              }
            }
            this.$modal.msgSuccess("修改报销单保存成功!");
            // this.getList();
            // })
            // .catch(err => {
            //   this.$modal.msgError("修改报销单保存失败!");
            // });
          } else {
            this.form.recordstatus = -1;
            addReimbursement(this.form)
              .then(response => {
                //保存明细
                for (let i = 0; i < rbDetails.length; i++) {
                  //rbid关联主表Id
                  rbDetails[i].rbid = response.data;
                  addReimbursementdetail(rbDetails[i]);
                }
                //保存账号
                for (let i = 0; i < rbPayees.length; i++) {
                  //rbid关联主表Id
                  rbPayees[i].rbid = response.data;
                  addReimbursementpayee(rbPayees[i]);
                }
                this.$modal.msgSuccess("新增报销单保存成功!");
              })
              .catch(err => {
                this.$modal.msgError("新增报销单保存失败!");
              });
          }
        }
      });
    },
    //新增一行
    addDetailRow(rowIndex) {
@@ -2137,11 +2284,17 @@
        personname: null,
        destination: null
      };
      if (this.Reminderquantity >= 5) {
        this.Savereminder = true;
        return;
      }
      if (rowIndex == undefined || rowIndex == null || rowIndex < 0) {
        this.rbDetails.push(rowData);
      } else {
        this.rbDetails.splice(rowIndex + 1, 0, rowData);
      }
      this.Reminderquantity++;
      this.totalquantity++;
      for (let i = 0; i < this.rbDetails.length; i++) {
        this.rbDetails[i].orderno = i + 1;
      }
@@ -2160,11 +2313,17 @@
        personname: null,
        amount: null
      };
      if (this.Reminderquantity >= 5) {
        this.Savereminder = true;
        return;
      }
      if (rowIndex == undefined || rowIndex == null || rowIndex <= 0) {
        this.rbPayees.push(rowData);
      } else {
        this.rbPayees.splice(rowIndex + 1, 0, rowData);
      }
      this.Reminderquantity++;
      this.totalquantity++;
      for (let i = 0; i < this.rbPayees.length; i++) {
        this.rbPayees[i].orderno = i + 1;
      }