@whitesev/pops 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +2192 -2186
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +2192 -2186
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2192 -2186
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +2192 -2186
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +2192 -2186
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +2192 -2186
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +1 -1
- package/dist/types/src/components/panel/PanelHandleContentDetails.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/panel/PanelHandleContentDetails.ts +2472 -2451
- package/src/components/panel/index.ts +2 -2
package/dist/index.amd.js
CHANGED
|
@@ -7268,2310 +7268,2315 @@ define((function () { 'use strict';
|
|
|
7268
7268
|
},
|
|
7269
7269
|
};
|
|
7270
7270
|
|
|
7271
|
-
const PanelHandleContentDetails = {
|
|
7272
|
-
|
|
7273
|
-
* 左侧的ul容器
|
|
7274
|
-
*/
|
|
7275
|
-
asideULElement: null,
|
|
7276
|
-
/**
|
|
7277
|
-
* 右侧主内容的顶部文字ul容器
|
|
7278
|
-
*/
|
|
7279
|
-
sectionContainerHeaderULElement: null,
|
|
7280
|
-
/**
|
|
7281
|
-
* 右侧主内容的ul容器
|
|
7282
|
-
*/
|
|
7283
|
-
sectionContainerULElement: null,
|
|
7284
|
-
$el: {
|
|
7285
|
-
$content: null,
|
|
7286
|
-
$contentAside: null,
|
|
7287
|
-
$contentSectionContainer: null,
|
|
7288
|
-
},
|
|
7289
|
-
init(details) {
|
|
7290
|
-
// @ts-ignore
|
|
7291
|
-
this.$el = null;
|
|
7292
|
-
this.$el = {
|
|
7293
|
-
...details.$el,
|
|
7294
|
-
};
|
|
7295
|
-
this.asideULElement =
|
|
7296
|
-
this.$el.$contentAside.querySelector("ul");
|
|
7297
|
-
this.sectionContainerHeaderULElement =
|
|
7298
|
-
this.$el.$contentSectionContainer.querySelectorAll("ul")[0];
|
|
7299
|
-
this.sectionContainerULElement =
|
|
7300
|
-
this.$el.$contentSectionContainer.querySelectorAll("ul")[1];
|
|
7271
|
+
const PanelHandleContentDetails = () => {
|
|
7272
|
+
return {
|
|
7301
7273
|
/**
|
|
7302
|
-
*
|
|
7274
|
+
* 左侧的ul容器
|
|
7303
7275
|
*/
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7276
|
+
asideULElement: null,
|
|
7277
|
+
/**
|
|
7278
|
+
* 右侧主内容的顶部文字ul容器
|
|
7279
|
+
*/
|
|
7280
|
+
sectionContainerHeaderULElement: null,
|
|
7281
|
+
/**
|
|
7282
|
+
* 右侧主内容的ul容器
|
|
7283
|
+
*/
|
|
7284
|
+
sectionContainerULElement: null,
|
|
7285
|
+
$el: {
|
|
7286
|
+
$content: null,
|
|
7287
|
+
$contentAside: null,
|
|
7288
|
+
$contentSectionContainer: null,
|
|
7289
|
+
},
|
|
7290
|
+
init(details) {
|
|
7291
|
+
// @ts-ignore
|
|
7292
|
+
this.$el = null;
|
|
7293
|
+
this.$el = {
|
|
7294
|
+
...details.$el,
|
|
7295
|
+
};
|
|
7296
|
+
this.asideULElement =
|
|
7297
|
+
this.$el.$contentAside.querySelector("ul");
|
|
7298
|
+
this.sectionContainerHeaderULElement =
|
|
7299
|
+
this.$el.$contentSectionContainer.querySelectorAll("ul")[0];
|
|
7300
|
+
this.sectionContainerULElement =
|
|
7301
|
+
this.$el.$contentSectionContainer.querySelectorAll("ul")[1];
|
|
7302
|
+
/**
|
|
7303
|
+
* 默认点击的左侧容器
|
|
7304
|
+
*/
|
|
7305
|
+
let asideDefaultItemElement = null;
|
|
7306
|
+
let isScrollToDefaultView = false;
|
|
7307
|
+
details.config.content.forEach((asideItem) => {
|
|
7308
|
+
let asideLiElement = this.getAsideItem(asideItem);
|
|
7309
|
+
this.setAsideItemClickEvent(asideLiElement, asideItem);
|
|
7310
|
+
this.asideULElement.appendChild(asideLiElement);
|
|
7311
|
+
if (asideDefaultItemElement == null) {
|
|
7312
|
+
let flag = false;
|
|
7313
|
+
if (typeof asideItem.isDefault === "function") {
|
|
7314
|
+
flag = Boolean(asideItem.isDefault());
|
|
7315
|
+
}
|
|
7316
|
+
else {
|
|
7317
|
+
flag = Boolean(asideItem.isDefault);
|
|
7318
|
+
}
|
|
7319
|
+
if (flag) {
|
|
7320
|
+
asideDefaultItemElement = asideLiElement;
|
|
7321
|
+
isScrollToDefaultView = Boolean(asideItem.scrollToDefaultView);
|
|
7322
|
+
}
|
|
7317
7323
|
}
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7324
|
+
});
|
|
7325
|
+
/* 点击左侧列表 */
|
|
7326
|
+
if (asideDefaultItemElement == null &&
|
|
7327
|
+
this.asideULElement.children.length) {
|
|
7328
|
+
/* 默认第一个 */
|
|
7329
|
+
asideDefaultItemElement = this.asideULElement
|
|
7330
|
+
.children[0];
|
|
7331
|
+
}
|
|
7332
|
+
if (asideDefaultItemElement) {
|
|
7333
|
+
/* 点击选择的那一项 */
|
|
7334
|
+
asideDefaultItemElement.click();
|
|
7335
|
+
if (isScrollToDefaultView) {
|
|
7336
|
+
asideDefaultItemElement?.scrollIntoView();
|
|
7321
7337
|
}
|
|
7322
7338
|
}
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
if (asideDefaultItemElement == null &&
|
|
7326
|
-
this.asideULElement.children.length) {
|
|
7327
|
-
/* 默认第一个 */
|
|
7328
|
-
asideDefaultItemElement = this.asideULElement
|
|
7329
|
-
.children[0];
|
|
7330
|
-
}
|
|
7331
|
-
if (asideDefaultItemElement) {
|
|
7332
|
-
/* 点击选择的那一项 */
|
|
7333
|
-
asideDefaultItemElement.click();
|
|
7334
|
-
if (isScrollToDefaultView) {
|
|
7335
|
-
asideDefaultItemElement?.scrollIntoView();
|
|
7339
|
+
else {
|
|
7340
|
+
console.error("pops.panel:左侧容器没有项");
|
|
7336
7341
|
}
|
|
7337
|
-
}
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
this.$el.$contentAside
|
|
7357
|
-
.querySelectorAll(".pops-is-visited")
|
|
7358
|
-
.forEach((element) => {
|
|
7359
|
-
popsDOMUtils.removeClassName(element, "pops-is-visited");
|
|
7360
|
-
});
|
|
7361
|
-
},
|
|
7362
|
-
/**
|
|
7363
|
-
* 设置左侧容器已访问记录
|
|
7364
|
-
* @param element
|
|
7365
|
-
*/
|
|
7366
|
-
setAsideItemIsVisited(element) {
|
|
7367
|
-
popsDOMUtils.addClassName(element, "pops-is-visited");
|
|
7368
|
-
},
|
|
7369
|
-
/**
|
|
7370
|
-
* 为元素添加自定义属性
|
|
7371
|
-
* @param element
|
|
7372
|
-
* @param attributes
|
|
7373
|
-
*/
|
|
7374
|
-
addElementAttributes(element, attributes) {
|
|
7375
|
-
if (attributes == null) {
|
|
7376
|
-
return;
|
|
7377
|
-
}
|
|
7378
|
-
if (Array.isArray(attributes)) {
|
|
7379
|
-
attributes.forEach((attrObject) => {
|
|
7380
|
-
this.addElementAttributes(element, attrObject);
|
|
7342
|
+
},
|
|
7343
|
+
/**
|
|
7344
|
+
* 清空container容器的元素
|
|
7345
|
+
*/
|
|
7346
|
+
clearContainer() {
|
|
7347
|
+
this.sectionContainerHeaderULElement.innerHTML = "";
|
|
7348
|
+
this.sectionContainerULElement.innerHTML = "";
|
|
7349
|
+
this.$el.$content
|
|
7350
|
+
?.querySelectorAll("section.pops-panel-deepMenu-container")
|
|
7351
|
+
.forEach((ele) => ele.remove());
|
|
7352
|
+
},
|
|
7353
|
+
/**
|
|
7354
|
+
* 清空左侧容器已访问记录
|
|
7355
|
+
*/
|
|
7356
|
+
clearAsideItemIsVisited() {
|
|
7357
|
+
this.$el.$contentAside
|
|
7358
|
+
.querySelectorAll(".pops-is-visited")
|
|
7359
|
+
.forEach((element) => {
|
|
7360
|
+
popsDOMUtils.removeClassName(element, "pops-is-visited");
|
|
7381
7361
|
});
|
|
7382
|
-
}
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7362
|
+
},
|
|
7363
|
+
/**
|
|
7364
|
+
* 设置左侧容器已访问记录
|
|
7365
|
+
* @param element
|
|
7366
|
+
*/
|
|
7367
|
+
setAsideItemIsVisited(element) {
|
|
7368
|
+
popsDOMUtils.addClassName(element, "pops-is-visited");
|
|
7369
|
+
},
|
|
7370
|
+
/**
|
|
7371
|
+
* 为元素添加自定义属性
|
|
7372
|
+
* @param element
|
|
7373
|
+
* @param attributes
|
|
7374
|
+
*/
|
|
7375
|
+
addElementAttributes(element, attributes) {
|
|
7376
|
+
if (attributes == null) {
|
|
7377
|
+
return;
|
|
7378
|
+
}
|
|
7379
|
+
if (Array.isArray(attributes)) {
|
|
7380
|
+
attributes.forEach((attrObject) => {
|
|
7381
|
+
this.addElementAttributes(element, attrObject);
|
|
7382
|
+
});
|
|
7383
|
+
}
|
|
7384
|
+
else {
|
|
7385
|
+
Object.keys(attributes).forEach((attributeName) => {
|
|
7386
|
+
element.setAttribute(attributeName, attributes[attributeName]);
|
|
7387
|
+
});
|
|
7388
|
+
}
|
|
7389
|
+
},
|
|
7390
|
+
/**
|
|
7391
|
+
* 为元素设置(自定义)属性
|
|
7392
|
+
* @param element
|
|
7393
|
+
* @param props
|
|
7394
|
+
*/
|
|
7395
|
+
setElementProps(element, props) {
|
|
7396
|
+
if (props == null) {
|
|
7397
|
+
return;
|
|
7398
|
+
}
|
|
7399
|
+
Object.keys(props).forEach((propName) => {
|
|
7400
|
+
element[propName] = props[propName];
|
|
7386
7401
|
});
|
|
7387
|
-
}
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
}
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
const PopsPanelSwitch = {
|
|
7446
|
-
[Symbol.toStringTag]: "PopsPanelSwitch",
|
|
7447
|
-
$data: {
|
|
7448
|
-
value: Boolean(formConfig.getValue()),
|
|
7449
|
-
},
|
|
7450
|
-
$ele: {
|
|
7451
|
-
switch: liElement.querySelector(".pops-panel-switch"),
|
|
7452
|
-
input: liElement.querySelector(".pops-panel-switch__input"),
|
|
7453
|
-
core: liElement.querySelector(".pops-panel-switch__core"),
|
|
7454
|
-
},
|
|
7455
|
-
init() {
|
|
7456
|
-
this.setStatus(this.$data.value);
|
|
7457
|
-
if (formConfig.disabled) {
|
|
7458
|
-
this.disable();
|
|
7459
|
-
}
|
|
7460
|
-
this.setClickEvent();
|
|
7461
|
-
},
|
|
7462
|
-
setClickEvent() {
|
|
7463
|
-
let that = this;
|
|
7464
|
-
popsDOMUtils.on(this.$ele.core, "click", void 0, function (event) {
|
|
7465
|
-
if (that.$ele.input.disabled ||
|
|
7466
|
-
that.$ele.switch.hasAttribute("data-disabled")) {
|
|
7467
|
-
return;
|
|
7402
|
+
},
|
|
7403
|
+
/**
|
|
7404
|
+
* 获取左侧容器元素<li>
|
|
7405
|
+
* @param asideConfig
|
|
7406
|
+
*/
|
|
7407
|
+
getAsideItem(asideConfig) {
|
|
7408
|
+
let liElement = document.createElement("li");
|
|
7409
|
+
liElement.id = asideConfig.id;
|
|
7410
|
+
liElement["__forms__"] = asideConfig.forms;
|
|
7411
|
+
liElement.innerHTML = asideConfig.title;
|
|
7412
|
+
this.addElementAttributes(liElement, asideConfig.attributes);
|
|
7413
|
+
this.setElementProps(liElement, asideConfig.props);
|
|
7414
|
+
return liElement;
|
|
7415
|
+
},
|
|
7416
|
+
/**
|
|
7417
|
+
* 获取中间容器的元素<li>
|
|
7418
|
+
* type ==> switch
|
|
7419
|
+
* @param formConfig
|
|
7420
|
+
*/
|
|
7421
|
+
getSectionContainerItem_switch(formConfig) {
|
|
7422
|
+
let liElement = document.createElement("li");
|
|
7423
|
+
liElement["__formConfig__"] = formConfig;
|
|
7424
|
+
if (formConfig.className) {
|
|
7425
|
+
liElement.className = formConfig.className;
|
|
7426
|
+
}
|
|
7427
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
7428
|
+
this.setElementProps(liElement, formConfig.props);
|
|
7429
|
+
/* 左边底部的描述的文字 */
|
|
7430
|
+
let leftDescriptionText = "";
|
|
7431
|
+
if (Boolean(formConfig.description)) {
|
|
7432
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
7433
|
+
}
|
|
7434
|
+
liElement.innerHTML = /*html*/ `
|
|
7435
|
+
<div class="pops-panel-item-left-text">
|
|
7436
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
7437
|
+
${leftDescriptionText}
|
|
7438
|
+
</div>
|
|
7439
|
+
<div class="pops-panel-switch">
|
|
7440
|
+
<input class="pops-panel-switch__input" type="checkbox">
|
|
7441
|
+
<span class="pops-panel-switch__core">
|
|
7442
|
+
<div class="pops-panel-switch__action">
|
|
7443
|
+
</div>
|
|
7444
|
+
</span>
|
|
7445
|
+
</div>`;
|
|
7446
|
+
const PopsPanelSwitch = {
|
|
7447
|
+
[Symbol.toStringTag]: "PopsPanelSwitch",
|
|
7448
|
+
$data: {
|
|
7449
|
+
value: Boolean(formConfig.getValue()),
|
|
7450
|
+
},
|
|
7451
|
+
$ele: {
|
|
7452
|
+
switch: liElement.querySelector(".pops-panel-switch"),
|
|
7453
|
+
input: liElement.querySelector(".pops-panel-switch__input"),
|
|
7454
|
+
core: liElement.querySelector(".pops-panel-switch__core"),
|
|
7455
|
+
},
|
|
7456
|
+
init() {
|
|
7457
|
+
this.setStatus(this.$data.value);
|
|
7458
|
+
if (formConfig.disabled) {
|
|
7459
|
+
this.disable();
|
|
7468
7460
|
}
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7461
|
+
this.setClickEvent();
|
|
7462
|
+
},
|
|
7463
|
+
setClickEvent() {
|
|
7464
|
+
let that = this;
|
|
7465
|
+
popsDOMUtils.on(this.$ele.core, "click", void 0, function (event) {
|
|
7466
|
+
if (that.$ele.input.disabled ||
|
|
7467
|
+
that.$ele.switch.hasAttribute("data-disabled")) {
|
|
7468
|
+
return;
|
|
7469
|
+
}
|
|
7470
|
+
that.$data.value = that.getStatus();
|
|
7471
|
+
that.setStatus(that.$data.value);
|
|
7472
|
+
if (typeof formConfig.callback === "function") {
|
|
7473
|
+
formConfig.callback(event, that.$data.value);
|
|
7474
|
+
}
|
|
7475
|
+
});
|
|
7476
|
+
},
|
|
7477
|
+
/**
|
|
7478
|
+
* 设置状态
|
|
7479
|
+
*/
|
|
7480
|
+
setStatus(isChecked = false) {
|
|
7481
|
+
isChecked = Boolean(isChecked);
|
|
7482
|
+
this.$ele.input.checked = isChecked;
|
|
7483
|
+
if (isChecked) {
|
|
7484
|
+
popsDOMUtils.addClassName(this.$ele.switch, "pops-panel-switch-is-checked");
|
|
7473
7485
|
}
|
|
7474
|
-
|
|
7475
|
-
|
|
7486
|
+
else {
|
|
7487
|
+
popsDOMUtils.removeClassName(this.$ele.switch, "pops-panel-switch-is-checked");
|
|
7488
|
+
}
|
|
7489
|
+
},
|
|
7490
|
+
/**
|
|
7491
|
+
* 根据className来获取逆反值
|
|
7492
|
+
*/
|
|
7493
|
+
getStatus() {
|
|
7494
|
+
let checkedValue = false;
|
|
7495
|
+
if (!popsDOMUtils.containsClassName(this.$ele.switch, "pops-panel-switch-is-checked")) {
|
|
7496
|
+
checkedValue = true;
|
|
7497
|
+
}
|
|
7498
|
+
return checkedValue;
|
|
7499
|
+
},
|
|
7500
|
+
/**
|
|
7501
|
+
* 禁用复选框
|
|
7502
|
+
*/
|
|
7503
|
+
disable() {
|
|
7504
|
+
this.$ele.input.disabled = true;
|
|
7505
|
+
this.$ele.switch.setAttribute("data-disabled", "true");
|
|
7506
|
+
},
|
|
7507
|
+
/**
|
|
7508
|
+
* 启用复选框
|
|
7509
|
+
*/
|
|
7510
|
+
notDisable() {
|
|
7511
|
+
this.$ele.input.disabled = false;
|
|
7512
|
+
this.$ele.switch.removeAttribute("data-disabled");
|
|
7513
|
+
},
|
|
7514
|
+
};
|
|
7515
|
+
PopsPanelSwitch.init();
|
|
7516
|
+
liElement["data-switch"] = PopsPanelSwitch;
|
|
7517
|
+
return liElement;
|
|
7518
|
+
},
|
|
7519
|
+
/**
|
|
7520
|
+
* 获取中间容器的元素<li>
|
|
7521
|
+
* type ==> slider
|
|
7522
|
+
* @param formConfig
|
|
7523
|
+
*/
|
|
7524
|
+
getSectionContainerItem_slider(formConfig) {
|
|
7525
|
+
let liElement = document.createElement("li");
|
|
7526
|
+
liElement["__formConfig__"] = formConfig;
|
|
7527
|
+
if (formConfig.className) {
|
|
7528
|
+
liElement.className = formConfig.className;
|
|
7529
|
+
}
|
|
7530
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
7531
|
+
this.setElementProps(liElement, formConfig.props);
|
|
7532
|
+
/* 左边底部的描述的文字 */
|
|
7533
|
+
let leftDescriptionText = "";
|
|
7534
|
+
if (Boolean(formConfig.description)) {
|
|
7535
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
7536
|
+
}
|
|
7537
|
+
liElement.innerHTML = `
|
|
7538
|
+
<div class="pops-panel-item-left-text">
|
|
7539
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
7540
|
+
${leftDescriptionText}
|
|
7541
|
+
</div>
|
|
7542
|
+
<div class="pops-panel-slider">
|
|
7543
|
+
<input type="range" min="${formConfig.min}" max="${formConfig.max}">
|
|
7544
|
+
</div>`;
|
|
7545
|
+
let rangeInputElement = liElement.querySelector(".pops-panel-slider input[type=range]");
|
|
7546
|
+
if (formConfig.step) {
|
|
7547
|
+
rangeInputElement.setAttribute("step", formConfig.step.toString());
|
|
7548
|
+
}
|
|
7549
|
+
rangeInputElement.value = formConfig.getValue().toString();
|
|
7476
7550
|
/**
|
|
7477
|
-
*
|
|
7551
|
+
* 获取提示的内容
|
|
7552
|
+
* @param value
|
|
7478
7553
|
*/
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
if (isChecked) {
|
|
7483
|
-
popsDOMUtils.addClassName(this.$ele.switch, "pops-panel-switch-is-checked");
|
|
7554
|
+
let getToolTipContent = function (value) {
|
|
7555
|
+
if (typeof formConfig.getToolTipContent === "function") {
|
|
7556
|
+
return formConfig.getToolTipContent(value);
|
|
7484
7557
|
}
|
|
7485
7558
|
else {
|
|
7486
|
-
|
|
7559
|
+
return value;
|
|
7487
7560
|
}
|
|
7488
|
-
}
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7561
|
+
};
|
|
7562
|
+
let tooltip = pops.tooltip({
|
|
7563
|
+
target: rangeInputElement.parentElement,
|
|
7564
|
+
content: getToolTipContent(rangeInputElement.value),
|
|
7565
|
+
zIndex: 1000000,
|
|
7566
|
+
className: "github-tooltip",
|
|
7567
|
+
showBeforeCallBack() {
|
|
7568
|
+
tooltip.toolTipNode.querySelector("div").innerText =
|
|
7569
|
+
getToolTipContent(rangeInputElement.value);
|
|
7570
|
+
},
|
|
7571
|
+
alwaysShow: false,
|
|
7572
|
+
only: false,
|
|
7573
|
+
position: "top",
|
|
7574
|
+
arrowDistance: 10,
|
|
7575
|
+
});
|
|
7576
|
+
popsDOMUtils.on(rangeInputElement, ["input", "propertychange"], void 0, function (event) {
|
|
7577
|
+
tooltip.toolTipNode.querySelector("div").innerText =
|
|
7578
|
+
getToolTipContent(rangeInputElement.value);
|
|
7579
|
+
if (typeof formConfig.callback === "function") {
|
|
7580
|
+
formConfig.callback(event, event.target.value);
|
|
7496
7581
|
}
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
* 禁用复选框
|
|
7501
|
-
*/
|
|
7502
|
-
disable() {
|
|
7503
|
-
this.$ele.input.disabled = true;
|
|
7504
|
-
this.$ele.switch.setAttribute("data-disabled", "true");
|
|
7505
|
-
},
|
|
7506
|
-
/**
|
|
7507
|
-
* 启用复选框
|
|
7508
|
-
*/
|
|
7509
|
-
notDisable() {
|
|
7510
|
-
this.$ele.input.disabled = false;
|
|
7511
|
-
this.$ele.switch.removeAttribute("data-disabled");
|
|
7512
|
-
},
|
|
7513
|
-
};
|
|
7514
|
-
PopsPanelSwitch.init();
|
|
7515
|
-
liElement["data-switch"] = PopsPanelSwitch;
|
|
7516
|
-
return liElement;
|
|
7517
|
-
},
|
|
7518
|
-
/**
|
|
7519
|
-
* 获取中间容器的元素<li>
|
|
7520
|
-
* type ==> slider
|
|
7521
|
-
* @param formConfig
|
|
7522
|
-
*/
|
|
7523
|
-
getSectionContainerItem_slider(formConfig) {
|
|
7524
|
-
let liElement = document.createElement("li");
|
|
7525
|
-
liElement["__formConfig__"] = formConfig;
|
|
7526
|
-
if (formConfig.className) {
|
|
7527
|
-
liElement.className = formConfig.className;
|
|
7528
|
-
}
|
|
7529
|
-
this.addElementAttributes(liElement, formConfig.attributes);
|
|
7530
|
-
this.setElementProps(liElement, formConfig.props);
|
|
7531
|
-
/* 左边底部的描述的文字 */
|
|
7532
|
-
let leftDescriptionText = "";
|
|
7533
|
-
if (Boolean(formConfig.description)) {
|
|
7534
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
7535
|
-
}
|
|
7536
|
-
liElement.innerHTML = `
|
|
7537
|
-
<div class="pops-panel-item-left-text">
|
|
7538
|
-
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
7539
|
-
${leftDescriptionText}
|
|
7540
|
-
</div>
|
|
7541
|
-
<div class="pops-panel-slider">
|
|
7542
|
-
<input type="range" min="${formConfig.min}" max="${formConfig.max}">
|
|
7543
|
-
</div>`;
|
|
7544
|
-
let rangeInputElement = liElement.querySelector(".pops-panel-slider input[type=range]");
|
|
7545
|
-
if (formConfig.step) {
|
|
7546
|
-
rangeInputElement.setAttribute("step", formConfig.step.toString());
|
|
7547
|
-
}
|
|
7548
|
-
rangeInputElement.value = formConfig.getValue().toString();
|
|
7582
|
+
});
|
|
7583
|
+
return liElement;
|
|
7584
|
+
},
|
|
7549
7585
|
/**
|
|
7550
|
-
*
|
|
7551
|
-
*
|
|
7586
|
+
* 获取中间容器的元素<li>
|
|
7587
|
+
* type ==> slider
|
|
7588
|
+
* @param formConfig
|
|
7552
7589
|
*/
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
return value;
|
|
7590
|
+
getSectionContainerItem_slider_new(formConfig) {
|
|
7591
|
+
let liElement = document.createElement("li");
|
|
7592
|
+
liElement["__formConfig__"] = formConfig;
|
|
7593
|
+
if (formConfig.className) {
|
|
7594
|
+
liElement.className = formConfig.className;
|
|
7559
7595
|
}
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
showBeforeCallBack() {
|
|
7567
|
-
tooltip.toolTipNode.querySelector("div").innerText = getToolTipContent(rangeInputElement.value);
|
|
7568
|
-
},
|
|
7569
|
-
alwaysShow: false,
|
|
7570
|
-
only: false,
|
|
7571
|
-
position: "top",
|
|
7572
|
-
arrowDistance: 10,
|
|
7573
|
-
});
|
|
7574
|
-
popsDOMUtils.on(rangeInputElement, ["input", "propertychange"], void 0, function (event) {
|
|
7575
|
-
tooltip.toolTipNode.querySelector("div").innerText = getToolTipContent(rangeInputElement.value);
|
|
7576
|
-
if (typeof formConfig.callback === "function") {
|
|
7577
|
-
formConfig.callback(event, event.target.value);
|
|
7596
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
7597
|
+
this.setElementProps(liElement, formConfig.props);
|
|
7598
|
+
/* 左边底部的描述的文字 */
|
|
7599
|
+
let leftDescriptionText = "";
|
|
7600
|
+
if (Boolean(formConfig.description)) {
|
|
7601
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
7578
7602
|
}
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
this.setElementProps(liElement, formConfig.props);
|
|
7595
|
-
/* 左边底部的描述的文字 */
|
|
7596
|
-
let leftDescriptionText = "";
|
|
7597
|
-
if (Boolean(formConfig.description)) {
|
|
7598
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
7599
|
-
}
|
|
7600
|
-
liElement.innerHTML = /*html*/ `
|
|
7601
|
-
<div class="pops-panel-item-left-text" style="flex: 1;">
|
|
7602
|
-
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
7603
|
-
${leftDescriptionText}
|
|
7604
|
-
</div>
|
|
7605
|
-
<div class="pops-slider pops-slider-width">
|
|
7606
|
-
<div class="pops-slider__runway">
|
|
7607
|
-
<div class="pops-slider__bar" style="width: 0%; left: 0%"></div>
|
|
7608
|
-
<div class="pops-slider__button-wrapper" style="left: 0%">
|
|
7609
|
-
<div class="pops-slider__button"></div>
|
|
7610
|
-
</div>
|
|
7611
|
-
</div>
|
|
7612
|
-
</div>`;
|
|
7613
|
-
const PopsPanelSlider = {
|
|
7614
|
-
[Symbol.toStringTag]: "PopsPanelSlider",
|
|
7615
|
-
/**
|
|
7616
|
-
* 值
|
|
7617
|
-
*/
|
|
7618
|
-
value: formConfig.getValue(),
|
|
7619
|
-
/**
|
|
7620
|
-
* 最小值
|
|
7621
|
-
*/
|
|
7622
|
-
min: formConfig.min,
|
|
7623
|
-
/**
|
|
7624
|
-
* 最大值
|
|
7625
|
-
*/
|
|
7626
|
-
max: formConfig.max,
|
|
7627
|
-
/**
|
|
7628
|
-
* 间隔
|
|
7629
|
-
*/
|
|
7630
|
-
step: formConfig.step || 1,
|
|
7631
|
-
$data: {
|
|
7603
|
+
liElement.innerHTML = /*html*/ `
|
|
7604
|
+
<div class="pops-panel-item-left-text" style="flex: 1;">
|
|
7605
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
7606
|
+
${leftDescriptionText}
|
|
7607
|
+
</div>
|
|
7608
|
+
<div class="pops-slider pops-slider-width">
|
|
7609
|
+
<div class="pops-slider__runway">
|
|
7610
|
+
<div class="pops-slider__bar" style="width: 0%; left: 0%"></div>
|
|
7611
|
+
<div class="pops-slider__button-wrapper" style="left: 0%">
|
|
7612
|
+
<div class="pops-slider__button"></div>
|
|
7613
|
+
</div>
|
|
7614
|
+
</div>
|
|
7615
|
+
</div>`;
|
|
7616
|
+
const PopsPanelSlider = {
|
|
7617
|
+
[Symbol.toStringTag]: "PopsPanelSlider",
|
|
7632
7618
|
/**
|
|
7633
|
-
*
|
|
7619
|
+
* 值
|
|
7634
7620
|
*/
|
|
7635
|
-
|
|
7621
|
+
value: formConfig.getValue(),
|
|
7636
7622
|
/**
|
|
7637
|
-
*
|
|
7623
|
+
* 最小值
|
|
7638
7624
|
*/
|
|
7639
|
-
|
|
7625
|
+
min: formConfig.min,
|
|
7640
7626
|
/**
|
|
7641
|
-
*
|
|
7627
|
+
* 最大值
|
|
7642
7628
|
*/
|
|
7643
|
-
|
|
7629
|
+
max: formConfig.max,
|
|
7644
7630
|
/**
|
|
7645
|
-
*
|
|
7631
|
+
* 间隔
|
|
7646
7632
|
*/
|
|
7647
|
-
|
|
7633
|
+
step: formConfig.step || 1,
|
|
7634
|
+
$data: {
|
|
7635
|
+
/**
|
|
7636
|
+
* 是否正在移动
|
|
7637
|
+
*/
|
|
7638
|
+
isMove: false,
|
|
7639
|
+
/**
|
|
7640
|
+
* 是否已初始化已拖拽的距离
|
|
7641
|
+
*/
|
|
7642
|
+
isInitDragPosition: false,
|
|
7643
|
+
/**
|
|
7644
|
+
* 是否正在检测是否停止拖拽
|
|
7645
|
+
*/
|
|
7646
|
+
isCheckingStopDragMove: false,
|
|
7647
|
+
/**
|
|
7648
|
+
* 总宽度(px)
|
|
7649
|
+
*/
|
|
7650
|
+
totalWidth: 0,
|
|
7651
|
+
/**
|
|
7652
|
+
* 每一块的间隔(px)
|
|
7653
|
+
*/
|
|
7654
|
+
stepPx: 0,
|
|
7655
|
+
/**
|
|
7656
|
+
* 已拖拽的距离(px)
|
|
7657
|
+
*/
|
|
7658
|
+
dragWidth: 0,
|
|
7659
|
+
/**
|
|
7660
|
+
* 已拖拽的百分比
|
|
7661
|
+
*/
|
|
7662
|
+
dragPercent: 0,
|
|
7663
|
+
/**
|
|
7664
|
+
* 每一次块的信息
|
|
7665
|
+
* 例如:当最小值是2,最大值是10,step为2
|
|
7666
|
+
* 那么生成[2,4,6,8,10] 共计5个
|
|
7667
|
+
* 又获取到当前滑块总长度是200px
|
|
7668
|
+
* 那么生成映射
|
|
7669
|
+
* 2 => 0px~40px
|
|
7670
|
+
* 4 => 40px~80px
|
|
7671
|
+
* 6 => 80px~120px
|
|
7672
|
+
* 8 => 120px~160px
|
|
7673
|
+
* 10 => 160px~200px
|
|
7674
|
+
*/
|
|
7675
|
+
stepBlockMap: new Map(),
|
|
7676
|
+
},
|
|
7677
|
+
$ele: {
|
|
7678
|
+
slider: liElement.querySelector(".pops-slider"),
|
|
7679
|
+
runAway: liElement.querySelector(".pops-slider__runway"),
|
|
7680
|
+
bar: liElement.querySelector(".pops-slider__bar"),
|
|
7681
|
+
buttonWrapper: liElement.querySelector(".pops-slider__button-wrapper"),
|
|
7682
|
+
button: liElement.querySelector(".pops-slider__button"),
|
|
7683
|
+
tooltip: null,
|
|
7684
|
+
},
|
|
7685
|
+
$interval: {
|
|
7686
|
+
isCheck: false,
|
|
7687
|
+
},
|
|
7688
|
+
$tooltip: null,
|
|
7689
|
+
init() {
|
|
7690
|
+
this.initEleData();
|
|
7691
|
+
this.setToolTipEvent();
|
|
7692
|
+
this.setPanEvent();
|
|
7693
|
+
this.setRunAwayClickEvent();
|
|
7694
|
+
this.intervalInit();
|
|
7695
|
+
if (formConfig.disabled) {
|
|
7696
|
+
this.disableDrag();
|
|
7697
|
+
}
|
|
7698
|
+
},
|
|
7648
7699
|
/**
|
|
7649
|
-
*
|
|
7700
|
+
* 10s内循环获取slider的宽度等信息
|
|
7701
|
+
* 获取到了就可以初始化left的值
|
|
7702
|
+
* @param {number} [checkStepTime=200] 每次检测的间隔时间
|
|
7703
|
+
* @param {number} [maxTime=10000] 最大的检测时间
|
|
7650
7704
|
*/
|
|
7651
|
-
|
|
7705
|
+
intervalInit(checkStepTime = 200, maxTime = 10000) {
|
|
7706
|
+
if (this.$interval.isCheck) {
|
|
7707
|
+
return;
|
|
7708
|
+
}
|
|
7709
|
+
this.$interval.isCheck = true;
|
|
7710
|
+
let isSuccess = false;
|
|
7711
|
+
let oldTotalWidth = this.$data.totalWidth;
|
|
7712
|
+
let timer = void 0;
|
|
7713
|
+
let interval = setInterval(() => {
|
|
7714
|
+
if (isSuccess) {
|
|
7715
|
+
this.$interval.isCheck = false;
|
|
7716
|
+
clearTimeout(timer);
|
|
7717
|
+
clearInterval(interval);
|
|
7718
|
+
}
|
|
7719
|
+
else {
|
|
7720
|
+
this.initTotalWidth();
|
|
7721
|
+
if (this.$data.totalWidth !== 0) {
|
|
7722
|
+
isSuccess = true;
|
|
7723
|
+
if (this.$data.totalWidth !== oldTotalWidth) {
|
|
7724
|
+
/* slider的总宽度改变了 */
|
|
7725
|
+
if (PopsMathFloatUtils.isFloat(this.step)) {
|
|
7726
|
+
this.initFloatStepMap();
|
|
7727
|
+
}
|
|
7728
|
+
else {
|
|
7729
|
+
this.initStepMap();
|
|
7730
|
+
}
|
|
7731
|
+
this.initSliderPosition();
|
|
7732
|
+
}
|
|
7733
|
+
}
|
|
7734
|
+
}
|
|
7735
|
+
}, checkStepTime);
|
|
7736
|
+
/* 最长检测时间是10s */
|
|
7737
|
+
timer = setTimeout(() => {
|
|
7738
|
+
clearInterval(interval);
|
|
7739
|
+
}, maxTime);
|
|
7740
|
+
},
|
|
7652
7741
|
/**
|
|
7653
|
-
*
|
|
7742
|
+
* 把数据添加到元素上
|
|
7654
7743
|
*/
|
|
7655
|
-
|
|
7744
|
+
initEleData() {
|
|
7745
|
+
this.$ele.slider.setAttribute("data-min", this.min.toString());
|
|
7746
|
+
this.$ele.slider.setAttribute("data-max", this.max.toString());
|
|
7747
|
+
this.$ele.slider.setAttribute("data-value", this.value.toString());
|
|
7748
|
+
this.$ele.slider.setAttribute("data-step", this.step.toString());
|
|
7749
|
+
this.$ele.slider["data-min"] = this.min;
|
|
7750
|
+
this.$ele.slider["data-max"] = this.max;
|
|
7751
|
+
this.$ele.slider["data-value"] = this.value;
|
|
7752
|
+
this.$ele.slider["data-step"] = this.step;
|
|
7753
|
+
},
|
|
7656
7754
|
/**
|
|
7657
|
-
*
|
|
7755
|
+
* 初始化滑块的总长度的数据(px)
|
|
7658
7756
|
*/
|
|
7659
|
-
|
|
7757
|
+
initTotalWidth() {
|
|
7758
|
+
this.$data.totalWidth = popsDOMUtils.width(this.$ele.runAway);
|
|
7759
|
+
},
|
|
7660
7760
|
/**
|
|
7661
|
-
*
|
|
7662
|
-
* 例如:当最小值是2,最大值是10,step为2
|
|
7663
|
-
* 那么生成[2,4,6,8,10] 共计5个
|
|
7664
|
-
* 又获取到当前滑块总长度是200px
|
|
7665
|
-
* 那么生成映射
|
|
7666
|
-
* 2 => 0px~40px
|
|
7667
|
-
* 4 => 40px~80px
|
|
7668
|
-
* 6 => 80px~120px
|
|
7669
|
-
* 8 => 120px~160px
|
|
7670
|
-
* 10 => 160px~200px
|
|
7761
|
+
* 初始化每一个块的具体数据信息
|
|
7671
7762
|
*/
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
let interval = setInterval(() => {
|
|
7711
|
-
if (isSuccess) {
|
|
7712
|
-
this.$interval.isCheck = false;
|
|
7713
|
-
clearTimeout(timer);
|
|
7714
|
-
clearInterval(interval);
|
|
7763
|
+
initStepMap() {
|
|
7764
|
+
let index = 0;
|
|
7765
|
+
// 计算出份数
|
|
7766
|
+
let blockNums = (this.max - this.min) / this.step;
|
|
7767
|
+
// 计算出每一份占据的px
|
|
7768
|
+
this.$data.stepPx = this.$data.totalWidth / blockNums;
|
|
7769
|
+
let widthPx = 0;
|
|
7770
|
+
for (let stepValue = this.min; stepValue <= this.max; stepValue += this.step) {
|
|
7771
|
+
let value = this.formatValue(stepValue);
|
|
7772
|
+
let info = {};
|
|
7773
|
+
if (value === this.min) {
|
|
7774
|
+
/* 起始 */
|
|
7775
|
+
info = {
|
|
7776
|
+
value: value,
|
|
7777
|
+
px: 0,
|
|
7778
|
+
pxLeft: 0,
|
|
7779
|
+
pxRight: this.$data.stepPx / 2,
|
|
7780
|
+
percent: 0,
|
|
7781
|
+
};
|
|
7782
|
+
}
|
|
7783
|
+
else {
|
|
7784
|
+
info = {
|
|
7785
|
+
value: value,
|
|
7786
|
+
px: widthPx,
|
|
7787
|
+
pxLeft: widthPx - this.$data.stepPx / 2,
|
|
7788
|
+
pxRight: widthPx + this.$data.stepPx / 2,
|
|
7789
|
+
percent: widthPx / this.$data.totalWidth,
|
|
7790
|
+
};
|
|
7791
|
+
//if (value === this.max) {
|
|
7792
|
+
// info["pxLeft"] = this.$data.stepBlockMap.get(
|
|
7793
|
+
// index - 1
|
|
7794
|
+
// ).pxRight;
|
|
7795
|
+
// info["pxRight"] = this.$data.totalWidth;
|
|
7796
|
+
//}
|
|
7797
|
+
}
|
|
7798
|
+
this.$data.stepBlockMap.set(index, info);
|
|
7799
|
+
index++;
|
|
7800
|
+
widthPx += this.$data.stepPx;
|
|
7715
7801
|
}
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7802
|
+
},
|
|
7803
|
+
/**
|
|
7804
|
+
* 初始化每一个块的具体数据信息(浮点)
|
|
7805
|
+
*/
|
|
7806
|
+
initFloatStepMap() {
|
|
7807
|
+
let index = 0;
|
|
7808
|
+
// 计算出份数
|
|
7809
|
+
let blockNums = (this.max - this.min) / this.step;
|
|
7810
|
+
// 计算出每一份占据的px
|
|
7811
|
+
this.$data.stepPx = this.$data.totalWidth / blockNums;
|
|
7812
|
+
let widthPx = 0;
|
|
7813
|
+
for (let stepValue = this.min; stepValue <= this.max; stepValue = PopsMathFloatUtils.add(stepValue, this.step)) {
|
|
7814
|
+
let value = this.formatValue(stepValue);
|
|
7815
|
+
let info = {};
|
|
7816
|
+
if (value === this.min) {
|
|
7817
|
+
/* 起始 */
|
|
7818
|
+
info = {
|
|
7819
|
+
value: value,
|
|
7820
|
+
px: 0,
|
|
7821
|
+
pxLeft: 0,
|
|
7822
|
+
pxRight: this.$data.stepPx / 2,
|
|
7823
|
+
percent: 0,
|
|
7824
|
+
};
|
|
7825
|
+
}
|
|
7826
|
+
else {
|
|
7827
|
+
info = {
|
|
7828
|
+
value: value,
|
|
7829
|
+
px: widthPx,
|
|
7830
|
+
pxLeft: widthPx - this.$data.stepPx / 2,
|
|
7831
|
+
pxRight: widthPx + this.$data.stepPx / 2,
|
|
7832
|
+
percent: widthPx / this.$data.totalWidth,
|
|
7833
|
+
};
|
|
7834
|
+
//if (value === this.max) {
|
|
7835
|
+
// info["pxLeft"] = this.$data.stepBlockMap.get(
|
|
7836
|
+
// index - 1
|
|
7837
|
+
// ).pxRight;
|
|
7838
|
+
// info["pxRight"] = this.$data.totalWidth;
|
|
7839
|
+
//}
|
|
7730
7840
|
}
|
|
7841
|
+
this.$data.stepBlockMap.set(index, info);
|
|
7842
|
+
index++;
|
|
7843
|
+
widthPx += this.$data.stepPx;
|
|
7731
7844
|
}
|
|
7732
|
-
},
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
this.$ele.slider["data-min"] = this.min;
|
|
7747
|
-
this.$ele.slider["data-max"] = this.max;
|
|
7748
|
-
this.$ele.slider["data-value"] = this.value;
|
|
7749
|
-
this.$ele.slider["data-step"] = this.step;
|
|
7750
|
-
},
|
|
7751
|
-
/**
|
|
7752
|
-
* 初始化滑块的总长度的数据(px)
|
|
7753
|
-
*/
|
|
7754
|
-
initTotalWidth() {
|
|
7755
|
-
this.$data.totalWidth = popsDOMUtils.width(this.$ele.runAway);
|
|
7756
|
-
},
|
|
7757
|
-
/**
|
|
7758
|
-
* 初始化每一个块的具体数据信息
|
|
7759
|
-
*/
|
|
7760
|
-
initStepMap() {
|
|
7761
|
-
let index = 0;
|
|
7762
|
-
// 计算出份数
|
|
7763
|
-
let blockNums = (this.max - this.min) / this.step;
|
|
7764
|
-
// 计算出每一份占据的px
|
|
7765
|
-
this.$data.stepPx = this.$data.totalWidth / blockNums;
|
|
7766
|
-
let widthPx = 0;
|
|
7767
|
-
for (let stepValue = this.min; stepValue <= this.max; stepValue += this.step) {
|
|
7768
|
-
let value = this.formatValue(stepValue);
|
|
7769
|
-
let info = {};
|
|
7770
|
-
if (value === this.min) {
|
|
7771
|
-
/* 起始 */
|
|
7772
|
-
info = {
|
|
7773
|
-
value: value,
|
|
7774
|
-
px: 0,
|
|
7775
|
-
pxLeft: 0,
|
|
7776
|
-
pxRight: this.$data.stepPx / 2,
|
|
7777
|
-
percent: 0,
|
|
7778
|
-
};
|
|
7845
|
+
},
|
|
7846
|
+
/**
|
|
7847
|
+
* 初始化slider的默认起始left的百分比值
|
|
7848
|
+
*/
|
|
7849
|
+
initSliderPosition() {
|
|
7850
|
+
/* 设置起始默认style的left值 */
|
|
7851
|
+
let percent = 0;
|
|
7852
|
+
for (const [, stepBlockInfo] of this.$data.stepBlockMap.entries()) {
|
|
7853
|
+
/* 判断值是否和区域内的值相等 */
|
|
7854
|
+
if (stepBlockInfo.value == this.value) {
|
|
7855
|
+
percent = stepBlockInfo.percent;
|
|
7856
|
+
this.$data.dragWidth = stepBlockInfo.px;
|
|
7857
|
+
break;
|
|
7858
|
+
}
|
|
7779
7859
|
}
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7860
|
+
percent = this.formatValue(percent * 100);
|
|
7861
|
+
this.setSliderPosition(percent);
|
|
7862
|
+
},
|
|
7863
|
+
/**
|
|
7864
|
+
* 判断数字是否是浮点数
|
|
7865
|
+
* @param num
|
|
7866
|
+
* @returns
|
|
7867
|
+
*/
|
|
7868
|
+
isFloat(num) {
|
|
7869
|
+
return Number(num) === num && num % 1 !== 0;
|
|
7870
|
+
},
|
|
7871
|
+
/**
|
|
7872
|
+
* 值改变的回调
|
|
7873
|
+
* @param event
|
|
7874
|
+
* @param value
|
|
7875
|
+
*/
|
|
7876
|
+
valueChangeCallBack(event, value) {
|
|
7877
|
+
if (typeof formConfig.callback === "function") {
|
|
7878
|
+
formConfig.callback(event, value);
|
|
7794
7879
|
}
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
// 计算出每一份占据的px
|
|
7808
|
-
this.$data.stepPx = this.$data.totalWidth / blockNums;
|
|
7809
|
-
let widthPx = 0;
|
|
7810
|
-
for (let stepValue = this.min; stepValue <= this.max; stepValue = PopsMathFloatUtils.add(stepValue, this.step)) {
|
|
7811
|
-
let value = this.formatValue(stepValue);
|
|
7812
|
-
let info = {};
|
|
7813
|
-
if (value === this.min) {
|
|
7814
|
-
/* 起始 */
|
|
7815
|
-
info = {
|
|
7816
|
-
value: value,
|
|
7817
|
-
px: 0,
|
|
7818
|
-
pxLeft: 0,
|
|
7819
|
-
pxRight: this.$data.stepPx / 2,
|
|
7820
|
-
percent: 0,
|
|
7821
|
-
};
|
|
7880
|
+
},
|
|
7881
|
+
/**
|
|
7882
|
+
* 根据拖拽距离获取滑块应该在的区间和值
|
|
7883
|
+
*/
|
|
7884
|
+
getDragInfo(dragX) {
|
|
7885
|
+
let result = this.$data.stepBlockMap.get(0);
|
|
7886
|
+
for (const [, stepBlockInfo] of this.$data.stepBlockMap.entries()) {
|
|
7887
|
+
if (stepBlockInfo.pxLeft <= dragX &&
|
|
7888
|
+
dragX < stepBlockInfo.pxRight) {
|
|
7889
|
+
result = stepBlockInfo;
|
|
7890
|
+
break;
|
|
7891
|
+
}
|
|
7822
7892
|
}
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7893
|
+
return result;
|
|
7894
|
+
},
|
|
7895
|
+
/**
|
|
7896
|
+
* 获取滑块的当前脱拖拽占据的百分比
|
|
7897
|
+
* @param {number} dragWidth
|
|
7898
|
+
*/
|
|
7899
|
+
getSliderPositonPercent(dragWidth) {
|
|
7900
|
+
return dragWidth / this.$data.totalWidth;
|
|
7901
|
+
},
|
|
7902
|
+
/**
|
|
7903
|
+
* 根据step格式化value
|
|
7904
|
+
* @param num
|
|
7905
|
+
*/
|
|
7906
|
+
formatValue(num) {
|
|
7907
|
+
if (PopsMathFloatUtils.isFloat(this.step)) {
|
|
7908
|
+
num = parseFloat(num.toFixed(2));
|
|
7837
7909
|
}
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
widthPx += this.$data.stepPx;
|
|
7841
|
-
}
|
|
7842
|
-
},
|
|
7843
|
-
/**
|
|
7844
|
-
* 初始化slider的默认起始left的百分比值
|
|
7845
|
-
*/
|
|
7846
|
-
initSliderPosition() {
|
|
7847
|
-
/* 设置起始默认style的left值 */
|
|
7848
|
-
let percent = 0;
|
|
7849
|
-
for (const [, stepBlockInfo] of this.$data.stepBlockMap.entries()) {
|
|
7850
|
-
/* 判断值是否和区域内的值相等 */
|
|
7851
|
-
if (stepBlockInfo.value == this.value) {
|
|
7852
|
-
percent = stepBlockInfo.percent;
|
|
7853
|
-
this.$data.dragWidth = stepBlockInfo.px;
|
|
7854
|
-
break;
|
|
7910
|
+
else {
|
|
7911
|
+
num = parseInt(num.toString());
|
|
7855
7912
|
}
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
isFloat(num) {
|
|
7866
|
-
return Number(num) === num && num % 1 !== 0;
|
|
7867
|
-
},
|
|
7868
|
-
/**
|
|
7869
|
-
* 值改变的回调
|
|
7870
|
-
* @param event
|
|
7871
|
-
* @param value
|
|
7872
|
-
*/
|
|
7873
|
-
valueChangeCallBack(event, value) {
|
|
7874
|
-
if (typeof formConfig.callback === "function") {
|
|
7875
|
-
formConfig.callback(event, value);
|
|
7876
|
-
}
|
|
7877
|
-
},
|
|
7878
|
-
/**
|
|
7879
|
-
* 根据拖拽距离获取滑块应该在的区间和值
|
|
7880
|
-
*/
|
|
7881
|
-
getDragInfo(dragX) {
|
|
7882
|
-
let result = this.$data.stepBlockMap.get(0);
|
|
7883
|
-
for (const [, stepBlockInfo] of this.$data.stepBlockMap.entries()) {
|
|
7884
|
-
if (stepBlockInfo.pxLeft <= dragX && dragX < stepBlockInfo.pxRight) {
|
|
7885
|
-
result = stepBlockInfo;
|
|
7886
|
-
break;
|
|
7913
|
+
return num;
|
|
7914
|
+
},
|
|
7915
|
+
/**
|
|
7916
|
+
* 设置滑块的位置偏移(left)
|
|
7917
|
+
* @param percent 百分比
|
|
7918
|
+
*/
|
|
7919
|
+
setSliderPosition(percent) {
|
|
7920
|
+
if (parseInt(percent.toString()) === 1) {
|
|
7921
|
+
percent = 1;
|
|
7887
7922
|
}
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
},
|
|
7891
|
-
/**
|
|
7892
|
-
* 获取滑块的当前脱拖拽占据的百分比
|
|
7893
|
-
* @param {number} dragWidth
|
|
7894
|
-
*/
|
|
7895
|
-
getSliderPositonPercent(dragWidth) {
|
|
7896
|
-
return dragWidth / this.$data.totalWidth;
|
|
7897
|
-
},
|
|
7898
|
-
/**
|
|
7899
|
-
* 根据step格式化value
|
|
7900
|
-
* @param num
|
|
7901
|
-
*/
|
|
7902
|
-
formatValue(num) {
|
|
7903
|
-
if (PopsMathFloatUtils.isFloat(this.step)) {
|
|
7904
|
-
num = parseFloat(num.toFixed(2));
|
|
7905
|
-
}
|
|
7906
|
-
else {
|
|
7907
|
-
num = parseInt(num.toString());
|
|
7908
|
-
}
|
|
7909
|
-
return num;
|
|
7910
|
-
},
|
|
7911
|
-
/**
|
|
7912
|
-
* 设置滑块的位置偏移(left)
|
|
7913
|
-
* @param percent 百分比
|
|
7914
|
-
*/
|
|
7915
|
-
setSliderPosition(percent) {
|
|
7916
|
-
if (parseInt(percent.toString()) === 1) {
|
|
7917
|
-
percent = 1;
|
|
7918
|
-
}
|
|
7919
|
-
if (percent > 1) {
|
|
7920
|
-
percent = percent / 100;
|
|
7921
|
-
}
|
|
7922
|
-
/* 滑块按钮的偏移 */
|
|
7923
|
-
this.$ele.buttonWrapper.style.left = `${percent * 100}%`;
|
|
7924
|
-
/* 滑块进度的宽度 */
|
|
7925
|
-
this.$ele.bar.style.width = `${percent * 100}%`;
|
|
7926
|
-
},
|
|
7927
|
-
/**
|
|
7928
|
-
* 禁止拖拽
|
|
7929
|
-
*/
|
|
7930
|
-
disableDrag() {
|
|
7931
|
-
this.$ele.runAway.classList.add("pops-slider-is-disabled");
|
|
7932
|
-
},
|
|
7933
|
-
/**
|
|
7934
|
-
* 允许拖拽
|
|
7935
|
-
*/
|
|
7936
|
-
allowDrag() {
|
|
7937
|
-
this.$ele.runAway.classList.remove("pops-slider-is-disabled");
|
|
7938
|
-
},
|
|
7939
|
-
/**
|
|
7940
|
-
* 判断当前滑块是否被禁用
|
|
7941
|
-
*/
|
|
7942
|
-
isDisabledDrag() {
|
|
7943
|
-
return this.$ele.runAway.classList.contains("pops-slider-is-disabled");
|
|
7944
|
-
},
|
|
7945
|
-
/**
|
|
7946
|
-
* 设置进度条点击定位的事件
|
|
7947
|
-
*/
|
|
7948
|
-
setRunAwayClickEvent() {
|
|
7949
|
-
popsDOMUtils.on(this.$ele.runAway, "click", void 0, (event) => {
|
|
7950
|
-
if (event.target !== this.$ele.runAway &&
|
|
7951
|
-
event.target !== this.$ele.bar) {
|
|
7952
|
-
return;
|
|
7923
|
+
if (percent > 1) {
|
|
7924
|
+
percent = percent / 100;
|
|
7953
7925
|
}
|
|
7954
|
-
|
|
7955
|
-
this.
|
|
7956
|
-
|
|
7957
|
-
this.
|
|
7958
|
-
},
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7926
|
+
/* 滑块按钮的偏移 */
|
|
7927
|
+
this.$ele.buttonWrapper.style.left = `${percent * 100}%`;
|
|
7928
|
+
/* 滑块进度的宽度 */
|
|
7929
|
+
this.$ele.bar.style.width = `${percent * 100}%`;
|
|
7930
|
+
},
|
|
7931
|
+
/**
|
|
7932
|
+
* 禁止拖拽
|
|
7933
|
+
*/
|
|
7934
|
+
disableDrag() {
|
|
7935
|
+
this.$ele.runAway.classList.add("pops-slider-is-disabled");
|
|
7936
|
+
},
|
|
7937
|
+
/**
|
|
7938
|
+
* 允许拖拽
|
|
7939
|
+
*/
|
|
7940
|
+
allowDrag() {
|
|
7941
|
+
this.$ele.runAway.classList.remove("pops-slider-is-disabled");
|
|
7942
|
+
},
|
|
7943
|
+
/**
|
|
7944
|
+
* 判断当前滑块是否被禁用
|
|
7945
|
+
*/
|
|
7946
|
+
isDisabledDrag() {
|
|
7947
|
+
return this.$ele.runAway.classList.contains("pops-slider-is-disabled");
|
|
7948
|
+
},
|
|
7949
|
+
/**
|
|
7950
|
+
* 设置进度条点击定位的事件
|
|
7951
|
+
*/
|
|
7952
|
+
setRunAwayClickEvent() {
|
|
7953
|
+
popsDOMUtils.on(this.$ele.runAway, "click", void 0, (event) => {
|
|
7954
|
+
if (event.target !== this.$ele.runAway &&
|
|
7955
|
+
event.target !== this.$ele.bar) {
|
|
7956
|
+
return;
|
|
7957
|
+
}
|
|
7958
|
+
let clickX = parseFloat(event.offsetX);
|
|
7959
|
+
this.dragStartCallBack();
|
|
7960
|
+
this.dragMoveCallBack(event, clickX, this.value);
|
|
7961
|
+
this.dragEndCallBack(clickX);
|
|
7962
|
+
}, {
|
|
7963
|
+
capture: false,
|
|
7964
|
+
});
|
|
7965
|
+
},
|
|
7966
|
+
/**
|
|
7967
|
+
* 拖拽开始的回调,如果返回false,禁止拖拽
|
|
7968
|
+
*/
|
|
7969
|
+
dragStartCallBack() {
|
|
7970
|
+
if (!this.$data.isMove) {
|
|
7971
|
+
if (this.isDisabledDrag()) {
|
|
7972
|
+
return false;
|
|
7973
|
+
}
|
|
7974
|
+
this.$data.isMove = true;
|
|
7969
7975
|
}
|
|
7970
|
-
|
|
7971
|
-
}
|
|
7972
|
-
return true;
|
|
7973
|
-
},
|
|
7974
|
-
/**
|
|
7975
|
-
* 拖拽中的回调
|
|
7976
|
-
* @param event 事件
|
|
7977
|
-
* @param dragX 当前拖拽的距离
|
|
7978
|
-
* @param oldValue 旧的值
|
|
7979
|
-
*/
|
|
7980
|
-
dragMoveCallBack(event, dragX, oldValue) {
|
|
7981
|
-
let dragPercent = 0;
|
|
7982
|
-
if (dragX <= 0) {
|
|
7983
|
-
dragPercent = 0;
|
|
7984
|
-
this.value = this.min;
|
|
7985
|
-
}
|
|
7986
|
-
else if (dragX >= this.$data.totalWidth) {
|
|
7987
|
-
dragPercent = 1;
|
|
7988
|
-
this.value = this.max;
|
|
7989
|
-
}
|
|
7990
|
-
else {
|
|
7991
|
-
const dragInfo = this.getDragInfo(dragX);
|
|
7992
|
-
dragPercent = dragInfo.percent;
|
|
7993
|
-
this.value = this.formatValue(dragInfo.value);
|
|
7994
|
-
}
|
|
7995
|
-
this.$data.dragPercent = dragPercent;
|
|
7996
|
-
this.setSliderPosition(this.$data.dragPercent);
|
|
7997
|
-
this.showToolTip();
|
|
7998
|
-
if (oldValue !== this.value) {
|
|
7999
|
-
this.valueChangeCallBack(event, this.value);
|
|
8000
|
-
}
|
|
8001
|
-
},
|
|
8002
|
-
/**
|
|
8003
|
-
* 拖拽结束的回调
|
|
8004
|
-
*/
|
|
8005
|
-
dragEndCallBack(dragX) {
|
|
8006
|
-
this.$data.isMove = false;
|
|
8007
|
-
if (dragX <= 0) {
|
|
8008
|
-
this.$data.dragWidth = 0;
|
|
8009
|
-
}
|
|
8010
|
-
else if (dragX >= this.$data.totalWidth) {
|
|
8011
|
-
this.$data.dragWidth = this.$data.totalWidth;
|
|
8012
|
-
}
|
|
8013
|
-
else {
|
|
8014
|
-
this.$data.dragWidth = dragX;
|
|
8015
|
-
}
|
|
8016
|
-
this.closeToolTip();
|
|
8017
|
-
},
|
|
8018
|
-
/**
|
|
8019
|
-
* 设置点击拖拽事件
|
|
8020
|
-
*/
|
|
8021
|
-
setPanEvent() {
|
|
8022
|
-
const AnyTouch = popsUtils.AnyTouch();
|
|
8023
|
-
this.$tooltip = new AnyTouch(this.$ele.button, {
|
|
8024
|
-
preventEvent() {
|
|
8025
|
-
return false;
|
|
8026
|
-
},
|
|
8027
|
-
});
|
|
7976
|
+
return true;
|
|
7977
|
+
},
|
|
8028
7978
|
/**
|
|
8029
|
-
*
|
|
7979
|
+
* 拖拽中的回调
|
|
7980
|
+
* @param event 事件
|
|
7981
|
+
* @param dragX 当前拖拽的距离
|
|
7982
|
+
* @param oldValue 旧的值
|
|
8030
7983
|
*/
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
7984
|
+
dragMoveCallBack(event, dragX, oldValue) {
|
|
7985
|
+
let dragPercent = 0;
|
|
7986
|
+
if (dragX <= 0) {
|
|
7987
|
+
dragPercent = 0;
|
|
7988
|
+
this.value = this.min;
|
|
8036
7989
|
}
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
if (displacementX <= 0) {
|
|
8041
|
-
displacementX = 0;
|
|
7990
|
+
else if (dragX >= this.$data.totalWidth) {
|
|
7991
|
+
dragPercent = 1;
|
|
7992
|
+
this.value = this.max;
|
|
8042
7993
|
}
|
|
8043
|
-
else
|
|
8044
|
-
|
|
7994
|
+
else {
|
|
7995
|
+
const dragInfo = this.getDragInfo(dragX);
|
|
7996
|
+
dragPercent = dragInfo.percent;
|
|
7997
|
+
this.value = this.formatValue(dragInfo.value);
|
|
8045
7998
|
}
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
this.
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
this.$tooltip.on("at:end", (event) => {
|
|
8052
|
-
this.dragEndCallBack(currentDragX);
|
|
8053
|
-
});
|
|
8054
|
-
},
|
|
8055
|
-
/**
|
|
8056
|
-
* 显示悬浮的
|
|
8057
|
-
*/
|
|
8058
|
-
showToolTip() {
|
|
8059
|
-
this.$ele.tooltip.show();
|
|
8060
|
-
},
|
|
8061
|
-
/**
|
|
8062
|
-
* 关闭悬浮的
|
|
8063
|
-
*/
|
|
8064
|
-
closeToolTip() {
|
|
8065
|
-
this.$ele.tooltip.close();
|
|
8066
|
-
},
|
|
8067
|
-
/**
|
|
8068
|
-
* 检测在1000ms内,是否停止了拖拽
|
|
8069
|
-
*/
|
|
8070
|
-
checkStopDragMove() {
|
|
8071
|
-
if (this.$data.isCheckingStopDragMove) {
|
|
8072
|
-
return;
|
|
8073
|
-
}
|
|
8074
|
-
this.$data.isCheckingStopDragMove = true;
|
|
8075
|
-
let interval = setInterval(() => {
|
|
8076
|
-
if (!this.$data.isMove) {
|
|
8077
|
-
this.$data.isCheckingStopDragMove = false;
|
|
8078
|
-
this.closeToolTip();
|
|
8079
|
-
clearInterval(interval);
|
|
7999
|
+
this.$data.dragPercent = dragPercent;
|
|
8000
|
+
this.setSliderPosition(this.$data.dragPercent);
|
|
8001
|
+
this.showToolTip();
|
|
8002
|
+
if (oldValue !== this.value) {
|
|
8003
|
+
this.valueChangeCallBack(event, this.value);
|
|
8080
8004
|
}
|
|
8081
|
-
},
|
|
8082
|
-
setTimeout(() => {
|
|
8083
|
-
this.$data.isCheckingStopDragMove = false;
|
|
8084
|
-
clearInterval(interval);
|
|
8085
|
-
}, 2000);
|
|
8086
|
-
},
|
|
8087
|
-
/**
|
|
8088
|
-
* 设置拖拽按钮的悬浮事件
|
|
8089
|
-
*/
|
|
8090
|
-
setToolTipEvent() {
|
|
8005
|
+
},
|
|
8091
8006
|
/**
|
|
8092
|
-
*
|
|
8007
|
+
* 拖拽结束的回调
|
|
8093
8008
|
*/
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8009
|
+
dragEndCallBack(dragX) {
|
|
8010
|
+
this.$data.isMove = false;
|
|
8011
|
+
if (dragX <= 0) {
|
|
8012
|
+
this.$data.dragWidth = 0;
|
|
8013
|
+
}
|
|
8014
|
+
else if (dragX >= this.$data.totalWidth) {
|
|
8015
|
+
this.$data.dragWidth = this.$data.totalWidth;
|
|
8097
8016
|
}
|
|
8098
8017
|
else {
|
|
8099
|
-
|
|
8018
|
+
this.$data.dragWidth = dragX;
|
|
8100
8019
|
}
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
capture: true,
|
|
8111
|
-
passive: true,
|
|
8112
|
-
},
|
|
8113
|
-
showBeforeCallBack: () => {
|
|
8114
|
-
this.intervalInit();
|
|
8115
|
-
},
|
|
8116
|
-
showAfterCallBack: (toolTipNode) => {
|
|
8117
|
-
tooltipContent.innerText = getToolTipContent();
|
|
8118
|
-
},
|
|
8119
|
-
closeBeforeCallBack: () => {
|
|
8120
|
-
if (this.$data.isMove) {
|
|
8121
|
-
this.checkStopDragMove();
|
|
8020
|
+
this.closeToolTip();
|
|
8021
|
+
},
|
|
8022
|
+
/**
|
|
8023
|
+
* 设置点击拖拽事件
|
|
8024
|
+
*/
|
|
8025
|
+
setPanEvent() {
|
|
8026
|
+
const AnyTouch = popsUtils.AnyTouch();
|
|
8027
|
+
this.$tooltip = new AnyTouch(this.$ele.button, {
|
|
8028
|
+
preventEvent() {
|
|
8122
8029
|
return false;
|
|
8030
|
+
},
|
|
8031
|
+
});
|
|
8032
|
+
/**
|
|
8033
|
+
* 当前的拖拽的距离px
|
|
8034
|
+
*/
|
|
8035
|
+
let currentDragX = 0;
|
|
8036
|
+
/* 监听拖拽 */
|
|
8037
|
+
this.$tooltip.on("at:move", (event) => {
|
|
8038
|
+
if (!this.dragStartCallBack()) {
|
|
8039
|
+
return;
|
|
8123
8040
|
}
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
});
|
|
8130
|
-
tooltipContent =
|
|
8131
|
-
this.$ele.tooltip.toolTipNode.querySelector("div");
|
|
8132
|
-
},
|
|
8133
|
-
};
|
|
8134
|
-
PopsPanelSlider.init();
|
|
8135
|
-
liElement["data-slider"] = PopsPanelSlider;
|
|
8136
|
-
return liElement;
|
|
8137
|
-
},
|
|
8138
|
-
/**
|
|
8139
|
-
* 获取中间容器的元素<li>
|
|
8140
|
-
* type ==> input
|
|
8141
|
-
* @param formConfig
|
|
8142
|
-
*/
|
|
8143
|
-
getSectionContainerItem_input(formConfig) {
|
|
8144
|
-
let liElement = document.createElement("li");
|
|
8145
|
-
liElement["__formConfig__"] = formConfig;
|
|
8146
|
-
if (formConfig.className) {
|
|
8147
|
-
liElement.className = formConfig.className;
|
|
8148
|
-
}
|
|
8149
|
-
this.addElementAttributes(liElement, formConfig.attributes);
|
|
8150
|
-
this.setElementProps(liElement, formConfig.props);
|
|
8151
|
-
let inputType = "text";
|
|
8152
|
-
if (formConfig.isPassword) {
|
|
8153
|
-
inputType = "password";
|
|
8154
|
-
}
|
|
8155
|
-
else if (formConfig.isNumber) {
|
|
8156
|
-
inputType = "number";
|
|
8157
|
-
}
|
|
8158
|
-
/* 左边底部的描述的文字 */
|
|
8159
|
-
let leftDescriptionText = "";
|
|
8160
|
-
if (Boolean(formConfig.description)) {
|
|
8161
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
8162
|
-
}
|
|
8163
|
-
liElement.innerHTML = `
|
|
8164
|
-
<div class="pops-panel-item-left-text">
|
|
8165
|
-
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
8166
|
-
${leftDescriptionText}
|
|
8167
|
-
</div>
|
|
8168
|
-
<div class="pops-panel-input">
|
|
8169
|
-
<input type="${inputType}" placeholder="${formConfig.placeholder}">
|
|
8170
|
-
</div>
|
|
8171
|
-
`;
|
|
8172
|
-
const PopsPanelInput = {
|
|
8173
|
-
[Symbol.toStringTag]: "PopsPanelInput",
|
|
8174
|
-
$ele: {
|
|
8175
|
-
panelInput: liElement.querySelector(".pops-panel-input"),
|
|
8176
|
-
input: liElement.querySelector("input"),
|
|
8177
|
-
inputSpanIcon: document.createElement("span"),
|
|
8178
|
-
inputSpanIconInner: null,
|
|
8179
|
-
icon: null,
|
|
8180
|
-
},
|
|
8181
|
-
$data: {
|
|
8182
|
-
value: formConfig.getValue(),
|
|
8183
|
-
isView: false,
|
|
8184
|
-
},
|
|
8185
|
-
init() {
|
|
8186
|
-
this.initEle();
|
|
8187
|
-
this.setInputValue(this.$data.value);
|
|
8188
|
-
/* 如果是密码框,放进图标 */
|
|
8189
|
-
if (formConfig.isPassword) {
|
|
8190
|
-
this.setCircleIcon(pops.config.iconSVG.view);
|
|
8191
|
-
this.setCircleIconClickEvent();
|
|
8192
|
-
}
|
|
8193
|
-
else {
|
|
8194
|
-
/* 先判断预设值是否为空,不为空添加清空图标按钮 */
|
|
8195
|
-
if (this.$ele.input.value != "") {
|
|
8196
|
-
this.setCircleIcon(pops.config.iconSVG.circleClose);
|
|
8197
|
-
this.setCircleIconClickEvent();
|
|
8198
|
-
}
|
|
8199
|
-
}
|
|
8200
|
-
this.setInputChangeEvent();
|
|
8201
|
-
if (formConfig.disabled) {
|
|
8202
|
-
this.disable();
|
|
8203
|
-
}
|
|
8204
|
-
if (typeof formConfig.handlerCallBack === "function") {
|
|
8205
|
-
formConfig.handlerCallBack(liElement, this.$ele.input);
|
|
8206
|
-
}
|
|
8207
|
-
},
|
|
8208
|
-
/**
|
|
8209
|
-
* 初始化$ele的配置
|
|
8210
|
-
*/
|
|
8211
|
-
initEle() {
|
|
8212
|
-
this.$ele.input.parentElement.insertBefore(this.$ele.inputSpanIcon, this.$ele.input.nextSibling);
|
|
8213
|
-
this.$ele.inputSpanIcon.className = "pops-panel-input__suffix";
|
|
8214
|
-
this.$ele.inputSpanIcon.innerHTML = `
|
|
8215
|
-
<span class="pops-panel-input__suffix-inner">
|
|
8216
|
-
<i class="pops-panel-icon"></i>
|
|
8217
|
-
</span>
|
|
8218
|
-
`;
|
|
8219
|
-
this.$ele.inputSpanIconInner =
|
|
8220
|
-
this.$ele.inputSpanIcon.querySelector(".pops-panel-input__suffix-inner");
|
|
8221
|
-
this.$ele.icon =
|
|
8222
|
-
this.$ele.inputSpanIcon.querySelector(".pops-panel-icon");
|
|
8223
|
-
},
|
|
8224
|
-
/**
|
|
8225
|
-
* 禁用
|
|
8226
|
-
*/
|
|
8227
|
-
disable() {
|
|
8228
|
-
this.$ele.input.disabled = true;
|
|
8229
|
-
this.$ele.panelInput.classList.add("pops-input-disabled");
|
|
8230
|
-
},
|
|
8231
|
-
/**
|
|
8232
|
-
* 取消禁用
|
|
8233
|
-
*/
|
|
8234
|
-
notDisable() {
|
|
8235
|
-
this.$ele.input.disabled = false;
|
|
8236
|
-
this.$ele.panelInput.classList.remove("pops-input-disabled");
|
|
8237
|
-
},
|
|
8238
|
-
/**
|
|
8239
|
-
* 判断是否已被禁用
|
|
8240
|
-
*/
|
|
8241
|
-
isDisabled() {
|
|
8242
|
-
return this.$ele.input.disabled;
|
|
8243
|
-
},
|
|
8244
|
-
/**
|
|
8245
|
-
* 设置输入框内容
|
|
8246
|
-
* @param {string} [value=""] 值
|
|
8247
|
-
*/
|
|
8248
|
-
setInputValue(value = "") {
|
|
8249
|
-
this.$ele.input.value = value;
|
|
8250
|
-
},
|
|
8251
|
-
/**
|
|
8252
|
-
* 设置input元素的type
|
|
8253
|
-
* @param {string} [typeValue="text"] type值
|
|
8254
|
-
*/
|
|
8255
|
-
setInputType(typeValue = "text") {
|
|
8256
|
-
this.$ele.input.setAttribute("type", typeValue);
|
|
8257
|
-
},
|
|
8258
|
-
/**
|
|
8259
|
-
* 删除图标按钮
|
|
8260
|
-
*/
|
|
8261
|
-
removeCircleIcon() {
|
|
8262
|
-
this.$ele.icon.innerHTML = "";
|
|
8263
|
-
},
|
|
8264
|
-
/**
|
|
8265
|
-
* 添加清空图标按钮
|
|
8266
|
-
* @param {string} [svgHTML=pops.config.iconSVG.circleClose] svg图标,默认为清空的图标
|
|
8267
|
-
*/
|
|
8268
|
-
setCircleIcon(svgHTML = pops.config.iconSVG.circleClose) {
|
|
8269
|
-
this.$ele.icon.innerHTML = svgHTML;
|
|
8270
|
-
},
|
|
8271
|
-
/**
|
|
8272
|
-
* 添加图标按钮的点击事件
|
|
8273
|
-
*/
|
|
8274
|
-
setCircleIconClickEvent() {
|
|
8275
|
-
popsDOMUtils.on(this.$ele.icon, "click", void 0, () => {
|
|
8276
|
-
if (this.isDisabled()) {
|
|
8277
|
-
return;
|
|
8278
|
-
}
|
|
8279
|
-
/* 删除图标 */
|
|
8280
|
-
this.removeCircleIcon();
|
|
8281
|
-
if (formConfig.isPassword) {
|
|
8282
|
-
/* 密码输入框 */
|
|
8283
|
-
if (this.$data.isView) {
|
|
8284
|
-
/* 当前可见 => 点击改变为隐藏 */
|
|
8285
|
-
this.$data.isView = false;
|
|
8286
|
-
/* 显示输入框内容,且更换图标为隐藏图标 */
|
|
8287
|
-
this.setInputType("text");
|
|
8288
|
-
this.setCircleIcon(pops.config.iconSVG.hide);
|
|
8041
|
+
let oldValue = this.value;
|
|
8042
|
+
const runAwayRect = this.$ele.runAway.getBoundingClientRect();
|
|
8043
|
+
let displacementX = event.x - (runAwayRect.left + globalThis.screenX);
|
|
8044
|
+
if (displacementX <= 0) {
|
|
8045
|
+
displacementX = 0;
|
|
8289
8046
|
}
|
|
8290
|
-
else {
|
|
8291
|
-
|
|
8292
|
-
this.$data.isView = true;
|
|
8293
|
-
/* 隐藏输入框内容,且更换图标为显示图标 */
|
|
8294
|
-
this.setInputType("password");
|
|
8295
|
-
this.setCircleIcon(pops.config.iconSVG.view);
|
|
8047
|
+
else if (displacementX >= runAwayRect.width) {
|
|
8048
|
+
displacementX = runAwayRect.width;
|
|
8296
8049
|
}
|
|
8050
|
+
currentDragX = displacementX;
|
|
8051
|
+
/* 拖拽移动 */
|
|
8052
|
+
this.dragMoveCallBack(event, currentDragX, oldValue);
|
|
8053
|
+
});
|
|
8054
|
+
/* 监听触点离开,处理某些情况下,拖拽松开,但是未触发pan事件,可以通过设置这个来关闭tooltip */
|
|
8055
|
+
this.$tooltip.on("at:end", (event) => {
|
|
8056
|
+
this.dragEndCallBack(currentDragX);
|
|
8057
|
+
});
|
|
8058
|
+
},
|
|
8059
|
+
/**
|
|
8060
|
+
* 显示悬浮的
|
|
8061
|
+
*/
|
|
8062
|
+
showToolTip() {
|
|
8063
|
+
this.$ele.tooltip.show();
|
|
8064
|
+
},
|
|
8065
|
+
/**
|
|
8066
|
+
* 关闭悬浮的
|
|
8067
|
+
*/
|
|
8068
|
+
closeToolTip() {
|
|
8069
|
+
this.$ele.tooltip.close();
|
|
8070
|
+
},
|
|
8071
|
+
/**
|
|
8072
|
+
* 检测在1000ms内,是否停止了拖拽
|
|
8073
|
+
*/
|
|
8074
|
+
checkStopDragMove() {
|
|
8075
|
+
if (this.$data.isCheckingStopDragMove) {
|
|
8076
|
+
return;
|
|
8297
8077
|
}
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
/* 触发内容改变事件 */
|
|
8305
|
-
this.$ele.input.dispatchEvent(new Event("input"));
|
|
8306
|
-
}
|
|
8307
|
-
});
|
|
8308
|
-
},
|
|
8309
|
-
/**
|
|
8310
|
-
* 监听输入框内容改变
|
|
8311
|
-
*/
|
|
8312
|
-
setInputChangeEvent() {
|
|
8313
|
-
popsDOMUtils.on(this.$ele.input, ["input", "propertychange"], void 0, (event) => {
|
|
8314
|
-
this.$data.value = this.$ele.input.value;
|
|
8315
|
-
if (!formConfig.isPassword) {
|
|
8316
|
-
/* 不是密码框 */
|
|
8317
|
-
if (this.$ele.input.value !== "" &&
|
|
8318
|
-
this.$ele.icon.innerHTML === "") {
|
|
8319
|
-
/* 不为空,显示清空图标 */
|
|
8320
|
-
this.setCircleIcon(pops.config.iconSVG.circleClose);
|
|
8321
|
-
this.setCircleIconClickEvent();
|
|
8078
|
+
this.$data.isCheckingStopDragMove = true;
|
|
8079
|
+
let interval = setInterval(() => {
|
|
8080
|
+
if (!this.$data.isMove) {
|
|
8081
|
+
this.$data.isCheckingStopDragMove = false;
|
|
8082
|
+
this.closeToolTip();
|
|
8083
|
+
clearInterval(interval);
|
|
8322
8084
|
}
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8085
|
+
}, 200);
|
|
8086
|
+
setTimeout(() => {
|
|
8087
|
+
this.$data.isCheckingStopDragMove = false;
|
|
8088
|
+
clearInterval(interval);
|
|
8089
|
+
}, 2000);
|
|
8090
|
+
},
|
|
8091
|
+
/**
|
|
8092
|
+
* 设置拖拽按钮的悬浮事件
|
|
8093
|
+
*/
|
|
8094
|
+
setToolTipEvent() {
|
|
8095
|
+
/**
|
|
8096
|
+
* 获取提示的内容
|
|
8097
|
+
*/
|
|
8098
|
+
function getToolTipContent() {
|
|
8099
|
+
if (typeof formConfig.getToolTipContent === "function") {
|
|
8100
|
+
return formConfig.getToolTipContent(PopsPanelSlider.value);
|
|
8330
8101
|
}
|
|
8331
8102
|
else {
|
|
8332
|
-
|
|
8103
|
+
return PopsPanelSlider.value;
|
|
8333
8104
|
}
|
|
8334
8105
|
}
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8106
|
+
let tooltipContent = null;
|
|
8107
|
+
this.$ele.tooltip = pops.tooltip({
|
|
8108
|
+
target: this.$ele.button,
|
|
8109
|
+
content: getToolTipContent,
|
|
8110
|
+
zIndex: 1000000,
|
|
8111
|
+
className: "github-tooltip",
|
|
8112
|
+
only: false,
|
|
8113
|
+
eventOption: {
|
|
8114
|
+
capture: true,
|
|
8115
|
+
passive: true,
|
|
8116
|
+
},
|
|
8117
|
+
showBeforeCallBack: () => {
|
|
8118
|
+
this.intervalInit();
|
|
8119
|
+
},
|
|
8120
|
+
showAfterCallBack: (toolTipNode) => {
|
|
8121
|
+
tooltipContent.innerText = getToolTipContent();
|
|
8122
|
+
},
|
|
8123
|
+
closeBeforeCallBack: () => {
|
|
8124
|
+
if (this.$data.isMove) {
|
|
8125
|
+
this.checkStopDragMove();
|
|
8126
|
+
return false;
|
|
8127
|
+
}
|
|
8128
|
+
},
|
|
8129
|
+
alwaysShow: false,
|
|
8130
|
+
// only: false,
|
|
8131
|
+
position: "top",
|
|
8132
|
+
arrowDistance: 10,
|
|
8133
|
+
});
|
|
8134
|
+
tooltipContent =
|
|
8135
|
+
this.$ele.tooltip.toolTipNode.querySelector("div");
|
|
8136
|
+
},
|
|
8137
|
+
};
|
|
8138
|
+
PopsPanelSlider.init();
|
|
8139
|
+
liElement["data-slider"] = PopsPanelSlider;
|
|
8140
|
+
return liElement;
|
|
8141
|
+
},
|
|
8142
|
+
/**
|
|
8143
|
+
* 获取中间容器的元素<li>
|
|
8144
|
+
* type ==> input
|
|
8145
|
+
* @param formConfig
|
|
8146
|
+
*/
|
|
8147
|
+
getSectionContainerItem_input(formConfig) {
|
|
8148
|
+
let liElement = document.createElement("li");
|
|
8149
|
+
liElement["__formConfig__"] = formConfig;
|
|
8150
|
+
if (formConfig.className) {
|
|
8151
|
+
liElement.className = formConfig.className;
|
|
8152
|
+
}
|
|
8153
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
8154
|
+
this.setElementProps(liElement, formConfig.props);
|
|
8155
|
+
let inputType = "text";
|
|
8156
|
+
if (formConfig.isPassword) {
|
|
8157
|
+
inputType = "password";
|
|
8158
|
+
}
|
|
8159
|
+
else if (formConfig.isNumber) {
|
|
8160
|
+
inputType = "number";
|
|
8161
|
+
}
|
|
8162
|
+
/* 左边底部的描述的文字 */
|
|
8163
|
+
let leftDescriptionText = "";
|
|
8164
|
+
if (Boolean(formConfig.description)) {
|
|
8165
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
8166
|
+
}
|
|
8167
|
+
liElement.innerHTML = `
|
|
8168
|
+
<div class="pops-panel-item-left-text">
|
|
8169
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
8170
|
+
${leftDescriptionText}
|
|
8171
|
+
</div>
|
|
8172
|
+
<div class="pops-panel-input">
|
|
8173
|
+
<input type="${inputType}" placeholder="${formConfig.placeholder}">
|
|
8174
|
+
</div>
|
|
8175
|
+
`;
|
|
8176
|
+
const PopsPanelInput = {
|
|
8177
|
+
[Symbol.toStringTag]: "PopsPanelInput",
|
|
8178
|
+
$ele: {
|
|
8179
|
+
panelInput: liElement.querySelector(".pops-panel-input"),
|
|
8180
|
+
input: liElement.querySelector("input"),
|
|
8181
|
+
inputSpanIcon: document.createElement("span"),
|
|
8182
|
+
inputSpanIconInner: null,
|
|
8183
|
+
icon: null,
|
|
8184
|
+
},
|
|
8185
|
+
$data: {
|
|
8186
|
+
value: formConfig.getValue(),
|
|
8187
|
+
isView: false,
|
|
8188
|
+
},
|
|
8189
|
+
init() {
|
|
8190
|
+
this.initEle();
|
|
8191
|
+
this.setInputValue(this.$data.value);
|
|
8192
|
+
/* 如果是密码框,放进图标 */
|
|
8193
|
+
if (formConfig.isPassword) {
|
|
8194
|
+
this.setCircleIcon(pops.config.iconSVG.view);
|
|
8195
|
+
this.setCircleIconClickEvent();
|
|
8409
8196
|
}
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
},
|
|
8417
|
-
/**
|
|
8418
|
-
* 获取中间容器的元素<li>
|
|
8419
|
-
* type ==> select
|
|
8420
|
-
* @param formConfig
|
|
8421
|
-
*/
|
|
8422
|
-
getSectionContainerItem_select(formConfig) {
|
|
8423
|
-
let liElement = document.createElement("li");
|
|
8424
|
-
liElement["__formConfig__"] = formConfig;
|
|
8425
|
-
if (formConfig.className) {
|
|
8426
|
-
liElement.className = formConfig.className;
|
|
8427
|
-
}
|
|
8428
|
-
this.addElementAttributes(liElement, formConfig.attributes);
|
|
8429
|
-
this.setElementProps(liElement, formConfig.props);
|
|
8430
|
-
/* 左边底部的描述的文字 */
|
|
8431
|
-
let leftDescriptionText = "";
|
|
8432
|
-
if (Boolean(formConfig.description)) {
|
|
8433
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
8434
|
-
}
|
|
8435
|
-
liElement.innerHTML = /*html*/ `
|
|
8436
|
-
<div class="pops-panel-item-left-text">
|
|
8437
|
-
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
8438
|
-
${leftDescriptionText}
|
|
8439
|
-
</div>
|
|
8440
|
-
<div class="pops-panel-select">
|
|
8441
|
-
<select></select>
|
|
8442
|
-
</div>
|
|
8443
|
-
`;
|
|
8444
|
-
const PopsPanelSelect = {
|
|
8445
|
-
[Symbol.toStringTag]: "PopsPanelSelect",
|
|
8446
|
-
$ele: {
|
|
8447
|
-
panelSelect: liElement.querySelector(".pops-panel-select"),
|
|
8448
|
-
select: liElement.querySelector(".pops-panel-select select"),
|
|
8449
|
-
},
|
|
8450
|
-
$eleKey: {
|
|
8451
|
-
disable: "__disable__",
|
|
8452
|
-
value: "__value__",
|
|
8453
|
-
},
|
|
8454
|
-
$data: {
|
|
8455
|
-
defaultValue: formConfig.getValue(),
|
|
8456
|
-
},
|
|
8457
|
-
init() {
|
|
8458
|
-
this.initOption();
|
|
8459
|
-
this.setChangeEvent();
|
|
8460
|
-
this.setClickEvent();
|
|
8461
|
-
if (formConfig.disabled) {
|
|
8462
|
-
this.disable();
|
|
8463
|
-
}
|
|
8464
|
-
},
|
|
8465
|
-
/**
|
|
8466
|
-
* 给option元素设置属性
|
|
8467
|
-
* @param $ele
|
|
8468
|
-
* @param key
|
|
8469
|
-
* @param value
|
|
8470
|
-
*/
|
|
8471
|
-
setNodeValue($ele, key, value) {
|
|
8472
|
-
Reflect.set($ele, key, value);
|
|
8473
|
-
},
|
|
8474
|
-
/**
|
|
8475
|
-
* 获取option元素上设置的属性
|
|
8476
|
-
* @param $ele
|
|
8477
|
-
* @param value
|
|
8478
|
-
* @param key
|
|
8479
|
-
*/
|
|
8480
|
-
getNodeValue($ele, key) {
|
|
8481
|
-
return Reflect.get($ele, key);
|
|
8482
|
-
},
|
|
8483
|
-
disable() {
|
|
8484
|
-
this.$ele.select.setAttribute("disabled", "true");
|
|
8485
|
-
this.$ele.panelSelect.classList.add("pops-panel-select-disable");
|
|
8486
|
-
},
|
|
8487
|
-
notDisable() {
|
|
8488
|
-
this.$ele.select.removeAttribute("disabled");
|
|
8489
|
-
this.$ele.panelSelect.classList.remove("pops-panel-select-disable");
|
|
8490
|
-
},
|
|
8491
|
-
isDisabled() {
|
|
8492
|
-
return (this.$ele.select.hasAttribute("disabled") ||
|
|
8493
|
-
this.$ele.panelSelect.classList.contains("pops-panel-select-disable"));
|
|
8494
|
-
},
|
|
8495
|
-
initOption() {
|
|
8496
|
-
formConfig.data.forEach((dataItem) => {
|
|
8497
|
-
// 初始化默认选中
|
|
8498
|
-
let optionElement = document.createElement("option");
|
|
8499
|
-
this.setNodeValue(optionElement, this.$eleKey.value, dataItem.value);
|
|
8500
|
-
this.setNodeValue(optionElement, this.$eleKey.disable, dataItem.disable);
|
|
8501
|
-
if (dataItem.value === this.$data.defaultValue) {
|
|
8502
|
-
optionElement.setAttribute("selected", "true");
|
|
8197
|
+
else {
|
|
8198
|
+
/* 先判断预设值是否为空,不为空添加清空图标按钮 */
|
|
8199
|
+
if (this.$ele.input.value != "") {
|
|
8200
|
+
this.setCircleIcon(pops.config.iconSVG.circleClose);
|
|
8201
|
+
this.setCircleIconClickEvent();
|
|
8202
|
+
}
|
|
8503
8203
|
}
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
},
|
|
8508
|
-
/** 检测所有option并设置禁用状态 */
|
|
8509
|
-
setSelectOptionsDisableStatus() {
|
|
8510
|
-
if (this.$ele.select.options && this.$ele.select.options.length) {
|
|
8511
|
-
Array.from(this.$ele.select.options).forEach((optionItem) => {
|
|
8512
|
-
this.setOptionDisableStatus(optionItem);
|
|
8513
|
-
});
|
|
8514
|
-
}
|
|
8515
|
-
},
|
|
8516
|
-
/** 设置禁用状态 */
|
|
8517
|
-
setOptionDisableStatus(optionElement) {
|
|
8518
|
-
let disable = false;
|
|
8519
|
-
let optionDisableAttr = this.getNodeValue(optionElement, this.$eleKey.disable);
|
|
8520
|
-
if (optionDisableAttr === "function") {
|
|
8521
|
-
let value = this.getNodeValue(optionElement, this.$eleKey.value);
|
|
8522
|
-
disable = Boolean(optionDisableAttr(value));
|
|
8523
|
-
}
|
|
8524
|
-
if (disable) {
|
|
8525
|
-
optionElement.setAttribute("disabled", "true");
|
|
8526
|
-
}
|
|
8527
|
-
else {
|
|
8528
|
-
optionElement.removeAttribute("disabled");
|
|
8529
|
-
}
|
|
8530
|
-
},
|
|
8531
|
-
/** 获取option上的信息 */
|
|
8532
|
-
getSelectOptionInfo($option) {
|
|
8533
|
-
let optionValue = this.getNodeValue($option, this.$eleKey.value);
|
|
8534
|
-
let optionText = $option.innerText || $option.textContent;
|
|
8535
|
-
return {
|
|
8536
|
-
value: optionValue,
|
|
8537
|
-
text: optionText,
|
|
8538
|
-
$option: $option,
|
|
8539
|
-
};
|
|
8540
|
-
},
|
|
8541
|
-
/**
|
|
8542
|
-
* 监听选择内容改变
|
|
8543
|
-
*/
|
|
8544
|
-
setChangeEvent() {
|
|
8545
|
-
popsDOMUtils.on(this.$ele.select, "change", void 0, (event) => {
|
|
8546
|
-
this.setSelectOptionsDisableStatus();
|
|
8547
|
-
if (typeof formConfig.callback === "function") {
|
|
8548
|
-
let $isSelectedElement = event.target[event.target.selectedIndex];
|
|
8549
|
-
let selectInfo = this.getSelectOptionInfo($isSelectedElement);
|
|
8550
|
-
formConfig.callback(event, selectInfo.value, selectInfo.text);
|
|
8204
|
+
this.setInputChangeEvent();
|
|
8205
|
+
if (formConfig.disabled) {
|
|
8206
|
+
this.disable();
|
|
8551
8207
|
}
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
/**
|
|
8555
|
-
* 监听点击事件
|
|
8556
|
-
*/
|
|
8557
|
-
setClickEvent() {
|
|
8558
|
-
popsDOMUtils.on(this.$ele.select, "click", void 0, (event) => {
|
|
8559
|
-
this.setSelectOptionsDisableStatus();
|
|
8560
|
-
if (typeof formConfig.clickCallBack === "function") {
|
|
8561
|
-
formConfig.clickCallBack(event, this.$ele.select);
|
|
8208
|
+
if (typeof formConfig.handlerCallBack === "function") {
|
|
8209
|
+
formConfig.handlerCallBack(liElement, this.$ele.input);
|
|
8562
8210
|
}
|
|
8563
|
-
}
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
/**
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8211
|
+
},
|
|
8212
|
+
/**
|
|
8213
|
+
* 初始化$ele的配置
|
|
8214
|
+
*/
|
|
8215
|
+
initEle() {
|
|
8216
|
+
this.$ele.input.parentElement.insertBefore(this.$ele.inputSpanIcon, this.$ele.input.nextSibling);
|
|
8217
|
+
this.$ele.inputSpanIcon.className = "pops-panel-input__suffix";
|
|
8218
|
+
this.$ele.inputSpanIcon.innerHTML = `
|
|
8219
|
+
<span class="pops-panel-input__suffix-inner">
|
|
8220
|
+
<i class="pops-panel-icon"></i>
|
|
8221
|
+
</span>
|
|
8222
|
+
`;
|
|
8223
|
+
this.$ele.inputSpanIconInner =
|
|
8224
|
+
this.$ele.inputSpanIcon.querySelector(".pops-panel-input__suffix-inner");
|
|
8225
|
+
this.$ele.icon =
|
|
8226
|
+
this.$ele.inputSpanIcon.querySelector(".pops-panel-icon");
|
|
8227
|
+
},
|
|
8228
|
+
/**
|
|
8229
|
+
* 禁用
|
|
8230
|
+
*/
|
|
8231
|
+
disable() {
|
|
8232
|
+
this.$ele.input.disabled = true;
|
|
8233
|
+
this.$ele.panelInput.classList.add("pops-input-disabled");
|
|
8234
|
+
},
|
|
8235
|
+
/**
|
|
8236
|
+
* 取消禁用
|
|
8237
|
+
*/
|
|
8238
|
+
notDisable() {
|
|
8239
|
+
this.$ele.input.disabled = false;
|
|
8240
|
+
this.$ele.panelInput.classList.remove("pops-input-disabled");
|
|
8241
|
+
},
|
|
8242
|
+
/**
|
|
8243
|
+
* 判断是否已被禁用
|
|
8244
|
+
*/
|
|
8245
|
+
isDisabled() {
|
|
8246
|
+
return this.$ele.input.disabled;
|
|
8247
|
+
},
|
|
8248
|
+
/**
|
|
8249
|
+
* 设置输入框内容
|
|
8250
|
+
* @param {string} [value=""] 值
|
|
8251
|
+
*/
|
|
8252
|
+
setInputValue(value = "") {
|
|
8253
|
+
this.$ele.input.value = value;
|
|
8254
|
+
},
|
|
8255
|
+
/**
|
|
8256
|
+
* 设置input元素的type
|
|
8257
|
+
* @param {string} [typeValue="text"] type值
|
|
8258
|
+
*/
|
|
8259
|
+
setInputType(typeValue = "text") {
|
|
8260
|
+
this.$ele.input.setAttribute("type", typeValue);
|
|
8261
|
+
},
|
|
8262
|
+
/**
|
|
8263
|
+
* 删除图标按钮
|
|
8264
|
+
*/
|
|
8265
|
+
removeCircleIcon() {
|
|
8266
|
+
this.$ele.icon.innerHTML = "";
|
|
8267
|
+
},
|
|
8268
|
+
/**
|
|
8269
|
+
* 添加清空图标按钮
|
|
8270
|
+
* @param {string} [svgHTML=pops.config.iconSVG.circleClose] svg图标,默认为清空的图标
|
|
8271
|
+
*/
|
|
8272
|
+
setCircleIcon(svgHTML = pops.config.iconSVG.circleClose) {
|
|
8273
|
+
this.$ele.icon.innerHTML = svgHTML;
|
|
8274
|
+
},
|
|
8275
|
+
/**
|
|
8276
|
+
* 添加图标按钮的点击事件
|
|
8277
|
+
*/
|
|
8278
|
+
setCircleIconClickEvent() {
|
|
8279
|
+
popsDOMUtils.on(this.$ele.icon, "click", void 0, () => {
|
|
8280
|
+
if (this.isDisabled()) {
|
|
8281
|
+
return;
|
|
8282
|
+
}
|
|
8283
|
+
/* 删除图标 */
|
|
8284
|
+
this.removeCircleIcon();
|
|
8285
|
+
if (formConfig.isPassword) {
|
|
8286
|
+
/* 密码输入框 */
|
|
8287
|
+
if (this.$data.isView) {
|
|
8288
|
+
/* 当前可见 => 点击改变为隐藏 */
|
|
8289
|
+
this.$data.isView = false;
|
|
8290
|
+
/* 显示输入框内容,且更换图标为隐藏图标 */
|
|
8291
|
+
this.setInputType("text");
|
|
8292
|
+
this.setCircleIcon(pops.config.iconSVG.hide);
|
|
8293
|
+
}
|
|
8294
|
+
else {
|
|
8295
|
+
/* 当前不可见 => 点击改变为显示 */
|
|
8296
|
+
this.$data.isView = true;
|
|
8297
|
+
/* 隐藏输入框内容,且更换图标为显示图标 */
|
|
8298
|
+
this.setInputType("password");
|
|
8299
|
+
this.setCircleIcon(pops.config.iconSVG.view);
|
|
8300
|
+
}
|
|
8301
|
+
}
|
|
8302
|
+
else {
|
|
8303
|
+
/* 普通输入框 */
|
|
8304
|
+
/* 清空内容 */
|
|
8305
|
+
this.setInputValue("");
|
|
8306
|
+
/* 获取焦点 */
|
|
8307
|
+
this.$ele.input.focus();
|
|
8308
|
+
/* 触发内容改变事件 */
|
|
8309
|
+
this.$ele.input.dispatchEvent(new Event("input"));
|
|
8310
|
+
}
|
|
8311
|
+
});
|
|
8312
|
+
},
|
|
8313
|
+
/**
|
|
8314
|
+
* 监听输入框内容改变
|
|
8315
|
+
*/
|
|
8316
|
+
setInputChangeEvent() {
|
|
8317
|
+
popsDOMUtils.on(this.$ele.input, ["input", "propertychange"], void 0, (event) => {
|
|
8318
|
+
this.$data.value = this.$ele.input.value;
|
|
8319
|
+
if (!formConfig.isPassword) {
|
|
8320
|
+
/* 不是密码框 */
|
|
8321
|
+
if (this.$ele.input.value !== "" &&
|
|
8322
|
+
this.$ele.icon.innerHTML === "") {
|
|
8323
|
+
/* 不为空,显示清空图标 */
|
|
8324
|
+
this.setCircleIcon(pops.config.iconSVG.circleClose);
|
|
8325
|
+
this.setCircleIconClickEvent();
|
|
8326
|
+
}
|
|
8327
|
+
else if (this.$ele.input.value === "") {
|
|
8328
|
+
this.removeCircleIcon();
|
|
8329
|
+
}
|
|
8330
|
+
}
|
|
8331
|
+
if (typeof formConfig.callback === "function") {
|
|
8332
|
+
if (formConfig.isNumber) {
|
|
8333
|
+
formConfig.callback(event, this.$ele.input.value, this.$ele.input.valueAsNumber);
|
|
8334
|
+
}
|
|
8335
|
+
else {
|
|
8336
|
+
formConfig.callback(event, this.$ele.input.value);
|
|
8337
|
+
}
|
|
8338
|
+
}
|
|
8339
|
+
});
|
|
8340
|
+
},
|
|
8341
|
+
};
|
|
8342
|
+
PopsPanelInput.init();
|
|
8343
|
+
liElement["data-input"] = PopsPanelInput;
|
|
8344
|
+
return liElement;
|
|
8345
|
+
},
|
|
8346
|
+
/**
|
|
8347
|
+
* 获取中间容器的元素<li>
|
|
8348
|
+
* type ==> textarea
|
|
8349
|
+
* @param formConfig
|
|
8350
|
+
*/
|
|
8351
|
+
getSectionContainerItem_textarea(formConfig) {
|
|
8352
|
+
let liElement = document.createElement("li");
|
|
8353
|
+
liElement["__formConfig__"] = formConfig;
|
|
8354
|
+
if (formConfig.className) {
|
|
8355
|
+
liElement.className = formConfig.className;
|
|
8356
|
+
}
|
|
8357
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
8358
|
+
this.setElementProps(liElement, formConfig.props);
|
|
8359
|
+
/* 左边底部的描述的文字 */
|
|
8360
|
+
let leftDescriptionText = "";
|
|
8361
|
+
if (Boolean(formConfig.description)) {
|
|
8362
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
8363
|
+
}
|
|
8364
|
+
liElement.innerHTML = `
|
|
8365
|
+
<div class="pops-panel-item-left-text">
|
|
8366
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
8367
|
+
${leftDescriptionText}
|
|
8368
|
+
</div>
|
|
8369
|
+
<div class="pops-panel-textarea">
|
|
8370
|
+
<textarea placeholder="${formConfig.placeholder ?? ""}">
|
|
8371
|
+
</textarea>
|
|
8372
|
+
</div>
|
|
8373
|
+
`;
|
|
8374
|
+
const PopsPanelTextArea = {
|
|
8375
|
+
[Symbol.toStringTag]: "PopsPanelTextArea",
|
|
8376
|
+
$ele: {
|
|
8377
|
+
panelTextarea: liElement.querySelector(".pops-panel-textarea"),
|
|
8378
|
+
textarea: liElement.querySelector(".pops-panel-textarea textarea"),
|
|
8379
|
+
},
|
|
8380
|
+
$data: {
|
|
8381
|
+
value: formConfig.getValue(),
|
|
8382
|
+
},
|
|
8383
|
+
init() {
|
|
8384
|
+
this.setValue(this.$data.value);
|
|
8385
|
+
this.setChangeEvent();
|
|
8386
|
+
if (formConfig.disabled) {
|
|
8387
|
+
this.disable();
|
|
8657
8388
|
}
|
|
8658
|
-
}
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8389
|
+
},
|
|
8390
|
+
disable() {
|
|
8391
|
+
this.$ele.textarea.setAttribute("disabled", "true");
|
|
8392
|
+
this.$ele.panelTextarea.classList.add("pops-panel-textarea-disable");
|
|
8393
|
+
},
|
|
8394
|
+
notDisable() {
|
|
8395
|
+
this.$ele.textarea.removeAttribute("disabled");
|
|
8396
|
+
this.$ele.panelTextarea.classList.remove("pops-panel-textarea-disable");
|
|
8397
|
+
},
|
|
8398
|
+
isDisabled() {
|
|
8399
|
+
return (this.$ele.textarea.hasAttribute("disabled") ||
|
|
8400
|
+
this.$ele.panelTextarea.classList.contains("pops-panel-textarea-disable"));
|
|
8401
|
+
},
|
|
8402
|
+
setValue(value) {
|
|
8403
|
+
this.$ele.textarea.value = value;
|
|
8404
|
+
},
|
|
8405
|
+
/**
|
|
8406
|
+
* 监听选择内容改变
|
|
8407
|
+
*/
|
|
8408
|
+
setChangeEvent() {
|
|
8409
|
+
popsDOMUtils.on(this.$ele.textarea, ["input", "propertychange"], void 0, (event) => {
|
|
8410
|
+
this.$data.value = event.target.value;
|
|
8411
|
+
if (typeof formConfig.callback === "function") {
|
|
8412
|
+
formConfig.callback(event, event.target.value);
|
|
8413
|
+
}
|
|
8414
|
+
});
|
|
8415
|
+
},
|
|
8416
|
+
};
|
|
8417
|
+
PopsPanelTextArea.init();
|
|
8418
|
+
liElement["data-textarea"] = PopsPanelTextArea;
|
|
8419
|
+
return liElement;
|
|
8420
|
+
},
|
|
8421
|
+
/**
|
|
8422
|
+
* 获取中间容器的元素<li>
|
|
8423
|
+
* type ==> select
|
|
8424
|
+
* @param formConfig
|
|
8425
|
+
*/
|
|
8426
|
+
getSectionContainerItem_select(formConfig) {
|
|
8427
|
+
let liElement = document.createElement("li");
|
|
8428
|
+
liElement["__formConfig__"] = formConfig;
|
|
8429
|
+
if (formConfig.className) {
|
|
8430
|
+
liElement.className = formConfig.className;
|
|
8431
|
+
}
|
|
8432
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
8433
|
+
this.setElementProps(liElement, formConfig.props);
|
|
8434
|
+
/* 左边底部的描述的文字 */
|
|
8435
|
+
let leftDescriptionText = "";
|
|
8436
|
+
if (Boolean(formConfig.description)) {
|
|
8437
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
8438
|
+
}
|
|
8439
|
+
liElement.innerHTML = /*html*/ `
|
|
8440
|
+
<div class="pops-panel-item-left-text">
|
|
8441
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
8442
|
+
${leftDescriptionText}
|
|
8443
|
+
</div>
|
|
8444
|
+
<div class="pops-panel-select">
|
|
8445
|
+
<select></select>
|
|
8446
|
+
</div>
|
|
8447
|
+
`;
|
|
8448
|
+
const PopsPanelSelect = {
|
|
8449
|
+
[Symbol.toStringTag]: "PopsPanelSelect",
|
|
8450
|
+
$ele: {
|
|
8451
|
+
panelSelect: liElement.querySelector(".pops-panel-select"),
|
|
8452
|
+
select: liElement.querySelector(".pops-panel-select select"),
|
|
8453
|
+
},
|
|
8454
|
+
$eleKey: {
|
|
8455
|
+
disable: "__disable__",
|
|
8456
|
+
value: "__value__",
|
|
8457
|
+
},
|
|
8458
|
+
$data: {
|
|
8459
|
+
defaultValue: formConfig.getValue(),
|
|
8460
|
+
},
|
|
8461
|
+
init() {
|
|
8462
|
+
this.initOption();
|
|
8463
|
+
this.setChangeEvent();
|
|
8464
|
+
this.setClickEvent();
|
|
8465
|
+
if (formConfig.disabled) {
|
|
8466
|
+
this.disable();
|
|
8684
8467
|
}
|
|
8685
|
-
}
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8468
|
+
},
|
|
8469
|
+
/**
|
|
8470
|
+
* 给option元素设置属性
|
|
8471
|
+
* @param $ele
|
|
8472
|
+
* @param key
|
|
8473
|
+
* @param value
|
|
8474
|
+
*/
|
|
8475
|
+
setNodeValue($ele, key, value) {
|
|
8476
|
+
Reflect.set($ele, key, value);
|
|
8477
|
+
},
|
|
8478
|
+
/**
|
|
8479
|
+
* 获取option元素上设置的属性
|
|
8480
|
+
* @param $ele
|
|
8481
|
+
* @param value
|
|
8482
|
+
* @param key
|
|
8483
|
+
*/
|
|
8484
|
+
getNodeValue($ele, key) {
|
|
8485
|
+
return Reflect.get($ele, key);
|
|
8486
|
+
},
|
|
8487
|
+
disable() {
|
|
8488
|
+
this.$ele.select.setAttribute("disabled", "true");
|
|
8489
|
+
this.$ele.panelSelect.classList.add("pops-panel-select-disable");
|
|
8490
|
+
},
|
|
8491
|
+
notDisable() {
|
|
8492
|
+
this.$ele.select.removeAttribute("disabled");
|
|
8493
|
+
this.$ele.panelSelect.classList.remove("pops-panel-select-disable");
|
|
8494
|
+
},
|
|
8495
|
+
isDisabled() {
|
|
8496
|
+
return (this.$ele.select.hasAttribute("disabled") ||
|
|
8497
|
+
this.$ele.panelSelect.classList.contains("pops-panel-select-disable"));
|
|
8498
|
+
},
|
|
8499
|
+
initOption() {
|
|
8500
|
+
formConfig.data.forEach((dataItem) => {
|
|
8501
|
+
// 初始化默认选中
|
|
8502
|
+
let optionElement = document.createElement("option");
|
|
8503
|
+
this.setNodeValue(optionElement, this.$eleKey.value, dataItem.value);
|
|
8504
|
+
this.setNodeValue(optionElement, this.$eleKey.disable, dataItem.disable);
|
|
8505
|
+
if (dataItem.value === this.$data.defaultValue) {
|
|
8506
|
+
optionElement.setAttribute("selected", "true");
|
|
8507
|
+
}
|
|
8508
|
+
optionElement.innerText = dataItem.text;
|
|
8509
|
+
this.$ele.select.appendChild(optionElement);
|
|
8510
|
+
});
|
|
8511
|
+
},
|
|
8512
|
+
/** 检测所有option并设置禁用状态 */
|
|
8513
|
+
setSelectOptionsDisableStatus() {
|
|
8514
|
+
if (this.$ele.select.options && this.$ele.select.options.length) {
|
|
8515
|
+
Array.from(this.$ele.select.options).forEach((optionItem) => {
|
|
8516
|
+
this.setOptionDisableStatus(optionItem);
|
|
8708
8517
|
});
|
|
8709
8518
|
}
|
|
8710
|
-
}
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
const $selectedItem = popsDOMUtils.createElement("div", {
|
|
8719
|
-
className: "el-select__selected-item el-select__choose_tag",
|
|
8720
|
-
innerHTML: /*html*/ `
|
|
8721
|
-
<span class="el-tag is-closable el-tag--info el-tag--default el-tag--light">
|
|
8722
|
-
<span class="el-tag__content">
|
|
8723
|
-
<span class="el-select__tags-text"></span>
|
|
8724
|
-
</span>
|
|
8725
|
-
<!-- 关闭tag的图标 -->
|
|
8726
|
-
<i class="el-icon el-tag__close">
|
|
8727
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
8728
|
-
<path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path>
|
|
8729
|
-
</svg>
|
|
8730
|
-
</i>
|
|
8731
|
-
</span>
|
|
8732
|
-
`,
|
|
8733
|
-
});
|
|
8734
|
-
/** 标签 */
|
|
8735
|
-
const $tagText = $selectedItem.querySelector(".el-select__tags-text");
|
|
8736
|
-
/** 关闭图标 */
|
|
8737
|
-
const $closeIcon = $selectedItem.querySelector(".el-icon.el-tag__close");
|
|
8738
|
-
if (data.isHTML) {
|
|
8739
|
-
$tagText.innerHTML = data.text;
|
|
8740
|
-
}
|
|
8741
|
-
else {
|
|
8742
|
-
$tagText.innerText = data.text;
|
|
8743
|
-
}
|
|
8744
|
-
return {
|
|
8745
|
-
$tag: $selectedItem,
|
|
8746
|
-
$tagText: $tagText,
|
|
8747
|
-
$closeIcon: $closeIcon,
|
|
8748
|
-
};
|
|
8749
|
-
},
|
|
8750
|
-
/**
|
|
8751
|
-
* 添加选中项元素
|
|
8752
|
-
*/
|
|
8753
|
-
addSelectedItem($ele) {
|
|
8754
|
-
// 往前添加
|
|
8755
|
-
// 去除前面的空白
|
|
8756
|
-
this.setSectionIsNear();
|
|
8757
|
-
if (this.$el.$section.contains(this.$el.$selectedInputWrapper)) {
|
|
8758
|
-
let $prev = this.$el.$selectedInputWrapper.previousElementSibling;
|
|
8759
|
-
if ($prev) {
|
|
8760
|
-
// 存在前一个元素,添加到前面的元素的后面
|
|
8761
|
-
popsDOMUtils.after($prev, $ele);
|
|
8762
|
-
}
|
|
8763
|
-
else {
|
|
8764
|
-
// 不存在前一个元素,添加到最前面
|
|
8765
|
-
popsDOMUtils.before(this.$el.$selectedInputWrapper, $ele);
|
|
8519
|
+
},
|
|
8520
|
+
/** 设置禁用状态 */
|
|
8521
|
+
setOptionDisableStatus(optionElement) {
|
|
8522
|
+
let disable = false;
|
|
8523
|
+
let optionDisableAttr = this.getNodeValue(optionElement, this.$eleKey.disable);
|
|
8524
|
+
if (optionDisableAttr === "function") {
|
|
8525
|
+
let value = this.getNodeValue(optionElement, this.$eleKey.value);
|
|
8526
|
+
disable = Boolean(optionDisableAttr(value));
|
|
8766
8527
|
}
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
let $prev = this.$el.$selectedPlaceHolderWrapper.previousElementSibling;
|
|
8770
|
-
if ($prev) {
|
|
8771
|
-
// 存在前一个元素,添加到前面的元素的后面
|
|
8772
|
-
popsDOMUtils.after($prev, $ele);
|
|
8528
|
+
if (disable) {
|
|
8529
|
+
optionElement.setAttribute("disabled", "true");
|
|
8773
8530
|
}
|
|
8774
8531
|
else {
|
|
8775
|
-
|
|
8776
|
-
popsDOMUtils.before(this.$el.$selectedPlaceHolderWrapper, $ele);
|
|
8532
|
+
optionElement.removeAttribute("disabled");
|
|
8777
8533
|
}
|
|
8778
|
-
}
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8534
|
+
},
|
|
8535
|
+
/** 获取option上的信息 */
|
|
8536
|
+
getSelectOptionInfo($option) {
|
|
8537
|
+
let optionValue = this.getNodeValue($option, this.$eleKey.value);
|
|
8538
|
+
let optionText = $option.innerText || $option.textContent;
|
|
8539
|
+
return {
|
|
8540
|
+
value: optionValue,
|
|
8541
|
+
text: optionText,
|
|
8542
|
+
$option: $option,
|
|
8543
|
+
};
|
|
8544
|
+
},
|
|
8545
|
+
/**
|
|
8546
|
+
* 监听选择内容改变
|
|
8547
|
+
*/
|
|
8548
|
+
setChangeEvent() {
|
|
8549
|
+
popsDOMUtils.on(this.$ele.select, "change", void 0, (event) => {
|
|
8550
|
+
this.setSelectOptionsDisableStatus();
|
|
8551
|
+
if (typeof formConfig.callback === "function") {
|
|
8552
|
+
let $isSelectedElement = event.target[event.target.selectedIndex];
|
|
8553
|
+
let selectInfo = this.getSelectOptionInfo($isSelectedElement);
|
|
8554
|
+
formConfig.callback(event, selectInfo.value, selectInfo.text);
|
|
8555
|
+
}
|
|
8556
|
+
});
|
|
8557
|
+
},
|
|
8558
|
+
/**
|
|
8559
|
+
* 监听点击事件
|
|
8560
|
+
*/
|
|
8561
|
+
setClickEvent() {
|
|
8562
|
+
popsDOMUtils.on(this.$ele.select, "click", void 0, (event) => {
|
|
8563
|
+
this.setSelectOptionsDisableStatus();
|
|
8564
|
+
if (typeof formConfig.clickCallBack === "function") {
|
|
8565
|
+
formConfig.clickCallBack(event, this.$ele.select);
|
|
8566
|
+
}
|
|
8567
|
+
});
|
|
8568
|
+
},
|
|
8569
|
+
};
|
|
8570
|
+
PopsPanelSelect.init();
|
|
8571
|
+
Reflect.set(liElement, "data-select", PopsPanelSelect);
|
|
8572
|
+
return liElement;
|
|
8573
|
+
},
|
|
8574
|
+
/**
|
|
8575
|
+
* 获取中间容器的元素<li>
|
|
8576
|
+
* type ==> select-multiple
|
|
8577
|
+
* @param formConfig
|
|
8578
|
+
*/
|
|
8579
|
+
getSectionContainerItem_select_multiple_new(formConfig) {
|
|
8580
|
+
let liElement = document.createElement("li");
|
|
8581
|
+
Reflect.set(liElement, "__formConfig__", formConfig);
|
|
8582
|
+
if (formConfig.className) {
|
|
8583
|
+
liElement.className = formConfig.className;
|
|
8584
|
+
}
|
|
8585
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
8586
|
+
this.setElementProps(liElement, formConfig.props);
|
|
8587
|
+
/* 左边底部的描述的文字 */
|
|
8588
|
+
let leftDescriptionText = "";
|
|
8589
|
+
if (Boolean(formConfig.description)) {
|
|
8590
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
8591
|
+
}
|
|
8592
|
+
liElement.innerHTML = /*html*/ `
|
|
8593
|
+
<div class="pops-panel-item-left-text">
|
|
8594
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
8595
|
+
${leftDescriptionText}
|
|
8596
|
+
</div>
|
|
8597
|
+
<div class="pops-panel-select-multiple">
|
|
8598
|
+
<div class="el-select__wrapper">
|
|
8599
|
+
<div class="el-select__selection">
|
|
8600
|
+
<!-- 这个是用于手动输入的,这里暂不适配 -->
|
|
8601
|
+
<div class="el-select__selected-item el-select__input-wrapper">
|
|
8602
|
+
|
|
8603
|
+
</div>
|
|
8604
|
+
<!-- 这个是placeholder -->
|
|
8605
|
+
<div class="el-select__selected-item el-select__placeholder">
|
|
8606
|
+
</div>
|
|
8607
|
+
</div>
|
|
8608
|
+
<!-- 下拉箭头 -->
|
|
8609
|
+
<div class="el-select__suffix">
|
|
8610
|
+
<i class="el-icon el-select__caret el-select__icon">
|
|
8611
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
8612
|
+
<path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>
|
|
8613
|
+
</svg>
|
|
8614
|
+
</i>
|
|
8615
|
+
</div>
|
|
8616
|
+
</div>
|
|
8617
|
+
</div>
|
|
8618
|
+
`;
|
|
8619
|
+
const PopsPanelSelectMultiple = {
|
|
8620
|
+
[Symbol.toStringTag]: "PopsPanelSelectMultiple",
|
|
8621
|
+
$el: {
|
|
8622
|
+
/** 容器 */
|
|
8623
|
+
$container: void 0,
|
|
8624
|
+
/** 包括的容器 */
|
|
8625
|
+
$wrapper: void 0,
|
|
8626
|
+
/** 内容区域 */
|
|
8627
|
+
$section: void 0,
|
|
8628
|
+
/** 手动输入 */
|
|
8629
|
+
$selectedInputWrapper: void 0,
|
|
8630
|
+
/** 灰色提示语 */
|
|
8631
|
+
$selectedPlaceHolderWrapper: void 0,
|
|
8632
|
+
/** 下拉箭头区域 */
|
|
8633
|
+
$suffix: void 0,
|
|
8634
|
+
/** 下拉箭头图标 */
|
|
8635
|
+
$suffixIcon: void 0,
|
|
8636
|
+
},
|
|
8637
|
+
$data: {
|
|
8638
|
+
/** 默认值 */
|
|
8639
|
+
defaultValue: formConfig.getValue(),
|
|
8640
|
+
selectInfo: [],
|
|
8641
|
+
},
|
|
8642
|
+
/** 初始化 */
|
|
8643
|
+
init() {
|
|
8644
|
+
this.initDefault();
|
|
8645
|
+
this.inintEl();
|
|
8646
|
+
this.initPlaceHolder();
|
|
8647
|
+
this.updateTagElement();
|
|
8648
|
+
this.setSelectContainerClickEvent();
|
|
8649
|
+
},
|
|
8650
|
+
/** 初始化默认值 */
|
|
8651
|
+
initDefault() {
|
|
8652
|
+
formConfig.data.forEach((dataItem) => {
|
|
8653
|
+
if (this.$data.defaultValue.includes(dataItem.value)) {
|
|
8654
|
+
// 初始化选中的配置
|
|
8655
|
+
this.$data.selectInfo.push({
|
|
8656
|
+
text: dataItem.text,
|
|
8657
|
+
value: dataItem.value,
|
|
8658
|
+
isHTML: Boolean(dataItem.isHTML),
|
|
8659
|
+
disable: dataItem.disable,
|
|
8660
|
+
});
|
|
8661
|
+
}
|
|
8662
|
+
});
|
|
8663
|
+
},
|
|
8664
|
+
/** 初始化$el变量 */
|
|
8665
|
+
inintEl() {
|
|
8666
|
+
this.$el.$container = liElement.querySelector(".pops-panel-select-multiple");
|
|
8667
|
+
this.$el.$wrapper = liElement.querySelector(".el-select__wrapper");
|
|
8668
|
+
this.$el.$section = liElement.querySelector(".el-select__selection");
|
|
8669
|
+
this.$el.$selectedInputWrapper = liElement.querySelector(".el-select__selected-item.el-select__input-wrapper");
|
|
8670
|
+
this.$el.$selectedPlaceHolderWrapper =
|
|
8671
|
+
liElement.querySelector(".el-select__selected-item.el-select__placeholder");
|
|
8672
|
+
this.$el.$suffix =
|
|
8673
|
+
liElement.querySelector(".el-select__suffix");
|
|
8674
|
+
this.$el.$suffixIcon = liElement.querySelector(".el-select__suffix .el-icon");
|
|
8675
|
+
// 先把手动输入框隐藏
|
|
8676
|
+
this.hideInputWrapper();
|
|
8677
|
+
},
|
|
8678
|
+
/** 初始化提示文字 */
|
|
8679
|
+
initPlaceHolder() {
|
|
8680
|
+
let placeholder = "";
|
|
8681
|
+
if (typeof formConfig.placeholder === "string") {
|
|
8682
|
+
placeholder = formConfig.placeholder;
|
|
8817
8683
|
}
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
$ele.classList.remove("select-item-is-selected");
|
|
8684
|
+
else if (typeof formConfig.placeholder === "function") {
|
|
8685
|
+
let placeholderResult = formConfig.placeholder();
|
|
8686
|
+
if (typeof placeholderResult === "string") {
|
|
8687
|
+
placeholder = placeholderResult;
|
|
8688
|
+
}
|
|
8824
8689
|
}
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8690
|
+
let $placeholder = popsDOMUtils.createElement("span", {
|
|
8691
|
+
innerText: placeholder,
|
|
8692
|
+
});
|
|
8693
|
+
this.$el.$selectedPlaceHolderWrapper.appendChild($placeholder);
|
|
8694
|
+
},
|
|
8695
|
+
/** 初始化tag */
|
|
8696
|
+
updateTagElement() {
|
|
8697
|
+
// 遍历数据,寻找对应的值
|
|
8698
|
+
formConfig.data.forEach((dataItem) => {
|
|
8699
|
+
let findValue = this.$data.selectInfo.find((item) => item.value === dataItem.value);
|
|
8700
|
+
if (findValue) {
|
|
8701
|
+
// 选中的值和获取的所有的值相同
|
|
8702
|
+
let selectedInfo = this.createSelectedItem({
|
|
8703
|
+
text: dataItem.text,
|
|
8704
|
+
isHTML: dataItem.isHTML,
|
|
8705
|
+
});
|
|
8706
|
+
this.addSelectedItem(selectedInfo.$tag);
|
|
8707
|
+
this.setSelectedItemCloseIconClickEvent({
|
|
8708
|
+
$tag: selectedInfo.$tag,
|
|
8709
|
+
$closeIcon: selectedInfo.$closeIcon,
|
|
8710
|
+
value: dataItem.value,
|
|
8711
|
+
text: dataItem.text,
|
|
8837
8712
|
});
|
|
8838
8713
|
}
|
|
8839
|
-
|
|
8714
|
+
});
|
|
8715
|
+
this.checkTagEmpty();
|
|
8716
|
+
},
|
|
8717
|
+
/**
|
|
8718
|
+
* 生成一个tag项
|
|
8719
|
+
* @param data 配置
|
|
8720
|
+
*/
|
|
8721
|
+
createSelectedItem(data) {
|
|
8722
|
+
const $selectedItem = popsDOMUtils.createElement("div", {
|
|
8723
|
+
className: "el-select__selected-item el-select__choose_tag",
|
|
8724
|
+
innerHTML: /*html*/ `
|
|
8725
|
+
<span class="el-tag is-closable el-tag--info el-tag--default el-tag--light">
|
|
8726
|
+
<span class="el-tag__content">
|
|
8727
|
+
<span class="el-select__tags-text"></span>
|
|
8728
|
+
</span>
|
|
8729
|
+
<!-- 关闭tag的图标 -->
|
|
8730
|
+
<i class="el-icon el-tag__close">
|
|
8731
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
8732
|
+
<path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path>
|
|
8733
|
+
</svg>
|
|
8734
|
+
</i>
|
|
8735
|
+
</span>
|
|
8736
|
+
`,
|
|
8737
|
+
});
|
|
8738
|
+
/** 标签 */
|
|
8739
|
+
const $tagText = $selectedItem.querySelector(".el-select__tags-text");
|
|
8740
|
+
/** 关闭图标 */
|
|
8741
|
+
const $closeIcon = $selectedItem.querySelector(".el-icon.el-tag__close");
|
|
8742
|
+
if (data.isHTML) {
|
|
8743
|
+
$tagText.innerHTML = data.text;
|
|
8840
8744
|
}
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
*/
|
|
8844
|
-
function removeSelectedInfo($ele) {
|
|
8845
|
-
let info = getSelectedInfo($ele);
|
|
8846
|
-
let findIndex = selectedInfo.findIndex((item) => item.value === info.value);
|
|
8847
|
-
if (findIndex !== -1) {
|
|
8848
|
-
selectedInfo.splice(findIndex, 1);
|
|
8849
|
-
}
|
|
8850
|
-
that.selectValueChangeCallBack(selectedInfo);
|
|
8745
|
+
else {
|
|
8746
|
+
$tagText.innerText = data.text;
|
|
8851
8747
|
}
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8748
|
+
return {
|
|
8749
|
+
$tag: $selectedItem,
|
|
8750
|
+
$tagText: $tagText,
|
|
8751
|
+
$closeIcon: $closeIcon,
|
|
8752
|
+
};
|
|
8753
|
+
},
|
|
8754
|
+
/**
|
|
8755
|
+
* 添加选中项元素
|
|
8756
|
+
*/
|
|
8757
|
+
addSelectedItem($ele) {
|
|
8758
|
+
// 往前添加
|
|
8759
|
+
// 去除前面的空白
|
|
8760
|
+
this.setSectionIsNear();
|
|
8761
|
+
if (this.$el.$section.contains(this.$el.$selectedInputWrapper)) {
|
|
8762
|
+
let $prev = this.$el.$selectedInputWrapper.previousElementSibling;
|
|
8763
|
+
if ($prev) {
|
|
8764
|
+
// 存在前一个元素,添加到前面的元素的后面
|
|
8765
|
+
popsDOMUtils.after($prev, $ele);
|
|
8766
|
+
}
|
|
8767
|
+
else {
|
|
8768
|
+
// 不存在前一个元素,添加到最前面
|
|
8769
|
+
popsDOMUtils.before(this.$el.$selectedInputWrapper, $ele);
|
|
8770
|
+
}
|
|
8858
8771
|
}
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8772
|
+
else if (this.$el.$section.contains(this.$el.$selectedPlaceHolderWrapper)) {
|
|
8773
|
+
let $prev = this.$el.$selectedPlaceHolderWrapper.previousElementSibling;
|
|
8774
|
+
if ($prev) {
|
|
8775
|
+
// 存在前一个元素,添加到前面的元素的后面
|
|
8776
|
+
popsDOMUtils.after($prev, $ele);
|
|
8777
|
+
}
|
|
8778
|
+
else {
|
|
8779
|
+
// 不存在前一个元素,添加到最前面
|
|
8780
|
+
popsDOMUtils.before(this.$el.$selectedPlaceHolderWrapper, $ele);
|
|
8781
|
+
}
|
|
8864
8782
|
}
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
*/
|
|
8868
|
-
function getAllSelectedInfo() {
|
|
8869
|
-
return Array.from($selectContainer.querySelectorAll(".select-item"))
|
|
8870
|
-
.map(($ele) => {
|
|
8871
|
-
if (isSelected($ele)) {
|
|
8872
|
-
return getSelectedInfo($ele);
|
|
8873
|
-
}
|
|
8874
|
-
})
|
|
8875
|
-
.filter((item) => {
|
|
8876
|
-
return item != null;
|
|
8877
|
-
});
|
|
8783
|
+
else {
|
|
8784
|
+
this.$el.$section.appendChild($ele);
|
|
8878
8785
|
}
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8786
|
+
// 隐藏元素
|
|
8787
|
+
this.hideInputWrapper();
|
|
8788
|
+
this.hidePlaceHolderWrapper();
|
|
8789
|
+
},
|
|
8790
|
+
/** 更新tag信息 */
|
|
8791
|
+
updateSelectTagItem() {
|
|
8792
|
+
this.$el.$section
|
|
8793
|
+
.querySelectorAll(".el-select__choose_tag")
|
|
8794
|
+
.forEach(($ele) => {
|
|
8795
|
+
$ele.remove();
|
|
8796
|
+
});
|
|
8797
|
+
this.updateTagElement();
|
|
8798
|
+
},
|
|
8799
|
+
/**
|
|
8800
|
+
* 选中的值改变的回调
|
|
8801
|
+
* @param currentSelectInfo 当前的选中信息
|
|
8802
|
+
*/
|
|
8803
|
+
selectValueChangeCallBack(currentSelectInfo) {
|
|
8804
|
+
if (typeof formConfig.callback === "function") {
|
|
8805
|
+
formConfig.callback(currentSelectInfo || this.$data.selectInfo);
|
|
8891
8806
|
}
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8807
|
+
},
|
|
8808
|
+
/** 设置下拉列表的点击事件 */
|
|
8809
|
+
setSelectContainerClickEvent() {
|
|
8810
|
+
const that = this;
|
|
8811
|
+
popsDOMUtils.on(this.$el.$container, "click", (event) => {
|
|
8812
|
+
/** 弹窗的选中的值 */
|
|
8813
|
+
let selectedInfo = [];
|
|
8814
|
+
selectedInfo = selectedInfo.concat(that.$data.selectInfo);
|
|
8815
|
+
/**
|
|
8816
|
+
* 设置项选中
|
|
8817
|
+
* @param $ele
|
|
8818
|
+
*/
|
|
8819
|
+
function setItemSelected($ele) {
|
|
8820
|
+
$ele.classList.add("select-item-is-selected");
|
|
8821
|
+
}
|
|
8822
|
+
/**
|
|
8823
|
+
* 设置项取消选中
|
|
8824
|
+
* @param $ele
|
|
8825
|
+
*/
|
|
8826
|
+
function removeItemSelected($ele) {
|
|
8827
|
+
$ele.classList.remove("select-item-is-selected");
|
|
8828
|
+
}
|
|
8829
|
+
/**
|
|
8830
|
+
* 添加选中信息
|
|
8831
|
+
*/
|
|
8832
|
+
function addSelectedInfo($ele) {
|
|
8833
|
+
let info = getSelectedInfo($ele);
|
|
8834
|
+
let findValue = selectedInfo.find((item) => item.value === info.value);
|
|
8835
|
+
if (!findValue) {
|
|
8836
|
+
selectedInfo.push({
|
|
8837
|
+
value: info.value,
|
|
8838
|
+
text: info.text,
|
|
8839
|
+
isHTML: Boolean(info.isHTML),
|
|
8840
|
+
disable: info.disable,
|
|
8841
|
+
});
|
|
8908
8842
|
}
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8843
|
+
that.selectValueChangeCallBack(selectedInfo);
|
|
8844
|
+
}
|
|
8845
|
+
/**
|
|
8846
|
+
* 移除选中信息
|
|
8847
|
+
*/
|
|
8848
|
+
function removeSelectedInfo($ele) {
|
|
8849
|
+
let info = getSelectedInfo($ele);
|
|
8850
|
+
let findIndex = selectedInfo.findIndex((item) => item.value === info.value);
|
|
8851
|
+
if (findIndex !== -1) {
|
|
8852
|
+
selectedInfo.splice(findIndex, 1);
|
|
8912
8853
|
}
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8854
|
+
that.selectValueChangeCallBack(selectedInfo);
|
|
8855
|
+
}
|
|
8856
|
+
/**
|
|
8857
|
+
* 判断该项是否选中
|
|
8858
|
+
* @param $ele
|
|
8859
|
+
*/
|
|
8860
|
+
function isSelected($ele) {
|
|
8861
|
+
return $ele.classList.contains("select-item-is-selected");
|
|
8862
|
+
}
|
|
8863
|
+
/**
|
|
8864
|
+
* 获取选中的项的信息
|
|
8865
|
+
*/
|
|
8866
|
+
function getSelectedInfo($ele) {
|
|
8867
|
+
return Reflect.get($ele, "data-info");
|
|
8868
|
+
}
|
|
8869
|
+
/**
|
|
8870
|
+
* 获取所有选中的项的信息
|
|
8871
|
+
*/
|
|
8872
|
+
function getAllSelectedInfo() {
|
|
8873
|
+
return Array.from($selectContainer.querySelectorAll(".select-item"))
|
|
8874
|
+
.map(($ele) => {
|
|
8875
|
+
if (isSelected($ele)) {
|
|
8876
|
+
return getSelectedInfo($ele);
|
|
8877
|
+
}
|
|
8878
|
+
})
|
|
8879
|
+
.filter((item) => {
|
|
8880
|
+
return item != null;
|
|
8881
|
+
});
|
|
8882
|
+
}
|
|
8883
|
+
/**
|
|
8884
|
+
* 创建一个选择项元素
|
|
8885
|
+
*/
|
|
8886
|
+
function createSelectItemElement(dataInfo) {
|
|
8887
|
+
let $item = popsDOMUtils.createElement("li", {
|
|
8888
|
+
className: "select-item",
|
|
8889
|
+
innerHTML: /*html*/ `
|
|
8890
|
+
<span>${dataInfo.text}</span>
|
|
8924
8891
|
`,
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8892
|
+
});
|
|
8893
|
+
Reflect.set($item, "data-info", dataInfo);
|
|
8894
|
+
return $item;
|
|
8895
|
+
}
|
|
8896
|
+
/**
|
|
8897
|
+
* 设置选择项的点击事件
|
|
8898
|
+
*/
|
|
8899
|
+
function setSelectElementClickEvent($ele) {
|
|
8900
|
+
popsDOMUtils.on($ele, "click", (event) => {
|
|
8901
|
+
popsDOMUtils.preventEvent(event);
|
|
8902
|
+
if (typeof formConfig.clickCallBack === "function") {
|
|
8903
|
+
let clickResult = formConfig.clickCallBack(event, getAllSelectedInfo());
|
|
8904
|
+
if (typeof clickResult === "boolean" && !clickResult) {
|
|
8905
|
+
return;
|
|
8906
|
+
}
|
|
8907
|
+
}
|
|
8908
|
+
// 修改选中状态
|
|
8909
|
+
if (isSelected($ele)) {
|
|
8910
|
+
removeItemSelected($ele);
|
|
8911
|
+
removeSelectedInfo($ele);
|
|
8912
|
+
}
|
|
8913
|
+
else {
|
|
8914
|
+
setItemSelected($ele);
|
|
8915
|
+
addSelectedInfo($ele);
|
|
8916
|
+
}
|
|
8917
|
+
});
|
|
8918
|
+
}
|
|
8919
|
+
let { style, ...userConfirmDetails } = formConfig.selectConfirmDialogDetails || {};
|
|
8920
|
+
let confirmDetails = popsUtils.assign({
|
|
8921
|
+
title: {
|
|
8922
|
+
text: "请勾选需要选择的选项",
|
|
8923
|
+
position: "center",
|
|
8924
|
+
},
|
|
8925
|
+
content: {
|
|
8926
|
+
text: /*html*/ `
|
|
8927
|
+
<ul class="select-container"></ul>
|
|
8928
|
+
`,
|
|
8929
|
+
html: true,
|
|
8930
|
+
},
|
|
8931
|
+
btn: {
|
|
8932
|
+
ok: {
|
|
8933
|
+
enable: false,
|
|
8934
|
+
},
|
|
8935
|
+
close: {
|
|
8936
|
+
enable: true,
|
|
8937
|
+
callback(details, event) {
|
|
8938
|
+
that.$data.selectInfo = [...selectedInfo];
|
|
8939
|
+
that.updateSelectTagItem();
|
|
8940
|
+
details.close();
|
|
8941
|
+
},
|
|
8942
|
+
},
|
|
8930
8943
|
},
|
|
8931
|
-
|
|
8944
|
+
mask: {
|
|
8932
8945
|
enable: true,
|
|
8933
|
-
|
|
8946
|
+
clickCallBack(originalRun, config) {
|
|
8947
|
+
originalRun();
|
|
8934
8948
|
that.$data.selectInfo = [...selectedInfo];
|
|
8935
8949
|
that.updateSelectTagItem();
|
|
8936
|
-
|
|
8950
|
+
},
|
|
8951
|
+
clickEvent: {
|
|
8952
|
+
toClose: true,
|
|
8937
8953
|
},
|
|
8938
8954
|
},
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
8955
|
+
drag: true,
|
|
8956
|
+
dragLimit: true,
|
|
8957
|
+
width: "300px",
|
|
8958
|
+
height: "300px",
|
|
8959
|
+
style: /*css*/ `
|
|
8960
|
+
.select-container{
|
|
8961
|
+
--el-font-size-base: 14px;
|
|
8962
|
+
--el-text-color-regular: #606266;
|
|
8963
|
+
--el-color-primary: #409eff;
|
|
8964
|
+
--el-fill-color-light: #f5f7fa;
|
|
8965
|
+
}
|
|
8966
|
+
.select-item{
|
|
8967
|
+
cursor: pointer;
|
|
8968
|
+
cursor: pointer;
|
|
8969
|
+
font-size: var(--el-font-size-base);
|
|
8970
|
+
padding: 0 32px 0 20px;
|
|
8971
|
+
position: relative;
|
|
8972
|
+
white-space: nowrap;
|
|
8973
|
+
overflow: hidden;
|
|
8974
|
+
text-overflow: ellipsis;
|
|
8975
|
+
color: var(--el-text-color-regular);
|
|
8976
|
+
height: 34px;
|
|
8977
|
+
line-height: 34px;
|
|
8978
|
+
box-sizing: border-box;
|
|
8979
|
+
}
|
|
8980
|
+
.select-item:hover{
|
|
8981
|
+
background-color: var(--el-fill-color-light);
|
|
8982
|
+
}
|
|
8983
|
+
.select-item.select-item-is-selected{
|
|
8984
|
+
color: var(--el-color-primary);
|
|
8985
|
+
font-weight: 700;
|
|
8986
|
+
}
|
|
8987
|
+
.select-item.select-item-is-selected::after{
|
|
8988
|
+
content: "";
|
|
8989
|
+
position: absolute;
|
|
8990
|
+
top: 50%;
|
|
8991
|
+
right: 20px;
|
|
8992
|
+
border-top: none;
|
|
8993
|
+
border-right: none;
|
|
8994
|
+
background-repeat: no-repeat;
|
|
8995
|
+
background-position: center;
|
|
8996
|
+
background-color: var(--el-color-primary);
|
|
8997
|
+
mask: url("data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E") no-repeat;
|
|
8998
|
+
mask-size: 100% 100%;
|
|
8999
|
+
-webkit-mask: url("data:image/svg+xml;utf8,%3Csvg class='icon' width='200' height='200' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='currentColor' d='M406.656 706.944L195.84 496.256a32 32 0 10-45.248 45.248l256 256 512-512a32 32 0 00-45.248-45.248L406.592 706.944z'%3E%3C/path%3E%3C/svg%3E") no-repeat;
|
|
9000
|
+
-webkit-mask-size: 100% 100%;
|
|
9001
|
+
transform: translateY(-50%);
|
|
9002
|
+
width: 12px;
|
|
9003
|
+
height: 12px;
|
|
9004
|
+
}
|
|
9005
|
+
${style || ""}
|
|
9006
|
+
`,
|
|
9007
|
+
}, userConfirmDetails);
|
|
9008
|
+
let $dialog = pops.alert(confirmDetails);
|
|
9009
|
+
let $selectContainer = $dialog.$shadowRoot.querySelector(".select-container");
|
|
9010
|
+
// 配置选项元素
|
|
9011
|
+
formConfig.data.forEach((item) => {
|
|
9012
|
+
let $select = createSelectItemElement(item);
|
|
9013
|
+
// 添加到confirm中
|
|
9014
|
+
$selectContainer.appendChild($select);
|
|
9015
|
+
// 设置每一项的点击事件
|
|
9016
|
+
setSelectElementClickEvent($select);
|
|
9017
|
+
let findValue = selectedInfo.find((value) => value.value === item.value);
|
|
9018
|
+
if (findValue) {
|
|
9019
|
+
setItemSelected($select);
|
|
9020
|
+
}
|
|
9021
|
+
});
|
|
9022
|
+
});
|
|
9023
|
+
},
|
|
9024
|
+
/** 设置关闭图标的点击事件 */
|
|
9025
|
+
setSelectedItemCloseIconClickEvent(data) {
|
|
9026
|
+
popsDOMUtils.on(data.$closeIcon, "click", (event) => {
|
|
9027
|
+
popsDOMUtils.preventEvent(event);
|
|
9028
|
+
if (typeof formConfig.closeIconClickCallBack === "function") {
|
|
9029
|
+
let result = formConfig.closeIconClickCallBack(event, {
|
|
9030
|
+
$tag: data.$tag,
|
|
9031
|
+
$closeIcon: data.$closeIcon,
|
|
9032
|
+
value: data.value,
|
|
9033
|
+
text: data.text,
|
|
9034
|
+
});
|
|
9035
|
+
if (typeof result === "boolean" && !result) {
|
|
9036
|
+
return;
|
|
9037
|
+
}
|
|
9038
|
+
}
|
|
9039
|
+
this.removeSelectedItem(data.$tag);
|
|
9040
|
+
this.removeSelectedInfo({
|
|
9041
|
+
value: data.value,
|
|
9042
|
+
text: data.text,
|
|
9043
|
+
});
|
|
9044
|
+
}, {
|
|
9045
|
+
capture: true,
|
|
9046
|
+
});
|
|
9047
|
+
},
|
|
9048
|
+
/**
|
|
9049
|
+
* 检测tag是否为空,为空显示placeholder
|
|
9050
|
+
*/
|
|
9051
|
+
checkTagEmpty() {
|
|
9052
|
+
if (!this.$el.$section.querySelectorAll(".el-select__choose_tag").length) {
|
|
9053
|
+
// 没有tag了
|
|
9054
|
+
// this.showInputWrapper();
|
|
9055
|
+
this.showPlaceHolderWrapper();
|
|
9056
|
+
this.removeSectionIsNear();
|
|
9057
|
+
}
|
|
9058
|
+
},
|
|
9059
|
+
/** 移除选中项元素 */
|
|
9060
|
+
removeSelectedItem($ele) {
|
|
9061
|
+
$ele.remove();
|
|
9062
|
+
this.checkTagEmpty();
|
|
9063
|
+
},
|
|
9064
|
+
/** 移除选中的信息 */
|
|
9065
|
+
removeSelectedInfo(data) {
|
|
9066
|
+
for (let index = 0; index < this.$data.selectInfo.length; index++) {
|
|
9067
|
+
const selectInfo = this.$data.selectInfo[index];
|
|
9068
|
+
if (selectInfo.value === data.value) {
|
|
9069
|
+
this.$data.selectInfo.splice(index, 1);
|
|
9070
|
+
break;
|
|
9071
|
+
}
|
|
9072
|
+
}
|
|
9073
|
+
this.selectValueChangeCallBack();
|
|
9074
|
+
},
|
|
9075
|
+
/** 显示输入框 */
|
|
9076
|
+
showInputWrapper() {
|
|
9077
|
+
popsDOMUtils.cssShow(this.$el.$selectedInputWrapper);
|
|
9078
|
+
},
|
|
9079
|
+
/** 隐藏输入框 */
|
|
9080
|
+
hideInputWrapper() {
|
|
9081
|
+
popsDOMUtils.cssHide(this.$el.$selectedInputWrapper, true);
|
|
9082
|
+
},
|
|
9083
|
+
/** 显示palceholder */
|
|
9084
|
+
showPlaceHolderWrapper() {
|
|
9085
|
+
popsDOMUtils.cssShow(this.$el.$selectedPlaceHolderWrapper);
|
|
9086
|
+
},
|
|
9087
|
+
/** 隐藏palceholder */
|
|
9088
|
+
hidePlaceHolderWrapper() {
|
|
9089
|
+
popsDOMUtils.cssHide(this.$el.$selectedPlaceHolderWrapper, true);
|
|
9090
|
+
},
|
|
9091
|
+
/** 设置隐藏section的前面的空白 */
|
|
9092
|
+
setSectionIsNear() {
|
|
9093
|
+
this.$el.$section.classList.add("is-near");
|
|
9094
|
+
},
|
|
9095
|
+
/** 取消设置隐藏section的前面的空白 */
|
|
9096
|
+
removeSectionIsNear() {
|
|
9097
|
+
this.$el.$section.classList.remove("is-near");
|
|
9098
|
+
},
|
|
9099
|
+
};
|
|
9100
|
+
PopsPanelSelectMultiple.init();
|
|
9101
|
+
Reflect.set(liElement, "data-select-multiple", PopsPanelSelectMultiple);
|
|
9102
|
+
return liElement;
|
|
9103
|
+
},
|
|
9104
|
+
/**
|
|
9105
|
+
* 获取中间容器的元素<li>
|
|
9106
|
+
* type ==> button
|
|
9107
|
+
* @param formConfig
|
|
9108
|
+
*/
|
|
9109
|
+
getSectionContainerItem_button(formConfig) {
|
|
9110
|
+
let liElement = document.createElement("li");
|
|
9111
|
+
liElement["__formConfig__"] = formConfig;
|
|
9112
|
+
if (formConfig.className) {
|
|
9113
|
+
liElement.className = formConfig.className;
|
|
9114
|
+
}
|
|
9115
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
9116
|
+
this.setElementProps(liElement, formConfig.props);
|
|
9117
|
+
/* 左边底部的描述的文字 */
|
|
9118
|
+
let leftDescriptionText = "";
|
|
9119
|
+
if (Boolean(formConfig.description)) {
|
|
9120
|
+
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
9121
|
+
}
|
|
9122
|
+
liElement.innerHTML = /*html*/ `
|
|
9123
|
+
<div class="pops-panel-item-left-text">
|
|
9124
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
9125
|
+
${leftDescriptionText}
|
|
9126
|
+
</div>
|
|
9127
|
+
<div class="pops-panel-button">
|
|
9128
|
+
<button class="pops-panel-button_inner">
|
|
9129
|
+
<i class="pops-bottom-icon"></i>
|
|
9130
|
+
<span class="pops-panel-button-text"></span>
|
|
9131
|
+
</button>
|
|
9132
|
+
</div>
|
|
9133
|
+
`;
|
|
9134
|
+
const PopsPanelButton = {
|
|
9135
|
+
[Symbol.toStringTag]: "PopsPanelButton",
|
|
9136
|
+
$ele: {
|
|
9137
|
+
panelButton: liElement.querySelector(".pops-panel-button"),
|
|
9138
|
+
button: liElement.querySelector(".pops-panel-button .pops-panel-button_inner"),
|
|
9139
|
+
icon: liElement.querySelector(".pops-panel-button .pops-bottom-icon"),
|
|
9140
|
+
spanText: liElement.querySelector(".pops-panel-button .pops-panel-button-text"),
|
|
9141
|
+
},
|
|
9142
|
+
$data: {},
|
|
9143
|
+
init() {
|
|
9144
|
+
this.$ele.panelButton.appendChild(this.$ele.button);
|
|
9145
|
+
this.initButton();
|
|
9146
|
+
this.setClickEvent();
|
|
9147
|
+
},
|
|
9148
|
+
initButton() {
|
|
9149
|
+
if (typeof formConfig.buttonIcon === "string" &&
|
|
9150
|
+
formConfig.buttonIcon.trim() !== "") {
|
|
9151
|
+
/* 存在icon图标且不为空 */
|
|
9152
|
+
if (formConfig.buttonIcon in pops.config.iconSVG) {
|
|
9153
|
+
this.setIconSVG(pops.config.iconSVG[formConfig.buttonIcon]);
|
|
9016
9154
|
}
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
},
|
|
9020
|
-
/** 设置关闭图标的点击事件 */
|
|
9021
|
-
setSelectedItemCloseIconClickEvent(data) {
|
|
9022
|
-
popsDOMUtils.on(data.$closeIcon, "click", (event) => {
|
|
9023
|
-
popsDOMUtils.preventEvent(event);
|
|
9024
|
-
if (typeof formConfig.closeIconClickCallBack === "function") {
|
|
9025
|
-
let result = formConfig.closeIconClickCallBack(event, {
|
|
9026
|
-
$tag: data.$tag,
|
|
9027
|
-
$closeIcon: data.$closeIcon,
|
|
9028
|
-
value: data.value,
|
|
9029
|
-
text: data.text,
|
|
9030
|
-
});
|
|
9031
|
-
if (typeof result === "boolean" && !result) {
|
|
9032
|
-
return;
|
|
9155
|
+
else {
|
|
9156
|
+
this.setIconSVG(formConfig.buttonIcon);
|
|
9033
9157
|
}
|
|
9158
|
+
this.showIcon();
|
|
9034
9159
|
}
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
value: data.value,
|
|
9038
|
-
text: data.text,
|
|
9039
|
-
});
|
|
9040
|
-
}, {
|
|
9041
|
-
capture: true,
|
|
9042
|
-
});
|
|
9043
|
-
},
|
|
9044
|
-
/**
|
|
9045
|
-
* 检测tag是否为空,为空显示placeholder
|
|
9046
|
-
*/
|
|
9047
|
-
checkTagEmpty() {
|
|
9048
|
-
if (!this.$el.$section.querySelectorAll(".el-select__choose_tag").length) {
|
|
9049
|
-
// 没有tag了
|
|
9050
|
-
// this.showInputWrapper();
|
|
9051
|
-
this.showPlaceHolderWrapper();
|
|
9052
|
-
this.removeSectionIsNear();
|
|
9053
|
-
}
|
|
9054
|
-
},
|
|
9055
|
-
/** 移除选中项元素 */
|
|
9056
|
-
removeSelectedItem($ele) {
|
|
9057
|
-
$ele.remove();
|
|
9058
|
-
this.checkTagEmpty();
|
|
9059
|
-
},
|
|
9060
|
-
/** 移除选中的信息 */
|
|
9061
|
-
removeSelectedInfo(data) {
|
|
9062
|
-
for (let index = 0; index < this.$data.selectInfo.length; index++) {
|
|
9063
|
-
const selectInfo = this.$data.selectInfo[index];
|
|
9064
|
-
if (selectInfo.value === data.value) {
|
|
9065
|
-
this.$data.selectInfo.splice(index, 1);
|
|
9066
|
-
break;
|
|
9160
|
+
else {
|
|
9161
|
+
this.hideIcon();
|
|
9067
9162
|
}
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
hideInputWrapper() {
|
|
9077
|
-
popsDOMUtils.cssHide(this.$el.$selectedInputWrapper, true);
|
|
9078
|
-
},
|
|
9079
|
-
/** 显示palceholder */
|
|
9080
|
-
showPlaceHolderWrapper() {
|
|
9081
|
-
popsDOMUtils.cssShow(this.$el.$selectedPlaceHolderWrapper);
|
|
9082
|
-
},
|
|
9083
|
-
/** 隐藏palceholder */
|
|
9084
|
-
hidePlaceHolderWrapper() {
|
|
9085
|
-
popsDOMUtils.cssHide(this.$el.$selectedPlaceHolderWrapper, true);
|
|
9086
|
-
},
|
|
9087
|
-
/** 设置隐藏section的前面的空白 */
|
|
9088
|
-
setSectionIsNear() {
|
|
9089
|
-
this.$el.$section.classList.add("is-near");
|
|
9090
|
-
},
|
|
9091
|
-
/** 取消设置隐藏section的前面的空白 */
|
|
9092
|
-
removeSectionIsNear() {
|
|
9093
|
-
this.$el.$section.classList.remove("is-near");
|
|
9094
|
-
},
|
|
9095
|
-
};
|
|
9096
|
-
PopsPanelSelectMultiple.init();
|
|
9097
|
-
Reflect.set(liElement, "data-select-multiple", PopsPanelSelectMultiple);
|
|
9098
|
-
return liElement;
|
|
9099
|
-
},
|
|
9100
|
-
/**
|
|
9101
|
-
* 获取中间容器的元素<li>
|
|
9102
|
-
* type ==> button
|
|
9103
|
-
* @param formConfig
|
|
9104
|
-
*/
|
|
9105
|
-
getSectionContainerItem_button(formConfig) {
|
|
9106
|
-
let liElement = document.createElement("li");
|
|
9107
|
-
liElement["__formConfig__"] = formConfig;
|
|
9108
|
-
if (formConfig.className) {
|
|
9109
|
-
liElement.className = formConfig.className;
|
|
9110
|
-
}
|
|
9111
|
-
this.addElementAttributes(liElement, formConfig.attributes);
|
|
9112
|
-
this.setElementProps(liElement, formConfig.props);
|
|
9113
|
-
/* 左边底部的描述的文字 */
|
|
9114
|
-
let leftDescriptionText = "";
|
|
9115
|
-
if (Boolean(formConfig.description)) {
|
|
9116
|
-
leftDescriptionText = /*html*/ `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
9117
|
-
}
|
|
9118
|
-
liElement.innerHTML = /*html*/ `
|
|
9119
|
-
<div class="pops-panel-item-left-text">
|
|
9120
|
-
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
9121
|
-
${leftDescriptionText}
|
|
9122
|
-
</div>
|
|
9123
|
-
<div class="pops-panel-button">
|
|
9124
|
-
<button class="pops-panel-button_inner">
|
|
9125
|
-
<i class="pops-bottom-icon"></i>
|
|
9126
|
-
<span class="pops-panel-button-text"></span>
|
|
9127
|
-
</button>
|
|
9128
|
-
</div>
|
|
9129
|
-
`;
|
|
9130
|
-
const PopsPanelButton = {
|
|
9131
|
-
[Symbol.toStringTag]: "PopsPanelButton",
|
|
9132
|
-
$ele: {
|
|
9133
|
-
panelButton: liElement.querySelector(".pops-panel-button"),
|
|
9134
|
-
button: liElement.querySelector(".pops-panel-button .pops-panel-button_inner"),
|
|
9135
|
-
icon: liElement.querySelector(".pops-panel-button .pops-bottom-icon"),
|
|
9136
|
-
spanText: liElement.querySelector(".pops-panel-button .pops-panel-button-text"),
|
|
9137
|
-
},
|
|
9138
|
-
$data: {},
|
|
9139
|
-
init() {
|
|
9140
|
-
this.$ele.panelButton.appendChild(this.$ele.button);
|
|
9141
|
-
this.initButton();
|
|
9142
|
-
this.setClickEvent();
|
|
9143
|
-
},
|
|
9144
|
-
initButton() {
|
|
9145
|
-
if (typeof formConfig.buttonIcon === "string" &&
|
|
9146
|
-
formConfig.buttonIcon.trim() !== "") {
|
|
9147
|
-
/* 存在icon图标且不为空 */
|
|
9148
|
-
if (formConfig.buttonIcon in pops.config.iconSVG) {
|
|
9149
|
-
this.setIconSVG(pops.config.iconSVG[formConfig.buttonIcon]);
|
|
9163
|
+
/* 按钮文字 */
|
|
9164
|
+
let buttonText = formConfig.buttonText;
|
|
9165
|
+
if (typeof formConfig.buttonText === "function") {
|
|
9166
|
+
buttonText = formConfig.buttonText();
|
|
9167
|
+
}
|
|
9168
|
+
this.setButtonType(formConfig.buttonType);
|
|
9169
|
+
if (formConfig.buttonIsRightIcon) {
|
|
9170
|
+
this.setIconRight();
|
|
9150
9171
|
}
|
|
9151
9172
|
else {
|
|
9152
|
-
this.
|
|
9173
|
+
this.setIconLeft();
|
|
9153
9174
|
}
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
else {
|
|
9157
|
-
this.hideIcon();
|
|
9158
|
-
}
|
|
9159
|
-
/* 按钮文字 */
|
|
9160
|
-
let buttonText = formConfig.buttonText;
|
|
9161
|
-
if (typeof formConfig.buttonText === "function") {
|
|
9162
|
-
buttonText = formConfig.buttonText();
|
|
9163
|
-
}
|
|
9164
|
-
this.setButtonType(formConfig.buttonType);
|
|
9165
|
-
if (formConfig.buttonIsRightIcon) {
|
|
9166
|
-
this.setIconRight();
|
|
9167
|
-
}
|
|
9168
|
-
else {
|
|
9169
|
-
this.setIconLeft();
|
|
9170
|
-
}
|
|
9171
|
-
if (formConfig.disable) {
|
|
9172
|
-
this.disable();
|
|
9173
|
-
}
|
|
9174
|
-
this.setButtonText(buttonText);
|
|
9175
|
-
this.setIconLoadingStatus(formConfig.buttonIconIsLoading);
|
|
9176
|
-
},
|
|
9177
|
-
disable() {
|
|
9178
|
-
this.$ele.button.setAttribute("disabled", "true");
|
|
9179
|
-
},
|
|
9180
|
-
notDisable() {
|
|
9181
|
-
this.$ele.button.removeAttribute("disabled");
|
|
9182
|
-
},
|
|
9183
|
-
/**
|
|
9184
|
-
* 隐藏icon图标
|
|
9185
|
-
*/
|
|
9186
|
-
hideIcon() {
|
|
9187
|
-
this.$ele.panelButton.classList.add("pops-panel-button-no-icon");
|
|
9188
|
-
},
|
|
9189
|
-
/**
|
|
9190
|
-
* 显示icon图标
|
|
9191
|
-
*/
|
|
9192
|
-
showIcon() {
|
|
9193
|
-
this.$ele.panelButton.classList.remove("pops-panel-button-no-icon");
|
|
9194
|
-
},
|
|
9195
|
-
/**
|
|
9196
|
-
* 设置icon图标的svg
|
|
9197
|
-
*/
|
|
9198
|
-
setIconSVG(svgHTML) {
|
|
9199
|
-
this.$ele.icon.innerHTML = svgHTML;
|
|
9200
|
-
},
|
|
9201
|
-
/**
|
|
9202
|
-
* 设置icon图标是否旋转
|
|
9203
|
-
* @param status
|
|
9204
|
-
*/
|
|
9205
|
-
setIconLoadingStatus(status) {
|
|
9206
|
-
this.$ele.icon.setAttribute("is-loading", Boolean(status).toString());
|
|
9207
|
-
},
|
|
9208
|
-
/**
|
|
9209
|
-
* 设置属性上是否存在icon图标
|
|
9210
|
-
*/
|
|
9211
|
-
setHasIcon(value) {
|
|
9212
|
-
this.$ele.button.setAttribute("data-icon", Boolean(value).toString());
|
|
9213
|
-
},
|
|
9214
|
-
/**
|
|
9215
|
-
* 设置按钮类型
|
|
9216
|
-
* @param typeValue
|
|
9217
|
-
*/
|
|
9218
|
-
setButtonType(typeValue) {
|
|
9219
|
-
this.$ele.button.setAttribute("type", typeValue);
|
|
9220
|
-
},
|
|
9221
|
-
/**
|
|
9222
|
-
* 添加按钮的图标在右边
|
|
9223
|
-
*/
|
|
9224
|
-
setIconRight() {
|
|
9225
|
-
this.$ele.button.classList.add("pops-panel-button-right-icon");
|
|
9226
|
-
},
|
|
9227
|
-
/**
|
|
9228
|
-
* (默认)添加按钮的图标在左边
|
|
9229
|
-
*/
|
|
9230
|
-
setIconLeft() {
|
|
9231
|
-
this.$ele.button.classList.remove("pops-panel-button-right-icon");
|
|
9232
|
-
},
|
|
9233
|
-
/**
|
|
9234
|
-
* 设置按钮文本
|
|
9235
|
-
* @param text
|
|
9236
|
-
*/
|
|
9237
|
-
setButtonText(text) {
|
|
9238
|
-
this.$ele.spanText.innerHTML = text;
|
|
9239
|
-
},
|
|
9240
|
-
setClickEvent() {
|
|
9241
|
-
popsDOMUtils.on(this.$ele.button, "click", void 0, (event) => {
|
|
9242
|
-
if (typeof formConfig.callback === "function") {
|
|
9243
|
-
formConfig.callback(event);
|
|
9175
|
+
if (formConfig.disable) {
|
|
9176
|
+
this.disable();
|
|
9244
9177
|
}
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
};
|
|
9248
|
-
PopsPanelButton.init();
|
|
9249
|
-
liElement["data-button"] = PopsPanelButton;
|
|
9250
|
-
return liElement;
|
|
9251
|
-
},
|
|
9252
|
-
/**
|
|
9253
|
-
* 获取深层容器的元素<li>
|
|
9254
|
-
* @param formConfig
|
|
9255
|
-
*/
|
|
9256
|
-
getSectionContainerItem_deepMenu(formConfig) {
|
|
9257
|
-
let that = this;
|
|
9258
|
-
let liElement = document.createElement("li");
|
|
9259
|
-
liElement.classList.add("pops-panel-deepMenu-nav-item");
|
|
9260
|
-
liElement["__formConfig__"] = formConfig;
|
|
9261
|
-
if (formConfig.className) {
|
|
9262
|
-
liElement.classList.add(formConfig.className);
|
|
9263
|
-
}
|
|
9264
|
-
// 设置属性
|
|
9265
|
-
this.addElementAttributes(liElement, formConfig.attributes);
|
|
9266
|
-
// 设置元素上的属性
|
|
9267
|
-
this.setElementProps(liElement, formConfig.props);
|
|
9268
|
-
/* 左边底部的描述的文字 */
|
|
9269
|
-
let leftDescriptionText = "";
|
|
9270
|
-
if (Boolean(formConfig.description)) {
|
|
9271
|
-
// 设置描述
|
|
9272
|
-
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
9273
|
-
}
|
|
9274
|
-
// 箭头图标
|
|
9275
|
-
let arrowRightIcon = typeof formConfig.arrowRightIcon === "boolean"
|
|
9276
|
-
? formConfig.arrowRightIcon
|
|
9277
|
-
: true;
|
|
9278
|
-
let arrowRightIconHTML = "";
|
|
9279
|
-
if (arrowRightIcon) {
|
|
9280
|
-
arrowRightIconHTML = `<i class="pops-panel-deepMenu-arrowRight-icon">${pops.config.iconSVG.arrowRight}</i>`;
|
|
9281
|
-
}
|
|
9282
|
-
let rightText = "";
|
|
9283
|
-
if (formConfig.rightText) {
|
|
9284
|
-
rightText = /*html*/ `<p class="pops-panel-item-right-text">${formConfig.rightText}</p>`;
|
|
9285
|
-
}
|
|
9286
|
-
liElement.innerHTML = /*html*/ `
|
|
9287
|
-
<div class="pops-panel-item-left-text">
|
|
9288
|
-
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
9289
|
-
${leftDescriptionText}
|
|
9290
|
-
</div>
|
|
9291
|
-
<div class="pops-panel-deepMenu">
|
|
9292
|
-
${rightText}
|
|
9293
|
-
${arrowRightIconHTML}
|
|
9294
|
-
</div>
|
|
9295
|
-
`;
|
|
9296
|
-
const PopsPanelDeepMenu = {
|
|
9297
|
-
[Symbol.toStringTag]: "PopsPanelDeepMenu",
|
|
9298
|
-
$ele: {
|
|
9299
|
-
get parentSection() {
|
|
9300
|
-
return that.$el.$contentSectionContainer;
|
|
9178
|
+
this.setButtonText(buttonText);
|
|
9179
|
+
this.setIconLoadingStatus(formConfig.buttonIconIsLoading);
|
|
9301
9180
|
},
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9181
|
+
disable() {
|
|
9182
|
+
this.$ele.button.setAttribute("disabled", "true");
|
|
9183
|
+
},
|
|
9184
|
+
notDisable() {
|
|
9185
|
+
this.$ele.button.removeAttribute("disabled");
|
|
9186
|
+
},
|
|
9187
|
+
/**
|
|
9188
|
+
* 隐藏icon图标
|
|
9189
|
+
*/
|
|
9190
|
+
hideIcon() {
|
|
9191
|
+
this.$ele.panelButton.classList.add("pops-panel-button-no-icon");
|
|
9192
|
+
},
|
|
9193
|
+
/**
|
|
9194
|
+
* 显示icon图标
|
|
9195
|
+
*/
|
|
9196
|
+
showIcon() {
|
|
9197
|
+
this.$ele.panelButton.classList.remove("pops-panel-button-no-icon");
|
|
9198
|
+
},
|
|
9199
|
+
/**
|
|
9200
|
+
* 设置icon图标的svg
|
|
9201
|
+
*/
|
|
9202
|
+
setIconSVG(svgHTML) {
|
|
9203
|
+
this.$ele.icon.innerHTML = svgHTML;
|
|
9204
|
+
},
|
|
9205
|
+
/**
|
|
9206
|
+
* 设置icon图标是否旋转
|
|
9207
|
+
* @param status
|
|
9208
|
+
*/
|
|
9209
|
+
setIconLoadingStatus(status) {
|
|
9210
|
+
this.$ele.icon.setAttribute("is-loading", Boolean(status).toString());
|
|
9211
|
+
},
|
|
9212
|
+
/**
|
|
9213
|
+
* 设置属性上是否存在icon图标
|
|
9214
|
+
*/
|
|
9215
|
+
setHasIcon(value) {
|
|
9216
|
+
this.$ele.button.setAttribute("data-icon", Boolean(value).toString());
|
|
9217
|
+
},
|
|
9218
|
+
/**
|
|
9219
|
+
* 设置按钮类型
|
|
9220
|
+
* @param typeValue
|
|
9221
|
+
*/
|
|
9222
|
+
setButtonType(typeValue) {
|
|
9223
|
+
this.$ele.button.setAttribute("type", typeValue);
|
|
9224
|
+
},
|
|
9225
|
+
/**
|
|
9226
|
+
* 添加按钮的图标在右边
|
|
9227
|
+
*/
|
|
9228
|
+
setIconRight() {
|
|
9229
|
+
this.$ele.button.classList.add("pops-panel-button-right-icon");
|
|
9230
|
+
},
|
|
9231
|
+
/**
|
|
9232
|
+
* (默认)添加按钮的图标在左边
|
|
9233
|
+
*/
|
|
9234
|
+
setIconLeft() {
|
|
9235
|
+
this.$ele.button.classList.remove("pops-panel-button-right-icon");
|
|
9236
|
+
},
|
|
9237
|
+
/**
|
|
9238
|
+
* 设置按钮文本
|
|
9239
|
+
* @param text
|
|
9240
|
+
*/
|
|
9241
|
+
setButtonText(text) {
|
|
9242
|
+
this.$ele.spanText.innerHTML = text;
|
|
9243
|
+
},
|
|
9244
|
+
setClickEvent() {
|
|
9245
|
+
popsDOMUtils.on(this.$ele.button, "click", void 0, (event) => {
|
|
9246
|
+
if (typeof formConfig.callback === "function") {
|
|
9247
|
+
formConfig.callback(event);
|
|
9248
|
+
}
|
|
9323
9249
|
});
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9250
|
+
},
|
|
9251
|
+
};
|
|
9252
|
+
PopsPanelButton.init();
|
|
9253
|
+
liElement["data-button"] = PopsPanelButton;
|
|
9254
|
+
return liElement;
|
|
9255
|
+
},
|
|
9256
|
+
/**
|
|
9257
|
+
* 获取深层容器的元素<li>
|
|
9258
|
+
* @param formConfig
|
|
9259
|
+
*/
|
|
9260
|
+
getSectionContainerItem_deepMenu(formConfig) {
|
|
9261
|
+
let that = this;
|
|
9262
|
+
let liElement = document.createElement("li");
|
|
9263
|
+
liElement.classList.add("pops-panel-deepMenu-nav-item");
|
|
9264
|
+
liElement["__formConfig__"] = formConfig;
|
|
9265
|
+
if (formConfig.className) {
|
|
9266
|
+
liElement.classList.add(formConfig.className);
|
|
9267
|
+
}
|
|
9268
|
+
// 设置属性
|
|
9269
|
+
this.addElementAttributes(liElement, formConfig.attributes);
|
|
9270
|
+
// 设置元素上的属性
|
|
9271
|
+
this.setElementProps(liElement, formConfig.props);
|
|
9272
|
+
/* 左边底部的描述的文字 */
|
|
9273
|
+
let leftDescriptionText = "";
|
|
9274
|
+
if (Boolean(formConfig.description)) {
|
|
9275
|
+
// 设置描述
|
|
9276
|
+
leftDescriptionText = `<p class="pops-panel-item-left-desc-text">${formConfig.description}</p>`;
|
|
9277
|
+
}
|
|
9278
|
+
// 箭头图标
|
|
9279
|
+
let arrowRightIcon = typeof formConfig.arrowRightIcon === "boolean"
|
|
9280
|
+
? formConfig.arrowRightIcon
|
|
9281
|
+
: true;
|
|
9282
|
+
let arrowRightIconHTML = "";
|
|
9283
|
+
if (arrowRightIcon) {
|
|
9284
|
+
arrowRightIconHTML = `<i class="pops-panel-deepMenu-arrowRight-icon">${pops.config.iconSVG.arrowRight}</i>`;
|
|
9285
|
+
}
|
|
9286
|
+
let rightText = "";
|
|
9287
|
+
if (formConfig.rightText) {
|
|
9288
|
+
rightText = /*html*/ `<p class="pops-panel-item-right-text">${formConfig.rightText}</p>`;
|
|
9289
|
+
}
|
|
9290
|
+
liElement.innerHTML = /*html*/ `
|
|
9291
|
+
<div class="pops-panel-item-left-text">
|
|
9292
|
+
<p class="pops-panel-item-left-main-text">${formConfig.text}</p>
|
|
9293
|
+
${leftDescriptionText}
|
|
9294
|
+
</div>
|
|
9295
|
+
<div class="pops-panel-deepMenu">
|
|
9296
|
+
${rightText}
|
|
9297
|
+
${arrowRightIconHTML}
|
|
9298
|
+
</div>
|
|
9299
|
+
`;
|
|
9300
|
+
const PopsPanelDeepMenu = {
|
|
9301
|
+
[Symbol.toStringTag]: "PopsPanelDeepMenu",
|
|
9302
|
+
$ele: {
|
|
9303
|
+
get parentSection() {
|
|
9304
|
+
return that.$el.$contentSectionContainer;
|
|
9305
|
+
},
|
|
9306
|
+
},
|
|
9307
|
+
init() {
|
|
9308
|
+
this.setLiClickEvent();
|
|
9309
|
+
},
|
|
9310
|
+
/**
|
|
9311
|
+
* 生成配置每一项的元素
|
|
9312
|
+
* @param $container
|
|
9313
|
+
* @param formItemConfig
|
|
9314
|
+
*/
|
|
9315
|
+
initFormItem($container, formItemConfig) {
|
|
9316
|
+
if (formItemConfig["type"] === "forms") {
|
|
9317
|
+
let childForms = formItemConfig["forms"];
|
|
9318
|
+
/* 每一项<li>元素 */
|
|
9319
|
+
let formContainerListElement = document.createElement("li");
|
|
9320
|
+
/* 每一项<li>内的子<ul>元素 */
|
|
9321
|
+
let formContainerULElement = document.createElement("ul");
|
|
9322
|
+
formContainerListElement.className =
|
|
9323
|
+
"pops-panel-forms-container-item";
|
|
9324
|
+
/* 区域头部的文字 */
|
|
9325
|
+
let formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
9326
|
+
className: "pops-panel-forms-container-item-header-text",
|
|
9327
|
+
});
|
|
9328
|
+
formHeaderDivElement.innerHTML = formItemConfig["text"];
|
|
9329
|
+
/* 加进容器内 */
|
|
9330
|
+
formContainerListElement.appendChild(formHeaderDivElement);
|
|
9331
|
+
if (formItemConfig.className) {
|
|
9332
|
+
popsDOMUtils.addClassName(formContainerListElement, formItemConfig.className);
|
|
9333
|
+
}
|
|
9334
|
+
that.addElementAttributes(formContainerListElement, formItemConfig.attributes);
|
|
9335
|
+
that.setElementProps(formContainerListElement, formItemConfig.props);
|
|
9336
|
+
childForms.forEach((childFormConfig) => {
|
|
9337
|
+
that.uListContainerAddItem(childFormConfig, {
|
|
9338
|
+
ulElement: formContainerULElement,
|
|
9339
|
+
sectionContainerULElement: that.sectionContainerULElement,
|
|
9340
|
+
formContainerListElement: formContainerListElement,
|
|
9341
|
+
formHeaderDivElement: formHeaderDivElement,
|
|
9342
|
+
});
|
|
9343
|
+
});
|
|
9344
|
+
formContainerListElement.appendChild(formContainerULElement);
|
|
9345
|
+
$container.appendChild(formContainerListElement);
|
|
9329
9346
|
}
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
ulElement: formContainerULElement,
|
|
9335
|
-
sectionContainerULElement: that.sectionContainerULElement,
|
|
9336
|
-
formContainerListElement: formContainerListElement,
|
|
9337
|
-
formHeaderDivElement: formHeaderDivElement,
|
|
9347
|
+
else {
|
|
9348
|
+
/* 如果成功创建,加入到中间容器中 */
|
|
9349
|
+
that.uListContainerAddItem(formConfig, {
|
|
9350
|
+
ulElement: that.sectionContainerULElement,
|
|
9338
9351
|
});
|
|
9352
|
+
}
|
|
9353
|
+
},
|
|
9354
|
+
/**
|
|
9355
|
+
* 前往子菜单
|
|
9356
|
+
* @param event 点击事件
|
|
9357
|
+
* @param liElement 当前的<li>元素
|
|
9358
|
+
*/
|
|
9359
|
+
gotoDeepMenu(event, liElement) {
|
|
9360
|
+
/** 当前所在的容器 */
|
|
9361
|
+
let currentSection = liElement.closest("section.pops-panel-container");
|
|
9362
|
+
if (currentSection) {
|
|
9363
|
+
popsDOMUtils.cssHide(currentSection);
|
|
9364
|
+
}
|
|
9365
|
+
// 子菜单的容器
|
|
9366
|
+
let $deepMenuContainer = popsDOMUtils.createElement("section", {
|
|
9367
|
+
className: "pops-panel-container pops-panel-deepMenu-container",
|
|
9339
9368
|
});
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
}
|
|
9343
|
-
else {
|
|
9344
|
-
/* 如果成功创建,加入到中间容器中 */
|
|
9345
|
-
that.uListContainerAddItem(formConfig, {
|
|
9346
|
-
ulElement: that.sectionContainerULElement,
|
|
9369
|
+
let $deepMenuHeaderUL = popsDOMUtils.createElement("ul", {
|
|
9370
|
+
className: "pops-panel-deepMenu-container-header-ul",
|
|
9347
9371
|
});
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
popsDOMUtils.
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9372
|
+
let $deepMenuChildMenuUL = popsDOMUtils.createElement("ul");
|
|
9373
|
+
// 标题文字
|
|
9374
|
+
let headerTitleText = formConfig.headerTitle ?? formConfig.text;
|
|
9375
|
+
let $header = popsDOMUtils.createElement("div", {
|
|
9376
|
+
className: "pops-panel-deepMenu-container-header",
|
|
9377
|
+
innerHTML: `<p>${headerTitleText}</p>`,
|
|
9378
|
+
});
|
|
9379
|
+
let $headerLeftArrow = popsDOMUtils.createElement("i", {
|
|
9380
|
+
className: "pops-panel-deepMenu-container-left-arrow-icon",
|
|
9381
|
+
innerHTML: pops.config.iconSVG.arrowLeft,
|
|
9382
|
+
});
|
|
9383
|
+
popsDOMUtils.on($headerLeftArrow, "click", void 0, (event) => {
|
|
9384
|
+
event?.preventDefault();
|
|
9385
|
+
event?.stopPropagation();
|
|
9386
|
+
// 返回上一层菜单
|
|
9387
|
+
let $prev = $deepMenuContainer.previousElementSibling;
|
|
9388
|
+
popsDOMUtils.cssShow($prev);
|
|
9389
|
+
$deepMenuContainer.remove();
|
|
9390
|
+
}, {
|
|
9391
|
+
once: true,
|
|
9392
|
+
});
|
|
9393
|
+
$header.firstElementChild?.insertAdjacentElement("beforebegin", $headerLeftArrow);
|
|
9394
|
+
$deepMenuHeaderUL.appendChild($header);
|
|
9395
|
+
$deepMenuContainer.appendChild($deepMenuHeaderUL);
|
|
9396
|
+
$deepMenuContainer.appendChild($deepMenuChildMenuUL);
|
|
9397
|
+
if (formConfig.forms && Array.isArray(formConfig.forms)) {
|
|
9398
|
+
for (let index = 0; index < formConfig.forms.length; index++) {
|
|
9399
|
+
let formItemConfig = formConfig.forms[index];
|
|
9400
|
+
this.initFormItem($deepMenuChildMenuUL, formItemConfig);
|
|
9401
|
+
}
|
|
9402
|
+
}
|
|
9403
|
+
that.$el.$content?.appendChild($deepMenuContainer);
|
|
9404
|
+
/* 根据标题的高度来自适应内容高度,默认开启 */
|
|
9405
|
+
/* 中间容器的偏移量,看设置的section.pops-panel-container的padding,默认0 */
|
|
9406
|
+
let contentContainerOffset = 0;
|
|
9407
|
+
/* 获取标题的<ul>元素的高度 */
|
|
9408
|
+
let sectionContainerHeaderULElementHeight = popsDOMUtils.height($deepMenuHeaderUL);
|
|
9409
|
+
$deepMenuChildMenuUL.style.setProperty("height", `calc( 100% - ${sectionContainerHeaderULElementHeight + contentContainerOffset}px )`);
|
|
9410
|
+
},
|
|
9411
|
+
/** 设置项的点击事件 */
|
|
9412
|
+
setLiClickEvent() {
|
|
9413
|
+
popsDOMUtils.on(liElement, "click", void 0, async (event) => {
|
|
9414
|
+
if (typeof formConfig.clickCallBack === "function") {
|
|
9415
|
+
let result = await formConfig.clickCallBack(event, formConfig);
|
|
9416
|
+
if (result) {
|
|
9417
|
+
return;
|
|
9418
|
+
}
|
|
9419
|
+
}
|
|
9420
|
+
this.gotoDeepMenu(event, liElement);
|
|
9421
|
+
});
|
|
9422
|
+
},
|
|
9423
|
+
};
|
|
9424
|
+
PopsPanelDeepMenu.init();
|
|
9425
|
+
liElement["data-deepMenu"] = PopsPanelDeepMenu;
|
|
9426
|
+
return liElement;
|
|
9427
|
+
},
|
|
9428
|
+
/**
|
|
9429
|
+
* 获取中间容器的元素<li>
|
|
9430
|
+
* type ===> own
|
|
9431
|
+
* @param formConfig
|
|
9432
|
+
*/
|
|
9433
|
+
getSectionContainerItem_own(formConfig) {
|
|
9434
|
+
let liElement = document.createElement("li");
|
|
9435
|
+
liElement["__formConfig__"] = formConfig;
|
|
9436
|
+
if (formConfig.className) {
|
|
9437
|
+
liElement.className = formConfig.className;
|
|
9438
|
+
}
|
|
9439
|
+
liElement = formConfig.getLiElementCallBack(liElement);
|
|
9440
|
+
return liElement;
|
|
9441
|
+
},
|
|
9442
|
+
/**
|
|
9443
|
+
* 获取中间容器的元素<li>
|
|
9444
|
+
* @param formConfig
|
|
9445
|
+
*/
|
|
9446
|
+
getSectionContainerItem(formConfig) {
|
|
9447
|
+
/** 配置项的类型 */
|
|
9448
|
+
let formType = formConfig["type"];
|
|
9449
|
+
if (formType === "switch") {
|
|
9450
|
+
return this.getSectionContainerItem_switch(formConfig);
|
|
9451
|
+
}
|
|
9452
|
+
else if (formType === "slider") {
|
|
9453
|
+
return this.getSectionContainerItem_slider_new(formConfig);
|
|
9454
|
+
}
|
|
9455
|
+
else if (formType === "input") {
|
|
9456
|
+
return this.getSectionContainerItem_input(formConfig);
|
|
9457
|
+
}
|
|
9458
|
+
else if (formType === "textarea") {
|
|
9459
|
+
return this.getSectionContainerItem_textarea(formConfig);
|
|
9460
|
+
}
|
|
9461
|
+
else if (formType === "select") {
|
|
9462
|
+
return this.getSectionContainerItem_select(formConfig);
|
|
9463
|
+
}
|
|
9464
|
+
else if (formType === "select-multiple") {
|
|
9465
|
+
return this.getSectionContainerItem_select_multiple_new(formConfig);
|
|
9466
|
+
}
|
|
9467
|
+
else if (formType === "button") {
|
|
9468
|
+
return this.getSectionContainerItem_button(formConfig);
|
|
9469
|
+
}
|
|
9470
|
+
else if (formType === "deepMenu") {
|
|
9471
|
+
return this.getSectionContainerItem_deepMenu(formConfig);
|
|
9472
|
+
}
|
|
9473
|
+
else if (formType === "own") {
|
|
9474
|
+
return this.getSectionContainerItem_own(formConfig);
|
|
9475
|
+
}
|
|
9476
|
+
else {
|
|
9477
|
+
console.error("尚未实现的type类型", formConfig);
|
|
9478
|
+
}
|
|
9479
|
+
},
|
|
9480
|
+
/**
|
|
9481
|
+
* 生成配置每一项的元素
|
|
9482
|
+
* @param formConfig
|
|
9483
|
+
*/
|
|
9484
|
+
initFormItem(formConfig) {
|
|
9485
|
+
let that = this;
|
|
9486
|
+
if (formConfig["type"] === "forms") {
|
|
9487
|
+
let __formConfig_forms = formConfig;
|
|
9488
|
+
let childForms = formConfig["forms"];
|
|
9489
|
+
/* 每一项<li>元素 */
|
|
9490
|
+
let formContainerListElement = document.createElement("li");
|
|
9491
|
+
/* 每一项<li>内的子<ul>元素 */
|
|
9492
|
+
let formContainerULElement = document.createElement("ul");
|
|
9493
|
+
formContainerListElement.className = "pops-panel-forms-container-item";
|
|
9494
|
+
/* 区域头部的文字 */
|
|
9495
|
+
let formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
9496
|
+
className: "pops-panel-forms-container-item-header-text",
|
|
9367
9497
|
});
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
className
|
|
9373
|
-
|
|
9498
|
+
formHeaderDivElement.innerHTML = __formConfig_forms["text"];
|
|
9499
|
+
/* 加进容器内 */
|
|
9500
|
+
formContainerListElement.appendChild(formHeaderDivElement);
|
|
9501
|
+
if (__formConfig_forms.className) {
|
|
9502
|
+
popsDOMUtils.addClassName(formContainerListElement, __formConfig_forms.className);
|
|
9503
|
+
}
|
|
9504
|
+
that.addElementAttributes(formContainerListElement, formConfig.attributes);
|
|
9505
|
+
that.setElementProps(formContainerListElement, formConfig.props);
|
|
9506
|
+
childForms.forEach((childFormConfig) => {
|
|
9507
|
+
that.uListContainerAddItem(childFormConfig, {
|
|
9508
|
+
ulElement: formContainerULElement,
|
|
9509
|
+
sectionContainerULElement: that.sectionContainerULElement,
|
|
9510
|
+
formContainerListElement: formContainerListElement,
|
|
9511
|
+
formHeaderDivElement: formHeaderDivElement,
|
|
9512
|
+
});
|
|
9374
9513
|
});
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9514
|
+
formContainerListElement.appendChild(formContainerULElement);
|
|
9515
|
+
that.sectionContainerULElement.appendChild(formContainerListElement);
|
|
9516
|
+
}
|
|
9517
|
+
else {
|
|
9518
|
+
/* 如果成功创建,加入到中间容器中 */
|
|
9519
|
+
that.uListContainerAddItem(formConfig, {
|
|
9520
|
+
ulElement: that.sectionContainerULElement,
|
|
9378
9521
|
});
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9522
|
+
}
|
|
9523
|
+
},
|
|
9524
|
+
/**
|
|
9525
|
+
*
|
|
9526
|
+
* @param formConfig
|
|
9527
|
+
* @param containerOptions
|
|
9528
|
+
*/
|
|
9529
|
+
uListContainerAddItem(formConfig, containerOptions) {
|
|
9530
|
+
let itemLiElement = this.getSectionContainerItem(formConfig);
|
|
9531
|
+
if (itemLiElement) {
|
|
9532
|
+
containerOptions["ulElement"].appendChild(itemLiElement);
|
|
9533
|
+
}
|
|
9534
|
+
if (typeof formConfig.afterAddToUListCallBack === "function") {
|
|
9535
|
+
formConfig.afterAddToUListCallBack(formConfig, containerOptions);
|
|
9536
|
+
}
|
|
9537
|
+
},
|
|
9538
|
+
/**
|
|
9539
|
+
* 为左侧容器元素添加点击事件
|
|
9540
|
+
* @param asideLiElement 左侧的容器<li>元素
|
|
9541
|
+
* @param asideConfig 配置
|
|
9542
|
+
*/
|
|
9543
|
+
setAsideItemClickEvent(asideLiElement, asideConfig) {
|
|
9544
|
+
const that = this;
|
|
9545
|
+
popsDOMUtils.on(asideLiElement, "click", void 0, (event) => {
|
|
9546
|
+
this.clearContainer();
|
|
9547
|
+
popsDOMUtils.cssShow(that.$el.$contentSectionContainer);
|
|
9548
|
+
this.clearAsideItemIsVisited();
|
|
9549
|
+
this.setAsideItemIsVisited(asideLiElement);
|
|
9550
|
+
/* 顶部标题栏,存在就设置 */
|
|
9551
|
+
let headerTitleText = asideConfig.headerTitle ?? asideConfig.title;
|
|
9552
|
+
if (typeof headerTitleText === "string" &&
|
|
9553
|
+
headerTitleText.trim() !== "") {
|
|
9554
|
+
let containerHeaderTitleLIElement = document.createElement("li");
|
|
9555
|
+
containerHeaderTitleLIElement["__asideConfig__"] =
|
|
9556
|
+
asideConfig;
|
|
9557
|
+
containerHeaderTitleLIElement.innerHTML = headerTitleText;
|
|
9558
|
+
this.sectionContainerHeaderULElement.appendChild(containerHeaderTitleLIElement);
|
|
9559
|
+
}
|
|
9560
|
+
let __forms__ = asideLiElement["__forms__"];
|
|
9561
|
+
__forms__.forEach((formConfig) => {
|
|
9562
|
+
this.initFormItem(formConfig);
|
|
9388
9563
|
});
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9564
|
+
let autoAdaptionContentHeight = asideConfig.autoAdaptionContentHeight ?? true;
|
|
9565
|
+
if (autoAdaptionContentHeight) {
|
|
9566
|
+
/* 根据标题的高度来自适应内容高度,默认开启 */
|
|
9567
|
+
/* 中间容器的偏移量,看设置的section.pops-panel-container的padding,默认0 */
|
|
9568
|
+
let contentContainerOffset = asideConfig.contentContainerOffset ?? 0;
|
|
9569
|
+
/* 获取标题的<ul>元素的高度 */
|
|
9570
|
+
let sectionContainerHeaderULElementHeight = popsDOMUtils.height(this.sectionContainerHeaderULElement);
|
|
9571
|
+
this.sectionContainerULElement.style.setProperty("height", `calc( 100% - ${sectionContainerHeaderULElementHeight + contentContainerOffset}px )`);
|
|
9572
|
+
}
|
|
9573
|
+
if (typeof asideConfig.callback === "function") {
|
|
9574
|
+
/* 执行回调 */
|
|
9575
|
+
asideConfig.callback(event, this.sectionContainerHeaderULElement, this.sectionContainerULElement);
|
|
9398
9576
|
}
|
|
9399
|
-
that.$el.$content?.appendChild($deepMenuContainer);
|
|
9400
|
-
/* 根据标题的高度来自适应内容高度,默认开启 */
|
|
9401
|
-
/* 中间容器的偏移量,看设置的section.pops-panel-container的padding,默认0 */
|
|
9402
|
-
let contentContainerOffset = 0;
|
|
9403
|
-
/* 获取标题的<ul>元素的高度 */
|
|
9404
|
-
let sectionContainerHeaderULElementHeight = popsDOMUtils.height($deepMenuHeaderUL);
|
|
9405
|
-
$deepMenuChildMenuUL.style.setProperty("height", `calc( 100% - ${sectionContainerHeaderULElementHeight + contentContainerOffset}px )`);
|
|
9406
|
-
},
|
|
9407
|
-
/** 设置项的点击事件 */
|
|
9408
|
-
setLiClickEvent() {
|
|
9409
|
-
popsDOMUtils.on(liElement, "click", void 0, async (event) => {
|
|
9410
|
-
if (typeof formConfig.clickCallBack === "function") {
|
|
9411
|
-
let result = await formConfig.clickCallBack(event, formConfig);
|
|
9412
|
-
if (result) {
|
|
9413
|
-
return;
|
|
9414
|
-
}
|
|
9415
|
-
}
|
|
9416
|
-
this.gotoDeepMenu(event, liElement);
|
|
9417
|
-
});
|
|
9418
|
-
},
|
|
9419
|
-
};
|
|
9420
|
-
PopsPanelDeepMenu.init();
|
|
9421
|
-
liElement["data-deepMenu"] = PopsPanelDeepMenu;
|
|
9422
|
-
return liElement;
|
|
9423
|
-
},
|
|
9424
|
-
/**
|
|
9425
|
-
* 获取中间容器的元素<li>
|
|
9426
|
-
* type ===> own
|
|
9427
|
-
* @param formConfig
|
|
9428
|
-
*/
|
|
9429
|
-
getSectionContainerItem_own(formConfig) {
|
|
9430
|
-
let liElement = document.createElement("li");
|
|
9431
|
-
liElement["__formConfig__"] = formConfig;
|
|
9432
|
-
if (formConfig.className) {
|
|
9433
|
-
liElement.className = formConfig.className;
|
|
9434
|
-
}
|
|
9435
|
-
liElement = formConfig.getLiElementCallBack(liElement);
|
|
9436
|
-
return liElement;
|
|
9437
|
-
},
|
|
9438
|
-
/**
|
|
9439
|
-
* 获取中间容器的元素<li>
|
|
9440
|
-
* @param formConfig
|
|
9441
|
-
*/
|
|
9442
|
-
getSectionContainerItem(formConfig) {
|
|
9443
|
-
/** 配置项的类型 */
|
|
9444
|
-
let formType = formConfig["type"];
|
|
9445
|
-
if (formType === "switch") {
|
|
9446
|
-
return this.getSectionContainerItem_switch(formConfig);
|
|
9447
|
-
}
|
|
9448
|
-
else if (formType === "slider") {
|
|
9449
|
-
return this.getSectionContainerItem_slider_new(formConfig);
|
|
9450
|
-
}
|
|
9451
|
-
else if (formType === "input") {
|
|
9452
|
-
return this.getSectionContainerItem_input(formConfig);
|
|
9453
|
-
}
|
|
9454
|
-
else if (formType === "textarea") {
|
|
9455
|
-
return this.getSectionContainerItem_textarea(formConfig);
|
|
9456
|
-
}
|
|
9457
|
-
else if (formType === "select") {
|
|
9458
|
-
return this.getSectionContainerItem_select(formConfig);
|
|
9459
|
-
}
|
|
9460
|
-
else if (formType === "select-multiple") {
|
|
9461
|
-
return this.getSectionContainerItem_select_multiple_new(formConfig);
|
|
9462
|
-
}
|
|
9463
|
-
else if (formType === "button") {
|
|
9464
|
-
return this.getSectionContainerItem_button(formConfig);
|
|
9465
|
-
}
|
|
9466
|
-
else if (formType === "deepMenu") {
|
|
9467
|
-
return this.getSectionContainerItem_deepMenu(formConfig);
|
|
9468
|
-
}
|
|
9469
|
-
else if (formType === "own") {
|
|
9470
|
-
return this.getSectionContainerItem_own(formConfig);
|
|
9471
|
-
}
|
|
9472
|
-
else {
|
|
9473
|
-
console.error("尚未实现的type类型", formConfig);
|
|
9474
|
-
}
|
|
9475
|
-
},
|
|
9476
|
-
/**
|
|
9477
|
-
* 生成配置每一项的元素
|
|
9478
|
-
* @param formConfig
|
|
9479
|
-
*/
|
|
9480
|
-
initFormItem(formConfig) {
|
|
9481
|
-
let that = this;
|
|
9482
|
-
if (formConfig["type"] === "forms") {
|
|
9483
|
-
let __formConfig_forms = formConfig;
|
|
9484
|
-
let childForms = formConfig["forms"];
|
|
9485
|
-
/* 每一项<li>元素 */
|
|
9486
|
-
let formContainerListElement = document.createElement("li");
|
|
9487
|
-
/* 每一项<li>内的子<ul>元素 */
|
|
9488
|
-
let formContainerULElement = document.createElement("ul");
|
|
9489
|
-
formContainerListElement.className = "pops-panel-forms-container-item";
|
|
9490
|
-
/* 区域头部的文字 */
|
|
9491
|
-
let formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
9492
|
-
className: "pops-panel-forms-container-item-header-text",
|
|
9493
|
-
});
|
|
9494
|
-
formHeaderDivElement.innerHTML = __formConfig_forms["text"];
|
|
9495
|
-
/* 加进容器内 */
|
|
9496
|
-
formContainerListElement.appendChild(formHeaderDivElement);
|
|
9497
|
-
if (__formConfig_forms.className) {
|
|
9498
|
-
popsDOMUtils.addClassName(formContainerListElement, __formConfig_forms.className);
|
|
9499
|
-
}
|
|
9500
|
-
that.addElementAttributes(formContainerListElement, formConfig.attributes);
|
|
9501
|
-
that.setElementProps(formContainerListElement, formConfig.props);
|
|
9502
|
-
childForms.forEach((childFormConfig) => {
|
|
9503
|
-
that.uListContainerAddItem(childFormConfig, {
|
|
9504
|
-
ulElement: formContainerULElement,
|
|
9505
|
-
sectionContainerULElement: that.sectionContainerULElement,
|
|
9506
|
-
formContainerListElement: formContainerListElement,
|
|
9507
|
-
formHeaderDivElement: formHeaderDivElement,
|
|
9508
|
-
});
|
|
9509
|
-
});
|
|
9510
|
-
formContainerListElement.appendChild(formContainerULElement);
|
|
9511
|
-
that.sectionContainerULElement.appendChild(formContainerListElement);
|
|
9512
|
-
}
|
|
9513
|
-
else {
|
|
9514
|
-
/* 如果成功创建,加入到中间容器中 */
|
|
9515
|
-
that.uListContainerAddItem(formConfig, {
|
|
9516
|
-
ulElement: that.sectionContainerULElement,
|
|
9517
|
-
});
|
|
9518
|
-
}
|
|
9519
|
-
},
|
|
9520
|
-
/**
|
|
9521
|
-
*
|
|
9522
|
-
* @param formConfig
|
|
9523
|
-
* @param containerOptions
|
|
9524
|
-
*/
|
|
9525
|
-
uListContainerAddItem(formConfig, containerOptions) {
|
|
9526
|
-
let itemLiElement = this.getSectionContainerItem(formConfig);
|
|
9527
|
-
if (itemLiElement) {
|
|
9528
|
-
containerOptions["ulElement"].appendChild(itemLiElement);
|
|
9529
|
-
}
|
|
9530
|
-
if (typeof formConfig.afterAddToUListCallBack === "function") {
|
|
9531
|
-
formConfig.afterAddToUListCallBack(formConfig, containerOptions);
|
|
9532
|
-
}
|
|
9533
|
-
},
|
|
9534
|
-
/**
|
|
9535
|
-
* 为左侧容器元素添加点击事件
|
|
9536
|
-
* @param asideLiElement 左侧的容器<li>元素
|
|
9537
|
-
* @param asideConfig 配置
|
|
9538
|
-
*/
|
|
9539
|
-
setAsideItemClickEvent(asideLiElement, asideConfig) {
|
|
9540
|
-
const that = this;
|
|
9541
|
-
popsDOMUtils.on(asideLiElement, "click", void 0, (event) => {
|
|
9542
|
-
this.clearContainer();
|
|
9543
|
-
popsDOMUtils.cssShow(that.$el.$contentSectionContainer);
|
|
9544
|
-
this.clearAsideItemIsVisited();
|
|
9545
|
-
this.setAsideItemIsVisited(asideLiElement);
|
|
9546
|
-
/* 顶部标题栏,存在就设置 */
|
|
9547
|
-
let headerTitleText = asideConfig.headerTitle ?? asideConfig.title;
|
|
9548
|
-
if (typeof headerTitleText === "string" &&
|
|
9549
|
-
headerTitleText.trim() !== "") {
|
|
9550
|
-
let containerHeaderTitleLIElement = document.createElement("li");
|
|
9551
|
-
containerHeaderTitleLIElement["__asideConfig__"] =
|
|
9552
|
-
asideConfig;
|
|
9553
|
-
containerHeaderTitleLIElement.innerHTML = headerTitleText;
|
|
9554
|
-
this.sectionContainerHeaderULElement.appendChild(containerHeaderTitleLIElement);
|
|
9555
|
-
}
|
|
9556
|
-
let __forms__ = asideLiElement["__forms__"];
|
|
9557
|
-
__forms__.forEach((formConfig) => {
|
|
9558
|
-
this.initFormItem(formConfig);
|
|
9559
9577
|
});
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
/* 根据标题的高度来自适应内容高度,默认开启 */
|
|
9563
|
-
/* 中间容器的偏移量,看设置的section.pops-panel-container的padding,默认0 */
|
|
9564
|
-
let contentContainerOffset = asideConfig.contentContainerOffset ?? 0;
|
|
9565
|
-
/* 获取标题的<ul>元素的高度 */
|
|
9566
|
-
let sectionContainerHeaderULElementHeight = popsDOMUtils.height(this.sectionContainerHeaderULElement);
|
|
9567
|
-
this.sectionContainerULElement.style.setProperty("height", `calc( 100% - ${sectionContainerHeaderULElementHeight + contentContainerOffset}px )`);
|
|
9568
|
-
}
|
|
9569
|
-
if (typeof asideConfig.callback === "function") {
|
|
9570
|
-
/* 执行回调 */
|
|
9571
|
-
asideConfig.callback(event, this.sectionContainerHeaderULElement, this.sectionContainerULElement);
|
|
9572
|
-
}
|
|
9573
|
-
});
|
|
9574
|
-
},
|
|
9578
|
+
},
|
|
9579
|
+
};
|
|
9575
9580
|
};
|
|
9576
9581
|
|
|
9577
9582
|
class PopsPanel {
|
|
@@ -9662,10 +9667,11 @@ define((function () { 'use strict';
|
|
|
9662
9667
|
if ($mask != null) {
|
|
9663
9668
|
$anim.after($mask);
|
|
9664
9669
|
}
|
|
9670
|
+
let panelHandleContentDetails = PanelHandleContentDetails();
|
|
9665
9671
|
/**
|
|
9666
9672
|
* 处理内部配置
|
|
9667
9673
|
*/
|
|
9668
|
-
|
|
9674
|
+
panelHandleContentDetails.init({
|
|
9669
9675
|
config: config,
|
|
9670
9676
|
$el: {
|
|
9671
9677
|
$content: $content,
|