addStock.vue 68 KB

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