Commit ff6bd3ca authored by “yiyousong”'s avatar “yiyousong”

feat:新增移动端应用

parent f0054910
<template>
<div>暂未开通</div>
<div class="terminal">
<div class="header flex aic jcb mb20">
<a-space>
<a-button type="primary" @click="handleAdd"> 新增应用 </a-button>
<a-button type="primary" @click="handleClone"> 克隆 </a-button>
</a-space>
<a-input-search
style="width: 300px"
placeholder="请输入应用名称搜索"
enter-button="搜索"
v-model="searchVal"
allowClear
@search="onSearch"
/>
</div>
<!-- 表格 -->
<div class="table-content">
<a-table
:row-selection="{
selectedRowKeys: selectedRowKeys,
onChange: onSelectChange,
}"
:loading="loading"
bordered
:scroll="{ y: 550 }"
:columns="columns"
:pagination="{
showTotal: (total) => `共 ${total} 条`,
current: current,
total: total,
pageSize: size,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: handleChange,
onShowSizeChange: showSizeChange,
}"
:data-source="tableData"
:rowKey="(record) => record.id"
>
<!-- 序号 -->
<span slot="num" slot-scope="text, record, index">{{
(current - 1) * size + index + 1
}}</span>
<!-- 图标 -->
<template slot="appIconPath" slot-scope="text">
<img
v-if="text.appIconPath"
height="20"
width="20"
:src="api2 + text.appIconPath"
/>
<span v-else>--</span>
</template>
<!-- 简介 -->
<template slot="summary" slot-scope="text">
<span :title="text.summary">{{
text.summary ? text.summary : "--"
}}</span>
</template>
<!-- 版本 -->
<template slot="version" slot-scope="text">
{{ text.version ? "v" + text.version : "--" }}
</template>
<!-- 类型 -->
<template slot="appType" slot-scope="text">
{{ text.appType === 1 ? "应用程序" : "URL" }}
</template>
<!-- 上下架 -->
<template slot="shelves" slot-scope="text">
<YSwitch
checkedChildren="上架"
unCheckedChildren="下架"
v-model="text.shelves"
@change="changeShelves(text)"
></YSwitch>
</template>
<!-- 操作 -->
<template slot="action" slot-scope="text">
<a-space size="middle">
<a class="edit" @click="handleEdit(text)">编辑</a>
<a class="primary" @click="handleCheck(text.id)">查看</a>
<a
class="delete"
:class="{ unDelete: text.distribute }"
@click="handleDel(text.distribute, text.id)"
>删除</a
>
</a-space>
</template>
</a-table>
</div>
<!-- 新增应用 -->
<AddApp
ref="AddApp"
@success="getAppList"
:AddVisible.sync="AddVisible"
:title="title"
></AddApp>
<!-- 选择站点 -->
<CheckSite
ref="CheckSite"
@checkSite="cloneSuccess"
:appList="selectedRowKeys"
:siteVisible.sync="siteVisible"
></CheckSite>
</div>
</template>
<script>
export default {};
import YSwitch from "../../../../components/yswitch/YSwitch.vue";
import AddApp from "../modal/AddApp.vue";
import CheckSite from "../modal/CheckSite.vue";
import { getAppList, deleteApp, saveApp } from "@/services/market";
import local from "@/utils/local";
const columns = [
{
title: "序号",
dataIndex: "num",
width: "65px",
scopedSlots: {
customRender: "num",
},
},
{
title: "应用名称",
dataIndex: "appName",
},
{
title: "应用图标",
scopedSlots: { customRender: "appIconPath" },
},
{
title: "当前版本",
scopedSlots: { customRender: "version" },
},
{
title: "应用主题",
ellipsis: true,
dataIndex: "appThemeName",
},
{
title: "应用简介",
ellipsis: true,
scopedSlots: { customRender: "summary" },
},
{
title: "应用类型",
scopedSlots: { customRender: "appType" },
},
{
title: "下发设备",
dataIndex: "downDevCount",
},
{
title: "上架/下架",
scopedSlots: { customRender: "shelves" },
},
{
title: "操作",
width: "150px",
scopedSlots: { customRender: "action" },
},
];
export default {
components: {
YSwitch,
AddApp,
CheckSite,
},
data() {
return {
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
columns,
siteId: local.getLocal("siteId"),
tableData: [], // 表格数据
loading: false,
searchVal: "", // 搜索
current: 1,
size: 10,
total: 0,
pageSizeOptions: ["10", "30", "50", "100"],
selectedRowKeys: [], // 表格勾选数据
AddVisible: false,
title: "新增应用",
siteVisible: false,
};
},
// 详情页返回不刷新数据
activated() {
if (!this.$route.meta.isBack) {
Object.assign(this.$data, this.$options.data());
this.getAppList();
} else {
this.$route.meta.isBack = false;
}
},
created() {},
methods: {
// 获取应用列表
async getAppList() {
this.loading = true;
let res = await getAppList({
page: this.current,
size: this.size,
siteId: this.siteId,
appName: `%${this.searchVal}%`,
type: 2,
});
this.loading = false;
let { data, total } = res.data.data;
if (res.data.code === 1) {
if (!data.length && this.current > 1) {
this.current -= 1;
this.getAppList();
}
this.tableData = data;
this.total = total;
}
},
// 克隆
handleClone() {
if (!this.selectedRowKeys.length) {
this.$message.warning("请先勾选应用");
return;
}
this.siteVisible = true;
},
// 新增
handleAdd() {
this.title = "新增应用";
this.$refs.AddApp.onAdd(2);
this.AddVisible = true;
},
// 搜索
onSearch() {
this.current = 1;
this.getAppList();
},
// 翻页
handleChange(cur) {
this.current = cur;
this.getAppList();
},
// 改变每页显示数量
showSizeChange(current, size) {
this.current = current;
this.size = size;
this.getAppList();
},
// 勾选表格
onSelectChange(keys) {
this.selectedRowKeys = keys;
},
// 编辑
handleEdit(row) {
this.title = "编辑应用";
this.$refs.AddApp.onEdit(row);
this.AddVisible = true;
},
// 查看
handleCheck(id) {
this.$router.push({
path: "/appmarket/appdetails",
query: {
id,
},
});
},
// 删除
handleDel(distribute, id) {
if (distribute) {
this.$confirm({
title: "拒绝删除",
content: "该应用正在使用中。",
okText: "确定",
okType: "danger",
cancelText: "取消",
centered: true,
icon: "exclamation-circle",
maskClosable: true,
onOk() {
console.log("ok");
},
onCancel() {
console.log("Cancel");
},
});
return;
}
let _this = this;
_this.$confirm({
title: "系统提示",
content: "删除不可恢复,确定要删除吗?",
okText: "确定",
okType: "danger",
cancelText: "取消",
centered: true,
icon: "exclamation-circle",
maskClosable: true,
async onOk() {
let res = await deleteApp({ id });
let { code, msg } = res.data;
if (code === 1) {
_this.$message.success(msg);
_this.getAppList();
}
},
onCancel() {
console.log("Cancel");
},
});
},
// 克隆成功
cloneSuccess() {
this.selectedRowKeys = [];
this.getAppList();
},
// 上下架
async changeShelves(row) {
let res = await saveApp(row);
let { code, msg } = res.data;
if (code === 1) {
this.$message.success(msg);
} else {
this.getAppList();
}
},
},
};
</script>
<style lang="less" scoped>
.unDelete {
color: #ff4d5075 !important;
}
</style>
\ No newline at end of file
......@@ -231,7 +231,7 @@ export default {
// 新增
handleAdd() {
this.title = "新增应用";
this.$refs.AddApp.onAdd();
this.$refs.AddApp.onAdd(1);
this.AddVisible = true;
},
// 搜索
......
......@@ -188,7 +188,7 @@ export default {
appCode: "", // 应用编码
appIconPath: "", // 应用图标
appThemeName: "", // 应用主题名称
type: 1, // 类型(1.终端应用,2.移动端应用)
type: "", // 类型(1.终端应用,2.移动端应用)
appType: 1, // 类型(1.应用程序,2.url)
shelves: 0,
fileName: "", // 文件名称
......@@ -318,9 +318,10 @@ export default {
}
},
// 新增
onAdd() {
onAdd(type) {
Object.assign(this.form, this.$options.data().form);
this.form.id && this.$delete(this.form, "id");
this.form.type = type;
},
// 编辑
onEdit(data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment