公告管理
This commit is contained in:
1 parent
374ce74e2d
commit
c0621ff48b
15 files changed
+4641
No files matched your search
@@ -0,0 +1,725 @@
|
||||
{% extends 'template/jhTemplateV4.html'%} {% block vueTemplate %}
|
||||
|
||||
<script type="text/html" id="app-template">
|
||||
<div>
|
||||
<v-app mobile-breakpoint="sm">
|
||||
<jh-menu />
|
||||
<v-main class="mt-15">
|
||||
<!-- 头部内容 >>>>>>>>>>>>> -->
|
||||
<div class="jh-page-second-bar px-8">
|
||||
<v-row class="align-center">
|
||||
<v-col cols="12" xs="12" sm="12" md="4" xl="3">
|
||||
<div class="py-4 text-body-1 font-weight-bold">公告管理
|
||||
<!-- 帮助页按钮 -->
|
||||
<span role="button" class="success--text font-weight-regular jh-font-size-13 ml-2" @click="isHelpPageDrawerShown = true">
|
||||
<v-icon size="13" class="success--text">mdi-help-circle-outline</v-icon>帮助
|
||||
</span>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
<!-- <<<<<<<<<<<<< 头部内容 -->
|
||||
|
||||
<div class="jh-page-body-container px-8">
|
||||
<!-- 页面内容 >>>>>>>>>>>>> -->
|
||||
<v-card class="rounded-lg">
|
||||
<v-row class="ma-0 pa-4 d-flex align-center">
|
||||
<!-- 新增按钮 -->
|
||||
<v-btn color="success" class="elevation-0 mr-2" @click="doUiAction('startCreateItem')" small>新建公告
|
||||
</v-btn>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-col cols="12" xs="8" sm="4" md="3" class="pa-0">
|
||||
<v-text-field color="success" v-model="searchInput" prefix="搜索:" class="jh-v-input" dense filled single-line></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- 表格 -->
|
||||
<v-data-table
|
||||
:headers="headers"
|
||||
:items="tableData"
|
||||
:search="searchInput"
|
||||
:footer-props="{ itemsPerPageOptions: [20, 50, -1], itemsPerPageText: '每页', itemsPerPageAllText: '所有'}"
|
||||
:items-per-page="-1"
|
||||
mobile-breakpoint="0"
|
||||
:loading="isTableLoading"
|
||||
checkbox-color="success"
|
||||
:class="{'zebraLine': isTableZebraLineShown }"
|
||||
fixed-header
|
||||
class="jh-fixed-table-height elevation-0 mt-0 mb-xs-4">
|
||||
|
||||
<template v-slot:item.afficheDesc="{ item }">
|
||||
<div v-html="item.afficheDesc" @click="doUiAction('viewItem', { item })"></div>
|
||||
</template>
|
||||
<!-- 表格操作按钮 -->
|
||||
<template v-slot:item.action="{ item }">
|
||||
<span role="button" class="primary--text font-weight-medium font-size-2" @click="doUiAction('viewItem', { item })">
|
||||
<v-icon size="16" class="primary--text">mdi-note-edit-outline</v-icon>预览
|
||||
</span>
|
||||
<span v-if="item.afficheStatus==='草稿'" role="button" class="primary--text font-weight-medium font-size-2" @click="doUiAction('startUpdateItem', { item })">
|
||||
<v-icon size="16" class="primary--text">mdi-note-edit-outline</v-icon>修改
|
||||
</span>
|
||||
</template>
|
||||
<!-- <template v-slot:item.afficheTitle="{ item }">
|
||||
<a @click="doUiAction('viewItem', { item })">{{item.afficheTitle}}</a>
|
||||
</template> -->
|
||||
<!-- 没有数据 -->
|
||||
<template v-slot:loading>
|
||||
<div class="jh-no-data">数据加载中</div>
|
||||
</template>
|
||||
<template v-slot:no-data>
|
||||
<div class="jh-no-data">暂无数据</div>
|
||||
</template>
|
||||
<template v-slot:no-results>
|
||||
<div class="jh-no-data">暂无数据</div>
|
||||
</template>
|
||||
<!-- 表格分页 -->
|
||||
<template v-slot:footer.page-text="pagination">
|
||||
<span>{{pagination.pageStart}}-{{pagination.pageStop}}</span>
|
||||
<span class="ml-1">共{{pagination.itemsLength}}条</span>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
<!-- 新增抽屉 -->
|
||||
<v-navigation-drawer v-if="isCreateDrawerShown" v-model="isCreateDrawerShown" :permanent="isCreateDrawerShown" fixed temporary right width="80%" class="elevation-24">
|
||||
<v-form ref="createForm" lazy-validation>
|
||||
<!-- 抽屉标题 -->
|
||||
<v-row no-gutters>
|
||||
<span class="text-h7 font-weight-bold pa-4">新建公告</span>
|
||||
</v-row>
|
||||
<v-divider class="jh-divider"></v-divider>
|
||||
<!-- 抽屉表单 -->
|
||||
<!-- <v-text-field class="jh-v-input" dense single-line filled v-model="createItem.xxxId" :rules="validationRules.requireRules"></v-text-field> -->
|
||||
<v-row class="mt-0 px-4">
|
||||
<v-col cols="12" sm="12" md="4">
|
||||
<span class="jh-input-label"><span class="red--text">*</span>公告名称</span>
|
||||
<v-text-field :rules="validationRules.requireRules" :rules="validationRules.requireRules" class="jh-v-input" dense single-line filled v-model="createItem.afficheTitle"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4">
|
||||
<span class="jh-input-label"><span class="red--text">*</span>通知范围</span>
|
||||
<v-text-field
|
||||
:rules="validationRules.requireRules"
|
||||
multiple
|
||||
class="jh-v-input"
|
||||
dense single-line filled v-model="createItem.afficheMemberIdList"
|
||||
readonly
|
||||
@click="isDialogShown=true"
|
||||
>
|
||||
<template v-slot:selection="{ item, index }">
|
||||
<v-chip v-if="index === 0">
|
||||
<span>{{ item }}</span>
|
||||
</v-chip>
|
||||
<span
|
||||
v-if="index === 1"
|
||||
class="grey--text text-caption"
|
||||
>
|
||||
(+{{ createItem?.afficheMemberIdList?.length - 1 }} others)
|
||||
</span>
|
||||
</template>
|
||||
</v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="12" md="12">
|
||||
<span class="jh-input-label"><span class="red--text">*</span>公告内容</span>
|
||||
|
||||
<div id="editorMdContainer">
|
||||
<textarea style="display:none;">{{ createItem.afficheContent }}</textarea>
|
||||
</div>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
|
||||
<!-- 抽屉操作按钮 -->
|
||||
<v-row class="justify-end mx-0 mt-8 px-6">
|
||||
<v-btn color="success" @click="doUiAction('createItem', {afficheStatus: '已发送'})" small>发送</v-btn>
|
||||
<v-btn color="success" class="ml-2" @click="doUiAction('createItem', {afficheStatus: '草稿'})" small>存为草稿</v-btn>
|
||||
<v-btn class="elevation-0 ml-2" @click="isCreateDrawerShown = false" small>取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
<select-org-user-dialog
|
||||
:show.sync="isDialogShown"
|
||||
:selected-ids.sync="createItem.afficheMemberIdList"
|
||||
@confirm="doUiAction('addPerson', $event)"
|
||||
></select-org-user-dialog>
|
||||
<!-- 抽屉关闭按钮 -->
|
||||
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isCreateDrawerShown = false">
|
||||
<v-icon>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-navigation-drawer>
|
||||
|
||||
<!-- 更新抽屉 -->
|
||||
<v-navigation-drawer v-if="isUpdateDrawerShown" v-model="isUpdateDrawerShown" :permanent="isUpdateDrawerShown" fixed temporary right width="80%" class="elevation-24">
|
||||
<v-form ref="createForm" lazy-validation>
|
||||
<!-- 抽屉标题 -->
|
||||
<v-row no-gutters>
|
||||
<span class="text-h7 font-weight-bold pa-4">编辑公告</span>
|
||||
</v-row>
|
||||
<v-divider class="jh-divider"></v-divider>
|
||||
<v-row class="mt-0 px-4">
|
||||
<v-col cols="12" sm="12" md="4">
|
||||
<span class="jh-input-label"><span class="red--text">*</span>公告名称</span>
|
||||
<v-text-field :rules="validationRules.requireRules" :rules="validationRules.requireRules" class="jh-v-input" dense single-line filled v-model="updateItem.afficheTitle"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="4">
|
||||
<span class="jh-input-label"><span class="red--text">*</span>通知范围</span>
|
||||
<v-text-field
|
||||
:rules="validationRules.requireRules"
|
||||
multiple
|
||||
class="jh-v-input"
|
||||
dense single-line filled v-model="updateItem.afficheMemberIdList"
|
||||
readonly
|
||||
@click="isDialogShown=true"
|
||||
>
|
||||
<template v-slot:selection="{ item, index }">
|
||||
<v-chip v-if="index === 0">
|
||||
<span>{{ item }}</span>
|
||||
</v-chip>
|
||||
<span
|
||||
v-if="index === 1"
|
||||
class="grey--text text-caption"
|
||||
>
|
||||
(+{{ updateItem?.afficheMemberIdList?.length - 1 }} others)
|
||||
</span>
|
||||
</template>
|
||||
</v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="12" md="12">
|
||||
<span class="jh-input-label"><span class="red--text">*</span>公告内容</span>
|
||||
|
||||
<div id="editorMdContainer">
|
||||
<textarea style="display:none;">{{ updateItem.afficheContent }}</textarea>
|
||||
</div>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
|
||||
<!-- 抽屉操作按钮 -->
|
||||
<v-row class="justify-end mx-0 mt-8 px-6">
|
||||
<v-btn color="success" @click="doUiAction('updateItem', {afficheStatus: '已发送'})" small>发送</v-btn>
|
||||
<v-btn color="success" class="ml-2" @click="doUiAction('updateItem', {afficheStatus: '草稿'})" small>更新草稿</v-btn>
|
||||
<v-btn class="elevation-0 ml-2" @click="isUpdateDrawerShown = false" small>取消</v-btn>
|
||||
</v-row>
|
||||
</v-form>
|
||||
<!-- 抽屉关闭按钮 -->
|
||||
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isUpdateDrawerShown = false">
|
||||
<v-icon>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<select-org-user-dialog
|
||||
:show.sync="isDialogShown"
|
||||
:selected-ids.sync="updateItem.afficheMemberIdList"
|
||||
@confirm="doUiAction('addPerson', $event)"
|
||||
></select-org-user-dialog>
|
||||
</v-navigation-drawer>
|
||||
|
||||
<!-- 抽屉关闭按钮 -->
|
||||
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isViewDrawerShown = false">
|
||||
<v-icon>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-navigation-drawer>
|
||||
<!-- <<<<<<<<<<<<< 页面内容 -->
|
||||
</div>
|
||||
|
||||
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
|
||||
<v-navigation-drawer v-if="isHelpPageDrawerLoaded" v-model="isHelpPageDrawerShown" :permanent="isHelpPageDrawerShown" fixed temporary right width="80%" class="elevation-24">
|
||||
<iframe style="border: 0" :src="`/${appInfo.appId}/pageDoc#404.md`" width="100%" height="100%"></iframe>
|
||||
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isHelpPageDrawerShown = false">
|
||||
<v-icon>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-navigation-drawer>
|
||||
<!-- <<<<<<<<<<<<< 帮助页抽屉 -->
|
||||
|
||||
</v-main>
|
||||
</v-app>
|
||||
|
||||
<jh-toast />
|
||||
<jh-mask />
|
||||
<jh-confirm-dialog />
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<div id="app"></div>
|
||||
|
||||
{% endblock %}
|
||||
{% block vueScript %}
|
||||
{% include 'component/select-org-user-dialog.html' %}
|
||||
|
||||
<link rel="stylesheet" href="/<$ ctx.app.config.appId $>/public/plugins/editor.md/css/editormd.min.css" />
|
||||
<script src="/<$ ctx.app.config.appId $>/public/lib/jquery/jquery.min.js"></script>
|
||||
<script src="/<$ ctx.app.config.appId $>/public/plugins/editor.md/editormd.js"></script>
|
||||
|
||||
<script type="module">
|
||||
new Vue({
|
||||
el: "#app",
|
||||
template: "#app-template",
|
||||
vuetify: new Vuetify(),
|
||||
data: () => ({
|
||||
// 面包屑
|
||||
breadcrumbs: [
|
||||
{
|
||||
text: "首页",
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
text: "通知管理",
|
||||
disabled: true,
|
||||
},
|
||||
],
|
||||
isHelpPageDrawerShown: false,
|
||||
isHelpPageDrawerLoaded: false,
|
||||
isMobile: window.innerWidth < 500,
|
||||
// 表格相关数据
|
||||
isTableZebraLineShown: true,
|
||||
validationRules: {
|
||||
requireRules: [(v) => !!v || "必填"],
|
||||
},
|
||||
// 下拉选项
|
||||
constantObj: {
|
||||
afficheStatus: [
|
||||
{ text: "草稿", value: "草稿" },
|
||||
{ text: "已发送", value: "已发送" },
|
||||
],
|
||||
},
|
||||
currentSceneId: null,
|
||||
serverSearchInput: {
|
||||
|
||||
},
|
||||
searchInput: null,
|
||||
isTableLoading: true,
|
||||
tableData: [],
|
||||
headers: [
|
||||
{ text: "公告名称", value: "afficheTitle", width: 120 },
|
||||
{ text: "状态", value: "afficheStatus", width: 120 },
|
||||
{ text: "通知范围", value: "afficheMemberIdList", width: 120 },
|
||||
{ text: "创建时间", value: "afficheCreateAt", width: 250 },
|
||||
{ text: "操作", value: "action", width: 150 },
|
||||
],
|
||||
|
||||
isCreateDrawerShown: false,
|
||||
createItem: {},
|
||||
createActionData: {},
|
||||
deleteItem: {},
|
||||
deleteItemId: null,
|
||||
|
||||
isUpdateDrawerShown: false,
|
||||
updateItem: {},
|
||||
updateActionData: {},
|
||||
|
||||
userList: [],
|
||||
isViewDrawerShown: false,
|
||||
|
||||
isMoreMenuShown: false,
|
||||
|
||||
isDialogShown: false,
|
||||
}),
|
||||
watch: {
|
||||
isHelpPageDrawerShown(val) {
|
||||
if (val && !this.isHelpPageDrawerLoaded) {
|
||||
this.isHelpPageDrawerLoaded = true;
|
||||
}
|
||||
},
|
||||
},
|
||||
async created() { },
|
||||
mounted() {
|
||||
this.doUiAction("initPageData");
|
||||
},
|
||||
methods: {
|
||||
async doUiAction(uiActionId, uiActionData) {
|
||||
switch (uiActionId) {
|
||||
case "initPageData":
|
||||
await this.getTableData();
|
||||
break;
|
||||
case "getTableData":
|
||||
await this.getTableData();
|
||||
break;
|
||||
case "startCreateItem":
|
||||
await this.prepareCreateFormData();
|
||||
await this.openCreateDrawer();
|
||||
break;
|
||||
case "createItem":
|
||||
await this.prepareCreateValidate();
|
||||
await this.confirmCreateItemDialog();
|
||||
await this.prepareDoCreateItem(uiActionData);
|
||||
await this.doCreateItem();
|
||||
await this.closeCreateDrawer();
|
||||
await this.getTableData();
|
||||
break;
|
||||
case "startUpdateItem":
|
||||
await this.prepareUpdateFormData(uiActionData);
|
||||
await this.openUpdateDrawer();
|
||||
break;
|
||||
case "updateItem":
|
||||
await this.prepareCreateValidate();
|
||||
await this.confirmUpdateItemDialog();
|
||||
await this.prepareDoUpdateItem(uiActionData);
|
||||
await this.doUpdateItem();
|
||||
await this.closeUpdateDrawer();
|
||||
await this.getTableData();
|
||||
break;
|
||||
case "addPerson":
|
||||
await this.addPerson(uiActionData);
|
||||
break;
|
||||
case "viewItem":
|
||||
window.open(
|
||||
`/<$ ctx.app.config.appId $>/page/afficheViewer?afficheId=${uiActionData.item.afficheId}`
|
||||
);
|
||||
break;
|
||||
default:
|
||||
console.error("[doUiAction] uiActionId not find", { uiActionId });
|
||||
break;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取表格数据
|
||||
*/
|
||||
async getTableData() {
|
||||
this.isTableLoading = true;
|
||||
const whereData = _.pickBy(this.serverSearchInput, _.identity);
|
||||
|
||||
const rows = (
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: "afficheManagement",
|
||||
actionId: "selectItemList",
|
||||
actionData: {},
|
||||
where: whereData,
|
||||
orderBy: [{ column: "operationAt", order: "desc" }],
|
||||
},
|
||||
},
|
||||
})
|
||||
).data.appData.resultData.rows;
|
||||
rows.forEach((item) => {
|
||||
item.afficheMemberIdList = (item.afficheMemberIdList || "").split(",");
|
||||
});
|
||||
|
||||
this.tableData = rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
// ---------- 新增数据 uiAction >>>>>>>>>> --------
|
||||
async prepareCreateFormData() {
|
||||
// Tips: 测试数据
|
||||
this.createItem = {
|
||||
afficheTitle: `公告${+new Date()}`,
|
||||
afficheMemberIdList: [],
|
||||
afficheContent: `公告${+new Date()}`,
|
||||
afficheStatus: "草稿",
|
||||
};
|
||||
this.actionKey = "createItem";
|
||||
},
|
||||
|
||||
async openCreateDrawer() {
|
||||
this.isCreateDrawerShown = true;
|
||||
|
||||
this.initEditorMd(this, "afficheContent", {
|
||||
image: () => {
|
||||
this.openImageUploadDrawer();
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async prepareCreateValidate() {
|
||||
if (await this.$refs.createForm.validate()) {
|
||||
return true;
|
||||
}
|
||||
throw new Error("请完善表单信息");
|
||||
},
|
||||
|
||||
async confirmCreateItemDialog() {
|
||||
if (
|
||||
(await window.confirmDialog({
|
||||
title: "新增",
|
||||
content: "确定新增吗?",
|
||||
})) === false
|
||||
) {
|
||||
throw new Error("[confirmCreateFormDialog] 否");
|
||||
}
|
||||
},
|
||||
|
||||
prepareDoCreateItem({ afficheStatus }) {
|
||||
const { id, ...data } = this.createItem;
|
||||
data.afficheMemberIdList = data.afficheMemberIdList.join(",");
|
||||
data.afficheCreateAt = dayjs().format("YYYY-MM-DD hh:mm:ss");
|
||||
data.afficheStatus = afficheStatus;
|
||||
this.createActionData = data;
|
||||
},
|
||||
|
||||
async doCreateItem() {
|
||||
await window.vtoast.loading("新增数据");
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: "afficheManagement",
|
||||
actionId: "insertItem",
|
||||
actionData: this.createActionData,
|
||||
bizIdGenerate: {
|
||||
tableName: "affiche",
|
||||
prefix: "GG",
|
||||
type: "idSequence",
|
||||
bizId: "afficheId",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
await window.vtoast.success("新增数据成功");
|
||||
},
|
||||
async closeCreateDrawer() {
|
||||
this.isCreateDrawerShown = false;
|
||||
this.createItem = {};
|
||||
this.createActionData = null;
|
||||
},
|
||||
// ---------- <<<<<<<<<<< 新增数据 uiAction ---------
|
||||
// ---------- 更新数据 uiAction >>>>>>>>>> --------
|
||||
|
||||
async prepareUpdateFormData({ item }) {
|
||||
this.updateItem = item;
|
||||
this.actionKey = "updateItem";
|
||||
},
|
||||
async openUpdateDrawer() {
|
||||
this.isUpdateDrawerShown = true;
|
||||
this.initEditorMd(this, "afficheContent", {
|
||||
image: () => {
|
||||
this.openImageUploadDrawer();
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async confirmUpdateItemDialog() {
|
||||
if (
|
||||
(await window.confirmDialog({
|
||||
title: "更新",
|
||||
content: "确定更新吗?",
|
||||
})) === false
|
||||
) {
|
||||
throw new Error("[confirmCreateFormDialog] 否");
|
||||
}
|
||||
},
|
||||
|
||||
prepareDoUpdateItem({ afficheStatus }) {
|
||||
const {
|
||||
afficheMemberIdList,
|
||||
afficheContent,
|
||||
afficheTitle,
|
||||
afficheId
|
||||
} = this.updateItem;
|
||||
|
||||
this.updateActionData = {
|
||||
afficheId,
|
||||
afficheStatus,
|
||||
afficheTitle,
|
||||
afficheContent,
|
||||
afficheMemberIdList: afficheMemberIdList.join(","),
|
||||
};
|
||||
},
|
||||
|
||||
async doUpdateItem() {
|
||||
await window.vtoast.loading("更新草稿");
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: "afficheManagement",
|
||||
actionId: "updateItem",
|
||||
actionData: this.updateActionData,
|
||||
},
|
||||
},
|
||||
});
|
||||
await window.vtoast.success("更新草稿成功");
|
||||
},
|
||||
async closeUpdateDrawer() {
|
||||
this.isUpdateDrawerShown = false;
|
||||
this.updateItem = {};
|
||||
this.updateActionData = null;
|
||||
},
|
||||
|
||||
// ---------- <<<<<<<<<<< 更新数据 uiAction ---------
|
||||
|
||||
// ---------- 初始化页面时参数处理 >>>>>>>>>>>>> ----------
|
||||
|
||||
// ---------- <<<<<<<<<<<<< 初始化页面时参数处理 ----------
|
||||
async addPerson(selectedItems) {
|
||||
this.isDialogShown = false;
|
||||
},
|
||||
|
||||
initEditorMd(that, key, { image: onImageUpload }) {
|
||||
that.$nextTick(() => {
|
||||
if (document.getElementById("editorMdContainer")) {
|
||||
document.getElementById(
|
||||
"editorMdContainer"
|
||||
).innerHTML = `<textarea style=\"display:none;\">${that[that.actionKey][key] || ""
|
||||
}</textarea>`;
|
||||
that.editor = editormd("editorMdContainer", {
|
||||
// width : "100%",
|
||||
height: "300px",
|
||||
watch: false,
|
||||
saveHTMLToTextarea: true, // 保存 HTML 到 Textarea
|
||||
htmlDecode: "style,script,iframe|on*",
|
||||
path: "/<$ ctx.app.config.appId $>/public/plugins/editor.md/lib/",
|
||||
toolbarIcons: Object.freeze([
|
||||
"undo",
|
||||
"redo",
|
||||
"|",
|
||||
"watch",
|
||||
"preview",
|
||||
"|",
|
||||
"h1",
|
||||
"h2",
|
||||
"h3",
|
||||
"h4",
|
||||
"h5",
|
||||
"bold",
|
||||
"del",
|
||||
"italic",
|
||||
"quote",
|
||||
"mark",
|
||||
"imageUpload",
|
||||
"list-ul",
|
||||
"list-ol",
|
||||
"hr",
|
||||
"link",
|
||||
"|",
|
||||
"toggle",
|
||||
"articleQuery",
|
||||
]),
|
||||
toolbarIconsClass: {
|
||||
audioUpload: "fa-file-audio-o",
|
||||
videoUpload: "fa-youtube-play",
|
||||
attachmentUpload: "fa-upload",
|
||||
imageUpload: "fa-image",
|
||||
},
|
||||
// 如果没有图标,则可以这样直接插入内容,可以是字符串或HTML标签
|
||||
toolbarIconTexts: {
|
||||
toggle:
|
||||
"<i class='fa fa-expand' name='toggle' unselectable='on' style='display: inline-block;'></i><span class='ml-1'>收缩</span>",
|
||||
articleQuery:
|
||||
"<i class='fa fa-table' name='toggle' unselectable='on' style='display: inline-block;'></i><span class='ml-1'>列表</span>",
|
||||
},
|
||||
toolbarHandlers: {
|
||||
imageUpload: function (cm, icon, cursor, selection) {
|
||||
onImageUpload();
|
||||
},
|
||||
|
||||
toggle: function (cm, icon, cursor, selection) {
|
||||
cm.replaceSelection(
|
||||
`\n[jh-toggle title=\"折叠容器\" default-open=\"true\"]\n折叠内容\n[/jh-toggle]\n`
|
||||
);
|
||||
},
|
||||
articleQuery: function (cm, icon, cursor, selection) {
|
||||
cm.replaceSelection(
|
||||
"\n[jh-article-query]\n" +
|
||||
"{\n" +
|
||||
' "where": "",\n' +
|
||||
' "queryType": "order",\n' +
|
||||
' "orderBy": "order by articleId asc",\n' +
|
||||
' "limit": 20\n' +
|
||||
"}" +
|
||||
"\n[/jh-article-query]\n"
|
||||
);
|
||||
},
|
||||
},
|
||||
lang: {
|
||||
toolbar: {
|
||||
toggle: "展开收起",
|
||||
column: "横向排列", // 自定义按钮的提示文本,即title属性
|
||||
articleQuery: "数据列表",
|
||||
},
|
||||
},
|
||||
onchange: function () {
|
||||
that.mdChanged = true;
|
||||
that[that.actionKey][key] = this.getMarkdown();
|
||||
// that.createItem[`${key}ForSeo`] = this.getPreviewedHTML2();
|
||||
},
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(() => {
|
||||
this.initEditorMd(that, key, {
|
||||
image: onImageUpload,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
async openImageUploadDrawer() {
|
||||
this.materialType = "image";
|
||||
this.$refs.selectFileDialog.doUiAction("open");
|
||||
},
|
||||
|
||||
editHandlerWhenUseMaterial({ filename, downloadPath }) {
|
||||
if (this.materialType === "pdf") {
|
||||
// pdf 操作使用通道
|
||||
this.editor.insertValue(`\n[jh-pdf-viewer src="${downloadPath}"/]\n`);
|
||||
return;
|
||||
}
|
||||
const fileSubbfix =
|
||||
filename.lastIndexOf(".") > -1
|
||||
? filename.substring(filename.lastIndexOf(".") + 1).toLowerCase()
|
||||
: "";
|
||||
if (
|
||||
[
|
||||
"png",
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"bmp",
|
||||
"gif",
|
||||
"webp",
|
||||
".psd",
|
||||
"svg",
|
||||
"tiff",
|
||||
].indexOf(fileSubbfix) !== -1
|
||||
) {
|
||||
this.editor.insertValue(
|
||||
`\n`
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (["mp3", "wav", "wmv"].indexOf(fileSubbfix) !== -1) {
|
||||
this.editor.insertValue(
|
||||
`\n<audio controls="" preload="none"><source src="/<$ ctx.app.config.appId $>/upload${downloadPath}"></audio>`
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
[
|
||||
"avi",
|
||||
"mpg",
|
||||
"mpeg",
|
||||
"mov",
|
||||
"rm",
|
||||
"ram",
|
||||
"swf",
|
||||
"flv",
|
||||
"mp4",
|
||||
"wma",
|
||||
"rmvb",
|
||||
"mkv",
|
||||
].indexOf(fileSubbfix) !== -1
|
||||
) {
|
||||
this.editor.insertValue(
|
||||
`\n<video controls="" preload="none"><source src="/<$ ctx.app.config.appId $>/upload${downloadPath}"></video>`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 下载链接
|
||||
this.editor.insertValue(
|
||||
`\n[${filename}](/<$ ctx.app.config.appId $>/upload${downloadPath})`
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.v-btn.filter-btn:not(.v-btn--round).v-size--default {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.v-dialog--fullscreen .v-sheet {
|
||||
height: auto;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user