Skip to content

Commit

Permalink
Merge pull request #153 from vipshop/develop
Browse files Browse the repository at this point in the history
v0.32.0
  • Loading branch information
wuzebin authored Jun 1, 2021
2 parents 67c20ba + 0acd657 commit 561fdef
Show file tree
Hide file tree
Showing 20 changed files with 275 additions and 47 deletions.
14 changes: 8 additions & 6 deletions docs/zh-CN/api/ams-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ ams.config({
return res;
},

// 全局默认withCredentials,请求接口是否携带cookie
withCredentials: true,
// 全局默认contentType json | form
contentType: 'json',
// 全局成功code
successCode: 0
api: {
// 全局默认withCredentials,请求接口是否携带cookie
withCredentials: true,
// 全局默认contentType json | form
contentType: 'json',
// 全局成功code
successCode: 0
}
}
})
```
2 changes: 1 addition & 1 deletion docs/zh-CN/api/getstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
注意要先引入vue element-ui的依赖

```html
<script src="https://h5rsc.vipstatic.com/ams/ams@0.7.16.js"></script>
<script src="https://h5rsc.vipstatic.com/ams/ams@0.32.0.js"></script>
```


Expand Down
2 changes: 1 addition & 1 deletion docs/zh-CN/api/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Vue.use(ams);

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

<script src="https://h5rsc.vipstatic.com/ams/ams@0.31.3.js"></script>
<script src="https://h5rsc.vipstatic.com/ams/ams@0.32.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.31.3.js"></script>
<script src="https://h5rsc.vipstatic.com/ams/ams@0.32.0.js"></script>
</head>
<body>
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@ ams.block('list-field-convert', {
options: {
operationsWidth: '120px',
'table-column': [
{
label: 'ID',
name: 'id'
},
{
label: '店铺名称',
children: [{
label: 'id',
name: 'id'
},
{
label: 'testText',
label: '店铺',
name: 'testText'
}
]
},
{
label: '店铺详情',
children: [{
label: 'testRadio',
label: '美食',
name: 'testRadio'
},
{
label: 'testTextarea',
label: '介绍',
name: 'testTextarea'
},
{
label: 'testRate',
label: '店铺评分',
name: 'testRate'
}
]
Expand All @@ -111,5 +111,12 @@ ams.block('list-field-convert', {
events: {
init: '@list',
back: '@routerGo:-1'
},
operations: {
multiSetHeader: {
slot: 'searchs',
type: 'filter',
label: '批量设置表头'
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ ams.block('list-simulate', {
testText: true
},
options: {
operationsWidth: '120px'
operationsWidth: '120px',
multipleSelect: true
},
data: {
list: Array.from(Array(100), (v, k) => ({
Expand All @@ -45,5 +46,12 @@ ams.block('list-simulate', {
},
events: {
back: '@routerGo:-1'
},
operations: {
multiSetHeader: {
slot: 'searchs',
type: 'filter',
label: '批量设置表头'
}
}
});
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.31.3",
"version": "0.32.0",
"main": "lib/ams.common.js",
"unpkg": "lib/ams.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ export const list = ams.createApiAction({
res.data.data
) {
const config = this.resource.api.list;
this.data.total = res.data.data.total;

if (typeof config === 'object' && typeof config.transform === 'function') {
this.data.list = config.transform(res.data.data.list) || [];
} else if (typeof config === 'object' && typeof config.responseDataParse === 'function') {
Expand All @@ -346,7 +348,6 @@ export const list = ams.createApiAction({
} else {
this.data.list = res.data.data.list || [];
}
this.data.total = res.data.data.total;
if (typeof this.on['list-success'] === 'function') {
this.on['list-success'](res.data);
}
Expand Down
3 changes: 3 additions & 0 deletions src/ams/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { getType, deepExtend } from '../utils';
export default function initConfig(ams) {
// 配置列表
ams.configs = {
appName: '', // ams的全局name,可以用于区分同域下的localstorage等
sentPageMars: false, // 是否发送页面埋点
sentBehaviorMars: false, // 是否发送行为埋点
consoleWarn: true,
...configs
};
Expand Down
6 changes: 3 additions & 3 deletions src/ams/configs/alias/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ export const SELECT_REMOTE = {
// 组装请求参数
const params = {
url: remoteConfig.action || remoteConfig.url,
method: method || 'GET'
method: method || 'GET',
params: {},
data: {}
};
if (query) {
if (!method || method === 'GET') {
params.params = {};
params.params[remoteConfig.queryKey] = query;
} else if (httpRequestTypeExcludeGet.indexOf(method) >= 0) {
params.data = {};
params.data[remoteConfig.queryKey] = query;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/ams/mixins/field-edit-mixin.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { on } from './computed';
import { on, tooltip } from './computed';
import { equals } from '../configs/field-get-set';

export default {
computed: {
on,
tooltip,
localValue: {
get() {
return this.field.get ? this.field.get(this.value, this.field) : this.value;
Expand Down
5 changes: 4 additions & 1 deletion src/ams/mixins/operation-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ export default {
methods: {
emit() {
ams.$prevReturn = this.context;
const allowNoSelect = this.operation.props && this.operation.props.allowNoSelect;
const block = this.$block.block;
// 兼容block-list中配置multipleSelectAffixShow: true的情况
if (
this.$block.block.type === 'list' &&
block.type === 'list' &&
this.path === 'multipleSelect' &&
!allowNoSelect &&
Array.isArray(this.context) &&
!this.context.length) {
this.$message('已选择的数据项为空');
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/block/operations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<i class="el-icon-info ams-form-label-info el-form-item__label"></i>
<div slot="content" v-html="operation.info"></div>
</el-tooltip>
<label v-if="operation.label && !/^(?:button|reset|icon|text)$/.test(operation.type)"
<label v-if="operation.label && !/^(?:button|reset|icon|text|filter)$/.test(operation.type)"
class="el-form-item__label">{{operation.label}}</label>
<div class="el-form-item__content">
<component :is="'ams-operation-' + getOpType(operation.type)"
Expand All @@ -30,7 +30,7 @@
import ams from '../../ams';
import mixins from '../../ams/mixins';
const operationTypes = ['button', 'dropdown', 'icon', 'reset', 'text']; // TODO 这里列出了部分不需要处理的operations类型
const operationTypes = ['button', 'dropdown', 'icon', 'reset', 'text', 'filter']; // TODO 这里列出了部分不需要处理的operations类型
export default {
mixins: [mixins.getShowState, mixins.getField],
props: {
Expand Down
Loading

0 comments on commit 561fdef

Please sign in to comment.