在这里插入图片描述
在这里插入图片描述

<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      :permission="permissionList"
      :before-open="beforeOpen"
      v-model="form"
      ref="crud"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @row-del="rowDel"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
    自定义 列表按钮
      <template slot="menu">
        <el-button
          type="text"
          size="small"
          icon="el-icon-s-order"
          @click="detailLookFn"
        >
          查询详情
        </el-button>
      </template>
      自定义头部按钮
      <template slot="menuLeft">
   
        <el-button
          type="primary"
          size="small"
          icon="el-icon-s-release"
          v-if="permission.reviewer_delete"
          @click="SendFn(2)"
          >发布至内网
        </el-button>
      </template>
      <!-- 插入 -->
   弹框内容
      <div slot-scope="{}" slot="bindForm" style="display: inline-block">
        <el-upload
          style="width: 60px; display: inline-block"
          class="upload-demo"
          action="/api/blade-resource/oss/endpoint/put-file"
          :on-success="handleSuccess"
          :show-file-list="false"
          :headers="headers"
        >
          <el-button size="small" type="success">上传</el-button>
        </el-upload>
        <el-button
          style="margin-left: 10px; display: inline-block"
          size="small"
          type="danger"
          >下载/预览</el-button
        >
        <el-button
          style="width: 60px; display: inline-block"
          size="small"
          type="primary"
          >预览</el-button
        >
      </div>
      <!-- </template> -->
    </avue-crud>
  
    <!-- 查看详情 -->
    <el-dialog
      title="查看详情"
      :visible.sync="isShow"
      width="60%"
      append-to-body
      :before-close="handleClose"
      v-if="isShow"
    >
    <schoolFile></schoolFile>
  </el-dialog>
  </basic-container>
</template>

<script>
import { getList, getDetail, add, update, remove } from "@/api/office/document";
import { mapGetters } from "vuex";
import website from "@/config/website";
import { getToken } from "@/util/auth";
import schoolFile from "./components/schoolFile";
export default {
  components: { schoolFile },
  data() {
    return {
      headers: {
        "Blade-Auth": "",
        Authorization: "",
      },
      tableData: [],
      isShow: false,
      checkList:'',
      pigeonholeShow: false,
      addShow: false,
      ruleForm: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
      },
      // 列表
      form: {},
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        height: "auto",
        calcHeight: 30,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        viewBtn: false,
        // addBtn:false,
        delBtn: false,
        selection: true,
        dialogClickModal: false,
        column: [
          {
            label: "文件",
            prop: "filesname",
            bind: "",
            hide: true,
            rules: [
              {
                required: true,
                message: "请输入文件",
                trigger: "blur",
              },
            ],
          },
          {
            label: "",
            prop: "bind",
            hide: true,
            formslot: true,
          },
       
       
          {
            label: "正文",
            prop: "attachmentDescription",
            hide: true,
            span: 24,
            component: "AvueUeditor",
            options: {
              action: "/api/blade-resource/oss/endpoint/put-file",
              props: {
                res: "data",
                url: "link",
              },
            },
            rules: [
              {
                required: true,
                message: "请输入正文",
                trigger: "blur",
              },
            ],
          },
        ],
      },
      data: [],
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.reviewer_add, false),
        viewBtn: this.vaildData(this.permission.reviewer_view, false),
        delBtn: this.vaildData(this.permission.reviewer_delete, false),
        editBtn: this.vaildData(this.permission.reviewer_edit, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  mounted() {
    this.headers["Blade-Auth"] = getToken();
    this.headers["Authorization"] = `Basic ${Base64.encode(
      `${website.clientId}:${website.clientSecret}`
    )}`;
  },
  methods: {
    // 顶部按钮
    SendFn(num) {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }

      var tip;
      if (num == 1) {
        tip = "发送行政领导审阅";
      }
      if (num == 2) {
        tip = "公文发布至内网";
      }

      this.$confirm(tip, {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          // return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.crud.toggleSelection();
        });
    },
    detailLookFn() {
      this.isShow = true;
    },
    // 新增
    // 上传文件成功事件
    handleSuccess(res, file) {
      console.log(res, file);
      // this.pictureName = res.data.originalName;
      this.$set(this.form, "filesname", res.data.originalName);
      this.$set(this.form, "files", res.data.link);
    },
    addfn() {
      this.addShow = true;
    },
    // 归档
    pigeonholeFn() {

      this.pigeonholeShow = true;
    },
    rowSave(row, done, loading) {
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
          window.console.log(error);
        }
      );
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
          console.log(error);
        }
      );
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then((res) => {
          this.form = res.data.data;
        });
      }
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
  },
};
</script>

<style></style>

Logo

前往低代码交流专区

更多推荐