prepareMaterials.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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 style="font-size:44rpx;" class="gui-header-leader-btns gui-color-white font-icons"
  7. @tap="goBack">&#xe6c5;</text>
  8. <!-- 导航文本此处也可以是其他自定义内容 -->
  9. <text class="gui-h4 gui-blod gui-flex1 gui-text-center gui-ellipsis gui-color-white gui-primary-text"
  10. style="font-size: 1rem;">备料单列表</text>
  11. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  12. <!-- 实际宽度请根据自己情况设置 -->
  13. <view style="width:40px;" />
  14. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
  15. </view>
  16. </template>
  17. <template #gBody>
  18. <view class="list-content">
  19. <view class="tabs">
  20. <div class="tabs-list">
  21. <text :class="[checkedTabs===-1?'tabs-item-active':'tabs-item']" @click="handleCheckTabs(-1)">多单备料</text>
  22. <text :class="[checkedTabs===0?'tabs-item-active':'tabs-item']" @click="handleCheckTabs(0)">订单备料</text>
  23. <text :class="[checkedTabs===1?'tabs-item-active':'tabs-item']" @click="handleCheckTabs(1)">生产发料单</text>
  24. </div>
  25. </view>
  26. <view v-show="checkedTabs===0" class="scan">
  27. <view class="scan-card">
  28. <uni-easyinput ref="easyinput" v-model="scanBatchNumber" :input-border="false"
  29. :clearable="false" type="text" focus @focus="handleInputFocus" placeholder="请扫描生产订单二维码"
  30. @confirm="confirmBatchNumber" />
  31. <text class="font-icons" style="font-size: 20px;width: 40px;text-align: right;"
  32. @click="handleMapass">&#xe6b7;</text>
  33. </view>
  34. </view>
  35. <view v-show="checkedTabs===1" class="scan">
  36. <view class="scan-card">
  37. <uni-easyinput ref="easyinput2" v-model="queryParams.keyWord" :input-border="false"
  38. :clearable="false" type="text" focus @focus="handleInputFocus"
  39. placeholder="生产订单号/领料单号/产品编码/物料编码搜索" @confirm="confirmKeyWord" />
  40. <text class="font-icons" style="font-size: 20px;width: 20px;text-align: right;"
  41. @click="search(1, 'out')">&#xe6b5;</text>
  42. </view>
  43. </view>
  44. <view v-show="checkedTabs===0" style="margin-top: 90px;">
  45. <view v-if="cardList?.length > 0" class="list-panel">
  46. <div v-for="(item, key) in cardList" :key="key" class="panel"
  47. @click="handleToScanMaterial(item)">
  48. <div class="panel-row">
  49. <span>{{ item.erpOrderNo }}</span>
  50. <span class="font-icons">前往备料&#xe66b;</span>
  51. </div>
  52. <div class="panel-row">
  53. <span>产品名称</span>
  54. <span>{{ item.materialName }}</span>
  55. </div>
  56. <div class="panel-row">
  57. <span>备料状态</span>
  58. <span>{{ computedMaterialPreparationState(item.prepareStatus) }}</span>
  59. </div>
  60. </div>
  61. </view>
  62. <view v-else>
  63. <view class="bg-image">
  64. <image src="@/static/empty.png" mode="heightFix" />
  65. <text>这里什么都没有...</text>
  66. </view>
  67. </view>
  68. </view>
  69. <view v-show="checkedTabs===1" style="margin-top: 90px;">
  70. <view v-if="cardList?.length > 0" class="list-panel">
  71. <div v-for="(item, key) in cardList" :key="key" class="panel">
  72. <div class="panel-row">
  73. <span>{{ item.workOrderBomNo }}</span>
  74. </div>
  75. <div class="panel-row">
  76. <span>产品编码</span>
  77. <span>{{ item.erpMaterialId }}</span>
  78. </div>
  79. <div class="panel-row">
  80. <span>产品名称</span>
  81. <span>{{ item.materialName }}</span>
  82. </div>
  83. <div class="panel-row">
  84. <span>发料数量</span>
  85. <span style="color: orange;font-weight: bold;">{{ item.batchQty * 1 }}</span>
  86. </div>
  87. </div>
  88. </view>
  89. <view v-else>
  90. <view class="bg-image">
  91. <image src="@/static/empty.png" mode="heightFix" />
  92. <text>这里什么都没有...</text>
  93. </view>
  94. </view>
  95. </view>
  96. <view v-if="checkedTabs===-1" style="margin-top: 45px;">
  97. <view v-if="cardList?.length > 0" class="list-panel">
  98. <div v-for="(item, key) in cardList" :key="key" class="panel"
  99. @click="handleToScanMaterials(item)">
  100. <div class="panel-row">
  101. <span>{{ item.prepareOrderNo }}</span>
  102. <span class="font-icons">前往备料&#xe66b;</span>
  103. </div>
  104. <div class="panel-row">
  105. <span>备料状态</span>
  106. <span>{{ computedState(item.syntheticalStatus) }}</span>
  107. </div>
  108. <div class="panel-row">
  109. <span>生产订单</span>
  110. <span>{{ item.workOrderNo }}</span>
  111. </div>
  112. </div>
  113. </view>
  114. <view v-else>
  115. <view class="bg-image">
  116. <image src="@/static/empty.png" mode="heightFix" />
  117. <text>这里什么都没有...</text>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </template>
  123. </gui-page>
  124. </template>
  125. <script>
  126. import {
  127. onReachBottom
  128. } from '@dcloudio/uni-app'
  129. import {
  130. ref,
  131. defineComponent,
  132. computed,
  133. onMounted
  134. } from 'vue'
  135. export default defineComponent({
  136. setup() {
  137. const easyinput = ref()
  138. const easyinput2 = ref()
  139. const checkedTabs = ref(-1)
  140. const queryParams = ref({
  141. pageSize: 10,
  142. pageNo: 1,
  143. keyWord: ''
  144. })
  145. const scanBatchNumber = ref('')
  146. const cardList = ref([])
  147. const computedState = computed(() => {
  148. return item => {
  149. switch (item) {
  150. case 0:
  151. return '待备料'
  152. case 1:
  153. return '已备料'
  154. case 2:
  155. return '已发料'
  156. }
  157. }
  158. })
  159. // 订单备料 备料状态
  160. const computedMaterialPreparationState = computed(() => {
  161. return item => {
  162. switch (item) {
  163. case 0:
  164. return '未备料'
  165. case 1:
  166. return '已备料'
  167. case 2:
  168. return '已发料'
  169. case -1:
  170. return '部分备料'
  171. }
  172. }
  173. })
  174. const search = function(pageNo, state) {
  175. if (state === 'out') {
  176. uni.$reqGet('getOutStockMainDetailPage', {
  177. ...queryParams.value,
  178. pageNo
  179. })
  180. .then(({
  181. data
  182. }) => {
  183. cardList.value = data?.list
  184. })
  185. } else if (state === 'materials') {
  186. uni.$reqGet('getPrepareMatersList', {
  187. ...queryParams.value,
  188. pageNo
  189. })
  190. .then(({
  191. data,
  192. msg
  193. }) => {
  194. cardList.value = data?.list ?? []
  195. })
  196. } else {
  197. uni.$reqGet('getProductionWorkOrderList')
  198. .then(({
  199. data,
  200. msg
  201. }) => {
  202. cardList.value = data?.list ?? []
  203. })
  204. }
  205. }
  206. onMounted(() => {
  207. search(1, 'materials')
  208. })
  209. const goBack = function() {
  210. uni.removeStorageSync('workOrderId')
  211. uni.removeStorageSync('masterId')
  212. uni.$goHome()
  213. }
  214. const handleToScanMaterial = function(params) {
  215. uni.setStorageSync('workOrderId', JSON.stringify({
  216. id: params?.id
  217. }))
  218. uni.navigateTo({
  219. url: `/pages/workbranch/warehouse/production/scanMaterials`
  220. })
  221. }
  222. const handleToScanMaterials = function(params) {
  223. uni.setStorageSync('masterId', JSON.stringify({
  224. id: params?.id
  225. }))
  226. uni.navigateTo({
  227. url: `/pages/workbranch/warehouse/production/scanMixMaterials`
  228. })
  229. }
  230. const handleMapass = function() {
  231. // #ifdef APP-PLUS
  232. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  233. mpaasScanModule.mpaasScan({
  234. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  235. 'scanType': ['qrCode', 'barCode'],
  236. // 是否隐藏相册,默认false不隐藏
  237. 'hideAlbum': false
  238. },
  239. (ret) => {
  240. if (ret.resp_code === 1000) {
  241. uni.setStorageSync('workOrderId', JSON.stringify({
  242. id: ret.resp_result
  243. }))
  244. uni.navigateTo({
  245. url: `/pages/workbranch/warehouse/production/scanMaterials`
  246. })
  247. }
  248. })
  249. // #endif
  250. // #ifdef H5
  251. uni.setStorageSync('workOrderId', JSON.stringify({
  252. id: '60'
  253. }))
  254. uni.navigateTo({
  255. url: `/pages/workbranch/warehouse/production/scanMaterials`
  256. })
  257. // #endif
  258. }
  259. // 扫描生产订单二维码输入框回车事件
  260. const confirmBatchNumber = function(e) {
  261. uni.setStorageSync('workOrderId', JSON.stringify({
  262. id: e
  263. }))
  264. uni.navigateTo({
  265. url: `/pages/workbranch/warehouse/production/scanMaterials`
  266. })
  267. }
  268. // 生产发料单搜索输入框回车事件
  269. const confirmKeyWord = function(e) {
  270. search(1, 'out')
  271. }
  272. const handleCheckTabs = function(item) {
  273. queryParams.value.pageNo = 1
  274. queryParams.value.keyWord = ''
  275. cardList.value = []
  276. checkedTabs.value = item
  277. if (item === 0) {
  278. search()
  279. easyinput.value.onBlur()
  280. easyinput.value.onFocus()
  281. } else if (item === 1) {
  282. search(1, 'out')
  283. easyinput2.value.onBlur()
  284. easyinput2.value.onFocus()
  285. } else {
  286. search(1, 'materials')
  287. }
  288. }
  289. // 禁用软键盘
  290. const handleInputFocus = function() {
  291. setTimeout(() => {
  292. uni.hideKeyboard()
  293. }, 100)
  294. }
  295. // uniapp移动端触底事件
  296. onReachBottom(() => {
  297. queryParams.value.pageNo += 1
  298. if (checkedTabs.value === 0) {
  299. uni.$reqGet('getProductionWorkOrderList', queryParams.value)
  300. .then(({
  301. data
  302. }) => {
  303. Array.prototype.push.call(cardList.value, ...data?.list ?? [])
  304. })
  305. } else if (checkedTabs.value === 1) {
  306. uni.$reqGet('getOutStockMainDetailPage', queryParams.value)
  307. .then(({
  308. data
  309. }) => {
  310. Array.prototype.push.call(cardList.value, ...data?.list ?? [])
  311. })
  312. } else {
  313. uni.$reqGet('getPrepareMatersList', queryParams.value)
  314. .then(({
  315. data,
  316. msg
  317. }) => {
  318. Array.prototype.push.call(cardList.value, ...data?.list ?? [])
  319. })
  320. }
  321. })
  322. return {
  323. goBack,
  324. cardList,
  325. search,
  326. easyinput,
  327. easyinput2,
  328. computedState,
  329. computedMaterialPreparationState,
  330. queryParams,
  331. checkedTabs,
  332. scanBatchNumber,
  333. confirmBatchNumber,
  334. confirmKeyWord,
  335. handleMapass,
  336. handleCheckTabs,
  337. handleInputFocus,
  338. handleToScanMaterial,
  339. handleToScanMaterials
  340. }
  341. }
  342. })
  343. </script>
  344. <style lang="scss" scoped>
  345. .gui-header-leader-btns {
  346. color: black;
  347. font-size: 24px !important;
  348. margin-left: 24rpx;
  349. }
  350. .list-content {
  351. margin-top: 80px;
  352. min-height: calc(100vh - 80px);
  353. background-color: #edeeee;
  354. }
  355. span,
  356. text {
  357. font-size: 12px;
  358. }
  359. .scan {
  360. position: fixed;
  361. top: 116px;
  362. left: 0;
  363. height: 45px;
  364. width: calc(100% - 24px);
  365. padding: 0 12px;
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: center;
  369. border-top: 1px solid #edeeee;
  370. border-bottom: 1px solid #edeeee;
  371. z-index: 9;
  372. background-color: white;
  373. .scan-card {
  374. width: 100%;
  375. display: flex;
  376. align-items: center;
  377. input {
  378. height: 35px;
  379. line-height: 35px;
  380. }
  381. text {
  382. width: 100%;
  383. text-align: right;
  384. }
  385. }
  386. }
  387. .tabs {
  388. position: fixed;
  389. top: 72px;
  390. left: 0;
  391. width: 100%;
  392. height: 45px;
  393. display: flex;
  394. align-items: flex-end;
  395. padding: 0 2px;
  396. z-index: 9;
  397. background-color: white;
  398. .tabs-list {
  399. border-radius: 3px;
  400. overflow: hidden;
  401. }
  402. .tabs-item {
  403. display: inline-block;
  404. width: 72px;
  405. height: 30px;
  406. line-height: 30px;
  407. padding: 0 8px;
  408. font-size: 14px;
  409. font-weight: bold;
  410. text-align: center;
  411. color: black;
  412. border-bottom: 1.5px dashed #00a0e9;
  413. transition: all .5s ease-in-out;
  414. }
  415. .tabs-item-active {
  416. position: relative;
  417. display: inline-block;
  418. width: 72px;
  419. height: 30px;
  420. line-height: 30px;
  421. padding: 0 8px;
  422. font-size: 14px;
  423. font-weight: bold;
  424. text-align: center;
  425. color: white;
  426. border-left: 1px solid #00a0e9;
  427. border-top: 1px solid #00a0e9;
  428. border-right: 1px solid #00a0e9;
  429. border-bottom: 1.5px solid #00a0e9;
  430. border-radius: 5px 5px 0 0;
  431. animation: .3s linear show;
  432. background-color: #00a0e9;
  433. }
  434. .tabs-item-active::before {
  435. content: '';
  436. position: absolute;
  437. left: -10px;
  438. bottom: 0;
  439. width: 10px;
  440. height: 10px;
  441. background: radial-gradient(circle at 0% 25%, transparent 10px, #00a0e9 0)
  442. }
  443. .tabs-item-active::after {
  444. content: '';
  445. position: absolute;
  446. right: -10px;
  447. bottom: 0;
  448. width: 10px;
  449. height: 10px;
  450. background: radial-gradient(circle at 100% 25%, transparent 10px, #00a0e9 0)
  451. }
  452. }
  453. @keyframes show {
  454. from {
  455. transform: translateY(5%);
  456. }
  457. to {
  458. transform: translateY(0%);
  459. }
  460. }
  461. </style>