boxNumberStacking.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  6. <text
  7. style="font-size:44rpx;"
  8. class="gui-header-leader-btns gui-color-white font-icons"
  9. @tap="goBack"
  10. >&#xe6c5;</text>
  11. <!-- 导航文本此处也可以是其他自定义内容 -->
  12. <text
  13. class="gui-h4 gui-blod gui-flex1 gui-text-center gui-ellipsis gui-color-white gui-primary-text"
  14. >栈板列表</text>
  15. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  16. <!-- 实际宽度请根据自己情况设置 -->
  17. <view style="width:40px;" />
  18. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现 -->
  19. </view>
  20. </template>
  21. <template #gBody>
  22. <view class="list-content">
  23. <view class="select-item">
  24. <text class="store-text">栈板编号</text>
  25. <view class="custom-select">
  26. <uni-data-select
  27. v-model="submitParams.wmsPalletId"
  28. :localdata="locationList"
  29. @change="handleSelect"
  30. />
  31. </view>
  32. </view>
  33. <view class="operation" style="padding: 10px 0;background-color: white;">
  34. <view class="gui-bg-white gui-dark-bg-level-3 gui-padding-x">
  35. <view class="gui-form-item gui-border-b">
  36. <button
  37. type="default"
  38. class="gui-button-mini gui-bg-blue gui-noborder button-search"
  39. @click="handleNavigateTo('input')"
  40. >
  41. <text class="gui-color-white gui-button-text-mini">搜索</text>
  42. </button>
  43. <view class="gui-form-body">
  44. <input
  45. v-model="submitParams.materialName"
  46. type="text"
  47. class="gui-form-input"
  48. name="name1"
  49. @focus="handleInputFocus"
  50. placeholder="请输入内容"
  51. >
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view v-if="boxNumberList.length > 0">
  57. <view
  58. v-for="(item, key) in boxNumberList"
  59. :key="key"
  60. class="card-list-flexbox"
  61. @click="handleCheckedItem(item)"
  62. >
  63. <view v-if="computedChecked(item.materialLots)" class="checkbox-cubes">
  64. <view class="checkbox-box" />
  65. <view class="checkbox-icon">✔</view>
  66. </view>
  67. <view class="card-list-item">
  68. <text class="text-1 gui-color-gray">{{ item.materialLots }}</text>
  69. </view>
  70. <view class="card-list-item">
  71. <text class="text-1 gui-color-gray">物料名称</text>
  72. <text class="text-2 gui-color-gray">{{ item.materialName }}</text>
  73. </view>
  74. <view class="card-list-item">
  75. <text class="text-1 gui-color-gray">批次数量</text>
  76. <text class="text-2 gui-color-gray">{{ computedMaterialQty(item.qty) }}</text>
  77. </view>
  78. </view>
  79. </view>
  80. <view v-else>
  81. <view class="bg-image">
  82. <image src="@/static/empty.png" mode="heightFix" />
  83. <text>这里什么都没有...</text>
  84. </view>
  85. </view>
  86. </view>
  87. <gui-right-menus>
  88. <!-- 扩展按钮 -->
  89. <template #menus-more>
  90. <view
  91. hover-class="gui-tap"
  92. class="menu-items gui-bg-primary gui-flex gui-columns gui-justify-content-center"
  93. @click="handleComplute"
  94. >
  95. <text class="menu-text gui-block gui-text-center gui-color-white">确认入栈</text>
  96. </view>
  97. </template>
  98. <!-- 核心按钮 -->
  99. <template #menus-primary>
  100. <view class="menu-items gui-bg-primary gui-flex gui-columns gui-justify-content-center">
  101. <text class="menu-icon gui-color-white gui-block gui-text-center gui-icons">&#xe614;</text>
  102. <text class="menu-text gui-color-white gui-block gui-text-center">功能</text>
  103. </view>
  104. </template>
  105. </gui-right-menus>
  106. </template>
  107. </gui-page>
  108. </template>
  109. <script>
  110. import {
  111. onReachBottom
  112. } from '@dcloudio/uni-app'
  113. import {
  114. ref,
  115. defineComponent,
  116. computed
  117. } from 'vue'
  118. export default defineComponent({
  119. setup() {
  120. const checkboxParams = ref({
  121. checkboxIds: [], // 待选项的物料批次集合
  122. checkedIds: [] // 选中的字段
  123. })
  124. const computedChecked = computed(() => {
  125. return item => checkboxParams.value.checkedIds.includes(item)
  126. })
  127. const computedMaterialQty = computed(() => {
  128. return item => {
  129. return item / 10000 > 1 ? (item / 10000) + 'w' : item
  130. }
  131. })
  132. const submitParams = ref({
  133. wmsPalletId: '', // 栈板ID
  134. materialName: '' // 物料名称
  135. })
  136. const queryParams = ref({
  137. pageSize: 20,
  138. pageNo: 1
  139. })
  140. const locationList = ref([])
  141. const boxNumberList = ref([])
  142. uni.$reqGet('getWmsTrestleDropDownList')
  143. .then(({
  144. data,
  145. msg
  146. }) => {
  147. if (data?.length > 0) {
  148. for (let x = 0; x < data.length; x++) {
  149. locationList.value.push({
  150. text: data[x].name,
  151. value: data[x].id
  152. })
  153. }
  154. }
  155. })
  156. uni.$reqGet('pdaMaterialsPage', queryParams.value)
  157. .then(({
  158. data,
  159. msg
  160. }) => {
  161. boxNumberList.value = data?.list ?? []
  162. checkboxParams.value.checkboxIds = Array.from(boxNumberList.value, item => item
  163. ?.materialLots)
  164. })
  165. // 多选框选中事件
  166. const handleCheckedItem = function(item) {
  167. const ifExist = checkboxParams.value.checkedIds.includes(item?.materialLots)
  168. if (ifExist) {
  169. const fdIndex = checkboxParams.value.checkedIds.findIndex(option => option === item
  170. ?.materialLots)
  171. checkboxParams.value.checkedIds.splice(fdIndex, 1)
  172. } else {
  173. checkboxParams.value.checkedIds.push(item?.materialLots)
  174. }
  175. }
  176. const handleComplute = function() {
  177. if (submitParams.value.wmsPalletId) {
  178. const params = []
  179. checkboxParams.value.checkedIds?.forEach(item => params.push({
  180. materialLots: item,
  181. wmsPalletId: submitParams.value.wmsPalletId
  182. }))
  183. uni.$reqPost('pdaCreateBatch', params)
  184. .then(({
  185. code,
  186. data,
  187. msg
  188. }) => {
  189. if (code === 0) {
  190. uni.$grace.msg('入栈成功')
  191. setTimeout(() => {
  192. uni.redirectTo({
  193. url: '/pages/workbranch/warehouse/trestle/boxNumberStacking'
  194. })
  195. }, 500)
  196. } else {
  197. uni.$grace.msg(msg)
  198. }
  199. })
  200. } else {
  201. uni.$grace.msg('请先选择栈板')
  202. }
  203. }
  204. const goBack = function() {
  205. uni.$goBack('/pages/workbranch/warehouse/trestle/trestleList')
  206. }
  207. // 禁用软键盘
  208. const handleInputFocus = function() {
  209. setTimeout(() => {
  210. uni.hideKeyboard()
  211. }, 100)
  212. }
  213. // uniapp移动端触底事件
  214. onReachBottom(() => {
  215. queryParams.value.pageNo += 1
  216. uni.$reqGet('pdaMaterialsPage', queryParams.value)
  217. .then(({
  218. data
  219. }) => {
  220. Array.prototype.push.call(boxNumberList.value, ...data?.list ?? [])
  221. Array.prototype.push.call(checkboxParams.value.checkboxIds, ...Array.from(data
  222. ?.list, item => item
  223. ?.materialLots))
  224. })
  225. })
  226. return {
  227. submitParams,
  228. locationList,
  229. boxNumberList,
  230. handleComplute,
  231. goBack,
  232. computedMaterialQty,
  233. computedChecked,
  234. handleInputFocus,
  235. handleCheckedItem
  236. }
  237. }
  238. })
  239. </script>
  240. <style lang="scss" scoped>
  241. .gui-sbody {
  242. font-size: 14px;
  243. background-color: rgba(234, 239, 242, 1);
  244. }
  245. .gui-header-leader-btns {
  246. color: black;
  247. font-size: 24px !important;
  248. margin-left: 24rpx;
  249. margin-right: 24rpx;
  250. }
  251. .list-content {
  252. margin-top: 80px;
  253. background-color: #edeeee;
  254. }
  255. .gui-button-mini {
  256. line-height: 32px !important;
  257. height: 32px !important;
  258. width: 160rpx !important;
  259. margin-right: 34rpx;
  260. .gui-button-text-mini {
  261. line-height: 32px;
  262. }
  263. }
  264. .select-item {
  265. display: flex;
  266. flex-direction: row;
  267. justify-content: space-between;
  268. align-items: center;
  269. margin-bottom: 10px;
  270. padding: 12px;
  271. background-color: white;
  272. .store-text {
  273. width: 80px;
  274. text-align: center;
  275. margin-right: 14px;
  276. }
  277. .custom-select {
  278. display: flex;
  279. flex-direction: row;
  280. justify-content: center;
  281. align-items: center;
  282. line-height: 40px;
  283. width: 100%;
  284. min-width: 275px;
  285. }
  286. }
  287. ::v-deep .uni-checkbox-input {
  288. border-radius: 50% !important;
  289. }
  290. .card-list-flexbox {
  291. display: flex;
  292. flex-direction: row;
  293. align-items: center;
  294. flex-wrap: wrap;
  295. margin: 0 2px 4px 2px;
  296. .card-list-item,
  297. .card-list-item-operation {
  298. width: 750rpx;
  299. height: 40px;
  300. margin-bottom: 3rpx;
  301. display: flex;
  302. flex-direction: row;
  303. align-items: center;
  304. justify-content: space-between;
  305. background-color: #fff;
  306. uni-text {
  307. font-size: 14px;
  308. height: 50rpx;
  309. text-align: left;
  310. padding: 0 12px;
  311. display: flex;
  312. flex-direction: row;
  313. align-items: center;
  314. }
  315. .text-1 {
  316. flex: 1;
  317. height: 40px;
  318. justify-content: flex-start;
  319. }
  320. .text-2 {
  321. flex: 3;
  322. height: 40px;
  323. justify-content: flex-end;
  324. margin-right: 4px;
  325. padding: 2px 6px;
  326. }
  327. }
  328. .card-list-item-operation {
  329. justify-content: flex-end;
  330. }
  331. .card-list-item:nth-of-type(1) {
  332. .text-1 {
  333. font-weight: bold;
  334. color: black !important;
  335. }
  336. .text-1::before {
  337. content: "";
  338. width: 4px;
  339. height: 20px;
  340. border-radius: 4px;
  341. margin-right: 4px;
  342. background-color: skyblue;
  343. }
  344. }
  345. }
  346. .checkbox-cubes {
  347. width: 30px;
  348. height: 124px;
  349. position: absolute;
  350. .checkbox-box {
  351. /*宽高为0*/
  352. width: 0;
  353. height: 0;
  354. position: relative;
  355. /*在三角形底边设置一个边界颜色*/
  356. border-left: 28px solid skyblue;
  357. /*其它3边设置相同颜色,*/
  358. border-bottom: 25px solid transparent;
  359. }
  360. .checkbox-icon {
  361. height: 20px;
  362. position: absolute;
  363. top: 0;
  364. left: 3px;
  365. display: flex;
  366. align-items: center;
  367. font-size: 10px;
  368. font-weight: bold;
  369. color: white;
  370. }
  371. }
  372. </style>