已支付订单列表:where.payStatus = 1;

This commit is contained in:
2024-07-10 22:44:18 +08:00
parent 9dd834adb5
commit 1311eb03b8
611 changed files with 92828 additions and 400 deletions
@@ -0,0 +1,295 @@
"use strict";
const uni_modules_uniDataPicker_components_uniDataPickerview_uniDataPicker = require("../uni-data-pickerview/uni-data-picker.js");
const common_vendor = require("../../../../common/vendor.js");
const DataPickerView = () => "../uni-data-pickerview/uni-data-pickerview.js";
const _sfc_main = {
name: "UniDataPicker",
emits: ["popupopened", "popupclosed", "nodeclick", "input", "change", "update:modelValue", "inputclick"],
mixins: [uni_modules_uniDataPicker_components_uniDataPickerview_uniDataPicker.dataPicker],
components: {
DataPickerView
},
props: {
options: {
type: [Object, Array],
default() {
return {};
}
},
popupTitle: {
type: String,
default: "请选择"
},
placeholder: {
type: String,
default: "请选择"
},
heightMobile: {
type: String,
default: ""
},
readonly: {
type: Boolean,
default: false
},
clearIcon: {
type: Boolean,
default: true
},
border: {
type: Boolean,
default: true
},
split: {
type: String,
default: "/"
},
ellipsis: {
type: Boolean,
default: true
}
},
data() {
return {
isOpened: false,
inputSelected: []
};
},
created() {
this.$nextTick(() => {
this.load();
});
},
watch: {
localdata: {
handler() {
this.load();
},
deep: true
}
},
methods: {
clear() {
this._dispatchEvent([]);
},
onPropsChange() {
this._treeData = [];
this.selectedIndex = 0;
this.load();
},
load() {
if (this.readonly) {
this._processReadonly(this.localdata, this.dataValue);
return;
}
if (this.isLocalData) {
this.loadData();
this.inputSelected = this.selected.slice(0);
} else if (this.isCloudDataList || this.isCloudDataTree) {
this.loading = true;
this.getCloudDataValue().then((res) => {
this.loading = false;
this.inputSelected = res;
}).catch((err) => {
this.loading = false;
this.errorMessage = err;
});
}
},
show() {
this.isOpened = true;
setTimeout(() => {
this.$refs.pickerView.updateData({
treeData: this._treeData,
selected: this.selected,
selectedIndex: this.selectedIndex
});
}, 200);
this.$emit("popupopened");
},
hide() {
this.isOpened = false;
this.$emit("popupclosed");
},
handleInput() {
if (this.readonly) {
this.$emit("inputclick");
return;
}
this.show();
},
handleClose(e) {
this.hide();
},
onnodeclick(e) {
this.$emit("nodeclick", e);
},
ondatachange(e) {
this._treeData = this.$refs.pickerView._treeData;
},
onchange(e) {
this.hide();
this.$nextTick(() => {
this.inputSelected = e;
});
this._dispatchEvent(e);
},
_processReadonly(dataList, value) {
var isTree = dataList.findIndex((item2) => {
return item2.children;
});
if (isTree > -1) {
let inputValue;
if (Array.isArray(value)) {
inputValue = value[value.length - 1];
if (typeof inputValue === "object" && inputValue.value) {
inputValue = inputValue.value;
}
} else {
inputValue = value;
}
this.inputSelected = this._findNodePath(inputValue, this.localdata);
return;
}
if (!this.hasValue) {
this.inputSelected = [];
return;
}
let result = [];
for (let i = 0; i < value.length; i++) {
var val = value[i];
var item = dataList.find((v) => {
return v.value == val;
});
if (item) {
result.push(item);
}
}
if (result.length) {
this.inputSelected = result;
}
},
_filterForArray(data, valueArray) {
var result = [];
for (let i = 0; i < valueArray.length; i++) {
var value = valueArray[i];
var found = data.find((item) => {
return item.value == value;
});
if (found) {
result.push(found);
}
}
return result;
},
_dispatchEvent(selected) {
let item = {};
if (selected.length) {
var value = new Array(selected.length);
for (var i = 0; i < selected.length; i++) {
value[i] = selected[i].value;
}
item = selected[selected.length - 1];
} else {
item.value = "";
}
if (this.formItem) {
this.formItem.setValue(item.value);
}
this.$emit("input", item.value);
this.$emit("update:modelValue", item.value);
this.$emit("change", {
detail: {
value: selected
}
});
}
}
};
if (!Array) {
const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
const _component_data_picker_view = common_vendor.resolveComponent("data-picker-view");
(_easycom_uni_load_more2 + _easycom_uni_icons2 + _component_data_picker_view)();
}
const _easycom_uni_load_more = () => "../../../uni-load-more/components/uni-load-more/uni-load-more.js";
const _easycom_uni_icons = () => "../../../uni-icons/components/uni-icons/uni-icons.js";
if (!Math) {
(_easycom_uni_load_more + _easycom_uni_icons)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: _ctx.errorMessage
}, _ctx.errorMessage ? {
b: common_vendor.t(_ctx.errorMessage)
} : _ctx.loading && !$data.isOpened ? {
d: common_vendor.p({
contentText: _ctx.loadMore,
status: "loading"
})
} : $data.inputSelected.length ? {
f: common_vendor.f($data.inputSelected, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(item.text),
b: index < $data.inputSelected.length - 1
}, index < $data.inputSelected.length - 1 ? {
c: common_vendor.t($props.split)
} : {}, {
d: index
});
})
} : {
g: common_vendor.t($props.placeholder)
}, {
c: _ctx.loading && !$data.isOpened,
e: $data.inputSelected.length,
h: $props.clearIcon && !$props.readonly && $data.inputSelected.length
}, $props.clearIcon && !$props.readonly && $data.inputSelected.length ? {
i: common_vendor.p({
type: "clear",
color: "#c0c4cc",
size: "24"
}),
j: common_vendor.o((...args) => $options.clear && $options.clear(...args))
} : {}, {
k: (!$props.clearIcon || !$data.inputSelected.length) && !$props.readonly
}, (!$props.clearIcon || !$data.inputSelected.length) && !$props.readonly ? {} : {}, {
l: $props.border ? 1 : "",
m: common_vendor.r("d", {
options: $props.options,
data: $data.inputSelected,
error: _ctx.errorMessage
}),
n: common_vendor.o((...args) => $options.handleInput && $options.handleInput(...args)),
o: $data.isOpened
}, $data.isOpened ? {
p: common_vendor.o((...args) => $options.handleClose && $options.handleClose(...args))
} : {}, {
q: $data.isOpened
}, $data.isOpened ? {
r: common_vendor.t($props.popupTitle),
s: common_vendor.o((...args) => $options.handleClose && $options.handleClose(...args)),
t: common_vendor.sr("pickerView", "fb9b1612-2"),
v: common_vendor.o($options.onchange),
w: common_vendor.o($options.ondatachange),
x: common_vendor.o($options.onnodeclick),
y: common_vendor.o(($event) => _ctx.dataValue = $event),
z: common_vendor.p({
localdata: _ctx.localdata,
preload: _ctx.preload,
collection: _ctx.collection,
field: _ctx.field,
orderby: _ctx.orderby,
where: _ctx.where,
["step-searh"]: _ctx.stepSearh,
["self-field"]: _ctx.selfField,
["parent-field"]: _ctx.parentField,
["managed-mode"]: true,
map: _ctx.map,
ellipsis: $props.ellipsis,
modelValue: _ctx.dataValue
})
} : {});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue"]]);
wx.createComponent(Component);
@@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"data-picker-view": "../uni-data-pickerview/uni-data-pickerview",
"uni-load-more": "../../../uni-load-more/components/uni-load-more/uni-load-more",
"uni-icons": "../../../uni-icons/components/uni-icons/uni-icons"
}
}
@@ -0,0 +1 @@
<view class="uni-data-tree"><view class="uni-data-tree-input" bindtap="{{n}}"><block wx:if="{{$slots.d}}"><slot name="d"></slot></block><block wx:else><view class="{{['input-value', l && 'input-value-border']}}"><text wx:if="{{a}}" class="selected-area error-text">{{b}}</text><view wx:elif="{{c}}" class="selected-area"><uni-load-more wx:if="{{d}}" class="load-more" u-i="fb9b1612-0" bind:__l="__l" u-p="{{d}}"></uni-load-more></view><scroll-view wx:elif="{{e}}" class="selected-area" scroll-x="true"><view class="selected-list"><view wx:for="{{f}}" wx:for-item="item" wx:key="d" class="selected-item"><text class="text-color">{{item.a}}</text><text wx:if="{{item.b}}" class="input-split-line">{{item.c}}</text></view></view></scroll-view><text wx:else class="selected-area placeholder">{{g}}</text><view wx:if="{{h}}" class="icon-clear" catchtap="{{j}}"><uni-icons wx:if="{{i}}" u-i="fb9b1612-1" bind:__l="__l" u-p="{{i}}"></uni-icons></view><view wx:if="{{k}}" class="arrow-area"><view class="input-arrow"></view></view></view></block></view><view wx:if="{{o}}" class="uni-data-tree-cover" bindtap="{{p}}"></view><view wx:if="{{q}}" class="uni-data-tree-dialog"><view class="uni-popper__arrow"></view><view class="dialog-caption"><view class="title-area"><text class="dialog-title">{{r}}</text></view><view class="dialog-close" bindtap="{{s}}"><view class="dialog-close-plus" data-id="close"></view><view class="dialog-close-plus dialog-close-rotate" data-id="close"></view></view></view><data-picker-view wx:if="{{z}}" class="picker-view r" u-r="pickerView" bindchange="{{v}}" binddatachange="{{w}}" bindnodeclick="{{x}}" u-i="fb9b1612-2" bind:__l="__l" bindupdateModelValue="{{y}}" u-p="{{z}}"></data-picker-view></view></view>
@@ -0,0 +1,229 @@
.uni-data-tree {
flex: 1;
position: relative;
font-size: 14px;
}
.error-text {
color: #DD524D;
}
.input-value {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: nowrap;
font-size: 14px;
/* line-height: 35px; */
padding: 0 10px;
padding-right: 5px;
overflow: hidden;
height: 35px;
box-sizing: border-box;
}
.input-value-border {
border: 1px solid #e5e5e5;
border-radius: 5px;
}
.selected-area {
flex: 1;
overflow: hidden;
display: flex;
flex-direction: row;
}
.load-more {
margin-right: auto;
}
.selected-list {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
/* padding: 0 5px; */
}
.selected-item {
flex-direction: row;
/* padding: 0 1px; */
white-space: nowrap;
}
.text-color {
color: #333;
}
.placeholder {
color: grey;
font-size: 12px;
}
.input-split-line {
opacity: .5;
}
.arrow-area {
position: relative;
width: 20px;
margin-bottom: 5px;
margin-left: auto;
display: flex;
justify-content: center;
transform: rotate(-45deg);
transform-origin: center;
}
.input-arrow {
width: 7px;
height: 7px;
border-left: 1px solid #999;
border-bottom: 1px solid #999;
}
.uni-data-tree-cover {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, .4);
display: flex;
flex-direction: column;
z-index: 100;
}
.uni-data-tree-dialog {
position: fixed;
left: 0;
top: 20%;
right: 0;
bottom: 0;
background-color: #FFFFFF;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
display: flex;
flex-direction: column;
z-index: 102;
overflow: hidden;
}
.dialog-caption {
position: relative;
display: flex;
flex-direction: row;
/* border-bottom: 1px solid #f0f0f0; */
}
.title-area {
display: flex;
align-items: center;
margin: auto;
padding: 0 10px;
}
.dialog-title {
/* font-weight: bold; */
line-height: 44px;
}
.dialog-close {
position: absolute;
top: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: row;
align-items: center;
padding: 0 15px;
}
.dialog-close-plus {
width: 16px;
height: 2px;
background-color: #666;
border-radius: 2px;
transform: rotate(45deg);
}
.dialog-close-rotate {
position: absolute;
transform: rotate(-45deg);
}
.picker-view {
flex: 1;
overflow: hidden;
}
.icon-clear {
display: flex;
align-items: center;
}
/* picker 弹出层通用的指示小三角, todo:扩展至上下左右方向定位 */
.uni-popper__arrow,
.uni-popper__arrow::after {
position: absolute;
display: block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 6px;
}
.uni-popper__arrow {
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
top: -6px;
left: 10%;
margin-right: 3px;
border-top-width: 0;
border-bottom-color: #EBEEF5;
}
.uni-popper__arrow::after {
content: " ";
top: 1px;
margin-left: -6px;
border-top-width: 0;
border-bottom-color: #fff;
}
@@ -0,0 +1,547 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const dataPicker = {
props: {
localdata: {
type: [Array, Object],
default() {
return [];
}
},
spaceInfo: {
type: Object,
default() {
return {};
}
},
collection: {
type: String,
default: ""
},
action: {
type: String,
default: ""
},
field: {
type: String,
default: ""
},
orderby: {
type: String,
default: ""
},
where: {
type: [String, Object],
default: ""
},
pageData: {
type: String,
default: "add"
},
pageCurrent: {
type: Number,
default: 1
},
pageSize: {
type: Number,
default: 500
},
getcount: {
type: [Boolean, String],
default: false
},
getone: {
type: [Boolean, String],
default: false
},
gettree: {
type: [Boolean, String],
default: false
},
manual: {
type: Boolean,
default: false
},
value: {
type: [Array, String, Number],
default() {
return [];
}
},
modelValue: {
type: [Array, String, Number],
default() {
return [];
}
},
preload: {
type: Boolean,
default: false
},
stepSearh: {
type: Boolean,
default: true
},
selfField: {
type: String,
default: ""
},
parentField: {
type: String,
default: ""
},
multiple: {
type: Boolean,
default: false
},
map: {
type: Object,
default() {
return {
text: "text",
value: "value"
};
}
}
},
data() {
return {
loading: false,
errorMessage: "",
loadMore: {
contentdown: "",
contentrefresh: "",
contentnomore: ""
},
dataList: [],
selected: [],
selectedIndex: 0,
page: {
current: this.pageCurrent,
size: this.pageSize,
count: 0
}
};
},
computed: {
isLocalData() {
return !this.collection.length;
},
isCloudData() {
return this.collection.length > 0;
},
isCloudDataList() {
return this.isCloudData && (!this.parentField && !this.selfField);
},
isCloudDataTree() {
return this.isCloudData && this.parentField && this.selfField;
},
dataValue() {
let isModelValue = Array.isArray(this.modelValue) ? this.modelValue.length > 0 : this.modelValue !== null || this.modelValue !== void 0;
return isModelValue ? this.modelValue : this.value;
},
hasValue() {
if (typeof this.dataValue === "number") {
return true;
}
return this.dataValue != null && this.dataValue.length > 0;
}
},
created() {
this.$watch(() => {
var al = [];
[
"pageCurrent",
"pageSize",
"spaceInfo",
"value",
"modelValue",
"localdata",
"collection",
"action",
"field",
"orderby",
"where",
"getont",
"getcount",
"gettree"
].forEach((key) => {
al.push(this[key]);
});
return al;
}, (newValue, oldValue) => {
for (let i = 2; i < newValue.length; i++) {
if (newValue[i] != oldValue[i]) {
break;
}
}
if (newValue[0] != oldValue[0]) {
this.page.current = this.pageCurrent;
}
this.page.size = this.pageSize;
this.onPropsChange();
});
this._treeData = [];
},
methods: {
onPropsChange() {
this._treeData = [];
},
// 填充 pickview 数据
async loadData() {
if (this.isLocalData) {
this.loadLocalData();
} else if (this.isCloudDataList) {
this.loadCloudDataList();
} else if (this.isCloudDataTree) {
this.loadCloudDataTree();
}
},
// 加载本地数据
async loadLocalData() {
this._treeData = [];
this._extractTree(this.localdata, this._treeData);
let inputValue = this.dataValue;
if (inputValue === void 0) {
return;
}
if (Array.isArray(inputValue)) {
inputValue = inputValue[inputValue.length - 1];
if (typeof inputValue === "object" && inputValue[this.map.value]) {
inputValue = inputValue[this.map.value];
}
}
this.selected = this._findNodePath(inputValue, this.localdata);
},
// 加载 Cloud 数据 (单列)
async loadCloudDataList() {
if (this.loading) {
return;
}
this.loading = true;
try {
let response = await this.getCommand();
let responseData = response.result.data;
this._treeData = responseData;
this._updateBindData();
this._updateSelected();
this.onDataChange();
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 加载 Cloud 数据 (树形)
async loadCloudDataTree() {
if (this.loading) {
return;
}
this.loading = true;
try {
let commandOptions = {
field: this._cloudDataPostField(),
where: this._cloudDataTreeWhere()
};
if (this.gettree) {
commandOptions.startwith = `${this.selfField}=='${this.dataValue}'`;
}
let response = await this.getCommand(commandOptions);
let responseData = response.result.data;
this._treeData = responseData;
this._updateBindData();
this._updateSelected();
this.onDataChange();
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 加载 Cloud 数据 (节点)
async loadCloudDataNode(callback) {
if (this.loading) {
return;
}
this.loading = true;
try {
let commandOptions = {
field: this._cloudDataPostField(),
where: this._cloudDataNodeWhere()
};
let response = await this.getCommand(commandOptions);
let responseData = response.result.data;
callback(responseData);
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 回显 Cloud 数据
getCloudDataValue() {
if (this.isCloudDataList) {
return this.getCloudDataListValue();
}
if (this.isCloudDataTree) {
return this.getCloudDataTreeValue();
}
},
// 回显 Cloud 数据 (单列)
getCloudDataListValue() {
let where = [];
let whereField = this._getForeignKeyByField();
if (whereField) {
where.push(`${whereField} == '${this.dataValue}'`);
}
where = where.join(" || ");
if (this.where) {
where = `(${this.where}) && (${where})`;
}
return this.getCommand({
field: this._cloudDataPostField(),
where
}).then((res) => {
this.selected = res.result.data;
return res.result.data;
});
},
// 回显 Cloud 数据 (树形)
getCloudDataTreeValue() {
return this.getCommand({
field: this._cloudDataPostField(),
getTreePath: {
startWith: `${this.selfField}=='${this.dataValue}'`
}
}).then((res) => {
let treePath = [];
this._extractTreePath(res.result.data, treePath);
this.selected = treePath;
return treePath;
});
},
getCommand(options = {}) {
let db = common_vendor.Ws.database(this.spaceInfo);
const action = options.action || this.action;
if (action) {
db = db.action(action);
}
const collection = options.collection || this.collection;
db = db.collection(collection);
const where = options.where || this.where;
if (!(!where || !Object.keys(where).length)) {
db = db.where(where);
}
const field = options.field || this.field;
if (field) {
db = db.field(field);
}
const orderby = options.orderby || this.orderby;
if (orderby) {
db = db.orderBy(orderby);
}
const current = options.pageCurrent !== void 0 ? options.pageCurrent : this.page.current;
const size = options.pageSize !== void 0 ? options.pageSize : this.page.size;
const getCount = options.getcount !== void 0 ? options.getcount : this.getcount;
const getTree = options.gettree !== void 0 ? options.gettree : this.gettree;
const getOptions = {
getCount,
getTree
};
if (options.getTreePath) {
getOptions.getTreePath = options.getTreePath;
}
db = db.skip(size * (current - 1)).limit(size).get(getOptions);
return db;
},
_cloudDataPostField() {
let fields = [this.field];
if (this.parentField) {
fields.push(`${this.parentField} as parent_value`);
}
return fields.join(",");
},
_cloudDataTreeWhere() {
let result = [];
let selected = this.selected;
let parentField = this.parentField;
if (parentField) {
result.push(`${parentField} == null || ${parentField} == ""`);
}
if (selected.length) {
for (var i = 0; i < selected.length - 1; i++) {
result.push(`${parentField} == '${selected[i].value}'`);
}
}
let where = [];
if (this.where) {
where.push(`(${this.where})`);
}
if (result.length) {
where.push(`(${result.join(" || ")})`);
}
return where.join(" && ");
},
_cloudDataNodeWhere() {
let where = [];
let selected = this.selected;
if (selected.length) {
where.push(`${this.parentField} == '${selected[selected.length - 1].value}'`);
}
where = where.join(" || ");
if (this.where) {
return `(${this.where}) && (${where})`;
}
return where;
},
_getWhereByForeignKey() {
let result = [];
let whereField = this._getForeignKeyByField();
if (whereField) {
result.push(`${whereField} == '${this.dataValue}'`);
}
if (this.where) {
return `(${this.where}) && (${result.join(" || ")})`;
}
return result.join(" || ");
},
_getForeignKeyByField() {
let fields = this.field.split(",");
let whereField = null;
for (let i = 0; i < fields.length; i++) {
const items = fields[i].split("as");
if (items.length < 2) {
continue;
}
if (items[1].trim() === "value") {
whereField = items[0].trim();
break;
}
}
return whereField;
},
_updateBindData(node) {
const {
dataList,
hasNodes
} = this._filterData(this._treeData, this.selected);
let isleaf = this._stepSearh === false && !hasNodes;
if (node) {
node.isleaf = isleaf;
}
this.dataList = dataList;
this.selectedIndex = dataList.length - 1;
if (!isleaf && this.selected.length < dataList.length) {
this.selected.push({
value: null,
text: "请选择"
});
}
return {
isleaf,
hasNodes
};
},
_updateSelected() {
let dl = this.dataList;
let sl = this.selected;
let textField = this.map.text;
let valueField = this.map.value;
for (let i = 0; i < sl.length; i++) {
let value = sl[i].value;
let dl2 = dl[i];
for (let j = 0; j < dl2.length; j++) {
let item2 = dl2[j];
if (item2[valueField] === value) {
sl[i].text = item2[textField];
break;
}
}
}
},
_filterData(data, paths) {
let dataList = [];
let hasNodes = true;
dataList.push(data.filter((item) => {
return item.parent_value === null || item.parent_value === void 0 || item.parent_value === "";
}));
for (let i = 0; i < paths.length; i++) {
let value = paths[i].value;
let nodes = data.filter((item) => {
return item.parent_value === value;
});
if (nodes.length) {
dataList.push(nodes);
} else {
hasNodes = false;
}
}
return {
dataList,
hasNodes
};
},
_extractTree(nodes, result, parent_value) {
let valueField = this.map.value;
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i];
let child = {};
for (let key in node) {
if (key !== "children") {
child[key] = node[key];
}
}
if (parent_value !== null && parent_value !== void 0 && parent_value !== "") {
child.parent_value = parent_value;
}
result.push(child);
let children = node.children;
if (children) {
this._extractTree(children, result, node[valueField]);
}
}
},
_extractTreePath(nodes, result) {
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i];
let child = {};
for (let key in node) {
if (key !== "children") {
child[key] = node[key];
}
}
result.push(child);
let children = node.children;
if (children) {
this._extractTreePath(children, result);
}
}
},
_findNodePath(key, nodes, path = []) {
let textField = this.map.text;
let valueField = this.map.value;
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i];
let children = node.children;
let text = node[textField];
let value = node[valueField];
path.push({
value,
text
});
if (value === key) {
return path;
}
if (children) {
const p = this._findNodePath(key, children, path);
if (p.length) {
return p;
}
}
path.pop();
}
return [];
}
}
};
exports.dataPicker = dataPicker;
@@ -0,0 +1,152 @@
"use strict";
const uni_modules_uniDataPicker_components_uniDataPickerview_uniDataPicker = require("./uni-data-picker.js");
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "UniDataPickerView",
emits: ["nodeclick", "change", "datachange", "update:modelValue"],
mixins: [uni_modules_uniDataPicker_components_uniDataPickerview_uniDataPicker.dataPicker],
props: {
managedMode: {
type: Boolean,
default: false
},
ellipsis: {
type: Boolean,
default: true
}
},
created() {
if (!this.managedMode) {
this.$nextTick(() => {
this.loadData();
});
}
},
methods: {
onPropsChange() {
this._treeData = [];
this.selectedIndex = 0;
this.$nextTick(() => {
this.loadData();
});
},
handleSelect(index) {
this.selectedIndex = index;
},
handleNodeClick(item, i, j) {
if (item.disable) {
return;
}
const node = this.dataList[i][j];
const text = node[this.map.text];
const value = node[this.map.value];
if (i < this.selected.length - 1) {
this.selected.splice(i, this.selected.length - i);
this.selected.push({
text,
value
});
} else if (i === this.selected.length - 1) {
this.selected.splice(i, 1, {
text,
value
});
}
if (node.isleaf) {
this.onSelectedChange(node, node.isleaf);
return;
}
const {
isleaf,
hasNodes
} = this._updateBindData();
if (this.isLocalData) {
this.onSelectedChange(node, !hasNodes || isleaf);
} else if (this.isCloudDataList) {
this.onSelectedChange(node, true);
} else if (this.isCloudDataTree) {
if (isleaf) {
this.onSelectedChange(node, node.isleaf);
} else if (!hasNodes) {
this.loadCloudDataNode((data) => {
if (!data.length) {
node.isleaf = true;
} else {
this._treeData.push(...data);
this._updateBindData(node);
}
this.onSelectedChange(node, node.isleaf);
});
}
}
},
updateData(data) {
this._treeData = data.treeData;
this.selected = data.selected;
if (!this._treeData.length) {
this.loadData();
} else {
this._updateBindData();
}
},
onDataChange() {
this.$emit("datachange");
},
onSelectedChange(node, isleaf) {
if (isleaf) {
this._dispatchEvent();
}
if (node) {
this.$emit("nodeclick", node);
}
},
_dispatchEvent() {
this.$emit("change", this.selected.slice(0));
}
}
};
if (!Array) {
const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
_easycom_uni_load_more2();
}
const _easycom_uni_load_more = () => "../../../uni-load-more/components/uni-load-more/uni-load-more.js";
if (!Math) {
_easycom_uni_load_more();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: !_ctx.isCloudDataList
}, !_ctx.isCloudDataList ? {
b: common_vendor.f(_ctx.selected, (item, index, i0) => {
return {
a: common_vendor.t(item.text || ""),
b: index,
c: index == _ctx.selectedIndex ? 1 : "",
d: common_vendor.o(($event) => $options.handleSelect(index), index)
};
})
} : {}, {
c: common_vendor.f(_ctx.dataList[_ctx.selectedIndex], (item, j, i0) => {
return common_vendor.e({
a: common_vendor.t(item[_ctx.map.text]),
b: _ctx.selected.length > _ctx.selectedIndex && item[_ctx.map.value] == _ctx.selected[_ctx.selectedIndex].value
}, _ctx.selected.length > _ctx.selectedIndex && item[_ctx.map.value] == _ctx.selected[_ctx.selectedIndex].value ? {} : {}, {
c: !!item.disable ? 1 : "",
d: j,
e: common_vendor.o(($event) => $options.handleNodeClick(item, _ctx.selectedIndex, j), j)
});
}),
d: _ctx.loading
}, _ctx.loading ? {
e: common_vendor.p({
contentText: _ctx.loadMore,
status: "loading"
})
} : {}, {
f: _ctx.errorMessage
}, _ctx.errorMessage ? {
g: common_vendor.t(_ctx.errorMessage)
} : {});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.vue"]]);
wx.createComponent(Component);
@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"uni-load-more": "../../../uni-load-more/components/uni-load-more/uni-load-more"
}
}
@@ -0,0 +1 @@
<view class="uni-data-pickerview"><scroll-view wx:if="{{a}}" class="selected-area" scroll-x="true"><view class="selected-list"><view wx:for="{{b}}" wx:for-item="item" wx:key="b" class="{{['selected-item', item.c && 'selected-item-active']}}" bindtap="{{item.d}}"><text>{{item.a}}</text></view></view></scroll-view><view class="tab-c"><scroll-view class="list" scroll-y="{{true}}"><view wx:for="{{c}}" wx:for-item="item" wx:key="d" class="{{['item', item.c && 'is-disabled']}}" bindtap="{{item.e}}"><text class="item-text">{{item.a}}</text><view wx:if="{{item.b}}" class="check"></view></view></scroll-view><view wx:if="{{d}}" class="loading-cover"><uni-load-more wx:if="{{e}}" class="load-more" u-i="51653c41-0" bind:__l="__l" u-p="{{e}}"></uni-load-more></view><view wx:if="{{f}}" class="error-message"><text class="error-text">{{g}}</text></view></view></view>
@@ -0,0 +1,134 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.uni-data-pickerview {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
height: 100%;
}
.error-text {
color: #DD524D;
}
.loading-cover {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.5);
display: flex;
flex-direction: column;
align-items: center;
z-index: 1001;
}
.load-more {
margin: auto;
}
.error-message {
background-color: #fff;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
padding: 15px;
opacity: 0.9;
z-index: 102;
}
.selected-list {
display: flex;
flex-wrap: nowrap;
flex-direction: row;
padding: 0 5px;
border-bottom: 1px solid #f8f8f8;
}
.selected-item {
margin-left: 10px;
margin-right: 10px;
padding: 12px 0;
text-align: center;
white-space: nowrap;
}
.selected-item-text-overflow {
width: 168px;
/* fix nvue */
overflow: hidden;
width: 6em;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
}
.selected-item-active {
border-bottom: 2px solid #007aff;
}
.selected-item-text {
color: #007aff;
}
.tab-c {
position: relative;
flex: 1;
display: flex;
flex-direction: row;
overflow: hidden;
}
.list {
flex: 1;
}
.item {
padding: 12px 15px;
/* border-bottom: 1px solid #f0f0f0; */
display: flex;
flex-direction: row;
justify-content: space-between;
}
.is-disabled {
opacity: 0.5;
}
.item-text {
/* flex: 1; */
color: #333333;
}
.item-text-overflow {
width: 280px;
/* fix nvue */
overflow: hidden;
width: 20em;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
}
.check {
margin-right: 5px;
border: 2px solid #007aff;
border-left: 0;
border-top: 0;
height: 12px;
width: 6px;
transform-origin: center;
transition: all 0.3s;
transform: rotate(45deg);
}