Administrator
2021-07-14 4873e63b91c6a059b525c394236c72ac4bf32b3b
新增通知公告,附件上传下载
3 files modified
1 files added
1408 ■■■■■ changed files
src/api/desk/notice.js 81 ●●●●● patch | view | raw | blame | history
src/router/views/index.js 400 ●●●● patch | view | raw | blame | history
src/views/desk/notice.vue 582 ●●●●● patch | view | raw | blame | history
src/views/resource/uploadNotice.vue 345 ●●●●● patch | view | raw | blame | history
src/api/desk/notice.js
@@ -1,50 +1,61 @@
import request from '@/router/axios';
export const getList = (current, size, params) => {
  return request({
    url: '/api/blade-desk/notice/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
    return request({
        url: '/api/blade-desk/notice/list',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}
export const getListPage = (current, size, params) => {
    return request({
        url: '/api/blade-desk/notice/page',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}
export const remove = (ids) => {
  return request({
    url: '/api/blade-desk/notice/remove',
    method: 'post',
    params: {
      ids,
    }
  })
    return request({
        url: '/api/blade-desk/notice/remove',
        method: 'post',
        params: {
            ids,
        }
    })
}
export const add = (row) => {
  return request({
    url: '/api/blade-desk/notice/submit',
    method: 'post',
    data: row
  })
    return request({
        url: '/api/blade-desk/notice/submit',
        method: 'post',
        data: row
    })
}
export const update = (row) => {
  return request({
    url: '/api/blade-desk/notice/submit',
    method: 'post',
    data: row
  })
    return request({
        url: '/api/blade-desk/notice/submit',
        method: 'post',
        data: row
    })
}
export const getNotice = (id) => {
  return request({
    url: '/api/blade-desk/notice/detail',
    method: 'get',
    params: {
      id
    }
  })
}
    return request({
        url: '/api/blade-desk/notice/detail',
        method: 'get',
        params: {
            id
        }
    })
}
src/router/views/index.js
@@ -1,195 +1,223 @@
import Layout from '@/page/index/'
export default [
  // {
  //   path: '/wel',
  //   component: Layout,
  //   redirect: '/wel/index',
  //   children: [{
  //     path: 'index',
  //     name: '首页',
  //     meta: {
  //       i18n: 'dashboard'
  //     },
  //     component: () =>
  //       import( /*webpackChunkName:"views"*/ '@/views/wel/index')
  //   }, {
  //     path: 'dashboard',
  //     name: '控制台',
  //     meta: {
  //       i18n: 'dashboard',
  //       menu: false,
  //     },
  //     component: () =>
  //       import( /*webpackChunkName:"views"*/ '@/views/wel/dashboard')
  //   }]
  // },
    // {
    //   path: '/wel',
    //   component: Layout,
    //   redirect: '/wel/index',
    //   children: [{
    //     path: 'index',
    //     name: '首页',
    //     meta: {
    //       i18n: 'dashboard'
    //     },
    //     component: () =>
    //       import( /*webpackChunkName:"views"*/ '@/views/wel/index')
    //   }, {
    //     path: 'dashboard',
    //     name: '控制台',
    //     meta: {
    //       i18n: 'dashboard',
    //       menu: false,
    //     },
    //     component: () =>
    //       import( /*webpackChunkName:"views"*/ '@/views/wel/dashboard')
    //   }]
    // },
  {
    path: '/wel',
    component: () =>
      import('@/views/home/index')
    // component: Layout,
    // redirect: '/wel/index',
    // children: [{
    //   path: 'index',
    //   name: '首页',
    //   meta: {
    //     i18n: 'dashboard'
    //   },
    //   component: () =>
    //     import( /* webpackChunkName: "views" */ '@/views/wel/index')
    // }, {
    //   path: 'dashboard',
    //   name: '控制台',
    //   meta: {
    //     i18n: 'dashboard',
    //     menu: false,
    //   },
    //   component: () =>
    //     import( /* webpackChunkName: "views" */ '@/views/wel/dashboard')
    // }]
  },
    {
        path: '/wel',
        component: () =>
            import ('@/views/home/index')
            // component: Layout,
            // redirect: '/wel/index',
            // children: [{
            //   path: 'index',
            //   name: '首页',
            //   meta: {
            //     i18n: 'dashboard'
            //   },
            //   component: () =>
            //     import( /* webpackChunkName: "views" */ '@/views/wel/index')
            // }, {
            //   path: 'dashboard',
            //   name: '控制台',
            //   meta: {
            //     i18n: 'dashboard',
            //     menu: false,
            //   },
            //   component: () =>
            //     import( /* webpackChunkName: "views" */ '@/views/wel/dashboard')
            // }]
    },
  {
    path: '/test',
    component: Layout,
    redirect: '/test/index',
    children: [{
      path: 'index',
      name: '测试页',
      meta: {
        i18n: 'test'
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/util/test')
    }]
  }, {
    path: '/dict-horizontal',
    component: Layout,
    redirect: '/dict-horizontal/index',
    children: [{
      path: 'index',
      name: '字典管理',
      meta: {
        i18n: 'dict'
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal')
    }]
  }, {
    path: '/dict-vertical',
    component: Layout,
    redirect: '/dict-vertical/index',
    children: [{
      path: 'index',
      name: '字典管理',
      meta: {
        i18n: 'dict'
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical')
    }]
  }, {
    path: '/info',
    component: Layout,
    redirect: '/info/index',
    children: [{
      path: 'index',
      name: '个人信息',
      meta: {
        i18n: 'info'
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/system/userinfo')
    }]
  }, {
    path: '/work/process/leave',
    component: Layout,
    redirect: '/work/process/leave/form',
    children: [{
      path: 'form/:processDefinitionId',
      name: '请假流程',
      meta: {
        i18n: 'work'
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/work/process/leave/form')
    {
        path: '/test',
        component: Layout,
        redirect: '/test/index',
        children: [{
            path: 'index',
            name: '测试页',
            meta: {
                i18n: 'test'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/test')
        }]
    }, {
      path: 'handle/:taskId/:processInstanceId/:businessId',
      name: '处理请假流程',
      meta: {
        i18n: 'work'
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/work/process/leave/handle')
        path: '/dict-horizontal',
        component: Layout,
        redirect: '/dict-horizontal/index',
        children: [{
            path: 'index',
            name: '字典管理',
            meta: {
                i18n: 'dict'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal')
        }]
    }, {
      path: 'detail/:processInstanceId/:businessId',
      name: '请假流程详情',
      meta: {
        i18n: 'work'
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
    }]
  },{
    path: '/attach',
    redirect: '/resource/attach',
    component: Layout,
    children: [{
      path: 'index',
      name: '附件上传',
      meta: {
        i18n: 'index',
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/resource/attach')
    }]
  },
  {
    path: '/register',
    redirect: '/management/index',
    component: Layout,
    children: [{
      path: 'index',
      name: '保安人员管理',
      meta: {
        i18n: 'index',
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/management/register')
    }]
  }, {
    path: '/management',
    redirect: '/management/index',
    component: Layout,
    children: [{
      path: 'index',
      name: '保安详细资料',
      meta: {
        i18n: 'index',
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/management/peopleDetails')
    }]
  }, {
    path: '/securityCompany',
    redirect: '/securityCompany/index',
    component: Layout,
    children: [{
      path: 'index',
      name: '保安详细资料',
      meta: {
        i18n: 'index',
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/securityCompany/companyDetails')
    }]
  }, {
    path: '/map',
    component: () =>
      import( /* webpackChunkName: "views" */ '@/views/mapHome/index')
  },
]
        path: '/dict-vertical',
        component: Layout,
        redirect: '/dict-vertical/index',
        children: [{
            path: 'index',
            name: '字典管理',
            meta: {
                i18n: 'dict'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical')
        }]
    }, {
        path: '/info',
        component: Layout,
        redirect: '/info/index',
        children: [{
            path: 'index',
            name: '个人信息',
            meta: {
                i18n: 'info'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/system/userinfo')
        }]
    }, {
        path: '/work/process/leave',
        component: Layout,
        redirect: '/work/process/leave/form',
        children: [{
            path: 'form/:processDefinitionId',
            name: '请假流程',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/form')
        }, {
            path: 'handle/:taskId/:processInstanceId/:businessId',
            name: '处理请假流程',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/handle')
        }, {
            path: 'detail/:processInstanceId/:businessId',
            name: '请假流程详情',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
        }]
    }, {
        path: '/attach',
        redirect: '/resource/attach',
        component: Layout,
        children: [{
            path: 'index',
            name: '附件上传',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/resource/attach')
        }]
    },
    {
        path: '/register',
        redirect: '/management/index',
        component: Layout,
        children: [{
            path: 'index',
            name: '保安人员管理',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/management/register')
        }]
    },
    {
        path: '/desk',
        redirect: '/desk/notice',
        component: Layout,
        children: [{
            path: 'notice',
            name: '通知公告',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/desk/notice')
        }]
    },
    {
        path: '/resource',
        redirect: '/resource/uploadNotice',
        component: Layout,
        children: [{
            path: 'uploadNotice',
            name: '附件上传',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/resource/uploadNotice')
        }]
    }, {
        path: '/management',
        redirect: '/management/index',
        component: Layout,
        children: [{
            path: 'index',
            name: '保安详细资料',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/management/peopleDetails')
        }]
    }, {
        path: '/securityCompany',
        redirect: '/securityCompany/index',
        component: Layout,
        children: [{
            path: 'index',
            name: '保安详细资料',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/securityCompany/companyDetails')
        }]
    }, {
        path: '/map',
        component: () =>
            import ( /* webpackChunkName: "views" */ '@/views/mapHome/index')
    },
]
src/views/desk/notice.vue
@@ -1,293 +1,381 @@
<template>
  <basic-container>
    <avue-crud :option="option"
               :table-loading="loading"
               :data="data"
               :page.sync="page"
               ref="crud"
               @row-del="rowDel"
               v-model="form"
               :permission="permissionList"
               @row-update="rowUpdate"
               @row-save="rowSave"
               :before-open="beforeOpen"
               @search-change="searchChange"
               @search-reset="searchReset"
               @selection-change="selectionChange"
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad">
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      ref="crud"
      @row-del="rowDel"
      v-model="form"
      :permission="permissionList"
      @row-update="rowUpdate"
      @row-save="rowSave"
      :before-open="beforeOpen"
      @filter="filterChange"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot="menuLeft">
        <el-button type="danger"
                   size="small"
                   icon="el-icon-delete"
                   plain
                   v-if="permission.notice_delete"
                   @click="handleDelete">删 除
        <el-button
          type="danger"
          size="small"
          icon="el-icon-delete"
          plain
          v-if="deptCategory"
          @click="handleDelete"
          >删 除
        </el-button>
        <!-- v-if="permission.notice_delete" -->
      </template>
      <template slot-scope="{row}"
                slot="category">
        <el-tag>{{row.categoryName}}</el-tag>
      <template slot-scope="{ row }" slot="category">
        <el-tag>{{ row.categoryName }}</el-tag>
      </template>
      <template slot-scope="{ type, size, row }" slot="menu">
        <el-button :size="size" :type="type" @click="handleUploadPage(row)"
          >附件上传
        </el-button>
        <!-- <el-button
          v-if="!deptCategory"
          :size="size"
          :type="type"
          @click="handleUploadPage(row)"
          >附件查看
        </el-button> -->
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
  import {getList, remove, update, add, getNotice} from "@/api/desk/notice";
  import {mapGetters} from "vuex";
import { getListPage, remove, update, add, getNotice } from "@/api/desk/notice";
import { mapGetters } from "vuex";
  export default {
    data() {
      return {
        form: {},
        query: {},
        loading: true,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        selectionList: [],
        option: {
          height: 'auto',
          calcHeight: 30,
          dialogWidth: 950,
          tip: false,
          searchShow: true,
          searchMenuSpan: 6,
          border: true,
          index: true,
          viewBtn: true,
          selection: true,
          excelBtn: true,
          dialogClickModal: false,
          column: [
            {
              label: "通知标题",
              prop: "title",
              span: 24,
              row: true,
              search: true,
              rules: [{
export default {
  data() {
    return {
      form: {},
      query: {},
      loading: true,
      deptCategory: "",
      deptId: "",
      userId: "",
      permissionAdd: "",
      permissionDelete: "",
      permissionView: "",
      permissionEdit: "",
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        height: "auto",
        calcHeight: 30,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: false,
        index: true,
        stripe: true,
        viewBtn: true,
        selection: true,
        excelBtn: false,
        menuWidth: 320,
        dialogClickModal: false,
        column: [
          {
            label: "通知标题",
            prop: "title",
            span: 24,
            row: true,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入通知标题",
                trigger: "blur"
              }]
            },
            {
              label: "通知类型",
              type: "select",
              dicUrl: "/api/blade-system/dict/dictionary?code=notice",
              props: {
                label: "dictValue",
                value: "dictKey"
                trigger: "blur",
              },
              dataType: "number",
              slot: true,
              prop: "category",
              search: true,
              rules: [{
                required: true,
                message: "请输入通知类型",
                trigger: "blur"
              }]
            ],
          },
          // {
          //   label: "通知类型",
          //   type: "select",
          //   dicUrl: "/api/blade-system/dict/dictionary?code=notice",
          //   props: {
          //     label: "dictValue",
          //     value: "dictKey",
          //   },
          //   dataType: "number",
          //   slot: true,
          //   addDisplay: false,
          //   editDisplay: false,
          //   defaultValue: "1",
          //   prop: "category",
          //   search: true,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入通知类型",
          //       trigger: "blur",
          //     },
          //   ],
          // },
          {
            label: "发布单位",
            prop: "deptId",
            type: "tree",
            dicUrl: "/api/blade-system/dept/lazy-tree",
            props: {
              label: "title",
              value: "id",
            },
            {
              label: "通知时间",
              prop: "releaseTimeRange",
              type: "datetime",
              format: "yyyy-MM-dd hh:mm:ss",
              valueFormat: "yyyy-MM-dd hh:mm:ss",
              searchRange:true,
              hide: true,
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              search: true,
              rules: [{
            addDisplay: false,
            editDisplay: false,
            rules: [
              {
                required: true,
                message: "所属组织机构",
                trigger: "click",
              },
            ],
          },
          {
            label: "通知时间",
            prop: "releaseTimeRange",
            type: "datetime",
            format: "yyyy-MM-dd hh:mm:ss",
            valueFormat: "yyyy-MM-dd hh:mm:ss",
            searchRange: true,
            hide: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入通知时间",
                trigger: "blur"
              }]
            },
            {
              label: "通知日期",
              prop: "releaseTime",
              type: "date",
              format: "yyyy-MM-dd hh:mm:ss",
              valueFormat: "yyyy-MM-dd hh:mm:ss",
              rules: [{
                trigger: "blur",
              },
            ],
          },
          {
            label: "通知日期",
            prop: "releaseTime",
            type: "date",
            format: "yyyy-MM-dd hh:mm:ss",
            valueFormat: "yyyy-MM-dd hh:mm:ss",
            rules: [
              {
                required: true,
                message: "请输入通知日期",
                trigger: "click"
              }]
            },
            {
              label: "通知内容",
              prop: "content",
              component: 'AvueUeditor',
              options: {
                action: '/api/blade-resource/oss/endpoint/put-file',
                props: {
                  res: "data",
                  url: "link",
                }
                trigger: "click",
              },
              hide: true,
              minRows: 6,
              span: 24,
            }
          ]
        },
        data: []
            ],
          },
          {
            label: "通知内容",
            prop: "content",
            component: "AvueUeditor",
            options: {
              action: "/api/blade-resource/oss/endpoint/put-file",
              props: {
                res: "data",
                url: "link",
              },
            },
            hide: true,
            minRows: 6,
            span: 24,
          },
        ],
      },
      data: [],
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.notice_add, false),
        viewBtn: this.vaildData(this.permission.notice_view, false),
        delBtn: this.vaildData(this.permission.notice_delete, false),
        editBtn: this.vaildData(this.permission.notice_edit, false),
      };
    },
    computed: {
      ...mapGetters(["permission"]),
      permissionList() {
        return {
          addBtn: this.vaildData(this.permission.notice_add, false),
          viewBtn: this.vaildData(this.permission.notice_view, false),
          delBtn: this.vaildData(this.permission.notice_delete, false),
          editBtn: this.vaildData(this.permission.notice_edit, false)
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    methods: {
      rowSave(row, done, loading) {
        add(row).then(() => {
  },
  mounted() {},
  methods: {
    //跳转到附近列表页面
    handleUploadPage(row) {
      this.$router.push({
        path: `/resource/uploadNotice`,
        query: {
          deptId: row.deptId,
        },
      });
    },
    rowSave(row, done, loading) {
      row.category = 2;
      row.deptId = this.deptId;
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
            message: "操作成功!",
          });
          done();
        }, error => {
        },
        (error) => {
          window.console.log(error);
          loading();
        });
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
        }
      );
    },
    rowUpdate(row, index, done, loading) {
      row.category = 2;
      row.deptId = this.deptId;
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
            message: "操作成功!",
          });
          done();
        }, error => {
        },
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
    },
    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();
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
        })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
      },
      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();
      },
      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)) {
          getNotice(this.form.id).then(res => {
            this.form = res.data.data;
          });
        }
        done();
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage;
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
      },
      onLoad(page, params = {}) {
        const {releaseTimeRange} = this.query;
        let values = {
          ...params,
        };
        if (releaseTimeRange) {
          values = {
            ...params,
            releaseTime_datege: releaseTimeRange[0],
            releaseTime_datelt: releaseTimeRange[1],
            ...this.query
          };
          values.releaseTimeRange = null;
        }
        this.loading = true;
        getList(page.currentPage, page.pageSize, values).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getNotice(this.form.id).then((res) => {
          this.form = res.data.data;
        });
      }
    }
  };
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.deptId = JSON.parse(
        window.localStorage.getItem("saber-userInfo")
      ).content.dept_id;
      this.userId = JSON.parse(
        window.localStorage.getItem("saber-userInfo")
      ).content.user_id;
      if (this.deptId != 1123598813738675201) {
        params["deptId"] = this.deptId;
      }
      const { releaseTimeRange } = this.query;
      let values = {
        ...params,
      };
      if (releaseTimeRange) {
        values = {
          ...params,
          startTime: releaseTimeRange[0],
          endTime: releaseTimeRange[1],
          ...this.query,
        };
        values.releaseTimeRange = null;
      }
      this.loading = true;
      getListPage(page.currentPage, page.pageSize, values).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
  },
};
</script>
<style>
src/views/resource/uploadNotice.vue
New file
@@ -0,0 +1,345 @@
<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-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="menuLeft">
        <el-button
          type="primary"
          size="small"
          plain
          v-if="permission.attach_upload"
          icon="el-icon-upload2"
          @click="handleUpload"
          >上 传
        </el-button>
        <el-button
          type="danger"
          size="small"
          icon="el-icon-delete"
          plain
          v-if="permission.attach_delete"
          @click="handleDelete"
          >删 除
        </el-button>
      </template>
      <template slot-scope="scope" slot="menu">
        <el-button
          type="text"
          icon="el-icon-download"
          size="small"
          v-if="permission.attach_download"
          @click="handleDownload(scope.row)"
          >下载
        </el-button>
      </template>
      <template slot-scope="{ row }" slot="attachSize">
        <el-tag>{{ `${row.attachSize} KB` }}</el-tag>
      </template>
    </avue-crud>
    <el-dialog
      title="附件管理"
      append-to-body
      :visible.sync="attachBox"
      width="555px"
    >
      <avue-form
        ref="form"
        :option="attachOption"
        v-model="attachForm"
        :upload-after="uploadAfter"
      >
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
<script>
import { getList, getDetail, remove } from "@/api/resource/attach";
import { mapGetters } from "vuex";
export default {
  data() {
    var type = 4;
    var deptid = this.$route.query.deptId;
    return {
      form: {},
      query: {},
      putParam: "",
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      attachBox: false,
      selectionList: [],
      option: {
        height: "auto",
        calcHeight: 30,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: false,
        index: true,
        stripe: true,
        viewBtn: true,
        selection: true,
        dialogClickModal: false,
        column: [
          {
            label: "附件地址",
            prop: "link",
            rules: [
              {
                required: true,
                message: "请输入附件地址",
                trigger: "blur",
              },
            ],
          },
          {
            label: "附件域名",
            prop: "domain",
            search: true,
            rules: [
              {
                required: true,
                message: "请输入附件域名",
                trigger: "blur",
              },
            ],
          },
          {
            label: "附件名称",
            prop: "name",
            search: true,
            rules: [
              {
                required: true,
                message: "请输入附件名称",
                trigger: "blur",
              },
            ],
          },
          {
            label: "附件原名",
            prop: "originalName",
            search: true,
            rules: [
              {
                required: true,
                message: "请输入附件原名",
                trigger: "blur",
              },
            ],
          },
          {
            label: "附件拓展名",
            prop: "extension",
            rules: [
              {
                required: true,
                message: "请输入附件拓展名",
                trigger: "blur",
              },
            ],
          },
          {
            label: "附件大小",
            prop: "attachSize",
            slot: true,
            rules: [
              {
                required: true,
                message: "请输入附件大小",
                trigger: "blur",
              },
            ],
          },
        ],
      },
      data: [],
      attachForm: {},
      attachOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "附件上传",
            prop: "attachFile",
            type: "upload",
            drag: true,
            loadText: "模板上传中,请稍等",
            span: 24,
            propsHttp: {
              res: "data",
            },
            action:
              "/api/blade-resource/oss/endpoint/put-file-attach?type=" +
              type +
              "&deptid=" +
              deptid,
          },
        ],
      },
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: false,
        editBtn: false,
        viewBtn: false,
        delBtn: this.vaildData(this.permission.attach_delete, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  mounted() {
    var flag = false,
      i = 0,
      ind = null;
    this.$store.state.tags.tagList.forEach((item, index) => {
      if (item.label == "附件上传") {
        if (flag == false) {
          ind = index;
          flag = true;
        }
        i++;
      }
    });
    if (i > 1) {
      this.$store.state.tags.tagList.splice(ind, 1);
    }
  },
  methods: {
    handleUpload() {
      this.attachBox = true;
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(column);
      this.attachBox = false;
      this.refreshChange();
      done();
    },
    handleDownload(row) {
      window.open(`${row.link}`);
    },
    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 = {}) {
      params.type = 4;
      params.deptid = this.$route.query.deptId;
      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>