|
@@ -1,19 +1,50 @@
|
|
|
<template>
|
|
|
<div class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
- <custom-search-bar :fields="fields.filter((f) => f.isSearch)" v-model="searchForm" @search="search" @reset="toReset"></custom-search-bar>
|
|
|
+ <custom-search-bar
|
|
|
+ :fields="fields.filter((f) => f.isSearch)"
|
|
|
+ v-model="searchForm"
|
|
|
+ @search="search"
|
|
|
+ @reset="toReset"
|
|
|
+ ></custom-search-bar>
|
|
|
<custom-button-bar :fields="buttonFields" @add="toAdd"></custom-button-bar>
|
|
|
- <custom-table :data="data" :fields="fields" @query="search" :total="total" :opera="opera" @exam="toExam" @edit="toEdit" @delete="toDelete">
|
|
|
+ <custom-table
|
|
|
+ :data="data"
|
|
|
+ :fields="fields"
|
|
|
+ @query="search"
|
|
|
+ :total="total"
|
|
|
+ :opera="opera"
|
|
|
+ @exam="toExam"
|
|
|
+ @edit="toEdit"
|
|
|
+ @delete="toDelete"
|
|
|
+ >
|
|
|
<template #is_use="{ row }">
|
|
|
<el-tag v-if="row.is_use == '0'" type="success" @click="toUse(row, '1')">启用</el-tag>
|
|
|
<el-tag v-else type="info" @click="toUse(row, '0')">禁用</el-tag>
|
|
|
</template>
|
|
|
</custom-table>
|
|
|
- <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
|
|
|
+ <el-dialog
|
|
|
+ v-model="dialog.show"
|
|
|
+ :title="dialog.title"
|
|
|
+ :destroy-on-close="false"
|
|
|
+ @close="toClose"
|
|
|
+ >
|
|
|
<el-row>
|
|
|
<el-col :span="24" v-if="dialog.type == '1'">
|
|
|
<custom-form v-model="form" :fields="formFields" :rules="rules" @save="toSave">
|
|
|
+ <template #logo>
|
|
|
+ <custom-upload
|
|
|
+ model="logo"
|
|
|
+ :list="form.logo"
|
|
|
+ :limit="1"
|
|
|
+ url="/files/web/template/news/upload"
|
|
|
+ @change="onUpload"
|
|
|
+ listType="picture-card"
|
|
|
+ ></custom-upload>
|
|
|
+ </template>
|
|
|
<template #is_use>
|
|
|
- <el-radio v-for="i in isUseList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
|
|
|
+ <el-radio v-for="i in isUseList" :key="i._id" :label="i.value">{{
|
|
|
+ i.label
|
|
|
+ }}</el-radio>
|
|
|
</template>
|
|
|
<template #content>
|
|
|
<WangEditor v-model="form.content" />
|
|
@@ -21,9 +52,19 @@
|
|
|
</custom-form>
|
|
|
</el-col>
|
|
|
<el-col :span="24" v-if="dialog.type == '2'">
|
|
|
- <custom-form v-model="examForm" :fields="examFormFields" :rules="examRules" @save="toExamSave">
|
|
|
+ <custom-form
|
|
|
+ v-model="examForm"
|
|
|
+ :fields="examFormFields"
|
|
|
+ :rules="examRules"
|
|
|
+ @save="toExamSave"
|
|
|
+ >
|
|
|
<template #status>
|
|
|
- <el-option v-for="i in statusList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ <el-option
|
|
|
+ v-for="i in statusList"
|
|
|
+ :key="i._id"
|
|
|
+ :label="i.label"
|
|
|
+ :value="i.value"
|
|
|
+ ></el-option>
|
|
|
</template>
|
|
|
</custom-form>
|
|
|
</el-col>
|
|
@@ -52,13 +93,24 @@ const fields = [
|
|
|
{ label: t('pages.news.person'), model: 'person', isSearch: true },
|
|
|
{ label: t('pages.news.time'), model: 'time', type: 'date', isSearch: true },
|
|
|
{ label: t('pages.news.number'), model: 'number' },
|
|
|
- { label: t('pages.news.is_use'), model: 'is_use', custom: true, format: (i) => getDict(i, 'is_use') },
|
|
|
+ {
|
|
|
+ label: t('pages.news.is_use'),
|
|
|
+ model: 'is_use',
|
|
|
+ custom: true,
|
|
|
+ format: (i) => getDict(i, 'is_use')
|
|
|
+ },
|
|
|
{ label: t('pages.news.status'), model: 'status', format: (i) => getDict(i, 'status') }
|
|
|
]
|
|
|
const opera = [
|
|
|
{ label: t('common.update'), method: 'edit', display: (i) => i.is_use === '1' },
|
|
|
{ label: t('common.exam'), method: 'exam', type: 'warning', display: (i) => i.status === '0' },
|
|
|
- { label: t('common.delete'), method: 'delete', confirm: true, type: 'danger', display: (i) => i.is_use === '1' }
|
|
|
+ {
|
|
|
+ label: t('common.delete'),
|
|
|
+ method: 'delete',
|
|
|
+ confirm: true,
|
|
|
+ type: 'danger',
|
|
|
+ display: (i) => i.is_use === '1'
|
|
|
+ }
|
|
|
]
|
|
|
const buttonFields = [{ label: t('common.add'), method: 'add' }]
|
|
|
let skip = 0
|
|
@@ -70,11 +122,13 @@ const statusList = ref([])
|
|
|
const loading = ref(false)
|
|
|
const formFields = ref([])
|
|
|
const formFieldsForCreate = [
|
|
|
+ { label: t('pages.news.logo'), model: 'logo', custom: true },
|
|
|
{ label: t('pages.news.title'), model: 'title' },
|
|
|
{ label: t('pages.news.is_use'), model: 'is_use', type: 'radio' },
|
|
|
{ label: t('pages.news.content'), model: 'content', custom: true }
|
|
|
]
|
|
|
const formFieldsForUpdate = [
|
|
|
+ { label: t('pages.news.logo'), model: 'logo', custom: true },
|
|
|
{ label: t('pages.news.title'), model: 'title' },
|
|
|
{ label: t('pages.news.person'), model: 'person', options: { disabled: true } },
|
|
|
{ label: t('pages.news.time'), model: 'time', type: 'date', options: { disabled: true } },
|
|
@@ -82,12 +136,16 @@ const formFieldsForUpdate = [
|
|
|
{ label: t('pages.news.is_use'), model: 'is_use', type: 'radio' },
|
|
|
{ label: t('pages.news.content'), model: 'content', custom: true }
|
|
|
]
|
|
|
-const rules = reactive({ title: [{ required: true, message: t('pages.news.titleMessage'), trigger: 'blur' }] })
|
|
|
+const rules = reactive({
|
|
|
+ title: [{ required: true, message: t('pages.news.titleMessage'), trigger: 'blur' }]
|
|
|
+})
|
|
|
const dialog = ref({ type: '1', show: false, title: t('pages.news.addDialogTitle') })
|
|
|
const form = ref({})
|
|
|
// 审核
|
|
|
const examFormFields = [{ label: t('pages.news.status'), model: 'status', type: 'select' }]
|
|
|
-const examRules = reactive({ status: [{ required: true, message: t('common.statusMessage'), trigger: 'blur' }] })
|
|
|
+const examRules = reactive({
|
|
|
+ status: [{ required: true, message: t('common.statusMessage'), trigger: 'blur' }]
|
|
|
+})
|
|
|
const examForm = ref({})
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
@@ -140,6 +198,13 @@ const toDelete = async (data) => {
|
|
|
search({ skip: 0, limit })
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// 上传图片
|
|
|
+const onUpload = (e) => {
|
|
|
+ const { model, value } = e
|
|
|
+ form.value[model] = value
|
|
|
+}
|
|
|
+
|
|
|
const toSave = async () => {
|
|
|
const data = cloneDeep(form.value)
|
|
|
const other = { time: moment().format('YYYY-MM-DD'), person: user.value.nick_name, status: '0' }
|
|
@@ -167,7 +232,11 @@ const toExamSave = async () => {
|
|
|
}
|
|
|
// 开启或禁用
|
|
|
const toUse = async (data, is_use) => {
|
|
|
- ElMessageBox.confirm(`确定修改【${data.title}】数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
|
|
|
+ ElMessageBox.confirm(`确定修改【${data.title}】数据?`, '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
.then(async () => {
|
|
|
let res = await store.update({ _id: get(data, '_id'), is_use })
|
|
|
if ($checkRes(res, true)) {
|