| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- Component({
- options: {
- addGlobalClass: true
- },
- properties: {
- iconName: {
- type: String,
- value: "icon-feiyongleixing"
- },
- title: {
- type: String,
- },
- type: {
- type: String,
- value: "全部"
- },
- list: {
- type: Array,
- },
- onChange: {
- type: Function,
- },
- clickOpen: {
- type: Function,
- },
- isEmpty: {
- type: Boolean,
- value: false
- }
- },
- lifetimes: {
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- this.setData({
- actions: this.data.list.map(item => {
- return {
- name: getApp().globalData.Language.getMapText(item.remarks || item.value),
- value: item.value,
- color: item.value == this.data.type ? "#3874F6" : ""
- }
- })
- })
- this.setShowText();
- }
- },
- data: {
- actionShow: false,
- },
- methods: {
- setShowText() {
- try {
- this.setData({
- showText: this.data.actions.find(item => item.value == this.data.type).name
- })
- } catch (error) {
- this.setData({
- showText: '全部'
- })
- }
- },
- setShowArrText(arr) {
- if (arr.length) {
- this.setData({
- showText: arr.map(v => getApp().globalData.Language.getMapText(v))
- })
- } else {
- this.setData({
- showText: '全部'
- })
- }
- },
- openActionSheet() {
- if (this.data.actions.length) this.setData({
- actionShow: true
- })
- this.triggerEvent("clickOpen")
- },
- onSelect(event) {
- const {
- value
- } = event.detail;
- if (this.data.type == value) return this.onCancel();
- this.setData({
- actions: this.data.actions.map(item => {
- item.color = item.value == value ? "#3874F6" : "";
- item.loading = item.value == value ? true : false;
- return item
- })
- })
- this.triggerEvent("onChange", value)
- },
- onCancel() {
- this.setData({
- actionShow: false,
- actions: this.data.actions.map(item => {
- item.loading = false;
- return item
- })
- })
- this.setShowText();
- },
- clearResults() {
- this.setData({
- showText: '全部'
- })
- this.triggerEvent("clickOpen", "clear")
- }
- }
- })
|