index.vue 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881
  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"
  5. right-icon="refreshempty" @clickRight="SendNumEmpty"/>
  6. <view class="scan-header">
  7. <uni-forms-item name="barCode" :label="specialScanName" :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"
  10. :clearable="false" @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
  20. :rules="rules"
  21. :value="formData"
  22. ref="form"
  23. validate-trigger="submit"
  24. err-show-type="toast"
  25. >
  26. <!--<uni-forms-item name="billTypeCode" :required="rulesStar('billTypeCode')" v-show="fieldHidden('billTypeCode')" label="单据类型" :label-width="lableWidth" labelAlign="right">
  27. <uni-data-select
  28. v-model="formData.billTypeCode"
  29. :localdata="billTypeOption"
  30. @change="ywlxChange"
  31. ></uni-data-select>
  32. </uni-forms-item>-->
  33. <uni-forms-item name="taskMoveCode" :required="rulesStar('taskMoveCode')" v-show="fieldHidden('taskMoveCode')" label="任务编码" :label-width="lableWidth" labelAlign="right">
  34. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  35. v-model="formData.taskMoveCode" suffixIcon="search" @iconClick="searchIconClick('task')">
  36. </uni-easyinput>
  37. </uni-forms-item>
  38. <uni-forms-item name="deptCodeOut" :required="rulesStar('deptCodeOut')" v-show="fieldHidden('deptCodeOut')" label="移出部门" :label-width="lableWidth" labelAlign="right">
  39. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  40. v-model="formData.deptNameOut" suffixIcon="search" @iconClick="searchIconClick('deptOut')">
  41. </uni-easyinput>
  42. </uni-forms-item>
  43. <uni-forms-item name="deptCodeIn" :required="rulesStar('deptCodeIn')" v-show="fieldHidden('deptCodeIn')" label="移入部门" :label-width="lableWidth" labelAlign="right">
  44. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  45. v-model="formData.deptNameIn" suffixIcon="search" @iconClick="searchIconClick('deptIn')">
  46. </uni-easyinput>
  47. </uni-forms-item>
  48. <uni-forms-item name="employeeCodeOut" :required="rulesStar('employeeCodeOut')" v-show="fieldHidden('employeeCodeOut')" label="移出职员" :label-width="lableWidth" labelAlign="right">
  49. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  50. v-model="formData.employeeNameOut" suffixIcon="search" @iconClick="searchIconClick('emplOut')">
  51. </uni-easyinput>
  52. </uni-forms-item>
  53. <uni-forms-item name="employeeCodeIn" :required="rulesStar('employeeCodeIn')" v-show="fieldHidden('employeeCodeIn')" label="移入职员" :label-width="lableWidth" labelAlign="right">
  54. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  55. v-model="formData.employeeNameIn" suffixIcon="search" @iconClick="searchIconClick('emplIn')">
  56. </uni-easyinput>
  57. </uni-forms-item>
  58. <uni-forms-item name="warehouseCodeOut" :required="rulesStar('warehouseCodeOut')" v-show="fieldHidden('warehouseCodeOut')" label="移出仓库" :label-width="lableWidth" labelAlign="right">
  59. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  60. v-model="formData.warehouseNameOut" suffixIcon="search" @iconClick="searchIconClick('wareOut')">
  61. </uni-easyinput>
  62. </uni-forms-item>
  63. <uni-forms-item name="warehouseCodeIn" :required="rulesStar('warehouseCodeIn')" v-show="fieldHidden('warehouseCodeIn')" label="移入仓库" :label-width="lableWidth" labelAlign="right">
  64. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  65. v-model="formData.warehouseNameIn" suffixIcon="search" @iconClick="searchIconClick('wareIn')">
  66. </uni-easyinput>
  67. </uni-forms-item>
  68. <uni-forms-item name="extendCode01" :required="rulesStar('extendCode01')" v-show="fieldHidden('extendCode01')" label="出库类别" :label-width="lableWidth" labelAlign="right">
  69. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  70. v-model="formData.extendName01" suffixIcon="search" @iconClick="searchIconClick('ext01')">
  71. </uni-easyinput>
  72. </uni-forms-item>
  73. <uni-forms-item name="extendCode02" :required="rulesStar('extendCode02')" v-show="fieldHidden('extendCode02')" label="入库类别" :label-width="lableWidth" labelAlign="right">
  74. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  75. v-model="formData.extendName02" suffixIcon="search" @iconClick="searchIconClick('ext02')">
  76. </uni-easyinput>
  77. </uni-forms-item>
  78. <uni-forms-item name="customerCodeIn" :required="rulesStar('customerCodeIn')" v-show="fieldHidden('customerCodeIn')" label="移入客户" :label-width="lableWidth" labelAlign="right">
  79. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  80. v-model="formData.customerNameIn" suffixIcon="search" @iconClick="searchIconClick('custIn')">
  81. </uni-easyinput>
  82. </uni-forms-item>
  83. <uni-forms-item name="extendCode03" :required="rulesStar('extendCode03')" v-show="fieldHidden('extendCode03')" label="要货单号" :label-width="lableWidth" labelAlign="right">
  84. <uni-easyinput type="text" @focus="specialScan('看板')" @blur="specialScan(false)"
  85. :styles="styleInput" :inputBorder="true" v-model="formData.extendName03">
  86. </uni-easyinput>
  87. </uni-forms-item>
  88. <uni-forms-item name="extendCode04" :required="rulesStar('extendNCode04')" v-show="fieldHidden('extendCode04')" label="审核人" :label-width="lableWidth" labelAlign="right">
  89. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  90. v-model="formData.extendName04" suffixIcon="search" @iconClick="searchIconClick('ext04')">
  91. </uni-easyinput>
  92. </uni-forms-item>
  93. <uni-forms-item name="extendCode05" :required="rulesStar('extendCode05')" v-show="fieldHidden('extendCode05')" label="发货时间" :label-width="lableWidth" labelAlign="right">
  94. <uni-datetime-picker type="datetime" v-model="formData.extendCode05" placeholder="年-月-日 --:--" :hideSecond="true"/>
  95. </uni-forms-item>
  96. <uni-forms-item name="locationCodeOut" :required="rulesStar('locationCodeOut')" v-show="isLabelScan && fieldHidden('locationCodeOut')" label="移出货位" :label-width="lableWidth" labelAlign="right">
  97. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  98. v-model="formData.locationNameOut" :suffixIcon="formData.labelCode ? 'search' : ''" @iconClick="searchIconClick('locaOut')">
  99. </uni-easyinput>
  100. </uni-forms-item>
  101. <uni-forms-item name="locationCodeIn" :required="rulesStar('locationCodeIn')" v-show="fieldHidden('locationCodeIn')" label="移入货位" :label-width="lableWidth" labelAlign="right">
  102. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  103. v-model="formData.locationNameIn" suffixIcon="search" @iconClick="searchIconClick('locaIn')">
  104. </uni-easyinput>
  105. </uni-forms-item>
  106. <template v-show="isLabelScan">
  107. <uni-forms-item name="labelCode" :required="rulesStar('labelCode')" v-show="fieldHidden('labelCode')" label="标签编码" :label-width="lableWidth" labelAlign="right">
  108. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  109. v-model="formData.labelCode" suffixIcon="compose" @iconClick="searchIconClick('Label')"></uni-easyinput>
  110. </uni-forms-item>
  111. <uni-forms-item name="materialCode" :required="rulesStar('materialCode')" v-show="fieldHidden('materialCode')" label="物料" :label-width="lableWidth" labelAlign="right">
  112. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  113. v-model="formData.materialName">
  114. </uni-easyinput>
  115. </uni-forms-item>
  116. <uni-forms-item name="batch" :required="rulesStar('batch')" v-show="fieldHidden('batch')" label="批号" :label-width="lableWidth" labelAlign="right">
  117. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-model="formData.batch"></uni-easyinput>
  118. </uni-forms-item>
  119. <uni-forms-item name="palletCodeOut" :required="rulesStar('palletCodeOut')" v-show="isLabelScan && fieldHidden('palletCodeOut')" label="调出托盘" :label-width="lableWidth" labelAlign="right">
  120. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-model="formData.palletCodeOut" >
  121. </uni-easyinput>
  122. </uni-forms-item>
  123. </template>
  124. <uni-forms-item name="palletCodeIn" :required="rulesStar('palletCodeIn')" v-show="fieldHidden('palletCodeIn')" label="调入托盘" :label-width="lableWidth" labelAlign="right">
  125. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  126. v-model="formData.palletCodeIn" suffixIcon="search" @iconClick="searchIconClick('pallIn')">
  127. </uni-easyinput>
  128. </uni-forms-item>
  129. <uni-forms-item name="packageCodeOut" :required="rulesStar('packageCodeOut')" v-show="isLabelScan && fieldHidden('packageCodeOut')" label="调出包装" :label-width="lableWidth" labelAlign="right">
  130. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  131. v-model="formData.packageCodeOut"></uni-easyinput>
  132. </uni-forms-item>
  133. <uni-forms-item name="packageCodeIn" :required="rulesStar('packageCodeIn')" v-show="fieldHidden('packageCodeIn')" label="调入包装" :label-width="lableWidth" labelAlign="right">
  134. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  135. v-model="formData.packageCodeIn" suffixIcon="search" @iconClick="searchIconClick('packIn')"></uni-easyinput>
  136. </uni-forms-item>
  137. <template v-show="isLabelScan">
  138. <uni-forms-item name="unitCode" :required="rulesStar('unitCode')" v-show="fieldHidden('unitCode')" label="单位" :label-width="lableWidth" labelAlign="right">
  139. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-model="formData.unitName">
  140. </uni-easyinput>
  141. </uni-forms-item>
  142. <uni-forms-item name="stockQty" :required="rulesStar('stockQty')" v-show="fieldHidden('stockQty')" label="数量" :label-width="lableWidth" labelAlign="right">
  143. <uni-easyinput type="number" :inputBorder="true"
  144. v-model="formData.stockQty" @input="bqslInputHandle" ></uni-easyinput>
  145. </uni-forms-item>
  146. <uni-forms-item name="rwQty" :required="rulesStar('rwQty')" v-show="fieldHidden('rwQty')" label="任务数量" :label-width="lableWidth" labelAlign="right">
  147. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-model="formData.rwQty"></uni-easyinput>
  148. </uni-forms-item>
  149. </template>
  150. <uni-card v-for="(item, index) in labelList" :key="index">
  151. <text class="uni-body" style="font-size: 16px;">
  152. <p><span class="titleV">标签:</span><span class="detailV">{{item.labelCode}}</span></p>
  153. <p><span class="titleV">物料:</span><span class="detailV">{{item.materialCode}}</span></p>
  154. <p><span class="titleV">单位:</span><span class="detailV">{{item.unitCode}}</span></p>
  155. <p><span class="titleV">批次:</span><span class="detailV">{{item.batch}}</span></p>
  156. <p v-if="item.batch1"><span class="titleV">批次1:</span><span class="detailV">{{item.batch1}}</span></p>
  157. <p v-if="item.batch2"><span class="titleV">批次2:</span><span class="detailV">{{item.batch2}}</span></p>
  158. <p v-if="item.tasksQty>=0">
  159. <span class="titleV">任务数量:</span>
  160. <span class="detailV">
  161. {{item.tasksQty}}<template v-if="sumlabelList[item.materialCode] && item.tasksQty-sumlabelList[item.materialCode]<0">(超任务{{item.tasksQty - sumlabelList[item.materialCode]}})</template>
  162. </span>
  163. </p>
  164. </text>
  165. <view slot="actions" class="card-actions">
  166. <view class="card-actions-item" @click="delLabelList(index)">
  167. <uni-icons type="closeempty" size="18" color="#999"></uni-icons>
  168. </view>
  169. <view class="card-actions-item">
  170. <uni-number-box :min="0" :max="item.maxQty" :value="item.stockQty"
  171. @change="labelListQtyChange(item, $event)" />
  172. </view>
  173. </view>
  174. </uni-card>
  175. </uni-forms>
  176. </view>
  177. </scroll-view>
  178. </view>
  179. <view class="page-bottom">
  180. <view class="p-b-btn">
  181. <uni-badge class="uni-badge-left-margin" :text="mxNum" :max-num="999" absolute="rightTop" :offset="[-3, -3]" size="small">
  182. <view class="box"><text class="box-text" @click="handleMx">明细</text></view>
  183. </uni-badge>
  184. </view>
  185. <view class="p-b-btn" @click="$noMultipleClicks($noMultipleClicks(handleSave))">
  186. <text class="box-text" v-show="isShowSaveButton">暂存</text>
  187. </view>
  188. <view class="p-b-btn" @click="handleAuto">
  189. <text class="box-text">{{autoButtonTitle}}</text>
  190. </view>
  191. <view class="p-b-btn" @click="handleBack">
  192. <text class="box-text">返回</text>
  193. </view>
  194. </view>
  195. <scan-code />
  196. <!-- 明细弹窗 -->
  197. <MxPopup ref="mxPopup" @sendNum="getSendNum" :formData="formData" @sendData="getSendData"/>
  198. <!-- 任务清单 -->
  199. <RwbmPopup ref="rwbmPopup" :title="rwbmTitle" :idxFlag="rwbmFlag" :formData="formData" @sendData="getSendData" />
  200. <!-- 仓库 -->
  201. <wareOutPopup ref="wareOutPopup" :title="wareOutTitle" :idxFlag="wareOutFlag" :formData="formData" @sendData="getSendData"/>
  202. <wareInPopup ref="wareInPopup" :title="wareInTitle" :idxFlag="wareInFlag" :formData="formData" @sendData="getSendData"/>
  203. <!-- 部门 -->
  204. <BmOutPopup ref="bmOutPopup" :title="bmOutTitle" :idxFlag="bmOutFlag" :formData="formData" @sendData="getSendData"/>
  205. <BmInPopup ref="bmInPopup" :title="bmInTitle" :idxFlag="bmInFlag" :formData="formData" @sendData="getSendData"/>
  206. <!-- 职员 -->
  207. <ZyOutPopup ref="zyOutPopup" :title="zyOutTitle" :idxFlag="zyOutFlag" :formData="formData" @sendData="getSendData"/>
  208. <ZyInPopup ref="zyInPopup" :title="zyInTitle" :idxFlag="zyInFlag" :formData="formData" @sendData="getSendData"/>
  209. <!-- 出入库类型 -->
  210. <SflbOutPopup ref="sflbOutPopup" :title="sflbOutTitle" :idxFlag="sflbOutFlag" :formData="formData" @sendData="getSendData"/>
  211. <SflbInPopup ref="sflbInPopup" :title="sflbInTitle" :idxFlag="sflbInFlag" :formData="formData" @sendData="getSendData"/>
  212. <!-- 移入客户 -->
  213. <KhInPopup ref="khInPopup" :title="khInTitle" :idxFlag="khInFlag" :formData="formData" @sendData="getSendData"/>
  214. <!-- 托盘 -->
  215. <TpInPopup ref="tpInPopup" :title="tpInTitle" :idxFlag="tpInFlag" :formData="formData" @sendData="getSendData"/>
  216. <!-- 包装 -->
  217. <BzInPopup ref="bzInPopup" :title="bzInTitle" :idxFlag="bzInFlag" :formData="formData" @sendData="getSendData"/>
  218. <!-- 审核人 -->
  219. <shrPopup ref="shrPopup" :title="shrTitle" :idxFlag="shrFlag" :formData="formData" @sendData="getSendData"/>
  220. <!-- 出入货位 -->
  221. <locaOutPopup ref="locaOutPopup" :title="locaOutTitle" :idxFlag="locaOutFlag" :formData="formData" @sendData="getSendData"/>
  222. <locaInPopup ref="locaInPopup" :title="locaInTitle" :idxFlag="locaInFlag" :formData="formData" @sendData="getSendData"/>
  223. <!-- 标签选任务子表 -->
  224. <selectTaskMoves ref="selectTaskMoves" title="任务选择" :formData="formData" @sendData="getSendDataTaskMoves"/>
  225. </view>
  226. </template>
  227. <script>
  228. import scanCode from "@/components/scan/scan.vue";
  229. import { getDicts } from "@/api/system/dict/data"; // 字典
  230. import RwbmPopup from './popup/commonpopup.vue' // 任务编码
  231. import BmOutPopup from './popup/commonpopup.vue' // 部门
  232. import BmInPopup from './popup/commonpopup.vue'
  233. import ZyOutPopup from './popup/commonpopup.vue' // 职员
  234. import ZyInPopup from './popup/commonpopup.vue'
  235. import wareOutPopup from './popup/commonpopup.vue' // 仓库
  236. import wareInPopup from './popup/commonpopup.vue'
  237. import SflbOutPopup from './popup/commonpopup.vue' // 收发类别
  238. import SflbInPopup from './popup/commonpopup.vue'
  239. import KhInPopup from './popup/commonpopup.vue' //客户
  240. import TpInPopup from './popup/commonpopup.vue' // 托盘
  241. import BzInPopup from './popup/commonpopup.vue' // 包装
  242. import LabelPopup from './popup/commonpopup.vue' // 标签
  243. import shrPopup from './popup/commonpopup.vue' // 审核人
  244. import locaOutPopup from './popup/commonpopup.vue' // 移出货位
  245. import locaInPopup from './popup/commonpopup.vue' // 移入货位
  246. import selectTaskMoves from './popup/selectTaskMoves' // 标签选任务子表
  247. import MxPopup from './popup/mxPopup.vue'
  248. import {addStockMove, checkAddStockMove, listStockMove, listLocation, listTaskMove, listCurrent, listWarehouse, listPallet, listPackage,listExtend,getMoveReviewerList,getListFieldSetting, queryBillTypeCache } from '@/api/wms/stockMove.js'
  249. import { listFieldDefault } from '@/api/wms/report.js'
  250. import storage from '@/utils/storage'
  251. import { nanoid } from 'nanoid'; //唯一值 nanoid
  252. export default {
  253. components: {
  254. scanCode,
  255. RwbmPopup,
  256. BmOutPopup,
  257. BmInPopup,
  258. wareOutPopup,
  259. wareInPopup,
  260. MxPopup,
  261. ZyOutPopup,
  262. ZyInPopup,
  263. SflbOutPopup,
  264. SflbInPopup,
  265. KhInPopup,
  266. shrPopup,
  267. TpInPopup,
  268. BzInPopup,
  269. locaOutPopup,
  270. locaInPopup,
  271. selectTaskMoves
  272. },
  273. props: {},
  274. async onLoad(option) {
  275. //下面请求如果失败改为false
  276. let isRequest = true;
  277. //字段设置
  278. try {
  279. const res = await this.retryRequest(getListFieldSetting, { billCode: "stockMove" });
  280. // 处理响应数据
  281. this.fieldSetting=res.rows;
  282. let obj = {"field": "billTypeCode","fieldName": "单据类型","required": null,"requiredCondition": null,"hidden": null,"hiddenCondition": null}
  283. obj.hidden = 1;
  284. this.setFieldSetting(obj);
  285. } catch (error) {
  286. isRequest = false;
  287. }
  288. //单据类型
  289. try {
  290. const res = await this.retryRequest(queryBillTypeCache, {billCode: "stockMove"});
  291. // 处理响应数据
  292. let tmpData = res.rows;
  293. this.billTypeOption = tmpData.filter(item => item.isEnableApp == 0 && item.status == 0)
  294. .map(item => ({
  295. billTypeCode: item.billTypeCode,
  296. billTypeName: item.billTypeName,
  297. value: item.billTypeCode,
  298. text: item.billTypeName,
  299. taskValue: item.taskBillTypeCode ? "'" + item.taskBillTypeCode.replace(/,/g, "','") + "'" : '',
  300. isControlTask: item.backTaskBillTypeCode ? item.isControlTask : 0,
  301. }));
  302. //触发单据类型变更
  303. this.ywlxChange(option.ywlx);
  304. } catch (error) {
  305. isRequest = false;
  306. }
  307. //审核人
  308. try {
  309. const res = await this.retryRequest(getMoveReviewerList);
  310. // 处理响应数据
  311. if(res && res.rows && res.rows[0] && res.rows[0].setDefaultSettings){
  312. if(res.rows[0].setDefaultSettings.settingFlag == "审核人"){
  313. this.formData.extendCode04 = res.rows[0].setDefaultSettings.settingCode;
  314. this.formData.extendName04 = res.rows[0].setDefaultSettings.settingName;
  315. this.formData.userids = res.rows[0].setDefaultSettings.settingValues == "" ? null : res.rows[0].setDefaultSettings.settingValues;
  316. }
  317. }
  318. } catch (error) {
  319. isRequest = false;
  320. }
  321. //任务有传参;执行扫任务
  322. if(option.taskCode){
  323. this.getScanRwList(option.taskCode);
  324. }
  325. if(isRequest==false){
  326. uni.showModal({
  327. title: '获取单据信息失败',
  328. content: '请返回菜单重新进入',
  329. showCancel: false ,//不显示取消按钮
  330. success: function (res) {
  331. if (res.confirm) {
  332. uni.navigateBack();
  333. }
  334. }
  335. })
  336. }else{
  337. this.isRequest=true
  338. }
  339. if(option.ywlx == 1){
  340. // 创建一个Date对象表示当前日期和时间
  341. const now = new Date();
  342. const year = now.getFullYear();
  343. const month = String(now.getMonth() + 1).padStart(2, '0');
  344. const date = String(now.getDate()).padStart(2, '0');
  345. const hours = String(now.getHours()).padStart(2, '0');
  346. const minutes = String(now.getMinutes()).padStart(2, '0');
  347. const formattedDateTime = `${year}-${month}-${date} ${hours}:${minutes}`;
  348. this.formData.extendCode05 = formattedDateTime;
  349. }
  350. },
  351. onUnload(){
  352. uni.removeStorageSync('stock_key');
  353. },
  354. onBackPress(options) {
  355. if (options.from === 'navigateBack') {
  356. // 来自于导航条返回按钮或者系统返回按钮的事件
  357. return false;
  358. }
  359. // 双击返回的逻辑
  360. const now = Date.now();
  361. if (this.lastBackPress && now - this.lastBackPress < 1000) {
  362. // 如果两次点击的间隔小于1000毫秒,则可以认为是双击
  363. //这时退出
  364. return false;
  365. } else {
  366. this.lastBackPress = now;
  367. uni.showToast({
  368. title: '再按一次退出',
  369. icon: 'none'
  370. });
  371. setTimeout(() => {
  372. this.lastBackPress = null;
  373. }, 1000);
  374. return true;
  375. }
  376. },
  377. data() {
  378. return {
  379. isRequest: false, //onLoad请求成功时改为true,否则不允许保存
  380. isLabelScan: true, //true是扫标签;false是扫托或包装,多行保存
  381. specialScanName: '条码', //不是条码时,执行特殊扫码(看板:扫到货单号)
  382. labelList: [], //扫托或包装获得的标签list
  383. remarkFocus: false,
  384. mxNum: 0, //明细按钮数量
  385. isShowSaveButton: false, //是否显示保存按钮
  386. // 必填项
  387. autoButtonTitle: '自动',
  388. scrollTop: 0,
  389. old: {
  390. scrollTop: 0
  391. },
  392. billTypeOption: [], // 业务类型字典选择框数据
  393. barCode: '', //条码
  394. formData: {
  395. // 单据类型
  396. billTypeCode: "", // 单据类型
  397. billTypeName: "",// 单据类型的名称(显示使用)
  398. taskBillTypeCode: "", //单据类型对应的任务类型
  399. isControlTask: null, //任务用,是否可超量
  400. // 任务编码
  401. taskMoveId: "",
  402. taskMoveCode: "",
  403. // 部门
  404. deptCodeOut: "",
  405. deptNameOut: "",
  406. deptCodeIn: "",
  407. deptNameIn: "",
  408. // 职员
  409. employeeCodeOut: "",
  410. employeeNameOut: "",
  411. employeeCodeIn: "",
  412. employeeNameIn: "",
  413. // 仓库
  414. warehouseCodeOut: "",
  415. warehouseNameOut: "",
  416. warehouseCodeIn: "",
  417. warehouseNameIn: "",
  418. // 出库类别
  419. extendName01: "",
  420. extendCode01: "",
  421. // 入库类别
  422. extendName02: "",
  423. extendCode02: "",
  424. // 要货单号
  425. extendName03: "",
  426. extendCode03: "",
  427. // 审核人
  428. extendName04: "",
  429. extendCode04: "",
  430. // 发货时间
  431. extendName05: "",
  432. extendCode05: "",
  433. // 移入客户
  434. customerCodeIn: "",
  435. customerNameIn: "",
  436. // 组id
  437. appGroupId: "",
  438. // ===== 以下 保存时转化为 wmsStockOutsList=====
  439. //任务子表id
  440. taskMovesId: "",
  441. taskMovesCode: "",
  442. // 货位
  443. locationCodeOut: "",
  444. locationNameOut: "",
  445. locationCodeIn: "",
  446. locationNameIn: "",
  447. // 标签
  448. labelCode: "", // 标签编码
  449. // 物料
  450. materialCode: "", // 物料编码
  451. materialName: "", //物料名称
  452. // 批号
  453. batch: "", //批号
  454. // 托盘
  455. palletCodeOut: "",
  456. palletNameOut: "",
  457. palletCodeIn: "",
  458. palletNameIn: "",
  459. // 包装
  460. packageCodeOut: "",
  461. packageNameOut: "",
  462. packageCodeIn: "",
  463. packageNameIn: "",
  464. //单位
  465. unitCode: "", //单位编码
  466. unitName: "", //单位名称
  467. stockQty: "", // 标签数量
  468. rwQty: "",// 任务数量
  469. batch1: "", //批号1
  470. batch2: "", //批号2
  471. materialSpecification: "", //物料规格
  472. userids:null, //选择审核人用,有值则只显示设置的人员
  473. isLocationOut:"",
  474. isPackageOut:"",
  475. isPalletOut:"",
  476. isLocationIn:"",
  477. isPackageIn:"",
  478. isPalletIn:"",
  479. },
  480. lableWidth: '80px',
  481. styleInput: {
  482. color: '#333',
  483. backgroundColor: '#fff',
  484. disableColor: '#fff',
  485. borderColor: '#e5e5e5',
  486. },
  487. fieldSetting: [], //单据字段设置
  488. // 任务编码
  489. rwbmTitle: "任务",
  490. rwbmFlag: "rwbm",
  491. // 职员
  492. zyOutTitle: "职员",
  493. zyOutFlag: "zyOut",
  494. zyInTitle: "职员",
  495. zyInFlag: "zyIn",
  496. // 部门
  497. bmOutTitle: "部门",
  498. bmOutFlag: "bmOut",
  499. bmInTitle: "部门",
  500. bmInFlag: "bmIn",
  501. // 收发类别
  502. sflbOutTitle: "收发类别",
  503. sflbOutFlag: "sflbOut",
  504. sflbInTitle: "收发类别",
  505. sflbInFlag: "sflbIn",
  506. // 移入客户
  507. khInTitle: "客户",
  508. khInFlag: "khIn",
  509. // 托盘
  510. tpInTitle: "托盘",
  511. tpInFlag: "tpIn",
  512. // 包装
  513. bzInTitle: "包装",
  514. bzInFlag: "bzIn",
  515. // 标签
  516. LabelPopup: "托盘",
  517. LabelFlag: "tpOut",
  518. // 仓库
  519. wareOutTitle: "移出仓库",
  520. wareOutFlag: "wareOut",
  521. wareInTitle: "移入仓库",
  522. wareInFlag: "wareIn",
  523. // 货位
  524. locaOutTitle: "移出货位",
  525. locaOutFlag: "locaOut",
  526. locaInTitle: "移入货位",
  527. locaInFlag: "locaIn",
  528. // 审核人
  529. shrTitle: "审核人",
  530. shrFlag: "shr",
  531. //配合$noMultipleClicks防止重复点击
  532. noClick:true,
  533. //记录物料号(用来处理任务有多行相同物料时弹窗)
  534. tempTaskMaterialCode:"",//记录物料
  535. tempTaskMovesId:"",//记录任务子表id
  536. isNewTaskMaterial:false,//true时弹窗选择任务行
  537. }
  538. },
  539. methods: {
  540. upper: function(e) {},
  541. lower: function(e) {},
  542. scroll: function(e) {
  543. this.old.scrollTop = e.detail.scrollTop
  544. },
  545. async retryRequest(requestFunction, requestParams, maxRetries = 1) {
  546. let retriesLeft = maxRetries;
  547. while (retriesLeft > 0) {
  548. try {
  549. // 调用请求函数并传入参数
  550. const response = await requestFunction(requestParams);
  551. if (response && response.code === 200) {
  552. return response; // 请求成功,返回响应
  553. } else {
  554. // 请求失败,但还有重试机会
  555. //console.warn(`请求失败,正在尝试第 ${maxRetries - retriesLeft + 1} 次重试...`);
  556. retriesLeft--;
  557. }
  558. } catch (error) {
  559. // 请求发生异常,但还有重试机会
  560. //console.error('请求发生异常,正在尝试重试...', error);
  561. retriesLeft--;
  562. }
  563. }
  564. // 所有重试都失败了,抛出错误
  565. throw new Error('获取信息失败');
  566. },
  567. onShow() {
  568. let that = this;
  569. uni.$off("scancode"); // 每次进来先 移除全局自定义事件监听器
  570. uni.$on("scancode", (data) => {
  571. // 扫描PCS码
  572. if(data && data !== ''){
  573. that.barCode = data;
  574. this.getDataByRemark(that.barCode);
  575. }else{
  576. uni.showToast({
  577. title: '扫码失败!',
  578. icon:'none',
  579. duration: 2000
  580. });
  581. }
  582. });
  583. },
  584. handleScanClick:function(){// 条码右侧扫码按钮事件
  585. let that = this;
  586. uni.scanCode({
  587. success: function(res) {
  588. // 播放音效
  589. // this.playMusic();
  590. // {"scanType":"QR_CODE","path":"","charSet":"ISO8859_1","result":"PT|04-A-1-1","errMsg":"scanCode:ok"}
  591. if(res.errMsg == "scanCode:ok"){
  592. that.barCode = res.result;
  593. this.getDataByRemark(that.barCode);
  594. }else{
  595. uni.showToast({
  596. title: '扫码失败!',
  597. icon:'none',
  598. duration: 2000
  599. });
  600. }
  601. },
  602. fail: (err) => {
  603. },
  604. complete: () => {
  605. }
  606. });
  607. },
  608. getDataByRemark(remark){ // 根据扫码数据查询其他formItem数据
  609. if(this.specialScanName=='看板'){
  610. this.formData.extendName03=remark
  611. uni.hideKeyboard()
  612. }
  613. let that = this;
  614. remark = remark.replace(/^\s+|\s+$/g, '');
  615. var splitPre = remark.split("|")[0];
  616. var splitLast = remark.slice(splitPre.length+1);
  617. // 条码空 不执行
  618. if(splitLast == ""){
  619. return true;
  620. }
  621. //任务子表弹窗时,不可以扫标签
  622. if(this.isNewTaskMaterial){
  623. return true;
  624. }
  625. // 扫码
  626. switch (splitPre){
  627. case "PT": // 货位 PT|04-A-1-1
  628. this.getScanHwList(splitLast);
  629. break;
  630. case "WH": // 仓库 WH|01
  631. this.getScanCkList(splitLast);
  632. break;
  633. case "RW": // 任务扫码 RW|
  634. this.getScanRwList(splitLast);
  635. break;
  636. case "L": // 标签 L|L2311060002
  637. this.getScanBqList(splitLast);
  638. break;
  639. case "P": // 托盘 P|0002
  640. this.getScanTpList(splitLast);
  641. break;
  642. case "PA": // 包装 PA|0002
  643. this.getScanBzList(splitLast);
  644. break;
  645. default:
  646. uni.showToast({
  647. title: "条码不合法",
  648. icon: "none"
  649. })
  650. break;
  651. }
  652. },
  653. scanSearch(remark){ // 条码框 回车
  654. this.getDataByRemark(remark);
  655. },
  656. //业务类型变更
  657. async ywlxChange(value) {
  658. if(value === ''){
  659. this.formData.billTypeCode = "";
  660. this.formData.billTypeName = "";
  661. this.formData.taskBillTypeCode = "";
  662. this.formData.isControlTask = "";
  663. }else {
  664. let status = this.billTypeOption.find(item => item.value == value);
  665. if(status){
  666. this.formData.billTypeCode = status.value;
  667. this.formData.billTypeName = status.text;
  668. this.formData.taskBillTypeCode = status.taskValue;
  669. this.formData.isControlTask = status.isControlTask
  670. }
  671. }
  672. // 监听业务类型变更,变更后。清空任务、客户、收发类别、审核人、发货时间、要货单号、清空明细查询出的数据、清空单号和单号数组
  673. //清空任务
  674. this.taskMoveId = "";
  675. this.taskMoveCode = "";
  676. this.taskMovesId = "";
  677. this.taskMovesCode = "";
  678. //清空客户
  679. this.formData.customerCodeIn = "";
  680. this.formData.customerNameIn = "";
  681. //清空收发类别、审核人、发货时间、要货单号
  682. this.formData.extendCode01 = "";
  683. this.formData.extendName01 = "";
  684. this.formData.extendCode02 = "";
  685. this.formData.extendName02 = "";
  686. this.formData.extendCode03 = "";
  687. this.formData.extendName03 = "";
  688. this.formData.extendCode04 = "";
  689. this.formData.extendName04 = "";
  690. this.formData.extendCode05 = "";
  691. this.formData.extendName05 = "";
  692. // 清空明细数据
  693. if (this.$refs.mxPopup) {
  694. this.$refs.mxPopup.listData = [];
  695. }
  696. // 清空单号和单号数组
  697. uni.removeStorageSync('stock_key');
  698. //更新唯一值
  699. this.formData.appGroupId = nanoid(19);
  700. if(value!='' && value!=null){
  701. //默认值
  702. const res = await this.retryRequest(listFieldDefault, { "billTypeCode":value, "billCode": 'stockMove' });
  703. if(res.code === 200){
  704. let fieldDefault = res.rows; //字段默认值
  705. let fieldSetting = this.fieldSetting.filter(item => item.defaults == '1'); //字段信息
  706. let form = this.formData; //新增的信息
  707. /*
  708. * 遍历字段信息,如果字段默认值和头信息中存在,则用字段中的keyCode、keyName和默认值中的settingCode、settingName赋值给from
  709. */
  710. for (let i = 0; i < fieldSetting.length; i++) {
  711. let fieldD = fieldDefault.filter(item => item.settingFlag == fieldSetting[i].field);
  712. //如果字段默认值和头信息中存在
  713. if (fieldD.length>0 && fieldSetting[i].field in form) {
  714. //仓库触发一次扫码
  715. if(fieldD[0].settingFlag=="warehouseCodeOut" && fieldD[0].settingCode){
  716. this.getScanCkList(fieldD[0].settingCode , "out")
  717. continue
  718. }else if(fieldD[0].settingFlag=="warehouseCodeIn" && fieldD[0].settingCode){
  719. this.getScanCkList(fieldD[0].settingCode , "in")
  720. continue
  721. }
  722. //赋值code(实际值)
  723. if(fieldSetting[i]["keyCode"]){
  724. form[ fieldSetting[i]["keyCode"] ] = fieldD[0].settingCode;
  725. }
  726. //赋值name(显示值)
  727. if(fieldSetting[i]["keyName"]){
  728. form[ fieldSetting[i]["keyName"] ] = fieldD[0].settingName;
  729. }
  730. }
  731. }
  732. }
  733. }
  734. },
  735. getSendData(res){ //基础资料
  736. let cFlag = res.currentFlag;
  737. let obj = {};
  738. switch (cFlag){
  739. case "rwbm": // 赋值任务
  740. if(this.formData.billTypeCode == '2'){
  741. break;
  742. }
  743. this.formData.taskMoveCode = res.selectData.taskCode;
  744. this.formData.taskMoveId = res.selectData.id;
  745. // 赋值部门
  746. this.formData.deptCodeOut = res.selectData.deptCodeOut;
  747. this.formData.deptNameOut = res.selectData.deptNameOut;
  748. this.formData.deptCodeIn = res.selectData.deptCodeIn;
  749. this.formData.deptNameIn = res.selectData.deptNameIn;
  750. // 赋值职员
  751. this.formData.employeeCodeOut = res.selectData.employeeCodeOut;
  752. this.formData.employeeNameOut = res.selectData.employeeNameOut;
  753. this.formData.employeeCodeIn = res.selectData.employeeCodeIn;
  754. this.formData.employeeNameIn = res.selectData.employeeNameIn;
  755. // 赋值仓库
  756. this.formData.warehouseCodeOut = res.selectData.warehouseCodeOut;
  757. this.formData.warehouseNameOut = res.selectData.warehouseNameOut;
  758. this.formData.warehouseCodeIn = res.selectData.warehouseCodeIn;
  759. this.formData.warehouseNameIn = res.selectData.warehouseNameIn;
  760. //清空记录物料号
  761. this.tempTaskMaterialCode = ""
  762. this.tempTaskMovesId = ""
  763. this.isNewTaskMaterial = false
  764. break;
  765. case "bmOut": // 出部门
  766. this.formData.deptCodeOut = res.selectData.deptCode;
  767. this.formData.deptNameOut = res.selectData.deptName;
  768. // 职员清空
  769. this.formData.employeeCodeOut = "";
  770. this.formData.employeeNameOut = "";
  771. break;
  772. case "bmIn": // 入部门
  773. this.formData.deptCodeIn = res.selectData.deptCode;
  774. this.formData.deptNameIn = res.selectData.deptName;
  775. // 职员清空
  776. this.formData.employeeCodeIn = "";
  777. this.formData.employeeNameIn = "";
  778. break;
  779. case "zyOut": // 出职员
  780. this.formData.employeeCodeOut = res.selectData.employeeCode;
  781. this.formData.employeeNameOut = res.selectData.employeeName;
  782. break;
  783. case "zyIn": // 入职员
  784. this.formData.employeeCodeIn = res.selectData.employeeCode;
  785. this.formData.employeeNameIn = res.selectData.employeeName;
  786. break;
  787. case "sflbOut": // 出类别
  788. this.formData.extendName01 = res.selectData.extendName;
  789. this.formData.extendCode01 = res.selectData.extendCode;
  790. break;
  791. case "sflbIn": // 入类别
  792. this.formData.extendName02 = res.selectData.extendName;
  793. this.formData.extendCode02 = res.selectData.extendCode;
  794. break;
  795. case "wareOut": // 出仓库
  796. this.formData.warehouseCodeOut = res.selectData.warehouseCode;
  797. this.formData.warehouseNameOut = res.selectData.warehouseName;
  798. this.formData.isLocationOut = res.selectData.isLocation
  799. // 清空子表
  800. this.EmptyEntry();
  801. this.formData.rwQty = "";
  802. break;
  803. case "wareIn": // 入仓库
  804. this.formData.warehouseCodeIn = res.selectData.warehouseCode;
  805. this.formData.warehouseNameIn = res.selectData.warehouseName;
  806. // 是否移入货位 必录
  807. obj = {"field": "locationCodeIn","fieldName": "移入货位","required": null,"requiredCondition": null,"hidden": null,"hiddenCondition": null}
  808. obj.required = res.selectData.isLocation == "1" ? null : 1;
  809. obj.hidden = res.selectData.isLocation == "1" ? 1 : null;
  810. this.setFieldSetting(obj);
  811. this.formData.isLocationIn = res.selectData.isLocation
  812. // 清空子表
  813. this.EmptyEntry();
  814. this.formData.rwQty = "";
  815. this.formData.locationCodeIn = "";
  816. this.formData.locationNameIn = "";
  817. break;
  818. case "locaOut": // 出货位
  819. this.formData.stockQty = res.selectData.stockQty;
  820. if(this.formData.taskCode == '' || this.formData.taskCode == null){
  821. this.formData.rwQty = res.selectData.stockQty;
  822. }
  823. // 赋值货位
  824. this.formData.locationCodeOut = res.selectData.locationCode;
  825. this.formData.locationNameOut = res.selectData.locationName;
  826. // 赋值托、包装
  827. this.formData.palletCodeOut = res.selectData.palletCode;
  828. this.formData.palletNameOut = res.selectData.palletName;
  829. this.formData.packageCodeOut = res.selectData.packageCode;
  830. this.formData.isLocationOut = 0
  831. break;
  832. case "locaIn": // 入货位
  833. this.formData.warehouseCodeIn = res.selectData.warehouseCode;
  834. this.formData.warehouseNameIn = res.selectData.warehouseName;
  835. this.formData.locationCodeIn = res.selectData.locationCode;
  836. this.formData.locationNameIn = res.selectData.locationName;
  837. // 是否移入货位 必录
  838. obj = {"field": "locationCodeIn","fieldName": "移入货位","required": null,"requiredCondition": null,"hidden": null,"hiddenCondition": null}
  839. obj.required = 1;
  840. this.formData.isLocationIn = 0
  841. this.setFieldSetting(obj);
  842. break;
  843. case "khIn": // 入客户
  844. this.formData.customerCodeIn = res.selectData.extendCode
  845. this.formData.customerNameIn = res.selectData.extendName
  846. break;
  847. case "shr": // 审核人
  848. this.formData.extendName04 = res.selectData.nickName;
  849. this.formData.extendCode04 = res.selectData.userId;
  850. break;
  851. case "bzIn": // 包装
  852. this.formData.packageCodeIn = res.selectData.packageCode;
  853. this.formData.packageNameIn = res.selectData.packageName;
  854. if(res.selectData.warehouseCode){
  855. this.formData.warehouseCodeIn = res.selectData.warehouseCode;
  856. this.formData.warehouseNameIn = res.selectData.warehouseName;
  857. }
  858. if(res.selectData.locationCode){
  859. this.formData.locationCodeIn = res.selectData.locationCode;
  860. this.formData.locationNameIn = res.selectData.locationName;
  861. }
  862. if(res.selectData.palletCode){
  863. this.formData.palletCodeIn = res.selectData.palletCode;
  864. this.formData.palletNameIn = res.selectData.palletName;
  865. }
  866. break;
  867. case "tpIn": // 托盘
  868. this.formData.palletCodeIn = res.selectData.palletCode;
  869. this.formData.palletNameIn = res.selectData.palletName;
  870. if(res.selectData.warehouseCode){
  871. this.formData.warehouseCodeIn = res.selectData.warehouseCode;
  872. this.formData.warehouseNameIn = res.selectData.warehouseName;
  873. }
  874. if(res.selectData.locationCode){
  875. this.formData.locationCodeIn = res.selectData.locationCode;
  876. this.formData.locationNameIn = res.selectData.locationName;
  877. }
  878. this.formData.packageCodeIn = '';
  879. this.formData.packageNameIn = '';
  880. break;
  881. case "stock": // 其它单据
  882. let billType = this.billTypeOption.find(item => item.value == res.selectData.billTypeCode);
  883. this.formData = {
  884. billTypeCode: billType.value,
  885. billTypeName: billType.text,
  886. taskBillTypeCode: billType.taskValue,
  887. isControlTask: billType.isControlTask,
  888. taskMoveId: res.selectData.taskMoveId,
  889. taskMoveCode: res.selectData.taskMoveCode,
  890. deptCodeOut: res.selectData.deptCodeOut,
  891. deptNameOut: res.selectData.deptNameOut,
  892. deptCodeIn: res.selectData.deptCodeIn,
  893. deptNameIn: res.selectData.deptNameIn,
  894. employeeCodeOut: res.selectData.employeeCodeOut,
  895. employeeNameOut: res.selectData.employeeNameOut,
  896. employeeCodeIn: res.selectData.employeeCodeIn,
  897. employeeNameIn: res.selectData.employeeNameIn,
  898. warehouseCodeOut: res.selectData.warehouseCodeOut,
  899. warehouseNameOut: res.selectData.warehouseNameOut,
  900. warehouseCodeIn: res.selectData.warehouseCodeIn,
  901. warehouseNameIn: res.selectData.warehouseNameIn,
  902. extendName01: res.selectData.extendName01,
  903. extendCode01: res.selectData.extendCode01,
  904. extendName02: res.selectData.extendName02,
  905. extendCode02: res.selectData.extendCode02,
  906. extendName03: res.selectData.extendName03,
  907. extendCode03: res.selectData.extendCode03,
  908. extendName04: res.selectData.extendName04,
  909. extendCode04: res.selectData.extendCode04,
  910. extendName05: res.selectData.extendName05,
  911. extendCode05: res.selectData.extendCode05,
  912. appGroupId: res.selectData.appGroupId,
  913. // ===== 以下 保存时转化为 wmsStockOutsList=====
  914. locationCodeOut: "",
  915. locationNameOut: "",
  916. locationCodeIn: "",
  917. locationNameIn: "",
  918. labelCode: "",
  919. materialCode: "",
  920. materialName: "",
  921. batch: "",
  922. palletCodeOut: "",
  923. palletNameOut: "",
  924. palletCodeIn: "",
  925. palletNameIn: "",
  926. unitCode: "",
  927. unitName: "",
  928. stockQty: "",
  929. rwQty: "",
  930. batch1: "",
  931. batch2: "",
  932. materialSpecification: "",
  933. }
  934. break;
  935. default:
  936. break;
  937. }
  938. },
  939. getSendDataTaskMoves(res){ // 任务物料多行时,选择任务行回调
  940. this.isNewTaskMaterial = false;
  941. this.tempTaskMovesId = res.wmsTaskMoves.id;
  942. },
  943. searchIconClick(type){ // easyinput后面放大镜点击
  944. switch (type){
  945. case "task": // 任务编码
  946. this.$refs.rwbmPopup.showPopup();
  947. break;
  948. case "deptOut": // 出部门
  949. this.$refs.bmOutPopup.showPopup();
  950. break;
  951. case "deptIn": // 人部门
  952. this.$refs.bmInPopup.showPopup();
  953. break;
  954. case "emplOut": // 出职员
  955. this.$refs.zyOutPopup.showPopup();
  956. break;
  957. case "emplIn": // 入职员
  958. this.$refs.zyInPopup.showPopup();
  959. break;
  960. case "ext01": // 出类别
  961. this.$refs.sflbOutPopup.showPopup();
  962. break;
  963. case "ext02": // 入类别
  964. this.$refs.sflbInPopup.showPopup();
  965. break;
  966. case "custIn": // 客户
  967. this.$refs.khInPopup.showPopup();
  968. break;
  969. case "ext04": // 审核人
  970. this.$refs.shrPopup.showPopup();
  971. break;
  972. case "locaOut": // 移出货位
  973. this.$refs.locaOutPopup.showPopup();
  974. break;
  975. case "locaIn": // 移入货位
  976. this.$refs.locaInPopup.showPopup();
  977. break;
  978. case "pallIn": // 移入托盘
  979. this.$refs.tpInPopup.showPopup();
  980. break;
  981. case "packIn": // 移入包装
  982. this.$refs.bzInPopup.showPopup();
  983. break;
  984. case "wareOut": // 移出仓库
  985. this.$refs.wareOutPopup.showPopup();
  986. break;
  987. case "wareIn": // 移入仓库
  988. this.$refs.wareInPopup.showPopup();
  989. break;
  990. default:
  991. break;
  992. }
  993. },
  994. remarkGetFocus(){
  995. this.remarkFocus = false;
  996. this.$nextTick(() => {
  997. this.remarkFocus = true
  998. })
  999. },
  1000. setScan(str){//赋值条码框 光标聚焦
  1001. this.barCode = str + "|";
  1002. this.remarkGetFocus();
  1003. },
  1004. bqslInputHandle(value){ //数量输入完成校验
  1005. let rwsl = this.formData.rwQty;
  1006. if(rwsl != ""){
  1007. if(value > parseFloat(rwsl)){
  1008. uni.showToast({
  1009. title: "数量大于可出数量",
  1010. icon: "none"
  1011. })
  1012. return;
  1013. }
  1014. }
  1015. },
  1016. handleMx(){ // 下面工具栏 明细点击 事件
  1017. this.$refs.mxPopup.showDrawer();
  1018. },
  1019. //根据index删除LabelList
  1020. delLabelList(index) {
  1021. this.labelList.splice(index, 1);
  1022. },
  1023. labelListQtyChange(item, newValue) {
  1024. item.stockQty = newValue;
  1025. },
  1026. handleSave() { //保存事件
  1027. //获取信息失败时不可以保存
  1028. if(this.isRequest==false){
  1029. uni.showToast({
  1030. title: '获取单据信息失败,请返回菜单重新进入',
  1031. icon: "none"
  1032. })
  1033. return true;
  1034. }
  1035. if (this.isShowSaveButton) {
  1036. uni.showToast({
  1037. title: '保存中,请稍等',
  1038. icon: 'none',
  1039. duration:2000
  1040. })
  1041. }
  1042. //如果唯一值空,生成唯一值
  1043. if(this.formData.appGroupId=='' || this.formData.appGroupId==null){
  1044. this.formData.appGroupId = nanoid(19)
  1045. }
  1046. let that = this;
  1047. that.$refs.form.validate().then(res => {
  1048. let wmsStockMovesList = [];
  1049. // true用普通保存;false用list保存多行
  1050. if (that.isLabelScan == true) {
  1051. let tmpWms = {
  1052. locationCodeOut: that.formData.locationCodeOut, // 移出货位
  1053. locationCodeIn: that.formData.locationCodeIn, // 移入货位
  1054. palletCodeOut: that.formData.palletCodeOut, // 移出托盘编码
  1055. palletCodeIn: that.formData.palletCodeIn, // 移入托盘编码
  1056. packageCodeOut: that.formData.packageCodeOut, // 移出包装编码
  1057. packageCodeIn: that.formData.packageCodeIn, // 移入包装编码
  1058. labelCode:that.formData.labelCode, // 标签编码
  1059. materialCode: that.formData.materialCode, // 物料编码
  1060. batch: that.formData.batch, //批号
  1061. batch1: that.formData.batch1, //批号
  1062. batch2: that.formData.batch2, //批号
  1063. unitCode: that.formData.unitCode, //单位编码
  1064. stockQty: that.formData.stockQty, // 标签数量
  1065. taskMovesId: that.formData.taskMovesId,
  1066. isLocationIn: that.formData.isLocationIn,
  1067. isPackageIn: that.formData.isPackageIn,
  1068. isPalletIn: that.formData.isPalletIn,
  1069. isPackageOut: that.formData.isPackageOut,
  1070. isPalletOut: that.formData.isPalletOut,
  1071. };
  1072. wmsStockMovesList.push(tmpWms);
  1073. } else if (that.isLabelScan == false && that.labelList.length > 0) {
  1074. wmsStockMovesList = that.labelList.map(item => ({
  1075. locationCodeOut: item.locationCode, // 移出货位
  1076. locationCodeIn: that.formData.locationCodeIn, // 移入货位
  1077. palletCodeOut: item.palletCode, // 移出托盘编码
  1078. palletCodeIn: that.formData.palletCodeIn, // 移入托盘编码
  1079. packageCodeOut: item.packageCode, // 移出包装编码
  1080. packageCodeIn: that.formData.packageCodeIn, // 移入包装编码
  1081. labelCode: item.labelCode, // 标签编码
  1082. materialCode: item.materialCode, // 物料编码
  1083. batch: item.batch, //批号
  1084. batch1: item.batch1, //批号
  1085. batch2: item.batch2, //批号
  1086. unitCode: item.unitCode, //单位编码
  1087. stockQty: item.stockQty, // 标签数量
  1088. taskMovesId: item.tasksId,
  1089. isPackageIn: that.formData.isPackageIn,
  1090. isPalletIn: that.formData.isPalletIn,
  1091. isPackageOut: that.formData.isPackageOut,
  1092. isPalletOut: that.formData.isPalletOut,
  1093. }))
  1094. } else {
  1095. return true;
  1096. }
  1097. let params = {
  1098. guid: that.getHashId,
  1099. appGroupId: that.formData.appGroupId,
  1100. status: "1",
  1101. billTypeCode: that.formData.billTypeCode, // 单据类型
  1102. taskMoveCode: that.formData.taskMoveCode,//任务
  1103. taskMoveId: that.formData.taskMoveId,
  1104. deptCodeOut: that.formData.deptCodeOut, //移出部门
  1105. deptNameOut: that.formData.deptNameOut,
  1106. deptCodeIn: that.formData.deptCodeIn, //移入部门
  1107. deptNameIn: that.formData.deptNameIn,
  1108. employeeCodeOut: that.formData.employeeCodeOut, // 移出职员
  1109. employeeNameOut: that.formData.employeeNameOut,
  1110. employeeCodeIn: that.formData.employeeCodeIn, // 移入职员
  1111. employeeNameIn: that.formData.employeeNameIn,
  1112. warehouseCodeOut: that.formData.warehouseCodeOut, // 移出仓库
  1113. warehouseNameOut: that.formData.warehouseNameOut,
  1114. warehouseCodeIn: that.formData.warehouseCodeIn, // 移入仓库
  1115. warehouseNameIn: that.formData.warehouseNameIn,
  1116. extendName01: that.formData.extendName01, // 出库类别
  1117. extendCode01: that.formData.extendCode01,
  1118. extendName02: that.formData.extendName02, // 入库类别
  1119. extendCode02: that.formData.extendCode02,
  1120. customerCodeIn: that.formData.customerCodeIn, //客户
  1121. extendCode03: that.formData.extendCode03,//要货单号
  1122. extendCode04: that.formData.extendCode04,
  1123. extendName04: that.formData.extendName04,
  1124. extendCode05: that.formData.extendCode05,
  1125. wmsStockMovesList: wmsStockMovesList,
  1126. isLocationIn: that.formData.isLocationIn,
  1127. isLocationOut: that.formData.isLocationOut,
  1128. }
  1129. checkAddStockMove(params).then(res => {
  1130. if(res.code === 200 && res.msg && res.msg != ""){
  1131. uni.vibrateLong({});
  1132. uni.showModal({
  1133. title: '提示',
  1134. content: res.msg,
  1135. success: (res) => {
  1136. if (res.confirm) {
  1137. saveStock();
  1138. } else if (res.cancel) {
  1139. // 不保存
  1140. }
  1141. }
  1142. });
  1143. }else if(res.code === 200 && res.msg == ""){
  1144. saveStock();
  1145. }
  1146. })
  1147. async function saveStock(){
  1148. await addStockMove(params).then(res => {
  1149. if(res.code === 200){
  1150. that.mxNum += that.isLabelScan ? 1 : that.labelList.length;
  1151. // 保存单号
  1152. if(res.msg !== ""){
  1153. let storageData = uni.getStorageSync('stock_key');
  1154. if(storageData){
  1155. let stockIdList = storageData.stockIdList;
  1156. stockIdList.push(res.msg);
  1157. let data = {
  1158. "stockId": res.msg,
  1159. "stockIdList": stockIdList
  1160. }
  1161. uni.setStorageSync('stock_key', data);
  1162. }else{
  1163. let tmpList = [];
  1164. tmpList.push(res.msg);
  1165. let data = {
  1166. "stockId": res.msg,
  1167. "stockIdList": tmpList
  1168. }
  1169. uni.setStorageSync('stock_key', data);
  1170. }
  1171. }
  1172. // 扫码后任务数量 - 标签数量
  1173. let rwQty = that.formData.rwQty;
  1174. if(rwQty!=0 && rwQty!="" && !isNaN(parseFloat(rwQty)) && isFinite(rwQty)){
  1175. that.formData.rwQty = rwQty - that.formData.stockQty;
  1176. }
  1177. //如果任务数量0,清空tempTaskMovesId(相同物料会继续弹窗)
  1178. if(that.formData.rwQty == 0){
  1179. that.tempTaskMovesId = ""
  1180. }
  1181. // 清空子表信息
  1182. that.EmptyEntry();
  1183. if (that.isShowSaveButton) {
  1184. uni.showToast({
  1185. title: '保存成功',
  1186. icon: 'none',
  1187. duration:2000
  1188. })
  1189. }
  1190. }else{
  1191. uni.vibrateLong({});
  1192. uni.showToast({
  1193. title: "保存失败!",
  1194. icon: "none"
  1195. })
  1196. }
  1197. }).catch((err) => {
  1198. uni.vibrateLong({});
  1199. });
  1200. }
  1201. }).catch((err) => {
  1202. uni.vibrateLong({});
  1203. });
  1204. },
  1205. getScanRwList(barCode){ // 任务扫码请求
  1206. if(this.formData.billTypeCode == '2'){ //货位转移不执行任务扫码
  1207. return true;
  1208. }
  1209. let that = this;
  1210. let params = {
  1211. billTypeCode: that.formData.taskBillTypeCode,
  1212. params: {
  1213. "barCode":barCode,
  1214. "limit":1,
  1215. "isControlTask": that.formData.isControlTask,
  1216. },
  1217. }
  1218. //扫码
  1219. listTaskMove(params).then(res => {
  1220. if(res.code === 200){
  1221. let data = res.rows ? res.rows[0] : {};
  1222. if(data && Object.keys(data).length !== 0){
  1223. // 赋值任务
  1224. this.formData.taskMoveCode = data.taskCode;
  1225. this.formData.taskMoveId = data.id;
  1226. // 赋值部门;
  1227. this.formData.deptCodeOut = data.deptCodeOut;
  1228. this.formData.deptNameOut = data.deptNameOut;
  1229. this.formData.deptCodeIn = data.deptCodeIn;
  1230. this.formData.deptNameIn = data.deptNameIn;
  1231. // 赋值职员
  1232. this.formData.employeeCodeOut = data.employeeCodeOut;
  1233. this.formData.employeeNameOut = data.employeeNameOut;
  1234. this.formData.employeeCodeIn = data.employeeCodeIn;
  1235. this.formData.employeeNameIn = data.employeeNameIn;
  1236. //仓库
  1237. this.formData.warehouseCodeIn = data.warehouseCodeIn;
  1238. this.formData.warehouseNameIn = data.warehouseNameIn;
  1239. this.formData.warehouseCodeOut = data.warehouseCodeOut;
  1240. this.formData.warehouseNameOut = data.warehouseNameOut;
  1241. //客户
  1242. this.formData.customerCodeIn = data.customerCodeIn
  1243. this.formData.customerNameIn = data.customerNameIn
  1244. //清空记录物料号
  1245. this.tempTaskMaterialCode = ""
  1246. this.tempTaskMovesId = ""
  1247. this.isNewTaskMaterial = false
  1248. }else{
  1249. uni.showToast({
  1250. title: "无数据",
  1251. icon: 'none',
  1252. })
  1253. }
  1254. }
  1255. });
  1256. },
  1257. getScanCkList(barCode,inOut){ // 仓库扫码请求
  1258. let that = this;
  1259. let params = {
  1260. status: "0", // (固定)
  1261. params: {
  1262. "barCode":barCode,
  1263. "limit":1
  1264. },
  1265. }
  1266. // 仓库网络请求
  1267. listWarehouse(params).then(res => {
  1268. if(res.code === 200){
  1269. let data = res.rows ? res.rows[0] : {};
  1270. if(data && Object.keys(data).length !== 0){
  1271. if(inOut == 'out'){
  1272. // 赋值仓库、货位
  1273. that.formData.warehouseCodeOut = data.warehouseCode;
  1274. that.formData.warehouseNameOut = data.warehouseName;
  1275. that.formData.locationCodeOut = "";
  1276. that.formData.locationNameOut = "";
  1277. that.formData.isLocationOut = data.isLocation
  1278. // 货位转移赋值移出仓库
  1279. if(that.formData.billTypeCode == '2'){
  1280. that.formData.warehouseCodeIn = data.warehouseCode;
  1281. that.formData.warehouseNameIn = data.warehouseName;
  1282. that.formData.locationCodeIn = "";
  1283. that.formData.locationNameIn = "";
  1284. // 是否移入货位 必录
  1285. let obj = {"field": "locationCodeIn","fieldName": "移入货位","required": null,"requiredCondition": null,"hidden": null,"hiddenCondition": null}
  1286. obj.required = data.isLocation == "1" ? null : 1;
  1287. obj.hidden = data.isLocation == "1" ? 1 : null;
  1288. that.formData.isLocationIn = data.isLocation
  1289. that.setFieldSetting(obj);
  1290. }
  1291. }else{
  1292. // 赋值仓库、货位
  1293. that.formData.warehouseCodeIn = data.warehouseCode;
  1294. that.formData.warehouseNameIn = data.warehouseName;
  1295. that.formData.locationCodeIn = "";
  1296. that.formData.locationNameIn = "";
  1297. // 货位转移赋值移出仓库
  1298. if(that.formData.billTypeCode == '2'){
  1299. that.formData.warehouseCodeOut = data.warehouseCode;
  1300. that.formData.warehouseNameOut = data.warehouseName;
  1301. that.formData.locationCodeOut = "";
  1302. that.formData.locationNameOut = "";
  1303. }
  1304. // 清空包装托盘
  1305. that.formData.palletCodeIn = '';
  1306. that.formData.palletNameIn = '';
  1307. that.formData.packageCodeIn = '';
  1308. that.formData.packageNameIn = '';
  1309. // 是否移入货位 必录
  1310. let obj = {"field": "locationCodeIn","fieldName": "移入货位","required": null,"requiredCondition": null,"hidden": null,"hiddenCondition": null}
  1311. obj.required = data.isLocation == "1" ? null : 1;
  1312. obj.hidden = data.isLocation == "1" ? 1 : null;
  1313. that.formData.isLocationIn = data.isLocation
  1314. that.setFieldSetting(obj);
  1315. }
  1316. // 清空子表
  1317. that.EmptyEntry();
  1318. that.formData.rwQty = "";
  1319. }else if(this.barCode){
  1320. uni.showToast({
  1321. title: "无数据",
  1322. icon: 'none',
  1323. })
  1324. }
  1325. }
  1326. });
  1327. },
  1328. //收发类别扫码请求(但不是给扫码用的,在加载时调用)
  1329. getScanSflbList(barCode,inOut){
  1330. let that = this;
  1331. let params = {
  1332. extendClassCode: inOut == 'out' ? "01.02":"01.01",
  1333. params: {
  1334. "keyWord":barCode,
  1335. "limit":1
  1336. },
  1337. }
  1338. // 收发类别网络请求
  1339. listExtend(params).then(res => {
  1340. if(res.code === 200){
  1341. let data = res.rows ? res.rows[0] : {};
  1342. if(data && Object.keys(data).length !== 0){
  1343. if(inOut == 'out'){
  1344. // 收发类别
  1345. that.formData.extendCode01 = data.extendCode;
  1346. that.formData.extendName01 = data.extendName;
  1347. }else{
  1348. // 收发类别
  1349. that.formData.extendCode02 = data.extendCode;
  1350. that.formData.extendName02 = data.extendName;
  1351. }
  1352. }else if(this.barCode){
  1353. uni.showToast({
  1354. title: "无数据",
  1355. icon: "none"
  1356. })
  1357. }
  1358. }
  1359. });
  1360. },
  1361. getScanHwList(barCode){ // 货位扫码请求
  1362. let that = this;
  1363. let params = {
  1364. status: "0", // (固定)
  1365. params: {
  1366. "barCode":barCode,
  1367. "limit":1
  1368. },
  1369. }
  1370. // 货位网络请求
  1371. listLocation(params).then(res => {
  1372. if(res.code === 200){
  1373. let data = res.rows ? res.rows[0] : {};
  1374. if(data && Object.keys(data).length !== 0){
  1375. that.EmptyEntry();
  1376. // 赋值仓库
  1377. that.formData.locationCodeIn = data.locationCode;
  1378. that.formData.locationNameIn = data.locationName;
  1379. that.formData.warehouseCodeIn = data.warehouseCode;
  1380. that.formData.warehouseNameIn = data.warehouseName;
  1381. //显示货位
  1382. that.formData.isLocationIn = 0
  1383. // 货位转移赋值移出仓库
  1384. if(that.formData.billTypeCode == '2'){
  1385. that.formData.warehouseCodeOut = data.warehouseCode;
  1386. that.formData.warehouseNameOut = data.warehouseName;
  1387. that.formData.isLocationOut = 0
  1388. }
  1389. // 清空包装托盘
  1390. that.formData.palletCodeIn = '';
  1391. that.formData.palletNameIn = '';
  1392. that.formData.packageCodeIn = '';
  1393. that.formData.packageNameIn = '';
  1394. }else{
  1395. uni.showToast({
  1396. title: "无数据",
  1397. icon: 'none',
  1398. })
  1399. }
  1400. }
  1401. });
  1402. },
  1403. //托盘扫码请求
  1404. getScanTpList(barCode){
  1405. let that = this;
  1406. let params = {
  1407. palletCode: barCode,
  1408. params: {
  1409. taskMoveId:that.formData.taskMoveId,
  1410. }
  1411. }
  1412. // 托盘网络请求
  1413. listCurrent(params).then(res => {
  1414. if (res.code === 200) {
  1415. that.isLabelScan = false;
  1416. let data = res.rows ? res.rows : [];
  1417. if (Array.isArray(data) && data.length > 0 && typeof data[0] == 'object') {
  1418. //将stockQty赋值给maxQty
  1419. data.forEach(item => {
  1420. if (item.hasOwnProperty('stockQty')) {
  1421. item.maxQty = item.stockQty;
  1422. }
  1423. })
  1424. that.labelList = data;
  1425. that.formData.warehouseCodeOut = data[0].warehouseCode;
  1426. that.formData.warehouseNameOut = data[0].warehouseName;
  1427. that.formData.locationCodeOut = data[0].locationCode;
  1428. that.formData.locationNameOut = data[0].locationName;
  1429. that.formData.palletCodeOut = data[0].palletCode;
  1430. that.formData.palletNameOut = data[0].palletName;
  1431. that.formData.palletCodeIn = data[0].palletCode;
  1432. that.formData.palletNameIn = data[0].palletName;
  1433. that.formData.labelCode = data[0].labelCode;
  1434. that.formData.stockQty = data[0].stockQty;
  1435. //如果不显示保存按钮则自动保存
  1436. if (!that.isShowSaveButton) {
  1437. setTimeout(() => {
  1438. that.handleSave();
  1439. }, 10)
  1440. }
  1441. } else {
  1442. uni.vibrateLong({});
  1443. uni.showToast({
  1444. title: "托盘无效",
  1445. icon: "none"
  1446. })
  1447. }
  1448. }
  1449. }).catch((err) => {
  1450. uni.vibrateLong({});
  1451. });
  1452. },
  1453. //包装扫码请求
  1454. getScanBzList(barCode){
  1455. let that = this;
  1456. let params = {
  1457. packageCode: barCode,
  1458. params: {
  1459. taskMoveId:that.formData.taskMoveId
  1460. }
  1461. }
  1462. // 包装网络请求
  1463. listCurrent(params).then(res => {
  1464. if (res.code === 200) {
  1465. that.isLabelScan = false;
  1466. let data = res.rows ? res.rows : [];
  1467. if (Array.isArray(data) && data.length > 0 && typeof data[0] == 'object') {
  1468. //将stockQty赋值给maxQty
  1469. data.forEach(item => {
  1470. if (item.hasOwnProperty('stockQty')) {
  1471. item.maxQty = item.stockQty;
  1472. }
  1473. })
  1474. that.labelList = data;
  1475. that.formData.warehouseCodeOut = data[0].warehouseCode;
  1476. that.formData.warehouseNameOut = data[0].warehouseName;
  1477. that.formData.locationCodeOut = data[0].locationCode;
  1478. that.formData.locationNameOut = data[0].locationName;
  1479. that.formData.palletCodeOut = data[0].palletCode;
  1480. that.formData.palletNameOut = data[0].palletName;
  1481. that.formData.palletCodeIn = data[0].palletCode;
  1482. that.formData.palletNameIn = data[0].palletName;
  1483. that.formData.packageCodeOut = data[0].packageCode;
  1484. that.formData.packageNameOut = data[0].packageName;
  1485. that.formData.packageCodeIn = data[0].packageCode;
  1486. that.formData.packageNameIn = data[0].packageName;
  1487. that.formData.labelCode = data[0].labelCode;
  1488. that.formData.stockQty = data[0].stockQty;
  1489. //如果不显示保存按钮则自动保存
  1490. if (!that.isShowSaveButton) {
  1491. setTimeout(() => {
  1492. that.handleSave();
  1493. }, 10)
  1494. }
  1495. } else {
  1496. uni.vibrateLong({});
  1497. uni.showToast({
  1498. title: "包装无效",
  1499. icon: "none"
  1500. })
  1501. }
  1502. }
  1503. }).catch((err) => {
  1504. uni.vibrateLong({});
  1505. });
  1506. },
  1507. async getScanBqList(barCode){ // 标签扫码请求
  1508. let that = this;
  1509. if(this.formData.warehouseNameOut==''){
  1510. uni.showToast({
  1511. title: "请先选择移出仓库",
  1512. icon: "none",
  1513. duration: 3000
  1514. })
  1515. return true;
  1516. }
  1517. let params = {
  1518. // status: "0", //固定
  1519. params: {
  1520. "barCode":barCode,
  1521. "limit":1,
  1522. "noLocationCode":this.formData.locationCodeIn,
  1523. "taskMoveId":this.formData.taskMoveId,
  1524. "tempTaskMaterialCode":this.tempTaskMaterialCode,
  1525. "tempTaskMovesId":this.tempTaskMovesId
  1526. },
  1527. warehouseCode: this.formData.warehouseCodeOut,
  1528. }
  1529. // 标签网络请求
  1530. try {
  1531. const res = await listCurrent(params);
  1532. if(res.code === 200){
  1533. this.isLabelScan = true;
  1534. this.labelList = [];
  1535. let data = res.rows ? res.rows[0] : {};
  1536. if(data && Object.keys(data).length !== 0){
  1537. // 赋值标签数量
  1538. this.formData.stockQty = data.stockQty;
  1539. // 赋值任务数量
  1540. this.formData.rwQty = data.stockQty < data.tasksQty ? data.stockQty : data.tasksQty;
  1541. // 赋值标签
  1542. this.formData.labelCode = data.labelCode;
  1543. //赋值任务
  1544. this.formData.taskMovesId = data.tasksId
  1545. this.formData.taskMovesCode = data.tasksCode
  1546. // 赋值物料编码,物料名称 , 规格
  1547. this.formData.materialName = data.materialName;
  1548. this.formData.materialCode = data.materialCode;
  1549. this.formData.materialSpecification = data.materialSpecification; //规格
  1550. // 赋值批号
  1551. this.formData.batch = data.batch;
  1552. this.formData.batch1 = data.batch1;
  1553. this.formData.batch2 = data.batch2;
  1554. // 赋值单位
  1555. this.formData.unitCode = data.unitCode;
  1556. this.formData.unitName = data.unitName;
  1557. // 赋值货位
  1558. this.formData.locationCodeOut = data.locationCode;
  1559. this.formData.locationNameOut = data.locationName;
  1560. // 赋值托、包装
  1561. this.formData.palletCodeOut = data.palletCode;
  1562. this.formData.palletNameOut = data.palletName;
  1563. this.formData.packageCodeOut = data.packageCode;
  1564. //赋值是否托、是否包装
  1565. this.formData.isPackageOut = data.isPackage
  1566. this.formData.isPalletOut = data.isPallet
  1567. this.formData.isPackageIn = data.isPackage
  1568. this.formData.isPalletIn = data.isPallet
  1569. // 查询物料对应任务子表信息。任务不为空、物料和记录的物料不同
  1570. if(this.formData.taskMoveCode!=null && this.formData.taskMoveCode!="" && this.tempTaskMaterialCode!=data.materialCode){
  1571. this.tempTaskMaterialCode=this.formData.materialCode
  1572. this.tempTaskMovesId=""
  1573. //查询有多行时显示弹窗,不执行自动保存
  1574. //this.isNewTaskMaterial=true
  1575. this.isNewTaskMaterial = await this.$refs.selectTaskMoves.getRwbmList();
  1576. }
  1577. //如果不显示保存按钮则自动保存
  1578. if (!this.isShowSaveButton && this.isNewTaskMaterial == false) {
  1579. setTimeout(() => {
  1580. this.handleSave();
  1581. },10)
  1582. }
  1583. }else{
  1584. uni.vibrateLong({});
  1585. uni.showToast({
  1586. title: "标签无效或已扫描",
  1587. icon: "none"
  1588. })
  1589. }
  1590. }
  1591. } catch (err) {
  1592. uni.vibrateLong({});
  1593. }
  1594. },
  1595. specialScan(name){ //到货单号焦点触发,
  1596. if(name){
  1597. this.specialScanName=name
  1598. }else{
  1599. this.specialScanName="条码"
  1600. }
  1601. },
  1602. handleAuto(){
  1603. if(this.autoButtonTitle === "自动"){ //手动
  1604. this.autoButtonTitle = "手动";
  1605. this.isShowSaveButton = true;
  1606. }else{ //自动
  1607. this.autoButtonTitle = "自动";
  1608. this.isShowSaveButton = false;
  1609. }
  1610. },
  1611. handleBack(){
  1612. uni.showModal({
  1613. title: '提示',
  1614. content: '确认返回?',
  1615. success: function (res) {
  1616. if (res.confirm) {
  1617. uni.navigateBack();
  1618. } else if (res.cancel) {
  1619. }
  1620. }
  1621. });
  1622. },
  1623. getSendNum(num){
  1624. this.mxNum = num;
  1625. if(num == 0){
  1626. this.formData.appGroupId=''
  1627. }
  1628. },
  1629. SendNumEmpty(){
  1630. let that = this;
  1631. if(this.mxNum>0){
  1632. uni.showModal({
  1633. title: '新单',
  1634. content: '是否要明细归零,录入新单?',
  1635. success: function (res) {
  1636. if (res.confirm) {
  1637. that.mxNum = 0;
  1638. let data = {
  1639. "stockId": "",
  1640. "stockIdList": []
  1641. }
  1642. uni.setStorageSync('stock_key', data);
  1643. //清空唯一值
  1644. that.formData.appGroupId = '';
  1645. }
  1646. }
  1647. });
  1648. }
  1649. },
  1650. EmptyTest(){//清空任务
  1651. this.formData.taskMovesCode = "";
  1652. this.formData.taskMovesId = "";
  1653. },
  1654. EmptyEntry(){ //清空子表信息
  1655. this.formData.labelCode = "";
  1656. this.formData.taskMovesCode = "";
  1657. this.formData.taskMovesId = "";
  1658. this.formData.materialCode = "";
  1659. this.formData.materialName = "";
  1660. this.formData.batch = "";
  1661. this.formData.unitCode = "";
  1662. this.formData.unitName = "";
  1663. this.formData.stockQty = "";
  1664. // this.formData.rwQty = "";
  1665. this.formData.batch1 = "";
  1666. this.formData.locationCodeOut = "";
  1667. this.formData.locationNameOut = "";
  1668. // this.formData.locationCodeIn = "";
  1669. // this.formData.locationNameIn = "";
  1670. this.formData.palletCodeOut = "";
  1671. this.formData.palletNameOut = "";
  1672. this.formData.palletCodeIn = "";
  1673. this.formData.palletNameIn = "";
  1674. this.formData.packageCodeOut = "";
  1675. this.formData.packageNameOut = "";
  1676. this.formData.packageCodeIn = "";
  1677. this.formData.packageNameIn = "";
  1678. this.formData.materialSpecification = "";
  1679. },
  1680. rulesStar(str){
  1681. let rules=this.rules;
  1682. if(rules[str] && rules[str].rules[0] && rules[str].rules[0].required){
  1683. return true;
  1684. }else{
  1685. return false;
  1686. }
  1687. },
  1688. fieldHidden(str){
  1689. let rules=this.rules;
  1690. if(rules[str] && rules[str].rules[0] && rules[str].rules[0].hidden){
  1691. return !true;
  1692. }else{
  1693. return !false;
  1694. }
  1695. },
  1696. setFieldSetting(obj){ //修改字段设置
  1697. let index = this.fieldSetting.findIndex(item => item.field == obj.field);
  1698. if (index !== -1) {
  1699. // 如果找到匹配项,则使用 obj 的属性覆盖 fieldSetting 中的相应属性
  1700. Object.assign(this.fieldSetting[index], obj);
  1701. } else {
  1702. // 如果没有找到匹配项,则将 obj 添加到 fieldSetting 中
  1703. this.fieldSetting.push(obj);
  1704. }
  1705. },
  1706. formatDate(date,type) { //date:日期字符串('2024-12-12 10-30-01' 或 '2024-12-12 10:30');type:0('2024-12-12 10-30-01')和1('2024-12-12 10:30'),指定返回的格式。
  1707. return date;
  1708. }
  1709. },
  1710. computed: {
  1711. rules() {
  1712. let form = this.formData;
  1713. let rules = {};
  1714. if(!Array.isArray(this.fieldSetting) && this.fieldSetting.length>0){
  1715. return rules;
  1716. }
  1717. //转数组
  1718. for(let i=0;i<this.fieldSetting.length;i++){
  1719. let field = this.fieldSetting[i];
  1720. rules[field.field] = {
  1721. rules: [{ required: false, errorMessage: field.fieldName + '不能为空', hidden: false }],
  1722. }
  1723. if(field.required==1 && field.field){ //判断是否必录
  1724. //判断是否必录
  1725. if(!field.requiredCondition){ //条件为空
  1726. rules[field.field].rules[0].required = true;
  1727. }else{ //有条件;form中对应属性满足正则
  1728. //先赋值true;正则不满足再赋值false
  1729. rules[field.field].rules[0].required = true;
  1730. //判断必录用正则数组
  1731. let regArr = [];
  1732. try {
  1733. if(field.requiredCondition){
  1734. let arr = JSON.parse(field.requiredCondition);
  1735. if(arr!=null){
  1736. regArr = arr.map(([key, value]) => [key, new RegExp(value)]);
  1737. }
  1738. }
  1739. }catch(err) {
  1740. console.error("err",err)
  1741. }
  1742. for(let j=0;j<regArr.length;j++){
  1743. if(regArr[j].length==2 && regArr[j][1].test( form[regArr[j][0]] )){
  1744. rules[field.field].rules[0].required = true;
  1745. }else{
  1746. rules[field.field].rules[0].required = false;
  1747. break;
  1748. }
  1749. }
  1750. }
  1751. }
  1752. if(field.hidden==1 && field.field){ //判断是否隐藏
  1753. //判断是否隐藏
  1754. if(!field.hiddenCondition){ //条件为空
  1755. rules[field.field].rules[0].hidden = true;
  1756. }else{ //有条件;form中对应属性满足正则
  1757. //先赋值true;正则不满足再赋值false
  1758. rules[field.field].rules[0].hidden = true;
  1759. //判断隐藏用正则数组
  1760. let regArr = [];
  1761. try {
  1762. if(field.hiddenCondition){
  1763. let arr = JSON.parse(field.hiddenCondition);
  1764. if(arr!=null){
  1765. regArr = arr.map(([key, value]) => [key, new RegExp(value)]);
  1766. }
  1767. }
  1768. }catch(err) {
  1769. console.error("err",err)
  1770. }
  1771. for(let j=0;j<regArr.length;j++){
  1772. if(regArr[j].length==2 && regArr[j][1].test( form[regArr[j][0]] )){
  1773. rules[field.field].rules[0].hidden = true;
  1774. }else{
  1775. rules[field.field].rules[0].hidden = false;
  1776. break;
  1777. }
  1778. }
  1779. }
  1780. }
  1781. }
  1782. return rules;
  1783. },
  1784. getHashId(){
  1785. //生成哈希值
  1786. const crypto = require('crypto');
  1787. function hashString(str) {
  1788. const hash = crypto.createHash('sha256');
  1789. hash.update(str);
  1790. return hash.digest('hex');
  1791. }
  1792. //null和undefined返回空
  1793. function IFNULL(str){
  1794. return (str==null || str==undefined) ? "" : str + "";
  1795. }
  1796. //使用头信息和nanoid来生成唯一值
  1797. let groupJson = {
  1798. appGroupId : this.formData.appGroupId,
  1799. billTypeCode : IFNULL(this.formData.billTypeCode),
  1800. taskMoveId : '',
  1801. deptCodeIn : IFNULL(this.formData.deptCodeIn),
  1802. deptCodeOut : IFNULL(this.formData.deptCodeOut),
  1803. employeeCodeIn : IFNULL(this.formData.employeeCodeIn),
  1804. employeeCodeOut : IFNULL(this.formData.employeeCodeOut),
  1805. warehouseCodeIn : IFNULL(this.formData.warehouseCodeIn),
  1806. warehouseCodeOut : IFNULL(this.formData.warehouseCodeOut),
  1807. extendCode01 : IFNULL(this.formData.extendCode01),
  1808. extendCode02 : IFNULL(this.formData.extendCode02),
  1809. extendCode03 : IFNULL(this.formData.extendCode03),
  1810. extendCode04 : IFNULL(this.formData.extendCode04),
  1811. extendCode05 : IFNULL(this.formData.extendCode05),
  1812. }
  1813. let groupStr = JSON.stringify(groupJson)
  1814. const hash = hashString(groupStr)
  1815. return hash
  1816. },
  1817. sumlabelList() {// 汇总标签数组,每个物料的总量,用来卡片显示任务后面括弧超多少
  1818. const summary = {};
  1819. const data = this.labelList;
  1820. // 遍历数据数组
  1821. data.forEach(item => {
  1822. const materialCode = item.materialCode;
  1823. const stockQty = item.stockQty;
  1824. // 如果summary中已经有了这个materialCode的条目,则累加stockQty
  1825. if (summary[materialCode]) {
  1826. summary[materialCode] += stockQty;
  1827. } else {
  1828. // 否则创建一个新的条目
  1829. summary[materialCode] = stockQty;
  1830. }
  1831. });
  1832. return summary;
  1833. },
  1834. }
  1835. }
  1836. </script>
  1837. <style>
  1838. @import "@/static/scss/stock.css";
  1839. </style>