Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mounted() {
// 如果已经注册过则不再注册
ams.resource('resource-material', materialResource);
this.type = ams.utils.getQueryString('type');
// console.log(data);
ams.block('market-detail', block);
this.init = true;
}
}
filterConfig(){
const config = ams.utils.deepExtend({}, this.templates[this.templateIndex].config)
if (this.templateIndex === 0) {
// 管理后台场景
if (!this.configFormOptions.search) { // 搜索
delete config.blocks.routerBlock.blocks.listBlock1.operations.name
delete config.blocks.routerBlock.blocks.listBlock1.operations.list
}
if (!this.configFormOptions.editItem) {// 编辑操作
delete config.blocks.routerBlock.blocks.listBlock1.operations.editItem
}
if (!this.configFormOptions.removeItem) {// 删除操作
delete config.blocks.routerBlock.blocks.listBlock1.operations.removeItem
}
if (!this.configFormOptions.addItem) { // 新增操作
delete config.blocks.routerBlock.blocks.listBlock1.operations.addItem
}
for(let key in config.resources.demoResource.fields) {
deepExtend(destination, source) {
// 数据深拷贝,与ams.utils.deepExtend不同在于数组的处理,数组直接覆盖
const type = ams.utils.getType(source);
if (type === 'object' || type === 'array') {
for (let property in source) {
if (source.hasOwnProperty(property)) {
let old = destination[property];
let obj = source[property];
let oldType = ams.utils.getType(old);
let objType = ams.utils.getType(obj);
if (objType === 'object') {
const target = oldType === 'object' ? old : {};
destination[property] = this.deepExtend(target, obj);
} else if (objType === 'array') {
// const target = oldType === 'array' ? old : [];
destination[property] = obj;
} else {
destination[property] = source[property];
}
}
}
}
return destination;
},
async setChartOption() {
initBlockArea() {
let _this = this;
// 配置项表单
ams.block('$ams-config-edit', {
type: 'form',
resource: {
fields: ams.utils.deepExtend({}, this.config)
},
ctx: 'edit',
blocks: {
baseTitle: {
type: 'title',
options: {
title: '基础设置'
},
slot: 'top'
},
fieldTitle: {
type: 'title',
options: {
title: '更多设置'
},
slot: 'field:rules'
mounted() {
let templateId = ams.utils.getQueryString('templateId');
console.log('templateData', templateId, templateData)
for(let i = 0; i < templateData.length; i++){
if (templateId == templateData[i].templateId) {
let config = (new Function(`return ${templateData[i].templateContent}`))();
console.log(config);
ams.block('templatePreview', config);
this.ready = true;
return;
}
}
}
}
parseTime(time) {
return ams.utils.parseTime(time, 'yyyy-MM-dd HH:mm')
},
newCompute(time) {
parseTime(time) {
return ams.utils.parseTime(time, 'yyyy-MM-dd HH:mm')
},
newCompute(time) {
created() {
const autoResizeRender = ams.configs && ams.configs['block_chart'] && ams.configs['block_chart']['resize-render'];
if (autoResizeRender !== false) {
const { addEvent, debounce } = ams.utils;
addEvent(window, 'resize', debounce(() => {
this.chartDom && this.chartDom.resize();
}, 100));
}
},
updated() {