selectWork.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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">{{ workerData(item) }}</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. let workOrderStatus = {
  78. 0: '待接收',
  79. 1: '已接收',
  80. 2: '执行中',
  81. 3: '待验收',
  82. 4: '待评价',
  83. 5: '已完成',
  84. 6: '验收不通过',
  85. }
  86. export default {
  87. data() {
  88. return {
  89. tableList: [],
  90. checkData: {},
  91. pageNum: 1,
  92. isEnd: false,
  93. }
  94. },
  95. computed: {
  96. checkListLen() {
  97. if (this.checkData.id) {
  98. return 1;
  99. }
  100. return 0;
  101. },
  102. workerData() {
  103. return (row) => {
  104. return workOrderStatus[row.orderStatus]
  105. }
  106. }
  107. },
  108. onLoad() {
  109. this.doSearch();
  110. },
  111. methods: {
  112. doSearch() {
  113. this.isEnd = false;
  114. this.page = 1;
  115. this.getList();
  116. },
  117. //获取列表信息
  118. getList() {
  119. if (this.isEnd) {
  120. return;
  121. }
  122. uni.showLoading({
  123. title: '加载中'
  124. })
  125. let data = {
  126. pageNum: this.page,
  127. size: 10,
  128. }
  129. getSalesWorkOrder(data).then(res => {
  130. if (this.page === 1) {
  131. this.tableList = res.list;
  132. } else {
  133. this.tableList.push(...res.list);
  134. }
  135. this.page += 1
  136. this.isEnd = this.tableList.length >= res.count;
  137. uni.hideLoading();
  138. }).catch((e) => {
  139. uni.hideLoading();
  140. })
  141. },
  142. selectVal(val, index) {
  143. this.$set(this.tableList[index], 'checked', !this.tableList[index].checked);
  144. this.tableList.forEach((item, i) => {
  145. if (item.id != val.id) {
  146. this.$set(this.tableList[i], 'checked', false)
  147. }
  148. })
  149. if (val.checked) {
  150. this.checkData = val;
  151. } else {
  152. this.checkData = {};
  153. }
  154. },
  155. scrolltolower() {
  156. if (this.isEnd) {
  157. return;
  158. }
  159. this.getList();
  160. },
  161. backAdd() {
  162. this.back();
  163. },
  164. jumpAdd() {
  165. if (!this.checkData.id) {
  166. this.$refs.uToast.show({
  167. type: "warning",
  168. message: "请选择一条工单数据",
  169. })
  170. return;
  171. }
  172. uni.$emit('updateWorkData', {
  173. data: this.checkData,
  174. })
  175. this.backAdd();
  176. }
  177. }
  178. }
  179. </script>
  180. <style scoped lang="scss">
  181. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  182. .mainBox {
  183. height: 100vh;
  184. display: flex;
  185. flex-direction: column;
  186. .wrapper {
  187. // flex: 1;
  188. height: calc(100vh - 196rpx);
  189. overflow: hidden;
  190. }
  191. }
  192. //底部按钮
  193. .footer {
  194. height: 45px;
  195. position: relative;
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: center;
  199. bottom: 0;
  200. width: 100%;
  201. height: 50px;
  202. border-top: 1px solid #eeecec;
  203. background-color: #ffffff;
  204. z-index: 999;
  205. .bottom {
  206. margin-left: 10rpx;
  207. }
  208. .u-reset-button {
  209. position: absolute;
  210. right: 10rpx;
  211. top: 20rpx;
  212. width: 150rpx;
  213. }
  214. }
  215. </style>