index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="报损报溢" @clickLeft="back"></uni-nav-bar>
  4. <view class="tab-wrapper">
  5. <tabs @change="handleTabChange" @handleSearch="handleTabSearch" />
  6. </view>
  7. <CardList :list="tableData" />
  8. <view class="footBox">
  9. <view class="reg" @click="addStock">
  10. <uni-icons custom-prefix="iconfont" type="icon-shixiangxinzeng" size="20" color="#fff"></uni-icons>
  11. 新增报损报溢
  12. </view>
  13. </view>
  14. <!-- 搜索组件 -->
  15. <u-popup :show="searchVisible" mode="right" @close="searchVisible = false">
  16. <view class="search-container">
  17. <view class="title">筛选</view>
  18. <uni-forms ref="customForm" :modelValue="popupInfo" label-position="top" label-width="200">
  19. <uni-forms-item label="单号" name="code">
  20. <uni-easyinput v-model="popupInfo.code" :inputBorder="false" placeholder="请输入" />
  21. </uni-forms-item>
  22. <uni-forms-item label="名称" name="name">
  23. <uni-easyinput v-model="popupInfo.name" :inputBorder="false" placeholder="请输入" />
  24. </uni-forms-item>
  25. <uni-forms-item label="报损报溢部门" name="deliveryreportDeptNameName">
  26. <uni-easyinput :value="popupInfo.reportDeptName" disabled
  27. @click.native="$refs.treePicker._show()" :inputBorder="false" placeholder="请选择" />
  28. </uni-forms-item>
  29. <uni-forms-item label="报损报溢人" name="reportName">
  30. <uni-data-select v-model="popupInfo.reportId" :localdata="userList"></uni-data-select>
  31. </uni-forms-item>
  32. </uni-forms>
  33. <view class="footer">
  34. <view class="btn reset" @click="handleReset">重置</view>
  35. <view class="btn search" @click="handleSearch">搜索</view>
  36. </view>
  37. </view>
  38. </u-popup>
  39. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
  40. valueKey="id" textKey="name" childrenKey="children" />
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. listOrganizations,
  46. getUserPage
  47. } from '@/api/myTicket/index.js'
  48. import {
  49. getPlanProfitLoss
  50. } from '@/api/warehouseManagement'
  51. import tabs from './components/tabs.vue'
  52. import CardList from './components/CardList.vue'
  53. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  54. export default {
  55. components: {
  56. tabs,
  57. CardList,
  58. baTreePicker
  59. },
  60. data() {
  61. return {
  62. listData: [],
  63. page: 1,
  64. size: 10,
  65. isEnd: true,
  66. searchVisible: false,
  67. status: '',
  68. pickerIndex: 0,
  69. pickTabIndex: 0,
  70. popupInfo: {
  71. code: '',
  72. name: '',
  73. reportDeptName: '',
  74. reportDeptId: '',
  75. reportName: '',
  76. reportId: ''
  77. }, //筛选数据
  78. userList: [],
  79. deptList: [],
  80. tableData: []
  81. }
  82. },
  83. onLoad() {
  84. this.getFirstList()
  85. this.getDept()
  86. },
  87. //触底加载
  88. onReachBottom: function() {
  89. if (this.isEnd) {
  90. return
  91. }
  92. this.getMoreLists()
  93. },
  94. methods: {
  95. back() {
  96. uni.switchTab({
  97. url: '/pages/index/index'
  98. })
  99. },
  100. getDept() {
  101. listOrganizations(1).then(data => {
  102. this.listData = data
  103. })
  104. },
  105. getUser(deptCode) {
  106. // 显示加载中的提示
  107. uni.showLoading({
  108. title: '加载中'
  109. })
  110. getUserPage({
  111. pageNum: 1,
  112. size: -1,
  113. groupId: deptCode
  114. })
  115. .then(data => {
  116. this.userList = data.list.map(item => {
  117. item.text = item.name
  118. item.value = item.id
  119. return item
  120. })
  121. })
  122. .finally(() => {
  123. uni.hideLoading()
  124. })
  125. },
  126. // 抬头下拉信息保存
  127. handlePicker(e, list, idKey, nameKey) {
  128. if (idKey) {
  129. this.popupInfo[idKey] = list[e.detail.value].id
  130. }
  131. if (nameKey) {
  132. this.popupInfo[nameKey] = list[e.detail.value].name
  133. }
  134. },
  135. handleSearch() {
  136. this.getFirstList()
  137. },
  138. getFirstList() {
  139. this.searchVisible = false
  140. this.page = 1
  141. this.isEnd = true
  142. this.getList()
  143. },
  144. getMoreLists() {
  145. //获取更多数据
  146. page++
  147. this.getList()
  148. },
  149. //获取列表信息
  150. getList() {
  151. uni.showLoading({
  152. title: '加载中'
  153. })
  154. let data = {
  155. pageNum: this.page,
  156. size: this.size,
  157. status: this.status
  158. }
  159. getPlanProfitLoss(data)
  160. .then(res => {
  161. if (this.page === 1) {
  162. this.tableData = res.list
  163. } else {
  164. this.tableData = this.tableData.concat(res.list)
  165. }
  166. this.isEnd = this.tableData.length >= res.count
  167. })
  168. .finally(() => {
  169. uni.hideLoading()
  170. })
  171. },
  172. confirm(data, name) {
  173. this.popupInfo.reportDeptName = name
  174. this.popupInfo.reportDeptId = data[0]
  175. this.popupInfo.reportName = ''
  176. this.popupInfo.reportId = ''
  177. this.getUser(data[0])
  178. },
  179. //切换tab
  180. handleTabChange(status) {
  181. this.status = status
  182. this.getFirstList()
  183. },
  184. //筛选
  185. handleTabSearch() {
  186. // this.getFirstList()
  187. this.searchVisible = true
  188. },
  189. handleReset() {
  190. this.popupInfo = {
  191. code: '',
  192. name: '',
  193. reportDeptName: '',
  194. reportDeptId: '',
  195. reportName: '',
  196. reportId: ''
  197. }
  198. this.getFirstList()
  199. },
  200. //新增
  201. addStock() {
  202. uni.navigateTo({
  203. url: '/pages/warehouse/reportLoss/edit'
  204. })
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. .mainBox {
  211. padding-bottom: 120rpx;
  212. }
  213. .tab-wrapper {
  214. z-index: 99;
  215. width: 100%;
  216. }
  217. .footBox {
  218. position: fixed;
  219. left: 0px;
  220. bottom: 0px;
  221. height: 100rpx;
  222. width: 100%;
  223. display: flex;
  224. align-items: center;
  225. justify-content: space-between;
  226. view {
  227. width: 100%;
  228. height: 100%;
  229. text-align: center;
  230. color: #fff;
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. }
  235. .add {
  236. background: $uni-color-primary;
  237. }
  238. .reg {
  239. background: $u-success-dark;
  240. }
  241. .uni-icons {
  242. margin-right: 8rpx !important;
  243. font-weight: bold;
  244. }
  245. }
  246. .search-container {
  247. width: 70vw;
  248. padding: 30rpx 36rpx;
  249. .footer {
  250. position: absolute;
  251. bottom: 0;
  252. left: 0;
  253. width: 100%;
  254. display: flex;
  255. box-shadow: 0 10rpx 30rpx 0 #000;
  256. .btn {
  257. width: 50%;
  258. height: 80rpx;
  259. border-radius: 0 !important;
  260. flex: 1;
  261. display: flex;
  262. justify-content: center;
  263. align-items: center;
  264. &.reset {
  265. color: $j-primary-border-green;
  266. }
  267. &.search {
  268. color: #fff;
  269. background-color: $j-primary-border-green;
  270. }
  271. }
  272. }
  273. .title {
  274. font-weight: bold;
  275. font-size: 30rpx;
  276. margin-bottom: 20rpx;
  277. }
  278. /deep/.uni-date__x-input,
  279. /deep/.uni-easyinput__content,
  280. /deep/.uni-easyinput__content-input {
  281. height: 60rpx;
  282. border-radius: 30rpx;
  283. overflow: hidden;
  284. background-color: rgba(242, 242, 242, 1);
  285. }
  286. }
  287. </style>