materialSplit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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
  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="form">
  23. <view class="row-1">
  24. <view class="row-1-card">
  25. <uni-easyinput
  26. ref="easyinput"
  27. v-model="submitParams.materialNo"
  28. :input-border="false"
  29. :clearable="false"
  30. type="text"
  31. focus
  32. @focus="handleInputFocus"
  33. placeholder="请扫描物料"
  34. @confirm="confirmMaterial"
  35. />
  36. <text class="font-icons" @click="handleMapass">&#xe6b7;</text>
  37. </view>
  38. </view>
  39. <view class="row-2">
  40. <view class="row-2-card">
  41. <uni-easyinput
  42. ref="easyinput2"
  43. v-model="submitParams.splitQty"
  44. :input-border="false"
  45. :clearable="false"
  46. type="number"
  47. focus
  48. @focus="handleInputFocus"
  49. placeholder="请输入拆分数量"
  50. />
  51. </view>
  52. </view>
  53. <view class="row-3">
  54. <view class="row-3-card">
  55. <view class="row-space-between">
  56. <text>物料编码</text>
  57. <text>{{ submitParams.materialNo }}</text>
  58. </view>
  59. <view class="row-space-between">
  60. <text>物料名称</text>
  61. <text>{{ submitParams.materialName }}</text>
  62. </view>
  63. <view class="row-space-between">
  64. <text>物料批次</text>
  65. <text>{{ submitParams.materialLots }}</text>
  66. </view>
  67. <view class="row-space-between">
  68. <text>批次数量</text>
  69. <text>{{ submitParams.inQty }}</text>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="row-operation">
  74. <view class="row-operation-card">
  75. <view class="button" size="primary" @click="handleSplit">
  76. <text class="gui-color-white">拆分</text>
  77. </view>
  78. </view>
  79. </view>
  80. <uni-popup ref="errorTip" type="dialog">
  81. <uni-popup-dialog
  82. type="error"
  83. cancel-text="关闭"
  84. confirm-text="确认"
  85. title="提示"
  86. :content="errorTipMessage"
  87. @confirm="handleCloseErrorTipsModal"
  88. @close="handleCloseErrorTipsModal"
  89. />
  90. </uni-popup>
  91. </view>
  92. </template>
  93. </gui-page>
  94. </template>
  95. <script>
  96. import {
  97. defineComponent,
  98. ref
  99. } from 'vue'
  100. export default defineComponent({
  101. setup() {
  102. const goBack = function() {
  103. uni.$goBack('/pages/workbranch/warehouse/materialDisass/materialWorkBranch')
  104. }
  105. const errorTip = ref('')
  106. const errorTipMessage = ref('')
  107. const easyinput = ref('')
  108. const easyinput2 = ref('')
  109. const errorState = ref(0)
  110. const isFetch = ref(false)
  111. const submitParams = ref({
  112. splitQty: '', // 拆分数量
  113. materialNo: '', // 物料编码
  114. materialName: '', // 物料名称
  115. materialLots: '', // 物料批次
  116. inQty: '' // 批次数量
  117. })
  118. // 校验参数
  119. const validatorList = ref({
  120. splitQty: '拆分数量',
  121. materialNo: '物料编码',
  122. materialName: '物料名称',
  123. materialLots: '物料批次',
  124. inQty: '批次数量'
  125. })
  126. const handleMapass = function() {
  127. // #ifdef APP-PLUS
  128. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  129. mpaasScanModule.mpaasScan({
  130. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  131. 'scanType': ['qrCode', 'barCode'],
  132. // 是否隐藏相册,默认false不隐藏
  133. 'hideAlbum': false
  134. },
  135. (ret) => {
  136. if (ret.resp_code === 1000) {
  137. uni.$reqGet('splitOrMergeScanMaterial', {
  138. qrCode: ret.resp_result
  139. })
  140. .then(({
  141. code,
  142. data,
  143. msg
  144. }) => {
  145. if (code === 0) {
  146. submitParams.value.id = data?.id // 物料编码
  147. submitParams.value.qrCode = data?.qrCode
  148. submitParams.value.materialNo = data?.materialNo // 物料编码
  149. submitParams.value.materialName = data?.materialName // 物料名称
  150. submitParams.value.materialLots = data?.qrCode // 物料批次
  151. submitParams.value.inQty = data?.inQty // 批次数量
  152. } else {
  153. // #ifdef APP-PLUS
  154. plus.device.beep(2)
  155. // #endif
  156. errorTipMessage.value = msg
  157. errorTip.value.open()
  158. errorState.value = 0
  159. }
  160. })
  161. }
  162. })
  163. // #endif
  164. }
  165. // 扫描物料输入框回车事件
  166. const confirmMaterial = function(e) {
  167. uni.$reqGet('splitOrMergeScanMaterial', {
  168. qrCode: e
  169. })
  170. .then(({
  171. code,
  172. data,
  173. msg
  174. }) => {
  175. if (code === 0) {
  176. submitParams.value.id = data?.id // 物料编码
  177. submitParams.value.qrCode = data?.qrCode
  178. submitParams.value.materialNo = data?.materialNo // 物料编码
  179. submitParams.value.materialName = data?.materialName // 物料名称
  180. submitParams.value.materialLots = data?.qrCode // 物料批次
  181. submitParams.value.inQty = data?.inQty // 批次数量
  182. } else {
  183. // #ifdef APP-PLUS
  184. plus.device.beep(2)
  185. // #endif
  186. errorTipMessage.value = msg
  187. errorTip.value.open()
  188. errorState.value = 0
  189. }
  190. })
  191. }
  192. // 拆分
  193. const handleSplit = function() {
  194. if (isFetch.value === true) {
  195. uni.showToast({
  196. title: '物料拆分中...',
  197. icon: 'none',
  198. duration: 2000
  199. })
  200. } else {
  201. const keys = Object.keys(submitParams.value)
  202. for (let x = 0; x < keys.length; x++) {
  203. const validataIsItEmpty = ['', null, undefined, NaN].includes(submitParams.value[keys[
  204. x]])
  205. if (validataIsItEmpty) {
  206. uni.showToast({
  207. title: validatorList.value[keys[x]] + '不能为空!',
  208. icon: 'none',
  209. duration: 2000
  210. })
  211. return
  212. }
  213. }
  214. isFetch.value = true
  215. submitParams.value.remainderQty = parseInt(submitParams.value.inQty) - parseInt(
  216. submitParams.value.splitQty)
  217. uni.$reqPost('materialSplit', submitParams.value)
  218. .then(({
  219. code,
  220. data,
  221. msg
  222. }) => {
  223. isFetch.value = false
  224. submitParams.value.splitQty = 0
  225. submitParams.value.id = ''
  226. submitParams.value.qrCode = ''
  227. submitParams.value.materialNo = ''
  228. submitParams.value.materialName = ''
  229. submitParams.value.materialLots = ''
  230. submitParams.value.inQty = ''
  231. if (code === 0) {
  232. const copyData = JSON.parse(JSON.stringify(data)) ?? []
  233. // 时间格式转换
  234. copyData.forEach(item => {
  235. item.createTime = $parseTime(item
  236. .createTime)
  237. })
  238. const message = {
  239. 'ClientId': 'webclient',
  240. 'templateName': 'http://192.168.1.156:9900/Upload/Tables/s_reportmodel/202303011142368103/materialSplit.btw',
  241. 'DataList': data
  242. }
  243. // uni.$useStore().mqttConfig.publish('adminS001', JSON.stringify(message), {
  244. // qos: 1
  245. // })
  246. } else {
  247. // #ifdef APP-PLUS
  248. plus.device.beep(2)
  249. // #endif
  250. errorTipMessage.value = msg
  251. errorTip.value.open()
  252. errorState.value = 0
  253. }
  254. })
  255. }
  256. }
  257. const setInputFocus = function() {
  258. submitParams.value.materialNo = ''
  259. easyinput.value.onBlur()
  260. easyinput.value.onFocus()
  261. }
  262. // 关闭错误信息弹窗
  263. const handleCloseErrorTipsModal = async function() {
  264. errorTip.value.close()
  265. if (errorState.value === 0) {
  266. await setInputFocus()
  267. }
  268. }
  269. // 禁用软键盘
  270. const handleInputFocus = function() {
  271. setTimeout(() => {
  272. uni.hideKeyboard()
  273. }, 100)
  274. }
  275. return {
  276. goBack,
  277. easyinput,
  278. easyinput2,
  279. errorTip,
  280. errorTipMessage,
  281. submitParams,
  282. handleMapass,
  283. handleSplit,
  284. confirmMaterial,
  285. handleInputFocus,
  286. handleCloseErrorTipsModal
  287. }
  288. }
  289. })
  290. </script>
  291. <style lang="scss" scoped>
  292. .gui-header-leader-btns {
  293. color: black;
  294. font-size: 24px !important;
  295. margin-left: 24rpx;
  296. }
  297. .gui-sbody {
  298. font-size: 14px;
  299. background-color: rgba(234, 239, 242, 1);
  300. }
  301. .form {
  302. margin-top: 85px;
  303. }
  304. .row-1,
  305. .row-3 {
  306. height: 55px;
  307. display: flex;
  308. justify-content: center;
  309. background-color: white;
  310. }
  311. .row-2 {
  312. height: 55px;
  313. display: flex;
  314. background-color: white;
  315. }
  316. .row-2,
  317. .row-3 {
  318. margin-top: 10px;
  319. }
  320. .row-1 {
  321. .row-1-card {
  322. flex: 1;
  323. display: flex;
  324. flex-direction: row;
  325. justify-content: space-between;
  326. align-items: center;
  327. }
  328. }
  329. .row-3 {
  330. height: 200px;
  331. .row-3-card {
  332. display: flex;
  333. flex-direction: column;
  334. .row-space-between {
  335. flex: 1;
  336. width: calc(100vw - 40px);
  337. display: flex;
  338. flex-direction: row;
  339. justify-content: space-between;
  340. align-items: center;
  341. padding-left: 20px;
  342. padding-right: 20px;
  343. padding-top: 12px;
  344. padding-bottom: 12px;
  345. }
  346. }
  347. }
  348. .row-1-card,
  349. .row-2-card {
  350. display: flex;
  351. flex-direction: row;
  352. justify-content: flex-start;
  353. align-items: center;
  354. padding-left: 10px;
  355. padding-right: 10px;
  356. }
  357. .row-operation {
  358. height: 110px;
  359. padding-left: 20px;
  360. padding-right: 20px;
  361. display: flex;
  362. flex-direction: row;
  363. justify-content: center;
  364. align-items: center;
  365. .row-operation-card {
  366. flex: 1;
  367. .btn-row-1 {
  368. margin-bottom: 5px !important;
  369. }
  370. }
  371. }
  372. .input-200 {
  373. width: 200px;
  374. padding-left: 10px;
  375. }
  376. .input-300 {
  377. width: 300px;
  378. padding-left: 10px;
  379. }
  380. .font-icons {
  381. width: 40px;
  382. font-size: 20px;
  383. }
  384. </style>