|
|
@@ -1612,12 +1612,14 @@ export default {
|
|
|
* @param {Object} param
|
|
|
* @param {Object} param.data - 模板数据
|
|
|
* @param {Array} param.content_group_row_list - 内容分组行列表
|
|
|
+ * @param {Array} param.backgroundList - 组件背景列表
|
|
|
*/
|
|
|
- loadTemplateData_CreateCanvas({ data, content_group_row_list }) {
|
|
|
+ async loadTemplateData_CreateCanvas({ data, content_group_row_list, backgroundList }) {
|
|
|
this.data = data || {
|
|
|
row_list: [],
|
|
|
};
|
|
|
this.content_group_row_list = content_group_row_list || [];
|
|
|
+ await this.insertComponentBackground(data.row_list, backgroundList, 'id');
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -1625,8 +1627,9 @@ export default {
|
|
|
* @param {Object} param
|
|
|
* @param {Object} param.row_list - 模板组件列表
|
|
|
* @param {Array} param.content_group_row_list - 内容分组行列表
|
|
|
+ * @param {Array} param.backgroundList - 组件背景列表
|
|
|
*/
|
|
|
- insertTemplateData_CreateCanvas({ row_list = [], content_group_row_list = [] }) {
|
|
|
+ async insertTemplateData_CreateCanvas({ row_list = [], content_group_row_list = [], backgroundList = [] }) {
|
|
|
let contentGroupRowList = JSON.parse(JSON.stringify(content_group_row_list));
|
|
|
|
|
|
let rowList = row_list.map((row) => {
|
|
|
@@ -1660,6 +1663,7 @@ export default {
|
|
|
if (!curId) {
|
|
|
this.data.row_list.push(...rowList);
|
|
|
this.content_group_row_list.push(...contentGroupRowList);
|
|
|
+ await this.insertComponentBackground(rowList, backgroundList);
|
|
|
return;
|
|
|
}
|
|
|
// 插入到当前选中组件后面
|
|
|
@@ -1668,6 +1672,29 @@ export default {
|
|
|
const i = Number(attrs['data-row']);
|
|
|
this.data.row_list.splice(i + 1, 0, ...rowList);
|
|
|
this.content_group_row_list.splice(i + 1, 0, ...contentGroupRowList);
|
|
|
+ await this.insertComponentBackground(rowList, backgroundList);
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 插入组件背景
|
|
|
+ * @param {Array} row_list - 行列表
|
|
|
+ * @param {Array} backgroundList - 组件背景列表
|
|
|
+ * @param {string} gridIdName - ID 属性名,默认为 'oldId'
|
|
|
+ */
|
|
|
+ async insertComponentBackground(row_list, backgroundList, gridIdName = 'oldId') {
|
|
|
+ if (!Array.isArray(row_list) || !Array.isArray(backgroundList)) return;
|
|
|
+ await this.$nextTick();
|
|
|
+ row_list.forEach((row) => {
|
|
|
+ row.col_list.forEach((col) => {
|
|
|
+ col.grid_list.forEach((grid) => {
|
|
|
+ const background = backgroundList.find((bg) => bg.component_id === grid[gridIdName]);
|
|
|
+ const bg = background?.background;
|
|
|
+
|
|
|
+ if (bg) {
|
|
|
+ this.findChildComponentByKey(`grid-${grid.id}`).background = bg;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
/**
|
|
|
* @description 复制组件
|