You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
4.5 KiB
181 lines
4.5 KiB
2 years ago
|
"use strict";
|
||
|
const common_vendor = require("../../common/vendor.js");
|
||
|
const common_assets = require("../../common/assets.js");
|
||
|
const _sfc_main = {
|
||
|
props: {
|
||
|
data: {
|
||
|
type: Array,
|
||
|
default: () => [
|
||
|
{
|
||
|
label: "label",
|
||
|
value: "value"
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
valueType: {
|
||
|
type: Object,
|
||
|
default: {
|
||
|
label: "label",
|
||
|
value: "value"
|
||
|
}
|
||
|
},
|
||
|
value: {
|
||
|
type: String,
|
||
|
default: "全部"
|
||
|
},
|
||
|
clearable: {
|
||
|
type: Boolean,
|
||
|
default: false
|
||
|
},
|
||
|
filterable: {
|
||
|
type: Boolean,
|
||
|
default: false
|
||
|
},
|
||
|
searchType: {
|
||
|
type: Number,
|
||
|
default: 1
|
||
|
},
|
||
|
placeholder: {
|
||
|
type: String,
|
||
|
default: "请选择"
|
||
|
},
|
||
|
noDataText: {
|
||
|
type: String,
|
||
|
default: "暂无数据"
|
||
|
},
|
||
|
arrLeft: {
|
||
|
type: Number,
|
||
|
default: 20
|
||
|
},
|
||
|
size: {
|
||
|
type: Number,
|
||
|
default: 240
|
||
|
}
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
show: false,
|
||
|
readonly: true,
|
||
|
isClick: false,
|
||
|
totalArr: [],
|
||
|
showData: []
|
||
|
};
|
||
|
},
|
||
|
watch: {
|
||
|
"filterable": {
|
||
|
immediate: true,
|
||
|
deep: true,
|
||
|
handler(news) {
|
||
|
this.readonly = !news;
|
||
|
}
|
||
|
},
|
||
|
"data": {
|
||
|
immediate: true,
|
||
|
deep: true,
|
||
|
handler(news) {
|
||
|
this.showData = news;
|
||
|
this.totalArr = news;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
created() {
|
||
|
},
|
||
|
methods: {
|
||
|
sjpd() {
|
||
|
if (this.value) {
|
||
|
this.clearItem();
|
||
|
} else {
|
||
|
this.openSelect();
|
||
|
}
|
||
|
},
|
||
|
openSelect() {
|
||
|
this.show = !this.show;
|
||
|
this.isClick = !this.isClick;
|
||
|
},
|
||
|
change(item) {
|
||
|
if (this.value != item[this.valueType]) {
|
||
|
this.$emit("input", item[this.valueType.value]);
|
||
|
this.$emit("change", item[this.valueType.value]);
|
||
|
}
|
||
|
this.show = false;
|
||
|
this.isClick = false;
|
||
|
this.showData = this.data;
|
||
|
},
|
||
|
clearItem() {
|
||
|
if (this.clearable) {
|
||
|
this.$emit("input", "");
|
||
|
this.$emit("change", "");
|
||
|
}
|
||
|
},
|
||
|
selectData(e) {
|
||
|
let sel = e.detail.value;
|
||
|
if (sel) {
|
||
|
let arrCons = [];
|
||
|
let selVal = [];
|
||
|
this.data.forEach((item) => {
|
||
|
arrCons.push(item);
|
||
|
});
|
||
|
arrCons.forEach((item) => {
|
||
|
console.log(item, sel, "arrCons---", item.label.indexOf(sel));
|
||
|
if (this.searchType == 1) {
|
||
|
if (item[this.valueType.label].indexOf(sel) != -1) {
|
||
|
selVal.push(item);
|
||
|
}
|
||
|
} else {
|
||
|
if (item[this.valueType.label] == sel) {
|
||
|
selVal.push(item);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
this.show = true;
|
||
|
this.showData = selVal;
|
||
|
} else {
|
||
|
this.showData = this.data;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
beforeDestroy() {
|
||
|
}
|
||
|
};
|
||
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||
|
return common_vendor.e({
|
||
|
a: $data.isClick,
|
||
|
b: common_vendor.o((...args) => $options.selectData && $options.selectData(...args)),
|
||
|
c: $props.value,
|
||
|
d: $data.readonly,
|
||
|
e: $data.readonly,
|
||
|
f: $props.placeholder,
|
||
|
g: common_vendor.o((...args) => $options.openSelect && $options.openSelect(...args)),
|
||
|
h: !$props.value && !$props.clearable || $props.value && !$props.clearable || !$props.value && $props.clearable && !$props.filterable
|
||
|
}, !$props.value && !$props.clearable || $props.value && !$props.clearable || !$props.value && $props.clearable && !$props.filterable ? {
|
||
|
i: common_vendor.n($data.show ? "arrow_down" : "arrow_up")
|
||
|
} : {}, {
|
||
|
j: $props.value && $props.clearable
|
||
|
}, $props.value && $props.clearable ? {
|
||
|
k: common_assets._imports_0
|
||
|
} : {}, {
|
||
|
l: common_vendor.o((...args) => $options.sjpd && $options.sjpd(...args)),
|
||
|
m: common_vendor.n($data.isClick ? "select_input_select" : ""),
|
||
|
n: $data.show
|
||
|
}, $data.show ? common_vendor.e({
|
||
|
o: common_vendor.f($data.showData, (item, index, i0) => {
|
||
|
return {
|
||
|
a: common_vendor.t(item.label),
|
||
|
b: index,
|
||
|
c: $props.value == item[$props.valueType.value] ? 1 : "",
|
||
|
d: common_vendor.o(($event) => $options.change(item), index)
|
||
|
};
|
||
|
}),
|
||
|
p: !$data.showData.length
|
||
|
}, !$data.showData.length ? {
|
||
|
q: common_vendor.t($props.noDataText)
|
||
|
} : {}, {
|
||
|
r: common_vendor.o(() => {
|
||
|
})
|
||
|
}) : {}, {
|
||
|
s: $props.size + "rpx"
|
||
|
});
|
||
|
}
|
||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-7a3666ce"], ["__file", "F:/物流/logPm/compoment/cus-selects-fan/cus-selects-fan.vue"]]);
|
||
|
wx.createComponent(Component);
|