1111
This commit is contained in:
-289
@@ -1,289 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const _sfc_main = {
|
||||
name: "u-picker",
|
||||
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$20],
|
||||
data() {
|
||||
return {
|
||||
// 上一次选择的列索引
|
||||
lastIndex: [],
|
||||
// 索引值 ,对应picker-view的value
|
||||
innerIndex: [],
|
||||
// 各列的值
|
||||
innerColumns: [],
|
||||
// 上一次的变化列索引
|
||||
columnIndex: 0,
|
||||
showByClickInput: false,
|
||||
currentActiveValue: []
|
||||
//当前用户选中,但是还没确认的值,用户没做change操作时候,点击确认可以默认选中第一个
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
// 监听默认索引的变化,重新设置对应的值
|
||||
defaultIndex: {
|
||||
immediate: true,
|
||||
deep: true,
|
||||
handler(n, o) {
|
||||
if (!o || n.join("/") != o.join("/")) {
|
||||
this.setIndexs(n, true);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 监听columns参数的变化
|
||||
columns: {
|
||||
immediate: true,
|
||||
deep: true,
|
||||
handler(n) {
|
||||
this.setColumns(n);
|
||||
}
|
||||
}
|
||||
},
|
||||
emits: ["close", "cancel", "confirm", "change", "update:modelValue", "update:show"],
|
||||
computed: {
|
||||
//已选&&已确认的值显示在input上面的文案
|
||||
inputLabel() {
|
||||
let firstItem = this.innerColumns[0] && this.innerColumns[0][0];
|
||||
if (firstItem && Object.prototype.toString.call(firstItem) === "[object Object]") {
|
||||
let res = this.innerColumns[0].filter((item) => this.modelValue.includes(item["id"]));
|
||||
res = res.map((item) => item[this.keyName]);
|
||||
return res.join("/");
|
||||
} else {
|
||||
return this.modelValue.join("/");
|
||||
}
|
||||
},
|
||||
//已选,待确认的值
|
||||
inputValue() {
|
||||
let items = this.innerColumns.map((item, index) => item[this.innerIndex[index]]);
|
||||
let res = [];
|
||||
if (items[0] && Object.prototype.toString.call(items[0]) === "[object Object]") {
|
||||
items.forEach((element) => {
|
||||
res.push(element && element["id"]);
|
||||
});
|
||||
} else {
|
||||
items.forEach((element, index) => {
|
||||
res.push(element);
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addUnit: common_vendor.addUnit,
|
||||
testArray: common_vendor.test.array,
|
||||
onShowByClickInput() {
|
||||
if (!this.disabled) {
|
||||
this.showByClickInput = !this.showByClickInput;
|
||||
}
|
||||
},
|
||||
// 获取item需要显示的文字,判别为对象还是文本
|
||||
getItemText(item) {
|
||||
if (common_vendor.test.object(item)) {
|
||||
return item[this.keyName];
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
},
|
||||
// 关闭选择器
|
||||
closeHandler() {
|
||||
if (this.closeOnClickOverlay) {
|
||||
if (this.hasInput) {
|
||||
this.showByClickInput = false;
|
||||
}
|
||||
this.$emit("update:show", false);
|
||||
this.$emit("close");
|
||||
}
|
||||
},
|
||||
// 点击工具栏的取消按钮
|
||||
cancel() {
|
||||
if (this.hasInput) {
|
||||
this.showByClickInput = false;
|
||||
}
|
||||
this.$emit("update:show", false);
|
||||
this.$emit("cancel");
|
||||
},
|
||||
// 点击工具栏的确定按钮
|
||||
confirm() {
|
||||
if (!this.currentActiveValue.length) {
|
||||
let arr = [0];
|
||||
if (Array.isArray(this.defaultIndex) && this.defaultIndex.length == this.innerColumns.length) {
|
||||
arr = [...this.defaultIndex];
|
||||
} else {
|
||||
arr = Array(this.innerColumns.length).fill(0);
|
||||
}
|
||||
this.setLastIndex(arr);
|
||||
this.setIndexs(arr);
|
||||
}
|
||||
this.$emit("update:modelValue", this.inputValue);
|
||||
if (this.hasInput) {
|
||||
this.showByClickInput = false;
|
||||
}
|
||||
this.$emit("update:show", false);
|
||||
this.$emit("confirm", {
|
||||
indexs: this.innerIndex,
|
||||
value: this.innerColumns.map((item, index) => item[this.innerIndex[index]]),
|
||||
values: this.innerColumns
|
||||
});
|
||||
},
|
||||
// 选择器某一列的数据发生变化时触发
|
||||
changeHandler(e) {
|
||||
const {
|
||||
value
|
||||
} = e.detail;
|
||||
let index = 0, columnIndex = 0;
|
||||
this.currentActiveValue = value;
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
let item = value[i];
|
||||
if (item !== (this.lastIndex[i] || 0)) {
|
||||
columnIndex = i;
|
||||
index = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.columnIndex = columnIndex;
|
||||
const values = this.innerColumns;
|
||||
this.setLastIndex(value);
|
||||
this.setIndexs(value);
|
||||
if (!this.hasInput) {
|
||||
this.$emit("update:modelValue", this.inputValue);
|
||||
}
|
||||
this.$emit("change", {
|
||||
value: this.innerColumns.map((item, index2) => item[value[index2]]),
|
||||
index,
|
||||
indexs: value,
|
||||
// values为当前变化列的数组内容
|
||||
values,
|
||||
columnIndex
|
||||
});
|
||||
},
|
||||
// 设置index索引,此方法可被外部调用设置
|
||||
setIndexs(index, setLastIndex) {
|
||||
this.innerIndex = common_vendor.deepClone(index);
|
||||
if (setLastIndex) {
|
||||
this.setLastIndex(index);
|
||||
}
|
||||
},
|
||||
// 记录上一次的各列索引位置
|
||||
setLastIndex(index) {
|
||||
this.lastIndex = common_vendor.deepClone(index);
|
||||
},
|
||||
// 设置对应列选项的所有值
|
||||
setColumnValues(columnIndex, values) {
|
||||
this.innerColumns.splice(columnIndex, 1, values);
|
||||
this.setLastIndex(this.innerIndex.slice(0, columnIndex));
|
||||
let tmpIndex = common_vendor.deepClone(this.innerIndex);
|
||||
for (let i = 0; i < this.innerColumns.length; i++) {
|
||||
if (i > this.columnIndex) {
|
||||
tmpIndex[i] = 0;
|
||||
}
|
||||
}
|
||||
this.setIndexs(tmpIndex);
|
||||
},
|
||||
// 获取对应列的所有选项
|
||||
getColumnValues(columnIndex) {
|
||||
(async () => {
|
||||
await common_vendor.sleep();
|
||||
})();
|
||||
return this.innerColumns[columnIndex];
|
||||
},
|
||||
// 设置整体各列的columns的值
|
||||
setColumns(columns) {
|
||||
this.innerColumns = common_vendor.deepClone(columns);
|
||||
if (this.innerIndex.length === 0) {
|
||||
this.innerIndex = new Array(columns.length).fill(0);
|
||||
}
|
||||
},
|
||||
// 获取各列选中值对应的索引
|
||||
getIndexs() {
|
||||
return this.innerIndex;
|
||||
},
|
||||
// 获取各列选中的值
|
||||
getValues() {
|
||||
(async () => {
|
||||
await common_vendor.sleep();
|
||||
})();
|
||||
return this.innerColumns.map((item, index) => item[this.innerIndex[index]]);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
|
||||
const _easycom_u_toolbar2 = common_vendor.resolveComponent("u-toolbar");
|
||||
const _easycom_u_loading_icon2 = common_vendor.resolveComponent("u-loading-icon");
|
||||
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
|
||||
(_easycom_up_input2 + _easycom_u_toolbar2 + _easycom_u_loading_icon2 + _easycom_u_popup2)();
|
||||
}
|
||||
const _easycom_up_input = () => "../u-input/u-input.js";
|
||||
const _easycom_u_toolbar = () => "../u-toolbar/u-toolbar.js";
|
||||
const _easycom_u_loading_icon = () => "../u-loading-icon/u-loading-icon.js";
|
||||
const _easycom_u_popup = () => "../u-popup/u-popup.js";
|
||||
if (!Math) {
|
||||
(_easycom_up_input + _easycom_u_toolbar + _easycom_u_loading_icon + _easycom_u_popup)();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: _ctx.hasInput
|
||||
}, _ctx.hasInput ? {
|
||||
b: common_vendor.o(($event) => $options.inputLabel = $event),
|
||||
c: common_vendor.p({
|
||||
disabled: _ctx.disabled,
|
||||
disabledColor: _ctx.disabledColor,
|
||||
placeholder: _ctx.placeholder,
|
||||
readonly: true,
|
||||
border: "surround",
|
||||
modelValue: $options.inputLabel
|
||||
}),
|
||||
d: common_vendor.o((...args) => $options.onShowByClickInput && $options.onShowByClickInput(...args))
|
||||
} : {}, {
|
||||
e: _ctx.showToolbar
|
||||
}, _ctx.showToolbar ? {
|
||||
f: common_vendor.o($options.cancel),
|
||||
g: common_vendor.o($options.confirm),
|
||||
h: common_vendor.p({
|
||||
cancelColor: _ctx.cancelColor,
|
||||
confirmColor: _ctx.confirmColor,
|
||||
cancelText: _ctx.cancelText,
|
||||
confirmText: _ctx.confirmText,
|
||||
title: _ctx.title,
|
||||
rightSlot: _ctx.toolbarRightSlot ? true : false
|
||||
})
|
||||
} : {}, {
|
||||
i: common_vendor.f($data.innerColumns, (item, index, i0) => {
|
||||
return common_vendor.e({
|
||||
a: $options.testArray(item)
|
||||
}, $options.testArray(item) ? {
|
||||
b: common_vendor.f(item, (item1, index1, i1) => {
|
||||
return {
|
||||
a: common_vendor.t($options.getItemText(item1)),
|
||||
b: common_vendor.n(index1 === $data.innerIndex[index] && "u-picker__view__column__item--selected"),
|
||||
c: index1,
|
||||
d: index1 === $data.innerIndex[index] ? "bold" : "normal"
|
||||
};
|
||||
}),
|
||||
c: $options.addUnit(_ctx.itemHeight),
|
||||
d: $options.addUnit(_ctx.itemHeight)
|
||||
} : {}, {
|
||||
e: index
|
||||
});
|
||||
}),
|
||||
j: `height: ${$options.addUnit(_ctx.itemHeight)}`,
|
||||
k: $data.innerIndex,
|
||||
l: _ctx.immediateChange,
|
||||
m: `${$options.addUnit(_ctx.visibleItemCount * _ctx.itemHeight)}`,
|
||||
n: common_vendor.o((...args) => $options.changeHandler && $options.changeHandler(...args)),
|
||||
o: _ctx.loading
|
||||
}, _ctx.loading ? {
|
||||
p: common_vendor.p({
|
||||
mode: "circle"
|
||||
})
|
||||
} : {}, {
|
||||
q: common_vendor.o($options.closeHandler),
|
||||
r: common_vendor.p({
|
||||
show: _ctx.show || _ctx.hasInput && $data.showByClickInput,
|
||||
mode: _ctx.popupMode,
|
||||
zIndex: _ctx.zIndex
|
||||
})
|
||||
});
|
||||
}
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1500ce68"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/uview-plus/components/u-picker/u-picker.js.map
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"up-input": "../u-input/u-input",
|
||||
"u-toolbar": "../u-toolbar/u-toolbar",
|
||||
"u-loading-icon": "../u-loading-icon/u-loading-icon",
|
||||
"u-popup": "../u-popup/u-popup"
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
<view class="u-picker-warrper data-v-1500ce68"><view wx:if="{{a}}" class="u-picker-input cursor-pointer data-v-1500ce68" bindtap="{{d}}"><block wx:if="{{$slots.d}}"><slot></slot></block><block wx:else><up-input wx:if="{{c}}" class="data-v-1500ce68" u-i="1500ce68-0" bind:__l="__l" bindupdateModelValue="{{b}}" u-p="{{c}}"></up-input><view class="input-cover data-v-1500ce68"></view></block></view><u-popup wx:if="{{r}}" class="data-v-1500ce68" u-s="{{['d']}}" bindclose="{{q}}" u-i="1500ce68-1" bind:__l="__l" u-p="{{r}}"><view class="u-picker data-v-1500ce68"><u-toolbar wx:if="{{e}}" class="data-v-1500ce68" u-s="{{['right']}}" bindcancel="{{f}}" bindconfirm="{{g}}" u-i="1500ce68-2,1500ce68-1" bind:__l="__l" u-p="{{h}}"><view slot="right"><slot name="toolbar-right"></slot></view></u-toolbar><slot name="toolbar-bottom"></slot><block wx:if="{{r0}}"><picker-view class="u-picker__view data-v-1500ce68" indicatorStyle="{{j}}" value="{{k}}" immediateChange="{{l}}" style="{{'height:' + m}}" bindchange="{{n}}"><picker-view-column wx:for="{{i}}" wx:for-item="item" wx:key="e" class="u-picker__view__column data-v-1500ce68"><block wx:if="{{item.a}}"><view wx:for="{{item.b}}" wx:for-item="item1" wx:key="c" class="{{['u-picker__view__column__item', 'u-line-1', 'data-v-1500ce68', item1.b]}}" style="{{'height:' + item.c + ';' + ('line-height:' + item.d) + ';' + ('font-weight:' + item1.d) + ';' + ('display:' + 'block')}}">{{item1.a}}</view></block></picker-view-column></picker-view></block><view wx:if="{{o}}" class="u-picker--loading data-v-1500ce68"><u-loading-icon wx:if="{{p}}" class="data-v-1500ce68" u-i="1500ce68-3,1500ce68-1" bind:__l="__l" u-p="{{p}}"></u-loading-icon></view></view></u-popup></view>
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.u-empty.data-v-1500ce68,
|
||||
.u-empty__wrap.data-v-1500ce68,
|
||||
.u-tabs.data-v-1500ce68,
|
||||
.u-tabs__wrapper.data-v-1500ce68,
|
||||
.u-tabs__wrapper__scroll-view-wrapper.data-v-1500ce68,
|
||||
.u-tabs__wrapper__scroll-view.data-v-1500ce68,
|
||||
.u-tabs__wrapper__nav.data-v-1500ce68,
|
||||
.u-tabs__wrapper__nav__line.data-v-1500ce68,
|
||||
.up-empty.data-v-1500ce68,
|
||||
.up-empty__wrap.data-v-1500ce68,
|
||||
.up-tabs.data-v-1500ce68,
|
||||
.up-tabs__wrapper.data-v-1500ce68,
|
||||
.up-tabs__wrapper__scroll-view-wrapper.data-v-1500ce68,
|
||||
.up-tabs__wrapper__scroll-view.data-v-1500ce68,
|
||||
.up-tabs__wrapper__nav.data-v-1500ce68,
|
||||
.up-tabs__wrapper__nav__line.data-v-1500ce68 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: auto;
|
||||
align-items: stretch;
|
||||
align-content: flex-start;
|
||||
}
|
||||
.u-picker.data-v-1500ce68 {
|
||||
position: relative;
|
||||
}
|
||||
.u-picker-input.data-v-1500ce68 {
|
||||
position: relative;
|
||||
}
|
||||
.u-picker-input .input-cover.data-v-1500ce68 {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
.u-picker__view__column.data-v-1500ce68 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
.u-picker__view__column__item.data-v-1500ce68 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
display: block;
|
||||
color: #303133;
|
||||
}
|
||||
.u-picker__view__column__item--disabled.data-v-1500ce68 {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.35;
|
||||
}
|
||||
.u-picker--loading.data-v-1500ce68 {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: rgba(255, 255, 255, 0.87);
|
||||
z-index: 1000;
|
||||
}
|
||||
Reference in New Issue
Block a user