carPopu.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view>
  3. <uni-popup ref="popup" type="bottom">
  4. <div class="popup">
  5. <div class="popup-top">
  6. <div class="top-left">选择周转车</div>
  7. <div class="top-right">
  8. <button @click="close">关闭</button>
  9. <button @click="confirm">确定</button>
  10. </div>
  11. </div>
  12. <view class="search-box">
  13. <uni-easyinput
  14. prefixIcon="search"
  15. v-model="searchKey"
  16. placeholder="请输入搜索内容"
  17. >
  18. </uni-easyinput>
  19. <view class="search-botton">搜索</view>
  20. </view>
  21. <uni-table
  22. border
  23. stripe
  24. type="selection"
  25. ref="tableRef"
  26. emptyText="暂无更多数据"
  27. @selection-change="selectionChange"
  28. >
  29. <uni-tr>
  30. <uni-th align="center">编码</uni-th>
  31. <uni-th align="center">名称</uni-th>
  32. </uni-tr>
  33. <uni-tr v-for="(item, index) in tableDataShow" :key="index">
  34. <uni-td>{{ item.code }}</uni-td>
  35. <uni-td>{{ item.name }}</uni-td>
  36. </uni-tr>
  37. </uni-table>
  38. </div>
  39. </uni-popup>
  40. </view>
  41. </template>
  42. <script>
  43. import { getByRootLevelId } from "@/api/classifyManage/itemInformation";
  44. export default {
  45. components: {},
  46. data() {
  47. return {
  48. searchKey: "",
  49. tableData: [],
  50. selectedIndexs: [],
  51. };
  52. },
  53. mounted() {
  54. this._getList();
  55. },
  56. computed: {
  57. tableDataShow() {
  58. return this.tableData.filter((item) => {
  59. if (!this.searchKey) return true;
  60. return (
  61. item.code.includes(this.searchKey) ||
  62. item.name.includes(this.searchKey)
  63. );
  64. });
  65. },
  66. },
  67. methods: {
  68. open() {
  69. this.$refs.popup.open();
  70. },
  71. close() {
  72. this.selectedIndexs = [];
  73. this.$refs.tableRef.clearSelection();
  74. this.$refs.popup.close();
  75. },
  76. confirm() {
  77. if (!this.selectedIndexs.length) {
  78. return uni.showToast({
  79. title: "请选择周转车",
  80. icon: "none",
  81. });
  82. }
  83. this.$emit(
  84. "confirm",
  85. this.tableData.filter((itm, index) =>
  86. this.selectedIndexs.includes(index)
  87. )
  88. );
  89. this.close();
  90. },
  91. // 多选
  92. selectionChange(e) {
  93. this.selectedIndexs = e.detail.index;
  94. },
  95. async _getList() {
  96. const res = await getByRootLevelId(7);
  97. this.tableData = res;
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="scss" scoped>
  103. .popup {
  104. width: 100%;
  105. height: 900rpx;
  106. background: #fff;
  107. .popup-top {
  108. width: 100%;
  109. display: flex;
  110. align-items: center;
  111. justify-content: space-between;
  112. height: 80rpx;
  113. background: rgba(21, 122, 44, 1);
  114. color: #fff;
  115. .top-left {
  116. font-size: 32rpx;
  117. margin-left: 10rpx;
  118. }
  119. .top-right {
  120. display: flex;
  121. align-items: center;
  122. justify-content: flex-end;
  123. margin-right: 10rpx;
  124. uni-button {
  125. background: rgba(21, 122, 44, 1);
  126. color: #fff;
  127. width: 100rpx;
  128. height: 60rpx;
  129. line-height: 60rpx;
  130. font-size: 28rpx;
  131. padding: 0;
  132. border: 1rpx solid #fff;
  133. margin-left: 20rpx;
  134. }
  135. }
  136. }
  137. .search-box {
  138. display: flex;
  139. align-items: center;
  140. justify-content: space-around;
  141. width: 94%;
  142. margin: 20rpx auto;
  143. .search-botton {
  144. background: rgba(112, 182, 3, 1);
  145. color: #fff;
  146. padding: 10rpx 20rpx;
  147. border-radius: 8rpx;
  148. margin-left: 20rpx;
  149. }
  150. }
  151. }
  152. </style>