From 1cb263efda55e67a8d5066edd7709b056f9b85ff Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期二, 07 九月 2021 18:46:59 +0800 Subject: [PATCH] code format --- src/views/project/index.vue | 226 ++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 138 insertions(+), 88 deletions(-) diff --git a/src/views/project/index.vue b/src/views/project/index.vue index 8df14be..6c2c5d8 100644 --- a/src/views/project/index.vue +++ b/src/views/project/index.vue @@ -2,7 +2,12 @@ <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-form-item> @@ -24,14 +29,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> @@ -47,7 +56,11 @@ > <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%" + > <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> @@ -58,9 +71,14 @@ <el-tag>{{ packageState[row.state] }}</el-tag> </template> </el-table-column> - <el-table-column width="120"> + <el-table-column width="200"> <template #default="scope"> - <el-button size="small" @click="handlePublish(scope.row)">鍙戝竷</el-button> + <el-button size="small" @click="handlePublish(scope.row)" + >鍙戝竷</el-button + > + <el-button size="small" @click="handleDownload(scope.row)" + >涓嬭浇</el-button + > </template> </el-table-column> </el-table> @@ -70,8 +88,16 @@ <el-table-column show-overflow-tooltip label="搴忓彿" width="95"> <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="椤圭洰鍚嶇О" + ></el-table-column> + <el-table-column + show-overflow-tooltip + prop="srcUrl" + label="椤圭洰鍦板潃" + ></el-table-column> <el-table-column show-overflow-tooltip prop="type" label="绫诲瀷"> <template #default="{ row }"> <el-tag>{{ row.type | typeFilter }}</el-tag> @@ -83,12 +109,26 @@ <el-tag>{{ row.state | stateFilter }}</el-tag> </template> </el-table-column> - <el-table-column label="鍒涘缓鏃堕棿" prop="createdAt" width="200"></el-table-column> + <el-table-column + label="鍒涘缓鏃堕棿" + prop="createdAt" + width="200" + ></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,28 +146,28 @@ </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 } 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 = ['涓嬭浇涓�', '鍚屾瀹屾垚', '鍚屾澶辫触'] + const stateMap = ["涓嬭浇涓�", "鍚屾瀹屾垚", "鍚屾澶辫触"]; - return stateMap[state] + return stateMap[state]; }, typeFilter(type) { const typeMap = { - sys: '绯荤粺鍖�', - app: '搴旂敤鍖�', - algo: '绠楁硶鍖�', - } - return typeMap[type] + sys: "绯荤粺鍖�", + app: "搴旂敤鍖�", + algo: "绠楁硶鍖�", + }; + return typeMap[type]; }, }, data() { @@ -135,137 +175,147 @@ imgShow: true, list: [], listLoading: true, - layout: 'total, sizes, prev, pager, next, jumper', + layout: "total, sizes, prev, pager, next, jumper", packageState: [ - '瀹屾垚', - '宸叉彁浜�', - '鎺掗槦涓�', - '鎵撳寘涓�', - '缂栬瘧澶辫触', - '鎵撳寘澶辫触', + "瀹屾垚", + "宸叉彁浜�", + "鎺掗槦涓�", + "鎵撳寘涓�", + "缂栬瘧澶辫触", + "鎵撳寘澶辫触", ], total: 0, background: true, - selectRows: '', - elementLoadingText: '姝e湪鍔犺浇...', + selectRows: "", + elementLoadingText: "姝e湪鍔犺浇...", queryForm: { pageNo: 1, pageSize: 20, - title: '', + 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) + console.log(row); if (expandRows.length == 0) { - console.log('fold') - return + console.log("fold"); + return; } - const { data, total } = await getPkgList(row.id) + const { data, total } = await getPkgList(row.id); this.list.forEach((item, idx) => { if (item.id === row.id) { - this.list[idx].pkgList = data + this.list[idx].pkgList = data; } - }) + }); }, 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) - }) + console.log(rsp); + 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) { + console.log(rsp); + window.location = rsp.data; + } + }); }, }, -} +}; </script> -- Gitblit v1.8.0