11
WXL
2023-09-04 1fc6fb99de36cc345e23f8ca5a6cbb9bc1828c07
src/views/project/travelexpenseapply/travelexpensedetail/index.vue
@@ -216,6 +216,7 @@
            :data="rbDetails"
            ref="table"
            border
            max-height="400"
            highlight-current-row
            :summary-method="getSummaries"
            show-summary
@@ -658,6 +659,7 @@
          <el-table
            :data="rbPayees"
            border
            max-height="400"
            highlight-current-row
            :summary-method="getSummaries"
            show-summary
@@ -916,7 +918,14 @@
      </div>
    </div>
    <el-dialog :title="pdftitle" :visible.sync="pdfVisible" width="50%">
    <el-dialog
      v-dialogDrags
      :modal="false"
      :close-on-click-modal="false"
      :title="pdftitle"
      :visible.sync="pdfVisible"
      width="60%"
    >
      <div class="pdfimg">
        <div class="box-pdf">
          <div>
@@ -925,7 +934,9 @@
              class="upload-demo"
              :action="uploadFileUrl"
              :file-list="fileListto"
              :show-file-list="false"
              multiple
              drag
              :limit="20"
              :headers="headers"
              :on-success="
@@ -939,22 +950,59 @@
              :on-remove="remove"
              accept="image/*,.pdf"
            >
              <el-button
                :disabled="operationType == 'detail'"
                size="small"
                type="primary"
                >上传</el-button
              >
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">
                将票据拖到此处,或
                <em
                  ><el-button
                    :disabled="operationType == 'detail'"
                    size="small"
                    type="primary"
                    >点击上传</el-button
                  ></em
                >
              </div>
            </el-upload>
            <el-table
              :data="fileListto"
              @row-click="downFile"
              style="width: 100%"
            >
              <el-table-column
                prop="name"
                :show-overflow-tooltip="true"
                label="名称"
              >
                <template slot-scope="scope">
                  <i style="color:#409EFF" class=" el-icon-s-order" />{{
                    scope.row.name
                  }}
                </template>
              </el-table-column>
              <el-table-column
                prop="name"
                width="180"
                :show-overflow-tooltip="true"
                label="功能"
              >
                <template slot-scope="scope">
                  <el-button
                    type="primary"
                    size="mini"
                    @click.native.prevent="deletedowfile(scope.row)"
                    >删除</el-button
                  >
                  <el-button
                    type="primary"
                    size="mini"
                    @click.native.prevent="moveupdowfile(scope.row)"
                    >上移</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- <div
            class="pdftit"
            @click="pdffn(item)"
            v-for="item in fileList"
            :key="item.name"
          >
            {{ item.name }}
          </div> -->
        </div>
        <div v-if="this.previewpdf" class="pdfimgmin">
@@ -971,6 +1019,21 @@
        </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>
@@ -1014,6 +1077,7 @@
import { getSubsidy } from "@/api/project/travelcity";
import { listReportname, listUser } from "@/api/project/organization";
import { getToken } from "@/utils/auth";
import debounce from "lodash/debounce";
export default {
  components: {
    Treeselect,
@@ -1057,6 +1121,9 @@
        label: ""
      },
      pdfimgsrcList: [],
      Savereminder: false, //提醒保存弹框
      Reminderquantity: 0, //提醒数量
      totalquantity: 0, //总数量
      hintitle: "选中左侧已上传文件预览查看",
      atpresent: "",
@@ -1283,9 +1350,12 @@
        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);
        this.fileListto.forEach(item => {
          this.pdfimgsrcList.push(this.Networkheader + "/prod-api" + item.url);
        });
        console.log(this.pdfimgsrcList);
        console.log(this.pdfimg);
      } else {
        this.fileListto = [];
        this.pdfimg = "";
@@ -1306,8 +1376,8 @@
        this.previewpdf = true;
        if (item.url) {
          this.pdfimg = this.Networkheader + "/prod-api" + item.url;
          this.pdfimgsrcList = [];
          this.pdfimgsrcList.push(this.pdfimg);
          // this.pdfimgsrcList = [];
          // this.pdfimgsrcList.push(this.pdfimg);
          console.log(this.pdfimg);
        } else {
          this.pdfimg = this.Networkheader + "/prod-api" + item.response.url;
@@ -1317,6 +1387,23 @@
        this.$modal.msgWarning("当前文件暂不支持预览");
        this.previewpdf = false;
      }
    },
    getIndexInArray(arr, obj) {
      return arr.indexOf(obj);
    },
    // 点击删除
    deletedowfile(row) {
      console.log(this.fileListto);
      console.log(row);
      const index = this.getIndexInArray(this.fileListto, row);
      this.fileList = this.fileListto.splice(index, 1);
      console.log(index);
    },
    // 点击上移
    moveupdowfile(row) {
      const index = this.getIndexInArray(this.fileListto, row);
      const item = this.fileListto.splice(index, 1)[0]; // 移除指定索引处的元素,并保存到item变量中
      this.fileListto.splice(index - 1, 0, item); // 将item插入到索引位置的前一位
    },
    /** 查询部门下拉树结构 */
@@ -1944,7 +2031,7 @@
    },
    /** 提交保存按钮 */
    submitForm() {
    submitForm: debounce(function(data) {
      this.$refs["form"].validate(valid => {
        if (valid) {
          // idisabled=true;
@@ -2095,7 +2182,7 @@
          }
        }
      });
    },
    }, 500),
    /** 删除按钮操作 */
    handleDelete(row) {
@@ -2128,6 +2215,100 @@
          this.exportLoading = false;
        })
        .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("新增报销单保存失败!");
              });
          }
        }
      });
    },
    //新增一行
@@ -2172,11 +2353,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;
      }
@@ -2195,11 +2382,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;
      }
@@ -2596,7 +2789,7 @@
  height: 600px;
  .box-pdf {
    width: 200px;
    width: 400px;
    padding-top: 20px;
    margin-right: 30px;
    border: 1px solid #dcdfe6;