mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-06 17:09:08 +08:00
refactor(page-decoration): 用 beforeRelease 替换发布开关逻辑
- 楼层与移动端装修列表改用 before-change,避免开关被直接切换 - 唯一页面禁止关闭,已开启页面提示改开其他页 - 按接口成功/失败再决定是否切换开关
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
inline-prompt
|
||||
active-text="开"
|
||||
inactive-text="关"
|
||||
@change="releaseTemplate(row.id)"
|
||||
:before-change="() => beforeRelease(row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -200,12 +200,27 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
releaseTemplate(id) {
|
||||
API_floor.releasePageHome(id).then((res) => {
|
||||
if (res.success) {
|
||||
this.$Message.success("发布模板成功");
|
||||
this.getTemplateList();
|
||||
}
|
||||
beforeRelease(row) {
|
||||
if (row.pageShow) {
|
||||
this.$Message.warning(
|
||||
this.total === 1
|
||||
? "当前为唯一页面,无法关闭"
|
||||
: "请直接开启其他页面,当前页面会自动关闭"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
API_floor.releasePageHome(row.id).then((res) => {
|
||||
if (res && res.success) {
|
||||
this.$Message.success("发布模板成功");
|
||||
resolve(true);
|
||||
this.getTemplateList();
|
||||
} else {
|
||||
reject(new Error("release failed"));
|
||||
}
|
||||
}).catch(() => {
|
||||
reject(new Error("release failed"));
|
||||
});
|
||||
});
|
||||
},
|
||||
confirmDel(id) {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
inline-prompt
|
||||
active-text="开"
|
||||
inactive-text="关"
|
||||
@change="changeSwitch(row)"
|
||||
:before-change="() => beforeRelease(row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -107,14 +107,27 @@ export default {
|
||||
this.params.pageNumber = val;
|
||||
this.init();
|
||||
},
|
||||
changeSwitch(item) {
|
||||
this.loading = true;
|
||||
API_Other.releasePageHome(item.id).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.result) {
|
||||
this.$Message.success("发布成功");
|
||||
this.init();
|
||||
}
|
||||
beforeRelease(row) {
|
||||
if (row.pageShow) {
|
||||
this.$Message.warning(
|
||||
this.total === 1
|
||||
? "当前为唯一页面,无法关闭"
|
||||
: "请直接开启其他页面,当前页面会自动关闭"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
API_Other.releasePageHome(row.id).then((res) => {
|
||||
if (res && res.success) {
|
||||
this.$Message.success("发布成功");
|
||||
resolve(true);
|
||||
this.init();
|
||||
} else {
|
||||
reject(new Error("release failed"));
|
||||
}
|
||||
}).catch(() => {
|
||||
reject(new Error("release failed"));
|
||||
});
|
||||
});
|
||||
},
|
||||
init() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { sellerUrl, getRequest, uploadFileRequest, uploadFile, request} from "@/libs/axios";
|
||||
import { sellerUrl, getRequest, uploadFileRequest, uploadFile } from "@/libs/axios";
|
||||
|
||||
// 通过id获取子地区
|
||||
export const getChildRegion = (id) => {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
inline-prompt
|
||||
active-text="开"
|
||||
inactive-text="关"
|
||||
@change="releaseTemplate(row.id)"
|
||||
:before-change="() => beforeRelease(row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -195,12 +195,27 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
releaseTemplate(id) {
|
||||
API_floor.releasePageHome(id).then((res) => {
|
||||
if (res.success) {
|
||||
this.$Message.success("发布模板成功");
|
||||
this.getTemplateList();
|
||||
}
|
||||
beforeRelease(row) {
|
||||
if (row.pageShow) {
|
||||
this.$Message.warning(
|
||||
this.total === 1
|
||||
? "当前为唯一页面,无法关闭"
|
||||
: "请直接开启其他页面,当前页面会自动关闭"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
API_floor.releasePageHome(row.id).then((res) => {
|
||||
if (res && res.success) {
|
||||
this.$Message.success("发布模板成功");
|
||||
resolve(true);
|
||||
this.getTemplateList();
|
||||
} else {
|
||||
reject(new Error("release failed"));
|
||||
}
|
||||
}).catch(() => {
|
||||
reject(new Error("release failed"));
|
||||
});
|
||||
});
|
||||
},
|
||||
confirmDel(id) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
inline-prompt
|
||||
active-text="开"
|
||||
inactive-text="关"
|
||||
@change="changeSwitch(row)"
|
||||
:before-change="() => beforeRelease(row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -106,14 +106,27 @@ export default {
|
||||
this.params.pageNumber = val;
|
||||
this.init();
|
||||
},
|
||||
changeSwitch(item) {
|
||||
this.loading = true;
|
||||
API_Other.releasePageHome(item.id).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.result) {
|
||||
this.$Message.success("发布成功");
|
||||
this.init();
|
||||
}
|
||||
beforeRelease(row) {
|
||||
if (row.pageShow) {
|
||||
this.$Message.warning(
|
||||
this.total === 1
|
||||
? "当前为唯一页面,无法关闭"
|
||||
: "请直接开启其他页面,当前页面会自动关闭"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
API_Other.releasePageHome(row.id).then((res) => {
|
||||
if (res && res.success) {
|
||||
this.$Message.success("发布成功");
|
||||
resolve(true);
|
||||
this.init();
|
||||
} else {
|
||||
reject(new Error("release failed"));
|
||||
}
|
||||
}).catch(() => {
|
||||
reject(new Error("release failed"));
|
||||
});
|
||||
});
|
||||
},
|
||||
init() {
|
||||
|
||||
Reference in New Issue
Block a user