123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <div class="page">
- <el-card shadow="never">
- <el-form :model="tableData.param" ref="queryRef" inline>
- <el-form-item label="升级包名称" prop="keyWord">
- <el-input
- v-model="tableData.param.keyWord"
- placeholder="请输入升级包名称"
- clearable
- style="width: 240px"
- @keyup.enter.native="getList(1)"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" class="ml10" @click="getList(1)">
- <el-icon>
- <ele-Search />
- </el-icon>
- 查询
- </el-button>
- <el-button @click="resetQuery">
- <el-icon>
- <ele-Refresh />
- </el-icon>
- 重置
- </el-button>
- <el-button type="primary" v-auth="'add'" @click="onOpenAdd()">
- <el-icon>
- <ele-FolderAdd />
- </el-icon>
- 添加升级包
- </el-button>
- </el-form-item>
- </el-form>
- <el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading">
- <el-table-column label="ID" v-col="'id'" align="center" prop="id" width="100" />
- <el-table-column label="升级包名称" v-col="'name'" prop="name" min-width="120" show-overflow-tooltip />
- <el-table-column prop="types" label="类型" show-overflow-tooltip v-col="'types'">
- <template #default="scope">
- <el-tag size="small" v-if="scope.row.types == 1">整包</el-tag>
- <el-tag type="info" size="small" v-if="scope.row.types == 2">差分</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="所属产品" v-col="'productName'" min-width="120" align="center" show-overflow-tooltip>
- <template #default="scope">
- <router-link :to="'/iotmanager/device/product/detail/' + scope.row.productKey" class="link-type">
- <span>{{ scope.row.productName }}</span>
- </router-link>
- </template>
- </el-table-column>
- <el-table-column label="模块名称" v-col="'moduleName'" align="center" show-overflow-tooltip>
- <template #default="scope">
- <router-link :to="'/iotmanager/operation/ota/module'" class="link-type">
- <span>{{ scope.row.moduleName }}</span>
- </router-link>
- </template>
- </el-table-column>
- <el-table-column label="需要验证" prop="check" v-col="'check'" width="120" align="center">
- <template #default="scope">
- <!-- 1需要,2不需要 -->
- <el-tag size="small" v-if="scope.row.check === 1">需要</el-tag>
- <el-tag type="danger" size="small" v-if="scope.row.check === 2">不需要</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="状态" prop="checkres" v-col="'checkres'" width="120" align="center">
- <template #default="scope">
- <!-- 升级包验证 0未验证,1验证中 2已验证 -->
- <el-tag size="small" v-if="scope.row.checkres === 1">验证中</el-tag>
- <el-tag type="success" size="small" v-if="scope.row.checkres === 2">已验证</el-tag>
- <el-tag type="danger" size="small" v-if="scope.row.checkres === 0">未验证</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="版本号" prop="version" align="center" width="160" />
- <el-table-column label="创建时间" prop="createdAt" align="center" width="160" />
- <el-table-column label="操作" width="150" v-col="'handle'" align="center" fixed="right">
- <template #default="scope">
- <el-button size="small" text type="primary" v-if="!scope.row.folderName" @click="toDetail(scope.row.id)">查看</el-button>
- <el-button size="small" text type="warning" v-auth="'edit'" @click="onOpenEdit(scope.row)">编辑</el-button>
- <el-button size="small" text type="info" v-auth="'del'" @click="onRowDel(scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="tableData.total > 0"
- :total="tableData.total"
- v-model:page="tableData.param.pageNum"
- v-model:limit="tableData.param.pageSize"
- @pagination="getList"
- />
- <EditConfig ref="editRef" @getList="getList(1)" />
- <CheckConfig ref="checkRef" @getList="getList(1)" />
- </el-card>
- </div>
- </template>
- <script lang="ts">
- import api from '/@/api/ota'
- import { toRefs, reactive, onMounted, ref, defineComponent, getCurrentInstance } from 'vue'
- import { ElMessageBox, ElMessage, FormInstance } from 'element-plus'
- import EditConfig from '/@/views/iot/ota-update/update/component/edit.vue'
- import CheckConfig from '/@/views/iot/ota-update/update/component/check.vue'
- import { useRouter } from 'vue-router'
- // 定义接口来定义对象的类型
- interface TableDataRow {
- id: number
- name: string
- types: string
- productName: number
- moduleName: string
- checkres: string
- createdAt: string
- }
- interface TableDataState {
- ids: number[]
- tableData: {
- data: Array<TableDataRow>
- total: number
- loading: boolean
- param: {
- pageNum: number
- pageSize: number
- keyWord: string
- dateRange: string[]
- }
- }
- }
- export default defineComponent({
- name: 'apiV1OtaUpdateDataList',
- components: { EditConfig, CheckConfig },
- setup() {
- const router = useRouter()
- const editRef = ref()
- const checkRef = ref()
- const detailRef = ref()
- const queryRef = ref()
- const tabDataList = ref([{ dictLabel: '全部', dictValue: '' }])
- const state = reactive<TableDataState>({
- ids: [],
- tableData: {
- data: [],
- total: 0,
- loading: false,
- param: {
- dateRange: [],
- pageNum: 1,
- pageSize: 20,
- keyWord: '',
- },
- },
- })
- // 页面加载时
- onMounted(() => {
- initTableData()
- })
- // 初始化表格数据
- const initTableData = () => {
- manageList()
- }
- const getList = (pageNum?: number) => {
- typeof pageNum === 'number' && (state.tableData.param.pageNum = pageNum)
- state.tableData.loading = true
- api.manage
- .getList(state.tableData.param)
- .then((res: any) => {
- state.tableData.data = res.firmware
- state.tableData.total = res.Total
- })
- .finally(() => (state.tableData.loading = false))
- }
- // 打开新增弹窗
- const onOpenAdd = () => {
- editRef.value.openDialog()
- }
- // 打开修改弹窗
- const onOpenEdit = (row: TableDataRow) => {
- editRef.value.openDialog(row)
- }
- // 打开详情弹窗
- // const opOpenDetail = (row: TableDataRow) => {
- // };
- const toDetail = (id: number) => {
- router.push(`/iotmanager/operation/ota/update/detail/${id}`)
- }
- // 删除模块
- const onRowDel = (row?: TableDataRow) => {
- let msg = '你确定要删除所选数据?'
- let ids: number[] = []
- if (row) {
- msg = `此操作将永久删除:“${row.name}”,是否继续?`
- ids = [row.id]
- } else {
- ids = state.ids
- }
- if (ids.length === 0) {
- ElMessage.error('请选择要删除的数据。')
- return
- }
- ElMessageBox.confirm(msg, '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(() => {
- api.manage.del(ids).then(() => {
- ElMessage.success('删除成功')
- getList()
- })
- })
- .catch(() => {})
- }
- /** 重置按钮操作 */
- const resetQuery = () => {
- if (!queryRef.value) return
- queryRef.value.resetFields()
- getList(1)
- }
- // 多选框选中数据
- const handleSelectionChange = (selection: TableDataRow[]) => {
- state.ids = selection.map((item) => item.id)
- }
- // 获取列表
- const manageList = () => {
- getList()
- }
- return {
- editRef,
- checkRef,
- queryRef,
- tabDataList,
- toDetail,
- onOpenAdd,
- onOpenEdit,
- onRowDel,
- getList,
- resetQuery,
- handleSelectionChange,
- ...toRefs(state),
- }
- },
- })
- </script>
|