selectWork.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择工单" @clickLeft="backAdd">
  4. </uni-nav-bar>
  5. <view class="wapper-top">
  6. </view>
  7. <view class="wrapper">
  8. <u-list @scrolltolower="scrolltolower" class="listContent">
  9. <checkbox-group v-for="(item, index) in tableList" :key="index" @change="selectVal(item, index)">
  10. <label>
  11. <view class="listBox">
  12. <view class="listBox-sel">
  13. <checkbox :value="item.id" color="#fff" :checked="item.checked" />
  14. </view>
  15. <view class="listBox-con">
  16. <view class="listBox-bottom">
  17. <view>
  18. <text>工单编号:</text>
  19. <text class="value">{{ item.code }}</text>
  20. </view>
  21. <view>
  22. <text>计划单号:</text>
  23. <text class="value">{{ item.planCode }}</text>
  24. </view>
  25. <view>
  26. <text>计划名称:</text>
  27. <text class="value">{{ item.planName }}</text>
  28. </view>
  29. <view class="label-s">
  30. <text>报工人:</text>
  31. <text class="value">{{ item.executeUserName }}</text>
  32. </view>
  33. <view class="label-s">
  34. <text>验收人:</text>
  35. <text class="value">{{ item.accepterUserName }}</text>
  36. </view>
  37. <view>
  38. <text>验收时间:</text>
  39. <text class="value">{{ item.accepterTime }}</text>
  40. </view>
  41. <view>
  42. <text>开始时间:</text>
  43. <text class="value">{{ item.acceptTime }}</text>
  44. </view>
  45. <view>
  46. <text>结束时间:</text>
  47. <text class="value">{{ item.finishTime }}</text>
  48. </view>
  49. <view>
  50. <text>计划完成时间:</text>
  51. <text class="value">{{ item.planFinishTime }}</text>
  52. </view>
  53. <view>
  54. <text>状态:</text>
  55. <text class="value">已完成</text>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </label>
  61. </checkbox-group>
  62. <u-empty class="noDate" style="margin-top: 20vh" v-if="!tableList.length"></u-empty>
  63. </u-list>
  64. </view>
  65. <view class="footer">
  66. <u-button type="success" size="small" class="u-reset-button" @click="jumpAdd">
  67. <view class="selBtn">选择( {{ checkListLen }} )</view>
  68. </u-button>
  69. </view>
  70. <u-toast ref="uToast"></u-toast>
  71. </view>
  72. </template>
  73. <script>
  74. import {
  75. getSalesWorkOrder
  76. } from '@/api/salesServiceManagement/workOrder/index.js'
  77. export default {
  78. data() {
  79. return {
  80. tableList: [],
  81. checkData: {},
  82. pageNum: 1,
  83. isEnd: false,
  84. }
  85. },
  86. computed: {
  87. checkListLen() {
  88. if (this.checkData.id) {
  89. return 1;
  90. }
  91. return 0;
  92. }
  93. },
  94. onLoad() {
  95. this.doSearch();
  96. },
  97. methods: {
  98. doSearch() {
  99. this.isEnd = false;
  100. this.page = 1;
  101. this.getList();
  102. },
  103. //获取列表信息
  104. getList() {
  105. if (this.isEnd) {
  106. return;
  107. }
  108. uni.showLoading({
  109. title: '加载中'
  110. })
  111. let data = {
  112. pageNum: this.page,
  113. size: 10,
  114. }
  115. getSalesWorkOrder(data).then(res => {
  116. if (this.page === 1) {
  117. this.tableList = res.list;
  118. } else {
  119. this.tableList.push(...res.list);
  120. }
  121. this.page += 1
  122. this.isEnd = this.tableList.length >= res.count;
  123. uni.hideLoading();
  124. }).catch((e) => {
  125. uni.hideLoading();
  126. })
  127. },
  128. selectVal(val, index) {
  129. this.$set(this.tableList[index], 'checked', !this.tableList[index].checked);
  130. this.tableList.forEach((item, i) => {
  131. if (item.id != val.id) {
  132. this.$set(this.tableList[i], 'checked', false)
  133. }
  134. })
  135. if (val.checked) {
  136. this.checkData = val;
  137. } else {
  138. this.checkData = {};
  139. }
  140. },
  141. scrolltolower() {
  142. if (this.isEnd) {
  143. return;
  144. }
  145. this.getList();
  146. },
  147. backAdd() {
  148. this.back();
  149. },
  150. jumpAdd() {
  151. if (!this.checkData.id) {
  152. this.$refs.uToast.show({
  153. type: "warning",
  154. message: "请选择一条工单数据",
  155. })
  156. return;
  157. }
  158. uni.$emit('updateWorkData', {
  159. data: this.checkData,
  160. })
  161. this.backAdd();
  162. }
  163. }
  164. }
  165. </script>
  166. <style scoped lang="scss">
  167. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  168. .mainBox {
  169. height: 100vh;
  170. display: flex;
  171. flex-direction: column;
  172. .wrapper {
  173. // flex: 1;
  174. height: calc(100vh - 196rpx);
  175. overflow: hidden;
  176. }
  177. }
  178. //底部按钮
  179. .footer {
  180. height: 45px;
  181. position: relative;
  182. display: flex;
  183. justify-content: space-between;
  184. align-items: center;
  185. bottom: 0;
  186. width: 100%;
  187. height: 50px;
  188. border-top: 1px solid #eeecec;
  189. background-color: #ffffff;
  190. z-index: 999;
  191. .bottom {
  192. margin-left: 10rpx;
  193. }
  194. .u-reset-button {
  195. position: absolute;
  196. right: 10rpx;
  197. top: 20rpx;
  198. width: 150rpx;
  199. }
  200. }
  201. </style>