提交 1343fe66 编写于 作者: zcdtk's avatar zcdtk

单选框列表组件代码格式化

上级 ca71dc91
<template>
<ion-list class="app-mobile-radio-list">
<ion-radio-group :value="value" @ionChange="change">
<ion-item v-for="(item,index) in options" :key="index">
<ion-label>{{item.text}}</ion-label>
<ion-radio :disabled="item.disabled" color="success" :value="item.value"></ion-radio>
</ion-item>
</ion-radio-group>
</ion-list>
<ion-list class="app-mobile-radio-list">
<ion-radio-group :value="value" @ionChange="change">
<ion-item v-for="(item,index) in options" :key="index">
<ion-label>{{item.text}}</ion-label>
<ion-radio :disabled="item.disabled" color="success" :value="item.value"></ion-radio>
</ion-item>
</ion-radio-group>
</ion-list>
</template>
<script lang="ts">
import {
Vue,
Component,
Prop,
Provide,
Emit,
Watch
} from "vue-property-decorator";
import { Vue, Component, Prop } from "vue-property-decorator";
import CodeListService from "@app-core/service/app/code-list-service";
@Component({
components: {}
components: {}
})
export default class AppMobRadio extends Vue {
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof AppMobRadio
*/
public codeListService: CodeListService = new CodeListService();
public codeListService: CodeListService = CodeListService.getInstance();
/**
* 代码表标识
......@@ -39,7 +32,7 @@ export default class AppMobRadio extends Vue {
* @type {string}
* @memberof AppMobRadio
*/
@Prop() public tag?: string;
@Prop() public tag!: string;
/**
* 代码表类型
......@@ -75,29 +68,53 @@ export default class AppMobRadio extends Vue {
/**
* change事件
*
* @param {*} data
* @memberof AppMobRadio
*/
public change(data: any) {
this.$emit("change", data.detail.value);
this.$emit("change", data.detail.value);
}
/**
* vue 生命周期
*
* @returns
* @memberof AppMobRadio
*/
public created() {
if (this.tag && this.type) {
if (Object.is(this.type, "dynamic")) {
this.codeListService
.getItems(this.tag)
.then((res: any) => {
this.options = res;
})
.catch((error: any) => {
this.options = [];
});
if (!this.tag || !this.type) {
return;
}
this.loadItems();
}
/**
* 加载 数据
*
* @private
* @returns {Promise<any>}
* @memberof AppMobRadio
*/
private async loadItems(): Promise<any> {
if (Object.is(this.type, 'dynamic')) {
const response: any = await this.codeListService.getItems(this.tag);
if (response && response.status === 200) {
this.options = response.data;
} else {
this.options = [];
}
} else {
this.options = this.$store.getters.getCodeListItems(this.tag);
this.options = this.$store.getters.getCodeListItems(this.tag);
}
}
}
public mounted(){
/**
* vue 生命周期
*
* @memberof AppMobRadio
*/
public mounted() {
this.changeLabelStyle();
}
......@@ -106,10 +123,12 @@ export default class AppMobRadio extends Vue {
* @memberof AppMobPicture
*/
public changeLabelStyle() {
document.querySelectorAll(".app-mobile-radio-list").forEach((element: any) => {
let prev = this.getNearEle(element, 1);
prev.style.transform = 'none';
})
document.querySelectorAll(".app-mobile-radio-list").forEach((element: any) => {
let prev = this.getNearEle(element, 1);
if (prev) {
prev.style.transform = 'none';
}
})
}
/**
......@@ -118,20 +137,21 @@ export default class AppMobRadio extends Vue {
* @memberof AppMobPicture
*/
public getNearEle(ele: any, type: any) {
type = type == 1 ? "previousSibling" : "nextSibling";
var nearEle = ele[type];
while (nearEle) {
if (nearEle.nodeType === 1) {
return nearEle;
type = type == 1 ? "previousSibling" : "nextSibling";
var nearEle = ele[type];
while (nearEle) {
if (nearEle.nodeType === 1) {
return nearEle;
}
nearEle = nearEle[type];
if (!nearEle) {
break;
}
}
nearEle = nearEle[type];
if (!nearEle) {
break;
}
}
return null;
return null;
}
}
</script>
<style lang="less">
</style>
\ No newline at end of file
......@@ -10,7 +10,7 @@
},
"rules": {
"quotemark": false,
"indent": [true, "spaces", 2],
"indent": [true, "spaces", 4],
"interface-name": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册