Browse Source

优化对话框和编辑器组件样式,调整表单布局和逻辑

master
parent
commit
15d094d934
  1. 8
      src/components/Dialog/src/Dialog.vue
  2. 22
      src/components/Editor/src/Editor.vue
  3. 6
      src/styles/variables.scss
  4. 10
      src/utils/formatTime.ts
  5. 64
      src/views/system/policy/PolicyForm.vue
  6. 174
      src/views/system/policy/index.vue
  7. 26
      src/views/system/taglibrary/index.vue

8
src/components/Dialog/src/Dialog.vue

@ -12,7 +12,7 @@ const props = defineProps({
width: propTypes.oneOfType([String, Number]).def('40%'),
scroll: propTypes.bool.def(false), // maxHeight
maxHeight: propTypes.oneOfType([String, Number]).def('400px'),
top: propTypes.string.def('15vh')
})
const getBindValue = computed(() => {
@ -29,9 +29,7 @@ const getBindValue = computed(() => {
const isFullscreen = ref(false)
const toggleFull = () => {
isFullscreen.value = !unref(isFullscreen)
}
const dialogHeight = ref(isNumber(props.maxHeight) ? `${props.maxHeight}px` : props.maxHeight)
@ -67,6 +65,7 @@ const dialogStyle = computed(() => {
lock-scroll
class="com-dialog"
:show-close="false"
:top="top"
>
<template #header="{ close }">
<div class="relative h-54px flex items-center justify-between pl-15px pr-15px">
@ -115,7 +114,6 @@ const dialogStyle = computed(() => {
}
&__body {
padding: 15px !important;
}
&__footer {

22
src/components/Editor/src/Editor.vue

@ -89,9 +89,8 @@ const editorConfig = computed((): IEditorConfig => {
},
autoFocus: false,
scroll: true,
MENU_CONF: {
MENU_CONF: {
['uploadImage']: {
server: getUploadUrl(),
// 2M
@ -229,13 +228,15 @@ defineExpose({
</script>
<template>
<div class="border-0 border-solid border-[var(--tags-view-border-color)] z-10">
<div
class="border-solid border-1 border-#dcdfe6 border-rounded-4px overflow-hidden z-10 pl-2px pr-2px"
>
<!-- 工具栏 -->
<Toolbar
v-if="getShowToolbar"
:editor="editorRef"
:editorId="editorId"
class="border-0 b-b-1 border-solid border-[var(--tags-view-border-color)]"
class="border-0 b-b-1 border-solid border-#303133"
/>
<!-- 编辑器 -->
<Editor
@ -245,8 +246,21 @@ defineExpose({
:style="editorStyle"
@on-change="handleChange"
@on-created="handleCreated"
class="scroll-block-none wgEdit"
/>
</div>
</template>
<style src="@wangeditor/editor/dist/css/style.css"></style>
<style scoped>
.wgEdit >>> .w-e-scroll::-webkit-scrollbar {
width: 4px !important;
//height: 8px !important;
}
.wgEdit >>> .w-e-scroll::-webkit-scrollbar-thumb {
background-color: #dcdfe6 !important;
border-radius: 10px !important;
box-shadow: none !important;
}
</style>

6
src/styles/variables.scss

@ -5,6 +5,7 @@ $elNamespace: el;
.el-form--inline {
display: flex;
flex-flow: row wrap;
gap: 40px;
margin-bottom: 0;
.el-form-item {
@ -23,3 +24,8 @@ $elNamespace: el;
color: #909399;
}
}
.el-pagination--large .btn-next, .el-pagination--large .btn-prev, .el-pagination--large .el-pager li{
height: fit-content;
line-height: normal;
}

10
src/utils/formatTime.ts

@ -1,4 +1,5 @@
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import type { TableColumnCtx } from 'element-plus'
/**
@ -69,7 +70,7 @@ export function formatDate(date: Date, format?: string): string {
return ''
}
// 日期存在,则进行格式化
return date ? dayjs(date).format(format ?? 'YYYY-MM-DD HH:mm:ss') : ''
return date ? dayjs(date).locale('zh-cn').format(format ?? 'YYYY-MM-DD HH:mm:ss') : ''
}
/**
@ -198,7 +199,7 @@ export function formatPast2(ms: number): string {
* @param cellValue
*/
export function dateFormatter(_row: any, _column: TableColumnCtx<any>, cellValue: any): string {
return cellValue ? formatDate(cellValue) : ''
return cellValue ? formatDate(cellValue, 'YYYY年MM月DD日 A') : ''
}
/**
@ -209,10 +210,9 @@ export function dateFormatter(_row: any, _column: TableColumnCtx<any>, cellValue
* @param cellValue
*/
export function dateFormatter2(_row: any, _column: TableColumnCtx<any>, cellValue: any): string {
return cellValue ? formatDate(cellValue, 'YYYY-MM-DD') : ''
return cellValue ? formatDate(cellValue, 'YYYY年MM月DD日') : ''
}
/**
* element plus Formatter 使 YYYY年MM月DD日
*
@ -224,8 +224,6 @@ export function dateFormatter3(_row: any, _column: TableColumnCtx<any>, cellValu
return cellValue ? formatDate(cellValue, 'YYYY年MM月DD日') : ''
}
/**
* 时间为00:00:00
* @param param

64
src/views/system/policy/PolicyForm.vue

@ -1,31 +1,41 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="80%" >
<Dialog :title="dialogTitle" v-model="dialogVisible" width="65vw" top="5vh">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
class="policyForm"
>
<el-form-item label="名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入名称" />
</el-form-item>
<el-form-item label="生效日期" prop="effectiveDate">
<el-date-picker
v-model="formData.effectiveDate"
type="date"
placeholder="请选择生效日期"
value-format="YYYY-MM-DD"
:default-value="new Date()"
/>
</el-form-item>
<el-form-item label="内容" prop="context">
<Editor v-model="formData.context" height="350px" />
</el-form-item>
<section class="flex flex-wrap gap-18px">
<el-form-item label="标题名称" prop="name" class="w-[calc(100%/2-10px)]">
<el-input v-model="formData.name" placeholder="请输入名称" />
</el-form-item>
<el-form-item label="生效日期" prop="effectiveDate" class="w-[calc(100%/2-10px)]">
<el-date-picker
v-model="formData.effectiveDate"
type="date"
placeholder="请选择生效日期"
value-format="YYYY-MM-DD"
:default-value="new Date()"
class="!w100%"
/>
</el-form-item>
<el-form-item label="内容详细" prop="context" class="w100%">
<Editor v-model="formData.context" height="350px" class="!w100%" />
</el-form-item>
</section>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-popconfirm title="是否确定删除当前政策法规?" @confirm="deletePolicy" width="230">
<template #reference>
<el-button type="danger" v-if="formType == 'update'" link class="underline">
我要删除
</el-button>
</template>
</el-popconfirm>
<el-button @click="dialogVisible = false"> </el-button>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
</template>
</Dialog>
</template>
@ -107,4 +117,20 @@ const resetForm = () => {
}
formRef.value?.resetFields()
}
</script>
const deletePolicy=()=>{
PolicyApi.deletePolicy(formData.value.id).then(()=>{
message.success(t('common.delSuccess'))
dialogVisible.value = false
emit('success')
})
}
</script>
<style scoped lang="scss">
.policyForm {
::v-deep(.el-form-item--large) {
margin-bottom: 0;
}
}
</style>

174
src/views/system/policy/index.vue

@ -1,107 +1,83 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-220px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['system:policy:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['system:policy:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<!-- <el-table-column label="id" align="center" prop="id" /> -->
<el-table-column label="名称" align="center" prop="name" />
<el-table-column label="生效日期" align="center" prop="effectiveDate" :formatter="dateFormatter2" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center" min-width="120px">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['system:policy:update']"
>
编辑
<section class="flex flex-col gap-20px">
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryFormRef" :inline="true" @submit.prevent>
<el-form-item prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery" type="primary" plain>
<Icon icon="ep:search" class="mr-5px" /> 查询
</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</el-form-item>
<el-form-item class="ml-auto">
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['system:policy:delete']"
type="primary"
@click="openForm('create')"
v-hasPermi="['system:policy:create']"
>
删除
<Icon icon="ep:circle-plus" class="mr-5px" /> 新增
</el-button>
<el-button
link
type="primary"
@click="clickOpenDetail(scope.row.id)"
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['system:policy:export']"
>
详情
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true">
<el-table-column label="名称" prop="name" />
<el-table-column
label="生效日期"
prop="effectiveDate"
:formatter="dateFormatter2"
width="320"
/>
<el-table-column label="发布人" width="320">
<template #default="{ row }">
{{ `${row.createName} | ${row.createDeptName}` }}
</template>
</el-table-column>
<el-table-column
label="创建时间"
prop="createTime"
:formatter="dateFormatter"
width="320"
/>
<el-table-column label="操作选项" align="center" width="120px">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['system:policy:update']"
>
编辑
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
:total="total"
:show-page-size="false"
layout="total, prev, pager, next"
v-model:current-page="queryParams.pageNo"
v-model:page-size="queryParams.pageSize"
@change="getList"
class="ml-auto"
/>
</section>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
@ -109,7 +85,7 @@
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import download from '@/utils/download'
import { PolicyApi, PolicyVO } from '@/api/system/policy'
import PolicyForm from './PolicyForm.vue'
@ -127,7 +103,7 @@ const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: undefined,
createTime: [],
createTime: []
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
@ -145,7 +121,7 @@ const getList = async () => {
}
const clickOpenDetail = (id: number) => {
console.log(id);
console.log(id)
window.open(`/policyDetail?id=${id}`, '_blank')
}
@ -199,4 +175,4 @@ const handleExport = async () => {
onMounted(() => {
getList()
})
</script>
</script>

26
src/views/system/taglibrary/index.vue

@ -1,18 +1,26 @@
<template>
<ContentWrap>
<section class="flex flex-col gap-20px">
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
<el-form
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
@submit.prevent
>
<el-form-item label="" prop="tagName">
<el-input
v-model="queryParams.tagName"
placeholder="请输入标签的名称"
clearable
@keyup.enter="handleQuery"
@keyup.enter.prevent="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="">
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-8px" /> 搜索</el-button>
<el-button @click="handleQuery" type="primary" plain
><Icon icon="ep:search" class="mr-8px" /> 查询
</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-8px" /> 重置</el-button>
<el-button
type="success"
@ -30,13 +38,18 @@
</el-button>
</el-form-item>
</el-form>
<el-table :data="list">
<el-table :data="list" size="large">
<el-table-column label="父级标签" prop="parentName" />
<el-table-column label="标签名称" prop="tagName" />
<el-table-column label="排列顺序" prop="sort" />
<el-table-column label="操作选项" align="right">
<el-table-column label="操作选项" align="center" width="100">
<template #default="{ row }">
<el-button type="text" @click="openForm(row.id)"> 编辑 </el-button>
<section
class="color-#409EFF cursor-pointer hover--font-bold"
@click="openForm(row.id)"
>
编辑
</section>
</template>
</el-table-column>
</el-table>
@ -47,6 +60,7 @@
v-model:current-page="queryParams.pageNo"
v-model:page-size="queryParams.pageSize"
class="ml-auto"
@change="getList"
/>
</section>
</ContentWrap>

Loading…
Cancel
Save