若依分离版—增加通知公告预览功能

前言

若依分离版的通知公告没有预览功能,想开发通知公告功能

开发通知公告

1. 效果如下

  

2.具体开发内容

参考物美智能开源代码物美智能官网 - wumei smart 开源生活物联网平台。修改若依notice代码如下。

 

<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="公告标题" prop="noticeTitle">
        <el-input
          v-model="queryParams.noticeTitle"
          placeholder="请输入公告标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="操作人员" prop="createBy">
        <el-input
          v-model="queryParams.createBy"
          placeholder="请输入操作人员"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="类型" prop="noticeType">
        <el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable>
          <el-option
            v-for="dict in dict.type.sys_notice_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:notice:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:notice:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:notice:remove']"
        >删除</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="noticeId" width="100" />
      <el-table-column
        label="公告标题"
        align="center"
        prop="noticeTitle"
        :show-overflow-tooltip="true"
      />
      <el-table-column label="公告类型" align="center" prop="noticeType" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_notice_type" :value="scope.row.noticeType"/>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_notice_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="创建者" align="center" prop="createBy" width="100" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:notice:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:notice:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="openDetailDialog(scope.row.noticeId)"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改公告对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="公告标题" prop="noticeTitle">
              <el-input v-model="form.noticeTitle" placeholder="请输入公告标题" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公告类型" prop="noticeType">
              <el-select v-model="form.noticeType" placeholder="请选择公告类型">
                <el-option
                  v-for="dict in dict.type.sys_notice_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="状态">
              <el-radio-group v-model="form.status">
                <el-radio
                  v-for="dict in dict.type.sys_notice_status"
                  :key="dict.value"
                  :label="dict.value"
                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="内容">
              <editor v-model="form.noticeContent" :min-height="192"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!--通知公告详情 -->
    <el-dialog :title="form.noticeTitle" :visible.sync="openDetail" width="800px" append-to-body>
      <div style="margin-top:-20px;margin-bottom:10px;">
        <el-tag size="mini" effect="dark" type="warning" v-if="form.noticeType==2">公告</el-tag>
        <el-tag size="mini" effect="dark" v-else>信息</el-tag>
        <span style="margin-left:20px;">{{form.createTime}}</span>
      </div>
      <div v-loading="loadingDetail" class="content">
        <div v-html="form.noticeContent" style="margin-left:0px;margin-right:76px" class="ql-editor"></div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="closeDetail"> 关 闭 </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";

export default {
  name: "Notice",
  dicts: ['sys_notice_status', 'sys_notice_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 详情加载
      loadingDetail: false,
      // 打开详情
      openDetail: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 公告表格数据
      noticeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        noticeTitle: undefined,
        createBy: undefined,
        status: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        noticeTitle: [
          { required: true, message: "公告标题不能为空", trigger: "blur" }
        ],
        noticeType: [
          { required: true, message: "公告类型不能为空", trigger: "change" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询公告列表 */
    getList() {
      this.loading = true;
      listNotice(this.queryParams).then(response => {
        this.noticeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        noticeId: undefined,
        noticeTitle: undefined,
        noticeType: undefined,
        noticeContent: undefined,
        status: "0"
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.noticeId)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加公告";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const noticeId = row.noticeId || this.ids
      getNotice(noticeId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改公告";
      });
    },
    // 打开信息详情
    openDetailDialog(id) {
      this.openDetail = true;
      this.loadingDetail = true;
      getNotice(id).then(response => {
        this.form = response.data;
        this.openDetail = true;
        this.loadingDetail = false;
      });
    },
    // 取消按钮
    closeDetail() {
      this.titleDetail = "详情";
      this.openDetail = false;
      this.reset();
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.noticeId != undefined) {
            updateNotice(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addNotice(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const noticeIds = row.noticeId || this.ids
      this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?').then(function() {
        return delNotice(noticeIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    }
  }
};
</script>

3. 出现的问题及解决办法

使用物美智联的源代码,出现大图超过窗口的情况。发现解决办法如下 增加class="ql-editor"

 <div v-html="form.noticeContent" style="margin-left:0px;margin-right:76px"
 class="ql-editor"></div>

vue-quill-editor 富文本样式失效_*且听风吟的博客-CSDN博客_vue-quill-editor 失效解决方法:引入样式文件,将回显的html内容,包裹在一个div容器中,并加上对应的class。引入样式:import 'quill/dist/quill.snow.css'回显的 div 加上对应的class:<div class="ql-container ql-snow"> <div class="ql-editor" v-html="formData.content" /></div>问题解决啦:...https://blog.csdn.net/HH18700418030/article/details/120180418?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-6-120180418-null-null.pc_agg_new_rank&utm_term=quill%20%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%20%E8%8B%A5%E4%BE%9D&spm=1000.2123.3001.4430

  • 10
    点赞
  • 56
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
可以使用 GStreamer 中的多个插件来实现拍照功能,例如 v4l2sink、jpegenc 和 multifilesink。具体流程为:先通过 v4l2src 插件采集视频流,然后将视频流转换为 JPEG 格式并保存到文件中,最后将 JPEG 文件显示在 xvimagesink 上。 以下是一个示例程序,可以启动 MIPI CSI 摄像头的预览,并在按下回车键后拍照并保存 JPEG 文件: ```c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <termios.h> #include <sys/select.h> #include <sys/time.h> #define WIDTH 720 #define HEIGHT 576 #define FPS 15 int main(void) { // 设置环境变量 setenv("DISPLAY", ":0.0", 1); setenv("XDG_RUNTIME_DIR", "/run/user/1000", 1); // 检查摄像头设备文件是否存在 char *dev_path = NULL; if (access("/dev/video51", F_OK) == 0) { dev_path = "/dev/video51"; } else if (access("/dev/video31", F_OK) == 0) { dev_path = "/dev/video31"; } else if (access("/dev/video11", F_OK) == 0) { dev_path = "/dev/video11"; } else { fprintf(stderr, "Can not find camera!!!\n"); return 1; } // 启动预览 pipeline char cmd[256]; snprintf(cmd, sizeof(cmd), "gst-launch-1.0 v4l2src device=%s io-mode=4 ! video/x-raw,format=NV12,width=%d,height=%d,framerate=%d/1 ! xvimagesink > /dev/null 2>&1 &", dev_path, WIDTH, HEIGHT, FPS); system(cmd); printf("MIPI CSI Camera Preview started!\n"); // 设置串口 struct termios tty; memset(&tty, 0, sizeof(tty)); tty.c_iflag = IGNBRK; tty.c_oflag = 0; tty.c_cflag = CS8 | CREAD | CLOCAL; tty.c_lflag = 0; tty.c_cc[VTIME] = 0; tty.c_cc[VMIN] = 1; cfsetospeed(&tty, B115200); cfsetispeed(&tty, B115200); int fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY); tcsetattr(fd, TCSANOW, &tty); fcntl(fd, F_SETFL, O_NONBLOCK); printf("Press Enter to take a photo...\n"); while (1) { fd_set fds; FD_ZERO(&fds); FD_SET(fd, &fds); struct timeval tv = {0}; tv.tv_sec = 1; int ret = select(fd + 1, &fds, NULL, NULL, &tv); if (ret > 0) { char buf[256]; read(fd, buf, sizeof(buf)); if (buf[0] == '\n') { // 拍照 char filename[256]; snprintf(filename, sizeof(filename), "photo-%ld.jpg", time(NULL)); snprintf(cmd, sizeof(cmd), "gst-launch-1.0 v4l2src device=%s ! video/x-raw,format=NV12,width=%d,height=%d,framerate=%d/1 ! jpegenc ! multifilesink location=%s > /dev/null 2>&1", dev_path, WIDTH, HEIGHT, FPS, filename); system(cmd); printf("Photo saved to %s\n", filename); } } } close(fd); return 0; } ``` 在程序中,我们使用了 select 函数来监听串口输入,如果读取到回车键,则执行拍照操作。拍照时,我们使用 jpegenc 插件将视频流转换为 JPEG 格式,然后使用 multifilesink 插件将 JPEG 文件保存到指定路径下。同时,预览 pipeline 依然在后台运行,可以在拍照后继续进行预览。 需要注意的是,如果使用该程序,需要在终端上按下 Enter 键才能拍照,而且需要连接串口设备。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值