- 消息通知
+
+
+
+
+ 新建
+
+
+ 删除
+
+ 确定删除选中的数据吗?
+
+
+
+
+
+
diff --git a/src/views/setting/notice/tools/form.js b/src/views/setting/notice/tools/form.js
new file mode 100644
index 0000000..fa230b1
--- /dev/null
+++ b/src/views/setting/notice/tools/form.js
@@ -0,0 +1,31 @@
+import { reactive } from 'vue'
+import { NOTICE_SOURCE, ADVERTISING_STATUS } from '@/utils/dictionary.js'
+
+export const form = reactive({
+ noticeForm: {
+ image: null,
+ title: null,
+ source: 1,
+ status: 1,
+ url: null,
+ guide: null,
+ content: null
+ },
+ noticeRules: {
+ title: [{ required: true, message: '请输入广告标题', trigger: 'blur' }]
+ },
+ formItem: [
+ { type: 'oss', refIndex: 0, key: 'imageStatus', file: 'image', label: '公告图片' },
+
+ { type: 'input', key: 'title', label: '通知标题', props: { maxlength: '20', placeholder: '请输入通知标题', clearable: true }},
+ { type: 'select', key: 'source', label: '通知来源', props: { options: NOTICE_SOURCE, placeholder: '请选择通知来源' }},
+
+ { type: 'radio', key: 'status', label: '通知状态', options: ADVERTISING_STATUS },
+ { type: 'input', key: 'url', label: '外部地址', props: { maxlength: '20', placeholder: '请输入外部地址', clearable: true }},
+
+ { type: 'input', key: 'guide', label: '公告摘要', props: { maxlength: '20', placeholder: '请输入公告摘要', clearable: true }},
+
+ { type: 'editor', key: 'content', label: '通知内容', props: { height: 300 }}
+ ]
+})
+
diff --git a/src/views/setting/notice/tools/search.js b/src/views/setting/notice/tools/search.js
new file mode 100644
index 0000000..ae211af
--- /dev/null
+++ b/src/views/setting/notice/tools/search.js
@@ -0,0 +1,14 @@
+import { reactive } from 'vue'
+
+const data = reactive([
+ {
+ label: '通知标题',
+ key: 'title',
+ props: {
+ placeholder: '请输入通知标题'
+ }
+ }
+])
+
+export default data
+
diff --git a/src/views/setting/notice/tools/table.js b/src/views/setting/notice/tools/table.js
new file mode 100644
index 0000000..da8c390
--- /dev/null
+++ b/src/views/setting/notice/tools/table.js
@@ -0,0 +1,234 @@
+import { h, ref, reactive } from 'vue'
+import TableImage from '@/components/DataTable/tools/Image.vue'
+import TableTags from '@/components/DataTable/tools/Tags.vue'
+import TableSwitch from '@/components/DataTable/tools/Switch.vue'
+import TableAction from '@/components/DataTable/tools/Action.vue'
+import { NOTICE_SOURCE } from '@/utils/dictionary.js'
+import { noticeDelete, isTopUpdate, statusUpdate } from '@/api/setting/notice.js'
+
+/* 注册table */
+const tableRef = ref()
+const searchParams = ref()
+
+function handleSearch(params) {
+ searchParams.value = { ...params }
+ tableRef.value.reFetch({ searchParams })
+}
+
+/**
+ * @description: 获取数据及操作
+ * @param {*} row 单行数据
+ * @param {*} type 操作类型 create:创建,preview:预览,edit:编辑
+ * @return {*}
+ */
+function getRowData(row, type) {
+ data.rowData = type === 'create' ? { pid: row.id } : row
+ data.modalType = type
+ data.modalShow = true
+}
+
+// 删除方法
+function deleteData(id) {
+ noticeDelete(id)
+ .then((res) => {
+ if (res.code === 0) {
+ handleSearch()
+ }
+ })
+ .catch((e) => {
+ console.log(e)
+ })
+}
+
+/**
+ * @description: 改变状态
+ * @param {*} row 选中数据
+ * @return {*}
+ */
+function handleIsTopChange(row) {
+ isTopUpdate({ id: row.data.id, isTop: row.value })
+ .then((res) => {
+ if (res.code === 0) {
+ handleSearch()
+ }
+ })
+ .catch((e) => {
+ console.log(e)
+ })
+}
+
+/**
+ * @description: 改变状态
+ * @param {*} row 选中数据
+ * @return {*}
+ */
+function handleStatusChange(row) {
+ statusUpdate({ id: row.data.id, status: row.value })
+ .then((res) => {
+ if (res.code === 0) {
+ handleSearch()
+ }
+ })
+ .catch((e) => {
+ console.log(e)
+ })
+}
+
+const data = reactive({
+ tableRef,
+ searchParams,
+ rowData: {},
+ modalType: 'create',
+ modalShow: false,
+ handleSearch,
+
+ columns: [
+ {
+ type: 'selection'
+ },
+ {
+ title: '编号',
+ key: 'key',
+ render: (_, index) => {
+ return `${index + 1}`
+ },
+ align: 'center',
+ width: 50
+ },
+ {
+ title: '通知标题',
+ key: 'title',
+ align: 'center',
+ ellipsis: {
+ tooltip: true
+ },
+ width: 500
+ },
+ {
+ title: '公告图片',
+ key: 'image',
+ render(row) {
+ return h(TableImage, {
+ images: {
+ width: 36,
+ height: 36,
+ src: row.image
+ }
+ })
+ },
+ align: 'center',
+ width: 100
+ },
+ {
+ title: '通知来源',
+ key: 'source',
+ align: 'center',
+ width: 100,
+ render(row) {
+ return h(TableTags, {
+ data: row.source,
+ filters: NOTICE_SOURCE,
+ tags: {
+ bordered: true
+ }
+ })
+ }
+ },
+ {
+ title: '是否置顶',
+ key: 'isTop',
+ align: 'center',
+ width: 100,
+ render(row) {
+ return h(TableSwitch, {
+ data: { id: row.id, isTop: row.isTop },
+ rowKey: 'isTop',
+ checkedValue: 1,
+ uncheckedValue: 2,
+ onChange: handleIsTopChange.bind(row)
+ })
+ }
+ },
+ {
+ title: '状态',
+ key: 'status',
+ align: 'center',
+ width: 100,
+ render(row) {
+ return h(TableSwitch, {
+ data: { id: row.id, status: row.status },
+ rowKey: 'status',
+ checkedValue: 1,
+ uncheckedValue: 2,
+ onChange: handleStatusChange.bind(row)
+ })
+ }
+ },
+ {
+ title: '浏览量',
+ key: 'browse',
+ align: 'center',
+ width: 100
+ },
+ {
+ title: '创建时间',
+ key: 'createTime',
+ align: 'center',
+ width: 200
+ },
+ {
+ title: '更新时间',
+ key: 'updateTime',
+ align: 'center',
+ width: 200
+ },
+ {
+ title: '操作',
+ align: 'center',
+ width: 150,
+ fixed: 'right',
+ render(row) {
+ return h(TableAction, {
+ actions: [
+ // {
+ // label: '查看',
+ // type: 'button',
+ // props: {
+ // type: 'primary',
+ // text: true,
+ // onClick: getRowData.bind(null, row, 'preview')
+ // },
+ // auth: 'basic_list'
+ // },
+ {
+ label: '修改',
+ type: 'button',
+ props: {
+ type: 'primary',
+ text: true,
+ onClick: getRowData.bind(null, row, 'update')
+ },
+ auth: 'basic_list'
+ },
+ {
+ label: '删除',
+ type: 'popconfirm',
+ auth: 'basic_list',
+ tip: '确定删除这条数据吗?',
+ props: {
+ onPositiveClick: deleteData.bind(null, [row.id])
+ },
+ ButtonProps: {
+ text: true,
+ type: 'primary'
+ }
+ }
+ ],
+ align: 'center'
+ })
+ }
+ }
+ ]
+})
+
+export default data