points.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="container">
  3. <cu-custom id="custom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
  5. :isBack="true">
  6. <block slot="backText">返回</block>
  7. <block slot="content">
  8. {{ title }}
  9. </block>
  10. </cu-custom>
  11. <My_listbox ref="List" @getlist="getList" :empty="empty">
  12. <view :class="[isActive(item[idKey])]" v-for="item in list" :key="item[idKey]" @click="onSelect(item)">
  13. {{ item[showKey] }}
  14. </view>
  15. <view style="height:22vw;" />
  16. </My_listbox>
  17. <view class="but-box">
  18. <view style="width: 75vw;">
  19. <u-button :disabled="!value.length" type="primary" text="确定选择" color="rgba(42,106,242,.8)"
  20. loadingText="执行中..." :loading="loading" @click="submit" />
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. name: "points",
  28. computed: {
  29. isActive() {
  30. return function (id) {
  31. return this.value.some(v => v == id) ? "active item" : "item"
  32. };
  33. }
  34. },
  35. data() {
  36. return {
  37. list: [],
  38. ...this.$Http.route.data.param,
  39. empty: true,
  40. title: '',
  41. idKey: "",
  42. showKey: "",
  43. loading: false,
  44. value: [],
  45. showList: [],
  46. }
  47. },
  48. onLoad(options) {
  49. let data = this.$Http.route.data;
  50. this.title = '选择' + data.label
  51. this.param = data.param;
  52. this.idKey = data.idKey;
  53. this.showKey = data.showKey;
  54. this.value = data.value.value;
  55. this.showList = data.value.showList;
  56. this.getList(true)
  57. },
  58. methods: {
  59. getList(init = false) {
  60. if (this.loading) return;
  61. let param = this.param;
  62. if (init) {
  63. param.content.pageNumber = 1;
  64. param.content.pageSize = param.content.pageSize || 20;
  65. param.content.pageTotal = 1;
  66. };
  67. if (param.content.pageNumber > param.content.pageTotal) return;
  68. this.loading = true;
  69. return this.$Http.basic(param).then(res => {
  70. this.loading = false;
  71. this.$refs.List.setHeight();
  72. console.log("选择列表", res)
  73. if (this.cutoff(res.msg)) return;
  74. this.$refs.List.RefreshToComplete();
  75. this.empty = res.total == 0;
  76. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  77. param.content.pageNumber = res.pageNumber + 1;
  78. param.content.pageTotal = res.pageTotal;
  79. })
  80. },
  81. onSelect(item) {
  82. let id = item[this.idKey];
  83. if (this.value.some(v => v == id)) {
  84. this.value = this.value.filter(v => v != id)
  85. this.showList = this.showList.filter(v => v[this.showKey] != item[this.showKey])
  86. } else {
  87. this.value.push(id);
  88. this.showList.push(item[this.showKey])
  89. }
  90. },
  91. submit() {
  92. this.$Http.handleAdd({
  93. value: this.value,
  94. showList: this.showList,
  95. })
  96. }
  97. },
  98. onUnload() {
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .item {
  104. display: flex;
  105. align-items: center;
  106. justify-content: space-between;
  107. padding: 10px;
  108. box-sizing: border-box;
  109. background: #fff;
  110. width: 355px;
  111. margin: 10px auto;
  112. border-radius: 4px;
  113. }
  114. .active {
  115. background: #0054E1;
  116. color: #fff;
  117. }
  118. .but-box {
  119. position: absolute;
  120. width: 100vw;
  121. bottom: 30px;
  122. display: flex;
  123. justify-content: center;
  124. /deep/ .u-button__text,
  125. /deep/.u-button__loading-text {
  126. font-size: 14px !important;
  127. }
  128. /deep/.u-loading-icon__spinner {
  129. width: 17.25px !important;
  130. height: 17.25px !important;
  131. }
  132. }
  133. </style>