addStock.vue 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="新增入库单" @clickLeft="back">
  4. <!-- @clickRight="handleScan"
  5. right-icon="scan"
  6. > -->
  7. <!--右菜单-->
  8. <template slot="float">
  9. <!-- <view class="nav-icon-caozuo rightNav" @click="getsure">
  10. <u-button type="success" size="small" class="u-reset-button" text="确定"></u-button>
  11. </view> -->
  12. </template>
  13. </uni-nav-bar>
  14. <u-form labelPosition="left" :model="formData" :rules="rules" ref="formRef" labelWidth="240" labelAlign="right"
  15. class="baseForm">
  16. <u-form-item label="物品类型" class="required-form" borderBottom prop="assetTypeName">
  17. <view :style="{ color: assetTypeName ? 'black' : '#c0c4cc' }" class="assetType_box" @click="openPicker">
  18. {{ assetTypeName ? assetTypeName : '请选择产品类型' }}
  19. </view>
  20. </u-form-item>
  21. <u-form-item label="来源单据" prop="documentSource" borderBottom>
  22. <u-input type="text" placeholder="请输入" v-model="formData.sourceBizNo" @click.native="goToRequisition" />
  23. </u-form-item>
  24. <u-form-item label="入库类型" class="required-form" prop="bizType" borderBottom>
  25. <uni-data-select v-model="formData.bizType" :localdata="sceneState"
  26. @change="changeType"></uni-data-select>
  27. <!-- <picker :disabled="!!(productList && productList.length)"
  28. @change="handlePicker(e, sceneState, 'bizType')" :value="pickerIndex" :range="sceneState"
  29. range-key="text">
  30. <u-input :value="sceneStateFilter(formData.bizType)"
  31. :disableColor="!!(productList && productList.length) ? '#F5F7FA' : '#fff'" placeholder="请选择"
  32. disabled type="select" />
  33. </picker> -->
  34. <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
  35. </u-form-item>
  36. <u-form-item label="入库时间" prop="storageTime" borderBottom>
  37. <view class="assetType_box" @click="timeShow = true">{{ storageTime ? formatter(storageTime) : '请选择' }}
  38. </view>
  39. </u-form-item>
  40. <u-form-item label="入库登记人" prop="createUserName" borderBottom>
  41. <u-input disableColor="#ffffff" :value="formData.extInfo.createUserName" placeholder="请选择" disabled
  42. type="text" />
  43. </u-form-item>
  44. <!-- <u-form-item label="送货人" prop="deliveryName" borderBottom>
  45. <u-input type="text" placeholder="请输入" v-model="formData.fromUser" />
  46. </u-form-item>
  47. <u-form-item label="送货人联系方式" prop="deliveryPhone" borderBottom>
  48. <u-input type="text" placeholder="请输入" v-model="formData.extInfo.deliveryPhone" />
  49. </u-form-item> -->
  50. <u-form-item label="备注" prop="remark" borderBottom>
  51. <u-input disableColor="#ffffff" v-model="formData.remark" placeholder="请输入内容" type="text" />
  52. </u-form-item>
  53. </u-form>
  54. <uni-collapse ref="collapse" v-model="collapseOpen">
  55. <uni-collapse-item :typeOpen="1" title="" name="collapse1" :open="true" :key="detailOpen"
  56. :show-animation="true">
  57. <template v-slot:title>
  58. <view class="detail-box flex_between">
  59. <view data-v-41027c34="" class="uni-collapse-item__title-wrap">
  60. <view data-v-41027c34=""
  61. class="uni-collapse-item__title-box uni-collapse-item__title-box-base">
  62. <text data-v-41027c34="" class="tag tag-base"><text></text></text>
  63. <text data-v-41027c34="" class="uni-collapse-item__title-text"><text>入库明细</text></text>
  64. </view>
  65. </view>
  66. <u-button type="primary" size="small" text="扫码添加"
  67. @click.native.stop="goToScanCodeList"></u-button>
  68. <u-button type="success" size="small" class="selectEnterType" text="手动添加"
  69. @click.native.stop="selectType"></u-button>
  70. </view>
  71. </template>
  72. <u-form labelPosition="left" :model="{ productList: productList }" ref="lisrFormRef" labelWidth="160"
  73. :rules="listRules" errorType="none" labelAlign="right" :labelStyle="{
  74. fontSize: '28rpx'
  75. }">
  76. <view class="listContent">
  77. <view class="listBox" v-for="(item, index) in productList" :key="index">
  78. <view class="listTit flex_between">
  79. <view class="name">{{ item.categoryName }}</view>
  80. <view class="btn">
  81. <u-button v-if="item.isSave" type="primary" size="small" :hairline="true" text="编辑"
  82. @click="listEdit(index)"></u-button>
  83. <u-button v-else type="primary" size="small" :hairline="true" text="保存"
  84. @click="listSave(item, index)"></u-button>
  85. <u-button type="error" size="small" :hairline="true" text="删除"
  86. @click="getDelete(index)"></u-button>
  87. </view>
  88. </view>
  89. <view class="listCont" :class="{ save: item.isSave }">
  90. <view class="item w100">
  91. <u-form-item :label="`物品编码`">
  92. {{ item.categoryCode }}
  93. </u-form-item>
  94. </view>
  95. <view class="item w100">
  96. <u-form-item label="包装规格" prop="packingSpecificationLabel">
  97. <u-tag style="margin-right: 5rpx" v-for="ite in item.packingSpecificationLabel"
  98. :text="ite"></u-tag>
  99. </u-form-item>
  100. </view>
  101. <view class="item">
  102. <u-form-item label="批次号" :prop="`productList.${index}.batchNo`"
  103. class="required-form">
  104. <!-- <u--input :disabled="item.isSave" placeholder="请输入" border="surround"
  105. v-model="item.batchNo"></u--input> -->
  106. <u-input :disabled="item.isSave" placeholder="请输入" style="height: 30px;"
  107. v-model="item.batchNo" />
  108. </u-form-item>
  109. </view>
  110. <view class="item">
  111. <u-form-item label="数量" :prop="`productList.${index}.packingQuantity`"
  112. class="aa required-form">
  113. <u--input :disabled="item.isSave" placeholder="请输入" border="surround"
  114. v-model="item.packingQuantity"
  115. @change="computeNum(item, index, true)"></u--input>
  116. </u-form-item>
  117. </view>
  118. <view class="item">
  119. <u-form-item label="包装单位" :prop="`productList.${index}.packingUnit`"
  120. class="dd required-form">
  121. <!-- <u--input :disabled="item.isSave" placeholder="请选择" border="surround"
  122. v-model="item.packingUnit"
  123. @click.native="showPackingUnitPicker(item, index)"></u--input> -->
  124. <view
  125. :style="{ color: item.packingUnit ? 'black' : '#c0c4cc',marginLeft:'9px' }"
  126. class="assetType_box" :disabled="item.isSave"
  127. @click="showPackingUnitPicker(item, index)">
  128. {{ item.packingUnit ? item.packingUnit : '请选择' }}
  129. </view>
  130. </u-form-item>
  131. </view>
  132. <view class="item">
  133. <u-form-item label="仓库" :prop="`productList.${index}.warehouseName`"
  134. class="dd required-form">
  135. <!-- <u--input :disabled="item.isSave" placeholder="请选择" border="surround"
  136. v-model="item.warehouseName"
  137. @click.native="showWarehousePicker(index)"></u--input> -->
  138. <view
  139. :style="{ color: item.warehouseName ? 'black' : '#c0c4cc',marginLeft:'9px' }"
  140. class="assetType_box" :disabled="item.isSave"
  141. @click="showWarehousePicker( index)">
  142. {{ item.warehouseName ? item.warehouseName : '请选择' }}
  143. </view>
  144. </u-form-item>
  145. </view>
  146. <view class="item w100">
  147. <u-form-item label="供应商" :prop="`productList.${index}.supplierName`" class="dd">
  148. <!-- <u--input :disabled="item.isSave" placeholder="请选择" border="surround"
  149. v-model="item.supplierName"
  150. @click.native="showSupplierPicker(item, index)"></u--input> -->
  151. <view
  152. :style="{ color: item.supplierName ? 'black' : '#c0c4cc',marginLeft:'9px' }"
  153. class="assetType_box" :disabled="item.isSave"
  154. @click="showSupplierPicker(item, index)">
  155. {{ item.supplierName ? item.supplierName : '请选择' }}
  156. </view>
  157. </u-form-item>
  158. </view>
  159. <view class="flex_between w100">
  160. <view class="item">
  161. <u-form-item label="计量数量"
  162. prop="measureQuantity">{{ item.measureQuantity }}</u-form-item>
  163. </view>
  164. <view class="item">
  165. <u-form-item label="计量单位"
  166. prop="measureUnit">{{ item.measureUnit }}</u-form-item>
  167. </view>
  168. </view>
  169. <view class="flex_between w100">
  170. <view class="item">
  171. <u-form-item label="重量" prop="weight">{{ item.weight }}</u-form-item>
  172. </view>
  173. <view class="item">
  174. <u-form-item label="重量单位" prop="weightUnit">{{ item.weightUnit }}</u-form-item>
  175. </view>
  176. </view>
  177. <view class="item">
  178. <u-form-item label="是否拆包"
  179. prop="isUnpack">{{ item.isUnpack ? '是' : '否' }}</u-form-item>
  180. </view>
  181. </view>
  182. <view class="selectTime" v-if="item.outInDetailRecordRequestList.length > 0">
  183. <view class="title">包装列表</view>
  184. <view class="timeBox">
  185. <u-button class="firstBtn" size="small" type="primary" text="选择时间类型"
  186. @click="timeTypeShow = true"></u-button>
  187. <u-button type="warning" size="small"
  188. :text="`批量设置${currentDateType?curDateTypeLabel[currentDateType]:''}`"
  189. @click="typeTimeClick(index)"></u-button>
  190. </view>
  191. </view>
  192. <u-list @scrolltolower="scrolltolower" class="z_list" style="height: 100% !important">
  193. <view class="material rx-ss" v-for="(ite, idx) in item.outInDetailRecordRequestList"
  194. :key="idx">
  195. <!-- <view class="left rx-ss" @click="deletePacking(index, idx)">
  196. <uni-icons custom-prefix="iconfont" type="icon-shanchu" size="20" color="#fa3534"></uni-icons>
  197. </view> -->
  198. <view class="content_table">
  199. <view class="item">
  200. <view class="lable rx-cc">序号</view>
  201. <view class="content">{{ idx + 1 }}</view>
  202. </view>
  203. <view class="item">
  204. <view class="lable rx-cc">包装编码</view>
  205. <view class="content">{{ ite.packageNo }}</view>
  206. </view>
  207. <view class="item">
  208. <view class="lable rx-cc">包装数量({{ ite.packingUnit }})</view>
  209. <view class="content">{{ ite.packingQuantity }}</view>
  210. </view>
  211. <view class="item">
  212. <view class="lable rx-cc">计量数量({{ ite.measureUnit }})</view>
  213. <view class="content">{{ ite.measureQuantity }}</view>
  214. </view>
  215. <view class="item">
  216. <view class="lable rx-cc">物料代号</view>
  217. <view class="content input_box"><u--input clearable placeholder="请输入"
  218. border="surround" v-model="ite.materielDesignation"></u--input>
  219. </view>
  220. </view>
  221. <view class="item">
  222. <view class="lable rx-cc">客户代号</view>
  223. <view class="content input_box"><u--input clearable placeholder="请输入"
  224. border="surround" v-model="ite.clientCode"></u--input></view>
  225. </view>
  226. <view class="item">
  227. <view class="lable rx-cc">刻码</view>
  228. <view class="content input_box"><u--input clearable placeholder="请输入"
  229. border="surround" v-model="ite.engrave"></u--input></view>
  230. </view>
  231. <view class="item">
  232. <view class="lable rx-cc">重量({{ ite.weightUnit }})</view>
  233. <view class="content input_box">
  234. <u--input clearable placeholder="请输入" border="surround"
  235. v-model="ite.weight"
  236. @change="weightInput($event, ite, index)"></u--input>
  237. </view>
  238. </view>
  239. <view class="item">
  240. <view class="lable rx-cc">质检状态</view>
  241. <view class="content" @click="statusClick(index, idx)">
  242. {{ qualityResults[ite.status] }}
  243. </view>
  244. </view>
  245. <view class="item">
  246. <view class="lable rx-cc">{{ curDateTypeLabel[currentDateType] }}</view>
  247. <view class="content input_box">
  248. <u--input clearable placeholder="请选择" border="surround"
  249. v-model="ite[currentDateType]"
  250. @click.native="typeTimeClick(index, idx)"></u--input>
  251. </view>
  252. </view>
  253. </view>
  254. </view>
  255. </u-list>
  256. </view>
  257. </view>
  258. </u-form>
  259. </uni-collapse-item>
  260. </uni-collapse>
  261. <view class="footBox">
  262. <view class="reg" @click="submit">
  263. <uni-icons custom-prefix="iconfont" size="20" color="#fff"></uni-icons>
  264. 提交
  265. </view>
  266. </view>
  267. <!-- 选择物品类型 -->
  268. <ba-tree-picker ref="treePicker" :multiple="true" @select-change="confirm" title="选择物品类型"
  269. :localdata="goodsLists" valueKey="id" textKey="name" childrenKey="child" />
  270. <!-- 选择入库时间 -->
  271. <u-datetime-picker @confirm="timeConfirm" @cancel="timeCancel" :show="timeShow" v-model="storageTime"
  272. mode="datetime"></u-datetime-picker>
  273. <!-- 选择包装单位 -->
  274. <u-picker :show="packingUnitsShow" visibleItemCount="10" :columns="currentPackingSpecificationOption"
  275. keyName="conversionUnit" @confirm="selectPackingUnitInfo" @cancel="packingUnitsShow = false"
  276. title="选择包装单位"></u-picker>
  277. <!-- 选择供应商单位 -->
  278. <u-picker :show="suppliersShow" visibleItemCount="10" :columns="currentSupplierListOption" keyName="name"
  279. @confirm="selectSuppliersInfo" @cancel="suppliersShow = false" title="选择供应商"></u-picker>
  280. <!-- 选择仓库 -->
  281. <u-picker :show="warehouseShow" visibleItemCount="10" :columns="warehouseListOption" keyName="name"
  282. @confirm="selectWarehouseInfo" @cancel="warehouseShow = false" title="选择仓库"></u-picker>
  283. <!-- 选择时间类型 -->
  284. <u-picker :show="timeTypeShow" visibleItemCount="10" :columns="timeTypeOption" keyName="name"
  285. @confirm="selectTimeTypeInfo" @cancel="timeTypeShow = false" title="选择时间类型"></u-picker>
  286. <!-- 选择生产/采购日期 -->
  287. <u-datetime-picker @confirm="typeTimeConfirm" @cancel="typeTimeShow = false" :show="typeTimeShow"
  288. v-model="currentTypeTime" mode="datetime"></u-datetime-picker>
  289. <!-- 选择质检状态 -->
  290. <u-picker :show="statusShow" visibleItemCount="10" :columns="qualityResultsOption" keyName="label"
  291. @confirm="selectStautsInfo" @cancel="statusShow = false" title="选择质检状态"></u-picker>
  292. </view>
  293. </template>
  294. <script>
  295. // import ScanCode from '@/components/ScanCode.vue'
  296. import {
  297. getTreeByGroup,
  298. contactQueryByCategoryIdsAPI,
  299. getCode,
  300. getCategoryPackageDisposition,
  301. getWarehouseList,
  302. getAssetNum,
  303. storage,
  304. qualityInspectionTwo,
  305. submitTwo
  306. } from '@/api/warehouseManagement'
  307. import {
  308. getByCode
  309. } from '@/api/pda/common'
  310. import dayjs from 'dayjs'
  311. import {
  312. sceneState
  313. } from '../common'
  314. import {
  315. post,
  316. postJ,
  317. get,
  318. getJ
  319. } from '@/utils/api.js'
  320. import WarehouseChoose from '@/components/WarehouseChoose'
  321. import {
  322. warehousingType,
  323. inputStatus,
  324. emergencyState,
  325. warehousingMaterialListTable,
  326. getDictName,
  327. materialType
  328. } from '../enum.js'
  329. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  330. // import addDetails from '@/components/addDetails'
  331. import UploadFileNew from '@/components/UploadFileNew'
  332. // import { getRuleNo } from '@/utils/utils.js'
  333. import {
  334. tableHeader
  335. } from '../common'
  336. // import dictMixins from '@/mixins/dictMixins.js'
  337. export default {
  338. components: {
  339. WarehouseChoose,
  340. baTreePicker,
  341. UploadFileNew
  342. },
  343. // mixins: [dictMixins],
  344. data() {
  345. return {
  346. goodsLists: [], // 物品类型
  347. assetTypeName: '', // 物品类型名称
  348. timeShow: false,
  349. packingSpecificationOption: [], // 包装规格
  350. currentPackingSpecificationOption: [], // 当前包装规格
  351. currentSupplierListOption: [], // 当前供货商
  352. warehouseListOption: [], // 仓库列表
  353. currentTypeTime: Number(new Date()), // 当前时间类型的时间
  354. storageTime: '', // 入库时间
  355. currentProductIndex: null, // 当前产品索引
  356. currentPackingIndex: null, // 当前包装索引
  357. packingUnitsShow: false,
  358. typeTimeShow: false,
  359. suppliersShow: false,
  360. warehouseShow: false,
  361. timeTypeShow: false,
  362. statusShow: false,
  363. dictCodeList: [], // 字典列表
  364. curDateType: 'purchaseDate',
  365. currentDateType: 'purchaseDate',
  366. qualityResultsOption: [
  367. [{
  368. label: '合格',
  369. value: 1
  370. },
  371. {
  372. label: '不合格',
  373. value: 2
  374. }
  375. ]
  376. ], // 质检状态 0未检 1已检
  377. qualityResults: {
  378. 1: '合格',
  379. 2: '不合格'
  380. }, // 质检结果 1合格 2不合格
  381. curDateTypeLabel: {
  382. purchaseDate: '采购日期',
  383. productionDate: '生产日期'
  384. },
  385. timeTypeOption: [
  386. [{
  387. name: '采购日期',
  388. prop: 'purchaseDate'
  389. },
  390. {
  391. name: '生产日期',
  392. prop: 'productionDate'
  393. }
  394. ]
  395. ], // 时间类型
  396. collapseOpen: 'collapse1',
  397. emergencyState,
  398. warehousingType,
  399. materialType,
  400. sceneState,
  401. inputStatus,
  402. getDictName,
  403. detailOpen: false,
  404. codeOpen: false,
  405. deptList: [], //部门
  406. supplierList: [], //供应商
  407. formData: {
  408. type: 1, // 入库
  409. bizType: '', // 入库场景
  410. storageTime: '', // 入库时间
  411. extInfo: {}, // 扩展信息
  412. sourceBizNo: '', // 来源单据编号
  413. fromUser: '', // 送货人
  414. remark: '' // 备注
  415. },
  416. statusList: [{
  417. id: 1,
  418. name: '紧急'
  419. },
  420. {
  421. id: 2,
  422. name: '中等'
  423. },
  424. {
  425. id: 1,
  426. name: '普通'
  427. }
  428. ], //紧急状态
  429. pickerIndex: 0,
  430. productList: [],
  431. userList: [],
  432. rules: {
  433. assetType: {
  434. type: 'number',
  435. required: true,
  436. message: '请选择入库产品类型',
  437. trigger: ['blur', 'change']
  438. },
  439. bizType: {
  440. type: 'number',
  441. required: true,
  442. message: '请选择入库场景',
  443. trigger: ['blur', 'change']
  444. }
  445. // contentImage: {
  446. // type: 'array',
  447. // required: true,
  448. // message: '请上传附件',
  449. // trigger: ['blur', 'change']
  450. // }
  451. },
  452. settingIndex: 0
  453. }
  454. },
  455. onShow() {
  456. // const _this = this
  457. // uni.$off('scancode') // 每次进来先 移除全局自定义事件监听器
  458. // uni.$on('scancode', function (data) {
  459. // uni.navigateBack({
  460. // delta: 1
  461. // })
  462. // _this.qrContent = data.code.trim()
  463. // _this.handleScan()
  464. // })
  465. this.collapseOpen = 'collapse1'
  466. },
  467. beforeDestroy() {
  468. uni.$off('setSelectList')
  469. uni.$off('requisitionSelect')
  470. },
  471. async onLoad(options) {
  472. await this.getListItems() // 物品类型
  473. await this.getwarehouseList() // 仓库列表
  474. await this.requireDictCode() // 字典列表
  475. // this.requestDict('物品类型')
  476. // this.getDept()
  477. // this.getSupplier()
  478. const userInfo = uni.getStorageSync('userInfo')
  479. console.log()
  480. this.formData.extInfo.createUserName = userInfo.name
  481. this.formData.createUserId = userInfo.name
  482. this.storageTime = Number(new Date())
  483. this.formData.storageTime = this.formatter(this.storageTime)
  484. // this.formData.registerId = userInfo.id
  485. uni.$on('setSelectList', async data => {
  486. if (data?.length) {
  487. this.formData.sourceBizNo = ''
  488. // 获取批次号
  489. const batchNo = await getCode('lot_number_code')
  490. // 获取供应商
  491. const supplierList = await contactQueryByCategoryIdsAPI({
  492. categoryIds: data.map(item => item.id)
  493. })
  494. // 获取包装规格
  495. let packingSpecification = await getCategoryPackageDisposition({
  496. categoryIds: data.map(item => item.id)
  497. })
  498. this.packingSpecificationOption = data.map(item => {
  499. return packingSpecification.filter(ite => item.id == ite.categoryId).sort((
  500. a, b) => a.sort - b.sort)
  501. })
  502. let productList = data.map((item, index) => {
  503. // 显示规格
  504. let packingSpecificationLabel = this.packingSpecificationOption[index]
  505. .map(item => {
  506. if (item.sort > 0) {
  507. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`
  508. }
  509. })
  510. .filter(item => !!item)
  511. return {
  512. index: this.productList.length - 1 > -1 ? this.productList[this
  513. .productList.length - 1].index + index + 1 : this.productList
  514. .length + index,
  515. categoryId: item.id, // 物品id
  516. categoryName: item.name, // 物品名称
  517. categoryCode: item.code, // 物品编码
  518. categoryModel: item.modelType, // 物品型号
  519. specification: item.specification, // 规格
  520. brandNum: item.brandNum, // 牌号
  521. batchNo: batchNo, // 批次号
  522. supplierListOptions: supplierList[item.id], // 供应商列表
  523. supplierId: '', // 供应商id
  524. supplierName: '', // 供应商名称
  525. approvalNumber: item.approvalNumber, // 批准文号
  526. packingSpecification: item.packingSpecification, // 包装规格
  527. packingSpecificationOption: this.packingSpecificationOption[
  528. index], // 包装规格选项
  529. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  530. minPackingQuantity: '', // 最小包装单元数量
  531. packingQuantity: '', // 包装数量
  532. packingUnit: '', // 包装单位
  533. measureQuantity: 0, // 计量数量
  534. measureUnit: item.measuringUnit, // 计量单位
  535. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  536. weight: 0, // 重量
  537. weightUnit: item.weightUnit, // 重量单位
  538. totalMoney: '', // 总价
  539. price: item.price, // 单价
  540. purpose: '', // 用途
  541. isUnpack: item.isUnpack, // 是否允许拆包
  542. outInDetailRecordRequestList: []
  543. }
  544. })
  545. this.productList = this.productList.concat(productList)
  546. console.log(this.productList, '------------------this.productList----111-----')
  547. setTimeout(() => {
  548. this.detailOpen = !this.detailOpen
  549. this.$refs.collapse && this.$refs.collapse.resize()
  550. }, 0)
  551. }
  552. })
  553. uni.$on('requisitionSelect', async (data, query) => {
  554. console.log(data)
  555. this.formData.sourceBizNo = query.sourceBizNo
  556. this.formData.bizType = parseInt(query.bizType)
  557. this.formData.extInfo.assetType = query.assetType.split(',')
  558. let filterArray = this.formData.extInfo.assetType.map(item => {
  559. return this.goodsLists.find(ite => ite.id == item).name
  560. })
  561. this.assetTypeName = Array.from(new Set(filterArray)).join('/')
  562. const batchNo = await getCode('lot_number_code')
  563. // 获取包装规格
  564. let packingSpecification = await getCategoryPackageDisposition({
  565. categoryIds: data.map(item => item.categoryId)
  566. })
  567. this.packingSpecificationOption = data.map(item => {
  568. return packingSpecification.filter(ite => item.categoryId == ite.categoryId)
  569. .sort((a, b) => a.sort - b.sort)
  570. })
  571. this.productList = data.map((productItem, productIndex) => {
  572. // 显示规格
  573. let packingSpecificationLabel = this.packingSpecificationOption[productIndex]
  574. .map(item => {
  575. if (item.sort > 0) {
  576. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`
  577. }
  578. })
  579. .filter(item => !!item)
  580. return {
  581. ...productItem,
  582. index: this.productList.length + productIndex,
  583. isSave: productItem.outInDetailRecordRequestList?.length > 0 ? true :
  584. false,
  585. batchNo: batchNo, // 批次号
  586. warehouseIds: [productItem.warehouseId], // 仓库Id
  587. warehouseNames: [productItem.warehouseName], // 仓库名称
  588. packingSpecificationOption: this.packingSpecificationOption[
  589. productIndex], // 包装规格选项
  590. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  591. outInDetailRecordRequestList: productItem.outInDetailRecordRequestList
  592. ?.length > 0 ?
  593. productItem.outInDetailRecordRequestList.map((packingItem,
  594. packingIndex) => {
  595. return {
  596. ...packingItem,
  597. index: this.productList.length + productIndex + '-' +
  598. packingIndex, // 包装索引
  599. batchNo: batchNo, // 批次号
  600. parentIndex: this.productList.length +
  601. productIndex, // 物品索引
  602. categoryName: productItem.categoryName,
  603. categoryCode: productItem.categoryCode,
  604. materialDetailList: packingItem.materialDetailList.map((
  605. materialItem, materialIndex) => {
  606. return {
  607. ...materialItem,
  608. index: this.productList.length +
  609. productIndex + '-' + packingIndex +
  610. '——' + materialIndex, // 包装索引
  611. parentIndex: this.productList.length +
  612. productIndex + '-' +
  613. packingIndex, // 物品索引
  614. batchNo: batchNo, // 批次号
  615. categoryName: productItem.categoryName,
  616. categoryCode: productItem.categoryCode
  617. }
  618. })
  619. }
  620. }) : []
  621. }
  622. })
  623. setTimeout(() => {
  624. this.detailOpen = !this.detailOpen
  625. this.$refs.collapse && this.$refs.collapse.resize()
  626. }, 0)
  627. })
  628. // 明细信息填写
  629. uni.$on('batchNumBack', productList => {
  630. if (productList?.length) {
  631. this.productList = productList
  632. }
  633. })
  634. },
  635. mounted() {
  636. // this.getAddDetails();
  637. },
  638. computed: {
  639. tableHeader() {
  640. return tableHeader(this.formData.assetType)
  641. },
  642. materialCodeReqList() {
  643. return this.productList.map(i => i.warehouseLedgerDetails || []).flat()
  644. },
  645. isMaterial() {
  646. return this.formData.assetType == 3
  647. },
  648. warehousingName() {
  649. return []
  650. this.productList = []
  651. return this.getDictValue('物品类型', this.formData.assetType)
  652. },
  653. listRules() {
  654. return this.productList.reduce((cur, pre, index) => {
  655. return {
  656. ...cur,
  657. [`productList.${index}.batchNo`]: {
  658. type: 'string',
  659. required: true,
  660. trigger: ['blur', 'change']
  661. },
  662. [`productList.${index}.packingQuantity`]: {
  663. type: 'number',
  664. required: true,
  665. trigger: ['blur', 'change']
  666. },
  667. [`productList.${index}.packingUnit`]: {
  668. type: 'string',
  669. required: true,
  670. trigger: ['blur', 'change']
  671. },
  672. [`productList.${index}.warehouseId`]: {
  673. type: 'string',
  674. required: true,
  675. trigger: ['blur', 'change']
  676. }
  677. }
  678. }, {})
  679. }
  680. },
  681. methods: {
  682. goToScanCodeList() {
  683. uni.navigateTo({
  684. url: '/pages/warehouse/enterHouse/components/scanCodeList'
  685. })
  686. },
  687. goToRequisition() {
  688. uni.navigateTo({
  689. url: '/pages/warehouse/components/requisitionList?type=' + 1
  690. })
  691. },
  692. // 入库
  693. submit() {
  694. if (this.productList.length <= 0) {
  695. uni.showToast({
  696. icon: 'none',
  697. title: '请添加产品!'
  698. })
  699. return
  700. }
  701. let boolen = this.productList.every(item => item.isSave)
  702. if (!boolen) {
  703. uni.showToast({
  704. icon: 'none',
  705. title: '请先保存所有产品信息!'
  706. })
  707. return
  708. }
  709. uni.showLoading({
  710. title: '保存中...'
  711. })
  712. this.formData.outInDetailList = this.productList
  713. let obj = uni.$u.deepClone(this.formData)
  714. // 处理物品类型assetType
  715. obj.extInfo.assetType = obj.extInfo.assetType?.join(',')
  716. // 处理仓库id
  717. let warehouseId = []
  718. let warehouseName = []
  719. let warehouseIds = this.productList.map(item => item.warehouseIds).flat()
  720. let warehouseNames = this.productList.map(item => item.warehouseNames).flat()
  721. warehouseIds.forEach((item, index) => {
  722. if (!warehouseId.includes(item)) {
  723. warehouseId.push(item)
  724. warehouseName.push(warehouseNames[index])
  725. }
  726. })
  727. obj.warehouseIds = warehouseId
  728. obj.warehouseNames = warehouseName
  729. // 是否需要审核(0审核 1跳过审核)
  730. if (obj.bizType == '12') {
  731. obj.isSkip = 1
  732. } else {
  733. obj.isSkip = 0
  734. }
  735. // obj.isSkip = 1;
  736. console.log(obj, '提交')
  737. storage(obj)
  738. .then(async res => {
  739. console.log('入库成功', res)
  740. if (res.code == 0) {
  741. try {
  742. // 委外入库(非采购)
  743. if (obj.bizType == '12') {
  744. await qualityInspectionTwo({
  745. outInId: res.data[0]
  746. })
  747. } else {
  748. await submitTwo({
  749. outInId: res.data[0]
  750. })
  751. }
  752. uni.hideLoading()
  753. uni.showToast({
  754. icon: 'none',
  755. title: '入库成功',
  756. duration: 1500
  757. })
  758. uni.navigateBack({
  759. delta: 1
  760. })
  761. } catch (error) {
  762. uni.hideLoading()
  763. console.log('提交流程失败', error)
  764. }
  765. }
  766. })
  767. .catch(err => {
  768. console.log('入库失败', err)
  769. uni.hideLoading()
  770. uni.showToast({
  771. icon: 'none',
  772. title: '入库失败',
  773. duration: 2000
  774. })
  775. })
  776. },
  777. // 重量限制
  778. weightInput(value, row, productIndex) {
  779. const newValue = value.replace(/[^\d.]/g, '') // 保留数字和小数点
  780. const decimalCount = (newValue.match(/\./g) || []).length // 计算小数点的个数
  781. if (row.weight < 0) {
  782. row.weight = 0
  783. } else if (row.weight > 9999) {
  784. row.weight = 9999
  785. } else {
  786. if (decimalCount > 1) {
  787. // 如果小数点个数大于1,移除多余的小数点
  788. const lastIndex = newValue.lastIndexOf('.')
  789. row.weight = newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1)
  790. } else if (decimalCount === 1) {
  791. // 如果小数点个数等于1,允许小数点的输入
  792. row.weight = newValue
  793. } else {
  794. row.weight = newValue === '' ? 0 : parseFloat(newValue) // 如果输入为空,则设为0
  795. }
  796. }
  797. this.packingWeightCahnge(productIndex)
  798. },
  799. // 包装重量修改
  800. packingWeightCahnge(productIndex) {
  801. // 修改物品重量
  802. let totalWeight = this.productList[productIndex].outInDetailRecordRequestList.reduce((accumulator,
  803. currentValue) => {
  804. return Number(accumulator) + Number(currentValue.weight)
  805. }, 0)
  806. this.$set(this.productList[productIndex], 'weight', totalWeight)
  807. },
  808. scrolltolower() {
  809. console.log('滑动了~~~')
  810. },
  811. typeTimeClick(index, idx) {
  812. console.log('index-----', index)
  813. console.log('idx----', idx)
  814. this.currentProductIndex = index
  815. this.currentPackingIndex = idx > -1 ? idx : -1
  816. this.typeTimeShow = true
  817. },
  818. statusClick(index, idx) {
  819. this.currentProductIndex = index
  820. this.currentPackingIndex = idx > -1 ? idx : -1
  821. this.statusShow = true
  822. },
  823. selectStautsInfo(e) {
  824. this.productList[this.currentProductIndex].outInDetailRecordRequestList[this.currentPackingIndex].status =
  825. e.value[0]?.value
  826. this.statusShow = false
  827. },
  828. typeTimeConfirm() {
  829. this.typeTimeShow = false
  830. this.$nextTick(() => {
  831. console.log(this.currentPackingIndex)
  832. if (this.currentPackingIndex > -1) {
  833. // 单独
  834. this.productList[this.currentProductIndex].outInDetailRecordRequestList[this
  835. .currentPackingIndex][this.currentDateType] = this.formatter(this.currentTypeTime)
  836. } else {
  837. // 批量
  838. this.productList[this.currentProductIndex].outInDetailRecordRequestList = this.productList[
  839. this.currentProductIndex].outInDetailRecordRequestList.map(item => {
  840. console.log(this.currentTypeTime)
  841. console.log(this.formatter(this.currentTypeTime))
  842. return {
  843. ...item,
  844. [this.currentDateType]: this.formatter(this.currentTypeTime)
  845. }
  846. })
  847. }
  848. })
  849. },
  850. // 物品保存验证表单(单独)
  851. validateFormIndividually(index) {
  852. return new Promise(async resolve => {
  853. console.log('index----------------', index)
  854. let fileds = [`productList.${index}.batchNo`, `productList.${index}.packingQuantity`,
  855. `productList.${index}.packingUnit`, `productList.${index}.warehouseId`
  856. ]
  857. Promise.all(
  858. fileds.map(
  859. item =>
  860. new Promise(async (res, rej) => {
  861. this.$refs.lisrFormRef.validateField(item, err => {
  862. console.log('err--', err)
  863. if (err?.length) {
  864. rej(err)
  865. } else {
  866. res(true)
  867. }
  868. })
  869. })
  870. )
  871. )
  872. .then(() => {
  873. resolve()
  874. })
  875. .catch(err => {
  876. uni.showToast({
  877. icon: 'none',
  878. title: '请填入必填项!'
  879. })
  880. })
  881. })
  882. },
  883. // 产品编辑
  884. listEdit(index) {
  885. this.currentProductIndex = index
  886. this.productList[index].isSave = false
  887. this.productList[index].outInDetailRecordRequestList = []
  888. },
  889. listSave(row, index) {
  890. console.log('index------', index)
  891. this.validateFormIndividually(index).then(async () => {
  892. console.log('通过了!!!')
  893. // 判断包装单位和计量单位是否为不拆物料层规格
  894. let packingBoolen = !!this.getDict(row.packingUnit).dictValue
  895. let measureBoolen = !!this.getDict(row.measureUnit).dictValue
  896. let packingNum = 0
  897. // 处理包装单位为KG类的情况
  898. if (packingBoolen) {
  899. let filterArr = row.packingSpecificationOption.filter(item => {
  900. return item.packageUnit == row.packingUnit && item.packageUnit != item
  901. .conversionUnit
  902. })
  903. packingNum = Math.ceil(row.packingQuantity / filterArr[0].packageCell)
  904. }
  905. // 处理包装单位不为KG类,计量单位为KG类的情况
  906. let measureNum = row.packingQuantity
  907. if (measureBoolen) {
  908. let splitIndex = row.packingSpecificationOption.findIndex(item => item
  909. .conversionUnit == row.packingUnit && item.packageUnit != item.conversionUnit)
  910. for (; splitIndex > 1; splitIndex--) {
  911. measureNum = measureNum * row.packingSpecificationOption[splitIndex].packageCell
  912. }
  913. }
  914. // 获取包装编码列表
  915. const {
  916. data
  917. } = await getAssetNum([{
  918. assetCode: row.categoryCode + row.index,
  919. batchNum: row.batchNo,
  920. num: packingBoolen ? packingNum : row.isUnpack ? (measureBoolen ?
  921. measureNum : row.measureQuantity) : row.packingQuantity
  922. }])
  923. this.generateWrappers(row, index, data)
  924. this.$set(this.productList[index], 'isSave', true)
  925. })
  926. },
  927. // 获取当前时间函数
  928. getNowDate() {
  929. let date = new Date(),
  930. obj = {
  931. year: date.getFullYear(), //获取完整的年份(4位)
  932. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  933. strDate: date.getDate(), // 获取当前日(1-31)
  934. hour: date.getHours(), //获取当前小时(0 ~ 23)
  935. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  936. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  937. }
  938. Object.keys(obj).forEach(key => {
  939. if (obj[key] < 10) obj[key] = `0${obj[key]}`
  940. })
  941. return obj
  942. },
  943. // 生成包装
  944. generateWrappers(row, productIndex, packingCodeList) {
  945. console.log('row----', row)
  946. console.log('是否拆包----', row.isUnpack)
  947. console.log('包装规格----', row.packingSpecificationOption)
  948. console.log('计量单位----', row.measureUnit)
  949. console.log('包装数量----', row.packingQuantity)
  950. console.log('包装编码----', packingCodeList)
  951. let obj = this.getNowDate()
  952. let productionDate = ''
  953. let purchaseDate = ''
  954. if (this.formData.bizType == '1') {
  955. // 生产入库
  956. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`
  957. this.curDateType = productionDate
  958. } else if (this.formData.bizType == '2') {
  959. // 采购入库
  960. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`
  961. this.curDateType = purchaseDate
  962. }
  963. console.log(this.curDateType, '----时间')
  964. // 判断包装单位和计量单位是否为不拆物料层规格
  965. let packingBoolen = !!this.getDict(row.packingUnit).dictValue
  966. let measureBoolen = !!this.getDict(row.measureUnit).dictValue
  967. let num = row.packingQuantity
  968. let filterArr = []
  969. // 处理包装单位为KG类的情况
  970. console.log('packingBoolen----', packingBoolen)
  971. console.log('measureBoolen', measureBoolen)
  972. if (packingBoolen) {
  973. filterArr = row.packingSpecificationOption.filter(item => {
  974. return item.packageUnit == row.packingUnit && item.packageUnit != item.conversionUnit
  975. })
  976. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell)
  977. } else {
  978. console.log(row.isUnpack, 'sssssssssss')
  979. if (row.isUnpack) {
  980. if (measureBoolen) {
  981. // 处理包装单位不为KG类,计量单位为KG类的情况
  982. let splitIndex = row.packingSpecificationOption.findIndex(item => item.conversionUnit == row
  983. .packingUnit && item.packageUnit != item.conversionUnit)
  984. for (; splitIndex > 1; splitIndex--) {
  985. // num = this.$math.format(num * row.packingSpecificationOption[splitIndex].packageCell, 14)
  986. num = num * row.packingSpecificationOption[splitIndex].packageCell
  987. }
  988. } else {
  989. console.log(row.packingSpecificationOption)
  990. let splitIndex = row.packingSpecificationOption.findIndex(item => item.conversionUnit == row
  991. .packingUnit && item.packageUnit != item.conversionUnit)
  992. console.log(splitIndex)
  993. for (; splitIndex > 0; splitIndex--) {
  994. console.log(splitIndex)
  995. // num = this.$math.format(num * row.packingSpecificationOption[splitIndex].packageCell, 14)
  996. num = num * row.packingSpecificationOption[splitIndex].packageCell
  997. }
  998. }
  999. } else {
  1000. num = row.packingQuantity
  1001. }
  1002. }
  1003. for (let index = 0; index < num; index++) {
  1004. let measureQuantity = 1
  1005. // 处理包装单位为KG类,计算每桶KG值
  1006. if (packingBoolen) {
  1007. // console.log(this.$math.format(filterArr[0].packageCell * (index + 1), 14))
  1008. console.log(filterArr[0].packageCell * (index + 1))
  1009. console.log(row.packingQuantity)
  1010. // measureQuantity =
  1011. // Number(row.packingQuantity) > this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  1012. // ? filterArr[0].packageCell
  1013. // : Number(row.packingQuantity) - this.$math.format(filterArr[0].packageCell * index, 14)
  1014. measureQuantity = Number(row.packingQuantity) > filterArr[0].packageCell * (index + 1) ? filterArr[
  1015. 0].packageCell : Number(row.packingQuantity) - filterArr[0].packageCell * index
  1016. } else {
  1017. if (!row.isUnpack) {
  1018. if (measureBoolen) {
  1019. // 处理包装单位不为KG类,计量单位为KG类的情况
  1020. let splitIndex = row.packingSpecificationOption.findIndex(item => item.conversionUnit ==
  1021. row.packingUnit && item.packageUnit != item.conversionUnit)
  1022. for (; splitIndex > 0; splitIndex--) {
  1023. // measureQuantity = this.$math.format(measureQuantity * row.packingSpecificationOption[splitIndex].packageCell, 14)
  1024. measureQuantity = measureQuantity * row.packingSpecificationOption[splitIndex]
  1025. .packageCell
  1026. }
  1027. } else {
  1028. let splitIndex = row.packingSpecificationOption.findIndex(item => item.conversionUnit ==
  1029. row.packingUnit && item.packageUnit != item.conversionUnit)
  1030. for (; splitIndex > 0; splitIndex--) {
  1031. console.log(splitIndex)
  1032. // measureQuantity = this.$math.format(measureQuantity * row.packingSpecificationOption[splitIndex].packageCell, 14)
  1033. measureQuantity = measureQuantity * row.packingSpecificationOption[splitIndex]
  1034. .packageCell
  1035. }
  1036. }
  1037. }
  1038. }
  1039. let item = {
  1040. index: row.index + '-' + index, // 包装索引
  1041. warehouseId: row.warehouseIds[0], // 仓库id
  1042. warehouseName: row.warehouseNames[0], // 仓库名称
  1043. categoryName: row.categoryName, // 产品名称
  1044. categoryCode: row.categoryCode, // 产品编码
  1045. categoryModel: row.categoryModel, // 物品型号
  1046. specification: row.specification, // 规格
  1047. brandNum: row.brandNum, // 牌号
  1048. parentIndex: row.index, // 产品索引
  1049. batchNo: row.batchNo, // 批次号
  1050. packageNo: packingCodeList[index].onlyCode, // 包装编码
  1051. packingQuantity: 1, // 包装数量
  1052. packingUnit: row.isUnpack ?
  1053. packingBoolen ?
  1054. filterArr[0].conversionUnit :
  1055. measureBoolen ?
  1056. row.packingSpecificationOption[1].conversionUnit :
  1057. row.measureUnit : packingBoolen ?
  1058. filterArr[0].conversionUnit : row.packingUnit,
  1059. measureQuantity: row.isUnpack ? (packingBoolen ? measureQuantity : measureBoolen ? row
  1060. .packingSpecificationOption[1].packageCell : measureQuantity) : measureQuantity, // 计量数量
  1061. measureUnit: row.isUnpack ? (measureBoolen ? row.packingSpecificationOption[1].packageUnit :
  1062. row.measureUnit) : row.measureUnit, // 计量单位
  1063. weight: 0, // 重量
  1064. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  1065. weightUnit: row.weightUnit, // 重量单位
  1066. netWeight: row.netWeight, // 净重
  1067. barcodes: '', // 发货条码
  1068. clientCode: '', // 客户代号
  1069. materielDesignation: '', // 物料代号
  1070. engrave: '', // 刻码
  1071. isUnpack: row.isUnpack, // 是否允许拆包
  1072. productionDate: productionDate, // 生产日期
  1073. purchaseDate: purchaseDate, // 采购时间
  1074. result: 1, // 结果(1合格 2不合格)
  1075. status: 1 // 状态(0=未质检 1已质检)
  1076. }
  1077. let outBoolen = !!this.getDict(item.measureUnit).dictValue
  1078. console.log('this.dictCodeList-------', this.dictCodeList)
  1079. console.log('item.measureUnit-------', item)
  1080. console.log('!!this.getDict(item.measureUnit).dictValue--------', this.getDict(item.measureUnit))
  1081. if (outBoolen) {
  1082. // 计量单位为KG类,直接替换
  1083. item.weight = item.measureQuantity
  1084. } else {
  1085. // 计量单位为不为KG类,重新统计计算
  1086. let inBoolen = !!this.getDict(item.packingSpecificationOption[0].packageUnit).dictValue
  1087. let startIndex = item.packingSpecificationOption.findIndex(ite => {
  1088. return item.measureUnit == ite.packingUnit && ite.packingUnit != ite.conversionUnit
  1089. })
  1090. console.log(startIndex)
  1091. let endIndex = item.packingSpecificationOption.findIndex(ite => item.packingUnit == ite
  1092. .conversionUnit)
  1093. console.log(endIndex)
  1094. let total = item.packingQuantity
  1095. for (; startIndex < endIndex; endIndex--) {
  1096. // total = this.$math.format(item.packingSpecificationOption[endIndex].packageCell * total, 14)
  1097. total = item.packingSpecificationOption[endIndex].packageCell * total
  1098. }
  1099. if (inBoolen) {
  1100. // 第二层为KG类
  1101. item.weight = total
  1102. } else {
  1103. // 第二层不为KG类
  1104. // item.weight = this.$math.format(total * item.netWeight, 14)
  1105. item.weight = total * item.netWeight
  1106. }
  1107. }
  1108. row.outInDetailRecordRequestList.push(item)
  1109. }
  1110. // // 单独点击保存并插入对应位置(包装)
  1111. // if (productIndex == 0) {
  1112. // this.packingList.splice(productIndex, 0, ...packingList)
  1113. // } else {
  1114. // let packingIndex = this.packingList.findLastIndex(item => item.parentIndex == this.productList[productIndex - 1].index)
  1115. // this.packingList.splice(packingIndex + 1, 0, ...packingList)
  1116. // }
  1117. },
  1118. async requireDictCode() {
  1119. // 不拆物料层规格列表
  1120. const res = await getByCode('material_layer')
  1121. this.dictCodeList = res.map(item => {
  1122. const arr = Object.entries(item)
  1123. return {
  1124. dictCode: arr[0][0],
  1125. dictValue: arr[0][1]
  1126. }
  1127. })
  1128. },
  1129. getDict(dictCode) {
  1130. // 不拆物料层规格列表
  1131. if (this.dictCodeList.length > 0) {
  1132. return this.dictCodeList.find(item => item.dictCode == dictCode) || {}
  1133. } else {
  1134. return {}
  1135. }
  1136. },
  1137. async computeNum(row, index, isClear) {
  1138. console.log(row)
  1139. console.log(row.packingQuantity)
  1140. console.log(row.packingUnit)
  1141. // 清空仓库(包装数量输入)
  1142. if (isClear) {
  1143. // this.$set(this.productList[index], 'warehouseId', '')
  1144. // this.$set(this.productList[index], 'warehouseName', '')
  1145. if (row.packingQuantity < 1) {
  1146. this.$set(this.productList[index], 'packingQuantity', 1)
  1147. } else if (row.packingQuantity > 9999) {
  1148. this.$set(this.productList[index], 'packingQuantity', 9999)
  1149. } else {
  1150. this.$set(this.productList[index], 'packingQuantity', row.packingQuantity.replace(
  1151. /[^\d\.{2,}]/g, ''))
  1152. }
  1153. }
  1154. if (row.packingQuantity && row.packingUnit) {
  1155. let startIndex = row.packingSpecificationOption.findIndex(ite => {
  1156. return row.measuringUnit == ite.packingUnit && ite.packingUnit != ite.conversionUnit
  1157. })
  1158. console.log(startIndex)
  1159. let endIndex = row.packingSpecificationOption.findIndex(ite => row.packingUnit == ite
  1160. .conversionUnit)
  1161. console.log(endIndex)
  1162. let total = row.packingQuantity
  1163. for (; startIndex < endIndex; endIndex--) {
  1164. total = row.packingSpecificationOption[endIndex].packageCell * total
  1165. }
  1166. row.measureQuantity = total
  1167. // 判断包装单位和计量单位是否为不拆物料层规格
  1168. console.log(this.getDict(row.packingUnit))
  1169. let packingBoolen = !!this.getDict(row.packingUnit).dictValue
  1170. let measureBoolen = !!this.getDict(row.measureUnit).dictValue
  1171. if (packingBoolen || measureBoolen) {
  1172. row.weight = total
  1173. } else {
  1174. row.weight = total * row.netWeight
  1175. }
  1176. }
  1177. },
  1178. //获取仓库
  1179. async getwarehouseList() {
  1180. let res = await getWarehouseList()
  1181. this.warehouseListOption = [res.data]
  1182. },
  1183. showWarehousePicker(index) {
  1184. this.currentProductIndex = index
  1185. this.warehouseShow = true
  1186. },
  1187. showPackingUnitPicker(data, index) {
  1188. this.currentProductIndex = index
  1189. this.currentPackingSpecificationOption = [data.packingSpecificationOption]
  1190. this.packingUnitsShow = true
  1191. },
  1192. showSupplierPicker(data, index) {
  1193. this.currentProductIndex = index
  1194. this.currentSupplierListOption = [data.supplierListOptions]
  1195. this.suppliersShow = true
  1196. },
  1197. selectPackingUnitInfo(e) {
  1198. this.productList[this.currentProductIndex].packingUnit = e.value[0]?.conversionUnit
  1199. this.computeNum(this.productList[this.currentProductIndex], this.currentProductIndex)
  1200. this.packingUnitsShow = false
  1201. },
  1202. selectSuppliersInfo(e) {
  1203. this.productList[this.currentProductIndex].supplierName = e.value[0]?.name
  1204. this.productList[this.currentProductIndex].supplierId = e.value[0]?.id
  1205. this.suppliersShow = false
  1206. },
  1207. selectWarehouseInfo(e) {
  1208. this.productList[this.currentProductIndex].warehouseName = e.value[0]?.name
  1209. this.productList[this.currentProductIndex].warehouseId = e.value[0]?.id
  1210. this.productList[this.currentProductIndex].warehouseNames = [e.value[0]?.name]
  1211. this.productList[this.currentProductIndex].warehouseIds = [e.value[0]?.id]
  1212. this.warehouseShow = false
  1213. },
  1214. selectTimeTypeInfo(e) {
  1215. this.currentDateType = e.value[0]?.prop
  1216. this.timeTypeShow = false
  1217. },
  1218. sceneStateFilter(bizType) {
  1219. if (bizType) {
  1220. return this.sceneState.filter(item => item.value == bizType)[0].text
  1221. }
  1222. },
  1223. formatter(dataTime) {
  1224. return dayjs(dataTime).format('YYYY-MM-DD HH:mm:ss')
  1225. },
  1226. timeConfirm() {
  1227. this.timeShow = false
  1228. this.$nextTick(() => {
  1229. console.log(this.storageTime)
  1230. console.log(this.formatter(this.storageTime))
  1231. this.formData.storageTime = this.formatter(this.storageTime)
  1232. console.log(this.formData)
  1233. })
  1234. },
  1235. timeCancel() {
  1236. this.timeShow = false
  1237. },
  1238. openPicker() {
  1239. this.$refs.treePicker._show()
  1240. },
  1241. // 获取物品列表
  1242. async getListItems() {
  1243. this.goodsLists = await getTreeByGroup({
  1244. type: 2
  1245. })
  1246. },
  1247. confirm(data, name, allList) {
  1248. console.log('name-------', name)
  1249. this.assetTypeName = name
  1250. this.formData.extInfo.assetType = allList.map(item => item.id)
  1251. },
  1252. handleScan() {
  1253. if (this.formData.bizType !== '' && this.formData.bizType != 5) {
  1254. uni.showModal({
  1255. title: '提示',
  1256. content: '仅退还入库支持扫码,是否清除已选明细并切换至退还入库?',
  1257. success: async res => {
  1258. if (res.confirm) {
  1259. this.productList = []
  1260. this.formData.bizType = 5
  1261. this.getData()
  1262. }
  1263. }
  1264. })
  1265. return
  1266. }
  1267. this.getData()
  1268. },
  1269. // goScan () {
  1270. // uni.navigateTo({
  1271. // url: '/pages/ScanCode/ScanCode'
  1272. // })
  1273. // },
  1274. // 根据条码请求设备数据 @_@
  1275. getData() {
  1276. let par = {
  1277. barType: this.qrContent.split('@_@')[1] || 0,
  1278. qrContent: this.qrContent
  1279. }
  1280. // uni.showLoading({
  1281. // title: '加载中',
  1282. // mask: true
  1283. // })
  1284. // postJ(this.apiUrl + '/scan/getAssetInfo', par)
  1285. // .then(res => {
  1286. // let data = res.data
  1287. // console.log(data, 'qrContent')
  1288. // if (data.assetType === undefined) {
  1289. // uni.showToast({
  1290. // title: '请扫码物品码',
  1291. // icon: 'none'
  1292. // })
  1293. // return
  1294. // } else if (data.source == 2) {
  1295. // uni.showModal({
  1296. // title: '提示',
  1297. // content: '当前物品已在库',
  1298. // success: async res => {}
  1299. // })
  1300. // return
  1301. // } else if (this.warehousingName && this.formData.assetType != data.assetType) {
  1302. // uni.showToast({
  1303. // title: `当前物品不属于${this.warehousingName}分类`,
  1304. // icon: 'none'
  1305. // })
  1306. // return
  1307. // }
  1308. // this.setScanMaterial(data)
  1309. // })
  1310. // .finally(() => {
  1311. // uni.hideLoading()
  1312. // })
  1313. },
  1314. async setScanMaterial(data) {
  1315. this.formData.assetType = data.assetType
  1316. this.formData.bizType = 5
  1317. const curMap = {
  1318. assetId: 'id',
  1319. assetCode: 'informationCode', //编码
  1320. assetName: 'informationName', //名称
  1321. materialId: 'id',
  1322. materialName: 'informationName',
  1323. batchNo: '', //批次号
  1324. unit: 'measuringUnit', //单位
  1325. minPackUnit: 'packingUnit' //最小包装单位
  1326. }
  1327. let obj = {}
  1328. for (const key in curMap) {
  1329. obj[key] = (curMap[key] && data.information[curMap[key]]) || ''
  1330. }
  1331. let detailObj = uni.$u.deepClone(obj)
  1332. detailObj.onlyCode = data.assetCode
  1333. obj = {
  1334. ...data.information,
  1335. ...obj,
  1336. ...{
  1337. cargoSpaceCode: '', //货位编码
  1338. cargoSpaceId: '', //货位id
  1339. shelfId: '', //货架id
  1340. shelfCode: '', //货架名称
  1341. areaId: '', //库区id
  1342. areaName: '', //库区名称
  1343. warehouseId: '', //仓库id
  1344. warehouseName: '', //仓库名称
  1345. measurementUnit: '',
  1346. bizStatus: 1,
  1347. contentImage: []
  1348. }
  1349. }
  1350. let warehouseLedgerDetails = [detailObj]
  1351. this.productList.push(obj)
  1352. this.$set(this.productList[this.productList.length - 1], 'warehouseLedgerDetails',
  1353. warehouseLedgerDetails)
  1354. this.$set(this.productList[this.productList.length - 1], 'selfWarehouseLedgerDetails', uni.$u
  1355. .deepClone(warehouseLedgerDetails))
  1356. this.handleBatchSetting(obj, this.productList.length - 1, true)
  1357. },
  1358. calcSum(a, b, c, row) {
  1359. if ((Number.isNaN(+a) && a !== '') || (Number.isNaN(+b) && b !== '') || (Number.isNaN(+c) && c !== '')) {
  1360. return ''
  1361. }
  1362. return a * b * c + {
  1363. yuan: '元',
  1364. wanyuan: '万元'
  1365. } [row.univalenceUnit]
  1366. },
  1367. handleBatchSetting(item, index, isScan = false) {
  1368. this.settingIndex = index
  1369. uni.setStorageSync('inputData', item)
  1370. uni.setStorageSync('productList', this.productList || [])
  1371. uni.navigateTo({
  1372. url: '/pages/warehouse/enterHouse/batchNumEdit?bizType=' + this.formData.bizType +
  1373. '&assetType=' + this.formData.assetType + '&index=' + index + '&isScan=' + isScan
  1374. })
  1375. },
  1376. chooseFile(file) {
  1377. console.log(file)
  1378. this.$refs.lFile.upload({
  1379. //替换为你的上传接口地址
  1380. url: this.apiUrl + '/data/doc/add',
  1381. // 服务端接收附件的key
  1382. name: 'file',
  1383. //根据你接口需求自定义 (优先不传content-type,安卓端无法收到参数再传)
  1384. header: {
  1385. Authorization: 'bearer eyJhbGciO',
  1386. uid: '27682',
  1387. client: 'app'
  1388. }
  1389. // 限制选择附件的大小上限,默认10M
  1390. // maxSize: 20,
  1391. // 若需要在body单独添加附件名或附件大小如下方式传入组件:
  1392. // addName: '后端要的附件名称字段key,此处请勿写name的同值如(file),会覆盖name',
  1393. // addSize: '后端要的附件大小字段key'
  1394. // body参数直接写key,value,如:
  1395. // date: '2020-1-1',
  1396. // key2: 'value2',
  1397. })
  1398. },
  1399. changeType(e) {
  1400. this.formData.bizType = e
  1401. },
  1402. // 抬头下拉信息保存
  1403. handlePicker(e, list, idKey, nameKey) {
  1404. console.log('e?.detail--------------', e)
  1405. if (idKey) {
  1406. this.formData[idKey] = list[e?.detail.value]?.value
  1407. }
  1408. if (nameKey) {
  1409. this.formData[nameKey] = list[e?.detail.value]?.text
  1410. }
  1411. this.$nextTick(() => {
  1412. if (idKey === 'assetType' || idKey === 'bizType') {
  1413. this.$refs.formRef.validateField(idKey)
  1414. }
  1415. console.log('this.formData.bizType---', this.formData.bizType)
  1416. })
  1417. },
  1418. // 抬头下拉信息保存
  1419. handleDictPicker(e, list, idKey, nameKey) {
  1420. if (idKey) {
  1421. this.formData[idKey] = list[e?.detail.value]?.dictCode
  1422. }
  1423. if (nameKey) {
  1424. this.formData[nameKey] = list[e?.detail.value]?.dictValue
  1425. }
  1426. this.$nextTick(() => {
  1427. if (idKey === 'assetType' || idKey === 'bizType') {
  1428. this.$refs.formRef.validateField(idKey)
  1429. }
  1430. })
  1431. },
  1432. // 明细下拉信息保存
  1433. handleListPicker(e, list, item, idKey, nameKey) {
  1434. if (idKey) {
  1435. item[idKey] = list[e.detail.value].id
  1436. }
  1437. if (nameKey) {
  1438. item[nameKey] = list[e.detail.value].name
  1439. }
  1440. },
  1441. //获取仓库信息
  1442. handleWarehouseChoose(item) {
  1443. this.$refs.warehouseChooseRef.openDefault(item, res => {
  1444. Object.assign(item, res)
  1445. })
  1446. },
  1447. //状态
  1448. getstatus(e) {
  1449. this.formData.houseType = this.statusList[e.detail.value].name
  1450. },
  1451. //上传附件
  1452. getUpFlie(res) {
  1453. console.log(res)
  1454. let arr = []
  1455. res.forEach(item => {
  1456. let obj = {
  1457. accessUrl: item.accessUrl,
  1458. docId: item.docId,
  1459. name: item.name,
  1460. size: item.size,
  1461. url: item.url,
  1462. type: 1
  1463. }
  1464. // obj.type.id = item.type.id;
  1465. // obj.type.value = item.type.name;
  1466. arr.push(obj)
  1467. })
  1468. this.formData.attaments = arr
  1469. },
  1470. //选择入库类别跳转
  1471. selectType() {
  1472. if (!this.formData.extInfo.assetType) {
  1473. uni.showToast({
  1474. title: '请选择物品类型',
  1475. icon: 'none'
  1476. })
  1477. return
  1478. }
  1479. if (!this.formData.bizType) {
  1480. uni.showToast({
  1481. title: '请选择入库场景',
  1482. icon: 'none'
  1483. })
  1484. return
  1485. }
  1486. uni.navigateTo({
  1487. url: '/pages/warehouse/enterHouse/selectEnterType?assetType=' + this.formData.extInfo.assetType
  1488. })
  1489. },
  1490. //删除
  1491. getDelete(index) {
  1492. uni.showModal({
  1493. title: '提示',
  1494. content: '是否删除当前物品',
  1495. success: res => {
  1496. if (res.confirm) {
  1497. this.productList.splice(index, 1)
  1498. }
  1499. }
  1500. })
  1501. },
  1502. deletePacking(index, idx) {
  1503. uni.showModal({
  1504. title: '提示',
  1505. content: '是否删除当前包装',
  1506. success: res => {
  1507. if (res.confirm) {
  1508. this.productList[index].outInDetailRecordRequestList.splice(idx, 1)
  1509. this.productList[index].packingQuantity = this.productList[index].packingQuantity -
  1510. 1
  1511. }
  1512. }
  1513. })
  1514. },
  1515. // 入库操作
  1516. // listEdit(row) {
  1517. // this.$set(row, 'isSave', false)
  1518. // },
  1519. // listSave(row, index) {
  1520. // const fileds = [`productList.${index}.cargoSpaceCode`, `productList.${index}.batchNum`]
  1521. // if (this.formData.bizType != 5) {
  1522. // fileds.push(...[`productList.${index}.outInNum`, `productList.${index}.measurementUnit`])
  1523. // } else if (this.productList.some(i => !i.selfWarehouseLedgerDetails?.length)) {
  1524. // uni.showToast({
  1525. // title: '请选择资产编号!',
  1526. // icon: 'none'
  1527. // })
  1528. // return
  1529. // }
  1530. // Promise.all(
  1531. // fileds.map(
  1532. // item =>
  1533. // new Promise(async (resolve, rej) => {
  1534. // this.$refs.lisrFormRef.validateField(item, err => {
  1535. // if (err?.length) {
  1536. // rej(err)
  1537. // } else {
  1538. // resolve()
  1539. // }
  1540. // })
  1541. // })
  1542. // )
  1543. // )
  1544. // .then(res => {
  1545. // this.$set(row, 'isSave', true)
  1546. // if (this.formData.bizType != 5) {
  1547. // this.createMaterialCode(row)
  1548. // } else {
  1549. // // 退还
  1550. // this.createMaterialCodeReturn(row)
  1551. // }
  1552. // })
  1553. // .catch(err => {
  1554. // uni.showToast({
  1555. // icon: 'error',
  1556. // title: '请填入必填项!'
  1557. // })
  1558. // })
  1559. // },
  1560. //入库明细删除
  1561. listDel(row, index) {
  1562. this.productList.splice(index, 1)
  1563. },
  1564. // 入库明细生成条码信息
  1565. async createMaterialCode(row) {
  1566. return
  1567. // 添加相同物品重新更新明细 原料编码
  1568. const list = this.productList.filter(i => i.assetCode === row.assetCode && i.batchNum === row
  1569. .batchNum && i.isSave)
  1570. const num = list.reduce((num, pre) => {
  1571. num += row.isUnpack ? pre.outInNum * pre.measurementUnit : pre.outInNum
  1572. return num
  1573. }, 0)
  1574. const res = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
  1575. batchNum: row.batchNum,
  1576. assetCode: row.assetCode,
  1577. num
  1578. })
  1579. if (res?.success) {
  1580. list.forEach(item => {
  1581. if (item.warehouseLedgerDetails?.length) {
  1582. item.warehouseLedgerDetails.forEach(i => {
  1583. i.onlyCode = res.data.shift().onlyCode
  1584. })
  1585. } else {
  1586. this.$set(
  1587. item,
  1588. 'warehouseLedgerDetails',
  1589. Array.from(new Array(item.isUnpack ? item.outInNum * item.measurementUnit :
  1590. +item.outInNum), (val, idx) => {
  1591. return {
  1592. ...item,
  1593. onlyCode: res.data.shift().onlyCode,
  1594. bizStatus: 1,
  1595. contentImage: []
  1596. }
  1597. })
  1598. )
  1599. }
  1600. })
  1601. }
  1602. // 添加相同物品,重复批次号 重新更新明细 包装编码
  1603. const batchList = this.productList.filter(i => i.batchNum === row.batchNum && i.isSave)
  1604. if (batchList.length) {
  1605. const num = batchList.reduce((num, pre) => {
  1606. num += +pre.outInNum
  1607. return num
  1608. }, 0)
  1609. const res1 = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
  1610. batchNum: row.batchNum,
  1611. num
  1612. })
  1613. if (res1?.success) {
  1614. batchList.forEach(item => {
  1615. let num = res1.data.shift()?.num
  1616. let measurementUnit = item.measurementUnit
  1617. if (item.warehouseLedgerDetails?.length) {
  1618. item.warehouseLedgerDetails.forEach((i, index) => {
  1619. this.$set(i, 'num', num)
  1620. if (!item.isUnpack) {
  1621. if (index < item.warehouseLedgerDetails.length - 1) {
  1622. num = res1.data.shift()?.num
  1623. }
  1624. } else {
  1625. // 拆包的包装编码一致
  1626. measurementUnit--
  1627. if (measurementUnit === 0 && index < item
  1628. .warehouseLedgerDetails.length - 1) {
  1629. measurementUnit = item.measurementUnit
  1630. num = res1.data.shift()?.num
  1631. }
  1632. }
  1633. })
  1634. }
  1635. })
  1636. }
  1637. }
  1638. },
  1639. // 入库明细生成条码信息 退还
  1640. async createMaterialCodeReturn(row) {
  1641. return
  1642. // 添加相同物品重新更新明细 原料编码
  1643. const list = this.productList.filter(i => i.batchNum === row.batchNum && i.isSave)
  1644. // 退还
  1645. const res = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
  1646. batchNum: row.batchNum,
  1647. num: list.reduce((num, pre) => {
  1648. num += pre.selfWarehouseLedgerDetails.length
  1649. return num
  1650. }, 0)
  1651. })
  1652. if (res?.success) {
  1653. list.forEach(item => {
  1654. const num = res.data.shift().num
  1655. if (item.warehouseLedgerDetails?.length) {
  1656. item.warehouseLedgerDetails.forEach(i => {
  1657. i.num = num
  1658. if (!item.isUnpack) {
  1659. // 拆包的包装编码一致
  1660. num = res.data.shift()?.num
  1661. }
  1662. })
  1663. } else {
  1664. this.$set(
  1665. item,
  1666. 'warehouseLedgerDetails',
  1667. item.selfWarehouseLedgerDetails.map((val, idx) => {
  1668. let obj = {
  1669. ...val,
  1670. bizStatus: 1,
  1671. batchNum: item.batchNum,
  1672. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  1673. cargoSpaceId: item.cargoSpaceId, //货位id
  1674. shelfId: item.shelfId, //货架id
  1675. shelfCode: item.shelfCode, //货架名称
  1676. areaId: item.areaId, //库区id
  1677. areaName: item.areaName, //库区名称
  1678. warehouseId: item.warehouseId, //仓库id
  1679. warehouseName: item.warehouseName, //仓库名称
  1680. num
  1681. }
  1682. if (!item.isUnpack) {
  1683. // 拆包的包装编码一致
  1684. num = res.data.shift()?.num
  1685. }
  1686. return obj
  1687. })
  1688. )
  1689. }
  1690. })
  1691. }
  1692. },
  1693. //确定提交
  1694. getsure() {
  1695. return
  1696. this.$refs.formRef.validate().then(res => {
  1697. if (!this.productList?.length) {
  1698. uni.showToast({
  1699. icon: 'error',
  1700. title: '请添加明细!'
  1701. })
  1702. return
  1703. } else if (this.productList.some(item => !item.warehouseLedgerDetails?.length)) {
  1704. uni.showToast({
  1705. icon: 'error',
  1706. title: '请完善明细信息!'
  1707. })
  1708. return
  1709. }
  1710. const params = {
  1711. outInWarehouse: {
  1712. ...this.formData,
  1713. bizStatus: 1
  1714. },
  1715. warehouseLedgerInfos: this.productList
  1716. }
  1717. postJ(this.apiUrl + '/outInWarehouse/add', params).then(res => {
  1718. if (res?.success) {
  1719. uni.showToast({
  1720. icon: 'success',
  1721. title: '保存成功'
  1722. })
  1723. setTimeout(() => {
  1724. uni.navigateBack({
  1725. delta: 1
  1726. })
  1727. }, 1500)
  1728. }
  1729. })
  1730. })
  1731. },
  1732. // 部门确认
  1733. deptConfirm(data, name) {
  1734. this.formData.deptName = name
  1735. this.formData.deptCode = data[0]
  1736. },
  1737. // 部门确认
  1738. verifyDeptConfirm(data, name) {
  1739. this.formData.verifyDeptCode = data[0]
  1740. this.formData.verifyDeptName = name
  1741. this.formData.verifyId = ''
  1742. this.formData.verifyName = ''
  1743. this.getUser(data[0])
  1744. },
  1745. // 获取部门
  1746. getDept() {
  1747. return
  1748. get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
  1749. if (res?.success) {
  1750. this.deptList = res.data
  1751. }
  1752. })
  1753. },
  1754. // 获取供应商
  1755. getSupplier() {
  1756. // post(this.apiUrl + `/main/supplier/list?page=1&size=999`, {
  1757. // page: 1,
  1758. // size: 999
  1759. // }).then(res => {
  1760. // if (res?.success) {
  1761. // this.supplierList = res.data.items
  1762. // }
  1763. // })
  1764. },
  1765. // 获取人员
  1766. getUser(deptCode) {
  1767. // post(this.apiUrl + '/main/user/list', {
  1768. // deptCode,
  1769. // page: 1,
  1770. // size: 9999
  1771. // }).then(res => {
  1772. // if (res?.success) {
  1773. // this.userList = res.data.items.map(item => {
  1774. // item.name = item.trueName
  1775. // item.id = item.userId
  1776. // return item
  1777. // })
  1778. // }
  1779. // })
  1780. }
  1781. }
  1782. }
  1783. </script>
  1784. <style lang="scss" scoped>
  1785. .mainBox {
  1786. padding-bottom: 120rpx;
  1787. }
  1788. /deep/.required-form .u-form-item__body__left__content__label::before {
  1789. content: '*';
  1790. color: red;
  1791. }
  1792. .required-form-text {
  1793. /deep/ .u-form-item__body__right {
  1794. overflow: hidden;
  1795. // background-color: red;
  1796. .u-form-item__body__right__content {
  1797. width: 100%;
  1798. display: inline-block !important;
  1799. }
  1800. }
  1801. }
  1802. // ::v-deep .listCont .u-input {
  1803. // height: 60rpx !important;
  1804. // }
  1805. ::v-deep .dd .u-form-item__body__right {
  1806. border: 1px solid #e5e5e5 !important;
  1807. border-radius: 4px;
  1808. line-height: 60rpx;
  1809. }
  1810. .ellipsis {
  1811. max-width: 100%;
  1812. overflow: hidden;
  1813. white-space: nowrap;
  1814. text-overflow: ellipsis;
  1815. }
  1816. .picList {
  1817. display: flex;
  1818. align-items: center;
  1819. justify-items: flex-start;
  1820. flex-wrap: wrap;
  1821. }
  1822. /deep/.baseForm {
  1823. .u-form-item__body {
  1824. padding: 4px !important;
  1825. }
  1826. .assetType_box {
  1827. padding: 12rpx 18rpx;
  1828. width: 100%;
  1829. overflow: hidden;
  1830. white-space: nowrap;
  1831. text-overflow: ellipsis;
  1832. font-size: 30rpx;
  1833. }
  1834. }
  1835. /deep/ .picList .u-image {
  1836. margin-right: 10rpx;
  1837. margin-bottom: 10rpx;
  1838. }
  1839. /deep/.cLine .u-line:nth-child(1) {
  1840. border-bottom: none !important;
  1841. }
  1842. .detail-box {
  1843. position: relative;
  1844. align-items: center;
  1845. /deep/uni-button {
  1846. margin: 0 !important;
  1847. width: 180rpx;
  1848. }
  1849. .selectEnterType {
  1850. margin-left: 10rpx !important;
  1851. }
  1852. }
  1853. .footBox {
  1854. position: fixed;
  1855. left: 0px;
  1856. bottom: 0px;
  1857. height: 100rpx;
  1858. width: 100%;
  1859. display: flex;
  1860. align-items: center;
  1861. justify-content: space-between;
  1862. view {
  1863. width: 100%;
  1864. height: 100%;
  1865. text-align: center;
  1866. color: #fff;
  1867. display: flex;
  1868. align-items: center;
  1869. justify-content: center;
  1870. }
  1871. .reg {
  1872. background: $u-success-dark;
  1873. }
  1874. .add {
  1875. background: $uni-color-primary;
  1876. }
  1877. .uni-icons {
  1878. margin-right: 8rpx !important;
  1879. }
  1880. }
  1881. .listBox {
  1882. padding: 20rpx 10rpx;
  1883. border-bottom: 1px #f2f2f2 solid;
  1884. position: relative;
  1885. &.code {
  1886. .label {
  1887. width: 120rpx !important;
  1888. }
  1889. }
  1890. .listTit {
  1891. width: 100%;
  1892. align-items: center;
  1893. /deep/uni-button {
  1894. margin-right: 20rpx;
  1895. width: 100rpx;
  1896. &.assets {
  1897. width: 180rpx;
  1898. }
  1899. }
  1900. .name {
  1901. width: 50%;
  1902. margin-left: 10px;
  1903. overflow: hidden;
  1904. white-space: nowrap;
  1905. -o-text-overflow: ellipsis;
  1906. text-overflow: ellipsis;
  1907. font-size: 28rpx;
  1908. font-weight: bold;
  1909. }
  1910. .btn {
  1911. display: flex;
  1912. justify-content: flex-end;
  1913. }
  1914. .weight {
  1915. width: 30%;
  1916. font-size: 24rpx;
  1917. margin-left: auto;
  1918. margin-right: 60rpx;
  1919. position: relative;
  1920. display: flex;
  1921. input {
  1922. margin-right: 10rpx;
  1923. border: 1px solid black;
  1924. width: 40%;
  1925. height: 20rpx;
  1926. }
  1927. }
  1928. .weight::after {
  1929. position: absolute;
  1930. right: -30rpx;
  1931. top: 50%;
  1932. content: '';
  1933. background: #eee;
  1934. width: 1px;
  1935. height: 28rpx;
  1936. margin-top: -14rpx;
  1937. }
  1938. }
  1939. .z_list {
  1940. height: 100% !important;
  1941. max-height: 500rpx;
  1942. .material {
  1943. margin-top: 10rpx;
  1944. .left {
  1945. width: 40rpx;
  1946. }
  1947. .zdy_check {
  1948. width: 30rpx;
  1949. height: 30rpx;
  1950. border: 2rpx solid #c8c9cc;
  1951. border-radius: 4rpx;
  1952. }
  1953. .check_active {
  1954. background: $theme-color;
  1955. border: 2rpx solid $theme-color;
  1956. /deep/ .u-icon__icon {
  1957. color: #fff !important;
  1958. }
  1959. }
  1960. .content_table {
  1961. width: 670rpx;
  1962. border: 2rpx solid $border-color;
  1963. .item {
  1964. display: flex;
  1965. border-bottom: 2rpx solid $border-color;
  1966. .lable {
  1967. width: 200rpx;
  1968. text-align: center;
  1969. background-color: #f7f9fa;
  1970. font-size: 26rpx;
  1971. border-right: 2rpx solid $border-color;
  1972. flex-shrink: 0;
  1973. }
  1974. .ww80 {
  1975. width: 80rpx;
  1976. }
  1977. .content {
  1978. width: 500rpx;
  1979. min-height: 64rpx;
  1980. font-size: 28rpx;
  1981. line-height: 28rpx;
  1982. font-style: normal;
  1983. font-weight: 400;
  1984. padding: 18rpx 8rpx;
  1985. box-sizing: border-box;
  1986. word-wrap: break-word;
  1987. flex-grow: 1 !important;
  1988. }
  1989. .input_box {
  1990. padding: 0 !important;
  1991. }
  1992. .content_num {
  1993. display: flex;
  1994. align-items: center;
  1995. padding: 0 4rpx;
  1996. /deep/ .uni-input-input {
  1997. width: 200rpx;
  1998. border: 2rpx solid #f0f8f2;
  1999. background: #f0f8f2;
  2000. color: $theme-color;
  2001. }
  2002. .unit {
  2003. padding: 0 4rpx;
  2004. font-size: 24rpx;
  2005. color: #404446;
  2006. }
  2007. }
  2008. .ww400 {
  2009. /deep/ .uni-input-input {
  2010. width: 400rpx;
  2011. }
  2012. }
  2013. .pd4 {
  2014. padding: 4rpx 8rpx;
  2015. }
  2016. &:last-child {
  2017. border-bottom: none;
  2018. }
  2019. }
  2020. .ww55 {
  2021. width: 55%;
  2022. }
  2023. .ww45 {
  2024. width: 45%;
  2025. }
  2026. .ww50 {
  2027. width: 50%;
  2028. }
  2029. .ww30 {
  2030. width: 30%;
  2031. }
  2032. .ww70 {
  2033. width: 70%;
  2034. }
  2035. .ww80 {
  2036. width: 80%;
  2037. }
  2038. .ww20 {
  2039. width: 20%;
  2040. }
  2041. .check {
  2042. width: 30rpx;
  2043. height: 30rpx;
  2044. }
  2045. .tag_box {
  2046. padding: 2rpx 10rpx;
  2047. margin-right: 12rpx;
  2048. background: #e6a23c;
  2049. font-size: 22rpx;
  2050. color: #fff;
  2051. border-radius: 4rpx;
  2052. }
  2053. }
  2054. }
  2055. }
  2056. .more {
  2057. position: absolute;
  2058. bottom: 26rpx;
  2059. right: 30rpx;
  2060. font-size: 28rpx;
  2061. color: #666;
  2062. }
  2063. }
  2064. .listCont {
  2065. display: flex;
  2066. align-items: center;
  2067. flex-wrap: wrap;
  2068. margin-top: 20rpx;
  2069. margin-left: 10rpx;
  2070. &.save {
  2071. .u-input {
  2072. border: none;
  2073. }
  2074. }
  2075. .u-input {
  2076. border: 1px solid rgb(229, 229, 229);
  2077. height: 60rpx !important;
  2078. padding: 0 0 0 9px !important;
  2079. }
  2080. .item {
  2081. width: 100%;
  2082. font-size: 28rpx;
  2083. margin-bottom: 10rpx;
  2084. margin-right: 3%;
  2085. /deep/.u-form-item__body {
  2086. padding: 0 !important;
  2087. }
  2088. /deep/.u-input__content__field-wrapper__field,
  2089. /deep/.u-form-item {
  2090. font-size: 28rpx !important;
  2091. }
  2092. text.label {
  2093. width: 120rpx;
  2094. display: inline-block;
  2095. text-align: right;
  2096. margin-right: 20rpx;
  2097. margin-bottom: 20rpx;
  2098. }
  2099. /deep/.uni-date__x-input {
  2100. height: 40rpx;
  2101. font-size: 28rpx;
  2102. }
  2103. /deep/.uni-date {
  2104. width: 48%;
  2105. display: inline-block;
  2106. .uni-icons {
  2107. display: none !important;
  2108. }
  2109. .uni-date-x {
  2110. padding: 0 !important;
  2111. }
  2112. }
  2113. }
  2114. .item text {
  2115. color: #666;
  2116. }
  2117. }
  2118. .selectTime {
  2119. display: flex;
  2120. justify-content: flex-end;
  2121. align-items: center;
  2122. margin-bottom: 10rpx;
  2123. .title {
  2124. flex: 1;
  2125. font-size: 30rpx;
  2126. }
  2127. .timeBox {
  2128. display: flex;
  2129. width: 500rpx;
  2130. .firstBtn {
  2131. margin-right: 10rpx;
  2132. }
  2133. }
  2134. }
  2135. .listBox:last-child {
  2136. border: none !important;
  2137. }
  2138. .textBox {
  2139. border: 1px #f2f2f2 solid;
  2140. height: 160px;
  2141. display: block;
  2142. width: auto !important;
  2143. }
  2144. .saveBtn {
  2145. width: 50%;
  2146. margin: 40rpx auto;
  2147. }
  2148. .top-css {
  2149. border-bottom: 1px solid rgb(207, 204, 204);
  2150. }
  2151. .flex_between {
  2152. display: flex;
  2153. justify-content: space-between;
  2154. }
  2155. </style>