Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/page/index/top/userSManual.vue
@@ -2,13 +2,6 @@
  <div class="userSManual">
    <!-- {{ form.link }} -->
    <basic-container id="PDFmain">
      <!-- <embed :src="form.link" type="application/pdf" width="800" height="800" /> -->
      <!-- <object
        :data="form.link"
        type="application/pdf"
        width="800"
        height="800"
      ></object> -->
      <iframe
        id="PDFmainIFRAM"
        src="/pfd/build/generic/web/viewer.html"
@@ -30,6 +23,7 @@
        :option="option"
        v-model="form"
        @submit="handleSubmit"
        @tab-click="handleTabClick"
        :upload-before="uploadBefore"
        :upload-after="uploadAfter"
      ></avue-form>
@@ -40,6 +34,7 @@
<script>
import { mapGetters } from "vuex";
import { add, getDetails } from "@/api/resource/attach";
import func from "@/util/func";
export default {
  data() {
    return {
@@ -99,6 +94,54 @@
              },
            ],
          },
          {
            label: "上传用户手册-民警版",
            prop: "info",
            column: [
              {
                label: "用户手册",
                type: "upload",
                // listType: "picture-img",
                propsHttp: {
                  res: "data",
                  url: "link",
                },
                // canvasOption: {
                //   text: " ",
                //   ratio: 0.1,
                // },
                action: "/api/blade-resource/oss/endpoint/put-file",
                // action: "/api/blade-resource/oss/endpoint/put-file-attach",
                // tip: "只能上传jpg/png用户头像,且不超过500kb",
                span: 24,
                row: true,
                prop: "link",
                labelWidth: 180,
              },
              {
                label: "首次上传时间",
                span: 24,
                row: true,
                prop: "createTime",
                labelWidth: 180,
                type: "datetime",
                disabled: true,
                format: "yyyy-MM-dd HH:mm:ss",
                valueFormat: "yyyy-MM-dd HH:mm:ss",
              },
              {
                label: "上次更新时间",
                span: 24,
                row: true,
                prop: "updateTime",
                labelWidth: 180,
                type: "datetime",
                disabled: true,
                format: "yyyy-MM-dd HH:mm:ss",
                valueFormat: "yyyy-MM-dd HH:mm:ss",
              },
            ],
          },
        ],
      },
      form: {},
@@ -109,12 +152,17 @@
    ...mapGetters(["userInfo"]),
  },
  created() {
    if (this.userInfo.role_name == "民警") {
      this.index = 1;
    }
    this.handleWitch();
    if (this.userInfo.role_name == "administrator") {
      this.userSManual_upBut = "block";
    } else {
      this.userSManual_upBut = "none";
    }
  },
  methods: {
    openUps() {
@@ -141,8 +189,34 @@
      if (this.index === 0) {
        form["type"] = 10;
        form["link"] = this.link;
        // console.log(form);
        // return;
        add(form).then(
          (res) => {
            if (res.data.success) {
              this.handleWitch();
              this.$message({
                type: "success",
                message: "用户手册上传成功!",
              });
            } else {
              this.$message({
                type: "error",
                message: res.data.msg,
              });
            }
            done();
            this.link = "";
            this.form = {};
            this.openUp = false;
          },
          (error) => {
            window.console.log(error);
            done();
          }
        );
      }
      if (this.index === 1) {
        form["type"] = 11;
        form["link"] = this.link;
        add(form).then(
          (res) => {
            if (res.data.success) {
@@ -181,19 +255,15 @@
      this.intime = setInterval(() => {
        let havePdf = this.havepdf();
        if (havePdf) {
          //   console.log("已加载完");
          havePdf.setUrl(url);
          //   console.log(this.intime, 1);
          clearInterval(this.intime);
          //   console.log(this.intime, 2);
          this.intime = "";
          //   console.log(this.intime, 3);
        } else {
          //   console.log("没加载玩");
        }
        // var pdf = document.getElementById("PDFmainIFRAM").contentWindow;
        // pdf.setUrl(url);
      }, 500);
    },
    handleTabClick(tabs) {
      this.index = func.toInt(tabs.index);
      this.handleWitch();
    },
    handleWitch() {
      if (this.index === 0) {
@@ -213,6 +283,23 @@
          };
        });
      }
      if (this.index === 1) {
        getDetails(11).then((res) => {
          const att = res.data.data;
          if (this.intime) {
            clearInterval(this.intime);
            this.setUrl(att.link);
          } else {
            this.setUrl(att.link);
          }
          this.form = {
            id: att.id,
            link: att.link,
            createTime: att.createTime,
            updateTime: att.updateTime,
          };
        });
      }
    },
  },
};