|
|
@@ -0,0 +1,528 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
+ <el-form-item label="别名" prop="secondName">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.secondName"
|
|
|
+ placeholder="请输入别名"
|
|
|
+ clearable
|
|
|
+ size="small"
|
|
|
+ @keyup.enter.native="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="标题" prop="title">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.title"
|
|
|
+ placeholder="请输入标题"
|
|
|
+ clearable
|
|
|
+ size="small"
|
|
|
+ @keyup.enter.native="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+
|
|
|
+ <el-form-item label="打卡类型" prop="type">
|
|
|
+ <el-select v-model="queryParams.type" placeholder="请选择打卡类型" clearable size="small">
|
|
|
+ <el-option
|
|
|
+ v-for="item in signTypeOptions"
|
|
|
+ :key="item.dictValue"
|
|
|
+ :label="item.dictLabel"
|
|
|
+ :value="item.dictValue"
|
|
|
+ />
|
|
|
+ </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="['his:article: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="['his:article: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="['his:article:remove']"
|
|
|
+ >删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="warning"
|
|
|
+ plain
|
|
|
+ icon="el-icon-download"
|
|
|
+ size="mini"
|
|
|
+ :loading="exportLoading"
|
|
|
+ @click="handleExport"
|
|
|
+ v-hasPermi="['his:article:export']"
|
|
|
+ >导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table border v-loading="loading" :data="articleList" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="ID" align="center" prop="id" />
|
|
|
+ <el-table-column label="别名" align="center" prop="secondName" />
|
|
|
+ <el-table-column label="封面图" align="center" prop="imageUrl" >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-popover v-if="scope.row.imageUrl!=null"
|
|
|
+ placement="right"
|
|
|
+ title=""
|
|
|
+ trigger="hover">
|
|
|
+ <img slot="reference" :src="scope.row.imageUrl" width="50px">
|
|
|
+ <img :src="scope.row.imageUrl" style="max-width: 150px;">
|
|
|
+ </el-popover>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="标题" align="center" prop="title" />
|
|
|
+ <el-table-column label="红包金额" align="center" prop="amount" />
|
|
|
+ <el-table-column label="打卡类型" align="center" prop="type" >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <dict-tag :options="signTypeOptions" :value="scope.row.type"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="是否打卡" align="center" prop="signFlag" >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <dict-tag :options="signFlagOptions" :value="scope.row.signFlag"/>
|
|
|
+ </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="['his:article:edit']"
|
|
|
+ >修改</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ @click="handleDelete(scope.row)"
|
|
|
+ v-hasPermi="['his:article:remove']"
|
|
|
+ >删除</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="700px" append-to-body :rules="rules">
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
+ <el-form-item label="标题" prop="title">
|
|
|
+ <el-input v-model="form.title" placeholder="请输入标题" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="别名" prop="secondName">
|
|
|
+ <el-input v-model="form.secondName" placeholder="请输入别名" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="医生" prop="doctorId">
|
|
|
+ <el-select v-model="form.doctorId" placeholder="请选择医生" filterable >
|
|
|
+ <el-option
|
|
|
+ v-for="dict in doctorOptions"
|
|
|
+ :key="dict.dictValue"
|
|
|
+ :label="dict.dictLabel"
|
|
|
+ :value="dict.dictValue"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="封面图" prop="imageUrl">
|
|
|
+ <el-upload
|
|
|
+ v-model="form.imageUrl"
|
|
|
+ class="avatar-uploader"
|
|
|
+ :action="uploadUrl"
|
|
|
+ :show-file-list="false"
|
|
|
+ :on-success="handleAvatarSuccess"
|
|
|
+ :before-upload="beforeAvatarUpload">
|
|
|
+ <img v-if="form.imageUrl" :src="form.imageUrl" class="avatar" width="200px">
|
|
|
+ <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="内容" prop="content">
|
|
|
+ <Editor ref="myeditor" @on-text-change="updateText"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="视频地址" prop="videoUrl">
|
|
|
+ <div>
|
|
|
+ <el-upload
|
|
|
+ ref="upload"
|
|
|
+ class="upload-demo"
|
|
|
+ :action="uploadUrl"
|
|
|
+ :on-success="handleSuccess"
|
|
|
+ :before-upload="beforeUpload"
|
|
|
+ :limit="1"
|
|
|
+ :accept="videoAccept"
|
|
|
+ >
|
|
|
+ <el-button size="small" type="primary">点击上传视频</el-button>
|
|
|
+ </el-upload>
|
|
|
+ <video v-if="form.videoUrl" :src="form.videoUrl" controls style="max-width: 400px; max-height: 400px;"></video>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="是否打卡" prop="signFlag">
|
|
|
+ <el-select v-model="form.signFlag" placeholder="请选择打卡类型">
|
|
|
+ <el-option
|
|
|
+ v-for="item in signFlagOptions"
|
|
|
+ :key="item.dictValue"
|
|
|
+ :label="item.dictLabel"
|
|
|
+ :value="Number(item.dictValue)"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="form.signFlag == 1" label="打卡类型" prop="type">
|
|
|
+ <el-select v-model="form.type" placeholder="请选择打卡类型">
|
|
|
+ <el-option
|
|
|
+ v-for="item in signTypeOptions"
|
|
|
+ :key="item.dictValue"
|
|
|
+ :label="item.dictLabel"
|
|
|
+ :value="Number(item.dictValue)"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="form.signFlag == 1" label="红包金额" prop="amount">
|
|
|
+ <el-input-number v-model="form.amount" :precision="1" :step="1" :min="0.1" :max="5" />
|
|
|
+ </el-form-item>
|
|
|
+ </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>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { listArticle, getArticle, delArticle, addArticle, updateArticle, exportArticle } from "@/api/his/signArticle";
|
|
|
+import {doctorOptions} from "@/api/his/doctor";
|
|
|
+import Editor from '@/components/Editor/wang';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "signArticle",
|
|
|
+ components: { Editor },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ videoUrl: "",
|
|
|
+ videoAccept:"video/*",
|
|
|
+ uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
|
|
|
+ baseUrl: process.env.VUE_APP_BASE_API,
|
|
|
+
|
|
|
+ // 遮罩层
|
|
|
+ loading: true,
|
|
|
+ // 导出遮罩层
|
|
|
+ exportLoading: false,
|
|
|
+ // 选中数组
|
|
|
+ ids: [],
|
|
|
+ // 非单个禁用
|
|
|
+ single: true,
|
|
|
+ // 非多个禁用
|
|
|
+ multiple: true,
|
|
|
+ // 显示搜索条件
|
|
|
+ showSearch: true,
|
|
|
+ // 总条数
|
|
|
+ total: 0,
|
|
|
+ // 打卡文章表格数据
|
|
|
+ articleList: [],
|
|
|
+ // 弹出层标题
|
|
|
+ title: "",
|
|
|
+ // 是否显示弹出层
|
|
|
+ open: false,
|
|
|
+ // 查询参数
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ secondName: null,
|
|
|
+ doctorId: null,
|
|
|
+ imageUrl: null,
|
|
|
+ title: null,
|
|
|
+ content: null,
|
|
|
+ views: null,
|
|
|
+ videoUrl: null,
|
|
|
+ amount: null,
|
|
|
+ type: null,
|
|
|
+ signFlag: null
|
|
|
+ },
|
|
|
+ // 表单参数
|
|
|
+ form: {},
|
|
|
+ // 表单校验
|
|
|
+ rules: {
|
|
|
+ title: [
|
|
|
+ { required: true, message: "标题不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ secondName: [
|
|
|
+ { required: true, message: "别名不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ imageUrl: [
|
|
|
+ { required: true, message: "封面图不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ content: [
|
|
|
+ { required: true, message: "内容不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ signFlag: [
|
|
|
+ { required: true, message: "请选择是否打卡", trigger: "change" }
|
|
|
+ ],
|
|
|
+ type: [
|
|
|
+ { required: true, message: "请选择打卡类型", trigger: "change" }
|
|
|
+ ],
|
|
|
+ amount: [
|
|
|
+ { required: true, message: "红包金额不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ signTypeOptions:[
|
|
|
+ {
|
|
|
+ "dictLabel": "直接打卡",
|
|
|
+ "dictValue": "1",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "dictLabel": "图片",
|
|
|
+ "dictValue": "2",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "dictLabel": "视频",
|
|
|
+ "dictValue": "3",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ signFlagOptions:[
|
|
|
+ {
|
|
|
+ "dictLabel": "否",
|
|
|
+ "dictValue": "0",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "dictLabel": "是",
|
|
|
+ "dictValue": "1",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ doctorOptions: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getList();
|
|
|
+ doctorOptions().then(res => {
|
|
|
+ this.doctorOptions = res.rows;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ handleSuccess(response, file) {
|
|
|
+ // 上传成功后的回调函数
|
|
|
+ this.myloading.close();
|
|
|
+ this.form.videoUrl = response.url;
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
+ },
|
|
|
+ beforeUpload(file) {
|
|
|
+ // 上传前的钩子函数,可以在这里对文件进行处理
|
|
|
+ // 返回 false 则取消上传
|
|
|
+
|
|
|
+ // 例如限制文件大小
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 200;
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error('上传视频文件大小不能超过 200MB!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.myloading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: '上传中',
|
|
|
+ spinner: 'el-icon-loading',
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)'
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+ updateText(text){
|
|
|
+ this.form.content=text
|
|
|
+ },
|
|
|
+ handleAvatarSuccess(res, file) {
|
|
|
+ if(res.code==200){
|
|
|
+ this.form.imageUrl=res.url;
|
|
|
+ self.$forceUpdate()
|
|
|
+ }else{
|
|
|
+ this.msgError(res.msg);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeAvatarUpload(file) {
|
|
|
+ const isLt1M = file.size / 1024 / 1024 < 1;
|
|
|
+ if (!isLt1M) {
|
|
|
+ this.$message.error('上传图片大小不能超过 1MB!');
|
|
|
+ }
|
|
|
+ return isLt1M;
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 查询打卡文章列表 */
|
|
|
+ getList() {
|
|
|
+ this.loading = true;
|
|
|
+ listArticle(this.queryParams).then(response => {
|
|
|
+ this.articleList = response.rows;
|
|
|
+ this.total = response.total;
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 取消按钮
|
|
|
+ cancel() {
|
|
|
+ this.open = false;
|
|
|
+ this.reset();
|
|
|
+ },
|
|
|
+ // 表单重置
|
|
|
+ reset() {
|
|
|
+ this.form = {
|
|
|
+ id: null,
|
|
|
+ secondName: null,
|
|
|
+ doctorId: null,
|
|
|
+ imageUrl: null,
|
|
|
+ title: null,
|
|
|
+ content: null,
|
|
|
+ views: null,
|
|
|
+ createTime: null,
|
|
|
+ updateTime: null,
|
|
|
+ videoUrl: null,
|
|
|
+ amount: null,
|
|
|
+ type: null,
|
|
|
+ signFlag: null
|
|
|
+ };
|
|
|
+ this.resetForm("form");
|
|
|
+ },
|
|
|
+ /** 搜索按钮操作 */
|
|
|
+ handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ /** 重置按钮操作 */
|
|
|
+ resetQuery() {
|
|
|
+ this.resetForm("queryForm");
|
|
|
+ this.handleQuery();
|
|
|
+ },
|
|
|
+ // 多选框选中数据
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ this.ids = selection.map(item => item.id)
|
|
|
+ this.single = selection.length!==1
|
|
|
+ this.multiple = !selection.length
|
|
|
+ },
|
|
|
+ /** 新增按钮操作 */
|
|
|
+ handleAdd() {
|
|
|
+ this.reset();
|
|
|
+ this.open = true;
|
|
|
+ this.title = "添加打卡文章";
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$refs.myeditor.setText("");
|
|
|
+ }, 100);
|
|
|
+ },
|
|
|
+ /** 修改按钮操作 */
|
|
|
+ handleUpdate(row) {
|
|
|
+ this.reset();
|
|
|
+ const id = row.id || this.ids
|
|
|
+ getArticle(id).then(response => {
|
|
|
+ this.form = response.data;
|
|
|
+ this.open = true;
|
|
|
+ this.title = "修改打卡文章";
|
|
|
+ setTimeout(() => {
|
|
|
+ if(this.form.content==null){
|
|
|
+ this.$refs.myeditor.setText("");
|
|
|
+ }else{
|
|
|
+ this.$refs.myeditor.setText(this.form.content);
|
|
|
+ }
|
|
|
+ }, 1);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 提交按钮 */
|
|
|
+ submitForm() {
|
|
|
+ this.$refs["form"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.form.id != null) {
|
|
|
+ updateArticle(this.form).then(response => {
|
|
|
+ this.msgSuccess("修改成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addArticle(this.form).then(response => {
|
|
|
+ this.msgSuccess("新增成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 删除按钮操作 */
|
|
|
+ handleDelete(row) {
|
|
|
+ const ids = row.id || this.ids;
|
|
|
+ this.$confirm('是否确认删除打卡文章编号为"' + ids + '"的数据项?', "警告", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(function() {
|
|
|
+ return delArticle(ids);
|
|
|
+ }).then(() => {
|
|
|
+ this.getList();
|
|
|
+ this.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+ /** 导出按钮操作 */
|
|
|
+ handleExport() {
|
|
|
+ const queryParams = this.queryParams;
|
|
|
+ this.$confirm('是否确认导出所有打卡文章数据项?', "警告", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ this.exportLoading = true;
|
|
|
+ return exportArticle(queryParams);
|
|
|
+ }).then(response => {
|
|
|
+ this.download(response.msg);
|
|
|
+ this.exportLoading = false;
|
|
|
+ }).catch(() => {});
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+ .avatar-uploader .el-upload {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ .avatar-uploader .el-upload:hover {
|
|
|
+ border-color: #409EFF;
|
|
|
+ }
|
|
|
+
|
|
|
+ .avatar-uploader-icon {
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 150px;
|
|
|
+ height: 150px;
|
|
|
+ line-height: 150px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+</style>
|