cuttingMaterialPreparation.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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="goHome"
  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="scan">
  24. <view class="scan-card">
  25. <uni-easyinput
  26. ref="easyinput"
  27. v-model="scanNumber"
  28. :input-border="false"
  29. :clearable="false"
  30. type="text"
  31. focus
  32. @focus="handleInputFocus"
  33. placeholder="扫描物料标签"
  34. @confirm="handleKeydown"
  35. />
  36. <text class="font-icons" @click="handleMapass">&#xe6b7;</text>
  37. </view>
  38. </view>
  39. <view class="table-title">
  40. <span>物料需求清单</span>
  41. </view>
  42. <view class="custom-table">
  43. <uni-table border stripe empty-text="暂无更多数据">
  44. <!-- 表头行 -->
  45. <uni-tr class="custom-table-head">
  46. <uni-th align="center" width="100px">分切单</uni-th>
  47. <uni-th align="center" width="180px">物料</uni-th>
  48. <uni-th align="center" width="180px">批号</uni-th>
  49. <uni-th align="center" width="90px">长</uni-th>
  50. <uni-th align="center" width="90px">宽</uni-th>
  51. <uni-th align="center" width="100px">库位</uni-th>
  52. </uni-tr>
  53. <!-- 表格数据行 -->
  54. <uni-tr v-for="(item, key) in materialList" :key="key">
  55. <uni-td align="center">{{ item.slittingOrderNo }}</uni-td>
  56. <uni-td align="center">{{ item.materialNo }}({{ item.materialName }})</uni-td>
  57. <uni-td align="center">{{ item.batchNumber }}</uni-td>
  58. <uni-td align="center">{{ item.length }}</uni-td>
  59. <uni-td align="center">{{ item.width }}</uni-td>
  60. <uni-td align="center">{{ item.locationName }}</uni-td>
  61. </uni-tr>
  62. </uni-table>
  63. </view>
  64. </view>
  65. <uni-popup ref="errorTip" type="dialog">
  66. <uni-popup-dialog
  67. type="error"
  68. cancel-text="关闭"
  69. confirm-text="确认"
  70. title="提示"
  71. :content="errorTipMessage"
  72. @confirm="handleCloseErrorTipsModal"
  73. @close="handleCloseErrorTipsModal"
  74. />
  75. </uni-popup>
  76. </template>
  77. </gui-page>
  78. </template>
  79. <script>
  80. import {
  81. defineComponent,
  82. onBeforeMount,
  83. ref
  84. } from 'vue'
  85. export default defineComponent({
  86. setup() {
  87. const modalForm = ref('')
  88. const errorState = ref(0)
  89. const easyinput = ref()
  90. const errorTip = ref('')
  91. const errorTipMessage = ref('')
  92. const materialList = ref([])
  93. const scanNumber = ref('')
  94. const search = function() {
  95. uni.$reqGet('cuttingMaterialList', {
  96. pageNo: 1,
  97. pageSize: 100
  98. })
  99. .then(({
  100. code,
  101. data,
  102. msg
  103. }) => {
  104. if (code === 0) {
  105. materialList.value = data?.list ?? []
  106. } else {
  107. uni.showToast({
  108. title: msg,
  109. icon: 'none',
  110. duration: 2000
  111. })
  112. }
  113. })
  114. }
  115. onBeforeMount(() => {
  116. search()
  117. })
  118. const handleMapass = function() {
  119. // #ifdef APP-PLUS
  120. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  121. mpaasScanModule.mpaasScan({
  122. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  123. 'scanType': ['qrCode', 'barCode'],
  124. // 是否隐藏相册,默认false不隐藏
  125. 'hideAlbum': false
  126. },
  127. (ret) => {
  128. if (ret.resp_code === 1000) {
  129. uni.$reqGet('scanPrepareMaterial', {
  130. qrCode: ret.resp_result
  131. })
  132. .then(({
  133. code,
  134. data,
  135. msg
  136. }) => {
  137. if (code === 0) {
  138. setInputFocus()
  139. uni.$reqPost('cuttingMaterialConfirm', {
  140. id: data[0].qrCode
  141. })
  142. .then(ret => {
  143. if (ret.code === 0) {
  144. uni.showToast({
  145. title: '备料成功',
  146. icon: 'none',
  147. duration: 2000
  148. })
  149. search()
  150. } else {
  151. // #ifdef APP-PLUS
  152. plus.device.beep(2)
  153. // #endif
  154. errorTipMessage.value = ret.msg
  155. errorTip.value.open()
  156. errorState.value = 0
  157. }
  158. })
  159. } else {
  160. // #ifdef APP-PLUS
  161. plus.device.beep(2)
  162. // #endif
  163. errorTipMessage.value = msg
  164. errorTip.value.open()
  165. errorState.value = 0
  166. }
  167. })
  168. }
  169. })
  170. // #endif
  171. }
  172. // 扫描完成品标签输入框回车事件
  173. const handleKeydown = function(e) {
  174. uni.$reqGet('scanPrepareMaterial', {
  175. qrCode: e
  176. })
  177. .then(({
  178. code,
  179. data,
  180. msg
  181. }) => {
  182. if (code === 0) {
  183. search()
  184. setInputFocus()
  185. uni.$reqPost('cuttingMaterialConfirm', {
  186. id: data[0].qrCode
  187. })
  188. .then(ret => {
  189. if (ret.code === 0) {
  190. uni.showToast({
  191. title: '备料成功',
  192. icon: 'none',
  193. duration: 2000
  194. })
  195. search()
  196. } else {
  197. // #ifdef APP-PLUS
  198. plus.device.beep(2)
  199. // #endif
  200. errorTipMessage.value = ret.msg
  201. errorTip.value.open()
  202. errorState.value = 0
  203. }
  204. })
  205. } else {
  206. // #ifdef APP-PLUS
  207. plus.device.beep(2)
  208. // #endif
  209. errorTipMessage.value = msg
  210. errorTip.value.open()
  211. errorState.value = 0
  212. }
  213. })
  214. }
  215. const goHome = function() {
  216. uni.$goHome()
  217. }
  218. const setInputFocus = function() {
  219. scanNumber.value = ''
  220. easyinput.value.onBlur()
  221. easyinput.value.onFocus()
  222. }
  223. // 关闭错误信息弹窗
  224. const handleCloseErrorTipsModal = async function() {
  225. errorTip.value.close()
  226. if (errorState.value === 0) {
  227. await setInputFocus()
  228. }
  229. }
  230. // 禁用软键盘
  231. const handleInputFocus = function() {
  232. setTimeout(() => {
  233. uni.hideKeyboard()
  234. }, 100)
  235. }
  236. return {
  237. options: [{
  238. text: '删除',
  239. style: {
  240. backgroundColor: '#dd524d'
  241. }
  242. }],
  243. goHome,
  244. easyinput,
  245. errorTip,
  246. errorTipMessage,
  247. handleInputFocus,
  248. modalForm,
  249. scanNumber,
  250. handleMapass,
  251. handleKeydown,
  252. materialList,
  253. handleCloseErrorTipsModal
  254. }
  255. }
  256. })
  257. </script>
  258. <style lang="scss" scoped>
  259. .gui-header-leader-btns {
  260. color: black;
  261. font-size: 24px !important;
  262. }
  263. .list-content {
  264. margin-top: 80px;
  265. background-color: #edeeee;
  266. }
  267. .input-200 {
  268. width: 200px;
  269. padding-left: 10px;
  270. }
  271. .font-icons {
  272. width: 40px;
  273. font-size: 20px;
  274. text-align: right;
  275. }
  276. .scan {
  277. height: 45px;
  278. width: calc(100% - 48px);
  279. margin: 12px;
  280. padding: 0 12px;
  281. display: flex;
  282. justify-content: space-between;
  283. align-items: center;
  284. border-radius: 6px;
  285. background-color: white;
  286. .scan-card {
  287. width: 100%;
  288. display: grid;
  289. grid-template-rows: 1fr;
  290. grid-template-columns: 7fr 2fr;
  291. align-items: center;
  292. input {
  293. height: 35px;
  294. line-height: 35px;
  295. }
  296. text {
  297. width: 100%;
  298. text-align: right;
  299. }
  300. }
  301. }
  302. .card-list-flexbox {
  303. width: calc(100vw - 24px);
  304. height: 195px;
  305. margin: 0 12px;
  306. display: flex;
  307. justify-content: center;
  308. flex-direction: column;
  309. align-items: center;
  310. overflow-y: scroll;
  311. .card-list-title {
  312. width: 100%;
  313. height: 35px;
  314. line-height: 35px;
  315. margin: 0 4px 0 4px;
  316. border-radius: 4px 4px 0 0;
  317. text-align: center;
  318. color: white;
  319. background-color: rgba(0, 160, 233, 1.0);
  320. }
  321. .card-list-item,
  322. .card-list-item-operation {
  323. width: 100%;
  324. height: 35px;
  325. margin: 0 4px 3rpx 4px;
  326. border-radius: 4px;
  327. display: flex;
  328. flex-direction: row;
  329. align-items: center;
  330. justify-content: space-between;
  331. background-color: #fff;
  332. uni-text {
  333. font-size: 14px;
  334. height: 50rpx;
  335. text-align: left;
  336. padding: 0 8px;
  337. display: flex;
  338. flex-direction: row;
  339. align-items: center;
  340. }
  341. .text-1 {
  342. flex: 1;
  343. height: 35px;
  344. justify-content: flex-start;
  345. }
  346. .text-2 {
  347. flex: 3;
  348. height: 35px;
  349. justify-content: flex-end;
  350. margin-right: 4px;
  351. padding: 2px 6px;
  352. }
  353. }
  354. }
  355. .table-title {
  356. height: 40px;
  357. line-height: 40px;
  358. margin: 4px 0 -3px 0;
  359. padding: 0 12px;
  360. font-size: 16px;
  361. font-weight: bold;
  362. background-color: white;
  363. }
  364. .custom-table {
  365. height: calc(100vh - 200px);
  366. // height: calc(100vh - 265px);
  367. min-height: 230px;
  368. margin: 5px 0;
  369. overflow-y: scroll;
  370. }
  371. </style>