index.vue 53 KB

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