Skip to content

Commit

Permalink
Merge branch 'master' into hotfix_input_tip_20180327
Browse files Browse the repository at this point in the history
  • Loading branch information
ZianeCui authored Mar 29, 2018
2 parents ae09533 + 532d750 commit cfb9574
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/js/components/form/KLForm/KLFormItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ const KLFormItem = Validation.extend({
},
init() {
const parentValidator = this._parentValidator;
this.$watch('this.controls.length', (newValue, oldValue) => {
/* 处理kl-form-item下面kl-select数量变化的情况,当从没有变为有时,需要赋值 */
if (oldValue === undefined) {
return;
}
this.$watch('this.controls.length', () => {
if (parentValidator && parentValidator.initSelectorSource) {
parentValidator.initSelectorSource();
}
if (parentValidator && parentValidator.initFormItem) {
parentValidator.initFormItem();
}
});

this.$watch('required', function () {
Expand Down
5 changes: 3 additions & 2 deletions src/js/components/form/KLForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const KLForm = Validation.extend({
this.initSelectorSource();
this.initFormItem();
});

this.__reqSourceOnce = _.debounce(this.__reqSource.bind(this), 200, false);
},
initFormItem() {
const controls = this.controls;
Expand Down Expand Up @@ -85,8 +87,7 @@ const KLForm = Validation.extend({
if (!this.data.service || !this.selectors.length) {
return;
}

this.__reqSource();
this.__reqSourceOnce();
},
__getSourceKeys() {
return this.selectors.map($formitem => $formitem.data.sourceKey);
Expand Down
3 changes: 3 additions & 0 deletions src/js/components/form/KLUpload/components/FileUnit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const FileUnit = Component.extend({
url: '',
name: '',
readonly: false,
headers: {},
data: {},
});

Expand Down Expand Up @@ -61,6 +62,8 @@ const FileUnit = Component.extend({

const options = {
name: data.name || 'file',
headers: data.headers,
withCredentials: data.withCredentials,
data: data.data,
upload: {
onprogress(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const KLImagePreview = require('../../../../widget/KLImagePreview');
* url: 文件的路径
* flag: 0, 新增的文件; 1, 已经上传未被删除的文件,2,已经上传被删除的文件
* @param {string} [options.data.name] => 可选,上传的文件字段名, 默认为'file'
* @param {object} [options.data.headers] => 可选,设置上传的请求头部
* @param {object} [options.data.with-credentials=false] => 可选,支持发送 cookie 凭证信息, 默认false
* @param {boolean} [options.data.multiple] => 可选,是否支持多选, 可选值true/false,默认false单选
* @param {object} [options.data.data] => 可选,上传时附带的额外参数
* @param {boolean} [options.data.drag] => 可选,是否支持拖拽上传,可选值true/false,默认false不支持拖拽
Expand All @@ -46,6 +48,8 @@ const UploadBase = Component.extend({
_.extend(data, {
action: '',
name: 'file',
headers: {},
withCredentials: false,
multiple: false,
data: {},
drag: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
name={name}
status={fileunit.status}
readonly={readonly}
headers={headers}
withCredentials={withCredentials}
data={data}
onLoadInterceptor={onLoadInterceptor}
onErrorInterceptor={onErrorInterceptor}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
name={name}
status={fileunit.status}
readonly={readonly}
headers={headers}
withCredentials={withCredentials}
data={data}
autoUpload={autoUpload}
onLoadInterceptor={onLoadInterceptor}
Expand Down
4 changes: 4 additions & 0 deletions src/js/components/form/KLUpload/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
action={action}
name={name}
data={data}
headers={headers}
withCredentials={withCredentials}
multiple={multiple}
drag={drag}
accept={accept}
Expand Down Expand Up @@ -31,6 +33,8 @@
action={action}
name={name}
data={data}
headers={headers}
withCredentials={withCredentials}
multiple={multiple}
drag={drag}
accept={accept}
Expand Down
4 changes: 4 additions & 0 deletions src/js/components/form/KLUpload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const tpl = require('./index.html');
* url: 文件的路径
* flag: 0, 新增的文件; 1, 已经上传未被删除的文件,2,已经上传被删除的文件
* @param {string} [options.data.name=file] => 可选,上传的文件字段名, 默认为'file'
* @param {object} [options.data.headers] => 可选,设置上传的请求头部
* @param {object} [options.data.with-credentials=false] => 可选,支持发送 cookie 凭证信息, 默认false
* @param {boolean} [options.data.multiple=false] => 可选,是否支持多选, 可选值true/false,默认false单选
* @param {object} [options.data.data] => 可选,上传时附带的额外参数
* @param {boolean} [options.data.drag=false] => 可选,是否支持拖拽上传,可选值true/false,默认false不支持拖拽
Expand Down Expand Up @@ -59,6 +61,8 @@ const KLUpload = Component.extend({
action: '',
name: 'file',
data: {},
headers: {},
withCredentials: false,
multiple: false,
drag: false,
accept: '*',
Expand Down
2 changes: 2 additions & 0 deletions src/js/components/form/KLUpload/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function ajax(options) {
}
}

xhr.withCredentials = options.withCredentials;

const noop = function () {};
const onerror = options.onerror || noop;
const onDownloadLoad = options.onload || noop;
Expand Down
2 changes: 1 addition & 1 deletion src/js/util/validationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function (Component) {
this.$on('destroy', function () {
const index = $outer.controls.indexOf(this);
if (index !== -1) {
$outer.controls = $outer.controls.splice(index, 1);
$outer.controls.splice(index, 1);
}
});
}
Expand Down

0 comments on commit cfb9574

Please sign in to comment.