This commit is contained in:
mkm 2023-08-31 11:21:40 +08:00
parent 7400adcd42
commit dfa9ac7dd8
3 changed files with 370 additions and 0 deletions

26
src/api/app_update.ts Normal file
View File

@ -0,0 +1,26 @@
import request from '@/utils/request'
// app更新列表
export function apiAppUpdateLists(params: any) {
return request.get({ url: '/app_update/lists', params })
}
// 添加app更新
export function apiAppUpdateAdd(params: any) {
return request.post({ url: '/app_update/add', params })
}
// 编辑app更新
export function apiAppUpdateEdit(params: any) {
return request.post({ url: '/app_update/edit', params })
}
// 删除app更新
export function apiAppUpdateDelete(params: any) {
return request.post({ url: '/app_update/delete', params })
}
// app更新详情
export function apiAppUpdateDetail(params: any) {
return request.get({ url: '/app_update/detail', params })
}

View File

@ -0,0 +1,153 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="标题" prop="title">
<el-input v-model="formData.title" clearable placeholder="请输入标题" />
</el-form-item>
<el-form-item label="内容" prop="content">
<el-input v-model="formData.content" clearable placeholder="请输入内容" />
</el-form-item>
<el-form-item label="APP类型" prop="type">
<el-radio-group v-model="formData.type" placeholder="请选择APP类型">
<el-radio
v-for="(item, index) in dictData.app_type"
:key="index"
:label="parseInt(item.value)"
>
{{ item.name }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="版本" prop="version">
<el-input v-model="formData.version" clearable placeholder="请输入版本" />
</el-form-item>
<el-form-item label="app链接" prop="dow_url">
<el-input v-model="formData.dow_url" clearable placeholder="请输入app链接" />
</el-form-item>
<el-form-item label="是否强制更新" prop="force">
<el-radio-group v-model="formData.force" placeholder="请选择是否强制更新">
<el-radio
v-for="(item, index) in dictData.app_force_quiet"
:key="index"
:label="parseInt(item.value)"
>
{{ item.name }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="是否静默更新" prop="quiet">
<el-radio-group v-model="formData.quiet" placeholder="请选择是否静默更新">
<el-radio
v-for="(item, index) in dictData.app_force_quiet"
:key="index"
:label="parseInt(item.value)"
>
{{ item.name }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="appUpdateEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiAppUpdateAdd, apiAppUpdateEdit, apiAppUpdateDetail } from '@/api/app_update'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑app更新' : '新增app更新'
})
//
const formData = reactive({
id: '',
title: '',
content: '',
type: '',
version: '',
dow_url: '',
force: '',
quiet: '',
})
//
const formRules = reactive<any>({
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiAppUpdateDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiAppUpdateEdit(data)
: await apiAppUpdateAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,191 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="标题" prop="title">
<el-input class="w-[280px]" v-model="queryParams.title" clearable placeholder="请输入标题" />
</el-form-item>
<el-form-item label="内容" prop="content">
<el-input class="w-[280px]" v-model="queryParams.content" clearable placeholder="请输入内容" />
</el-form-item>
<el-form-item label="APP类型" prop="type">
<el-select class="w-[280px]" v-model="queryParams.type" clearable placeholder="请选择APP类型">
<el-option label="全部" value=""></el-option>
<el-option
v-for="(item, index) in dictData.app_type"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="版本" prop="version">
<el-input class="w-[280px]" v-model="queryParams.version" clearable placeholder="请输入版本" />
</el-form-item>
<el-form-item label="app链接" prop="dow_url">
<el-input class="w-[280px]" v-model="queryParams.dow_url" clearable placeholder="请输入app链接" />
</el-form-item>
<el-form-item label="是否强制更新" prop="force">
<el-select class="w-[280px]" v-model="queryParams.force" clearable placeholder="请选择是否强制更新">
<el-option label="全部" value=""></el-option>
<el-option
v-for="(item, index) in dictData.app_force_quiet"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="是否静默更新" prop="quiet">
<el-select class="w-[280px]" v-model="queryParams.quiet" clearable placeholder="请选择是否静默更新">
<el-option label="全部" value=""></el-option>
<el-option
v-for="(item, index) in dictData.app_force_quiet"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<el-button v-perms="['app_update/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<el-button
v-perms="['app_update/delete']"
:disabled="!selectData.length"
@click="handleDelete(selectData)"
>
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="标题" prop="title" show-overflow-tooltip />
<el-table-column label="内容" prop="content" show-overflow-tooltip />
<el-table-column label="APP类型" prop="type">
<template #default="{ row }">
<dict-value :options="dictData.app_type" :value="row.type" />
</template>
</el-table-column>
<el-table-column label="版本" prop="version" show-overflow-tooltip />
<el-table-column label="app链接" prop="dow_url" show-overflow-tooltip />
<el-table-column label="是否强制更新" prop="force">
<template #default="{ row }">
<dict-value :options="dictData.app_force_quiet" :value="row.force" />
</template>
</el-table-column>
<el-table-column label="是否静默更新" prop="quiet">
<template #default="{ row }">
<dict-value :options="dictData.app_force_quiet" :value="row.quiet" />
</template>
</el-table-column>
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['app_update/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['app_update/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup name="appUpdateLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiAppUpdateLists, apiAppUpdateDelete } from '@/api/app_update'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
title: '',
content: '',
type: '',
version: '',
dow_url: '',
force: '',
quiet: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('app_type,app_force_quiet')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiAppUpdateLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiAppUpdateDelete({ id })
getLists()
}
getLists()
</script>