提交 5534f372 authored 作者: 刘旭's avatar 刘旭

商品管理

上级 90015874
<template> <template>
<div style="border: 1px solid #ccc"> <div style="border: 1px solid #ccc">
<Toolbar <Toolbar style="border-bottom: 1px solid #ccc" :editor="editorRef" :defaultConfig="toolbarConfig" :mode="mode" />
style="border-bottom: 1px solid #ccc" <Editor style="height: 400px; overflow-y: hidden;" v-model="valueHtml" :defaultConfig="editorConfig" :mode="mode"
:editor="editorRef" @onCreated="handleCreated" @onChange="handleChange"/>
:defaultConfig="toolbarConfig"
:mode="mode"
/>
<Editor
style="height: 500px; overflow-y: hidden;"
v-model="valueHtml"
:defaultConfig="editorConfig"
:mode="mode"
@onCreated="handleCreated"
/>
</div> </div>
</template> </template>
<script> <script setup lang="ts">
import '@wangeditor/editor/dist/css/style.css' // 引入 css import '@wangeditor/editor/dist/css/style.css' // 引入 css
import { onBeforeUnmount, ref, shallowRef, onMounted } from 'vue' import { onBeforeUnmount, ref, shallowRef, onMounted } from 'vue'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue' import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
export default { const props = defineProps({
components: { Editor, Toolbar }, valueHtml: {
setup() { type: String,
// 编辑器实例,必须用 shallowRef default: '<p></p>'
const editorRef = shallowRef() }
})
const emits = defineEmits(['htmlChange'])
// 内容 HTML // 编辑器实例,必须用 shallowRef
const valueHtml = ref('<p>hello</p>') const editorRef = shallowRef()
// 模拟 ajax 异步获取内容 // 内容 HTML
onMounted(() => { // const valueHtml = ref('<p></p>')
setTimeout(() => {
valueHtml.value = '<p>模拟 Ajax 异步设置内容</p>'
}, 1500)
})
const toolbarConfig = {} // 模拟 ajax 异步获取内容
const editorConfig = { placeholder: '请输入内容...' } // onMounted(() => {
// setTimeout(() => {
// valueHtml.value = '<p></p>'
// }, 1500)
// })
// 组件销毁时,也及时销毁编辑器 const toolbarConfig = {}
onBeforeUnmount(() => { const editorConfig = { placeholder: '请输入内容...' }
// 组件销毁时,也及时销毁编辑器
onBeforeUnmount(() => {
const editor = editorRef.value const editor = editorRef.value
if (editor == null) return if (editor == null) return
editor.destroy() editor.destroy()
}) })
const handleCreated = (editor) => { const handleCreated = (editor: any) => {
editorRef.value = editor // 记录 editor 实例,重要! editorRef.value = editor // 记录 editor 实例,重要!
} }
return { const handleChange = (editor: any) => {
editorRef, emits('htmlChange', editor.children)
valueHtml,
mode: 'default', // 或 'simple'
toolbarConfig,
editorConfig,
handleCreated
};
}
} }
</script> </script>
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row> <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row>
<el-table-column type="expand"> <el-table-column type="expand">
<template #default="props"> <template #default="props">
<el-form label-position="left" class="table-expand"> <el-form label-position="left">
<el-form-item label="商品编号"> <el-form-item label="商品编号">
<span>{{ props.row.goodsSn }}</span> <span>{{ props.row.goodsSn }}</span>
</el-form-item> </el-form-item>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<el-table-column align="center" label="详情" prop="detail"> <el-table-column align="center" label="详情" prop="detail">
<template #default="scope"> <template #default="scope">
<el-dialog :visible.sync="detailDialogVisible" title="商品详情"> <el-dialog v-model="detailDialogVisible" title="商品详情">
<div class="goods-detail-box" v-html="goodsDetail" /> <div class="goods-detail-box" v-html="goodsDetail" />
</el-dialog> </el-dialog>
<el-button type="primary" size="small" @click="showDetail(scope.row.detail)">查看</el-button> <el-button type="primary" size="small" @click="showDetail(scope.row.detail)">查看</el-button>
...@@ -118,15 +118,14 @@ import { ref } from "vue"; ...@@ -118,15 +118,14 @@ import { ref } from "vue";
import { ElMessageBox, ElNotification } from "element-plus"; import { ElMessageBox, ElNotification } from "element-plus";
import { listGoods, deleteGoods } from "@/services/api/commodityManage/list"; import { listGoods, deleteGoods } from "@/services/api/commodityManage/list";
import { thumbnail, toPreview } from "@/utils/index"; import { thumbnail, toPreview } from "@/utils/index";
import { useRouter } from "vue-router"; import router from '@/router';
let router = useRouter();
let list = ref([]); let list = ref([]);
let total = ref(0); let total = ref(0);
let listLoading = ref(true); let listLoading = ref(true);
let listQuery = ref({ let listQuery = ref({
page: 1, page: 1,
limit: 20, limit: 10,
goodsSn: undefined, goodsSn: undefined,
name: undefined, name: undefined,
sort: "add_time", sort: "add_time",
...@@ -157,7 +156,9 @@ let handleFilter = () => { ...@@ -157,7 +156,9 @@ let handleFilter = () => {
getList(); getList();
}; };
let handleCreate = () => { let handleCreate = () => {
// router.push({ path: "/goods/create" }); console.log('跳转');
router.push({ path: "/commodity/shelves" });
}; };
let handleUpdate = (row: any) => { let handleUpdate = (row: any) => {
// router.push({ path: "/goods/edit", query: { id: row.id } }); // router.push({ path: "/goods/edit", query: { id: row.id } });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论