index.vue 7.5 KB

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