inventoryPage.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <gui-page :custom-header="true" :header-class="['gui-theme-background-color']">
  3. <template #gHeader>
  4. <view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
  5. <text style="font-size:44rpx;" class="gui-header-leader-btns gui-color-white font-icons"
  6. @tap="goHome">&#xe6c5;</text>
  7. <text class="gui-h4 gui-blod gui-flex1 gui-text-center gui-ellipsis gui-color-white gui-primary-text"
  8. style="font-size: 1rem;">盘点列表</text>
  9. <view style="width:40px;" />
  10. </view>
  11. </template>
  12. <template #gBody>
  13. <view class="list-content">
  14. <!-- 搜索栏 -->
  15. <view class="search-bar">
  16. <!-- 业务类型查询条件 - 暂时注释 -->
  17. <!-- <view class="search-item">
  18. <text class="search-label">业务类型</text>
  19. <view class="search-select">
  20. <picker @change="onBusinessTypeChange" :range="businessTypeList" range-key="text" :value="businessTypeIndex">
  21. <view class="picker-text">{{ businessTypeList[businessTypeIndex]?.text || '请选择业务类型' }}</view>
  22. </picker>
  23. </view>
  24. </view> -->
  25. <view class="search-item">
  26. <text class="search-label">申请单号</text>
  27. <view class="search-input-wrapper">
  28. <input type="text" v-model="billNo" placeholder="请输入申请单号" class="search-input" />
  29. <text class="scan-icon font-icons" @tap="scanCode">
  30. &#xe6b7;
  31. </text>
  32. </view>
  33. </view>
  34. <view class="search-btn" @tap="handleSearch">
  35. <text class="font-icons">搜索&#xe60c;</text>
  36. </view>
  37. </view>
  38. <view style="margin-top: 110px;">
  39. <view v-if="cardList?.length > 0" class="list-panel">
  40. <div v-for="(item, key) in cardList" :key="key" class="panel"
  41. @click="handleToScanMaterials(item)">
  42. <div class="panel-row">
  43. <span>{{ item.billNo }}</span>
  44. <span class="font-icons">前往扫描&#xe66b;</span>
  45. </div>
  46. <!-- <div class="panel-row">
  47. <span>业务类型</span>
  48. <span></span>
  49. </div> -->
  50. <div class="panel-row">
  51. <span>业务状态</span>
  52. <span>{{ computedState(item.executeStatus,'status') }}</span>
  53. </div>
  54. </div>
  55. </view>
  56. <view v-else>
  57. <view class="bg-image">
  58. <image src="@/static/empty.png" mode="heightFix" />
  59. <text>这里什么都没有...</text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. </gui-page>
  66. </template>
  67. <script>
  68. import {
  69. onReachBottom
  70. } from '@dcloudio/uni-app'
  71. import {
  72. ref,
  73. defineComponent,
  74. computed,
  75. onMounted
  76. } from 'vue'
  77. export default defineComponent({
  78. setup() {
  79. const queryParams = ref({
  80. pageSize: 10,
  81. pageNo: 1,
  82. keyWord: '',
  83. businessType: ''
  84. })
  85. const cardList = ref([])
  86. const businessTypeList = ref([])
  87. const statusMap = ref({})
  88. const businessTypeIndex = ref(0)
  89. const selectedBusinessType = ref('')
  90. const billNo = ref('')
  91. const search = function(pageNo) {
  92. uni.$reqGet('inventoryGetStockCountList', {
  93. ...queryParams.value,
  94. // businessType: selectedBusinessType.value,
  95. billNo: billNo.value,
  96. pageNo
  97. })
  98. .then(({
  99. data,
  100. msg
  101. }) => {
  102. cardList.value = data?.list ?? []
  103. if (billNo.value && cardList.value.length === 1) {
  104. handleToScanMaterials(cardList.value[0])
  105. }
  106. })
  107. }
  108. onMounted(() => {
  109. search(1)
  110. // 获取业务类型字典数据 - 暂时注释
  111. // uni.$reqGet('getDictDataPage', {
  112. // dictType: 'in_business_type',
  113. // pageNo: 1,
  114. // pageSize: 100
  115. // }).then(({ data }) => {
  116. // businessTypeList.value = [{ text: '请选择业务类型', value: '' }]
  117. // const dataList = data?.list || [];
  118. // for (var i = 0; i < dataList.length; i++) {
  119. // businessTypeList.value.push({
  120. // text: dataList[i].label,
  121. // value: dataList[i].value,
  122. // })
  123. // }
  124. // })
  125. uni.$reqGet('getDictDataPage', {
  126. dictType: 'in_out_status',
  127. pageNo: 1,
  128. pageSize: 100
  129. }).then(({ data }) => {
  130. data?.list.forEach(item => {
  131. statusMap.value[item.value] = item.label
  132. })
  133. })
  134. })
  135. const goHome = function() {
  136. uni.$goHome()
  137. }
  138. const goBack = function() {
  139. uni.removeStorageSync('masterId')
  140. uni.$goBack('/pages/workbranch/warehouse/Inventory/inventoryDetail')
  141. }
  142. const handleToScanMaterials = function(params) {
  143. uni.setStorageSync('masterId', JSON.stringify({
  144. id: params?.id,
  145. businessType: params?.businessType
  146. }))
  147. uni.navigateTo({
  148. url: '/pages/workbranch/warehouse/Inventory/inventoryDetail'
  149. })
  150. }
  151. const syncQueryParams = () => {
  152. queryParams.value.businessType = selectedBusinessType.value;
  153. queryParams.value.billNo = billNo.value;
  154. };
  155. // 业务类型选择变化 - 暂时注释
  156. // const onBusinessTypeChange = function(e) {
  157. // businessTypeIndex.value = e.detail.value
  158. // selectedBusinessType.value = businessTypeList.value[e.detail.value]?.value || ''
  159. // }
  160. const handleSearch = function() {
  161. queryParams.value.pageNo = 1
  162. syncQueryParams();
  163. search(1)
  164. }
  165. const scanCode = function() {
  166. uni.scanCode({
  167. success: function(res) {
  168. billNo.value = res.result
  169. handleSearch()
  170. },
  171. fail: function(err) {
  172. console.log('扫码失败', err)
  173. uni.showToast({
  174. title: '扫码失败',
  175. icon: 'none'
  176. })
  177. }
  178. })
  179. }
  180. onReachBottom(() => {
  181. queryParams.value.pageNo += 1
  182. syncQueryParams();
  183. uni.$reqGet('inventoryGetStockCountList', queryParams.value)
  184. .then(({data,msg}) => {
  185. Array.prototype.push.call(cardList.value, ...data?.list ?? [])
  186. })
  187. })
  188. const computedState = function (value, type = 'businessType') {
  189. if (value === '' || value == null) return '未知'
  190. if (type === 'businessType') {
  191. const hit = businessTypeList.value.find(i => String(i.value).trim() === String(value).trim())
  192. return hit ? hit.text : '未知'
  193. }
  194. if (type === 'status') {
  195. return statusMap.value[value] || '未知'
  196. }
  197. return '未知'
  198. }
  199. return {
  200. goHome,
  201. goBack,
  202. cardList,
  203. handleToScanMaterials,
  204. businessTypeList,
  205. computedState,
  206. businessTypeIndex,
  207. // onBusinessTypeChange,
  208. handleSearch,
  209. billNo,
  210. scanCode
  211. }
  212. }
  213. })
  214. </script>
  215. <style lang="scss" scoped>
  216. .gui-header-leader-btns {
  217. color: black;
  218. font-size: 24px !important;
  219. margin-left: 24rpx;
  220. }
  221. .list-content {
  222. margin-top: 50px;
  223. min-height: calc(100vh - 80px);
  224. background-color: #edeeee;
  225. }
  226. .search-bar {
  227. position: fixed;
  228. top: 72px;
  229. left: 0;
  230. width: 100%;
  231. background-color: #fff;
  232. padding: 12px;
  233. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  234. display: flex;
  235. flex-wrap: wrap;
  236. gap: 12px;
  237. z-index: 9;
  238. box-sizing: border-box;
  239. }
  240. .search-item {
  241. flex: 1 1 200px;
  242. min-width: 200px;
  243. display: flex;
  244. align-items: center;
  245. gap: 8px;
  246. margin-bottom: 8px;
  247. }
  248. .search-input-wrapper {
  249. flex: 1;
  250. }
  251. .search-input {
  252. width: 90%;
  253. height: 36px;
  254. line-height: 36px;
  255. background-color: #f5f5f5;
  256. border-radius: 4px;
  257. padding: 0 12px;
  258. font-size: 12px;
  259. border: none;
  260. }
  261. .search-input-wrapper {
  262. flex: 1;
  263. position: relative;
  264. }
  265. .scan-icon {
  266. position: absolute;
  267. right: 10px;
  268. top: 50%;
  269. transform: translateY(-50%);
  270. font-size: 20px;
  271. color: #00a0e9;
  272. cursor: pointer;
  273. }
  274. .search-input:focus {
  275. outline: none;
  276. background-color: #fff;
  277. border: 1px solid #00a0e9;
  278. }
  279. .search-label {
  280. font-size: 12px;
  281. color: #666;
  282. }
  283. .search-select {
  284. flex: 1;
  285. position: relative;
  286. }
  287. .search-select picker {
  288. display: flex;
  289. align-items: center;
  290. height: 36px;
  291. line-height: 36px;
  292. min-width: 120px;
  293. background-color: #f5f5f5;
  294. border-radius: 4px;
  295. padding: 0 28px 0 12px;
  296. }
  297. .picker-text {
  298. font-size: 12px;
  299. color: #333;
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. }
  304. .picker-text::after {
  305. position: absolute;
  306. right: 8px;
  307. top: 50%;
  308. transform: translateY(-50%);
  309. }
  310. .search-btn {
  311. width: 80px;
  312. height: 36px;
  313. line-height: 36px;
  314. background-color: #00a0e9;
  315. color: #fff;
  316. border-radius: 4px;
  317. text-align: center;
  318. font-size: 12px;
  319. }
  320. .search-btn .font-icons {
  321. color: #fff;
  322. margin-right: 4px;
  323. }
  324. span,
  325. text {
  326. font-size: 12px;
  327. }
  328. .list-panel {
  329. padding: 12px;
  330. }
  331. .panel {
  332. background-color: white;
  333. border-radius: 8px;
  334. padding: 12px;
  335. margin-bottom: 12px;
  336. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  337. }
  338. .panel-row {
  339. display: flex;
  340. justify-content: space-between;
  341. align-items: center;
  342. margin-bottom: 8px;
  343. &:last-child {
  344. margin-bottom: 0;
  345. }
  346. span:first-child {
  347. color: #666;
  348. }
  349. span:last-child {
  350. font-weight: bold;
  351. }
  352. .font-icons {
  353. color: #00a0e9;
  354. display: flex;
  355. align-items: center;
  356. }
  357. }
  358. .bg-image {
  359. display: flex;
  360. flex-direction: column;
  361. align-items: center;
  362. justify-content: center;
  363. padding: 60px 0;
  364. image {
  365. width: 120px;
  366. height: 120px;
  367. margin-bottom: 16px;
  368. }
  369. text {
  370. color: #999;
  371. font-size: 14px;
  372. }
  373. }
  374. </style>