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

feat: 添加应用数据克隆

parent 4884f72a
......@@ -199,7 +199,7 @@ export default {
<style>
.editor {
line-height: normal !important;
height: 90% !important;
/* height: 90% !important; */
}
.SizeTiShi {
font-size: 12px;
......
......@@ -91,6 +91,9 @@
<!-- 操作 -->
<template slot="action" slot-scope="text">
<a-space size="middle">
<span class="primary pointer" @click="handleCloneAppData(text)"
>克隆数据</span
>
<span class="primary pointer" @click="handleEdit(text)">编辑</span>
<span class="primary pointer" @click="handleCheck(text.id)"
>查看</span
......@@ -127,6 +130,8 @@
:appList="selectedAppList"
@edit="cloneSuccess"
></ChangeThem>
<!-- 克隆应用数据 -->
<CloneData ref="CloneData" :show.sync="show"></CloneData>
</div>
</template>
......@@ -135,6 +140,7 @@ import YSwitch from "../../../../components/yswitch/YSwitch.vue";
import AddApp from "../modal/AddApp.vue";
import CheckSite from "../modal/CheckSite.vue";
import ChangeThem from "../modal/ChangeThem.vue";
import CloneData from "../modal/CloneData.vue";
import {
getAppList,
deleteApp,
......@@ -189,7 +195,7 @@ const columns = [
},
{
title: "操作",
width: "150px",
width: "240px",
scopedSlots: { customRender: "action" },
},
];
......@@ -199,6 +205,7 @@ export default {
AddApp,
CheckSite,
ChangeThem,
CloneData,
},
data() {
return {
......@@ -218,6 +225,7 @@ export default {
title: "新增应用",
siteVisible: false,
themVisible: false,
show: false,
dict: {}, // 字典
categoryList: [], // 应用分类列表
};
......@@ -398,6 +406,11 @@ export default {
this.selectedRowKeys = [];
this.getAppList();
},
// 克隆数据
handleCloneAppData(row) {
this.$refs.CloneData.onAdd(row);
this.show = true;
},
// 上下架
async changeShelves(row) {
let res = await saveApp(row);
......
......@@ -144,7 +144,9 @@
>
<a-space size="middle">
<a-button @click="resetForm"> 重置 </a-button>
<a-button type="primary" @click="onSubmit"> 确定 </a-button>
<a-button type="primary" @click="onSubmit" :loading="loading">
确定
</a-button>
</a-space>
</div>
</a-drawer>
......@@ -269,6 +271,7 @@ export default {
this.$refs.form.resetFields();
this.fileList = [];
this.iconFileList = [];
this.loading = false;
this.Visible = false;
},
resetForm() {
......@@ -280,6 +283,7 @@ export default {
onSubmit() {
this.$refs.form.validate(async (valid) => {
if (valid) {
this.loading = true;
let res = await saveApp(this.form);
let { code, msg } = res.data;
if (code === 1) {
......@@ -287,6 +291,7 @@ export default {
this.$emit("success");
this.onClose();
}
this.loading = false;
}
});
},
......
......@@ -595,6 +595,7 @@ export default {
}
.content {
align-items: flex-start !important;
padding-bottom: 30px;
.content-box {
min-height: 500px;
display: flex;
......
<template>
<div>
<a-modal v-model="Visible" title="克隆应用数据">
<div class="hint">
提示:目标应用中的数据字段需与克隆应用的数据字段保持一致。
</div>
<a-form-model
ref="form"
:model="form"
:label-col="{
span: 5,
}"
:wrapper-col="{
span: 19,
}"
:rules="rules"
>
<a-form-model-item label="克隆应用">
<a-input :value="sourceApp.appName" disabled></a-input>
</a-form-model-item>
<a-form-model-item label="目标应用" prop="targetAppId">
<a-cascader
:options="options"
:fieldNames="fieldNames"
allowClear
placeholder="请选择目标应用"
v-model="form.targetAppId"
/>
</a-form-model-item>
<a-form-model-item label="重置目标数据" prop="targetDelete">
<a-radio-group v-model="form.targetDelete">
<a-radio :value="0"></a-radio>
<a-radio :value="1"></a-radio>
</a-radio-group>
<a-tooltip>
<template slot="title">
为避免重复克隆造成数据重复,建议选择“是”。
</template>
<a-icon class="question-icon" type="question-circle" />
</a-tooltip>
</a-form-model-item>
</a-form-model>
<div slot="footer">
<a-button @click="handleCancel">取消</a-button>
<a-button type="primary" @click="handleOk" :loading="loading"
>确定</a-button
>
</div>
</a-modal>
</div>
</template>
<script>
import { cloneAppData, getAppList } from "@/services/market";
import local from "@/utils/local";
export default {
props: {
show: {
required: true,
type: Boolean,
default: false,
},
},
data() {
let checkTargetAppId = (rule, value, callback) => {
if (!value || value.length != 2) {
callback(new Error("请选择目标应用"));
} else {
callback();
}
};
return {
siteId: local.getLocal("siteId"),
loading: false,
sourceApp: {},
form: {
sourceAppId: "",
targetAppId: [],
targetDelete: 1,
},
fieldNames: {
label: "appName",
value: "id",
children: "children",
},
options: [
{
id: -1,
appName: "终端应用",
children: [],
},
{
id: -2,
appName: "移动端应用",
children: [],
},
],
rules: {
targetAppId: [
{
required: true,
validator: checkTargetAppId,
trigger: "change",
},
],
},
};
},
computed: {
Visible: {
get() {
return this.show;
},
set(val) {
this.$emit("update:show", val);
},
},
},
methods: {
// 获取应用列表
async getAppList() {
let res = await getAppList({
page: 1,
size: -1,
siteId: this.siteId,
});
if (res.data.code == 1) {
let { data } = res.data.data;
data = data.filter((v) => v.id != this.sourceApp.id);
this.options[0].children = data.filter((v) => v.type == 1);
this.options[1].children = data.filter((v) => v.type == 2);
}
},
onAdd(row) {
this.sourceApp = row;
this.form.sourceAppId = row.id;
this.getAppList();
},
async handleOk() {
this.$refs.form.validate(async (valid) => {
if (valid) {
this.loading = true;
let res = await cloneAppData({
...this.form,
targetAppId: this.form.targetAppId[1],
});
let { code, msg } = res.data;
if (code === 1) {
this.$message.success(msg);
this.$emit("success");
this.handleCancel();
}
this.loading = false;
}
});
},
// 关闭
handleCancel() {
this.$refs.form.resetFields();
this.loading = false;
this.Visible = false;
},
},
};
</script>
<style lang="less" scoped>
.hint {
margin-bottom: 15px;
color: #999;
}
.question-icon {
font-size: 16px;
cursor: pointer;
color: #999;
}
</style>
......@@ -289,6 +289,7 @@ module.exports = {
delete: `${BASE_URL}/base/app/delete`,
distribute: `${BASE_URL}/base/app/appDistribute`,
clone: `${BASE_URL}/base/app/cloneAppsBySites`,
cloneData: `${BASE_URL}/base/app//cloneAppBySameSite`,
common: `${BASE_URL}/base/app/appCommonDistribute`,
},
// 应用数据
......
......@@ -39,6 +39,10 @@ export async function deleteApp(data) {
export async function cloneApp(data) {
return request(App.clone, METHOD.POST, data);
}
// 克隆应用数据
export async function cloneAppData(data) {
return request(App.cloneData, METHOD.POST, data);
}
// 部署应用
export async function deployApp(data) {
return request(App.distribute, METHOD.POST, 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