From e9dc03b62fea3db1b2029a2a485c3e18caac6a43 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 07 六月 2022 10:31:53 +0800
Subject: [PATCH] 添加文件类型
---
src/views/project/index.vue | 350 ++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 242 insertions(+), 108 deletions(-)
diff --git a/src/views/project/index.vue b/src/views/project/index.vue
index 8df14be..b77d588 100644
--- a/src/views/project/index.vue
+++ b/src/views/project/index.vue
@@ -2,20 +2,49 @@
<div class="table-container">
<vab-query-form>
<vab-query-form-left-panel>
- <el-form ref="form" :model="queryForm" :inline="true" @submit.native.prevent>
+ <el-form
+ ref="form"
+ :model="queryForm"
+ :inline="true"
+ @submit.native.prevent
+ >
<el-form-item>
- <el-input v-model="queryForm.title" placeholder="鍚嶇О" />
+ <el-input
+ v-model="queryForm.name"
+ placeholder="鍚嶇О"
+ clearable=""
+ />
</el-form-item>
<el-form-item>
<el-select
- v-model="queryForm.address"
+ v-model="queryForm.type"
placeholder="绫诲瀷"
class="handle-select mr10"
size="mini"
+ clearable=""
>
- <el-option key="1" label="绯荤粺" value="绯荤粺"></el-option>
- <el-option key="2" label="搴旂敤" value="搴旂敤"></el-option>
- <el-option key="3" label="绠楁硶" value="绠楁硶"></el-option>
+ <el-option
+ v-for="(v, k) in typeOptions"
+ :key="k"
+ :label="v"
+ :value="k"
+ ></el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item>
+ <el-select
+ v-model="queryForm.arch"
+ placeholder="鏋舵瀯"
+ class="handle-select mr10"
+ size="mini"
+ clearable=""
+ >
+ <el-option
+ v-for="(v, k) in archOptions"
+ :key="k"
+ :label="v"
+ :value="k"
+ ></el-option>
</el-select>
</el-form-item>
<el-form-item>
@@ -24,14 +53,18 @@
type="primary"
native-type="submit"
@click="handleQuery"
- >鏌ヨ</el-button>
+ >鏌ヨ</el-button
+ >
</el-form-item>
</el-form>
</vab-query-form-left-panel>
<vab-query-form-right-panel>
<el-button icon="el-icon-plus" type="primary" @click="handleAdd">
- 娣诲姞</el-button>
- <el-button icon="el-icon-delete" type="danger" @click="handleDelete">鍒犻櫎</el-button>
+ 娣诲姞</el-button
+ >
+ <el-button icon="el-icon-delete" type="danger" @click="handleDelete"
+ >鍒犻櫎</el-button
+ >
</vab-query-form-right-panel>
</vab-query-form>
@@ -41,13 +74,19 @@
stripe
:data="list"
:element-loading-text="elementLoadingText"
- :height="height"
@selection-change="setSelectRows"
@expand-change="expandChange"
>
<el-table-column type="expand">
<template slot-scope="props">
- <el-table :data="props.row.pkgList" :show-header="false" style="width: 100%">
+ <el-table
+ :data="props.row.pkgList"
+ :show-header="false"
+ style="width: 100%"
+ row-class-name="expand-row"
+ :highlight-current-row="false"
+ >
+ >
<el-table-column prop="fileName"></el-table-column>
<el-table-column prop="version" width="150"></el-table-column>
<el-table-column prop="commit" width="150"></el-table-column>
@@ -55,40 +94,107 @@
<el-table-column prop="state" width="150">
<template #default="{ row }">
- <el-tag>{{ packageState[row.state] }}</el-tag>
+ <el-tag :type="row.state == 0 ? 'success' : 'danger'">{{
+ packageState[row.state]
+ }}</el-tag>
</template>
</el-table-column>
- <el-table-column width="120">
+ <el-table-column width="300">
<template #default="scope">
- <el-button size="small" @click="handlePublish(scope.row)">鍙戝竷</el-button>
+ <el-button
+ v-show="props.row.type == 'os' || props.row.type == 'algo'"
+ size="small"
+ @click="handlePublish(scope.row)"
+ >鍙戝竷</el-button
+ >
+ <el-button size="small" @click="handleDownload(scope.row)"
+ >涓嬭浇</el-button
+ >
+ <el-button
+ size="small"
+ type="warning"
+ :disabled="scope.row.state === 0"
+ @click="handleRebuild(scope.row)"
+ >閲嶇疆</el-button
+ >
+
+ <!-- 姝e湪鎵撳寘鐨勪换鍔′互鍙婅嚜鍔ㄦ墦鍖呯殑浠诲姟涓嶅厑璁稿垹闄� -->
+ <el-button
+ size="small"
+ type="danger"
+ :disabled="
+ scope.row.createType == 0 ||
+ (scope.row.state > 0 && scope.row.state < 3)
+ "
+ @click="handleDeletePkg(scope.row)"
+ >鍒犻櫎</el-button
+ >
</template>
</el-table-column>
</el-table>
</template>
</el-table-column>
<!-- <el-table-column show-overflow-tooltip type="selection" width="55"></el-table-column> -->
- <el-table-column show-overflow-tooltip label="搴忓彿" width="95">
+ <el-table-column show-overflow-tooltip label="搴忓彿" width="50">
<template #default="scope">{{ scope.$index + 1 }}</template>
</el-table-column>
- <el-table-column show-overflow-tooltip prop="name" label="椤圭洰鍚嶇О"></el-table-column>
- <el-table-column show-overflow-tooltip prop="srcUrl" label="椤圭洰鍦板潃"></el-table-column>
+ <el-table-column
+ show-overflow-tooltip
+ prop="name"
+ label="鍚嶇О"
+ width="150"
+ ></el-table-column>
+ <el-table-column
+ show-overflow-tooltip
+ prop="desc"
+ label="鎻忚堪"
+ ></el-table-column>
+ <el-table-column
+ show-overflow-tooltip
+ prop="srcUrl"
+ label="鍦板潃"
+ width="500"
+ ></el-table-column>
+ <el-table-column show-overflow-tooltip prop="branch" label="鍒嗘敮">
+ </el-table-column>
<el-table-column show-overflow-tooltip prop="type" label="绫诲瀷">
<template #default="{ row }">
- <el-tag>{{ row.type | typeFilter }}</el-tag>
+ <el-tag>{{ typeOptions[row.type] }}</el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column show-overflow-tooltip prop="arch" label="鏋舵瀯">
+ <template #default="{ row }">
+ <el-tag>{{ archOptions[row.arch] }}</el-tag>
</template>
</el-table-column>
<!-- <el-table-column show-overflow-tooltip label="褰撳墠鐗堟湰" prop="latestVersion"></el-table-column> -->
<el-table-column label="鐘舵��">
<template #default="{ row }">
- <el-tag>{{ row.state | stateFilter }}</el-tag>
+ <el-tag :type="row.state == 2 ? 'danger' : 'success'">{{
+ projectState[row.state]
+ }}</el-tag>
</template>
</el-table-column>
- <el-table-column label="鍒涘缓鏃堕棿" prop="createdAt" width="200"></el-table-column>
+ <el-table-column
+ label="鍒涘缓鏃堕棿"
+ prop="createdAt"
+ width="150"
+ ></el-table-column>
<el-table-column label="鎿嶄綔" width="180px">
<template #default="{ row }">
<el-button type="text" @click="handleEdit(row)">缂栬緫</el-button>
- <el-button type="text" style="color: red" @click="handleDeleteRow(row)">鍒犻櫎</el-button>
- <el-button type="text" style="color: deepskyblue" @click="handlePack(row)">鎵撳寘</el-button>
+ <el-button
+ type="text"
+ style="color: red"
+ @click="handleDeleteRow(row)"
+ >鍒犻櫎</el-button
+ >
+ <el-button
+ type="text"
+ style="color: deepskyblue"
+ @click="handlePack(row)"
+ >鎵撳寘</el-button
+ >
</template>
</el-table-column>
</el-table>
@@ -106,166 +212,194 @@
</template>
<script>
-import { getList, deletePrj, getPkgList, buildPkg } from '@/api/project'
-import { publish } from '@/api/package'
+import { getList, deletePrj, getPkgList, buildPkg } from "@/api/project";
+import { publish, download, rebuild, deletePkg } from "@/api/package";
-import TableEdit from './components/ProjectEdit.vue'
+import TableEdit from "./components/ProjectEdit.vue";
+
export default {
- name: 'ComprehensiveTable',
+ name: "ComprehensiveTable",
components: {
TableEdit,
},
- filters: {
- stateFilter(state) {
- const stateMap = ['涓嬭浇涓�', '鍚屾瀹屾垚', '鍚屾澶辫触']
-
- return stateMap[state]
- },
- typeFilter(type) {
- const typeMap = {
- sys: '绯荤粺鍖�',
- app: '搴旂敤鍖�',
- algo: '绠楁硶鍖�',
- }
- return typeMap[type]
- },
- },
data() {
return {
- imgShow: true,
list: [],
listLoading: true,
- layout: 'total, sizes, prev, pager, next, jumper',
+ layout: "total, sizes, prev, pager, next, jumper",
+ archOptions: {
+ amd64: "x86_64",
+ arm64: "arm_64",
+ },
+ typeOptions: {
+ os: "AIOS",
+ sys: "绯荤粺鍖�",
+ app: "搴旂敤鍖�",
+ algo: "绠楁硶鍖�",
+ },
+ projectState: ["涓嬭浇涓�", "鍚屾瀹屾垚", "鍚屾澶辫触"],
packageState: [
- '瀹屾垚',
- '宸叉彁浜�',
- '鎺掗槦涓�',
- '鎵撳寘涓�',
- '缂栬瘧澶辫触',
- '鎵撳寘澶辫触',
+ "鎵撳寘瀹屾垚",
+ "宸� 鎻� 浜�",
+ "鎺� 闃� 涓�",
+ "鎵� 鍖� 涓�",
+ "缂栬瘧澶辫触",
+ "鎵撳寘澶辫触",
],
total: 0,
background: true,
- selectRows: '',
- elementLoadingText: '姝e湪鍔犺浇...',
+ selectRows: "",
+ expandRow: "",
+ elementLoadingText: "姝e湪鍔犺浇...",
queryForm: {
pageNo: 1,
pageSize: 20,
- title: '',
},
- }
+ };
},
computed: {
height() {
- return this.$baseTableHeight()
+ return this.$baseTableHeight();
},
},
created() {
- this.fetchData()
+ this.fetchData();
},
- beforeDestroy() { },
- mounted() { },
+ beforeDestroy() {},
+ mounted() {},
methods: {
setSelectRows(val) {
- this.selectRows = val
+ this.selectRows = val;
},
handleAdd() {
- this.$refs['edit'].showEdit()
+ this.$refs["edit"].showEdit();
},
handleEdit(row) {
- this.$refs['edit'].showEdit(row)
+ this.$refs["edit"].showEdit(row);
},
handleDelete(row) {
if (this.selectRows.length > 0) {
- const ids = this.selectRows.map((item) => item.id).join()
- this.$baseConfirm('浣犵‘瀹氳鍒犻櫎閫変腑椤瑰悧', null, async () => {
- const { msg } = await doDelete({ ids: ids })
- this.$baseMessage(msg, 'success')
- this.fetchData()
- })
+ const ids = this.selectRows.map((item) => item.id).join();
+ this.$baseConfirm("浣犵‘瀹氳鍒犻櫎閫変腑椤瑰悧", null, async () => {
+ const { msg } = await doDelete({ ids: ids });
+ this.$baseMessage(msg, "success");
+ this.fetchData();
+ });
} else {
- this.$baseMessage('鏈�変腑浠讳綍琛�', 'error')
- return false
+ this.$baseMessage("鏈�変腑浠讳綍琛�", "error");
+ return false;
}
},
handleDeleteRow(row) {
if (row.id) {
- this.$baseConfirm('浣犵‘瀹氳鍒犻櫎褰撳墠椤瑰悧', null, async () => {
- const { msg } = await deletePrj(row.id)
- this.$baseMessage(msg, 'success')
- this.fetchData()
- })
+ this.$baseConfirm("浣犵‘瀹氳鍒犻櫎褰撳墠椤瑰悧", null, async () => {
+ const { msg } = await deletePrj(row.id);
+ this.$baseMessage(msg, "success");
+ this.fetchData();
+ });
}
},
handleSizeChange(val) {
- this.queryForm.pageSize = val
- this.fetchData()
+ this.queryForm.pageSize = val;
+ this.fetchData();
},
handleCurrentChange(val) {
- this.queryForm.pageNo = val
- this.fetchData()
+ this.queryForm.pageNo = val;
+ this.fetchData();
},
handleQuery() {
- this.queryForm.pageNo = 1
- this.fetchData()
+ this.queryForm.pageNo = 1;
+ this.fetchData();
},
async fetchData() {
- this.listLoading = true
- const { data, total } = await getList(this.queryForm)
+ this.listLoading = true;
+ const { data, total } = await getList(this.queryForm);
if (data) {
data.forEach((item) => {
- item.pkgList = []
- })
+ item.pkgList = [];
+ });
- this.list = data
+ this.list = data;
}
- this.total = total
+ this.total = total;
setTimeout(() => {
- this.listLoading = false
- }, 500)
+ this.listLoading = false;
+ }, 500);
},
async expandChange(row, expandRows) {
- console.log(row)
if (expandRows.length == 0) {
- console.log('fold')
- return
+ return;
}
- const { data, total } = await getPkgList(row.id)
+ this.getPackageList(row.id);
+ },
+ async getPackageList(id) {
+ const { data, total } = await getPkgList(id);
this.list.forEach((item, idx) => {
- if (item.id === row.id) {
- this.list[idx].pkgList = data
+ if (item.id === id) {
+ this.list[idx].pkgList = data.reverse();
}
- })
+ });
},
handlePack(row) {
- this.$prompt('璇疯緭鍏ョ増鏈彿', '鎻愮ず', {
- confirmButtonText: '纭畾',
- cancelButtonText: '鍙栨秷',
+ this.$prompt("璇疯緭鍏ョ増鏈彿", "鎻愮ず", {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
inputPattern: /[\d+][\.\d+]*/,
- inputErrorMessage: '鐗堟湰鍙锋牸寮忎笉姝g‘,渚� 1.0.0, 10.1.100',
+ inputErrorMessage: "鐗堟湰鍙锋牸寮忎笉姝g‘,渚� 1.0.0, 10.1.100",
})
.then(({ value }) => {
buildPkg(row, value).then((rsp) => {
- console.log(rsp)
- this.expandChange(row, 1)
- })
+ this.expandChange(row, 1);
+ });
})
.catch(() => {
this.$message({
- type: 'info',
- message: '鍙栨秷杈撳叆',
- })
- })
+ type: "info",
+ message: "鍙栨秷杈撳叆",
+ });
+ });
},
handlePublish(row) {
publish(row).then((rsp) => {
- console.log(rsp)
- })
+ if (rsp && rsp.success) {
+ this.$baseMessage(rsp.msg, "success");
+ }
+ });
+ },
+ handleDownload(row) {
+ download({ path: row.filePath }).then((rsp) => {
+ if (rsp && rsp.success) {
+ window.location = rsp.data;
+ }
+ });
+ },
+ handleRebuild(row) {
+ rebuild(row).then((rsp) => {
+ if (rsp && rsp.success) {
+ this.$baseMessage(rsp.msg, "success");
+ } else {
+ this.$baseMessage("淇濆瓨澶辫触", "error");
+ }
+ });
+ },
+ handleDeletePkg(row) {
+ if (row.id) {
+ this.$baseConfirm("浣犵‘瀹氳鍒犻櫎褰撳墠椤瑰悧", null, async () => {
+ const { msg } = await deletePkg(row);
+ this.$baseMessage(msg, "success");
+ this.getPackageList(row.projectId);
+ });
+ }
},
},
-}
+};
</script>
+<style>
+.el-table .expand-row {
+ background-color: oldlace;
+}
+</style>
--
Gitblit v1.8.0