tm-stepsItem.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="tm-stepsItem ">
  3. <view @click="onclick" class="px-10 flex-center flex-col tm-stepsItem-wk" >
  4. <view class="tm-stepsItem-dian rounded flex-center"
  5. :class="[
  6. isSu&&!isFa&&model=='icon'?' su '+ color +' shadow-'+color+'-5':'',
  7. isSu&&!isFa&&model=='number'?' su '+color +' shadow-'+color+'-5' :'',
  8. isFa?'fa red' +' shadow-red-5':'',
  9. isWa&&!isFa&&!isSu?(black_tmeme?'wa bk grey-lighten-4 text-grey':`wa grey-lighten-4 text text-grey`):'',
  10. ]"
  11. >
  12. <text v-if="model=='number'">{{setNum}}</text>
  13. <view v-if="model=='icon'">
  14. <tm-icons size="20" v-if="isSu&&!isFa" name="icon-check"></tm-icons>
  15. <tm-icons size="20" v-if="isFa" name="icon-times"></tm-icons>
  16. <view v-if="isWa&&!isFa&&!isSu" class="tm-stepsItem-dian-quan rounded " :class="[color]"></view>
  17. </view>
  18. </view>
  19. <view class="tm-stepsItem-text text-size-xs py-10 "><slot></slot></view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. /**
  25. * 步骤条子组件
  26. * @description 只能在tm-steps中使用。默认插槽显示底部内容。
  27. * @property {String} model = [number|icon] 默认:number,两种模式,number:数字,icon:图标模式。
  28. * @property {String} color = [] 默认:primary,主题色。
  29. * @property {Boolean} wait = [true|false] 默认:true,待流转。显示错误状态。优先级最低
  30. * @property {Boolean} fail = [true|false] 默认:false,显示错误状态。优先级最高
  31. * @property {Boolean} success = [true|false] 默认:false,显示错误状态。优先级高于wait.
  32. * @property {Number|String} step = [] 默认:0,model=number时,显示的数字文本。
  33. * @property {Boolean} black = [true|false] 默认:false,暗黑模式。
  34. * @property {Function} click 点击事件。
  35. * @example <tm-stepsItem :fail="true" model="icon" ></tm-stepsItem>
  36. */
  37. export default {
  38. name:"tm-stepsItem",
  39. props:{
  40. black:{
  41. type:Boolean|String,
  42. default:null
  43. },
  44. step:{
  45. type:Number|String,
  46. default:0
  47. },
  48. success:{
  49. type:Boolean,
  50. default:false
  51. },
  52. fail:{
  53. type:Boolean,
  54. default:false
  55. },
  56. wait:{
  57. type:Boolean,
  58. default:true
  59. },
  60. color:{
  61. type:String,
  62. default:'primary'
  63. },
  64. // number|icon
  65. model:{
  66. type:String,
  67. default:'number'
  68. }
  69. },
  70. data() {
  71. return {
  72. width:0,
  73. su_selft:false,
  74. fa_selft:false,
  75. wa_selft:false,
  76. };
  77. },
  78. watch:{
  79. success:function(newval){
  80. this.isSu = newval;
  81. },
  82. fail:function(newval){
  83. this.isFa = newval;
  84. },
  85. wait:function(newval){
  86. this.isWa = newval;
  87. },
  88. },
  89. computed:{
  90. black_tmeme: function() {
  91. if (this.black !== null) return this.black;
  92. return this.$tm.vx.state().tmVuetify.black;
  93. },
  94. setNum:function(){
  95. return this.step;
  96. },
  97. isSu:{
  98. get:function(){
  99. return this.su_selft;
  100. },
  101. set:function(val){
  102. this.su_selft = val;
  103. }
  104. },
  105. isFa:{
  106. get:function(){
  107. return this.fa_selft;
  108. },
  109. set:function(val){
  110. this.fa_selft = val;
  111. }
  112. },
  113. isWa:{
  114. get:function(){
  115. return this.wa_selft;
  116. },
  117. set:function(val){
  118. this.wa_selft = val;
  119. }
  120. },
  121. },
  122. async mounted() {
  123. this.isSu = this.success;
  124. this.isFa = this.fail;
  125. this.isWa = this.wait;
  126. this.$nextTick(async function (){
  127. let tbs = await this.$Querey(".tm-stepsItem");
  128. this.width = tbs[0].width;
  129. })
  130. },
  131. methods: {
  132. setActive({success,fail,wait}) {
  133. this.isSu = success;
  134. if(typeof fail !=='undefined'){
  135. this.isFa = fail;
  136. }
  137. this.isWa = wait;
  138. },
  139. onclick(e){
  140. this.$emit('click',e)
  141. },
  142. },
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .tm-stepsItem{
  147. flex-shrink: 0;
  148. .tm-stepsItem-wk{
  149. position: relative;
  150. top: -18upx;
  151. }
  152. .tm-stepsItem-dian{
  153. width: 36upx;
  154. height: 36upx;
  155. font-size: 22upx;
  156. line-height: 12upx;
  157. .tm-stepsItem-dian-quan{
  158. width: 12upx;
  159. height: 12upx;
  160. }
  161. }
  162. .tm-stepsItem-text{
  163. flex-shrink: 0;
  164. width: 100upx;
  165. text-align: center;
  166. }
  167. }
  168. </style>