123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- const getHeight = require("../../utils/GetRheRemainingHeight");
- Component({
- properties: {
- list: {
- type: Array,
- value: [{
- label: "筛选1",
- index: null,
- showName: "name",
- valueKey: "name",
- selectKey: "id",
- value: "",
- list: [{
- name: "a1",
- id: 0
- }, {
- name: "a2",
- id: 1
- }]
- }]
- },
- show: Boolean,
- handle: Function,
- dateRange: {
- type: Boolean,
- value: true
- },
- zIndex: {
- type: String,
- value: 99999,
- },
- },
- data: {
- startdate: "",
- enddate: "",
- },
- lifetimes: {
- ready() {
- getHeight.getHeight('.head', this).then(res => this.setData({
- listHeight: res - 80
- }));
- }
- },
- methods: {
-
- onSelect(e) {
- const {
- item,
- index,
- i
- } = e.currentTarget.dataset;
- if (this.data.list[index].index == i) {
- this.setData({
- [`list[${index}].value`]: "",
- [`list[${index}].index`]: null
- });
- } else {
- this.setData({
- [`list[${index}].value`]: this.data.list[index].selectKey ? item[this.data.list[index].selectKey] : item,
- [`list[${index}].index`]: i
- });
- }
- },
-
- onClick(e) {
- const {
- name
- } = e.target.dataset;
- if (name == 'reset') {
- this.setData({
- list: this.data.list.map(v => {
- v.value = "";
- v.index = null;
- return v;
- })
- })
- this.triggerEvent("handle", {})
- } else if (name == 'confirm') {
- let obj = {};
- this.data.list.forEach(v => {
- obj[v.valueKey] = v.value;
- });
- if (this.data.dateRange) {
- obj.startdate = this.data.startdate;
- obj.enddate = this.data.enddate;
- };
- this.triggerEvent("handle", obj);
- }
- this.onClose();
- },
-
- changeDate(e) {
- const name = e.currentTarget.dataset.name,
- value = e.detail.value;
- this.setData({
- [name]: value
- })
- },
- onClose() {
- this.setData({
- show: false
- })
- }
- }
- })
|