Browse Source
- 新增智慧教务系统插件,包含管理员和前端页面 - 实现了 hello world 功能作为插件示例 - 添加了插件安装、卸载和升级方法 - 创建了插件相关的路由、API 和页面组件master
54 changed files with 1508 additions and 99 deletions
@ -0,0 +1,54 @@ |
|||
import request from '@/utils/request' |
|||
|
|||
// USER_CODE_BEGIN -- zhjw_articles
|
|||
/** |
|||
* 获取文章管理列表 |
|||
* @param params |
|||
* @returns |
|||
*/ |
|||
export function getArticlesList(params: Record<string, any>) { |
|||
return request.get(`zhjw/articles`, {params}) |
|||
} |
|||
|
|||
/** |
|||
* 获取文章管理详情 |
|||
* @param id 文章管理id |
|||
* @returns |
|||
*/ |
|||
export function getArticlesInfo(id: number) { |
|||
return request.get(`zhjw/articles/${id}`); |
|||
} |
|||
|
|||
/** |
|||
* 添加文章管理 |
|||
* @param params |
|||
* @returns |
|||
*/ |
|||
export function addArticles(params: Record<string, any>) { |
|||
return request.post('zhjw/articles', params, { showErrorMessage: true, showSuccessMessage: true }) |
|||
} |
|||
|
|||
/** |
|||
* 编辑文章管理 |
|||
* @param id |
|||
* @param params |
|||
* @returns |
|||
*/ |
|||
export function editArticles(params: Record<string, any>) { |
|||
return request.put(`zhjw/articles/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) |
|||
} |
|||
|
|||
/** |
|||
* 删除文章管理 |
|||
* @param id |
|||
* @returns |
|||
*/ |
|||
export function deleteArticles(id: number) { |
|||
return request.delete(`zhjw/articles/${id}`, { showErrorMessage: true, showSuccessMessage: true }) |
|||
} |
|||
|
|||
export function getWithSysUserList(params: Record<string,any>){ |
|||
return request.get('zhjw/sys_user_all', {params}) |
|||
} |
|||
|
|||
// USER_CODE_END -- zhjw_articles
|
|||
@ -0,0 +1,17 @@ |
|||
{ |
|||
"title":"标题", |
|||
"titlePlaceholder":"请输入标题", |
|||
"content":"内容", |
|||
"contentPlaceholder":"请输入内容", |
|||
"category":"文章分类", |
|||
"categoryPlaceholder":"请输入文章分类", |
|||
"publisherId":"发布人", |
|||
"publisherIdPlaceholder":"全部", |
|||
"status":"状态", |
|||
"statusPlaceholder":"请输入状态", |
|||
"addArticles":"添加文章管理", |
|||
"updateArticles":"编辑文章管理", |
|||
"articlesDeleteTips":"确定要删除该数据吗?", |
|||
"startDate":"请选择开始时间", |
|||
"endDate":"请选择结束时间" |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
{ |
|||
"title":"标题", |
|||
"content":"内容", |
|||
"category":"文章分类", |
|||
"publisherId":"发布人", |
|||
"status":"状态", |
|||
"titlePlaceholder":"请输入标题", |
|||
"contentPlaceholder":"请输入内容", |
|||
"categoryPlaceholder":"请选择文章分类", |
|||
"publisherIdPlaceholder":"请选择发布人", |
|||
"statusPlaceholder":"请输入状态", |
|||
"addArticles":"添加文章管理", |
|||
"updateArticles":"编辑文章管理", |
|||
"articlesDeleteTips":"确定要删除该文章管理吗?" |
|||
} |
|||
@ -0,0 +1,234 @@ |
|||
<template> |
|||
<div class="main-container"> |
|||
<el-card class="box-card !border-none" shadow="never"> |
|||
|
|||
<div class="flex justify-between items-center"> |
|||
<span class="text-lg">{{pageName}}</span> |
|||
<el-button type="primary" @click="addEvent"> |
|||
{{ t('addArticles') }} |
|||
</el-button> |
|||
</div> |
|||
|
|||
<el-card class="box-card !border-none my-[10px] table-search-wrap" shadow="never"> |
|||
<el-form :inline="true" :model="articlesTable.searchParam" ref="searchFormRef"> |
|||
<el-form-item :label="t('title')" prop="title"> |
|||
<el-input v-model="articlesTable.searchParam.title" :placeholder="t('titlePlaceholder')" /> |
|||
</el-form-item> |
|||
<el-form-item :label="t('content')" prop="content"> |
|||
<el-input v-model="articlesTable.searchParam.content" :placeholder="t('contentPlaceholder')" /> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('category')" prop="category"> |
|||
<el-select class="w-[280px]" v-model="articlesTable.searchParam.category" clearable :placeholder="t('categoryPlaceholder')"> |
|||
<el-option label="全部" value=""></el-option> |
|||
<el-option |
|||
v-for="(item, index) in categoryList" |
|||
:key="index" |
|||
:label="item.name" |
|||
:value="item.value" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
|
|||
<el-form-item :label="t('publisherId')" prop="publisher_id"> |
|||
<el-select class="w-[280px]" v-model="articlesTable.searchParam.publisher_id" clearable :placeholder="t('publisherIdPlaceholder')"> |
|||
<el-option |
|||
v-for="(item, index) in publisherIdList" |
|||
:key="index" |
|||
:label="item['uid']" |
|||
:value="item['real_name']" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
|
|||
<el-form-item :label="t('status')" prop="status"> |
|||
<el-select class="w-[280px]" v-model="articlesTable.searchParam.status" clearable :placeholder="t('statusPlaceholder')"> |
|||
<el-option label="全部" value=""></el-option> |
|||
<el-option |
|||
v-for="(item, index) in statusList" |
|||
:key="index" |
|||
:label="item.name" |
|||
:value="item.value" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item> |
|||
<el-button type="primary" @click="loadArticlesList()">{{ t('search') }}</el-button> |
|||
<el-button @click="resetForm(searchFormRef)">{{ t('reset') }}</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
</el-card> |
|||
|
|||
<div class="mt-[10px]"> |
|||
<el-table :data="articlesTable.data" size="large" v-loading="articlesTable.loading"> |
|||
<template #empty> |
|||
<span>{{ !articlesTable.loading ? t('emptyData') : '' }}</span> |
|||
</template> |
|||
<el-table-column prop="title" :label="t('title')" min-width="120" :show-overflow-tooltip="true"/> |
|||
|
|||
<el-table-column :label="t('category')" min-width="180" align="center" :show-overflow-tooltip="true"> |
|||
<template #default="{ row }"> |
|||
<div v-for="(item, index) in categoryList"> |
|||
<div v-if="item.value == row.category">{{ item.name }}</div> |
|||
</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column prop="publisher_id_name" :label="t('publisherId')" min-width="120" :show-overflow-tooltip="true"/> |
|||
|
|||
<el-table-column :label="t('status')" min-width="180" align="center" :show-overflow-tooltip="true"> |
|||
<template #default="{ row }"> |
|||
<div v-for="(item, index) in statusList"> |
|||
<div v-if="item.value == row.status">{{ item.name }}</div> |
|||
</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column :label="t('operation')" fixed="right" min-width="120"> |
|||
<template #default="{ row }"> |
|||
<el-button type="primary" link @click="editEvent(row)">{{ t('edit') }}</el-button> |
|||
<el-button type="primary" link @click="deleteEvent(row.id)">{{ t('delete') }}</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
</el-table> |
|||
<div class="mt-[16px] flex justify-end"> |
|||
<el-pagination v-model:current-page="articlesTable.page" v-model:page-size="articlesTable.limit" |
|||
layout="total, sizes, prev, pager, next, jumper" :total="articlesTable.total" |
|||
@size-change="loadArticlesList()" @current-change="loadArticlesList" /> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
</el-card> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { reactive, ref, watch } from 'vue' |
|||
import { t } from '@/lang' |
|||
import { useDictionary } from '@/app/api/dict' |
|||
import { getArticlesList, deleteArticles, getWithSysUserList } from '@/addon/zhjw/api/articles' |
|||
import { img } from '@/utils/common' |
|||
import { ElMessageBox,FormInstance } from 'element-plus' |
|||
import { useRouter } from 'vue-router' |
|||
import { useRoute } from 'vue-router' |
|||
const route = useRoute() |
|||
const pageName = route.meta.title; |
|||
|
|||
let articlesTable = reactive({ |
|||
page: 1, |
|||
limit: 10, |
|||
total: 0, |
|||
loading: true, |
|||
data: [], |
|||
searchParam:{ |
|||
"title":"", |
|||
"content":"", |
|||
"category":"", |
|||
"publisher_id":"", |
|||
"status":"" |
|||
} |
|||
}) |
|||
|
|||
const searchFormRef = ref<FormInstance>() |
|||
|
|||
// 选中数据 |
|||
const selectData = ref<any[]>([]) |
|||
|
|||
// 字典数据 |
|||
const categoryList = ref([] as any[]) |
|||
const categoryDictList = async () => { |
|||
categoryList.value = await (await useDictionary('zhjw_article_category')).data.dictionary |
|||
} |
|||
categoryDictList(); |
|||
const statusList = ref([] as any[]) |
|||
const statusDictList = async () => { |
|||
statusList.value = await (await useDictionary('is_radio')).data.dictionary |
|||
} |
|||
statusDictList(); |
|||
|
|||
/** |
|||
* 获取文章管理列表 |
|||
*/ |
|||
const loadArticlesList = (page: number = 1) => { |
|||
articlesTable.loading = true |
|||
articlesTable.page = page |
|||
|
|||
getArticlesList({ |
|||
page: articlesTable.page, |
|||
limit: articlesTable.limit, |
|||
...articlesTable.searchParam |
|||
}).then(res => { |
|||
articlesTable.loading = false |
|||
articlesTable.data = res.data.data |
|||
articlesTable.total = res.data.total |
|||
}).catch(() => { |
|||
articlesTable.loading = false |
|||
}) |
|||
} |
|||
loadArticlesList() |
|||
|
|||
const router = useRouter() |
|||
|
|||
/** |
|||
* 添加文章管理 |
|||
*/ |
|||
const addEvent = () => { |
|||
router.push('/articles/articles_edit') |
|||
} |
|||
|
|||
/** |
|||
* 编辑文章管理 |
|||
* @param data |
|||
*/ |
|||
const editEvent = (data: any) => { |
|||
router.push('/articles/articles_edit?id='+data.id) |
|||
} |
|||
|
|||
/** |
|||
* 删除文章管理 |
|||
*/ |
|||
const deleteEvent = (id: number) => { |
|||
ElMessageBox.confirm(t('articlesDeleteTips'), t('warning'), |
|||
{ |
|||
confirmButtonText: t('confirm'), |
|||
cancelButtonText: t('cancel'), |
|||
type: 'warning', |
|||
} |
|||
).then(() => { |
|||
deleteArticles(id).then(() => { |
|||
loadArticlesList() |
|||
}).catch(() => { |
|||
}) |
|||
}) |
|||
} |
|||
|
|||
|
|||
const publisherIdList = ref([]) |
|||
const setPublisherIdList = async () => { |
|||
publisherIdList.value = await (await getWithSysUserList({})).data |
|||
} |
|||
setPublisherIdList() |
|||
|
|||
const resetForm = (formEl: FormInstance | undefined) => { |
|||
if (!formEl) return |
|||
formEl.resetFields() |
|||
loadArticlesList() |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
/* 多行超出隐藏 */ |
|||
.multi-hidden { |
|||
word-break: break-all; |
|||
text-overflow: ellipsis; |
|||
overflow: hidden; |
|||
display: -webkit-box; |
|||
-webkit-line-clamp: 2; |
|||
-webkit-box-orient: vertical; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,218 @@ |
|||
<template> |
|||
<div class="main-container"> |
|||
<div class="detail-head"> |
|||
<div class="left" @click="back()"> |
|||
<span class="iconfont iconxiangzuojiantou !text-xs"></span> |
|||
<span class="ml-[1px]">{{t('returnToPreviousPage')}}</span> |
|||
</div> |
|||
<span class="adorn">|</span> |
|||
<span class="right">{{ pageName }}</span> |
|||
</div> |
|||
<el-card class="box-card !border-none" shadow="never"> |
|||
<el-form :model="formData" label-width="90px" ref="formRef" :rules="formRules" class="page-form"> |
|||
<el-form-item :label="t('title')" prop="title"> |
|||
<el-input v-model="formData.title" clearable :placeholder="t('titlePlaceholder')" class="input-width" /> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('content')" prop="content"> |
|||
<el-input v-model="formData.content" clearable :placeholder="t('contentPlaceholder')" class="input-width" /> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('category')" prop="category"> |
|||
<el-select class="input-width" v-model="formData.category" clearable :placeholder="t('categoryPlaceholder')"> |
|||
<el-option label="请选择" value=""></el-option> |
|||
<el-option |
|||
v-for="(item, index) in categoryList" |
|||
:key="index" |
|||
:label="item.name" |
|||
:value="item.value" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('publisherId')" prop="publisher_id"> |
|||
<el-select class="input-width" v-model="formData.publisher_id" clearable :placeholder="t('publisherIdPlaceholder')"> |
|||
<el-option label="请选择" value=""></el-option> |
|||
<el-option |
|||
v-for="(item, index) in publisherIdList" |
|||
:key="index" |
|||
:label="item['uid']" |
|||
:value="item['real_name']" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('status')" prop="status"> |
|||
<el-radio-group v-model="formData.status" :placeholder="t('statusPlaceholder')"> |
|||
<el-radio |
|||
v-for="(item, index) in statusList" |
|||
:key="index" :label="item.value"> |
|||
{{ item.name }} |
|||
</el-radio> |
|||
</el-radio-group> |
|||
</el-form-item> |
|||
|
|||
</el-form> |
|||
</el-card> |
|||
<div class="fixed-footer-wrap"> |
|||
<div class="fixed-footer"> |
|||
<el-button type="primary" @click="onSave(formRef)">{{ t('save') }}</el-button> |
|||
<el-button @click="back()">{{ t('cancel') }}</el-button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { ref, reactive, computed, watch } from 'vue' |
|||
import { t } from '@/lang' |
|||
import { useDictionary } from '@/app/api/dict' |
|||
import type { FormInstance } from 'element-plus' |
|||
import { getArticlesInfo,addArticles,editArticles, getWithSysUserList } from '@/addon/zhjw/api/articles'; |
|||
import { useRoute } from 'vue-router' |
|||
|
|||
const route = useRoute() |
|||
const id:number = parseInt(route.query.id); |
|||
const loading = ref(false) |
|||
const pageName = route.meta.title |
|||
|
|||
|
|||
|
|||
/** |
|||
* 表单数据 |
|||
*/ |
|||
const initialFormData = { |
|||
id: 0, |
|||
title: '', |
|||
content: '', |
|||
category: '', |
|||
publisher_id: '', |
|||
status: '', |
|||
} |
|||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|||
|
|||
const setFormData = async (id:number = 0) => { |
|||
Object.assign(formData, initialFormData) |
|||
const data = await (await getArticlesInfo(id)).data |
|||
Object.keys(formData).forEach((key: string) => { |
|||
if (data[key] != undefined) formData[key] = data[key] |
|||
}) |
|||
} |
|||
if(id) setFormData(id); |
|||
|
|||
const formRef = ref<FormInstance>() |
|||
// 选中数据 |
|||
const selectData = ref<any[]>([]) |
|||
|
|||
// 字典数据 |
|||
let categoryList = ref([]) |
|||
const categoryDictList = async () => { |
|||
categoryList.value = await (await useDictionary('zhjw_article_category')).data.dictionary |
|||
} |
|||
categoryDictList(); |
|||
watch(() => categoryList.value, () => { formData.category = categoryList.value[0].value }) |
|||
let statusList = ref([]) |
|||
const statusDictList = async () => { |
|||
statusList.value = await (await useDictionary('is_radio')).data.dictionary |
|||
} |
|||
statusDictList(); |
|||
watch(() => statusList.value, () => { formData.status = statusList.value[0].value }) |
|||
|
|||
|
|||
const publisherIdList = ref([] as any[]) |
|||
const setPublisherIdList = async () => { |
|||
publisherIdList.value = await (await getWithSysUserList({})).data |
|||
} |
|||
setPublisherIdList() |
|||
// 表单验证规则 |
|||
const formRules = computed(() => { |
|||
return { |
|||
title: [ |
|||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
content: [ |
|||
{ required: true, message: t('contentPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
category: [ |
|||
{ required: true, message: t('categoryPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
publisher_id: [ |
|||
{ required: true, message: t('publisherIdPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
status: [ |
|||
{ required: true, message: t('statusPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
} |
|||
}) |
|||
|
|||
const onSave = async (formEl: FormInstance | undefined) => { |
|||
if (loading.value || !formEl) return |
|||
await formEl.validate(async (valid) => { |
|||
if (valid) { |
|||
loading.value = true |
|||
let data = formData |
|||
|
|||
const save = id ? editArticles : addArticles |
|||
save(data).then(res => { |
|||
loading.value = false |
|||
history.back() |
|||
}).catch(err => { |
|||
loading.value = false |
|||
}) |
|||
|
|||
} |
|||
}) |
|||
} |
|||
|
|||
// 验证手机号格式 |
|||
const mobileVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
|||
callback(new Error(t('generateMobile'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
// 验证身份证号 |
|||
const idCardVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
|||
callback(new Error(t('generateIdCard'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
// 验证邮箱号 |
|||
const emailVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
|||
callback(new Error(t('generateEmail'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
|
|||
// 验证请输入整数 |
|||
const numberVerify = (rule: any, value: any, callback: any) => { |
|||
if (!Number.isInteger(value)) { |
|||
callback(new Error(t('generateNumber'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
const back = () => { |
|||
history.back() |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped></style> |
|||
@ -0,0 +1,54 @@ |
|||
import request from '@/utils/request' |
|||
|
|||
// USER_CODE_BEGIN -- zhjw_articles
|
|||
/** |
|||
* 获取文章管理列表 |
|||
* @param params |
|||
* @returns |
|||
*/ |
|||
export function getArticlesList(params: Record<string, any>) { |
|||
return request.get(`zhjw/articles`, {params}) |
|||
} |
|||
|
|||
/** |
|||
* 获取文章管理详情 |
|||
* @param id 文章管理id |
|||
* @returns |
|||
*/ |
|||
export function getArticlesInfo(id: number) { |
|||
return request.get(`zhjw/articles/${id}`); |
|||
} |
|||
|
|||
/** |
|||
* 添加文章管理 |
|||
* @param params |
|||
* @returns |
|||
*/ |
|||
export function addArticles(params: Record<string, any>) { |
|||
return request.post('zhjw/articles', params, { showErrorMessage: true, showSuccessMessage: true }) |
|||
} |
|||
|
|||
/** |
|||
* 编辑文章管理 |
|||
* @param id |
|||
* @param params |
|||
* @returns |
|||
*/ |
|||
export function editArticles(params: Record<string, any>) { |
|||
return request.put(`zhjw/articles/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) |
|||
} |
|||
|
|||
/** |
|||
* 删除文章管理 |
|||
* @param id |
|||
* @returns |
|||
*/ |
|||
export function deleteArticles(id: number) { |
|||
return request.delete(`zhjw/articles/${id}`, { showErrorMessage: true, showSuccessMessage: true }) |
|||
} |
|||
|
|||
export function getWithSysUserList(params: Record<string,any>){ |
|||
return request.get('zhjw/sys_user_all', {params}) |
|||
} |
|||
|
|||
// USER_CODE_END -- zhjw_articles
|
|||
@ -0,0 +1,17 @@ |
|||
{ |
|||
"title":"标题", |
|||
"titlePlaceholder":"请输入标题", |
|||
"content":"内容", |
|||
"contentPlaceholder":"请输入内容", |
|||
"category":"文章分类", |
|||
"categoryPlaceholder":"请输入文章分类", |
|||
"publisherId":"发布人", |
|||
"publisherIdPlaceholder":"全部", |
|||
"status":"状态", |
|||
"statusPlaceholder":"请输入状态", |
|||
"addArticles":"添加文章管理", |
|||
"updateArticles":"编辑文章管理", |
|||
"articlesDeleteTips":"确定要删除该数据吗?", |
|||
"startDate":"请选择开始时间", |
|||
"endDate":"请选择结束时间" |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
{ |
|||
"title":"标题", |
|||
"content":"内容", |
|||
"category":"文章分类", |
|||
"publisherId":"发布人", |
|||
"status":"状态", |
|||
"titlePlaceholder":"请输入标题", |
|||
"contentPlaceholder":"请输入内容", |
|||
"categoryPlaceholder":"请选择文章分类", |
|||
"publisherIdPlaceholder":"请选择发布人", |
|||
"statusPlaceholder":"请输入状态", |
|||
"addArticles":"添加文章管理", |
|||
"updateArticles":"编辑文章管理", |
|||
"articlesDeleteTips":"确定要删除该文章管理吗?" |
|||
} |
|||
@ -0,0 +1,234 @@ |
|||
<template> |
|||
<div class="main-container"> |
|||
<el-card class="box-card !border-none" shadow="never"> |
|||
|
|||
<div class="flex justify-between items-center"> |
|||
<span class="text-lg">{{pageName}}</span> |
|||
<el-button type="primary" @click="addEvent"> |
|||
{{ t('addArticles') }} |
|||
</el-button> |
|||
</div> |
|||
|
|||
<el-card class="box-card !border-none my-[10px] table-search-wrap" shadow="never"> |
|||
<el-form :inline="true" :model="articlesTable.searchParam" ref="searchFormRef"> |
|||
<el-form-item :label="t('title')" prop="title"> |
|||
<el-input v-model="articlesTable.searchParam.title" :placeholder="t('titlePlaceholder')" /> |
|||
</el-form-item> |
|||
<el-form-item :label="t('content')" prop="content"> |
|||
<el-input v-model="articlesTable.searchParam.content" :placeholder="t('contentPlaceholder')" /> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('category')" prop="category"> |
|||
<el-select class="w-[280px]" v-model="articlesTable.searchParam.category" clearable :placeholder="t('categoryPlaceholder')"> |
|||
<el-option label="全部" value=""></el-option> |
|||
<el-option |
|||
v-for="(item, index) in categoryList" |
|||
:key="index" |
|||
:label="item.name" |
|||
:value="item.value" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
|
|||
<el-form-item :label="t('publisherId')" prop="publisher_id"> |
|||
<el-select class="w-[280px]" v-model="articlesTable.searchParam.publisher_id" clearable :placeholder="t('publisherIdPlaceholder')"> |
|||
<el-option |
|||
v-for="(item, index) in publisherIdList" |
|||
:key="index" |
|||
:label="item['uid']" |
|||
:value="item['real_name']" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
|
|||
<el-form-item :label="t('status')" prop="status"> |
|||
<el-select class="w-[280px]" v-model="articlesTable.searchParam.status" clearable :placeholder="t('statusPlaceholder')"> |
|||
<el-option label="全部" value=""></el-option> |
|||
<el-option |
|||
v-for="(item, index) in statusList" |
|||
:key="index" |
|||
:label="item.name" |
|||
:value="item.value" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item> |
|||
<el-button type="primary" @click="loadArticlesList()">{{ t('search') }}</el-button> |
|||
<el-button @click="resetForm(searchFormRef)">{{ t('reset') }}</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
</el-card> |
|||
|
|||
<div class="mt-[10px]"> |
|||
<el-table :data="articlesTable.data" size="large" v-loading="articlesTable.loading"> |
|||
<template #empty> |
|||
<span>{{ !articlesTable.loading ? t('emptyData') : '' }}</span> |
|||
</template> |
|||
<el-table-column prop="title" :label="t('title')" min-width="120" :show-overflow-tooltip="true"/> |
|||
|
|||
<el-table-column :label="t('category')" min-width="180" align="center" :show-overflow-tooltip="true"> |
|||
<template #default="{ row }"> |
|||
<div v-for="(item, index) in categoryList"> |
|||
<div v-if="item.value == row.category">{{ item.name }}</div> |
|||
</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column prop="publisher_id_name" :label="t('publisherId')" min-width="120" :show-overflow-tooltip="true"/> |
|||
|
|||
<el-table-column :label="t('status')" min-width="180" align="center" :show-overflow-tooltip="true"> |
|||
<template #default="{ row }"> |
|||
<div v-for="(item, index) in statusList"> |
|||
<div v-if="item.value == row.status">{{ item.name }}</div> |
|||
</div> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column :label="t('operation')" fixed="right" min-width="120"> |
|||
<template #default="{ row }"> |
|||
<el-button type="primary" link @click="editEvent(row)">{{ t('edit') }}</el-button> |
|||
<el-button type="primary" link @click="deleteEvent(row.id)">{{ t('delete') }}</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
</el-table> |
|||
<div class="mt-[16px] flex justify-end"> |
|||
<el-pagination v-model:current-page="articlesTable.page" v-model:page-size="articlesTable.limit" |
|||
layout="total, sizes, prev, pager, next, jumper" :total="articlesTable.total" |
|||
@size-change="loadArticlesList()" @current-change="loadArticlesList" /> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
</el-card> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { reactive, ref, watch } from 'vue' |
|||
import { t } from '@/lang' |
|||
import { useDictionary } from '@/app/api/dict' |
|||
import { getArticlesList, deleteArticles, getWithSysUserList } from '@/addon/zhjw/api/articles' |
|||
import { img } from '@/utils/common' |
|||
import { ElMessageBox,FormInstance } from 'element-plus' |
|||
import { useRouter } from 'vue-router' |
|||
import { useRoute } from 'vue-router' |
|||
const route = useRoute() |
|||
const pageName = route.meta.title; |
|||
|
|||
let articlesTable = reactive({ |
|||
page: 1, |
|||
limit: 10, |
|||
total: 0, |
|||
loading: true, |
|||
data: [], |
|||
searchParam:{ |
|||
"title":"", |
|||
"content":"", |
|||
"category":"", |
|||
"publisher_id":"", |
|||
"status":"" |
|||
} |
|||
}) |
|||
|
|||
const searchFormRef = ref<FormInstance>() |
|||
|
|||
// 选中数据 |
|||
const selectData = ref<any[]>([]) |
|||
|
|||
// 字典数据 |
|||
const categoryList = ref([] as any[]) |
|||
const categoryDictList = async () => { |
|||
categoryList.value = await (await useDictionary('zhjw_article_category')).data.dictionary |
|||
} |
|||
categoryDictList(); |
|||
const statusList = ref([] as any[]) |
|||
const statusDictList = async () => { |
|||
statusList.value = await (await useDictionary('is_radio')).data.dictionary |
|||
} |
|||
statusDictList(); |
|||
|
|||
/** |
|||
* 获取文章管理列表 |
|||
*/ |
|||
const loadArticlesList = (page: number = 1) => { |
|||
articlesTable.loading = true |
|||
articlesTable.page = page |
|||
|
|||
getArticlesList({ |
|||
page: articlesTable.page, |
|||
limit: articlesTable.limit, |
|||
...articlesTable.searchParam |
|||
}).then(res => { |
|||
articlesTable.loading = false |
|||
articlesTable.data = res.data.data |
|||
articlesTable.total = res.data.total |
|||
}).catch(() => { |
|||
articlesTable.loading = false |
|||
}) |
|||
} |
|||
loadArticlesList() |
|||
|
|||
const router = useRouter() |
|||
|
|||
/** |
|||
* 添加文章管理 |
|||
*/ |
|||
const addEvent = () => { |
|||
router.push('/articles/articles_edit') |
|||
} |
|||
|
|||
/** |
|||
* 编辑文章管理 |
|||
* @param data |
|||
*/ |
|||
const editEvent = (data: any) => { |
|||
router.push('/articles/articles_edit?id='+data.id) |
|||
} |
|||
|
|||
/** |
|||
* 删除文章管理 |
|||
*/ |
|||
const deleteEvent = (id: number) => { |
|||
ElMessageBox.confirm(t('articlesDeleteTips'), t('warning'), |
|||
{ |
|||
confirmButtonText: t('confirm'), |
|||
cancelButtonText: t('cancel'), |
|||
type: 'warning', |
|||
} |
|||
).then(() => { |
|||
deleteArticles(id).then(() => { |
|||
loadArticlesList() |
|||
}).catch(() => { |
|||
}) |
|||
}) |
|||
} |
|||
|
|||
|
|||
const publisherIdList = ref([]) |
|||
const setPublisherIdList = async () => { |
|||
publisherIdList.value = await (await getWithSysUserList({})).data |
|||
} |
|||
setPublisherIdList() |
|||
|
|||
const resetForm = (formEl: FormInstance | undefined) => { |
|||
if (!formEl) return |
|||
formEl.resetFields() |
|||
loadArticlesList() |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
/* 多行超出隐藏 */ |
|||
.multi-hidden { |
|||
word-break: break-all; |
|||
text-overflow: ellipsis; |
|||
overflow: hidden; |
|||
display: -webkit-box; |
|||
-webkit-line-clamp: 2; |
|||
-webkit-box-orient: vertical; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,218 @@ |
|||
<template> |
|||
<div class="main-container"> |
|||
<div class="detail-head"> |
|||
<div class="left" @click="back()"> |
|||
<span class="iconfont iconxiangzuojiantou !text-xs"></span> |
|||
<span class="ml-[1px]">{{t('returnToPreviousPage')}}</span> |
|||
</div> |
|||
<span class="adorn">|</span> |
|||
<span class="right">{{ pageName }}</span> |
|||
</div> |
|||
<el-card class="box-card !border-none" shadow="never"> |
|||
<el-form :model="formData" label-width="90px" ref="formRef" :rules="formRules" class="page-form"> |
|||
<el-form-item :label="t('title')" prop="title"> |
|||
<el-input v-model="formData.title" clearable :placeholder="t('titlePlaceholder')" class="input-width" /> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('content')" prop="content"> |
|||
<el-input v-model="formData.content" clearable :placeholder="t('contentPlaceholder')" class="input-width" /> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('category')" prop="category"> |
|||
<el-select class="input-width" v-model="formData.category" clearable :placeholder="t('categoryPlaceholder')"> |
|||
<el-option label="请选择" value=""></el-option> |
|||
<el-option |
|||
v-for="(item, index) in categoryList" |
|||
:key="index" |
|||
:label="item.name" |
|||
:value="item.value" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('publisherId')" prop="publisher_id"> |
|||
<el-select class="input-width" v-model="formData.publisher_id" clearable :placeholder="t('publisherIdPlaceholder')"> |
|||
<el-option label="请选择" value=""></el-option> |
|||
<el-option |
|||
v-for="(item, index) in publisherIdList" |
|||
:key="index" |
|||
:label="item['uid']" |
|||
:value="item['real_name']" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
|
|||
<el-form-item :label="t('status')" prop="status"> |
|||
<el-radio-group v-model="formData.status" :placeholder="t('statusPlaceholder')"> |
|||
<el-radio |
|||
v-for="(item, index) in statusList" |
|||
:key="index" :label="item.value"> |
|||
{{ item.name }} |
|||
</el-radio> |
|||
</el-radio-group> |
|||
</el-form-item> |
|||
|
|||
</el-form> |
|||
</el-card> |
|||
<div class="fixed-footer-wrap"> |
|||
<div class="fixed-footer"> |
|||
<el-button type="primary" @click="onSave(formRef)">{{ t('save') }}</el-button> |
|||
<el-button @click="back()">{{ t('cancel') }}</el-button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { ref, reactive, computed, watch } from 'vue' |
|||
import { t } from '@/lang' |
|||
import { useDictionary } from '@/app/api/dict' |
|||
import type { FormInstance } from 'element-plus' |
|||
import { getArticlesInfo,addArticles,editArticles, getWithSysUserList } from '@/addon/zhjw/api/articles'; |
|||
import { useRoute } from 'vue-router' |
|||
|
|||
const route = useRoute() |
|||
const id:number = parseInt(route.query.id); |
|||
const loading = ref(false) |
|||
const pageName = route.meta.title |
|||
|
|||
|
|||
|
|||
/** |
|||
* 表单数据 |
|||
*/ |
|||
const initialFormData = { |
|||
id: 0, |
|||
title: '', |
|||
content: '', |
|||
category: '', |
|||
publisher_id: '', |
|||
status: '', |
|||
} |
|||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|||
|
|||
const setFormData = async (id:number = 0) => { |
|||
Object.assign(formData, initialFormData) |
|||
const data = await (await getArticlesInfo(id)).data |
|||
Object.keys(formData).forEach((key: string) => { |
|||
if (data[key] != undefined) formData[key] = data[key] |
|||
}) |
|||
} |
|||
if(id) setFormData(id); |
|||
|
|||
const formRef = ref<FormInstance>() |
|||
// 选中数据 |
|||
const selectData = ref<any[]>([]) |
|||
|
|||
// 字典数据 |
|||
let categoryList = ref([]) |
|||
const categoryDictList = async () => { |
|||
categoryList.value = await (await useDictionary('zhjw_article_category')).data.dictionary |
|||
} |
|||
categoryDictList(); |
|||
watch(() => categoryList.value, () => { formData.category = categoryList.value[0].value }) |
|||
let statusList = ref([]) |
|||
const statusDictList = async () => { |
|||
statusList.value = await (await useDictionary('is_radio')).data.dictionary |
|||
} |
|||
statusDictList(); |
|||
watch(() => statusList.value, () => { formData.status = statusList.value[0].value }) |
|||
|
|||
|
|||
const publisherIdList = ref([] as any[]) |
|||
const setPublisherIdList = async () => { |
|||
publisherIdList.value = await (await getWithSysUserList({})).data |
|||
} |
|||
setPublisherIdList() |
|||
// 表单验证规则 |
|||
const formRules = computed(() => { |
|||
return { |
|||
title: [ |
|||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
content: [ |
|||
{ required: true, message: t('contentPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
category: [ |
|||
{ required: true, message: t('categoryPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
publisher_id: [ |
|||
{ required: true, message: t('publisherIdPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
status: [ |
|||
{ required: true, message: t('statusPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
} |
|||
}) |
|||
|
|||
const onSave = async (formEl: FormInstance | undefined) => { |
|||
if (loading.value || !formEl) return |
|||
await formEl.validate(async (valid) => { |
|||
if (valid) { |
|||
loading.value = true |
|||
let data = formData |
|||
|
|||
const save = id ? editArticles : addArticles |
|||
save(data).then(res => { |
|||
loading.value = false |
|||
history.back() |
|||
}).catch(err => { |
|||
loading.value = false |
|||
}) |
|||
|
|||
} |
|||
}) |
|||
} |
|||
|
|||
// 验证手机号格式 |
|||
const mobileVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
|||
callback(new Error(t('generateMobile'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
// 验证身份证号 |
|||
const idCardVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
|||
callback(new Error(t('generateIdCard'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
// 验证邮箱号 |
|||
const emailVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
|||
callback(new Error(t('generateEmail'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
|
|||
// 验证请输入整数 |
|||
const numberVerify = (rule: any, value: any, callback: any) => { |
|||
if (!Number.isInteger(value)) { |
|||
callback(new Error(t('generateNumber'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
const back = () => { |
|||
history.back() |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped></style> |
|||
@ -0,0 +1,101 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace addon\zhjw\app\adminapi\controller\articles; |
|||
|
|||
use core\base\BaseAdminController; |
|||
use addon\zhjw\app\service\admin\articles\ArticlesService; |
|||
|
|||
|
|||
/** |
|||
* 文章管理控制器 |
|||
* Class Articles |
|||
* @package addon\zhjw\app\adminapi\controller\articles |
|||
*/ |
|||
class Articles extends BaseAdminController |
|||
{ |
|||
/** |
|||
* 获取文章管理列表 |
|||
* @return \think\Response |
|||
*/ |
|||
public function lists(){ |
|||
$data = $this->request->params([ |
|||
["title",""], |
|||
["content",""], |
|||
["category",""], |
|||
["publisher_id",""], |
|||
["status",""] |
|||
]); |
|||
return success((new ArticlesService())->getPage($data)); |
|||
} |
|||
|
|||
/** |
|||
* 文章管理详情 |
|||
* @param int $id |
|||
* @return \think\Response |
|||
*/ |
|||
public function info(int $id){ |
|||
return success((new ArticlesService())->getInfo($id)); |
|||
} |
|||
|
|||
/** |
|||
* 添加文章管理 |
|||
* @return \think\Response |
|||
*/ |
|||
public function add(){ |
|||
$data = $this->request->params([ |
|||
["title",""], |
|||
["content",""], |
|||
["category",""], |
|||
["publisher_id",0], |
|||
["status",""], |
|||
|
|||
]); |
|||
$this->validate($data, 'addon\zhjw\app\validate\articles\Articles.add'); |
|||
$id = (new ArticlesService())->add($data); |
|||
return success('ADD_SUCCESS', ['id' => $id]); |
|||
} |
|||
|
|||
/** |
|||
* 文章管理编辑 |
|||
* @param $id 文章管理id |
|||
* @return \think\Response |
|||
*/ |
|||
public function edit(int $id){ |
|||
$data = $this->request->params([ |
|||
["title",""], |
|||
["content",""], |
|||
["category",""], |
|||
["publisher_id",0], |
|||
["status",""], |
|||
|
|||
]); |
|||
$this->validate($data, 'addon\zhjw\app\validate\articles\Articles.edit'); |
|||
(new ArticlesService())->edit($id, $data); |
|||
return success('EDIT_SUCCESS'); |
|||
} |
|||
|
|||
/** |
|||
* 文章管理删除 |
|||
* @param $id 文章管理id |
|||
* @return \think\Response |
|||
*/ |
|||
public function del(int $id){ |
|||
(new ArticlesService())->del($id); |
|||
return success('DELETE_SUCCESS'); |
|||
} |
|||
|
|||
|
|||
public function getSysUserAll(){ |
|||
return success(( new ArticlesService())->getSysUserAll()); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,124 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace addon\zhjw\app\model\articles; |
|||
|
|||
use core\base\BaseModel; |
|||
use think\model\concern\SoftDelete; |
|||
use think\model\relation\HasMany; |
|||
use think\model\relation\HasOne; |
|||
|
|||
use app\model\sys\SysUser; |
|||
|
|||
/** |
|||
* 文章管理模型 |
|||
* Class Articles |
|||
* @package addon\zhjw\app\model\articles |
|||
*/ |
|||
class Articles extends BaseModel |
|||
{ |
|||
|
|||
use SoftDelete; |
|||
|
|||
/** |
|||
* 数据表主键 |
|||
* @var string |
|||
*/ |
|||
protected $pk = 'id'; |
|||
|
|||
/** |
|||
* 模型名称 |
|||
* @var string |
|||
*/ |
|||
protected $name = 'zhjw_articles'; |
|||
|
|||
/** |
|||
* 定义软删除标记字段. |
|||
* @var string |
|||
*/ |
|||
protected $deleteTime = 'delete_time'; |
|||
|
|||
/** |
|||
* 定义软删除字段的默认值. |
|||
* @var int |
|||
*/ |
|||
protected $defaultSoftDelete = 0; |
|||
|
|||
/** |
|||
* 搜索器:文章管理标题 |
|||
* @param $value |
|||
* @param $data |
|||
*/ |
|||
public function searchTitleAttr($query, $value, $data) |
|||
{ |
|||
if ($value) { |
|||
$query->where("title", "like", "%".$value."%"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 搜索器:文章管理内容 |
|||
* @param $value |
|||
* @param $data |
|||
*/ |
|||
public function searchContentAttr($query, $value, $data) |
|||
{ |
|||
if ($value) { |
|||
$query->where("content", "like", "%".$value."%"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 搜索器:文章管理文章分类 |
|||
* @param $value |
|||
* @param $data |
|||
*/ |
|||
public function searchCategoryAttr($query, $value, $data) |
|||
{ |
|||
if ($value) { |
|||
$query->where("category", $value); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 搜索器:文章管理发布人 |
|||
* @param $value |
|||
* @param $data |
|||
*/ |
|||
public function searchPublisherIdAttr($query, $value, $data) |
|||
{ |
|||
if ($value) { |
|||
$query->where("publisher_id", $value); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 搜索器:文章管理状态 |
|||
* @param $value |
|||
* @param $data |
|||
*/ |
|||
public function searchStatusAttr($query, $value, $data) |
|||
{ |
|||
if ($value) { |
|||
$query->where("status", $value); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public function sysUser(){ |
|||
return $this->hasOne(SysUser::class, 'real_name', 'publisher_id')->joinType('left')->withField('uid,real_name')->bind(['publisher_id_name'=>'uid']); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace addon\zhjw\app\service\admin\articles; |
|||
|
|||
use addon\zhjw\app\model\articles\Articles; |
|||
use app\model\sys\SysUser; |
|||
|
|||
use core\base\BaseAdminService; |
|||
|
|||
|
|||
/** |
|||
* 文章管理服务层 |
|||
* Class ArticlesService |
|||
* @package addon\zhjw\app\service\admin\articles |
|||
*/ |
|||
class ArticlesService extends BaseAdminService |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
$this->model = new Articles(); |
|||
} |
|||
|
|||
/** |
|||
* 获取文章管理列表 |
|||
* @param array $where |
|||
* @return array |
|||
*/ |
|||
public function getPage(array $where = []) |
|||
{ |
|||
$field = 'id,title,content,category,publisher_id,status,create_time,update_time,delete_time'; |
|||
$order = 'id desc'; |
|||
|
|||
$search_model = $this->model->withSearch(["title","content","category","publisher_id","status"], $where)->with(['sysUser'])->field($field)->order($order); |
|||
$list = $this->pageQuery($search_model); |
|||
return $list; |
|||
} |
|||
|
|||
/** |
|||
* 获取文章管理信息 |
|||
* @param int $id |
|||
* @return array |
|||
*/ |
|||
public function getInfo(int $id) |
|||
{ |
|||
$field = 'id,title,content,category,publisher_id,status,create_time,update_time,delete_time'; |
|||
|
|||
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['sysUser'])->findOrEmpty()->toArray(); |
|||
$info['status'] = strval($info['status']); |
|||
return $info; |
|||
} |
|||
|
|||
/** |
|||
* 添加文章管理 |
|||
* @param array $data |
|||
* @return mixed |
|||
*/ |
|||
public function add(array $data) |
|||
{ |
|||
$res = $this->model->create($data); |
|||
return $res->id; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 文章管理编辑 |
|||
* @param int $id |
|||
* @param array $data |
|||
* @return bool |
|||
*/ |
|||
public function edit(int $id, array $data) |
|||
{ |
|||
|
|||
$this->model->where([['id', '=', $id]])->update($data); |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 删除文章管理 |
|||
* @param int $id |
|||
* @return bool |
|||
*/ |
|||
public function del(int $id) |
|||
{ |
|||
$model = $this->model->where([['id', '=', $id]])->find(); |
|||
$res = $model->delete(); |
|||
return $res; |
|||
} |
|||
|
|||
|
|||
public function getSysUserAll(){ |
|||
$sysUserModel = new SysUser(); |
|||
return $sysUserModel->select()->toArray(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace addon\zhjw\app\validate\articles; |
|||
use core\base\BaseValidate; |
|||
/** |
|||
* 文章管理验证器 |
|||
* Class Articles |
|||
* @package addon\zhjw\app\validate\articles |
|||
*/ |
|||
class Articles extends BaseValidate |
|||
{ |
|||
|
|||
protected $rule = [ |
|||
'title' => 'require', |
|||
'content' => 'require', |
|||
'category' => 'require', |
|||
'publisher_id' => 'require', |
|||
'status' => 'require', |
|||
]; |
|||
|
|||
protected $message = [ |
|||
'title.require' => ['common_validate.require', ['title']], |
|||
'content.require' => ['common_validate.require', ['content']], |
|||
'category.require' => ['common_validate.require', ['category']], |
|||
'publisher_id.require' => ['common_validate.require', ['publisher_id']], |
|||
'status.require' => ['common_validate.require', ['status']], |
|||
]; |
|||
|
|||
protected $scene = [ |
|||
"add" => ['title', 'content', 'category', 'publisher_id', 'status'], |
|||
"edit" => ['title', 'content', 'category', 'publisher_id', 'status'] |
|||
]; |
|||
|
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:6:{s:2:"id";i:2;s:10:"config_key";s:23:"START_UP_PAGE_DIY_INDEX";s:5:"value";a:6:{s:4:"type";s:9:"DIY_INDEX";s:4:"name";s:10:"SHOP_INDEX";s:6:"parent";s:9:"SHOP_LINK";s:4:"page";s:23:"/addon/shop/pages/index";s:5:"title";s:24:"dict_diy.shop_link_index";s:6:"action";s:8:"decorate";}s:6:"status";i:1;s:11:"create_time";s:19:"2025-03-04 09:13:36";s:11:"update_time";s:19:"2025-03-04 09:13:36";} |
|||
@ -1,4 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:1:{i:0;s:4:"shop";} |
|||
a:2:{i:0;s:4:"shop";i:1;s:4:"zhjw";} |
|||
File diff suppressed because one or more lines are too long
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:1:{i:0;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\c9\50b19bc6adb712f49ee5bbefeda601.php";} |
|||
@ -0,0 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:4:{i:0;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\20\336a007c8134208722cf4e14270f07.php";i:1;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\8d\4b55ce338f9b3a100a33ac8e8243e8.php";i:2;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\32\0a87fb2f5a7e9725055a2c99bd1e51.php";i:3;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\72\3ee2b5cca5d08bc4a333825c70f9c4.php";} |
|||
@ -0,0 +1,4 @@ |
|||
<?php |
|||
//000000000300 |
|||
exit();?> |
|||
a:2:{s:9:"secretKey";s:16:"bk88q1zmp1k2lcgw";s:5:"point";O:27:"Fastknife\Domain\Vo\PointVo":2:{s:1:"x";i:190;s:1:"y";i:5;}} |
|||
File diff suppressed because one or more lines are too long
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:1:{i:0;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\85\dff97d885b41077c47958d953c2dbd.php";} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:1:{i:0;a:6:{s:5:"title";s:12:"商城系统";s:4:"icon";s:19:"addon/shop/icon.png";s:3:"key";s:4:"shop";s:4:"desc";s:63:"实物虚拟商品,订单,物流同城配送,门店自提";s:6:"status";i:1;s:5:"cover";s:20:"addon/shop/cover.png";}} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000300 |
|||
exit();?> |
|||
a:2:{s:9:"secretKey";s:16:"hfk4kwq8r6p7ucrq";s:5:"point";O:27:"Fastknife\Domain\Vo\PointVo":2:{s:1:"x";i:179;s:1:"y";i:5;}} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000300 |
|||
exit();?> |
|||
a:2:{s:9:"secretKey";s:16:"tzex4hnus36vtgyn";s:5:"point";O:27:"Fastknife\Domain\Vo\PointVo":2:{s:1:"x";i:181;s:1:"y";i:5;}} |
|||
@ -1,4 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:16:{i:0;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\8d\edc20f770c6500c52ce13d6f306b10.php";i:1;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\f0\8f735f0ec7f9eccc3e70aa516d941d.php";i:2;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\47\0f6e29f334d3244ee0749eb9b1a151.php";i:3;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\bd\359a5364051f6c84d65c787bf23f9a.php";i:4;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\f4\073ed8013d62bb2e0f768418925e4d.php";i:5;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\c8\a5c3cd9f43d503a892ec0eaeb9ab08.php";i:6;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\a0\81b1d0c6234fbc717b33719be823a2.php";i:7;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\95\228e6be1c6483f594d6d736cba9335.php";i:8;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\8f\7fdd2caa2302a943c6b21d4b077526.php";i:9;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\21\6e30a16639b283b1efa6b98838867b.php";i:10;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\85\c6bb2855c5978a0ab5483ed7646a3b.php";i:11;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\01\c8e2ef1c2c504601d752e81c5f8f57.php";i:12;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\04\a77b15025b2c34a79ecfe786681739.php";i:13;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\ed\b6cf0da7ae6bc4e108cde29a092460.php";i:14;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\c0\2ea470914e2a1b4422c74fb53b3fb7.php";i:15;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\96\42cea4fc1e386bb972a5e5dec82fda.php";} |
|||
a:4:{i:0;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\f4\073ed8013d62bb2e0f768418925e4d.php";i:1;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\8d\edc20f770c6500c52ce13d6f306b10.php";i:2;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\c8\a5c3cd9f43d503a892ec0eaeb9ab08.php";i:3;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\f0\8f735f0ec7f9eccc3e70aa516d941d.php";} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:2:{s:8:"username";s:5:"admin";s:8:"password";s:6:"123456";} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000300 |
|||
exit();?> |
|||
a:2:{s:9:"secretKey";s:16:"kompifhgmu9trr4w";s:5:"point";O:27:"Fastknife\Domain\Vo\PointVo":2:{s:1:"x";i:209;s:1:"y";i:5;}} |
|||
File diff suppressed because one or more lines are too long
@ -0,0 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:1:{i:0;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\11\96761b4a84f0e988872166216d02cd.php";} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:4:{i:0;s:264:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpc3MiOiJzaG9wYWRtaW4uY2MiLCJhdWQiOiJzaG9wYWRtaW4uY2MiLCJpYXQiOjE3NDEwMDc3MDIsIm5iZiI6MTc0MTAwNzcwMiwiZXhwIjoxNzQxNjEyNTAyLCJqdGkiOiIxX2FkbWluIn0.ARwVjIYCdNUSwEmmm1KhrY1zKEWhRME0j26HM_GUNc4";i:1;s:264:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpc3MiOiJzaG9wYWRtaW4uY2MiLCJhdWQiOiJzaG9wYWRtaW4uY2MiLCJpYXQiOjE3NDEwNTA4MTYsIm5iZiI6MTc0MTA1MDgxNiwiZXhwIjoxNzQxNjU1NjE2LCJqdGkiOiIxX2FkbWluIn0.aZLpv4RBIlBCbnnqV9oXk9kC5AgdKHTUYiS3CCBSAqw";i:2;s:264:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpc3MiOiJzaG9wYWRtaW4uY2MiLCJhdWQiOiJzaG9wYWRtaW4uY2MiLCJpYXQiOjE3NDEwNTE0MTksIm5iZiI6MTc0MTA1MTQxOSwiZXhwIjoxNzQxNjU2MjE5LCJqdGkiOiIxX2FkbWluIn0.znLMCEfxdiRUIwiCBFah2d4cMlkJAazGbfAPU2C4bfo";i:3;s:251:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpc3MiOiJ6aGp3LmNjIiwiYXVkIjoiemhqdy5jYyIsImlhdCI6MTc0MTE1NjA1NSwibmJmIjoxNzQxMTU2MDU1LCJleHAiOjE3NDE3NjA4NTUsImp0aSI6IjFfYWRtaW4ifQ.Wt0Rfttva_ld-or-b7Ya5UI6TIJsTpu7ZyBIjXNJAsw";} |
|||
a:1:{i:0;s:251:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpc3MiOiJ6aGp3LmNjIiwiYXVkIjoiemhqdy5jYyIsImlhdCI6MTc0MTE2MDA0MSwibmJmIjoxNzQxMTYwMDQxLCJleHAiOjE3NDE3NjQ4NDEsImp0aSI6IjFfYWRtaW4ifQ.VPc32FOi_ft_SVPV18-1UTAP8yeLHhZHlY15bnYJiZM";} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000300 |
|||
exit();?> |
|||
a:2:{s:9:"secretKey";s:16:"l9ebzlmq9vow1xvi";s:5:"point";O:27:"Fastknife\Domain\Vo\PointVo":2:{s:1:"x";i:158;s:1:"y";i:5;}} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:1:{i:0;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\3d\23e92f6d905dabf364fea237dcc9b2.php";} |
|||
@ -1,4 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:2:{i:0;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\8d\fdacbfbb7ae58ba988054e909e2307.php";i:1;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\8d\fdacbfbb7ae58ba988054e909e2307.php";} |
|||
a:1:{i:0;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\8d\fdacbfbb7ae58ba988054e909e2307.php";} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:1:{i:0;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\a2\c8f1f64a1c2171c95fce93be9d7fad.php";} |
|||
a:1:{i:0;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\a2\c8f1f64a1c2171c95fce93be9d7fad.php";} |
|||
@ -1,4 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:14:{s:11:"status_name";s:6:"正常";s:3:"uid";i:1;s:8:"username";s:5:"admin";s:8:"head_img";s:0:"";s:9:"real_name";s:0:"";s:7:"last_ip";s:9:"127.0.0.1";s:9:"last_time";s:19:"2025-03-04 09:23:39";s:11:"create_time";s:0:"";s:11:"login_count";i:2;s:6:"status";i:1;s:11:"delete_time";i:0;s:11:"update_time";s:19:"2025-03-04 09:23:39";s:8:"role_ids";N;s:8:"is_admin";i:1;} |
|||
a:14:{s:11:"status_name";s:6:"正常";s:3:"uid";i:1;s:8:"username";s:5:"admin";s:8:"head_img";s:0:"";s:9:"real_name";s:0:"";s:7:"last_ip";s:9:"127.0.0.1";s:9:"last_time";s:19:"2025-03-05 15:33:47";s:11:"create_time";s:0:"";s:11:"login_count";i:8;s:6:"status";i:1;s:11:"delete_time";i:0;s:11:"update_time";s:19:"2025-03-05 15:33:47";s:8:"role_ids";N;s:8:"is_admin";i:1;} |
|||
@ -0,0 +1,4 @@ |
|||
<?php |
|||
//000000000300 |
|||
exit();?> |
|||
a:2:{s:9:"secretKey";s:16:"m755qyq455oyyr0t";s:5:"point";O:27:"Fastknife\Domain\Vo\PointVo":2:{s:1:"x";i:252;s:1:"y";i:5;}} |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
File diff suppressed because one or more lines are too long
@ -1,4 +0,0 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
-1 |
|||
@ -1,4 +1,4 @@ |
|||
<?php |
|||
//000000000000 |
|||
exit();?> |
|||
a:1:{i:0;s:88:"D:\phpstudy_pro\WWW\niushop\niucloud\runtime\cache\a2\c8f1f64a1c2171c95fce93be9d7fad.php";} |
|||
a:2:{i:0;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\a2\c8f1f64a1c2171c95fce93be9d7fad.php";i:1;s:121:"D:\DeveloperApp\phpstudy_pro\WWW\NiuCloud_ZhiHuiJiaoWu_Admin\niucloud\runtime\cache\d2\47cd20a670e865d55fa58f706501b6.php";} |
|||
Loading…
Reference in new issue