addStock.vue 68 KB

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