index.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450
  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" :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="cpck-content">
  17. <scroll-view :scroll-top="scrollTop" :show-scrollbar="true" scroll-y="true" class="scroll-Y">
  18. <view class="form-container">
  19. <uni-forms :rules="rules" :value="formData" ref="form" validate-trigger="submit"
  20. err-show-type="toast">
  21. <uni-forms-item name="billTypeCode" label="业务类型" :label-width="lableWidth" labelAlign="right">
  22. <uni-data-select v-model="formData.billTypeCode" :localdata="billTypeOption"
  23. @change="ywlxChange"></uni-data-select>
  24. </uni-forms-item>
  25. <uni-forms-item name="deptCode" :required="rulesStar('deptCode')" v-if="fieldHidden('deptCode')"
  26. label="部门" :label-width="lableWidth" labelAlign="right">
  27. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  28. v-show="false" v-model="formData.deptCode"></uni-easyinput>
  29. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  30. v-model="formData.deptName" suffixIcon="search"
  31. @iconClick="searchIconClick('dept')"></uni-easyinput>
  32. </uni-forms-item>
  33. <uni-forms-item name="employeeCode" :required="rulesStar('employeeCode')"
  34. v-if="fieldHidden('employeeCode')" label="职员" :label-width="lableWidth" labelAlign="right">
  35. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  36. v-model="formData.employeeCode" v-show="false"></uni-easyinput>
  37. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  38. v-model="formData.employeeName" suffixIcon="search"
  39. @iconClick="searchIconClick('empl')"></uni-easyinput>
  40. </uni-forms-item>
  41. <uni-forms-item name="supplierCode" :required="rulesStar('supplierCode')"
  42. v-if="fieldHidden('supplierCode')" label="供应商" :label-width="lableWidth" labelAlign="right">
  43. <uni-easyinput type="text" :inputBorder="true" v-model="formData.supplierCode"
  44. v-show="false" :disabled="true"></uni-easyinput>
  45. <uni-easyinput type="text" :inputBorder="true" v-model="formData.supplierName"
  46. :disabled="true" :styles="styleInput"
  47. :suffixIcon="formData.backTaskInsCode!=''? '' : 'search'"
  48. @iconClick="searchIconClick('supp')"></uni-easyinput>
  49. </uni-forms-item>
  50. <uni-forms-item name="extendCode01" :required="rulesStar('extendCode01')"
  51. v-if="fieldHidden('extendCode01')" label="收发类别" :label-width="lableWidth"
  52. labelAlign="right">
  53. <uni-easyinput type="text" :disabled="true" :inputBorder="true" v-show="false"
  54. v-model="formData.extendCode01"></uni-easyinput>
  55. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  56. v-model="formData.extendName01" suffixIcon="search"
  57. @iconClick="searchIconClick('ext01')"></uni-easyinput>
  58. </uni-forms-item>
  59. <uni-forms-item name="warehouseCode" :required="rulesStar('warehouseCode')"
  60. v-if="fieldHidden('warehouseCode')" label="仓库" :label-width="lableWidth" labelAlign="right">
  61. <uni-easyinput type="text" v-model="formData.warehouseCode" v-show="false"></uni-easyinput>
  62. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  63. v-model="formData.warehouseName" suffixIcon="compose"
  64. @iconClick="setScan('WH')"></uni-easyinput>
  65. </uni-forms-item>
  66. <uni-forms-item name="locationCode" :required="rulesStar('locationCode')"
  67. v-if="fieldHidden('locationCode')" label="货位" :label-width="lableWidth" labelAlign="right">
  68. <uni-easyinput type="text" v-model="formData.locationCode" v-show="false"></uni-easyinput>
  69. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  70. v-model="formData.locationName" suffixIcon="compose"
  71. @iconClick="setScan('PT')"></uni-easyinput>
  72. </uni-forms-item>
  73. <uni-forms-item name="backTaskInsCode" :required="rulesStar('backTaskInsCode')"
  74. v-if="fieldHidden('backTaskInsCode')" label="任务编码" :label-width="lableWidth"
  75. labelAlign="right">
  76. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  77. v-model="formData.backTaskInsCode" suffixIcon="search"
  78. @iconClick="searchIconClick('task')"></uni-easyinput>
  79. </uni-forms-item>
  80. <template v-if="isLabelScan">
  81. <uni-forms-item name="labelCode" :required="rulesStar('labelCode')"
  82. v-if="fieldHidden('labelCode')" label="标签编码" :label-width="lableWidth"
  83. labelAlign="right">
  84. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  85. v-model="formData.labelCode" suffixIcon="compose"
  86. @iconClick="setScan('L')"></uni-easyinput>
  87. </uni-forms-item>
  88. <uni-forms-item name="materialCode" :required="rulesStar('materialCode')"
  89. v-if="fieldHidden('materialCode')" label="物料" :label-width="lableWidth"
  90. labelAlign="right">
  91. <uni-easyinput type="text" v-model="formData.materialCode"
  92. v-show="false"></uni-easyinput>
  93. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  94. v-model="formData.materialName"></uni-easyinput>
  95. </uni-forms-item>
  96. <uni-forms-item name="batch" :required="rulesStar('batch')" v-if="fieldHidden('batch')"
  97. label="批号" :label-width="lableWidth" labelAlign="right">
  98. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  99. v-model="formData.batch"></uni-easyinput>
  100. </uni-forms-item>
  101. <uni-forms-item name="unitCode" :required="rulesStar('unitCode')"
  102. v-if="fieldHidden('unitCode')" label="单位" :label-width="lableWidth" labelAlign="right">
  103. <uni-easyinput type="text" v-model="formData.unitCode" v-show="false"></uni-easyinput>
  104. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  105. v-model="formData.unitName"></uni-easyinput>
  106. </uni-forms-item>
  107. <uni-forms-item name="stockQty" :required="rulesStar('stockQty')"
  108. v-if="fieldHidden('stockQty')" label="标签数量" :label-width="lableWidth"
  109. labelAlign="right">
  110. <uni-easyinput type="number" :inputBorder="true" v-model="formData.stockQty"
  111. @input="bqslInputHandle"></uni-easyinput>
  112. </uni-forms-item>
  113. <uni-forms-item name="rwQty" :required="rulesStar('rwQty')" v-if="fieldHidden('rwQty')"
  114. label="任务数量" :label-width="lableWidth" labelAlign="right">
  115. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  116. v-model="formData.rwQty"></uni-easyinput>
  117. </uni-forms-item>
  118. </template>
  119. </uni-forms>
  120. <uni-card v-for="(item, index) in labelList" :key="index">
  121. <text class="uni-body" style="font-size: 16px;">
  122. <p><span class="titleV">标签:</span><span class="detailV">{{item.labelCode}}</span></p>
  123. <p><span class="titleV">物料:</span><span class="detailV">{{item.materialCode}}</span></p>
  124. <p><span class="titleV">单位:</span><span class="detailV">{{item.unitCode}}</span></p>
  125. <p><span class="titleV">批次:</span><span class="detailV">{{item.batch}}</span></p>
  126. <p v-if="item.batch1"><span class="titleV">批次1:</span><span
  127. class="detailV">{{item.batch1}}</span></p>
  128. <p v-if="item.batch2"><span class="titleV">批次2:</span><span
  129. class="detailV">{{item.batch2}}</span></p>
  130. </text>
  131. <view slot="actions" class="card-actions">
  132. <view class="card-actions-item" @click="delLabelList(index)">
  133. <uni-icons type="closeempty" size="18" color="#999"></uni-icons>
  134. </view>
  135. <view class="card-actions-item">
  136. <uni-number-box :min="0" :max="item.maxQty" :value="item.stockQty"
  137. @change="labelListQtyChange(item, $event)" />
  138. </view>
  139. </view>
  140. </uni-card>
  141. </view>
  142. </scroll-view>
  143. </view>
  144. <view class="page-bottom">
  145. <view class="p-b-btn">
  146. <uni-badge class="uni-badge-left-margin" :text="mxNum" :max-num="999" absolute="rightTop"
  147. :offset="[-3, -3]" size="small">
  148. <view class="box"><text class="box-text" @click="handleMx">明细</text></view>
  149. </uni-badge>
  150. </view>
  151. <view class="p-b-btn" @click="$noMultipleClicks(handleSave)">
  152. <text class="box-text" v-show="isShowSaveButton">暂存</text>
  153. </view>
  154. <view class="p-b-btn" @click="handleAuto">
  155. <text class="box-text">{{autoButtonTitle}}</text>
  156. </view>
  157. <view class="p-b-btn" @click="handleBack">
  158. <text class="box-text">返回</text>
  159. </view>
  160. </view>
  161. <scan-code />
  162. <!-- 明细弹窗 -->
  163. <MxPopup ref="mxPopup" @sendNum="getSendNum" />
  164. <!-- 任务清单弹窗 -->
  165. <RwbmPopup ref="rwbmPopup" :title="rwbmTitle" :idxFlag="rwbmFlag" :formData="formData"
  166. @sendData="getSendData" />
  167. <!-- 部门弹窗 -->
  168. <BmPopup ref="bmPopup" :title="bmTitle" :idxFlag="bmFlag" :formData="formData" @sendData="getSendData" />
  169. <!-- 职员 -->
  170. <ZyPopup ref="zyPopup" :title="zyTitle" :idxFlag="zyFlag" :formData="formData" @sendData="getSendData" />
  171. <!-- 收发类别 -->
  172. <SflbPopup ref="sflbPopup" :title="sflbTitle" :idxFlag="sflbFlag" :formData="formData"
  173. @sendData="getSendData" />
  174. <!-- 供应商 -->
  175. <GysPopup ref="gysPopup" :title="gysTitle" :idxFlag="gysFlag" :formData="formData" @sendData="getSendData" />
  176. <!-- 托盘 -->
  177. <TpPopup ref="tpPopup" :title="tpTitle" :idxFlag="tpFlag" :formData="formData" @sendData="getSendData" />
  178. </view>
  179. </template>
  180. <script>
  181. import scanCode from "@/components/scan/scan.vue";
  182. import { getDicts } from "@/api/system/dict/data"; // 字典
  183. import RwbmPopup from './popup/commonpopup.vue' // 任务编码
  184. import BmPopup from './popup/commonpopup.vue' // 部门
  185. import ZyPopup from './popup/commonpopup.vue' // 职员
  186. import SflbPopup from './popup/commonpopup.vue' // 收发类别
  187. import GysPopup from './popup/commonpopup.vue' // 供应商
  188. import TpPopup from './popup/commonpopup.vue' // 托盘
  189. import MxPopup from './popup/mxPopup.vue'
  190. import {
  191. addBackStockIn,
  192. listBackStockIn,
  193. listWarehouse,
  194. listLocation,
  195. listBackStockInCurrent,
  196. listBackTaskInBackStockIn,
  197. listExtend,
  198. getListFieldSetting,
  199. queryBillTypeCache
  200. } from '@/api/wms/backStockIn.js'
  201. import { listFieldDefault } from '@/api/wms/report.js'
  202. import storage from '@/utils/storage'
  203. import { nanoid } from 'nanoid'; //唯一值 nanoid
  204. export default {
  205. components: {
  206. scanCode,
  207. RwbmPopup,
  208. BmPopup,
  209. MxPopup,
  210. ZyPopup,
  211. SflbPopup,
  212. GysPopup,
  213. TpPopup
  214. },
  215. props: {
  216. },
  217. async onLoad(option) {
  218. //下面请求如果失败改为false
  219. let isRequest = true;
  220. //字段设置
  221. try {
  222. const res = await this.retryRequest(getListFieldSetting, {
  223. billCode: "backStockIn"
  224. });
  225. // 处理响应数据
  226. this.fieldSetting = res.rows;
  227. } catch (error) {
  228. isRequest = false;
  229. }
  230. //单据类型
  231. try {
  232. const res = await this.retryRequest(queryBillTypeCache, {
  233. billCode: "backStockIn"
  234. });
  235. // 处理响应数据
  236. let tmpData = res.rows;
  237. this.billTypeOption = tmpData.filter(item => item.isEnableApp == 0 && item.status == 0)
  238. .map(item => ({
  239. billTypeCode: item.billTypeCode,
  240. billTypeName: item.billTypeName,
  241. value: item.billTypeCode,
  242. text: item.billTypeName,
  243. taskValue: item.taskBillTypeCode ? "'" + item.taskBillTypeCode.replace(/,/g, "','") + "'" : '',
  244. isControlTask: item.backTaskBillTypeCode ? item.isControlTask : 0,
  245. }));
  246. //触发单据类型变更
  247. this.ywlxChange(option.ywlx);
  248. } catch (error) {
  249. isRequest = false;
  250. }
  251. if (isRequest == false) {
  252. uni.showModal({
  253. title: '获取单据信息失败',
  254. content: '请返回菜单重新进入',
  255. showCancel: false, //不显示取消按钮
  256. success: function(res) {
  257. if (res.confirm) {
  258. uni.navigateBack();
  259. }
  260. }
  261. })
  262. } else {
  263. this.isRequest = true
  264. }
  265. },
  266. onUnload() {
  267. uni.removeStorageSync('stock_key');
  268. },
  269. onBackPress(options) {
  270. if (options.from === 'navigateBack') {
  271. // 来自于导航条返回按钮或者系统返回按钮的事件
  272. return false;
  273. }
  274. // 双击返回的逻辑
  275. const now = Date.now();
  276. if (this.lastBackPress && now - this.lastBackPress < 1000) {
  277. // 如果两次点击的间隔小于1000毫秒,则可以认为是双击
  278. //这时退出
  279. return false;
  280. } else {
  281. this.lastBackPress = now;
  282. uni.showToast({
  283. title: '再按一次退出',
  284. icon: 'none'
  285. });
  286. setTimeout(() => {
  287. this.lastBackPress = null;
  288. }, 1000);
  289. return true;
  290. }
  291. },
  292. data() {
  293. return {
  294. isRequest: false, //onLoad请求成功时改为true,否则不允许保存
  295. isLabelScan: true, //true是扫标签;false是扫托或包装,多行保存
  296. labelList: [], //扫托或包装获得的标签list
  297. remarkFocus: false,
  298. mxNum: 0, //明细按钮数量
  299. isShowSaveButton: false, //是否显示保存按钮
  300. currentSelectBillTypeCode: '', // 当前单据类型
  301. autoButtonTitle: '自动',
  302. scrollTop: 0,
  303. old: {
  304. scrollTop: 0
  305. },
  306. billTypeOption: [], // 业务类型字典选择框数据
  307. barCode: '', //条码
  308. formData: {
  309. // 单据类型
  310. billTypeCode: "", // 单据类型
  311. billTypeName: "", // 单据类型的名称(显示使用)
  312. taskBillTypeCode: "", //单据类型对应的任务类型
  313. isControlTask: null, //任务用,是否可超量
  314. // 部门
  315. deptCode: "", //部门
  316. deptName: "", //部门名称
  317. // 职员
  318. employeeCode: "", // 职员
  319. employeeName: "", // 职员名称
  320. // 供应商
  321. supplierCode: "", //供应商
  322. supplierName: "", //供应商名称
  323. // 收发类别
  324. extendName01: "", // 收发类别
  325. extendCode01: "", // 收发类别编码
  326. // 仓库
  327. warehouseCode: "", // 仓库
  328. warehouseName: "", // 仓库名称
  329. //预留
  330. extendCode02: "",
  331. extendCode03: "",
  332. extendCode04: "",
  333. extendCode05: "",
  334. // 组id
  335. appGroupId: "",
  336. // ===== 以下 保存时转化为 wmsStockOutsList=====
  337. //任务子表id
  338. taskInsId: "",
  339. backTaskInsId: "",
  340. backTaskInsCode: "",
  341. // 货位
  342. locationCode: "", // 货位编码
  343. locationName: "", // 货位名称
  344. // 标签
  345. labelCode: "", // 标签编码
  346. // 物料
  347. materialCode: "", // 物料编码
  348. materialName: "", //物料名称
  349. // 批号
  350. batch: "", //批号
  351. // 托盘
  352. palletCode: "", // 托盘编码
  353. palletName: "", // 托盘名称
  354. //单位
  355. unitCode: "", //单位编码
  356. unitName: "", //单位名称
  357. stockQty: "", // 标签数量
  358. rwQty: "", // 任务数量
  359. labelType: "", //标签类型(1一次性 2重复性)
  360. batch1: "", //批号1
  361. batch2: "", //批号2
  362. materialSpecification: "", //物料规格
  363. isLocation:"",
  364. isPackage:"",
  365. isPallet:"",
  366. },
  367. show: false,
  368. lableWidth: '80px',
  369. styleInput: {
  370. color: '#333',
  371. backgroundColor: '#fff',
  372. disableColor: '#fff',
  373. borderColor: '#e5e5e5',
  374. },
  375. fieldSetting: [], //单据字段设置
  376. // 任务编码
  377. rwbmTitle: "任务",
  378. rwbmFlag: "rwbm",
  379. // 职员
  380. zyTitle: "职员",
  381. zyFlag: "zy",
  382. // 部门
  383. bmTitle: "部门",
  384. bmFlag: "bm",
  385. // 收发类别
  386. sflbTitle: "收发类别",
  387. sflbFlag: "sflb",
  388. // 供应商
  389. gysTitle: "供应商",
  390. gysFlag: "gys",
  391. // 托盘
  392. tpTitle: "托盘",
  393. tpFlag: "tp",
  394. //配合$noMultipleClicks防止重复点击
  395. noClick:true,
  396. }
  397. },
  398. methods: {
  399. upper: function(e) {
  400. },
  401. lower: function(e) {
  402. },
  403. scroll: function(e) {
  404. this.old.scrollTop = e.detail.scrollTop
  405. },
  406. async retryRequest(requestFunction, requestParams, maxRetries = 1) {
  407. let retriesLeft = maxRetries;
  408. while (retriesLeft > 0) {
  409. try {
  410. // 调用请求函数并传入参数
  411. const response = await requestFunction(requestParams);
  412. if (response && response.code === 200) {
  413. return response; // 请求成功,返回响应
  414. } else {
  415. // 请求失败,但还有重试机会
  416. //console.warn(`请求失败,正在尝试第 ${maxRetries - retriesLeft + 1} 次重试...`);
  417. retriesLeft--;
  418. }
  419. } catch (error) {
  420. // 请求发生异常,但还有重试机会
  421. //console.error('请求发生异常,正在尝试重试...', error);
  422. retriesLeft--;
  423. }
  424. }
  425. // 所有重试都失败了,抛出错误
  426. throw new Error('获取信息失败');
  427. },
  428. onShow() {
  429. let that = this;
  430. uni.$off("scancode"); // 每次进来先 移除全局自定义事件监听器
  431. uni.$on("scancode", (data) => {
  432. // 扫描PCS码
  433. if (data && data !== '') {
  434. that.barCode = data;
  435. this.getDataByRemark(that.barCode);
  436. } else {
  437. uni.showToast({
  438. title: '扫码失败!',
  439. icon: 'none',
  440. duration: 2000
  441. });
  442. }
  443. });
  444. },
  445. // 条码右侧扫码按钮事件
  446. handleScanClick: function() {
  447. let that = this;
  448. uni.scanCode({
  449. success: function(res) {
  450. // 播放音效
  451. // this.playMusic();
  452. // {"scanType":"QR_CODE","path":"","charSet":"ISO8859_1","result":"PT|04-A-1-1","errMsg":"scanCode:ok"}
  453. if (res.errMsg == "scanCode:ok") {
  454. that.barCode = res.result;
  455. this.getDataByRemark(that.barCode);
  456. } else {
  457. uni.showToast({
  458. title: '扫码失败!',
  459. icon: 'none',
  460. duration: 2000
  461. });
  462. }
  463. },
  464. fail: (err) => {
  465. },
  466. complete: () => {
  467. }
  468. });
  469. },
  470. // 根据扫码数据查询其他formItem数据
  471. async getDataByRemark(remark) {
  472. let that = this;
  473. remark = remark.replace(/^\s+|\s+$/g, '');
  474. var splitPre = remark.split("|")[0];
  475. var splitLast = remark.slice(splitPre.length + 1);
  476. // 条码空 不执行
  477. if (splitLast == "") {
  478. return true;
  479. }
  480. // 扫码
  481. switch (splitPre) {
  482. case "PT": // 货位 PT|04-A-1-1
  483. this.getScanHwList(splitLast);
  484. break;
  485. case "WH": // 仓库 WH|01
  486. this.getScanCkList(splitLast);
  487. break;
  488. case "RW": // 任务扫码 RW|
  489. this.getScanRwList(splitLast);
  490. break;
  491. case "L": // 标签 L|L2311060002
  492. this.getScanBqList(splitLast);
  493. break;
  494. case "P": // 托盘 P|0002
  495. this.getScanTpList(splitLast);
  496. break;
  497. case "PA": // 包装 PA|0002
  498. this.getScanBzList(splitLast);
  499. break;
  500. default:
  501. uni.showToast({
  502. title: "条码不合法",
  503. icon: "none"
  504. })
  505. break;
  506. }
  507. },
  508. // 条码框 回车
  509. scanSearch(remark) {
  510. this.getDataByRemark(remark);
  511. },
  512. async ywlxChange(value) {
  513. let that = this;
  514. if (value === '') {
  515. this.formData.billTypeCode = "";
  516. this.formData.billTypeName = "";
  517. this.formData.taskBillTypeCode = "";
  518. this.formData.isControlTask = "";
  519. } else {
  520. let status = this.billTypeOption.find(item => item.value == value);
  521. if (status) {
  522. this.formData.billTypeCode = status.value;
  523. this.formData.billTypeName = status.text;
  524. this.formData.taskBillTypeCode = status.taskValue;
  525. this.formData.isControlTask = status.isControlTask
  526. }
  527. }
  528. // 监听业务类型变更,变更后。清空任务、供应商、收发类别、清空明细查询出的数据、清空入库单号和单号数组
  529. //清空任务
  530. this.formData.backTaskInsId = "";
  531. this.formData.taskInsId = "";
  532. this.formData.backTaskInsCode = "";
  533. //清空供应商
  534. this.formData.supplierCode = "";
  535. this.formData.supplierName = "";
  536. //清空收发类别
  537. this.formData.extendCode01 = "";
  538. this.formData.extendName01 = "";
  539. // 清空明细数据
  540. if (this.$refs.mxPopup) {
  541. this.$refs.mxPopup.listData = [];
  542. }
  543. // 清空入库单号和单号数组
  544. uni.removeStorageSync('stock_key');
  545. //更新唯一值
  546. this.formData.appGroupId = nanoid(19);
  547. if (value != '' && value != null) {
  548. //默认值
  549. const res = await this.retryRequest(listFieldDefault, {
  550. "billTypeCode": value,
  551. "billCode": 'backStockIn'
  552. });
  553. if (res.code === 200) {
  554. let fieldDefault = res.rows; //字段默认值
  555. let fieldSetting = this.fieldSetting.filter(item => item.defaults == '1'); //字段信息
  556. let form = this.formData; //新增的信息
  557. /*
  558. * 遍历字段信息,如果字段默认值和头信息中存在,则用字段中的keyCode、keyName和默认值中的settingCode、settingName赋值给from
  559. */
  560. for (let i = 0; i < fieldSetting.length; i++) {
  561. let fieldD = fieldDefault.filter(item => item.settingFlag == fieldSetting[i].field);
  562. //如果字段默认值和头信息中存在
  563. if (fieldD.length > 0 && fieldSetting[i].field in form) {
  564. //仓库触发一次扫码
  565. if(fieldD[0].settingFlag=="warehouseCode" && fieldD[0].settingCode){
  566. this.getScanCkList(fieldD[0].settingCode)
  567. continue
  568. }
  569. //赋值code(实际值)
  570. if (fieldSetting[i]["keyCode"]) {
  571. form[fieldSetting[i]["keyCode"]] = fieldD[0].settingCode;
  572. }
  573. //赋值name(显示值)
  574. if (fieldSetting[i]["keyName"]) {
  575. form[fieldSetting[i]["keyName"]] = fieldD[0].settingName;
  576. }
  577. }
  578. }
  579. }
  580. }
  581. },
  582. getSendData(res) { //基础资料
  583. let cFlag = res.currentFlag;
  584. switch (cFlag) {
  585. case "rwbm": // 任务编码
  586. this.formData.backTaskInsId = res.selectData.wmsTaskIns.id;
  587. this.formData.taskInsId = res.selectData.wmsTaskIns.taskInsId;
  588. this.formData.backTaskInsCode = res.selectData.wmsTaskIns.subTaskCode;
  589. // 赋值部门
  590. this.formData.deptCode = res.selectData.deptCode;
  591. this.formData.deptName = res.selectData.deptName;
  592. // 赋值职员
  593. this.formData.employeeCode = res.selectData.employeeCode;
  594. this.formData.employeeName = res.selectData.employeeName;
  595. // 赋值供应商
  596. this.formData.supplierCode = res.selectData.supplierCode;
  597. // 赋值物料、任务数量
  598. this.formData.materialCode = res.selectData.wmsTaskIns.materialCode;
  599. this.formData.materialName = res.selectData.wmsTaskIns.materialCode;
  600. this.formData.rwQty = (res.selectData.wmsTaskIns.taskQty || 0) - (res.selectData.wmsTaskIns
  601. .stockQty || 0);
  602. break;
  603. case "bm": // 部门
  604. // this.formData.deptCode = res.selectData.deptCode;
  605. this.formData.deptCode = res.selectData.deptCode;
  606. this.formData.deptName = res.selectData.deptName;
  607. // 职员清空
  608. this.formData.employeeCode = "";
  609. this.formData.employeeName = "";
  610. break;
  611. case "zy": // 职员
  612. this.formData.employeeCode = res.selectData.employeeCode;
  613. this.formData.employeeName = res.selectData.employeeName;
  614. break;
  615. case "sflb": // 收发类别
  616. this.formData.extendName01 = res.selectData.extendName;
  617. this.formData.extendCode01 = res.selectData.extendCode;
  618. break;
  619. case "gys": // 供应商
  620. this.formData.supplierCode = res.selectData.supplierCode;
  621. this.formData.supplierName = res.selectData.supplierName;
  622. break;
  623. default:
  624. break;
  625. }
  626. },
  627. // easyinput后面放大镜点击
  628. searchIconClick(type) {
  629. switch (type) {
  630. case "task": // 任务编码
  631. this.$refs.rwbmPopup.showPopup();
  632. break;
  633. case "dept": // 部门
  634. this.$refs.bmPopup.showPopup();
  635. break;
  636. case "empl": // 职员
  637. this.$refs.zyPopup.showPopup();
  638. break;
  639. case "supp": // 供应商
  640. this.$refs.gysPopup.showPopup();
  641. break;
  642. case "ext01": // 收发类别
  643. this.$refs.sflbPopup.showPopup();
  644. break;
  645. case "pall": // 托盘
  646. this.$refs.tpPopup.showPopup();
  647. break;
  648. default:
  649. break;
  650. }
  651. },
  652. remarkGetFocus() {
  653. this.remarkFocus = false;
  654. this.$nextTick(() => {
  655. this.remarkFocus = true
  656. })
  657. },
  658. setScan(str) { //赋值条码框 光标聚焦
  659. this.barCode = str + "|";
  660. this.remarkGetFocus();
  661. },
  662. bqslInputHandle(value) {
  663. let rwsl = this.formData.rwQty; //任务数量
  664. if (rwsl != "") {
  665. if (value > parseFloat(rwsl)) {
  666. uni.showToast({
  667. title: "数量大于任务数量",
  668. icon: "none"
  669. })
  670. return;
  671. }
  672. }
  673. },
  674. // 下面工具栏 明细点击 事件
  675. handleMx() {
  676. this.$refs.mxPopup.showDrawer();
  677. },
  678. handleSave() {
  679. //获取信息失败时不可以保存
  680. if (this.isRequest == false) {
  681. uni.showToast({
  682. title: '获取单据信息失败,请返回菜单重新进入',
  683. icon: "none"
  684. })
  685. return true;
  686. }
  687. if (this.isShowSaveButton) {
  688. uni.showToast({
  689. title: '保存中,请稍等',
  690. icon: 'none',
  691. duration:2000
  692. })
  693. }
  694. //如果唯一值空,生成唯一值
  695. if(this.formData.appGroupId=='' || this.formData.appGroupId==null){
  696. this.formData.appGroupId = nanoid(19)
  697. }
  698. let that = this;
  699. that.$refs.form.validate().then(res => {
  700. let wmsStockInsArr = [];
  701. // true用普通保存;false用list保存多行
  702. if (that.isLabelScan == true) {
  703. let tmpWms = {
  704. backTaskInsId: that.formData.backTaskInsId, // 子表id
  705. taskInsId: that.formData.taskInsId,
  706. locationCode: that.formData.locationCode, // 货位编码
  707. labelCode: that.formData.labelCode, // 标签编码
  708. materialCode: that.formData.materialCode, // 物料编码
  709. batch: that.formData.batch, //批号
  710. unitCode: that.formData.unitCode, //单位编码
  711. stockQty: that.formData.stockQty, // 标签数量
  712. rwQty: that.formData.rwQty, // 任务数量
  713. // labelType: that.formData.labelType, //标签类型(1一次性 2重复性)
  714. batch1: that.formData.batch1, //批号1
  715. batch2: that.formData.batch2, //批号2
  716. palletCode: that.formData.palletCode, // 托盘编码
  717. packageCode: that.formData.packageCode, // 包装编码
  718. isPackage: that.formData.isPackage,
  719. isPallet: that.formData.isPallet,
  720. };
  721. wmsStockInsArr.push(tmpWms);
  722. } else if (that.isLabelScan == false && that.labelList.length > 0) {
  723. wmsStockInsArr = that.labelList.map(item => ({
  724. backTaskInsId: that.formData.backTaskInsId, // 子表id
  725. taskInsId: that.formData.taskInsId,
  726. locationCode: item.locationCode, // 货位编码
  727. labelCode: item.labelCode, // 标签编码
  728. materialCode: item.materialCode, // 物料编码
  729. unitCode: item.unitCode, // 单位编码
  730. batch: item.batch, //批号
  731. stockQty: item.stockQty, // 标签数量
  732. batch1: item.batch1, //批号1
  733. batch2: item.batch2, //批号2
  734. palletCode: item.palletCode, // 托盘编码
  735. packageCode: item.packageCode, // 包装编码
  736. isPackage: that.formData.isPackage,
  737. isPallet: that.formData.isPallet,
  738. }))
  739. } else {
  740. return true;
  741. }
  742. let params = {
  743. guid: that.getHashId,
  744. appGroupId: that.formData.appGroupId,
  745. status: "1",
  746. stockType: -1,
  747. billTypeCode: that.formData.billTypeCode, // 单据类型
  748. billTypeName: that.formData.billTypeName, // 单据类型的名称(显示使用)
  749. backTaskInsCode: that.formData.backTaskInsCode, // 任务编号
  750. deptCode: that.formData.deptCode, //部门
  751. deptName: that.formData.deptName, //部门名称
  752. employeeCode: that.formData.employeeCode, // 职员
  753. supplierCode: that.formData.supplierCode, //供应商
  754. extendName01: that.formData.extendName01, // 收发类别
  755. extendCode01: that.formData.extendCode01, // 收发类别编码
  756. warehouseCode: that.formData.warehouseCode, // 仓库
  757. wmsStockInsList: wmsStockInsArr,
  758. isLocation: that.formData.isLocation
  759. }
  760. addBackStockIn(params).then(res => {
  761. if (res.code === 200) {
  762. that.mxNum += that.isLabelScan ? 1 : that.labelList.length;
  763. // 保存单号
  764. if (res.msg !== "") {
  765. let storageData = uni.getStorageSync('stock_key');
  766. if (storageData) {
  767. let stockIdList = storageData.stockIdList;
  768. stockIdList.push(res.msg);
  769. let data = {
  770. "stockId": res.msg,
  771. "stockIdList": stockIdList
  772. }
  773. uni.setStorageSync('stock_key', data);
  774. } else {
  775. let tmpList = [];
  776. tmpList.push(res.msg);
  777. let data = {
  778. "stockId": res.msg,
  779. "stockIdList": tmpList
  780. }
  781. uni.setStorageSync('stock_key', data);
  782. }
  783. }
  784. // 扫码后任务数量 - 标签数量
  785. let rwQty = that.formData.rwQty;
  786. if (rwQty != 0 && rwQty != "" && !isNaN(parseFloat(rwQty)) && isFinite(
  787. rwQty)) {
  788. that.formData.rwQty = rwQty - that.formData.stockQty;
  789. }
  790. // 清空子表信息
  791. that.EmptyEntry();
  792. if (that.isShowSaveButton) {
  793. uni.showToast({
  794. title: '保存成功',
  795. icon: 'none',
  796. duration:2000
  797. })
  798. }
  799. } else {
  800. uni.vibrateLong({});
  801. uni.showToast({
  802. title: "保存失败!",
  803. icon: "none"
  804. })
  805. }
  806. }).catch((err) => {
  807. uni.vibrateLong({});
  808. });
  809. }).catch((err) => {
  810. uni.vibrateLong({});
  811. });
  812. },
  813. // 任务扫码请求
  814. getScanRwList(barCode) {
  815. let that = this;
  816. let params = {
  817. taskType: '-1', // (固定,-1是入库退)
  818. supplierCode: that.formData.supplierCode, //供应商 (为空时不传)
  819. billTypeCode: that.formData.taskBillTypeCode,
  820. params: {
  821. "barCode": barCode,
  822. "limit": 1,
  823. "isControlTask": that.formData.isControlTask,
  824. },
  825. }
  826. listBackTaskInBackStockIn(params).then(res => {
  827. if (res.code === 200) {
  828. let data = res.rows ? res.rows[0] : {};
  829. if (data && Object.keys(data).length !== 0) {
  830. // 赋值任务编号
  831. that.formData.backTaskInsId = data.wmsTaskIns.id;
  832. that.formData.taskInsId = data.wmsTaskIns.taskInsId;
  833. that.formData.backTaskInsCode = data.wmsTaskIns.subTaskCode;
  834. // 赋值部门
  835. that.formData.deptCode = data.deptCode;
  836. that.formData.deptName = data.deptName;
  837. // 赋值职员
  838. that.formData.employeeCode = data.employeeCode;
  839. that.formData.employeeName = data.employeeName;
  840. // 赋值供应商
  841. that.formData.supplierCode = data.supplierCode;
  842. that.formData.supplierName = data.supplierName;
  843. // 赋值物料、任务数量
  844. that.formData.materialCode = data.wmsTaskIns.materialCode;
  845. that.formData.rwQty = (data.wmsTaskIns.taskQty || 0) - (data.wmsTaskIns.stockQty || 0);
  846. } else {
  847. uni.showToast({
  848. title: "无数据",
  849. icon: 'none',
  850. })
  851. that.formData.backTaskInsId = "";
  852. that.formData.taskInsId = "";
  853. that.formData.backTaskInsCode = "";
  854. that.formData.deptCode = "";
  855. that.formData.deptName = "";
  856. that.formData.employeeCode = "";
  857. that.formData.employeeName = "";
  858. that.formData.supplierCode = "";
  859. that.formData.supplierName = "";
  860. that.formData.materialCode = "";
  861. that.formData.materialName = "";
  862. that.formData.materialSpecification = "";
  863. }
  864. }
  865. });
  866. },
  867. //仓库扫码请求
  868. getScanCkList(barCode) {
  869. let that = this;
  870. let params = {
  871. status: "0", // (固定)
  872. params: {
  873. "barCode": barCode,
  874. "limit": 1
  875. },
  876. }
  877. // 仓库网络请求
  878. listWarehouse(params).then(res => {
  879. if (res.code === 200) {
  880. let data = res.rows ? res.rows[0] : {};
  881. if (data && Object.keys(data).length !== 0) {
  882. // 带出仓库编码、仓库名称、是否包含货位(is_location),如果is_location=1,隐藏货位
  883. // 赋值仓库、货位
  884. that.formData.warehouseCode = data.warehouseCode;
  885. that.formData.warehouseName = data.warehouseName;
  886. that.formData.locationCode = "";
  887. that.formData.locationName = "";
  888. // 是否显示货位
  889. let obj = {
  890. "field": "locationCode",
  891. "fieldName": "货位",
  892. "required": null,
  893. "requiredCondition": null,
  894. "hidden": null,
  895. "hiddenCondition": null
  896. }
  897. obj.required = data.isLocation == "1" ? null : 1;
  898. obj.hidden = data.isLocation == "1" ? 1 : null;
  899. that.formData.isLocation = data.isLocation;
  900. that.setFieldSetting(obj);
  901. // 清空信息
  902. that.EmptyEntry();
  903. this.formData.rwQty = "";
  904. } else if (this.barCode) {
  905. uni.showToast({
  906. title: "无数据",
  907. icon: 'none',
  908. })
  909. }
  910. }
  911. });
  912. },
  913. //收发类别扫码请求(但不是给扫码用的,在加载时调用)
  914. getScanSflbList(barCode) {
  915. let that = this;
  916. let params = {
  917. extendClassCode: "01.01",
  918. params: {
  919. "keyWord": barCode,
  920. "limit": 1
  921. },
  922. }
  923. // 收发类别网络请求
  924. listExtend(params).then(res => {
  925. if (res.code === 200) {
  926. let data = res.rows ? res.rows[0] : {};
  927. if (data && Object.keys(data).length !== 0) {
  928. // 收发类别
  929. that.formData.extendCode01 = data.extendCode;
  930. that.formData.extendName01 = data.extendName;
  931. } else if (this.barCode) {
  932. uni.showToast({
  933. title: "无数据",
  934. icon: "none"
  935. })
  936. }
  937. }
  938. });
  939. },
  940. //货位扫码请求
  941. getScanHwList(barCode) {
  942. let that = this;
  943. let params = {
  944. status: "0", // (固定)
  945. params: {
  946. "barCode": barCode,
  947. "limit": 1
  948. },
  949. }
  950. // 货位网络请求
  951. listLocation(params).then(res => {
  952. if (res.code === 200) {
  953. let data = res.rows ? res.rows[0] : {};
  954. if (data && Object.keys(data).length !== 0) {
  955. if (data.warehouseCode === that.formData.warehouseCode || '' == that.formData
  956. .warehouseCode) { // 货位能对上仓库
  957. // 赋值货位、仓库
  958. that.formData.locationCode = data.locationCode;
  959. that.formData.locationName = data.locationName;
  960. that.formData.warehouseCode = data.warehouseCode;
  961. that.formData.warehouseName = data.warehouseName;
  962. // 显示货位
  963. let obj = {
  964. "field": "locationCode",
  965. "fieldName": "货位",
  966. "required": null,
  967. "requiredCondition": null,
  968. "hidden": null,
  969. "hiddenCondition": null
  970. }
  971. obj.required = 1;
  972. that.setFieldSetting(obj);
  973. that.formData.isLocation = 0
  974. } else { // 货位对不上仓库
  975. uni.showToast({
  976. title: "货位不属于当前仓库",
  977. icon: "none"
  978. })
  979. }
  980. } else {
  981. uni.showToast({
  982. title: "无数据",
  983. icon: 'none',
  984. })
  985. }
  986. }
  987. });
  988. },
  989. // 标签扫码请求
  990. getScanBqList(barCode) {
  991. let that = this;
  992. if (!that.formData.warehouseCode) {
  993. uni.showToast({
  994. title: "请先录入仓库",
  995. icon: "none"
  996. })
  997. return false;
  998. }
  999. let params = {
  1000. // status: "0", //固定
  1001. params: {
  1002. "barCode": barCode,
  1003. "limit": 1
  1004. },
  1005. taskInsId: that.formData.taskInsId, //任务编号
  1006. warehouseCode: that.formData.warehouseCode,
  1007. }
  1008. //有任务时传物料编码
  1009. if (that.formData.backTaskInsCode != null && that.formData.backTaskInsCode != '' && that.formData
  1010. .backTaskInsCode != undefined) {
  1011. params.materialCode = that.formData.materialCode;
  1012. }
  1013. // 标签网络请求
  1014. listBackStockInCurrent(params).then(res => {
  1015. if (res.code === 200) {
  1016. that.isLabelScan = true;
  1017. that.labelList = [];
  1018. let data = res.rows ? res.rows[0] : {};
  1019. if (data && Object.keys(data).length !== 0) {
  1020. // 如果 labelType=2,隐藏任务数量
  1021. let obj = {
  1022. "field": "rwQty",
  1023. "fieldName": "任务数量",
  1024. "required": null,
  1025. "requiredCondition": null,
  1026. "hidden": null,
  1027. "hiddenCondition": null
  1028. }
  1029. obj.hidden = data.labelType == 2 ? 1 : null;
  1030. that.setFieldSetting(obj)
  1031. // 赋值标签数量
  1032. that.formData.stockQty = data.stockQty;
  1033. if (that.formData.backTaskInsCode == '' || that.formData.backTaskInsCode == null) {
  1034. that.formData.rwQty = data.stockQty;
  1035. }
  1036. // 赋值标签
  1037. that.formData.labelCode = data.labelCode;
  1038. //赋值货位
  1039. that.formData.locationCode = data.locationCode,
  1040. that.formData.locationName = data.locationName,
  1041. that.formData.labelType = data.labelType; // 标签类型(1一次性 2重复性)
  1042. // 赋值物料编码,物料名称 , 规格
  1043. that.formData.materialName = data.materialName;
  1044. that.formData.materialCode = data.materialCode;
  1045. that.formData.materialSpecification = data.materialSpecification; //规格
  1046. // 赋值批号
  1047. that.formData.batch = data.batch;
  1048. that.formData.batch1 = data.batch1;
  1049. that.formData.batch2 = data.batch2;
  1050. // 赋值单位
  1051. that.formData.unitCode = data.unitCode;
  1052. that.formData.unitName = data.unitName;
  1053. // 赋值托盘、包装
  1054. that.formData.palletCode = data.palletCode;
  1055. that.formData.packageCode = data.packageCode;
  1056. that.formData.palletName = data.palletName;
  1057. that.formData.packageName = data.packageName;
  1058. //赋值是否托、是否包装
  1059. that.formData.isPackage = data.isPackage
  1060. that.formData.isPallet = data.isPallet
  1061. //如果不显示保存按钮则自动保存
  1062. if (!that.isShowSaveButton) {
  1063. setTimeout(() => {
  1064. that.handleSave();
  1065. }, 10)
  1066. }
  1067. } else {
  1068. uni.vibrateLong({});
  1069. uni.showToast({
  1070. title: "标签无效或已扫描",
  1071. icon: "none"
  1072. })
  1073. }
  1074. }
  1075. }).catch((err) => {
  1076. uni.vibrateLong({});
  1077. });
  1078. },
  1079. // 托盘扫码请求
  1080. getScanTpList(barCode) {
  1081. let that = this;
  1082. let params = {
  1083. palletCode: barCode
  1084. }
  1085. //有任务时传物料编码
  1086. if (this.formData.backTaskInsCode != null && this.formData.backTaskInsCode != '' && this.formData.backTaskInsCode != undefined) {
  1087. params.materialCode = this.formData.materialCode;
  1088. }
  1089. // 托盘网络请求
  1090. listBackStockInCurrent(params).then(res => {
  1091. if (res.code === 200) {
  1092. that.isLabelScan = false;
  1093. let data = res.rows ? res.rows : [];
  1094. if (Array.isArray(data) && data.length > 0 && typeof data[0] == 'object') {
  1095. //将stockQty赋值给maxQty
  1096. data.forEach(item => {
  1097. if (item.hasOwnProperty('stockQty')) {
  1098. item.maxQty = item.stockQty;
  1099. }
  1100. })
  1101. that.labelList = data;
  1102. that.formData.warehouseCode = data[0].warehouseCode;
  1103. that.formData.warehouseName = data[0].warehouseName;
  1104. that.formData.locationCode = data[0].locationCode;
  1105. that.formData.locationName = data[0].locationName;
  1106. that.formData.labelCode = data[0].labelCode;
  1107. that.formData.stockQty = data[0].stockQty;
  1108. //如果不显示保存按钮则自动保存
  1109. if (!that.isShowSaveButton) {
  1110. setTimeout(() => {
  1111. that.handleSave();
  1112. }, 10)
  1113. }
  1114. } else {
  1115. uni.vibrateLong({});
  1116. uni.showToast({
  1117. title: "托盘无效",
  1118. icon: "none"
  1119. })
  1120. }
  1121. }
  1122. }).catch((err) => {
  1123. uni.vibrateLong({});
  1124. });
  1125. },
  1126. // 包装扫码请求
  1127. getScanBzList(barCode) {
  1128. let that = this;
  1129. let params = {
  1130. packageCode: barCode
  1131. }
  1132. //有任务时传物料编码
  1133. if (this.formData.backTaskInsCode != null && this.formData.backTaskInsCode != '' && this.formData.backTaskInsCode != undefined) {
  1134. params.materialCode = this.formData.materialCode;
  1135. }
  1136. // 包装网络请求
  1137. listBackStockInCurrent(params).then(res => {
  1138. if (res.code === 200) {
  1139. that.isLabelScan = false;
  1140. let data = res.rows ? res.rows : [];
  1141. if (Array.isArray(data) && data.length > 0 && typeof data[0] == 'object') {
  1142. //将stockQty赋值给maxQty
  1143. data.forEach(item => {
  1144. if (item.hasOwnProperty('stockQty')) {
  1145. item.maxQty = item.stockQty;
  1146. }
  1147. })
  1148. that.labelList = data;
  1149. that.formData.warehouseCode = data[0].warehouseCode;
  1150. that.formData.warehouseName = data[0].warehouseName;
  1151. that.formData.locationCode = data[0].locationCode;
  1152. that.formData.locationName = data[0].locationName;
  1153. that.formData.labelCode = data[0].labelCode;
  1154. that.formData.stockQty = data[0].stockQty;
  1155. //如果不显示保存按钮则自动保存
  1156. if (!that.isShowSaveButton) {
  1157. setTimeout(() => {
  1158. that.handleSave();
  1159. }, 10)
  1160. }
  1161. } else {
  1162. uni.vibrateLong({});
  1163. uni.showToast({
  1164. title: "包装无效",
  1165. icon: "none"
  1166. })
  1167. }
  1168. }
  1169. }).catch((err) => {
  1170. uni.vibrateLong({});
  1171. });
  1172. },
  1173. handleAuto() {
  1174. if (this.autoButtonTitle === "自动") { //手动
  1175. this.autoButtonTitle = "手动";
  1176. this.isShowSaveButton = true;
  1177. } else { //自动
  1178. this.autoButtonTitle = "自动";
  1179. this.isShowSaveButton = false;
  1180. }
  1181. },
  1182. handleBack() {
  1183. uni.showModal({
  1184. title: '提示',
  1185. content: '确认返回?',
  1186. success: function(res) {
  1187. if (res.confirm) {
  1188. uni.navigateBack();
  1189. } else if (res.cancel) {
  1190. }
  1191. }
  1192. });
  1193. },
  1194. getSendNum(num) {
  1195. this.mxNum = num;
  1196. if(num == 0){
  1197. this.formData.appGroupId=''
  1198. }
  1199. },
  1200. SendNumEmpty() {
  1201. let that = this;
  1202. if (this.mxNum > 0) {
  1203. uni.showModal({
  1204. title: '新单',
  1205. content: '是否要明细归零,录入新单?',
  1206. success: function(res) {
  1207. if (res.confirm) {
  1208. that.mxNum = 0;
  1209. let data = {
  1210. "stockId": "",
  1211. "stockIdList": []
  1212. }
  1213. uni.setStorageSync('stock_key', data);
  1214. //清空唯一值
  1215. that.formData.appGroupId = '';
  1216. }
  1217. }
  1218. });
  1219. }
  1220. },
  1221. //清空任务、部门、职员、供应商
  1222. EmptyTest() {
  1223. this.formData.taskInsId = "";
  1224. this.formData.backTaskInsId = "";
  1225. this.formData.backTaskInsCode = "";
  1226. this.formData.deptCode = "";
  1227. this.formData.deptName = "";
  1228. this.formData.employeeCode = "";
  1229. this.formData.employeeName = "";
  1230. this.formData.supplierCode = "";
  1231. this.formData.supplierName = "";
  1232. },
  1233. //清空子表信息
  1234. EmptyEntry() {
  1235. this.formData.labelCode = "";
  1236. if (!this.formData.backTaskInsCode) {
  1237. this.formData.materialCode = "";
  1238. this.formData.materialName = "";
  1239. }
  1240. this.formData.batch = "";
  1241. this.formData.unitCode = "";
  1242. this.formData.unitName = "";
  1243. this.formData.stockQty = "";
  1244. // this.formData.rwQty = "";
  1245. this.formData.batch1 = "";
  1246. this.formData.batch2 = "";
  1247. this.formData.materialSpecification = "";
  1248. },
  1249. rulesStar(str) {
  1250. let rules = this.rules;
  1251. if (rules[str] && rules[str].rules[0] && rules[str].rules[0].required) {
  1252. return true;
  1253. } else {
  1254. return false;
  1255. }
  1256. },
  1257. fieldHidden(str) {
  1258. let rules = this.rules;
  1259. if (rules[str] && rules[str].rules[0] && rules[str].rules[0].hidden) {
  1260. return !true;
  1261. } else {
  1262. return !false;
  1263. }
  1264. },
  1265. setFieldSetting(obj) { //修改字段设置
  1266. let index = this.fieldSetting.findIndex(item => item.field == obj.field);
  1267. if (index !== -1) {
  1268. // 如果找到匹配项,则使用 obj 的属性覆盖 fieldSetting 中的相应属性
  1269. Object.assign(this.fieldSetting[index], obj);
  1270. } else {
  1271. // 如果没有找到匹配项,则将 obj 添加到 fieldSetting 中
  1272. this.fieldSetting.push(obj);
  1273. }
  1274. },
  1275. },
  1276. computed: {
  1277. rules() {
  1278. let form = this.formData;
  1279. let rules = {};
  1280. if (!Array.isArray(this.fieldSetting) && this.fieldSetting.length > 0) {
  1281. return rules;
  1282. }
  1283. //转数组
  1284. for (let i = 0; i < this.fieldSetting.length; i++) {
  1285. let field = this.fieldSetting[i];
  1286. rules[field.field] = {
  1287. rules: [{
  1288. required: false,
  1289. errorMessage: field.fieldName + '不能为空',
  1290. hidden: false
  1291. }],
  1292. }
  1293. if (field.required == 1 && field.field) { //判断是否必录
  1294. //判断是否必录
  1295. if (!field.requiredCondition) { //条件为空
  1296. rules[field.field].rules[0].required = true;
  1297. } else { //有条件;form中对应属性满足正则
  1298. //先赋值true;正则不满足再赋值false
  1299. rules[field.field].rules[0].required = true;
  1300. //判断必录用正则数组
  1301. let regArr = [];
  1302. try {
  1303. if (field.requiredCondition) {
  1304. let arr = JSON.parse(field.requiredCondition);
  1305. if (arr != null) {
  1306. regArr = arr.map(([key, value]) => [key, new RegExp(value)]);
  1307. }
  1308. }
  1309. } catch (err) {
  1310. console.error("err", err)
  1311. }
  1312. for (let j = 0; j < regArr.length; j++) {
  1313. if (regArr[j].length == 2 && regArr[j][1].test(form[regArr[j][0]])) {
  1314. rules[field.field].rules[0].required = true;
  1315. } else {
  1316. rules[field.field].rules[0].required = false;
  1317. break;
  1318. }
  1319. }
  1320. }
  1321. }
  1322. if (field.hidden == 1 && field.field) { //判断是否隐藏
  1323. //判断是否必录
  1324. if (!field.hiddenCondition) { //条件为空
  1325. rules[field.field].rules[0].hidden = true;
  1326. } else { //有条件;form中对应属性满足正则
  1327. //先赋值true;正则不满足再赋值false
  1328. rules[field.field].rules[0].hidden = true;
  1329. //判断必录用正则数组
  1330. let regArr = [];
  1331. try {
  1332. if (field.hiddenCondition) {
  1333. let arr = JSON.parse(field.hiddenCondition);
  1334. if (arr != null) {
  1335. regArr = arr.map(([key, value]) => [key, new RegExp(value)]);
  1336. }
  1337. }
  1338. } catch (err) {
  1339. console.error("err", err)
  1340. }
  1341. for (let j = 0; j < regArr.length; j++) {
  1342. if (regArr[j].length == 2 && regArr[j][1].test(form[regArr[j][0]])) {
  1343. rules[field.field].rules[0].hidden = true;
  1344. } else {
  1345. rules[field.field].rules[0].hidden = false;
  1346. break;
  1347. }
  1348. }
  1349. }
  1350. }
  1351. }
  1352. return rules;
  1353. },
  1354. getHashId(){
  1355. //生成哈希值
  1356. const crypto = require('crypto');
  1357. function hashString(str) {
  1358. const hash = crypto.createHash('sha256');
  1359. hash.update(str);
  1360. return hash.digest('hex');
  1361. }
  1362. //null和undefined返回空
  1363. function IFNULL(str){
  1364. return (str==null || str==undefined) ? "" : str + "";
  1365. }
  1366. //使用头信息和nanoid来生成唯一值
  1367. let groupJson = {
  1368. appGroupId : this.formData.appGroupId,
  1369. billTypeCode : IFNULL(this.formData.billTypeCode),
  1370. backTaskInId : '',
  1371. deptCode : IFNULL(this.formData.deptCode),
  1372. employeeCode : IFNULL(this.formData.employeeCode),
  1373. supplierCode : IFNULL(this.formData.supplierCode),
  1374. warehouseCode : IFNULL(this.formData.warehouseCode),
  1375. extendCode01 : IFNULL(this.formData.extendCode01),
  1376. extendCode02 : IFNULL(this.formData.extendCode02),
  1377. extendCode03 : IFNULL(this.formData.extendCode03),
  1378. extendCode04 : IFNULL(this.formData.extendCode04),
  1379. extendCode05 : IFNULL(this.formData.extendCode05),
  1380. }
  1381. let groupStr = JSON.stringify(groupJson)
  1382. const hash = hashString(groupStr)
  1383. return hash
  1384. },
  1385. }
  1386. }
  1387. </script>
  1388. <style>
  1389. @import "@/static/scss/stock.css";
  1390. .titleV {
  1391. color: #888888;
  1392. font-size: 16px;
  1393. height: 26px;
  1394. line-height: 26px;
  1395. width: 60px;
  1396. }
  1397. .detailV {
  1398. margin-left: 4px;
  1399. color: #333333;
  1400. font-size: 16px;
  1401. height: auto;
  1402. line-height: 26px;
  1403. width: calc(100vw - 70px);
  1404. }
  1405. </style>