Procházet zdrojové kódy

Merge branch 'master' of http://120.46.159.163:7400/ezhizao/ezhizao_dms_vue

ezhizao_zx před 5 měsíci
rodič
revize
4486147480

+ 45 - 0
src/api/business/notification.js

@@ -0,0 +1,45 @@
+import request from '@/utils/request'
+
+const baseUrl = import.meta.env.VITE_APP_BASE_API
+// 查询发版通知公告列表
+export function listNotification(query) {
+  return request({
+    url: baseUrl+'/business/notification/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询发版通知公告详细
+export function getNotification(id) {
+  return request({
+    url: baseUrl+'/business/notification/' + id,
+    method: 'get'
+  })
+}
+
+// 新增发版通知公告
+export function addNotification(data) {
+  return request({
+    url: baseUrl+'/business/notification',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改发版通知公告
+export function updateNotification(data) {
+  return request({
+    url: baseUrl+'/business/notification',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除发版通知公告
+export function delNotification(id) {
+  return request({
+    url: baseUrl+'/business/notification/' + id,
+    method: 'delete'
+  })
+}

+ 253 - 0
src/views/system/notification/form.vue

@@ -0,0 +1,253 @@
+<template>
+  <!-- 添加或修改项目信息对话框 -->
+  <div class="el-drawer__wrapper">
+    <el-drawer :title="title" v-model="visible" direction="rtl" size="100%">
+      <div class="page-container form-container">
+        <div class="form-btns-container">
+          <span class="title-label"
+            ><el-icon>
+              <Document />
+            </el-icon>
+            项目信息</span
+          >
+          <el-button-group>
+            <el-button
+              v-if="editStatus"
+              type="primary"
+              size="small"
+              icon="Finished"
+              @click="submitForm"
+              >保存</el-button
+            >
+            <el-button
+              v-else
+              type="warning"
+              size="small"
+              icon="Edit"
+              @click="editStatus = true"
+              >编辑</el-button
+            >
+            <el-button
+              v-if="form.id && editStatus"
+              type="info"
+              size="small"
+              icon="Close"
+              @click="editStatus = false"
+              >取消编辑</el-button
+            >
+            <el-button
+              v-if="form.id"
+              type="success"
+              size="small"
+              @click="getForm"
+            >
+              <i class="fa fa-refresh" aria-hidden="true" /> 刷新
+            </el-button>
+          </el-button-group>
+          <div class="close-btn" @click="cancel">
+            <i class="fa fa-times" aria-hidden="true" />
+            <!-- <span>关闭</span> -->
+          </div>
+        </div>
+        <div
+          class="Y-scrollbar"
+          style="
+            position: absolute;
+            top: 32px;
+            bottom: 0;
+            width: 100%;
+            overflow: auto;
+          "
+        ></div>
+        <el-form
+          ref="notificationRef"
+          class="master-container"
+          :model="form"
+          :rules="rules"
+          label-width="120px"
+        >
+          <el-row :gutter="30">
+            <el-col :span="6"
+              ><el-form-item label="公告标题" prop="title">
+                <el-input
+                  v-if="editStatus"
+                  v-model="form.title"
+                  placeholder="请输入公告标题"
+                />
+                <span v-else>{{ form.title }}</span>
+              </el-form-item>
+              <el-form-item label="备注" prop="remark">
+                <el-input
+                  v-if="editStatus"
+                  v-model="form.remark"
+                  placeholder="请输入备注"
+                />
+                <span v-else>{{ form.remark }}</span>
+              </el-form-item></el-col
+            >
+          </el-row>
+
+          <el-form-item label="公告内容">
+            <wangEditor
+              class="WangEditor"
+              @select="getRich"
+              ref="childrenRef"
+              :editValue="editValue"
+            />
+          </el-form-item>
+        </el-form>
+      </div>
+    </el-drawer>
+  </div>
+</template>
+<script setup>
+import {
+  getNotification,
+  addNotification,
+  updateNotification,
+} from "@/api/business/notification";
+import "@wangeditor/editor/dist/css/style.css";
+import { onMounted, reactive, ref, watch, nextTick } from "vue";
+import wangEditor from "./wangEditor";
+const { proxy } = getCurrentInstance();
+/** 父组件传参 */
+const props = defineProps({
+  getList: {
+    type: Function,
+    default: () => {},
+  },
+});
+const { getList } = toRefs(props);
+/** 字典数组区 */
+/** 表单抽屉 页变量 */
+const title = ref("");
+const loading = ref(false);
+const multiple = ref(true);
+const visible = ref(false);
+const editStatus = ref(false);
+const isFullscreen = ref(false);
+const editorRef = ref(null);
+const webHost = import.meta.env.VITE_APP_BASE_API;
+
+const editValue = ref("");
+
+watch(
+  props,
+  (newUser, oldUser) => {
+    if (props.dataRow && props.dataRow.id) {
+      // 富文本回显
+      form.value.content = props.dataRow.content;
+      editValue.value = form.value.content;
+    }
+  },
+  {
+    deep: true,
+    immediate: true,
+  }
+);
+
+const data = reactive({
+  form: {},
+  rules: {
+    title: [{ required: true, message: "公告标题不能为空", trigger: "blur" }],
+    type: [{ required: true, message: "公告类型不能为空", trigger: "change" }],
+    content: [{ required: true, message: "公告内容不能为空", trigger: "blur" }],
+    updateContent: [
+      { required: true, message: "更新中公告内容不能为空", trigger: "blur" },
+    ],
+    status: [
+      { required: true, message: "公告状态不能为空", trigger: "change" },
+    ],
+  },
+});
+const { form, rules } = toRefs(data);
+/***********************  方法区  ****************************/
+/** 打开抽屉 */
+function open(id) {
+  reset();
+  visible.value = true;
+  if (id) {
+    getNotification(id).then((response) => {
+      form.value = response.data;
+      editStatus.value = false;
+      title.value = "修改项目信息";
+    });
+  } else {
+    editStatus.value = true;
+    title.value = "添加项目信息";
+  }
+}
+//当编辑器的内容更新时,获取该值
+const getRich = function (value) {
+  form.value.content = value;
+};
+/** 取消按钮 */
+function cancel() {
+  visible.value = false;
+  reset();
+}
+
+/** 表单重置 */
+function reset() {
+  form.value = {
+    id: null,
+    title: null,
+    type: null,
+    content: null,
+    updateContent: null,
+    status: null,
+    createTime: null,
+    creatorId: null,
+    updateId: null,
+    updateTime: null,
+    remark: null,
+    deleted: null,
+    version: null,
+  };
+  proxy.resetForm("notificationRef");
+}
+
+/** 全屏缩放 */
+function handleScreen() {
+  const dom = document.querySelector(
+    ".list-container > .el-drawer__wrapper > .el-overlay"
+  );
+  isFullscreen.value = !isFullscreen.value;
+  dom.style.position = isFullscreen.value ? "fixed" : "absolute";
+}
+
+/** 提交按钮 */
+function submitForm() {
+  proxy.$refs["notificationRef"].validate((valid) => {
+    if (valid) {
+      if (form.value.id != null) {
+        updateNotification(form.value).then((response) => {
+          proxy.$modal.msgSuccess("修改成功");
+          visible.value = false;
+          getList.value();
+        });
+      } else {
+        addNotification(form.value).then((response) => {
+          proxy.$modal.msgSuccess("新增成功");
+          visible.value = false;
+          getList.value();
+        });
+      }
+    }
+  });
+}
+
+/** 查询表单信息  */
+function getForm() {
+  loading.value = true;
+  getNotification(form.value.id).then((response) => {
+    loading.value = false;
+    form.value = response.data;
+  });
+}
+
+/** 暴露给父组件的方法 */
+defineExpose({
+  open,
+});
+</script>

+ 266 - 0
src/views/system/notification/index.vue

@@ -0,0 +1,266 @@
+<template>
+  <div class="page-container column-container">
+    <!-- 功能按钮区 -->
+
+    <!-- 搜索区 -->
+    <el-form
+      class="list-search-container"
+      :model="queryParams"
+      ref="queryRef"
+      :inline="true"
+      label-width="68px"
+    >
+      <el-form-item label="公告标题:" prop="title">
+        <el-input
+          v-model="queryParams.title"
+          placeholder="请输入公告标题"
+          clearable
+          @keyup.enter="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="Search" @click="handleQuery"
+          >搜索</el-button
+        >
+        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <div class="list-btns-container" style="display: flex">
+      <el-button
+        type="primary"
+        icon="Plus"
+        @click="handleAdd"
+        v-hasPermi="['business:notification:add']"
+        >新增</el-button
+      >
+
+      <el-button
+        type="warning"
+        icon="Edit"
+        :disabled="single"
+        @click="handleUpdate"
+        v-hasPermi="['business:notification:edit']"
+        >修改</el-button
+      >
+
+      <el-button
+        type="danger"
+        icon="Delete"
+        :disabled="multiple"
+        @click="handleDelete"
+        v-hasPermi="['business:notification:remove']"
+        >删除</el-button
+      >
+      <!-- 添加一个占位元素 -->
+      <div class="flex-grow"></div>
+      <el-button
+        type="success"
+        icon="Edit"
+        @click="handleDelete"
+        v-hasPermi="['business:notification:remove']"
+        >更新展示维护</el-button
+      >
+      <!-- 
+      <el-button
+        type="warning"
+        icon="Download"
+        @click="handleExport"
+        v-hasPermi="['business:notification:export']"
+        >导出</el-button
+      > -->
+      <!--<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>-->
+    </div>
+
+    <div class="el-table-container">
+      <div class="el-table-inner-container">
+        <!-- 列表区 -->
+        <el-table
+          v-loading="loading"
+          :data="notificationList"
+          size="small"
+          border
+          height="100%"
+          @selection-change="handleSelectionChange"
+        >
+          <el-table-column type="selection" width="55" align="center" />
+          <el-table-column
+            type="index"
+            label="行号"
+            width="50"
+            align="center"
+          />
+          <el-table-column label="公告标题" align="center" prop="title" />
+          <el-table-column
+            label="公告类型"
+            align="center"
+            width="200"
+            prop="type"
+          />
+          <el-table-column
+            label="公告状态"
+            align="center"
+            width="200"
+            prop="status"
+          />
+          <el-table-column
+            label="创建时间"
+            width="200"
+            align="center"
+            prop="createTime"
+          >
+            <template #default="scope">
+              <span>{{ parseTime(scope.row.createTime) }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column
+            label="备注"
+            width="200"
+            align="center"
+            prop="remark"
+          />
+          <el-table-column
+            label="操作"
+            align="center"
+            width="150"
+            class-name="small-padding fixed-width"
+          >
+            <template #default="scope">
+              <el-button
+                link
+                type="warning"
+                icon="Edit"
+                @click="handleUpdate(scope.row)"
+                v-hasPermi="['business:notification:edit']"
+                >修改</el-button
+              >
+              <el-button
+                link
+                type="danger"
+                icon="Delete"
+                @click="handleDelete(scope.row)"
+                v-hasPermi="['business:notification:remove']"
+                >删除</el-button
+              >
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+    </div>
+
+    <!-- 分页 -->
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      v-model:page="queryParams.pageNum"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 表单 -->
+    <notification-form
+      ref="notificationRef"
+      :get-list="getList"
+    ></notification-form>
+  </div>
+</template>
+
+<script setup name="Notification">
+import { listNotification, delNotification } from "@/api/business/notification";
+import notificationForm from "./form";
+const { proxy } = getCurrentInstance();
+/** 字典数组区 */
+/** 查询 对象 */
+
+const notificationList = ref([]);
+const loading = ref(true);
+const ids = ref([]);
+const single = ref(true);
+const multiple = ref(true);
+const total = ref(0);
+/** 查询对象 */
+const queryParams = ref({
+  pageNum: 1,
+  pageSize: 10,
+  title: null,
+  type: null,
+  content: null,
+  updateContent: null,
+  status: null,
+});
+
+/***********************  方法区  ****************************/
+
+/** 查询发版通知公告列表 */
+function getList() {
+  loading.value = true;
+  listNotification(queryParams.value).then((response) => {
+    notificationList.value = response.rows;
+    total.value = response.total;
+    loading.value = false;
+  });
+}
+
+/** 搜索按钮操作 */
+function handleQuery() {
+  queryParams.value.pageNum = 1;
+  getList();
+}
+
+/** 重置按钮操作 */
+function resetQuery() {
+  proxy.resetForm("queryRef");
+  handleQuery();
+}
+
+// 多选框选中数据
+function handleSelectionChange(selection) {
+  ids.value = selection.map((item) => item.id);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
+}
+
+/** 新增按钮操作 */
+function handleAdd() {
+  proxy.$refs.notificationRef.open();
+}
+
+/** 修改按钮操作 */
+function handleUpdate(row) {
+  const id = row.id || ids.value;
+  proxy.$refs.notificationRef.open(id);
+}
+
+/** 删除按钮操作 */
+function handleDelete(row) {
+  const _ids = row.id || ids.value;
+  proxy.$modal
+    .confirm("是否确认删除选中的数据项?")
+    .then(function () {
+      return delNotification(_ids);
+    })
+    .then(() => {
+      getList();
+      proxy.$modal.msgSuccess("删除成功!");
+    })
+    .catch(() => {});
+}
+
+/** 导出按钮操作 */
+function handleExport() {
+  proxy.download(
+    "business/notification/export",
+    {
+      ...queryParams.value,
+    },
+    `notification_${new Date().getTime()}.xlsx`
+  );
+}
+
+getList();
+</script>
+<style>
+.flex-grow {
+  flex-grow: 1;
+}
+</style>

+ 208 - 0
src/views/system/notification/wangEditor.vue

@@ -0,0 +1,208 @@
+<template>
+  <div
+    style="border: 1px solid #ccc"
+    v-loading="loading"
+    element-loading-text="文件上传中..."
+  >
+    <!-- <div style="color: red; padding-left: 18px">注:视频最佳宽度700-900</div> -->
+    <Toolbar
+      style="border-bottom: 1px solid #ccc"
+      class="count-yc-box-title"
+      :editor="editorRef"
+      :defaultConfig="toolbarConfig"
+      :mode="mode"
+    />
+
+    <Editor
+      style="min-height: 250px; overflow-y: hidden"
+      v-model="valueHtml"
+      :defaultConfig="editorConfig"
+      :mode="mode"
+      @onCreated="handleCreated"
+      class="count-yc-box"
+    />
+  </div>
+</template>
+
+<script>
+//script标签中引入
+import "@wangeditor/editor/dist/css/style.css"; // 引入 css
+import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
+import { defineExpose, onMounted, watch } from "vue";
+export default {
+  components: { Editor, Toolbar },
+  props: {
+    editValue: {
+      type: String,
+      default: "",
+    },
+  },
+  setup(props, { emit }) {
+    emits: ["select"];
+    // 编辑器实例,必须用 shallowRef
+    const editorRef = shallowRef();
+    console.log(editorRef, "editor.getAllMenuKeys()");
+    // 内容 HTML
+    const valueHtml = ref("");
+    const loading = ref(false);
+
+    watch(
+      () => props.editValue,
+      (val) => {
+        //当编辑器的内容发生变化时,把值传给父组件
+        valueHtml.value = props.editValue;
+      },
+      {
+        deep: true,
+        immediate: true,
+      }
+    );
+    //配置功能栏
+    let toolbarConfig = {
+      toolbarKeys: [
+        "headerSelect",
+        "header1",
+        "header2",
+        "header3",
+        "blockquote",
+        "|",
+        "bold",
+        "underline",
+        "italic",
+        "lineHeight",
+        // {
+        //   key: "group-more-style",
+        //   title: "更多",
+        //   iconSvg:
+        //     '<svg viewBox="0 0 1024 1024"><path d="M204.8 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path><path d="M505.6 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path><path d="M806.4 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path></svg>',
+        //   menuKeys: ["through", "code", "sup", "sub"],
+        // },
+        "color",
+        "bgColor",
+        "|",
+        "fontSize",
+        {
+          key: "group-justify",
+          title: "对齐",
+          iconSvg:
+            '<svg viewBox="0 0 1024 1024"><path d="M768 793.6v102.4H51.2v-102.4h716.8z m204.8-230.4v102.4H51.2v-102.4h921.6z m-204.8-230.4v102.4H51.2v-102.4h716.8zM972.8 102.4v102.4H51.2V102.4h921.6z"></path></svg>',
+          menuKeys: [
+            "justifyLeft",
+            "justifyRight",
+            "justifyCenter",
+            "justifyJustify",
+          ],
+        },
+        "todo",
+        // "fontFamily",
+        {
+          key: "group-indent",
+          title: "缩进",
+          iconSvg:
+            '<svg viewBox="0 0 1024 1024"><path d="M0 64h1024v128H0z m384 192h640v128H384z m0 192h640v128H384z m0 192h640v128H384zM0 832h1024v128H0z m0-128V320l256 192z"></path></svg>',
+          menuKeys: ["indent", "delIndent"],
+        },
+
+        "|",
+        // "emotion",
+        // "insertLink",
+        // "insertTable",
+        // "codeBlock",
+        "divider",
+        "clearStyle",
+        "|",
+        "undo",
+        "redo",
+      ],
+    };
+    const saveImageList = ref([]);
+
+    //编辑器配置
+    let editorConfig = {
+      placeholder: "请输入内容...",
+      // 所有的菜单配置,都要在 MENU_CONF 属性下
+      MENU_CONF: {},
+    };
+
+    // 组件销毁时,也及时销毁编辑器
+    onBeforeUnmount(() => {
+      const editor = editorRef.value;
+      if (editor == null) return;
+      editor.destroy();
+    });
+
+    const handleCreated = (editor) => {
+      editorRef.value = editor; // 记录 editor 实例,重要!
+      saveImageList.value = editor.getElemsByType("image");
+    };
+
+    watch(
+      () => valueHtml.value,
+      () => {
+        //当编辑器的内容发生变化时,把值传给父组件
+        emit("select", valueHtml.value);
+      }
+    );
+
+    // 一下方法 用作回调 但暂时未调用
+    const handleChange = (editor) => {
+      console.log("change:", editor.children);
+    };
+    const handleDestroyed = (editor) => {
+      console.log("destroyed", editor);
+    };
+    const handleFocus = (editor) => {
+      console.log("focus", editor);
+    };
+    const handleBlur = (editor) => {
+      console.log("blur", editor);
+    };
+    const customAlert = (info, type) => {
+      console.log(`【自定义提示】${type} - ${info}`);
+    };
+    const customPaste = (editor, event, callback) => {
+      console.log("ClipboardEvent 粘贴事件对象", event);
+      // const html = event.clipboardData.getData('text/html') // 获取粘贴的 html
+      // const text = event.clipboardData.getData('text/plain') // 获取粘贴的纯文本
+      // const rtf = event.clipboardData.getData('text/rtf') // 获取 rtf 数据(如从 word wsp 复制粘贴)
+
+      // 自定义插入内容
+      editor.insertText("xxx");
+
+      // 返回 false ,阻止默认粘贴行为
+      event.preventDefault();
+      callback(false); // 返回值(注意,vue 事件的返回值,不能用 return)
+
+      // 返回 true ,继续默认的粘贴行为
+      // callback(true)
+    };
+
+    //父组件调用子组件的方法清空编辑器内容
+    const abc = function () {
+      valueHtml.value = "";
+    };
+    //暴露该方法,defineExpose要引入
+    defineExpose({
+      abc,
+      valueHtml,
+    });
+
+    return {
+      editorRef,
+      valueHtml,
+      mode: "default", // 或 'simple'
+      toolbarConfig,
+      editorConfig,
+      handleCreated,
+      handleChange,
+      handleDestroyed,
+      handleFocus,
+      handleBlur,
+      customAlert,
+      customPaste,
+      abc,
+      loading,
+    };
+  },
+};
+</script>