index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  1. <template>
  2. <view class="app-container">
  3. <uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar :title="formData.billTypeName"
  4. left-icon="left" left-text="返回" @clickLeft="handleBack" right-icon="refreshempty"
  5. @clickRight="SendNumEmpty" />
  6. <view class="scan-header">
  7. <uni-forms-item name="remark" label="条码" :label-width="lableWidth" labelAlign="right"
  8. style="margin-bottom: 0px; padding: 0px 15px 0px 15px;">
  9. <uni-easyinput type="text" :inputBorder="true" v-model="barCode" :focus="remarkFocus" :clearable="false"
  10. @confirm="scanSearch"></uni-easyinput>
  11. <view class="icon" @click="handleScanClick">
  12. <uni-icons type="scan" size="20"></uni-icons>
  13. </view>
  14. </uni-forms-item>
  15. </view>
  16. <view class="cprk-content">
  17. <scroll-view :scroll-top="scrollTop" :show-scrollbar="true" scroll-y="true" class="scroll-Y"
  18. @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
  19. <view class="form-container">
  20. <uni-forms :rules="rules" :value="formData" ref="form" validate-trigger="submit"
  21. err-show-type="toast">
  22. <uni-forms-item name="warehouseCode" :required="true" label="仓库" :label-width="lableWidth"
  23. labelAlign="right">
  24. <uni-easyinput type="text" v-model="formData.warehouseCode" v-show="false"></uni-easyinput>
  25. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  26. v-model="formData.warehouseName" suffixIcon="compose"
  27. @iconClick="setScan('WH')"></uni-easyinput>
  28. </uni-forms-item>
  29. <uni-forms-item name="taskCode" :required="true" label="任务编码" :label-width="lableWidth"
  30. labelAlign="right">
  31. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  32. v-model="formData.taskCode" suffixIcon="search"
  33. @iconClick="searchIconClick('task')"></uni-easyinput>
  34. </uni-forms-item>
  35. <uni-forms-item name="deptCode" label="部门" :label-width="lableWidth" labelAlign="right">
  36. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  37. v-show="false" v-model="formData.deptCode"></uni-easyinput>
  38. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  39. v-model="formData.deptName" suffixIcon="search"
  40. @iconClick="searchIconClick('dept')"></uni-easyinput>
  41. </uni-forms-item>
  42. <uni-forms-item name="employeeCode" label="职员" :label-width="lableWidth" labelAlign="right">
  43. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  44. v-model="formData.employeeCode" v-show="false"></uni-easyinput>
  45. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  46. v-model="formData.employeeName" suffixIcon="search"
  47. @iconClick="searchIconClick('empl')"></uni-easyinput>
  48. </uni-forms-item>
  49. <uni-forms-item name="locationCode" :required="requiredLocation" label="货位"
  50. :label-width="lableWidth" labelAlign="right">
  51. <uni-easyinput type="text" v-model="formData.locationCode" v-show="false"></uni-easyinput>
  52. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  53. v-model="formData.locationName" suffixIcon="compose"
  54. @iconClick="setScan('PT')"></uni-easyinput>
  55. </uni-forms-item>
  56. <uni-forms-item name="labelCode" :required="true" label="标签编码" :label-width="lableWidth"
  57. labelAlign="right">
  58. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  59. v-model="formData.labelCode" suffixIcon="compose"
  60. @iconClick="setScan('L')"></uni-easyinput>
  61. </uni-forms-item>
  62. <uni-forms-item name="materialCode" label="物料" :label-width="lableWidth" labelAlign="right">
  63. <uni-easyinput type="text" v-model="formData.materialCode" v-show="false"></uni-easyinput>
  64. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  65. v-model="formData.materialName"></uni-easyinput>
  66. </uni-forms-item>
  67. <uni-forms-item name="batch" label="批号" :label-width="lableWidth" labelAlign="right">
  68. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  69. v-model="formData.batch"></uni-easyinput>
  70. </uni-forms-item>
  71. <uni-forms-item name="unitCode" label="单位" :label-width="lableWidth" labelAlign="right">
  72. <uni-easyinput type="text" v-model="formData.unitCode" v-show="false"></uni-easyinput>
  73. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  74. v-model="formData.unitName"></uni-easyinput>
  75. </uni-forms-item>
  76. <uni-forms-item name="stockQty" :required="true" label="盘点数量" :label-width="lableWidth"
  77. labelAlign="right">
  78. <uni-easyinput type="number" :inputBorder="true" v-model="formData.stockQty"
  79. @blur="stockQtyBlur"></uni-easyinput>
  80. </uni-forms-item>
  81. <uni-forms-item name="palletCode" label="托盘" :label-width="lableWidth" labelAlign="right">
  82. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  83. v-model="formData.palletCode" suffixIcon="search"
  84. @iconClick="searchIconClick('pall')"></uni-easyinput>
  85. </uni-forms-item>
  86. <uni-forms-item name="packageCode" label="包装" :label-width="lableWidth" labelAlign="right">
  87. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  88. v-model="formData.packageCode" suffixIcon="search"
  89. @iconClick="searchIconClick('pack')"></uni-easyinput>
  90. </uni-forms-item>
  91. </uni-forms>
  92. </view>
  93. </scroll-view>
  94. </view>
  95. <view class="page-bottom">
  96. <view class="p-b-btn">
  97. <uni-badge class="uni-badge-left-margin" :text="mxNum" :max-num="999" absolute="rightTop"
  98. :offset="[-3, -3]" size="small">
  99. <view class="box"><text class="box-text" @click="handleMx">明细</text></view>
  100. </uni-badge>
  101. </view>
  102. <view class="p-b-btn" @click="$noMultipleClicks(handleSave)">
  103. <text class="box-text" v-show="isShowSaveButton">暂存</text>
  104. </view>
  105. <view class="p-b-btn" @click="handleAuto">
  106. <text class="box-text">{{autoButtonTitle}}</text>
  107. </view>
  108. <view class="p-b-btn" @click="handleBack">
  109. <text class="box-text">返回</text>
  110. </view>
  111. </view>
  112. <scan-code />
  113. <!-- 明细弹窗 -->
  114. <MxPopup ref="mxPopup" @sendNum="getSendNum" :formData="formData" @sendData="getSendData" />
  115. <!-- 任务编码弹窗 -->
  116. <RwbmPopup ref="rwbmPopup" :title="rwbmTitle" :idxFlag="rwbmFlag" :formData="formData"
  117. @sendData="getSendData" />
  118. <!-- 部门弹窗 -->
  119. <BmPopup ref="bmPopup" :title="bmTitle" :idxFlag="bmFlag" :formData="formData" @sendData="getSendData" />
  120. <!-- 职员 -->
  121. <ZyPopup ref="zyPopup" :title="zyTitle" :idxFlag="zyFlag" :formData="formData" @sendData="getSendData" />
  122. <!-- 托盘 -->
  123. <TpPopup ref="tpPopup" :title="tpTitle" :idxFlag="tpFlag" :formData="formData" @sendData="getSendData" />
  124. <!-- 包装 -->
  125. <BzPopup ref="bzPopup" :title="bzTitle" :idxFlag="bzFlag" :formData="formData" @sendData="getSendData" />
  126. </view>
  127. </template>
  128. <script>
  129. import scanCode from "@/components/scan/scan.vue";
  130. import RwbmPopup from './popup/commonpopup.vue' // 任务编码
  131. import BmPopup from './popup/commonpopup.vue' // 部门
  132. import ZyPopup from './popup/commonpopup.vue' // 职业
  133. import TpPopup from './popup/commonpopup.vue' // 托盘
  134. import BzPopup from './popup/commonpopup.vue' // 包装
  135. import MxPopup from './popup/mxPopup.vue'
  136. import {
  137. addstockCheck,
  138. listRwbm,
  139. listWarehouse,
  140. listLocation,
  141. listLabelQueryParams,
  142. listPallet,
  143. listPackage
  144. } from '@/api/wms/stockCheck.js'
  145. import { nanoid } from 'nanoid'; //唯一值 nanoid
  146. export default {
  147. components: {
  148. scanCode,
  149. RwbmPopup,
  150. BmPopup,
  151. MxPopup,
  152. ZyPopup,
  153. TpPopup,
  154. BzPopup
  155. },
  156. props: {},
  157. async onLoad(option) {
  158. //下面请求如果失败改为false
  159. let isRequest = true;
  160. //请求写这里
  161. if (isRequest == false) {
  162. uni.showModal({
  163. title: '获取单据信息失败',
  164. content: '请返回菜单重新进入',
  165. showCancel: false, //不显示取消按钮
  166. success: function(res) {
  167. if (res.confirm) {
  168. uni.navigateBack();
  169. }
  170. }
  171. })
  172. } else {
  173. this.isRequest = true
  174. }
  175. },
  176. onUnload() {
  177. uni.removeStorageSync('stock_key');
  178. },
  179. onBackPress(options) {
  180. if (options.from === 'navigateBack') {
  181. // 来自于导航条返回按钮或者系统返回按钮的事件
  182. return false;
  183. }
  184. // 双击返回的逻辑
  185. const now = Date.now();
  186. if (this.lastBackPress && now - this.lastBackPress < 1000) {
  187. // 如果两次点击的间隔小于1000毫秒,则可以认为是双击
  188. //这时退出
  189. return false;
  190. } else {
  191. this.lastBackPress = now;
  192. uni.showToast({
  193. title: '再按一次退出',
  194. icon: 'none'
  195. });
  196. setTimeout(() => {
  197. this.lastBackPress = null;
  198. }, 1000);
  199. return true;
  200. }
  201. },
  202. data() {
  203. return {
  204. isRequest: false, //onLoad请求成功时改为true,否则不允许保存
  205. remarkFocus: false,
  206. mxNum: 0, //明细按钮数量
  207. isShowSaveButton: true, //是否显示保存按钮
  208. autoButtonTitle: '手动',
  209. scrollTop: 0,
  210. old: {
  211. scrollTop: 0
  212. },
  213. barCode: '', //条码
  214. formData: {
  215. status: "1",
  216. // 单据类型
  217. billTypeCode: "2", // 单据类型
  218. billTypeName: "标签盘点", // 单据类型的名称(显示使用)
  219. // 任务编码
  220. taskCode: "", // 任务编码
  221. taskCheckId: "",
  222. // 部门
  223. deptCode: "", //部门
  224. deptName: "", //部门名称
  225. // 职员
  226. employeeCode: "", // 职员
  227. employeeName: "", // 职员名称
  228. //预留
  229. extendCode01: "",
  230. extendCode02: "",
  231. extendCode03: "",
  232. extendCode04: "",
  233. extendCode05: "",
  234. // 组id
  235. appGroupId: "",
  236. // ===== 以下 保存时转化为 wmsStockChecksList=====
  237. // 仓库
  238. warehouseCode: "", // 仓库
  239. warehouseName: "", // 仓库名称
  240. // 货位
  241. locationCode: "", // 货位编码
  242. locationName: "", // 货位名称
  243. // 标签
  244. labelCode: "", // 标签编码
  245. // 物料
  246. materialCode: "", // 物料编码
  247. materialName: "", //物料名称
  248. // 批号
  249. batch: "", //批号
  250. // 托盘
  251. palletCode: "", // 托盘编码
  252. palletName: "", // 托盘名称
  253. // 包装
  254. packageCode: "", // 包装编码
  255. packageName: "", // 包装名称
  256. //单位
  257. unitCode: "", //单位编码
  258. unitName: "", //单位名称
  259. stockQty: "", // 盘点数量
  260. batch1: "", //批号1
  261. batch2: "", //批号2
  262. materialSpecification: "", //物料规格
  263. },
  264. requiredLocation: true,
  265. show: false,
  266. lableWidth: '80px',
  267. styleInput: {
  268. color: '#333',
  269. backgroundColor: '#fff',
  270. disableColor: '#fff',
  271. borderColor: '#e5e5e5',
  272. },
  273. // 任务编码
  274. rwbmTitle: "任务",
  275. rwbmFlag: "rwbm",
  276. // 职员
  277. zyTitle: "职员",
  278. zyFlag: "zy",
  279. // 部门
  280. bmTitle: "部门",
  281. bmFlag: "bm",
  282. // 收发类别
  283. sflbTitle: "收发类别",
  284. sflbFlag: "sflb",
  285. // 供应商
  286. gysTitle: "供应商",
  287. gysFlag: "gys",
  288. // 托盘
  289. tpTitle: "托盘",
  290. tpFlag: "tp",
  291. // 包装
  292. bzTitle: "包装",
  293. bzFlag: "bz",
  294. //校验
  295. rules: {
  296. warehouseName: {
  297. rules: [{
  298. required: true,
  299. errorMessage: '仓库不能为空'
  300. }],
  301. },
  302. labelCode: {
  303. rules: [{
  304. required: true,
  305. errorMessage: '标签不能为空'
  306. }],
  307. },
  308. stockQty: {
  309. rules: [{
  310. required: true,
  311. errorMessage: '盘点数量不能为空'
  312. }],
  313. },
  314. },
  315. //配合$noMultipleClicks防止重复点击
  316. noClick:true,
  317. }
  318. },
  319. methods: {
  320. upper: function(e) {},
  321. lower: function(e) {},
  322. scroll: function(e) {
  323. this.old.scrollTop = e.detail.scrollTop
  324. },
  325. //获取单据类型等信息时,重复尝试获取
  326. //requestFunction:api函数,requestParams:参数,maxRetries:重试次数
  327. async retryRequest(requestFunction, requestParams, maxRetries = 1) {
  328. let retriesLeft = maxRetries;
  329. while (retriesLeft > 0) {
  330. try {
  331. // 调用请求函数并传入参数
  332. const response = await requestFunction(requestParams);
  333. if (response && response.code === 200) {
  334. return response; // 请求成功,返回响应
  335. } else {
  336. // 请求失败,但还有重试机会
  337. //console.warn(`请求失败,正在尝试第 ${maxRetries - retriesLeft + 1} 次重试...`);
  338. retriesLeft--;
  339. }
  340. } catch (error) {
  341. // 请求发生异常,但还有重试机会
  342. //console.error('请求发生异常,正在尝试重试...', error);
  343. retriesLeft--;
  344. }
  345. }
  346. // 所有重试都失败了,抛出错误
  347. throw new Error('获取信息失败');
  348. },
  349. //安卓扫码
  350. onShow() {
  351. let that = this;
  352. uni.$off("scancode"); // 每次进来先 移除全局自定义事件监听器
  353. uni.$on("scancode", (data) => {
  354. // 扫描PCS码
  355. if (data && data !== '') {
  356. that.barCode = data;
  357. this.getDataByRemark(that.barCode);
  358. } else {
  359. uni.showToast({
  360. title: '扫码失败!',
  361. icon: 'none',
  362. duration: 2000
  363. });
  364. }
  365. });
  366. },
  367. // 条码右侧扫码按钮事件
  368. handleScanClick: function() {
  369. let that = this;
  370. uni.scanCode({
  371. success: function(res) {
  372. // {"scanType":"QR_CODE","path":"","charSet":"ISO8859_1","result":"PT|04-A-1-1","errMsg":"scanCode:ok"}
  373. if (res.errMsg == "scanCode:ok") {
  374. that.barCode = res.result;
  375. this.getDataByRemark(that.barCode);
  376. } else {
  377. uni.showToast({
  378. title: '扫码失败!',
  379. icon: 'none',
  380. duration: 2000
  381. });
  382. }
  383. },
  384. fail: (err) => {
  385. //扫码失败
  386. },
  387. complete: () => {
  388. //扫码结束
  389. }
  390. });
  391. },
  392. // 根据扫码数据查询其他formItem数据
  393. getDataByRemark(remark) {
  394. let that = this;
  395. remark = remark.replace(/^\s+|\s+$/g, '');
  396. let splitPre = remark.split("|")[0];
  397. let splitLast = remark.slice(splitPre.length + 1);
  398. // 条码空 不执行
  399. if (splitLast == "") {
  400. return true;
  401. }
  402. // 扫码
  403. switch (splitPre) {
  404. case "PT": // 货位 PT|04-A-1-1
  405. this.getScanHwList(splitLast);
  406. break;
  407. case "WH": // 仓库 WH|01
  408. this.getScanCkList(splitLast);
  409. break;
  410. case "RW": // 任务扫码 RW|
  411. this.getScanRwList(splitLast);
  412. break;
  413. case "L": // 标签 L|L2311060002
  414. this.getScanBqList(splitLast);
  415. break;
  416. case "P": // 托盘 P|0002
  417. this.getScanTpList(splitLast);
  418. break;
  419. case "PA": // 包装 PA|0002
  420. this.getScanBzList(splitLast);
  421. break;
  422. default:
  423. uni.showToast({
  424. title: "条码不合法",
  425. icon: "none"
  426. })
  427. break;
  428. }
  429. },
  430. // 条码框 回车
  431. scanSearch(remark) {
  432. this.getDataByRemark(remark);
  433. },
  434. getSendData(res) { //基础资料
  435. let cFlag = res.currentFlag;
  436. switch (cFlag) {
  437. case "rwbm": // 任务编码
  438. this.formData.taskCode = res.selectData.taskCode;
  439. this.formData.taskCheckId = res.selectData.id;
  440. // 赋值部门
  441. this.formData.deptCode = res.selectData.deptCode;
  442. this.formData.deptName = res.selectData.deptName;
  443. // 赋值职员
  444. this.formData.employeeCode = res.selectData.employeeCode;
  445. this.formData.employeeName = res.selectData.employeeName;
  446. break;
  447. case "bm": // 部门
  448. // this.formData.deptCode = res.selectData.deptCode;
  449. this.$set(this.formData, "deptCode", res.selectData.deptCode);
  450. this.$set(this.formData, "deptName", res.selectData.deptName);
  451. // this.formData.deptCode = res.selectData.deptCode;
  452. // this.formData.deptName = res.selectData.deptName;
  453. // 职员清空
  454. this.formData.employeeCode = "";
  455. this.formData.employeeName = "";
  456. break;
  457. case "zy": // 职员
  458. this.formData.employeeCode = res.selectData.employeeCode;
  459. this.formData.employeeName = res.selectData.employeeName;
  460. break;
  461. case "bz": // 包装
  462. this.formData.packageCode = res.selectData.packageCode;
  463. this.formData.packageName = res.selectData.packageName;
  464. if(res.selectData.warehouseCode){
  465. this.formData.warehouseCode = res.selectData.warehouseCode;
  466. this.formData.warehouseName = res.selectData.warehouseName;
  467. }
  468. if(res.selectData.locationCode){
  469. this.formData.locationCode = res.selectData.locationCode;
  470. this.formData.locationName = res.selectData.locationName;
  471. }
  472. if(res.selectData.palletCode){
  473. this.formData.palletCode = res.selectData.palletCode;
  474. this.formData.palletName = res.selectData.palletName;
  475. }
  476. break;
  477. case "tp": // 托盘
  478. this.formData.palletCode = res.selectData.palletCode;
  479. this.formData.palletName = res.selectData.palletName;
  480. if(res.selectData.warehouseCode){
  481. this.formData.warehouseCode = res.selectData.warehouseCode;
  482. this.formData.warehouseName = res.selectData.warehouseName;
  483. }
  484. if(res.selectData.locationCode){
  485. this.formData.locationCode = res.selectData.locationCode;
  486. this.formData.locationName = res.selectData.locationName;
  487. }
  488. this.formData.packageCode = '';
  489. this.formData.packageName = '';
  490. break;
  491. case "stock": // 其它单据
  492. this.formData = {
  493. billTypeCode: "2",
  494. billTypeName: "标签盘点",
  495. taskCode: res.selectData.taskCode,
  496. taskCheckId: res.selectData.taskCheckId,
  497. deptCode: res.selectData.deptCode,
  498. deptName: res.selectData.deptName,
  499. employeeCode: res.selectData.employeeCode,
  500. employeeName: res.selectData.employeeName,
  501. appGroupId: res.selectData.appGroupId,
  502. extendCode01: "",
  503. extendCode02: "",
  504. extendCode03: "",
  505. extendCode04: "",
  506. extendCode05: "",
  507. // ===== 以下 保存时转化为 wmsStockChecksList=====
  508. locationCode: "",
  509. locationName: "",
  510. labelCode: "",
  511. materialCode: "",
  512. materialName: "",
  513. batch: "",
  514. palletCode: "",
  515. palletName: "",
  516. packageCode: "",
  517. packageName: "",
  518. unitCode: "",
  519. unitName: "",
  520. stockQty: "",
  521. batch1: "",
  522. batch2: "",
  523. materialSpecification: "",
  524. };
  525. break;
  526. default:
  527. break;
  528. }
  529. },
  530. searchIconClick(type) { // 放大镜点击
  531. switch (type) {
  532. case "task": // 任务编码
  533. this.$refs.rwbmPopup.showPopup();
  534. break;
  535. case "dept": // 部门
  536. this.$refs.bmPopup.showPopup();
  537. break;
  538. case "empl": // 职员
  539. this.$refs.zyPopup.showPopup();
  540. break;
  541. case "pall": // 托盘
  542. this.$refs.tpPopup.showPopup();
  543. break;
  544. case "pack": // 包装
  545. this.$refs.bzPopup.showPopup();
  546. break;
  547. default:
  548. break;
  549. }
  550. },
  551. remarkGetFocus() {
  552. this.remarkFocus = false;
  553. this.$nextTick(() => {
  554. this.remarkFocus = true
  555. })
  556. },
  557. setScan(str) { //赋值条码框 光标聚焦
  558. this.barCode = str + "|";
  559. this.remarkGetFocus();
  560. },
  561. stockQtyBlur(value) {
  562. // 校验数量
  563. },
  564. // 下面工具栏 明细点击 事件
  565. handleMx() {
  566. this.$refs.mxPopup.showDrawer();
  567. },
  568. handleSave() {
  569. //获取信息失败时不可以保存
  570. if (this.isRequest == false) {
  571. uni.showToast({
  572. title: '获取单据信息失败,请返回菜单重新进入',
  573. icon: "none"
  574. })
  575. return true;
  576. }
  577. if (this.isShowSaveButton) {
  578. uni.showToast({
  579. title: '保存中,请稍等',
  580. icon: 'none',
  581. duration:2000
  582. })
  583. }
  584. //如果唯一值空,生成唯一值
  585. if(this.formData.appGroupId=='' || this.formData.appGroupId==null){
  586. this.formData.appGroupId = nanoid(19)
  587. }
  588. let that = this;
  589. that.$refs.form.validate().then(async res => {
  590. let that = this;
  591. let wmsStockChecksArr = [];
  592. let tmpWms = {
  593. warehouseCode: that.formData.warehouseCode, // 仓库
  594. warehouseName: that.formData.warehouseName, // 仓库名称
  595. locationCode: that.formData.locationCode, // 货位编码
  596. locationName: that.formData.locationName, // 货位名称
  597. labelCode: that.formData.labelCode, // 标签编码
  598. materialCode: that.formData.materialCode, // 物料编码
  599. materialName: that.formData.materialName, //物料名称
  600. batch: that.formData.batch, //批号
  601. palletCode: that.formData.palletCode, // 托盘编码
  602. palletName: that.formData.palletName, // 托盘名称
  603. unitCode: that.formData.unitCode, //单位编码
  604. unitName: that.formData.unitName, // 单位名称
  605. stockQty: that.formData.stockQty, // 标签数量
  606. batch1: that.formData.batch1, //批号1
  607. batch2: that.formData.batch2, //批号2
  608. packageCode: that.formData.packageCode, // 包装编码
  609. };
  610. wmsStockChecksArr.push(tmpWms);
  611. let params = {
  612. guid: that.getHashId,
  613. appGroupId: that.formData.appGroupId,
  614. status: "1",
  615. stockType: that.formData.billTypeCode, // 单据类型
  616. taskCheckId: that.formData.taskCheckId, // 任务编号
  617. deptCode: that.formData.deptCode, //部门
  618. deptName: that.formData.deptName, //部门名称
  619. employeeCode: that.formData.employeeCode, // 职员
  620. employeeName: that.formData.employeeName, // 职员名称
  621. wmsStockChecksList: wmsStockChecksArr
  622. }
  623. addstockCheck(params).then(res => {
  624. if (res.code === 200) {
  625. that.mxNum++;
  626. // 保存单号
  627. if (res.msg !== "") {
  628. let storageData = uni.getStorageSync('stock_key');
  629. let stockIdList = storageData && storageData.stockIdList ? storageData.stockIdList : [];
  630. stockIdList.push(res.msg);
  631. let data = {
  632. "stockId": res.msg,
  633. "stockIdList": stockIdList
  634. }
  635. uni.setStorageSync('stock_key', data);
  636. }
  637. // 清空子表信息
  638. that.EmptyEntry();
  639. if (that.isShowSaveButton) {
  640. uni.showToast({
  641. title: '保存成功',
  642. icon: 'none',
  643. duration:2000
  644. })
  645. }
  646. }
  647. }).catch((err) => {
  648. uni.vibrateLong({});
  649. });
  650. }).catch((err) => {
  651. uni.vibrateLong({});
  652. });
  653. },
  654. // 任务扫码请求
  655. getScanRwList(barCode) {
  656. let that = this;
  657. let params = {
  658. keyWord: that.keyWord,
  659. params: {
  660. "barCode": barCode,
  661. "limit": 1
  662. },
  663. }
  664. listRwbm(params).then(res => {
  665. if (res.code === 200) {
  666. let data = res.rows ? res.rows[0] : {};
  667. if (data && Object.keys(data).length !== 0) {
  668. // 2.带出任务编号、职员名称、职员编码、部门名称、部门编码
  669. // ​ 3.放大镜选择时,关键字传参 queryParams.keyword = 关键字(无值时传空),过滤数据
  670. // ​ 4.扫码时传参,queryParams.barCode = 条码(为空时扫码失败)
  671. // 赋值任务编号
  672. this.formData.taskCode = data.taskCode;
  673. this.formData.taskCheckId = data.id;
  674. // 赋值部门
  675. this.formData.deptCode = data.deptCode;
  676. this.formData.deptName = data.deptName;
  677. // 赋值职员
  678. this.formData.employeeCode = data.employeeCode;
  679. this.formData.employeeName = data.employeeName;
  680. // 赋值仓库
  681. this.formData.warehouseCode = data.warehouseCode;
  682. this.formData.warehouseName = data.warehouseName;
  683. // 赋值货位
  684. this.formData.locationCode = data.locationCode;
  685. this.formData.locationName = data.locationName;
  686. // 赋值托盘
  687. this.formData.palletCode = data.palletCode;
  688. this.formData.palletName = data.palletName;
  689. // 赋值包装
  690. this.formData.packageCode = data.packageCode;
  691. this.formData.packageName = data.packageName;
  692. } else {
  693. uni.showToast({
  694. title: "无数据",
  695. icon: "none"
  696. })
  697. that.formData.taskCode = "";
  698. that.formData.taskCheckId = "";
  699. that.formData.deptCode = "";
  700. that.formData.deptName = "";
  701. that.formData.employeeCode = "";
  702. that.formData.employeeName = "";
  703. }
  704. } else {
  705. uni.showToast({
  706. title: "无数据",
  707. icon: 'none',
  708. duration: 3000,
  709. })
  710. }
  711. });
  712. },
  713. //仓库扫码请求
  714. getScanCkList(barCode) {
  715. let that = this;
  716. let params = {
  717. status: "0", // (固定)
  718. params: {
  719. "barCode": barCode,
  720. "limit": 1
  721. },
  722. }
  723. // 仓库网络请求
  724. listWarehouse(params).then(res => {
  725. if (res.code === 200) {
  726. let data = res.rows ? res.rows[0] : {};
  727. if (data && Object.keys(data).length !== 0) {
  728. // 赋值仓库、货位
  729. that.formData.warehouseCode = data.warehouseCode;
  730. that.formData.warehouseName = data.warehouseName;
  731. that.formData.locationCode = "";
  732. that.formData.locationName = "";
  733. // 清空包装托盘
  734. that.formData.palletCode = '';
  735. that.formData.palletName = '';
  736. that.formData.packageCode = '';
  737. that.formData.packageName = '';
  738. // 是否显示货位
  739. let obj = {
  740. "field": "locationCode",
  741. "fieldName": "货位",
  742. "required": 1,
  743. "requiredCondition": null,
  744. "hidden": null,
  745. "hiddenCondition": null
  746. }
  747. obj.required = data.isLocation == "1" ? null : 1;
  748. obj.hidden = data.isLocation == "1" ? 1 : null;
  749. // 清空信息
  750. that.EmptyEntry();
  751. } else if (this.barCode) {
  752. uni.showToast({
  753. title: "无数据",
  754. icon: "none"
  755. })
  756. }
  757. }
  758. });
  759. },
  760. //货位扫码请求
  761. getScanHwList(barCode) {
  762. let that = this;
  763. let params = {
  764. status: "0", // (固定)
  765. params: {
  766. "barCode": barCode,
  767. "limit": 1
  768. },
  769. }
  770. // 货位网络请求
  771. listLocation(params).then(res => {
  772. if (res.code === 200) {
  773. let data = res.rows ? res.rows[0] : {};
  774. if (data && Object.keys(data).length !== 0) {
  775. if (data.warehouseCode === that.formData.warehouseCode || '' == that.formData.warehouseCode || undefined == that.formData.warehouseCode || null == that.formData.warehouseCode) { // 货位能对上仓库
  776. // 赋值货位、仓库
  777. that.formData.locationCode = data.locationCode;
  778. that.formData.locationName = data.locationName;
  779. that.formData.warehouseCode = data.warehouseCode;
  780. that.formData.warehouseName = data.warehouseName;
  781. // 清空包装托盘
  782. that.formData.palletCode = '';
  783. that.formData.palletName = '';
  784. that.formData.packageCode = '';
  785. that.formData.packageName = '';
  786. // 显示货位
  787. let obj = {
  788. "field": "locationCode",
  789. "fieldName": "货位",
  790. "required": 1,
  791. "requiredCondition": null,
  792. "hidden": null,
  793. "hiddenCondition": null
  794. }
  795. obj.required = 1;
  796. // 清空信息
  797. that.EmptyEntry();
  798. } else { // 货位对不上仓库
  799. uni.showToast({
  800. title: "货位不属于当前仓库",
  801. icon: "none",
  802. duration: 3000
  803. })
  804. }
  805. } else {
  806. uni.showToast({
  807. title: "无数据",
  808. icon: "none"
  809. })
  810. }
  811. }
  812. });
  813. },
  814. // 标签扫码请求
  815. getScanBqList(barCode) {
  816. let that = this;
  817. let params = {
  818. params: {
  819. "barCode": barCode,
  820. "limit": 1,
  821. "warehouseCode": that.formData.warehouseCode,
  822. "locationCode": that.formData.locationCode,
  823. "palletCode": that.formData.palletCode,
  824. "packageCode": that.formData.packageCode,
  825. },
  826. }
  827. listLabelQueryParams(params).then(res => {
  828. if (res.code === 200) {
  829. let data = res.rows ? res.rows[0] : {};
  830. if (data && Object.keys(data).length !== 0) {
  831. //返回数量
  832. that.formData.stockQty = (data.labelQty || 0); // 数量
  833. // 赋值标签
  834. that.formData.labelCode = data.labelCode;
  835. // 赋值物料编码,物料名称 , 规格
  836. that.formData.materialName = data.materialName;
  837. that.formData.materialCode = data.materialCode;
  838. that.formData.materialSpecification = data.materialSpecification; //规格
  839. // 赋值批号
  840. that.formData.batch = data.batch;
  841. that.formData.batch1 = data.batch1;
  842. that.formData.batch2 = data.batch2;
  843. // 赋值单位
  844. that.formData.unitCode = data.unitCode;
  845. that.formData.unitName = data.unitName;
  846. //如果不显示保存按钮则自动保存
  847. if (!that.isShowSaveButton) {
  848. setTimeout(() => {
  849. that.handleSave();
  850. }, 10)
  851. }
  852. } else {
  853. uni.vibrateLong({});
  854. uni.showToast({
  855. title: "标签无效或已扫描",
  856. icon: "none"
  857. })
  858. }
  859. }
  860. }).catch((err) => {
  861. uni.vibrateLong({});
  862. });
  863. },
  864. //托盘扫码请求
  865. getScanTpList(barCode) {
  866. let that = this;
  867. let params = {
  868. status: "0", // (固定)
  869. locationCode: this.formData.locationCode,
  870. warehouseCode: this.formData.warehouseCode,
  871. params: {
  872. "barCode": barCode,
  873. "limit": 1
  874. },
  875. }
  876. // 托盘网络请求
  877. listPallet(params).then(res => {
  878. if (res.code === 200) {
  879. let data = res.rows ? res.rows[0] : {};
  880. if (data && Object.keys(data).length !== 0) {
  881. that.formData.palletCode = data.palletCode;
  882. that.formData.palletName = data.palletName;
  883. if(data.warehouseCode){
  884. that.formData.warehouseCode = data.warehouseCode;
  885. that.formData.warehouseName = data.warehouseName;
  886. }
  887. if(data.locationCode){
  888. that.formData.locationCode = data.locationCode;
  889. that.formData.locationName = data.locationName;
  890. }
  891. that.formData.packageCode = '';
  892. that.formData.packageName = '';
  893. } else {
  894. uni.showToast({
  895. title: "无数据",
  896. icon: "none"
  897. })
  898. }
  899. }
  900. });
  901. },
  902. //包装扫码请求
  903. getScanBzList(barCode) {
  904. let that = this;
  905. let params = {
  906. status: "0", // (固定)
  907. locationCode: this.formData.locationCode,
  908. warehouseCode: this.formData.warehouseCode,
  909. palletCode: this.formData.palletCode,
  910. params: {
  911. "barCode": barCode,
  912. "limit": 1
  913. },
  914. }
  915. // 包装网络请求
  916. listPackage(params).then(res => {
  917. if (res.code === 200) {
  918. let data = res.rows ? res.rows[0] : {};
  919. if (data && Object.keys(data).length !== 0) {
  920. that.formData.packageCode = data.packageCode;
  921. that.formData.packageName = data.packageName;
  922. if(data.warehouseCode){
  923. that.formData.warehouseCode = data.warehouseCode;
  924. that.formData.warehouseName = data.warehouseName;
  925. }
  926. if(data.locationCode){
  927. that.formData.locationCode = data.locationCode;
  928. that.formData.locationName = data.locationName;
  929. }
  930. if(data.palletCode){
  931. that.formData.palletCode = data.palletCode;
  932. that.formData.palletName = data.palletName;
  933. }
  934. } else {
  935. uni.showToast({
  936. title: "无数据",
  937. icon: "none"
  938. })
  939. }
  940. }
  941. });
  942. },
  943. handleAuto() {
  944. if (this.autoButtonTitle === "自动") { //手动
  945. this.autoButtonTitle = "手动";
  946. this.isShowSaveButton = true;
  947. } else { //自动
  948. this.autoButtonTitle = "自动";
  949. this.isShowSaveButton = false;
  950. }
  951. },
  952. handleBack() {
  953. uni.showModal({
  954. title: '提示',
  955. content: '确认返回?',
  956. success: function(res) {
  957. if (res.confirm) {
  958. //用户点击确定;
  959. uni.navigateBack();
  960. } else if (res.cancel) {
  961. //用户点击取消;
  962. }
  963. }
  964. });
  965. },
  966. getSendNum(num) {
  967. this.mxNum = num;
  968. if(num == 0){
  969. this.formData.appGroupId=''
  970. }
  971. },
  972. SendNumEmpty() {
  973. let that = this;
  974. if (this.mxNum > 0) {
  975. uni.showModal({
  976. title: '新单',
  977. content: '是否要明细归零,录入新单?',
  978. success: function(res) {
  979. if (res.confirm) {
  980. that.mxNum = 0;
  981. let data = {
  982. "stockId": "",
  983. "stockIdList": []
  984. }
  985. uni.setStorageSync('stock_key', data);
  986. //清空唯一值
  987. that.formData.appGroupId = '';
  988. }
  989. }
  990. });
  991. }
  992. },
  993. //清空任务、部门、职员、供应商
  994. EmptyTest() {},
  995. //清空子表信息
  996. EmptyEntry() {
  997. this.formData.labelCode = "";
  998. this.formData.materialCode = "";
  999. this.formData.materialName = "";
  1000. this.formData.batch = "";
  1001. this.formData.unitCode = "";
  1002. this.formData.unitName = "";
  1003. this.formData.stockQty = "";
  1004. this.formData.batch1 = "";
  1005. this.formData.batch2 = "";
  1006. this.formData.materialSpecification = "";
  1007. // this.formData.palletCode = "";
  1008. // this.formData.palletName = "";
  1009. // this.formData.packageCode = "";
  1010. // this.formData.packageName = "";
  1011. },
  1012. },
  1013. computed: {
  1014. getHashId(){
  1015. //生成哈希值
  1016. const crypto = require('crypto');
  1017. function hashString(str) {
  1018. const hash = crypto.createHash('sha256');
  1019. hash.update(str);
  1020. return hash.digest('hex');
  1021. }
  1022. //null和undefined返回空
  1023. function IFNULL(str){
  1024. return (str==null || str==undefined) ? "" : str + "";
  1025. }
  1026. //使用头信息和nanoid来生成唯一值
  1027. let groupJson = {
  1028. appGroupId : this.formData.appGroupId,
  1029. billTypeCode : IFNULL(this.formData.billTypeCode),
  1030. taskCheckId : IFNULL(this.formData.taskCheckId),
  1031. deptCode : IFNULL(this.formData.deptCode),
  1032. employeeCode : IFNULL(this.formData.employeeCode),
  1033. extendCode01 : IFNULL(this.formData.extendCode01),
  1034. extendCode02 : IFNULL(this.formData.extendCode02),
  1035. extendCode03 : IFNULL(this.formData.extendCode03),
  1036. extendCode04 : IFNULL(this.formData.extendCode04),
  1037. extendCode05 : IFNULL(this.formData.extendCode05),
  1038. }
  1039. let groupStr = JSON.stringify(groupJson)
  1040. const hash = hashString(groupStr)
  1041. return hash
  1042. },
  1043. },
  1044. }
  1045. </script>
  1046. <style>
  1047. @import "@/static/scss/stock.css";
  1048. </style>