加油站付款小程序,打印小票
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.

96 lines
1.8 KiB

6 months ago
  1. <template>
  2. <!-- 协议配置弹出层组件 -->
  3. <view>
  4. <uv-parse
  5. v-if="tiled"
  6. :content="content">
  7. </uv-parse>
  8. <uv-popup
  9. v-else
  10. :customStyle="{height: '75vh'}"
  11. ref="popup">
  12. <view id="config">
  13. <uv-parse :content="content"></uv-parse>
  14. </view>
  15. </uv-popup>
  16. </view>
  17. </template>
  18. <script>
  19. import { mapState } from 'vuex'
  20. export default {
  21. name:"configPopup",
  22. props : {
  23. findValue : {//查找对应的值
  24. type : String,
  25. },
  26. findKey : {//查找的键
  27. type : String,
  28. default : 'keyValue'
  29. },
  30. contentKey : {//展示内容的键
  31. type : String,
  32. default : 'content'
  33. },
  34. languageContentKey : {//国际化展示内容的键
  35. type : Object,
  36. },
  37. index : {//索引查找,优先级高于查找
  38. type : Number,
  39. },
  40. tiled : {
  41. default : false,
  42. type : Boolean,
  43. }
  44. },
  45. data() {
  46. return {
  47. };
  48. },
  49. computed : {
  50. ...mapState(['configList']),
  51. locale(){
  52. return this.$t('components.config.configPopup')
  53. },
  54. obj(){
  55. if(typeof this.index == 'number'){
  56. return this.configList[this.index]
  57. }
  58. for(let i = 0; i < this.configList.length; i++){
  59. if(this.configList[i][this.findKey] == this.findValue){
  60. return this.configList[i]
  61. }
  62. }
  63. },
  64. objKey(){
  65. if(this.languageContentKey
  66. && this.languageContentKey[this.$i18n.locale]){
  67. return this.languageContentKey[this.$i18n.locale]
  68. }
  69. return this.contentKey
  70. },
  71. content(){
  72. if(!this.obj){
  73. return `<h3>${this.locale.noData}</h3>`
  74. }
  75. return this.obj[this.objKey]
  76. }
  77. },
  78. methods : {
  79. open(type = 'bottom'){
  80. if(this.tiled){
  81. return
  82. }
  83. this.$refs.popup.open(type);
  84. },
  85. },
  86. }
  87. </script>
  88. <style scoped lang="scss">
  89. #config{
  90. padding: 20rpx;
  91. line-height: 50rpx;
  92. }
  93. </style>