inquiryManageList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择采购计划" @clickLeft="handleClose">
  4. </uni-nav-bar>
  5. <view class="searchBox">
  6. <input v-model="searchVal" placeholder="请输入计划编码" class="searchInput" @confirm="doSearch" />
  7. <u-button type="icon-shixiangxinzeng" size="30" @click="doSearch" class="searchBtn">
  8. <view class="iconfont icon-sousuo"></view>
  9. <view class="text">搜索</view>
  10. </u-button>
  11. </view>
  12. <view class="wrapper">
  13. <scroll-view scroll-y class="listContent" @scrolltolower="scrolltolower">
  14. <view v-for="(item, index) in listData" :key="index">
  15. <view class="listBox" @click="selectItem(item, index)">
  16. <view class="listBox-sel">
  17. <view class="radio" :class="{ active: selectedIndex === index }">
  18. <view v-if="selectedIndex === index" class="radio-dot"></view>
  19. </view>
  20. </view>
  21. <view class="listBox-con">
  22. <view class="listBox-top">
  23. <view class="listBox-code">{{ item.planCode }}</view>
  24. <view class="listBox-status">{{ getStatus(item.status) }}</view>
  25. </view>
  26. <view class="listBox-middle">
  27. <view v-if="item.requirementCode">需求编码:{{ item.requirementCode }}</view>
  28. <view>需求部门:{{ item.requireDeptName }}</view>
  29. </view>
  30. <view class="listBox-bottom">
  31. <view>需求人:{{ item.requireUserName }}</view>
  32. <view>负责人:{{ item.responsibleName }}</view>
  33. <view>明细条数:{{ item.detailCount }}</view>
  34. <view>完成日期:{{ item.finishDate || '-' }}</view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <u-loadmore v-if="listData.length" :status="loadStatus" />
  40. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length && !loading"></u-empty>
  41. </scroll-view>
  42. </view>
  43. <view class="footer">
  44. <u-button type="success" size="small" :disabled="selectedIndex === null" @click="confirmSelect">
  45. 选择
  46. </u-button>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import { getTableList } from '@/api/purchasingManage/purchasePlanManage'
  52. export default {
  53. data() {
  54. return {
  55. page: 1,
  56. size: 20,
  57. isEnd: false,
  58. loading: false,
  59. searchVal: '',
  60. listData: [],
  61. selectedIndex: null,
  62. loadStatus: 'loadmore',
  63. initPlanCode: ''
  64. }
  65. },
  66. onLoad(option) {
  67. if (option && option.planCode) {
  68. this.initPlanCode = option.planCode
  69. }
  70. this.getList()
  71. },
  72. methods: {
  73. scrolltolower() {
  74. if (this.isEnd || this.loading) return
  75. this.page++
  76. this.getList()
  77. },
  78. doSearch() {
  79. this.page = 1
  80. this.listData = []
  81. this.selectedIndex = null
  82. this.getList()
  83. },
  84. async getList() {
  85. this.loading = true
  86. this.loadStatus = 'loading'
  87. try {
  88. const result = await getTableList({
  89. pageNum: this.page,
  90. size: this.size,
  91. status: 2,
  92. planCode: this.searchVal || undefined
  93. })
  94. const newList = result.list || result.records || []
  95. if (this.page === 1) {
  96. this.listData = newList
  97. } else {
  98. this.listData = this.listData.concat(newList)
  99. }
  100. const total = result.count || result.total || 0
  101. this.isEnd = this.listData.length >= total
  102. this.loadStatus = this.isEnd ? 'nomore' : 'loadmore'
  103. // 回显已选数据
  104. if (this.initPlanCode) {
  105. const idx = this.listData.findIndex(item => item.planCode === this.initPlanCode)
  106. if (idx !== -1) this.selectedIndex = idx
  107. }
  108. } catch (e) {
  109. console.error(e)
  110. this.loadStatus = 'nomore'
  111. }
  112. this.loading = false
  113. },
  114. selectItem(item, index) {
  115. this.selectedIndex = index
  116. },
  117. getStatus(status) {
  118. const map = { 0: '未提交', 1: '审核中', 2: '审核通过', 3: '审核不通过' }
  119. return map[status] || ''
  120. },
  121. confirmSelect() {
  122. if (this.selectedIndex === null) {
  123. uni.showToast({ title: '请选择一条数据', icon: 'none' })
  124. return
  125. }
  126. const current = this.listData[this.selectedIndex]
  127. console.log('confirmSelect~~', current)
  128. // 通过事件总线传递给 taskForm
  129. uni.$emit('changeInquiryManageList', current)
  130. uni.navigateBack()
  131. },
  132. handleClose() {
  133. uni.navigateBack()
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .mainBox {
  140. height: 100vh;
  141. display: flex;
  142. flex-direction: column;
  143. background: #f5f5f5;
  144. .wrapper {
  145. flex: 1;
  146. overflow: hidden;
  147. }
  148. .searchBox {
  149. padding: 10rpx 0;
  150. box-sizing: border-box;
  151. background-color: #dedede;
  152. height: 90rpx;
  153. width: 100%;
  154. display: flex;
  155. justify-content: space-around;
  156. align-items: center;
  157. input {
  158. height: 70rpx;
  159. width: 65%;
  160. background: #f9f9f9;
  161. margin: 0 10rpx;
  162. padding: 0 20rpx;
  163. box-sizing: border-box;
  164. border-radius: 8rpx;
  165. font-size: 28rpx;
  166. }
  167. .searchBtn {
  168. height: 70rpx;
  169. background: #f9f9f9;
  170. color: #676767;
  171. font-size: 28rpx;
  172. padding: 0 30rpx;
  173. box-sizing: border-box;
  174. outline: none;
  175. border: none;
  176. width: 240rpx;
  177. display: flex;
  178. align-items: center;
  179. justify-content: center;
  180. .icon-sousuo {
  181. font-size: 22px;
  182. }
  183. .text {
  184. font-size: 26rpx;
  185. margin-left: 10rpx;
  186. }
  187. }
  188. }
  189. .listContent {
  190. height: 100%;
  191. padding: 0 20rpx;
  192. .listBox {
  193. display: flex;
  194. padding: 24rpx 0;
  195. border-bottom: 2rpx solid #e5e5e5;
  196. background: #fff;
  197. margin-bottom: 2rpx;
  198. .listBox-sel {
  199. width: 80rpx;
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. flex-shrink: 0;
  204. .radio {
  205. width: 36rpx;
  206. height: 36rpx;
  207. border-radius: 50%;
  208. border: 3rpx solid #ccc;
  209. display: flex;
  210. align-items: center;
  211. justify-content: center;
  212. .radio-dot {
  213. width: 20rpx;
  214. height: 20rpx;
  215. border-radius: 50%;
  216. background: #157A2C;
  217. }
  218. &.active {
  219. border-color: #157A2C;
  220. }
  221. }
  222. }
  223. .listBox-con {
  224. flex: 1;
  225. padding-right: 18rpx;
  226. .listBox-top {
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. padding-bottom: 8rpx;
  231. .listBox-code {
  232. font-size: 28rpx;
  233. font-weight: bold;
  234. color: #333;
  235. }
  236. .listBox-status {
  237. font-size: 22rpx;
  238. color: #157A2C;
  239. background: #e8f5e9;
  240. padding: 4rpx 12rpx;
  241. border-radius: 4rpx;
  242. }
  243. }
  244. .listBox-middle {
  245. font-size: 24rpx;
  246. color: #666;
  247. padding-bottom: 6rpx;
  248. display: flex;
  249. flex-wrap: wrap;
  250. >view {
  251. margin-right: 24rpx;
  252. }
  253. }
  254. .listBox-bottom {
  255. display: flex;
  256. flex-wrap: wrap;
  257. font-size: 22rpx;
  258. color: #999;
  259. >view {
  260. width: 50%;
  261. overflow: hidden;
  262. white-space: nowrap;
  263. text-overflow: ellipsis;
  264. padding: 3rpx 0;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. .footer {
  271. height: 100rpx;
  272. display: flex;
  273. justify-content: flex-end;
  274. align-items: center;
  275. border-top: 1rpx solid #eeecec;
  276. background-color: #fff;
  277. padding: 0 30rpx;
  278. flex-shrink: 0;
  279. }
  280. }
  281. </style>