Skip to content

Commit

Permalink
Merge pull request #135 from vipshop/develop
Browse files Browse the repository at this point in the history
0.28.0
  • Loading branch information
wuzebin authored Dec 23, 2020
2 parents b2d2202 + b3d81a1 commit 42f09ea
Show file tree
Hide file tree
Showing 21 changed files with 642 additions and 38 deletions.
23 changes: 23 additions & 0 deletions docs/zh-CN/.vuepress/components/changelog/logs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
// 更新日志
export default [
{
version: '0.28.0',
date: '2020.12.23',
log: [
'fix: `inputnumber` 字段忽略了设置为 0 时的场景',
'feat: 新增处理上传视频中,Element UI 的 `on-error` 事件',
'feat: 将上传视频成功流程里的 this.field 调整为 this 和 transform 的一致',
'feat: `table`组件支持height配置',
]
},
{
version: '0.27.17',
date: '2020.12.17',
log: [
'fix: `video`上传的 on-error 事件无法执行清空操作',
'fix: `video`上传失败时清空选项',
'feat: `table`组件暴露border设置',
'fix: ESLint,数字类型变量不能指派给字符串类型',
'feat: `ams.request`formData 场景支持入参 Blob 格式',
'fix: 修复默认action自定义配置无传method时,传参异常问题',
'feat: `ams.request`增加responseType',
]
},
{
version: '0.27.9',
date: '2020.11.26',
Expand Down
4 changes: 2 additions & 2 deletions docs/zh-CN/api/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Vue.use(ams);
<!-- element-ui -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/lib/theme-chalk/index.css"/>
<!-- 或者使用vipshop定制UI主题 -->
<link rel="stylesheet" href="https://h5rsc.vipstatic.com/ams/theme-vipshop@0.27.9/index.css"/>
<link rel="stylesheet" href="https://h5rsc.vipstatic.com/ams/theme-vipshop@0.28.0/index.css"/>

<script src="https://unpkg.com/[email protected]/lib/index.js"></script>

<script src="https://h5rsc.vipstatic.com/ams/ams@0.27.9.js"></script>
<script src="https://h5rsc.vipstatic.com/ams/ams@0.28.0.js"></script>
```

尝试AMS的最简单的方式是使用[JSRUN上的官方入门Demo](http://jsrun.net/sehKp/edit?utm_source=website)。你可以在浏览器新标签页中打开它,跟着例子学习一些基础用法。
Expand Down
2 changes: 1 addition & 1 deletion docs/zh-CN/api/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Template: Template 模板
<script src="https://h5rsc.vipstatic.com/ams/babel-polyfill/7.4.0/polyfill.min.js"></script>
<script src="https://h5rsc.vipstatic.com/ams/[email protected]"></script>
<script src="https://h5rsc.vipstatic.com/ams/[email protected]/index.js"></script>
<script src="https://h5rsc.vipstatic.com/ams/ams@0.27.9.js"></script>
<script src="https://h5rsc.vipstatic.com/ams/ams@0.28.0.js"></script>
</head>
<body>
<script>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vue",
"element-ui"
],
"version": "0.27.9",
"version": "0.28.0",
"main": "lib/ams.common.js",
"unpkg": "lib/ams.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-ams-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ams-team/block-ams-config",
"version": "0.3.4",
"version": "0.3.5",
"description": "AMS可视化配置工具",
"author": "ams",
"main": "lib/block-ams-config.js",
Expand Down
14 changes: 14 additions & 0 deletions packages/block-ams-config/src/CONFIG_FIELD.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ export default {
}
}
},
changeConfig: {
type: 'ams-code',
label: 'changeConfig',
valueType: 'function',
info: '对字段的处理,参数field代表字段配置,context代表当前行数据',
default: function (field, context) {
if (context.id === 1) {
field.style = {
color: '#409EFF'
};
}
return field;
}
}
/**
* type
* label
Expand Down
2 changes: 1 addition & 1 deletion packages/block-chart/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ams-team/block-chart",
"version": "0.3.0",
"version": "0.4.1",
"description": "AMS图表",
"author": "ams",
"main": "lib/block-chart.js",
Expand Down
56 changes: 50 additions & 6 deletions packages/block-chart/src/theme/vipshop.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,30 @@
}
echarts.registerTheme('vipshop', {
'color': [
'#684bc5',
'#50b5ff',
'#f56c6c',
'#67c23a',
'#f7a545'
'#797EF5',
'#FF80CF',
'#9866FF',
'#DF2F91',
'#FF757E',
'#FF8F33',
'#FFC033',
'#B7D71D',
'#3EC705',
'#00E09F',
'#47CBFF',
'#33A6FF',
'#333AFF ',
'#722EFF',
'#EF38AA',
'#C31E79',
'#EC202C',
'#EB6900',
'#EBA300',
'#98B319',
'#33A404',
'#00B37F',
'#00A5E6',
'#007EE0'
],
'backgroundColor': 'rgba(0,0,0,0)',
'textStyle': {},
Expand Down Expand Up @@ -165,7 +184,32 @@
}
},
'funnel': {
color: ['#684bc5', '#866fd1', '#a493dc', '#c3b7e8', '#e1dbf3'],
color: [
'#797EF5',
'#FF80CF',
'#9866FF',
'#DF2F91',
'#FF757E',
'#FF8F33',
'#FFC033',
'#B7D71D',
'#3EC705',
'#00E09F',
'#47CBFF',
'#33A6FF',
'#333AFF ',
'#722EFF',
'#EF38AA',
'#C31E79',
'#EC202C',
'#EB6900',
'#EBA300',
'#98B319',
'#33A404',
'#00B37F',
'#00A5E6',
'#007EE0'
],
'toolbox': {
'feature': {
'dataView': {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _getSendData(config, method, prefix, arg) {
}
const sendArg = typeof config.requestDataParse === 'function' ? config.requestDataParse(arg) : arg;
options.method = config.method || method;
if (['post', 'POST'].indexOf(config.method) >= 0) {
if (['post', 'POST'].indexOf(options.method) >= 0) {
options.data = sendArg;
} else {
options.params = sendArg;
Expand Down
3 changes: 2 additions & 1 deletion src/ams/configs/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export const defaultFieldConfig = {
get,
set,
view,
equals
equals,
emptyEquel: false
},
password: {
props: {
Expand Down
13 changes: 8 additions & 5 deletions src/ams/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function initRequest(ams) {
let val = obj[key];
val = val == null ? '' : val;
if (typeof val === 'object') {
if (val instanceof window.File) {
if (val instanceof window.File || val instanceof window.Blob) {
formData.append(key, val);
} else {
formData.append(key, JSON.stringify(val));
Expand All @@ -46,6 +46,7 @@ export default function initRequest(ams) {
params, {a: 1},
withCredentials: true,
contentType: true,
responseType: '',
headers: {'X-Custom-Header': 'foobar'}
});
*/
Expand All @@ -63,7 +64,8 @@ export default function initRequest(ams) {
params,
headers = {},
withCredentials = ams.configs.withCredentials,
contentType = ams.configs.contentType
contentType = ams.configs.contentType,
responseType = ams.configs.responseType || '',
} = options;

const xhr = new XMLHttpRequest();
Expand Down Expand Up @@ -141,7 +143,7 @@ export default function initRequest(ams) {
}

} else {
reject(new Error(xhr.status));
reject(new Error(`${xhr.status}`));
}
}
};
Expand All @@ -150,6 +152,8 @@ export default function initRequest(ams) {
// withCredentials默认为true
xhr.withCredentials = withCredentials;

xhr.responseType = responseType;

xhr.send(sendData);
});
};
Expand Down Expand Up @@ -237,8 +241,7 @@ export default function initRequest(ams) {
);

} catch (e) {
// 处理完继续抛出错误使aciton中断

// 处理完继续抛出错误使 action 中断
this.hideLoading();
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
:rules="fields[fieldName].rules"
:prop="fields[fieldName].type !== 'array' && fields[fieldName].type !== 'object' ? fieldName : ''">
<component :is="`ams-field-${fields[fieldName].type}-${fields[fieldName].ctx}`"
:field="fields[fieldName]"
:field="getField(fields[fieldName], data)"
:value="data[fieldName]"
:ref="`$${fieldName}`"
:name="name"
Expand Down
26 changes: 24 additions & 2 deletions src/blocks/table/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
<ams-blocks :blocks="block.slotBlocks.tableTop" />

<el-form :model="data">
<el-table border
<el-table :border="isBorder"
:data="tableList"
@sort-change="handleSortChange"
@filter-change="handleFilterChange"
:span-method="handleSpanMethod"
v-on="on"
v-bind="block.props"
:height="height"
v-loading="loading"
highlight-current-row>

Expand Down Expand Up @@ -140,7 +141,7 @@
import mixins from '../../ams/mixins';
import { defaultListFieldWidth } from '../../ams/configs/field';
import SlotHeader from './components/SlotHeader.vue';
import { deepExtend } from '../../utils';
import { addEvent, debounce, deepExtend } from '../../utils';
export default {
components: {
Expand All @@ -155,6 +156,7 @@ export default {
options: {},
sortField: null,
sortOrder: null,
height: null,
loading: false,
tableList: [], // data.list数据处理
Expand All @@ -168,6 +170,13 @@ export default {
};
},
computed: {
isBorder() {
const props = this.block.props;
if (props && typeof props.border !== 'undefined') {
return props.border;
}
return true;
},
tableColumn() {
// option配置有多级表头
if (this.block.options && this.block.options['table-column'] && this.block.options['table-column'].length) {
Expand Down Expand Up @@ -201,6 +210,19 @@ export default {
}
},
methods: {
afterReady() {
// 屏幕自适应
if (this.block.options && this.block.options.tableHeightFit) {
this.heightFit();
// 监听滚动事件
this.events.push(addEvent(window, 'resize', debounce(() => {
this.heightFit();
}, 100)));
} else if (this.block.props && this.block.props.height) {
this.height = this.block.props.height;
}
},
// 行展开或展开子表
async handleRowClick(rowItem, rowIndex) {
Expand Down
28 changes: 21 additions & 7 deletions src/fields/video/video-edit.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<el-upload :on-remove="handleRemove"
:on-success="handleUploadSuccess"
:on-error="handleUploadError"
:before-upload="beforeUpload"
:file-list="localValue"
v-on="on"
:style="field.style"
v-bind="field.props">
v-bind="field.props"
ref="videoUploder">
<el-button :size="field.props['size']"
:disabled="field.props['disabled']"
type="primary">{{ field.props && field.props['button-label'] || '点击上传'}}</el-button>
Expand Down Expand Up @@ -35,13 +37,12 @@ export default {
}
const props = this.field.props || {};
if (typeof props['before-upload'] === 'function') {
await props['before-upload'](file);
await props['before-upload'](file, this.field);
}
resolve();
});
},
handleUploadSuccess(res, file) {
console.log('handleUploadSuccess', res, file);
const props = this.field.props || {};
// todo: 预览、上传进度
let successCode;
Expand All @@ -56,18 +57,31 @@ export default {
this.localValue = this.field.get(res.data[successUrlKey] || res.data, this.field);
}
if (typeof props['on-success'] === 'function') {
props['on-success'](res, file);
props['on-success'](res, file, this);
}
} else if (typeof props['on-error'] === 'function') {
props['on-error'](res, file);
this.handleRemove();
props['on-error'](res, file, this);
} else {
this.$message.error(`${res.msg}(${res.code})`);
this.handleRemove();
}
},
handleUploadError(res, file, fileList) {
const { props = {}} = this.field;
if (typeof props['on-error'] === 'function') {
props['on-error'](res, file, fileList, this);
} else {
this.$message.error(`${res.message}(${res.status})`);
}
},
handleRemove() {
// 清空预览url
// 变更数据
// 清空数据
this.localValue = [];
// 清空已选下拉列表
// @see {@link https://element.eleme.cn/#/zh-CN/component/upload#methods | Element UI Upload 上传组件}
this.$refs.videoUploder.clearFiles();
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import icon from './operations/icon';
import field from './operations/field';
import dropdown from './operations/dropdown';
// 版本号
ams.version = '0.27.9';
ams.version = '0.28.0';
// 挂载到ams上
ams.mixins = mixins;
ams.utils = utils;
Expand Down
290 changes: 283 additions & 7 deletions src/theme-default/fonts/iconfont.css

Large diffs are not rendered by default.

Binary file modified src/theme-default/fonts/iconfont.eot
Binary file not shown.
Loading

0 comments on commit 42f09ea

Please sign in to comment.