issuePage.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <gui-page :custom-header="true" :is-header-sized="false" :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: 14px;">发料</text>
  11. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  12. <!-- 实际宽度请根据自己情况设置 -->
  13. <view style="width:40px;" />
  14. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
  15. </view>
  16. </template>
  17. <template #gBody>
  18. <view class="form">
  19. <view class="row-1">
  20. <view class="row-1-card">
  21. <input v-model="submitParams.erpMaterialId" class="gui-form-input input-200" name="name"
  22. placeholder="扫描物料条码" @input="inputting" @focus="handleInputFocus">
  23. <text class="font-icons" style="font-size: 20px;" @click="handleMapass">&#xe6b7;</text>
  24. </view>
  25. </view>
  26. <view class="row-3">
  27. <view class="row-3-card">
  28. <view class="row-space-between">
  29. <text>物料编码</text>
  30. <text>{{ submitParams.erpMaterialId }}</text>
  31. </view>
  32. <view class="row-space-between">
  33. <text>物料名称</text>
  34. <text>{{ submitParams.materialName }}</text>
  35. </view>
  36. <view class="row-space-between">
  37. <text>物料批次</text>
  38. <text>{{ submitParams.materialLots }}</text>
  39. </view>
  40. <view class="row-space-between">
  41. <text>批次数量</text>
  42. <text>{{ submitParams.batchQty }}</text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="row-2">
  47. <view class="row-2-card" @click="handleNavigateTo">
  48. <text>本次发料记录</text>
  49. <!-- <view class="right-anchor">
  50. <text>{{ issueRecord.length }}</text>
  51. <text class="font-icons">&#xe601;</text>
  52. </view> -->
  53. </view>
  54. </view>
  55. <view class="row-operation">
  56. <view class="row-operation-card">
  57. <button type="default" class="gui-button gui-button gui-bg-blue gui-noborder btn-row-1"
  58. @click="handleAddIssue">
  59. <text class="gui-color-white gui-button-text">添加发料</text>
  60. </button>
  61. <button type="default" class="gui-button gui-button gui-bg-green gui-noborder"
  62. @click="handleNavigateToBack">
  63. <text class="gui-color-white gui-button-text">完成发料</text>
  64. </button>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. </gui-page>
  70. </template>
  71. <script>
  72. import {
  73. defineComponent,
  74. ref
  75. } from 'vue'
  76. import {
  77. onLoad
  78. } from '@dcloudio/uni-app'
  79. export default defineComponent({
  80. setup() {
  81. const goBack = function() {
  82. uni.$goBack('/pages/workbranch/warehouse/productionIssue/demandDetails')
  83. }
  84. const masterId = ref('')
  85. const issueRecord = ref([])
  86. const submitParams = ref({
  87. erpMaterialId: '', // 物料编码
  88. materialName: '', // 物料名称
  89. materialLots: '', // 物料批次
  90. supplierCode: '', // 供应商编号
  91. batchQty: '', // 批次数量
  92. unitCode: '', // 单位
  93. wmsLabelMasterId: '', // qrCode
  94. wmsProductionWorkOrderBomDetailId: '', // 父级ID
  95. wmsStockAreaId: '', // 货位
  96. wmsStockId: '', // 仓库
  97. wmsStockLocationId: '' // 区域
  98. })
  99. // 校验参数
  100. const validatorList = ref({
  101. erpMaterialId: '物料编码', // 物料编码
  102. materialName: '物料名称', // 物料名称
  103. materialLots: '物料批次', // 物料批次
  104. supplierCode: '供应商编号', // 供应商编号
  105. batchQty: '批次数量', // 批次数量
  106. unitCode: '单位', // 单位
  107. wmsLabelMasterId: 'qrCode', // qrCode
  108. wmsProductionWorkOrderBomDetailId: '父级ID', // 父级ID
  109. wmsStockAreaId: '货位', // 货位
  110. wmsStockId: '仓库', // 仓库
  111. wmsStockLocationId: '区域' // 区域
  112. })
  113. const inputting = function(e) {
  114. console.log(e)
  115. }
  116. onLoad((options) => {
  117. masterId.value = options?.id
  118. })
  119. const handleMapass = function() {
  120. // uni.$reqGet("scanMaterial", {
  121. // qrCode: "1633359048430505985-1-1-1-2"
  122. // })
  123. // .then(({
  124. // data
  125. // }) => {
  126. // uni.$grace.msg("成功")
  127. // submitParams.value = {
  128. // erpMaterialId: data?.materialNo, // 物料编码
  129. // materialName: data?.materialName, // 物料名称
  130. // materialLots: data?.materialLots, // 物料批次
  131. // supplierCode: data?.supplierCode, // 供应商编号
  132. // batchQty: data?.receiptQty, // 批次数量
  133. // unitCode: data?.funitId, // 单位
  134. // wmsLabelMasterId: data?.qrCode, // qrCode
  135. // wmsProductionWorkOrderBomDetailId: masterId.value,
  136. // wmsStockAreaId: data?.wmsStoreAreaId,
  137. // wmsStockId: data?.erpStockId,
  138. // wmsStockLocationId: data?.wmsStoreId,
  139. // }
  140. // })
  141. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  142. mpaasScanModule.mpaasScan({
  143. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  144. 'scanType': ['qrCode', 'barCode'],
  145. // 是否隐藏相册,默认false不隐藏
  146. 'hideAlbum': false
  147. },
  148. (ret) => {
  149. if (ret.resp_code === 1000) {
  150. uni.$reqGet('scanMaterial', {
  151. qrCode: ret.resp_result
  152. })
  153. .then(({
  154. data
  155. }) => {
  156. submitParams.value = {
  157. erpMaterialId: data?.materialNo, // 物料编码
  158. materialName: data?.materialName, // 物料名称
  159. materialLots: data?.materialLots, // 物料批次
  160. supplierCode: data?.supplierCode, // 供应商编号
  161. batchQty: data?.receiptQty, // 批次数量
  162. unitCode: data?.funitId, // 单位
  163. wmsLabelMasterId: data?.qrCode, // qrCode
  164. wmsProductionWorkOrderBomDetailId: masterId.value,
  165. wmsStockAreaId: data?.wmsStoreAreaId,
  166. wmsStockId: data?.erpStockId,
  167. wmsStockLocationId: data?.wmsStoreId
  168. }
  169. })
  170. }
  171. })
  172. }
  173. // 完成发料
  174. const handleNavigateToBack = function() {
  175. uni.$reqPost('issueFinishIssue', issueRecord.value).then(({
  176. code,
  177. data,
  178. msg
  179. }) => {
  180. if (code === 0) {
  181. uni.$grace.msg('已完成发料')
  182. } else {
  183. uni.$grace.msg(msg)
  184. }
  185. })
  186. }
  187. // 添加发料
  188. const handleAddIssue = function(state) {
  189. const keys = Object.keys(submitParams.value)
  190. for (let x = 0; x < keys.length; x++) {
  191. if (submitParams.value[keys[x]] === '' || submitParams.value[keys[x]] === undefined ||
  192. submitParams.value[keys[x]] === null) {
  193. uni.$grace.msg(validatorList.value[keys[x]] + '不能为空!')
  194. return
  195. }
  196. }
  197. issueRecord.value.push(submitParams.value)
  198. submitParams.value = {
  199. erpMaterialId: '',
  200. materialName: '',
  201. materialLots: '',
  202. supplierCode: '',
  203. batchQty: '',
  204. unitCode: '',
  205. wmsLabelMasterId: '',
  206. wmsProductionWorkOrderBomDetailId: '',
  207. wmsStockAreaId: '',
  208. wmsStockId: '',
  209. wmsStockLocationId: ''
  210. }
  211. uni.setStorage({
  212. key: 'issueRecord',
  213. data: JSON.stringify(issueRecord.value)
  214. })
  215. }
  216. // 本次发料记录
  217. const handleNavigateTo = function() {
  218. uni.navigateTo({
  219. url: '/pages/workbranch/warehouse/productionIssue/currentIssueRecord'
  220. })
  221. }
  222. // 禁用软键盘
  223. const handleInputFocus = function() {
  224. setTimeout(() => {
  225. uni.hideKeyboard()
  226. }, 100)
  227. }
  228. return {
  229. goBack,
  230. issueRecord,
  231. submitParams,
  232. inputting,
  233. handleMapass,
  234. handleAddIssue,
  235. handleInputFocus,
  236. handleNavigateTo,
  237. handleNavigateToBack
  238. }
  239. }
  240. })
  241. </script>
  242. <style lang="scss" scoped>
  243. .gui-header-leader-btns {
  244. color: black;
  245. font-size: 24px !important;
  246. margin-left: 24rpx;
  247. }
  248. .gui-sbody {
  249. font-size: 14px;
  250. background-color: rgba(234, 239, 242, 1);
  251. }
  252. .form {
  253. margin-top: 85px;
  254. }
  255. .row-1,
  256. .row-2,
  257. .row-3,
  258. .row-4 {
  259. margin-top: 10px;
  260. height: 55px;
  261. display: flex;
  262. justify-content: center;
  263. background-color: white;
  264. }
  265. .row-1 {
  266. margin-top: 0px;
  267. }
  268. .row-1,
  269. .row-2 {
  270. .row-1-card,
  271. .row-2-card {
  272. display: flex;
  273. flex-direction: row;
  274. justify-content: space-between;
  275. align-items: center;
  276. width: 100%;
  277. padding-left: 10px;
  278. padding-right: 10px;
  279. }
  280. }
  281. .row-3 {
  282. height: 200px;
  283. .row-3-card {
  284. display: flex;
  285. flex-direction: column;
  286. .row-space-between {
  287. flex: 1;
  288. width: calc(100vw - 40px);
  289. display: flex;
  290. flex-direction: row;
  291. justify-content: space-between;
  292. align-items: center;
  293. padding-top: 12px;
  294. padding-bottom: 12px;
  295. }
  296. }
  297. }
  298. .row-4 {
  299. height: 260px;
  300. .row-4-card {
  301. display: flex;
  302. flex-direction: column;
  303. .row-space-between {
  304. flex: 1;
  305. width: calc(100vw - 40px);
  306. display: flex;
  307. flex-direction: row;
  308. justify-content: space-between;
  309. align-items: center;
  310. padding-top: 12px;
  311. padding-bottom: 12px;
  312. }
  313. }
  314. }
  315. .row-operation {
  316. height: 110px;
  317. padding-left: 20px;
  318. padding-right: 20px;
  319. display: flex;
  320. flex-direction: row;
  321. justify-content: center;
  322. align-items: center;
  323. .row-operation-card {
  324. flex: 1;
  325. .btn-row-1 {
  326. margin-bottom: 5px !important;
  327. }
  328. }
  329. }
  330. .input-200 {
  331. width: 200px;
  332. padding-left: 10px;
  333. }
  334. .input-300 {
  335. width: 300px;
  336. padding-left: 10px;
  337. }
  338. .font-icons {
  339. width: 40px;
  340. font-size: 20px;
  341. }
  342. .select-group {
  343. display: flex;
  344. flex-direction: column;
  345. flex: 1;
  346. .select-item {
  347. display: flex;
  348. flex-direction: row;
  349. align-items: center;
  350. margin-bottom: 10px;
  351. .store-text {
  352. margin-right: 14px;
  353. }
  354. }
  355. }
  356. text,
  357. span {
  358. font-size: 12px;
  359. }
  360. </style>