|
|
@ -7,17 +7,32 @@ |
|
|
|
<a-space style="margin-left: 16px;"> |
|
|
|
<a-button @click="search">查询</a-button> |
|
|
|
<a-button type="primary" ghost @click="addModal">新增</a-button> |
|
|
|
<a-modal v-model:open="addControl.open" :title="addControl.title" cancelText="取消" okText="确定" @ok="add"> |
|
|
|
<a-modal v-model:open="addControl.open" :title="addControl.title" cancelText="取消" okText="确定" @ok="add" @cancel="unControl(addControl.title)"> |
|
|
|
<a-form ref="formRef" :model="addList" name="basic" :label-col="{ span: 4, offset: 2 }" |
|
|
|
:wrapper-col="{ span: 16 }"> |
|
|
|
<a-form-item label="类型名称" name="typename" :rules="[{ required: true, message: '请输入类型名称!' }]"> |
|
|
|
<a-input v-model:value="addList.typename" /> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item label="备注" name="descr" :rules="[{ required: true, message: '请输入备注!' }]"> |
|
|
|
<a-form-item label="备注" name="descr" :rules="[{ required: false, message: '请输入备注!' }]"> |
|
|
|
<a-input v-model:value="addList.descr" /> |
|
|
|
</a-form-item> |
|
|
|
</a-form> |
|
|
|
</a-modal> |
|
|
|
<a-modal v-model:open="editControl.open" :title="editControl.title" cancelText="取消" okText="确定" |
|
|
|
@ok="edit" @cancel="unControl(editControl.title)"> |
|
|
|
<a-form ref="formRef" :model="editList" name="basic" :label-col="{ span: 4, offset: 2 }" |
|
|
|
:wrapper-col="{ span: 16 }"> |
|
|
|
<a-form-item label="类型名称" name="typename" :rules="[{ required: true, message: '请修改类型名称!' }]"> |
|
|
|
<a-input v-model:value="editList.typename" /> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item label="备注" name="descr" :rules="[{ required: false, message: '请修改备注!' }]"> |
|
|
|
<a-input v-model:value="editList.descr" /> |
|
|
|
</a-form-item> |
|
|
|
</a-form> |
|
|
|
</a-modal> |
|
|
|
<a-modal v-model:open="delControl.open" title="提示" ok-text="确认" cancel-text="取消" @ok="del" @cancel="unControl('删除')"> |
|
|
|
<p>确认删除吗?</p> |
|
|
|
</a-modal> |
|
|
|
</a-space> |
|
|
|
</div> |
|
|
|
<div class="table"> |
|
|
@ -25,28 +40,9 @@ |
|
|
|
<template #bodyCell="{ column, record }"> |
|
|
|
<template v-if="column.dataIndex === 'operation'"> |
|
|
|
<a-space> |
|
|
|
<div> |
|
|
|
<a-button size="small" danger @click="delModal(record.id)">删除</a-button> |
|
|
|
<a-modal v-model:open="delControl.open" title="提示" ok-text="确认" cancel-text="取消" |
|
|
|
@ok="del"> |
|
|
|
<p>确认删除吗?</p> |
|
|
|
</a-modal> |
|
|
|
</div> |
|
|
|
<a-button size="small" type="primary" ghost @click="editModal(record.id)">编辑</a-button> |
|
|
|
<a-modal v-model:open="editControl.open" :title="editControl.title" cancelText="取消" |
|
|
|
okText="确定" @ok="edit"> |
|
|
|
<a-form ref="formRef" :model="editList" name="basic" :label-col="{ span: 4, offset: 2 }" |
|
|
|
:wrapper-col="{ span: 16 }"> |
|
|
|
<a-form-item label="类型名称" name="typename" |
|
|
|
:rules="[{ required: true, message: '请修改类型名称!' }]"> |
|
|
|
<a-input v-model:value="editList.typename" /> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item label="备注" name="descr" |
|
|
|
:rules="[{ required: true, message: '请修改备注!' }]"> |
|
|
|
<a-input v-model:value="editList.descr" /> |
|
|
|
</a-form-item> |
|
|
|
</a-form> |
|
|
|
</a-modal> |
|
|
|
|
|
|
|
</a-space> |
|
|
|
</template> |
|
|
|
</template> |
|
|
@ -58,6 +54,7 @@ |
|
|
|
<script setup lang='ts'> |
|
|
|
import { onMounted, reactive, ref } from 'vue'; |
|
|
|
import { typeStore } from "@/stores/index" |
|
|
|
import { message } from 'ant-design-vue'; |
|
|
|
import type { typeInterface } from "@/api/admin" |
|
|
|
import { get, post, remove, put } from '@/tools/request'; |
|
|
|
const { delControl, addControl, editControl } = typeStore() |
|
|
@ -69,6 +66,9 @@ const addList = ref({ |
|
|
|
typename: "", |
|
|
|
descr: "" |
|
|
|
}) |
|
|
|
const unControl = (text: string) => { |
|
|
|
message.warn(`取消${text}`) |
|
|
|
} |
|
|
|
|
|
|
|
const editList = ref({ |
|
|
|
typename: "", |
|
|
@ -96,7 +96,7 @@ const typeList = async () => { |
|
|
|
const search = async () => { |
|
|
|
try { |
|
|
|
await get( |
|
|
|
"/types/list/search", |
|
|
|
"/diarytypes/search", |
|
|
|
{ typename: searchlist.typename } |
|
|
|
).then(response => { |
|
|
|
if (response) { |
|
|
@ -123,7 +123,7 @@ const formRef = ref(); |
|
|
|
const add = async () => { |
|
|
|
try { |
|
|
|
await post( |
|
|
|
"/types/add", |
|
|
|
"/diarytypes/add", |
|
|
|
addList.value |
|
|
|
) |
|
|
|
typeList() |
|
|
@ -143,7 +143,7 @@ const del = async (id: any) => { |
|
|
|
try { |
|
|
|
if (id) { |
|
|
|
await remove( |
|
|
|
`/types/delete/${id}` |
|
|
|
`/diarytypes/delete/${id}` |
|
|
|
) |
|
|
|
typeList() |
|
|
|
} else { |
|
|
@ -161,7 +161,7 @@ const editModal = (id: any) => { |
|
|
|
editControl.title = "编辑" |
|
|
|
editControl.open = true |
|
|
|
get( |
|
|
|
`/types/list/search/${id}` |
|
|
|
`/diarytypes/search/${id}` |
|
|
|
).then(response => { |
|
|
|
editList.value = response.data.data |
|
|
|
}) |
|
|
@ -171,7 +171,7 @@ const edit = async (id: any) => { |
|
|
|
try { |
|
|
|
if (id) { |
|
|
|
await put( |
|
|
|
`/types/update/${id}`, |
|
|
|
`/diarytypes/update/${id}`, |
|
|
|
editList.value |
|
|
|
) |
|
|
|
editControl.open = false |
|
|
|