From 97837d1f683c4c1900a01dc86c1e08e7c90d1de3 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 10 Sep 2021 17:10:02 +0800
Subject: [PATCH] 部分内容的修改整理
---
src/views/workreport/workreport.vue | 614 +++++++++++++++++++++++++++----------------------------
1 files changed, 305 insertions(+), 309 deletions(-)
diff --git a/src/views/workreport/workreport.vue b/src/views/workreport/workreport.vue
index a33eec1..b12ab78 100644
--- a/src/views/workreport/workreport.vue
+++ b/src/views/workreport/workreport.vue
@@ -1,334 +1,330 @@
<template>
- <basic-container class="workreply">
- <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
- @click="handleDelete"
- >删 除
- </el-button>
- </template>
- <!-- <template slot-scope="{ type, size, row }" slot="menu">
+ <basic-container class="workreply">
+ <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
+ @click="handleDelete">删 除
+ </el-button>
+ </template>
+ <!-- <template slot-scope="{ type, size, row }" slot="menu">
<el-button :size="size" :type="type" @click="handleUploadPage(row)"
>附件上传
</el-button>
</template> -->
- </avue-crud>
- </basic-container>
+ </avue-crud>
+ </basic-container>
</template>
<script>
import { workreportColumn } from "./data";
import { mapState } from "vuex";
import {
- getListPage,
- remove,
- update,
- add,
- getDetail,
+ getListPage,
+ remove,
+ update,
+ add,
+ getDetail,
} from "@/api/workreport/workreport";
import { getDept } from "@/api/system/dept";
import { mapGetters } from "vuex";
import { getDictionaryBiz } from "@/api/system/dict";
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: 1000,
- tip: false,
- searchShow: true,
- searchMenuSpan: 6,
- border: true, //liu
- addBtnText: "发起",
- saveBtnText: "发起",
- addTitle: "发起",
- index: true,
- stripe: true,
- viewBtn: true,
- selection: true,
- excelBtn: false,
- menuWidth: 320,
- dialogClickModal: false,
- column: workreportColumn,
- },
- data: [],
- };
- },
- computed: {
- ...mapGetters(["permission"]),
- permissionList() {
- return {
- addBtn: this.vaildData(this.permission.workreport_add, false),
- viewBtn: this.vaildData(this.permission.workreport_view, false),
- delBtn: this.vaildData(this.permission.workreport_delete, false),
- editBtn: this.vaildData(this.permission.workreport_edit, false),
- };
- },
- ids() {
- let ids = [];
- this.selectionList.forEach((ele) => {
- ids.push(ele.id);
- });
- return ids.join(",");
- },
- ...mapState({
- userInfo: (state) => state.user.userInfo,
- }),
- },
- mounted() {},
- methods: {
- rowSave(row, done, loading) {
- row.receivedIds = row.receivedIds.join(",");
- row.deptId = this.deptId;
- row.userId = this.userId;
- add(row).then(
- () => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!",
- });
- done();
- },
- (error) => {
- window.console.log(error);
- loading();
- }
- );
- },
- rowUpdate(row, index, done, loading) {
- row.deptId = this.deptId;
- row.userId = this.userId;
- // row.receivedIds = row.receivedIds.join(",");
- update(row).then(
- () => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!",
- });
- done();
- },
- (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: "操作成功!",
- });
- });
- },
- 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)) {
- getDetail(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;
-
- var that = this;
- // getDept(this.deptId).then((res) => {
- // var deptCategory = res.data.data.deptCategory;
- // deptCategory == 1
- // ? (that.deptCategory = true)
- // : (that.deptCategory = false);
-
- //1:保安公司 2:公安 3:培训公司
- if (
- this.userInfo.role_name == "保安公司管理员" ||
- this.userInfo.role_name == "保安"
- ) {
- const column = that.findObject(that.option.column, "category");
- var code = {
- code: "securityWorkReportCategory",
+ 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: 1000,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ border: true, //liu
+ addTitle: "工作汇报",
+ addBtnText: "工作汇报",
+ saveBtnText: "发起",
+ index: true,
+ stripe: true,
+ viewBtn: true,
+ selection: true,
+ excelBtn: false,
+ menuWidth: 320,
+ dialogClickModal: false,
+ column: workreportColumn,
+ },
+ data: [],
};
-
- getDictionaryBiz(code).then((res) => {
- // column.dicUrl = "/api/blade-system/dict-biz/dictionary?code=securityWorkReportCategory";
- column.dicData = res.data.data;
- const columnReceivedIds = that.findObject(
- that.option.column,
- "receivedIds"
- );
- columnReceivedIds.dicUrl =
- "/api/blade-system/dept/lazy-tree-users?type={{key}}&deptId=" +
- that.userInfo.dept_id;
-
- params["deptId"] = this.deptId;
- params["userId"] = this.userId;
- // }
-
- let values = {
- ...params,
- };
- 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();
- });
- });
- } else if (this.userInfo.role_name == "公安管理员") {
- const column = that.findObject(that.option.column, "category");
- var code1 = { code: "workReportCategory" };
- getDictionaryBiz(code1).then((res) => {
- // column.dicUrl = "/api/blade-system/dict-biz/dictionary?code=workReportCategory";
- column.dicData = res.data.data;
- const columnReceivedIds = that.findObject(
- that.option.column,
- "receivedIds"
- );
- columnReceivedIds.dicUrl =
- "/api/blade-system/dept/lazy-tree-users?type={{key}}&deptId=" +
- that.userInfo.dept_id;
-
- params["deptId"] = this.deptId;
- params["userId"] = this.userId;
- // }
-
- let values = {
- ...params,
- };
- 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();
- });
- });
- } else if (this.userInfo.role_name == "administrator") {
- getListPage(page.currentPage, page.pageSize, params).then((res) => {
- const data = res.data.data;
- this.page.total = data.total;
- this.data = data.records;
- this.loading = false;
- this.selectionClear();
- });
- }
},
- },
+ computed: {
+ ...mapGetters(["permission"]),
+ permissionList () {
+ return {
+ addBtn: this.vaildData(this.permission.workreport_add, false),
+ viewBtn: this.vaildData(this.permission.workreport_view, false),
+ delBtn: this.vaildData(this.permission.workreport_delete, false),
+ editBtn: this.vaildData(this.permission.workreport_edit, false),
+ };
+ },
+ ids () {
+ let ids = [];
+ this.selectionList.forEach((ele) => {
+ ids.push(ele.id);
+ });
+ return ids.join(",");
+ },
+ ...mapState({
+ userInfo: (state) => state.user.userInfo,
+ }),
+ },
+ mounted () { },
+ methods: {
+ rowSave (row, done, loading) {
+ row.receivedIds = row.receivedIds.join(",");
+ row.deptId = this.deptId;
+ row.userId = this.userId;
+ add(row).then(
+ () => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ done();
+ },
+ (error) => {
+ window.console.log(error);
+ loading();
+ }
+ );
+ },
+ rowUpdate (row, index, done, loading) {
+ row.deptId = this.deptId;
+ row.userId = this.userId;
+ // row.receivedIds = row.receivedIds.join(",");
+ update(row).then(
+ () => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ done();
+ },
+ (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: "操作成功!",
+ });
+ });
+ },
+ 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)) {
+ getDetail(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;
+
+ var that = this;
+ // getDept(this.deptId).then((res) => {
+ // var deptCategory = res.data.data.deptCategory;
+ // deptCategory == 1
+ // ? (that.deptCategory = true)
+ // : (that.deptCategory = false);
+
+ //1:保安公司 2:公安 3:培训公司
+ if (
+ this.userInfo.role_name == "保安公司管理员" ||
+ this.userInfo.role_name == "保安"
+ ) {
+ const column = that.findObject(that.option.column, "category");
+ var code = {
+ code: "securityWorkReportCategory",
+ };
+
+ getDictionaryBiz(code).then((res) => {
+ // column.dicUrl = "/api/blade-system/dict-biz/dictionary?code=securityWorkReportCategory";
+ column.dicData = res.data.data;
+ const columnReceivedIds = that.findObject(
+ that.option.column,
+ "receivedIds"
+ );
+ columnReceivedIds.dicUrl =
+ "/api/blade-system/dept/lazy-tree-users?type={{key}}&deptId=" +
+ that.userInfo.dept_id;
+
+ params["deptId"] = this.deptId;
+ params["userId"] = this.userId;
+ // }
+
+ let values = {
+ ...params,
+ };
+ 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();
+ });
+ });
+ } else if (this.userInfo.role_name == "公安管理员") {
+ const column = that.findObject(that.option.column, "category");
+ var code1 = { code: "workReportCategory" };
+ getDictionaryBiz(code1).then((res) => {
+ // column.dicUrl = "/api/blade-system/dict-biz/dictionary?code=workReportCategory";
+ column.dicData = res.data.data;
+ const columnReceivedIds = that.findObject(
+ that.option.column,
+ "receivedIds"
+ );
+ columnReceivedIds.dicUrl =
+ "/api/blade-system/dept/lazy-tree-users?type={{key}}&deptId=" +
+ that.userInfo.dept_id;
+
+ params["deptId"] = this.deptId;
+ params["userId"] = this.userId;
+ // }
+
+ let values = {
+ ...params,
+ };
+ 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();
+ });
+ });
+ } else if (this.userInfo.role_name == "administrator") {
+ getListPage(page.currentPage, page.pageSize, params).then((res) => {
+ const data = res.data.data;
+ this.page.total = data.total;
+ this.data = data.records;
+ this.loading = false;
+ this.selectionClear();
+ });
+ }
+ },
+ },
};
</script>
<style>
.workreply .el-card.is-never-shadow.avue-crud__search {
- width: calc(100% - 380px) !important;
- left: 200px !important;
+ width: calc(100% - 380px) !important;
+ left: 200px !important;
}
</style>
--
Gitblit v1.9.3