Commit 4253380d authored by “yiyousong”'s avatar “yiyousong”

pref:修改皮肤设置时的产品选择

parent f358660c
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<script> <script>
import { getProductList } from "@/services/surface"; import { getProductList } from "@/services/surface";
import { mapMutations } from "vuex";
export default { export default {
data() { data() {
return { return {
...@@ -35,6 +36,7 @@ export default { ...@@ -35,6 +36,7 @@ export default {
this.getProductList(); this.getProductList();
}, },
methods: { methods: {
...mapMutations("site", ["SET_curProduct"]),
// 获取产品列表 // 获取产品列表
async getProductList(search = {}) { async getProductList(search = {}) {
let res = await getProductList({ page: 1, size: -1, ...search }); let res = await getProductList({ page: 1, size: -1, ...search });
...@@ -54,9 +56,12 @@ export default { ...@@ -54,9 +56,12 @@ export default {
productId: row.id, productId: row.id,
productName: row.productName, productName: row.productName,
}; };
this.$emit("clickFacility", obj); this.SET_curProduct(obj);
}, },
}, },
beforeDestroy() {
this.SET_curProduct({});
},
}; };
</script> </script>
......
...@@ -53,12 +53,18 @@ export default { ...@@ -53,12 +53,18 @@ export default {
return { return {
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE, simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
categoryId: "", // 分类ID categoryId: "", // 分类ID
facilityInfo: {}, // 设备信息
previewList: [], // 皮肤列表 previewList: [], // 皮肤列表
}; };
}, },
computed: { computed: {
...mapState("site", ["curSkinIndex"]), ...mapState("site", ["curSkinIndex", "curProduct"]),
},
watch: {
curProduct(newVal) {
if (Object.keys(newVal).length) {
this.getSkinList({ productId: newVal.productId });
}
},
}, },
created() { created() {
// this.getSkinList(); // this.getSkinList();
...@@ -80,8 +86,8 @@ export default { ...@@ -80,8 +86,8 @@ export default {
"SET_curSkinIndex", "SET_curSkinIndex",
]), ]),
// 获取设备信息 // 获取设备信息
getFacilityInfo(info) { getcurProduct(info) {
this.facilityInfo = info; this.curProduct = info;
this.getSkinList({ productId: info.id }); this.getSkinList({ productId: info.id });
}, },
// 获取皮肤列表 // 获取皮肤列表
...@@ -90,7 +96,7 @@ export default { ...@@ -90,7 +96,7 @@ export default {
let res = await getSkinList({ let res = await getSkinList({
page: 1, page: 1,
size: -1, size: -1,
productName: this.facilityInfo.productName, productName: this.curProduct.productName,
categoryId: this.categoryId, categoryId: this.categoryId,
...search, ...search,
}); });
...@@ -114,7 +120,7 @@ export default { ...@@ -114,7 +120,7 @@ export default {
}, },
// 新增 // 新增
AddSurface() { AddSurface() {
if (this.facilityInfo.productId) { if (this.curProduct.productId) {
this.$emit("addSkin"); this.$emit("addSkin");
} else { } else {
this.$message.warning("请先选择设备"); this.$message.warning("请先选择设备");
......
<template> <template>
<div class="add-surface" v-if="show"> <div class="add-surface" v-if="show">
<a-card :bordered="false"> <a-card :bordered="false">
<span slot="title">{{ facilityInfo.productName + "皮肤" }}</span> <span slot="title">{{ curProduct.productName + "皮肤" }}</span>
<a-button slot="extra" @click="backOne">返回上一级</a-button> <a-button slot="extra" @click="backOne">返回上一级</a-button>
<div class="add-surface-preview"> <div class="add-surface-preview">
<div ref="content" class="add-surface-preview-content"> <div ref="content" class="add-surface-preview-content">
...@@ -227,7 +227,6 @@ export default { ...@@ -227,7 +227,6 @@ export default {
formLoading: false, formLoading: false,
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE, simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
accept: "image/jpeg,image/png,image/gif", // 上传类型 accept: "image/jpeg,image/png,image/gif", // 上传类型
facilityInfo: {}, // 设备信息
skinTemplate: [], // 皮肤模板列表 skinTemplate: [], // 皮肤模板列表
curSkinTemplate: undefined, //当前选择皮肤模板 curSkinTemplate: undefined, //当前选择皮肤模板
isEdit: false, // 是否编辑状态 isEdit: false, // 是否编辑状态
...@@ -267,7 +266,7 @@ export default { ...@@ -267,7 +266,7 @@ export default {
}, },
component() { component() {
let str = ""; let str = "";
switch (this.facilityInfo.productName) { switch (this.curProduct.productName) {
case "排号机": case "排号机":
str = "LandscapeMode"; str = "LandscapeMode";
break; break;
...@@ -304,7 +303,7 @@ export default { ...@@ -304,7 +303,7 @@ export default {
} }
return str; return str;
}, },
...mapState("site", ["imageResolution"]), ...mapState("site", ["imageResolution", "curProduct"]),
}, },
created() {}, created() {},
watch: { watch: {
...@@ -325,11 +324,6 @@ export default { ...@@ -325,11 +324,6 @@ export default {
this.loading = false; this.loading = false;
this.skinTemplate = []; this.skinTemplate = [];
this.curSkinTemplate = undefined; this.curSkinTemplate = undefined;
this.facilityInfo = {};
},
// 获取设备信息
getFacilityInfo(info) {
this.facilityInfo = info;
}, },
// 获取皮肤模板 // 获取皮肤模板
async getTemplateList(search = {}) { async getTemplateList(search = {}) {
...@@ -337,7 +331,7 @@ export default { ...@@ -337,7 +331,7 @@ export default {
let res = await getTemplateList({ let res = await getTemplateList({
page: 1, page: 1,
size: -1, size: -1,
productId: this.facilityInfo.productId, productId: this.curProduct.productId,
...search, ...search,
}); });
let { data } = res.data.data; let { data } = res.data.data;
...@@ -407,7 +401,6 @@ export default { ...@@ -407,7 +401,6 @@ export default {
html2canvas(conponentsId, { html2canvas(conponentsId, {
backgroundColor: null, backgroundColor: null,
useCORS: true, useCORS: true,
dpi: window.devicePixelRatio * 4, //设备像素比
width: width, width: width,
height: height, height: height,
scale: 0.9, scale: 0.9,
...@@ -429,7 +422,7 @@ export default { ...@@ -429,7 +422,7 @@ export default {
if (code === 1) { if (code === 1) {
this.formData.previewImagePath = res.data.url; this.formData.previewImagePath = res.data.url;
let result = await skinSave({ let result = await skinSave({
...this.facilityInfo, ...this.curProduct,
...this.formData, ...this.formData,
}); });
let { code, msg } = result.data; let { code, msg } = result.data;
......
...@@ -11,6 +11,7 @@ export default { ...@@ -11,6 +11,7 @@ export default {
appDict: {}, // 应用字典 appDict: {}, // 应用字典
curSkin: {}, // 当前选中预览皮肤 curSkin: {}, // 当前选中预览皮肤
curSkinIndex: 0, // 当前选中皮肤索引 curSkinIndex: 0, // 当前选中皮肤索引
curProduct: {}, // 皮肤设置当前选中产品
}, },
getters: { getters: {
SiteTree(state) { SiteTree(state) {
...@@ -33,6 +34,9 @@ export default { ...@@ -33,6 +34,9 @@ export default {
}, },
}, },
mutations: { mutations: {
SET_curProduct(state, curProduct) {
state.curProduct = curProduct;
},
SET_curSkinIndex(state, curSkinIndex) { SET_curSkinIndex(state, curSkinIndex) {
state.curSkinIndex = curSkinIndex; state.curSkinIndex = curSkinIndex;
}, },
......
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