procurementStorage.vue 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283
  1. <!-- 采购入库(生产非生产性) 默认代入产品 -->
  2. <template>
  3. <div class="procurementStorage">
  4. <el-card shadow="never">
  5. <header-title title="基本信息"></header-title>
  6. <el-form
  7. :model="formData"
  8. ref="formName"
  9. label-width="110px"
  10. :rules="rules"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :span="8">
  14. <el-form-item label="物品类型" prop="extInfo.assetType">
  15. <selectTree
  16. ref="tree"
  17. class="form-ipt"
  18. :isBindPlan="true"
  19. disabled
  20. size="medium"
  21. style="width: 100%"
  22. :value="formData.extInfo.assetType"
  23. clearable
  24. :options="codeList"
  25. :props="{
  26. value: 'id',
  27. label: 'name',
  28. children: 'children'
  29. }"
  30. @getValue="codeListValue"
  31. :isAll="false"
  32. />
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="8">
  36. <el-form-item label="入库类型" prop="bizType">
  37. <el-select
  38. @change="onClear"
  39. filterable
  40. placeholder="请选择"
  41. v-model="formData.bizType"
  42. clearable
  43. :disabled="
  44. !!(warehousingMaterialList && warehousingMaterialList.length)
  45. "
  46. >
  47. <el-option
  48. v-for="item in sceneState"
  49. :key="item.code"
  50. :value="item.code + ''"
  51. :label="item.label"
  52. ></el-option>
  53. </el-select> </el-form-item
  54. ></el-col>
  55. <el-col :span="8">
  56. <el-form-item label="采购收货单" prop="documentSource">
  57. <el-input
  58. placeholder="请输入"
  59. v-model="formData.extInfo.documentSource"
  60. @click.native="handlePicker()"
  61. :disabled="isTask"
  62. >
  63. </el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="8">
  67. <el-form-item label="权属部门" prop="deptName">
  68. <el-input
  69. placeholder="权属部门"
  70. disabled
  71. v-model="formData.extInfo.deptName"
  72. clearable
  73. />
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="8">
  77. <el-form-item label="入库登记人">
  78. <el-input
  79. placeholder="登记人"
  80. disabled
  81. v-model="formData.extInfo.createUserName"
  82. clearable /></el-form-item
  83. ></el-col>
  84. <el-col :span="8" v-if="formData.bizType == 2">
  85. <el-form-item label="供应商" prop="supplierName">
  86. <el-input
  87. placeholder="请输入"
  88. clearable
  89. v-model="formData.extInfo.supplierName"
  90. />
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="8">
  94. <el-form-item label="送货人" prop="fromUser">
  95. <el-input
  96. placeholder="请输入"
  97. v-model="formData.fromUser"
  98. clearable
  99. /> </el-form-item
  100. ></el-col>
  101. <el-col :span="8">
  102. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  103. <el-input
  104. placeholder="请输入"
  105. v-model="formData.extInfo.deliveryPhone"
  106. clearable /></el-form-item
  107. ></el-col>
  108. <el-col :span="24">
  109. <el-form-item label="备注" prop="remark">
  110. <el-input
  111. v-model="formData.remark"
  112. clearable
  113. type="textarea"
  114. placeholder="请详细说明"
  115. :rows="4"
  116. ></el-input>
  117. </el-form-item>
  118. </el-col>
  119. </el-row>
  120. </el-form>
  121. <div class="material">
  122. <header-title title="产品信息">
  123. <el-button
  124. type="primary"
  125. @click="addStock"
  126. v-if="!isTask || isOutsourcing"
  127. >添加</el-button
  128. >
  129. </header-title>
  130. <div class="mt10 form-table">
  131. <el-form
  132. ref="warehousingMaterialListRef"
  133. :model="{ warehousingMaterialList: warehousingMaterialList }"
  134. :show-message="false"
  135. >
  136. <el-button
  137. v-if="warehousingMaterialList.length != 0"
  138. type="success"
  139. plain
  140. style="margin-bottom: 20px; float: right; margin-right: 20px"
  141. size="mini"
  142. @click="listSaveArrs"
  143. >批量保存</el-button
  144. >
  145. <el-table
  146. v-if="isWeight"
  147. :header-cell-style="rowClass"
  148. ref="warehousingMaterialListTable"
  149. :key="formData.extInfo.assetType"
  150. :data="warehousingMaterialList"
  151. tooltip-effect="dark"
  152. style="width: 100%"
  153. stripe
  154. >
  155. <el-table-column
  156. label="序号"
  157. type="index"
  158. width="50"
  159. align="center"
  160. >
  161. </el-table-column>
  162. <el-table-column
  163. label="编码"
  164. prop="assetCode"
  165. align="center"
  166. width="130"
  167. ></el-table-column>
  168. <el-table-column
  169. label="名称"
  170. align="center"
  171. width="200"
  172. prop="assetName"
  173. ></el-table-column>
  174. <el-table-column
  175. v-for="(item, index) in tableHeader"
  176. :key="index"
  177. align="center"
  178. :label="item.label"
  179. width="150"
  180. :prop="item.prop"
  181. >
  182. <template slot-scope="{ row }">
  183. <template v-if="item.formatter">{{
  184. item.formatter(row)
  185. }}</template>
  186. <template v-else>{{ row[item.prop] }}</template>
  187. </template>
  188. </el-table-column>
  189. <el-table-column label="批号" width="100" prop="assetName">
  190. <template slot-scope="{ row, $index }">
  191. <template v-if="row.isSave">
  192. {{ row.manualBatchNo }}
  193. </template>
  194. <el-form-item v-else>
  195. <el-input v-model="row.manualBatchNo"> </el-input>
  196. </el-form-item>
  197. </template>
  198. </el-table-column>
  199. <el-table-column
  200. label="批次号"
  201. prop="batchNo"
  202. width="70"
  203. align="center"
  204. >
  205. <template slot-scope="{ row, $index }">
  206. <template v-if="row.isSave">
  207. {{ row.batchNo }}
  208. </template>
  209. <el-form-item
  210. v-else
  211. :prop="`warehousingMaterialList.${$index}.batchNo`"
  212. required
  213. >
  214. <!-- <el-input v-model="row.batchNo"></el-input> -->
  215. {{ row.batchNo }}
  216. </el-form-item>
  217. </template>
  218. </el-table-column>
  219. <el-table-column
  220. label="最小包装单元"
  221. align="center"
  222. prop="minPackingCount"
  223. width="100"
  224. >
  225. <el-table-column label="" prop="minPackingCount" width="100">
  226. <template slot-scope="{ row, $index }">
  227. <template v-if="row.isSave">
  228. {{ row.minPackingCount }}
  229. </template>
  230. <el-form-item
  231. v-else
  232. :prop="`warehousingMaterialList.${$index}.minPackingCount`"
  233. required
  234. >
  235. <el-input
  236. type="number"
  237. v-model="row.minPackingCount"
  238. @input="minPackingCountChange(row, $event)"
  239. >
  240. </el-input>
  241. </el-form-item>
  242. </template>
  243. </el-table-column>
  244. <el-table-column label="" prop="minPackingCount">
  245. <template slot-scope="{ row, $index }">
  246. {{ handleRowUnit(row) }} /{{ row.minPackUnit }}
  247. </template>
  248. </el-table-column>
  249. </el-table-column>
  250. <el-table-column
  251. label="包装数量"
  252. prop="outInNum"
  253. width="150"
  254. align="center"
  255. >
  256. <template slot-scope="{ row, $index }">
  257. <template v-if="row.isSave || formData.bizType == 5">
  258. {{ row.outInNum }} {{ row.minPackUnit }}
  259. </template>
  260. <el-form-item
  261. v-else
  262. :prop="`warehousingMaterialList.${$index}.outInNum`"
  263. required
  264. >
  265. <el-input
  266. v-model="row.outInNum"
  267. @input="packNum(row, $event)"
  268. >
  269. <template slot="append">
  270. {{ row.minPackUnit ? row.minPackUnit : '/' }}
  271. </template>
  272. </el-input>
  273. </el-form-item>
  274. </template>
  275. </el-table-column>
  276. <el-table-column label="计量数量" prop="counts">
  277. <template slot-scope="{ row, $index }">
  278. {{ $math.format(row.minPackingCount * row.outInNum, 14) }}
  279. </template>
  280. </el-table-column>
  281. <el-table-column
  282. label="计量单位"
  283. prop="batchNo"
  284. width="100"
  285. align="center"
  286. >
  287. <!-- v-if="formData.extInfo.assetType == 1" -->
  288. <template slot-scope="{ row, $index }">
  289. <template>
  290. {{ row.measuringUnit }}
  291. </template>
  292. </template>
  293. </el-table-column>
  294. <el-table-column
  295. label="重量"
  296. align="center"
  297. prop="contentImage"
  298. :show-overflow-tooltip="true"
  299. >
  300. <template slot-scope="{ row, $index }">
  301. {{ row.weight }}
  302. <template slot="append">
  303. {{ handleRowUnit(row) }}
  304. </template>
  305. </template>
  306. </el-table-column>
  307. <el-table-column
  308. label="重量单位"
  309. align="center"
  310. prop="contentImage"
  311. :show-overflow-tooltip="true"
  312. >
  313. <template slot-scope="{ row, $index }">
  314. {{ row.weightUnit }}
  315. <template slot="append"> </template>
  316. </template>
  317. </el-table-column>
  318. <el-table-column
  319. label="单价"
  320. prop="univalence"
  321. width="150"
  322. align="center"
  323. >
  324. <template slot-scope="{ row, $index }">
  325. <el-form-item
  326. :prop="`warehousingMaterialList.${$index}.univalence`"
  327. >
  328. <el-input
  329. v-model="row.univalence"
  330. placeholder="非必填"
  331. @input="
  332. (value) =>
  333. (row.univalence = value.replace(/[^0-9.]+/g, ''))
  334. "
  335. >
  336. <template slot="append">
  337. 元/{{ handleRowUnit(row) }}
  338. </template>
  339. </el-input>
  340. </el-form-item>
  341. </template>
  342. </el-table-column>
  343. <el-table-column
  344. label="金额"
  345. align="center"
  346. prop="contentImage"
  347. :show-overflow-tooltip="true"
  348. >
  349. <template slot-scope="{ row, $index }">
  350. {{
  351. calcSumTotal(
  352. row.outInNum,
  353. row.minPackingCount,
  354. row.univalence,
  355. row
  356. )
  357. }}
  358. </template>
  359. </el-table-column>
  360. <el-table-column
  361. label="货位"
  362. prop="warehouseName"
  363. :show-overflow-tooltip="true"
  364. width="250"
  365. required
  366. >
  367. <template slot-scope="{ row, $index }">
  368. <el-form-item
  369. :prop="`warehousingMaterialList.${$index}.houseList`"
  370. :required="true"
  371. >
  372. <div @click="handleWareHouse(row, $index)">
  373. <div
  374. style="color: #ff4949"
  375. v-if="row.houseList.length == 0"
  376. >
  377. ---(必填)
  378. </div>
  379. <div v-else>
  380. <div
  381. class="fontOmitted"
  382. v-for="(item, index) in row.houseList"
  383. :key="index"
  384. >
  385. {{ item.warehouseName }}- {{ item.areaName }}-
  386. {{ item.shelfCode }}- {{ item.cargoSpaceCode
  387. }}<span style="color: #ff4949" v-if="item.num">
  388. - {{ item.num }}(数)</span
  389. >
  390. <br />
  391. </div>
  392. </div>
  393. </div>
  394. </el-form-item>
  395. </template>
  396. </el-table-column>
  397. <el-table-column
  398. label="质检单"
  399. v-if="formData.extInfo.assetType === 3"
  400. prop="contentImage"
  401. :show-overflow-tooltip="true"
  402. >
  403. <template slot-scope="{ row, $index }">
  404. <upload @on-success="(data) => (row.contentImage = [data])"
  405. ><template slot="placeholder">上传</template></upload
  406. >
  407. </template>
  408. </el-table-column>
  409. <el-table-column
  410. label="操作"
  411. width="200"
  412. fixed="right"
  413. align="center"
  414. >
  415. <template slot="header" slot-scope="scope"> 操作 </template>
  416. <template slot-scope="{ row, $index }">
  417. <el-button
  418. type="text"
  419. v-show="!row.isSave"
  420. @click="listSave(row, $index)"
  421. >保存</el-button
  422. >
  423. <el-button
  424. type="text"
  425. v-show="row.isSave"
  426. @click="listEdit(row, $index)"
  427. >编辑</el-button
  428. >
  429. <el-button type="text" @click="listDel(row, $index)"
  430. >删除</el-button
  431. >
  432. </template>
  433. </el-table-column>
  434. </el-table>
  435. </el-form>
  436. </div>
  437. <div class="mt20">
  438. <header-title :title="`包装明细`">
  439. <div class="switch_right">
  440. <span v-if="materialCodeReqList.length != 0">
  441. 分拆<el-switch
  442. v-model="isSplit"
  443. active-color="#13ce66"
  444. inactive-color="#ff4949"
  445. @change="handleIsDetail"
  446. style="margin-left: 10px"
  447. >
  448. </el-switch>
  449. </span>
  450. <el-button
  451. style="margin-left: 20px"
  452. type="text"
  453. @click="dateSetting"
  454. v-if="formData.bizType != 5"
  455. >批量设置{{
  456. curDateType === 'manufactureTime' ? '生产日期' : '采购日期'
  457. }}</el-button
  458. >
  459. </div>
  460. </header-title>
  461. <el-button
  462. v-if="materialCodeReqList.length != 0"
  463. type="success"
  464. plain
  465. style="margin-bottom: 20px; float: right; margin-right: 20px"
  466. size="mini"
  467. @click="wrapListSave"
  468. >批量保存</el-button
  469. >
  470. <el-table
  471. v-if="isWrapTable"
  472. ref="materialCodeReqListTable"
  473. :data="materialCodeReqList"
  474. tooltip-effect="dark"
  475. :key="formData.bizType"
  476. :header-cell-style="rowClass"
  477. style="width: 100%"
  478. stripe
  479. height="300px"
  480. @selection-change="handleSelectionChange"
  481. >
  482. <el-table-column
  483. label=""
  484. type="selection"
  485. align="center"
  486. width="50"
  487. v-if="formData.bizType != 5"
  488. >
  489. </el-table-column>
  490. <el-table-column label="序号" type="index" width="50">
  491. </el-table-column>
  492. <el-table-column
  493. label="编码"
  494. prop="assetCode"
  495. width="130"
  496. :show-overflow-tooltip="true"
  497. ></el-table-column>
  498. <el-table-column
  499. label="名称"
  500. prop="assetName"
  501. width="150"
  502. :show-overflow-tooltip="true"
  503. ></el-table-column>
  504. <el-table-column
  505. label="批号"
  506. prop="manualBatchNo"
  507. width="100"
  508. ></el-table-column>
  509. <el-table-column
  510. label="批次号"
  511. prop="batchNo"
  512. width="70"
  513. ></el-table-column>
  514. <el-table-column
  515. :label="`包装编码`"
  516. prop="onlyCode"
  517. width="130"
  518. :show-overflow-tooltip="true"
  519. ></el-table-column>
  520. <el-table-column
  521. label="包装数量"
  522. prop="packingCount"
  523. width="80"
  524. ></el-table-column>
  525. <el-table-column
  526. label="包装单位"
  527. prop="packingUnit"
  528. ></el-table-column>
  529. <el-table-column
  530. label="计量数量"
  531. prop="minPackingCount"
  532. ></el-table-column>
  533. <el-table-column
  534. label="计量单位"
  535. prop="measuringUnit"
  536. ></el-table-column>
  537. <el-table-column label="物料代号" prop="materielCode" width="130">
  538. <template slot-scope="{ row }">
  539. <el-input
  540. v-if="!row.isPack"
  541. v-model="row.materielCode"
  542. ></el-input>
  543. <span v-else>{{ row.materielCode }}</span>
  544. </template>
  545. </el-table-column>
  546. <el-table-column label="客户代号" prop="clientCode">
  547. <template slot-scope="{ row }">
  548. <el-input
  549. v-if="!row.isPack"
  550. v-model="row.clientCode"
  551. ></el-input>
  552. <span v-else> {{ row.clientCode }}</span>
  553. </template>
  554. </el-table-column>
  555. <el-table-column label="刻码" prop="engrave">
  556. <template slot-scope="{ row }">
  557. <el-input v-if="!row.isPack" v-model="row.engrave"></el-input>
  558. <span v-else>{{ row.engrave }}</span>
  559. </template>
  560. </el-table-column>
  561. <el-table-column label="重量" prop="weight" width="100">
  562. <template slot-scope="{ row }">
  563. <el-input
  564. v-if="!row.isPack && row.measuringUnit != row.weightUtil"
  565. v-model="row.weight"
  566. @input="weightInput($event, row)"
  567. ></el-input>
  568. <span v-else>{{ row.weight }}</span>
  569. </template>
  570. </el-table-column>
  571. <el-table-column label="重量单位" prop="weightUtil">
  572. <template slot-scope="{ row }">
  573. {{ row.weightUtil }}
  574. </template>
  575. </el-table-column>
  576. <el-table-column label="质检结果" prop="result" width="120">
  577. <template slot-scope="{ row }">
  578. <DictSelection
  579. dictName="质检结果"
  580. clearable
  581. v-model="row.result"
  582. v-if="!row.isPack"
  583. @updateVal="changeWrapStatus($event, row)"
  584. />
  585. <span v-else>{{ qualityResults[row.result] }}</span>
  586. </template>
  587. </el-table-column>
  588. <el-table-column label="质检状态" prop="status" width="120">
  589. <template slot-scope="{ row }">
  590. <span>{{ qualityStatus[row.status] }}</span>
  591. </template>
  592. </el-table-column>
  593. <el-table-column
  594. v-if="formData.bizType != 5"
  595. label="生产日期"
  596. prop=""
  597. width="220"
  598. >
  599. <template slot="header" slot-scope="scope">
  600. <el-select filterable v-model="curDateType">
  601. <el-option
  602. value="manufactureTime"
  603. label="生产日期"
  604. ></el-option>
  605. <el-option
  606. value="procurementTime"
  607. label="采购日期"
  608. ></el-option>
  609. </el-select>
  610. </template>
  611. <template slot-scope="{ row }">
  612. <template v-if="formData.bizType == 5">
  613. {{ row[curDateType] }}
  614. </template>
  615. <el-date-picker
  616. v-else
  617. :disabled="row.ispack"
  618. size="small"
  619. v-model="row[curDateType]"
  620. type="datetime"
  621. value-format="yyyy-MM-dd HH:mm:ss"
  622. placeholder="选择日期"
  623. >
  624. </el-date-picker>
  625. </template>
  626. </el-table-column>
  627. <template v-else>
  628. <el-table-column
  629. label="生产日期"
  630. prop="manufactureTime"
  631. width="200"
  632. ></el-table-column>
  633. <el-table-column
  634. label="采购日期"
  635. prop="procurementTime"
  636. width="200"
  637. ></el-table-column>
  638. </template>
  639. <el-table-column label="操作" width="120" fixed="right">
  640. <template slot-scope="{ row, $index }">
  641. <el-button type="text" @click="packCout(row)">
  642. {{ !row.isPack ? '保存' : '编辑' }}
  643. </el-button>
  644. <el-button type="text" @click="wrapDelete(row, $index)">
  645. 删除
  646. </el-button>
  647. </template>
  648. </el-table-column>
  649. </el-table>
  650. <!-- </el-tab-pane>
  651. </el-tabs> -->
  652. </div>
  653. <div class="mt20" v-if="isSplit">
  654. <header-title :title="`物料明细`"> </header-title>
  655. <el-button
  656. v-if="resultArray.length != 0"
  657. type="success"
  658. plain
  659. style="margin-bottom: 20px; float: right; margin-right: 20px"
  660. size="mini"
  661. @click="materialListSave"
  662. >批量保存</el-button
  663. >
  664. <el-table
  665. v-if="isMaterialTable"
  666. ref="resultArrayTable"
  667. :data="resultArray"
  668. tooltip-effect="dark"
  669. :key="formData.bizType"
  670. :header-cell-style="rowClass"
  671. style="width: 100%"
  672. stripe
  673. height="300px"
  674. @selection-change="handleSelectionChange"
  675. >
  676. <el-table-column label="序号" type="index" width="50">
  677. </el-table-column>
  678. <el-table-column
  679. label="编码"
  680. prop="assetCode"
  681. :show-overflow-tooltip="true"
  682. ></el-table-column>
  683. <el-table-column
  684. label="名称"
  685. prop="assetName"
  686. width="200"
  687. :show-overflow-tooltip="true"
  688. ></el-table-column>
  689. <el-table-column
  690. label="批号"
  691. prop="manualBatchNo"
  692. width="100"
  693. ></el-table-column>
  694. <el-table-column
  695. label="批次号"
  696. prop="batchNo"
  697. width="80"
  698. ></el-table-column>
  699. <el-table-column
  700. label="物料编码"
  701. prop="no"
  702. width="200"
  703. :show-overflow-tooltip="true"
  704. ></el-table-column>
  705. <el-table-column
  706. label="计量数量"
  707. prop="minPackingCount"
  708. width="90"
  709. ></el-table-column>
  710. <el-table-column
  711. width="80"
  712. label="计量单位"
  713. prop="measuringUnit"
  714. ></el-table-column>
  715. <el-table-column label="物料代号" prop="meterielCode" width="130">
  716. <template slot-scope="{ row }">
  717. <el-input
  718. v-model="row.materielCode"
  719. v-if="!row.isPack"
  720. ></el-input>
  721. <span v-else>{{ row.materialCode }}</span>
  722. </template>
  723. </el-table-column>
  724. <el-table-column label="客户代号" prop="clientCode">
  725. <template slot-scope="{ row }">
  726. <el-input
  727. v-model="row.clientCode"
  728. v-if="!row.isPack"
  729. ></el-input>
  730. <span v-else> {{ row.clientCode }}</span>
  731. </template>
  732. </el-table-column>
  733. <el-table-column label="刻码" prop="engrave">
  734. <template slot-scope="{ row }">
  735. <el-input v-model="row.engrave" v-if="!row.isPack"></el-input>
  736. <span v-else> {{ row.engrave }}</span>
  737. </template>
  738. </el-table-column>
  739. <el-table-column width="100" label="重量" prop="weight">
  740. <template slot-scope="{ row }">
  741. <el-input
  742. v-model="row.weight"
  743. v-if="!row.isPack && row.measuringUnit != row.weightUnit"
  744. ></el-input>
  745. <span v-else>{{ row.weight }}</span>
  746. </template>
  747. </el-table-column>
  748. <el-table-column label="重量单位" prop="weightUnit" width="100">
  749. </el-table-column>
  750. <el-table-column label="质检结果" prop="result" width="120">
  751. <template slot-scope="{ row }">
  752. <DictSelection
  753. dictName="质检结果"
  754. clearable
  755. v-model="row.result"
  756. v-if="!row.isPack"
  757. @updateVal="changeWrapStatus($event, row)"
  758. />
  759. <span v-else>{{ qualityResults[row.result] }}</span>
  760. </template>
  761. </el-table-column>
  762. <el-table-column label="质检状态" prop="status" width="120">
  763. <template slot-scope="{ row }">
  764. <span>{{ qualityStatus[row.status] }}</span>
  765. </template>
  766. </el-table-column>
  767. <el-table-column label="操作" width="120" fixed="right">
  768. <template slot-scope="{ row, $index }">
  769. <el-button type="text" @click="materialBtn(row)">
  770. {{ !row.isPack ? '保存' : '编辑' }}
  771. </el-button>
  772. <el-button type="text" @click="materialDelete(row, $index)">
  773. 删除
  774. </el-button>
  775. </template>
  776. </el-table-column>
  777. </el-table>
  778. </div>
  779. </div>
  780. </el-card>
  781. <selectType
  782. :visibleDialog.sync="visibleDialog"
  783. :title="title"
  784. :tableHeader="tableHeader"
  785. :bizScene="formData.bizType"
  786. :type="[selectEquiType]"
  787. :loadTree.sync="loadTree"
  788. @selectTableData="addProduct"
  789. />
  790. <WareHouseDailog
  791. ref="wareHouseDailogRef"
  792. @houseData="houseData"
  793. ></WareHouseDailog>
  794. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  795. <el-date-picker
  796. size="small"
  797. v-model="batchTime"
  798. type="datetime"
  799. style="width: 320px"
  800. value-format="yyyy-MM-dd HH:mm:ss"
  801. placeholder="选择日期"
  802. >
  803. </el-date-picker>
  804. <div style="text-align: right; margin-top: 20px">
  805. <el-button @click="dateVisible = false">取消</el-button>
  806. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  807. >确认</el-button
  808. >
  809. </div>
  810. </el-dialog>
  811. <!-- 销售订单 -->
  812. <picker ref="pickerRef" @success="pickerSuccess" />
  813. </div>
  814. </template>
  815. <script>
  816. import { getOutInBySourceBizNoOrError } from '@/api/classifyManage/index';
  817. import { getProductList } from '@/api/bpm/components/saleManage/contact';
  818. import { getLoginUser } from '@/api/login';
  819. import picker from '@/views/bpm/stockManagement/components/picker.vue';
  820. import outin from '@/api/warehouseManagement/outin';
  821. import { getTreeByGroup, allCategoryLevel } from '@/api/classifyManage';
  822. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  823. import selectUpload from '@/components/selectUpload';
  824. import upload from '@/components/uploadImg';
  825. import { sceneState } from '@/utils/dict/index';
  826. import selectTree from '@/components/selectTree';
  827. import selectType from '@/views/bpm/stockManagement/components/selectType.vue';
  828. import WareHouseDailog from '@/views/bpm/stockManagement/components/WareHouseDailog.vue';
  829. import ReturnSelect from '@/views/bpm/stockManagement/components/ReturnSelect.vue';
  830. import { tableHeader } from '@/views/bpm/handleTask/components/inoutBound/common';
  831. import { getCode } from '@/api/codeManagement/index.js';
  832. import { getReceiveSaleOrderrecordDetail } from '@/api/bpm/components/purchasingManage/purchaseorderreceive';
  833. import { deepClone } from 'ele-admin/lib/utils/core';
  834. export default {
  835. components: {
  836. selectUpload,
  837. selectTree,
  838. selectType,
  839. WareHouseDailog,
  840. upload,
  841. ReturnSelect,
  842. picker
  843. },
  844. data() {
  845. return {
  846. isWrapTable: true, // 包装表格显隐
  847. isMaterialTable: true, // 物料表格显隐
  848. isOutsourcing: false, // 是否委外
  849. isSplit: false, // 是否拆分到物料明细
  850. qualityStatus: {
  851. 0: '未检',
  852. 1: '已检',
  853. 2: '部分检'
  854. }, // 质检状态 0未检 1已检
  855. qualityResults: {
  856. 0: '合格',
  857. 1: '不合格',
  858. 3: '让步接收'
  859. }, // 质检结果 0合格 1不合格 3让步接收
  860. isTask: false,
  861. isWeight: true,
  862. resultArray: [],
  863. pickerRow: {},
  864. codeList: [],
  865. sceneState,
  866. visibleDialog: false,
  867. curDateType: 'manufactureTime',
  868. materialCodeReqListSelected: [],
  869. title: '',
  870. warehousingMaterialList: [],
  871. loadTree: true,
  872. selectEquiType: '',
  873. batchTime: '',
  874. dateVisible: false,
  875. formData: {
  876. extInfo: {
  877. assetType: '', //物品类型
  878. deptCode: '', //部门code
  879. deptName: '', //部门名称
  880. verifyDeptCode: '', //审核部门编码
  881. verifyDeptName: '', //审核部门名称
  882. deliveryName: '', //送货人名称
  883. deliveryPhone: '', //送货人电话
  884. documentSource: '', //销售订单
  885. urgent: '', //紧急状态
  886. supplierId: '', //供应商ID
  887. supplierName: '', //供应商名称
  888. createUserName: '', //创建人名字
  889. contentImage: [] //图片数组
  890. },
  891. fromUser: '', //送货人
  892. bizType: '', //物品类型
  893. verifyId: '', //审核人Id
  894. verifyName: '', //审核人名称
  895. createUserId: '',
  896. remark: ''
  897. },
  898. rules: {
  899. 'extInfo.assetType': {
  900. required: true,
  901. message: '请选择物品类型',
  902. trigger: 'change'
  903. },
  904. bizType: {
  905. required: true,
  906. message: '请选择入库场景',
  907. trigger: 'change'
  908. }
  909. }
  910. };
  911. },
  912. props: ['inboundType'],
  913. computed: {
  914. // 条码信息
  915. materialCodeReqList() {
  916. return this.warehousingMaterialList
  917. .map((i) => i.warehouseLedgerDetails || [])
  918. .flat();
  919. },
  920. tableHeader() {
  921. return tableHeader(this.selectEquiType);
  922. }
  923. },
  924. created() {
  925. this.initData();
  926. },
  927. methods: {
  928. // 包装维度最小包装单元改变——>总重量
  929. minPackingCountChange(row, value) {
  930. if (value >= 0) {
  931. row.minPackingCount = value;
  932. } else {
  933. row.minPackingCount = 0;
  934. }
  935. // row.minPackingCount = value.replace(/^(0+)|[^\d]+/g, '');
  936. if (row.outInNum >= 0 && value >= 0) {
  937. this.packNum(row, row.outInNum);
  938. }
  939. },
  940. // 选择质检结果改变质检状态
  941. changeWrapStatus(resultValue, row) {
  942. switch (resultValue) {
  943. case '':
  944. // 清空质检状态
  945. row.status = '0';
  946. break;
  947. default:
  948. // 默认已检质检状态
  949. row.status = '1';
  950. break;
  951. }
  952. },
  953. weightInput(value, row) {
  954. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  955. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  956. if (decimalCount > 1) {
  957. // 如果小数点个数大于1,移除多余的小数点
  958. const lastIndex = newValue.lastIndexOf('.');
  959. row.weight =
  960. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  961. } else if (decimalCount === 1) {
  962. // 如果小数点个数等于1,允许小数点的输入
  963. row.weight = newValue;
  964. } else {
  965. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  966. }
  967. },
  968. // 拆分物料
  969. handleIsDetail(event) {
  970. this.isSplit = event;
  971. const list = this.materialCodeReqList;
  972. if (event) {
  973. let resultArray = [];
  974. list.forEach((item) => {
  975. // 包装维度改成已保存状态
  976. item.isPack = true;
  977. // 拆分物料维度并生成列表
  978. for (let i = 1; i <= Number(item.minPackingCount); i++) {
  979. resultArray.push({
  980. onlyCode: item.onlyCode,
  981. no: item.onlyCode + i.toString().padStart(4, '0'),
  982. assetCode: item.assetCode,
  983. assetName: item.assetName,
  984. manualBatchNo: item.manualBatchNo,
  985. batchNo: item.batchNo,
  986. minPackingCount: 1,
  987. measuringUnit: item.measuringUnit,
  988. materielCode: item.materielCode,
  989. clientCode: item.clientCode,
  990. weight: this.$math.format(
  991. item.weight / Number(item.minPackingCount),
  992. 14
  993. ),
  994. initWeight: this.$math.format(
  995. item.weight / Number(item.minPackingCount),
  996. 14
  997. ),
  998. weightUnit: item.weightUnit,
  999. engrave: item.engrave,
  1000. result: item.result,
  1001. status: item.status,
  1002. isPack: false
  1003. });
  1004. }
  1005. });
  1006. this.resultArray = resultArray;
  1007. // 批量修改包装明细
  1008. this.isWeight = false;
  1009. this.bulkEditingWrap();
  1010. this.$nextTick(() => {
  1011. this.isWeight = true;
  1012. });
  1013. } else {
  1014. // 包装维度改成编辑状态
  1015. list.forEach((item) => {
  1016. item.isPack = false;
  1017. });
  1018. // 清空物料维度列表
  1019. this.resultArray = [];
  1020. }
  1021. },
  1022. //包装明细保存
  1023. packCout(row) {
  1024. //true保存==》反之
  1025. if (!row.isPack) {
  1026. row.isPack = true;
  1027. const code = row.assetCode;
  1028. const batchNo = row.batchNo;
  1029. //做防护,防止weight字符串类型
  1030. this.materialCodeReqList.forEach((ele) => {
  1031. ele.weight = Number(ele.weight);
  1032. });
  1033. // 修改产品信息重量(包装维度累计)
  1034. this.isWeight = false;
  1035. this.warehousingMaterialList.forEach((item) => {
  1036. if (item.assetCode == code && item.batchNo == batchNo) {
  1037. let arr = [];
  1038. for (const key in this.materialCodeReqList) {
  1039. if (
  1040. this.materialCodeReqList[key].assetCode == item.assetCode &&
  1041. this.materialCodeReqList[key].batchNo == item.batchNo
  1042. ) {
  1043. arr.push({ ...this.materialCodeReqList[key] });
  1044. }
  1045. }
  1046. const count = arr.reduce((acc, curr) => {
  1047. if (curr.isPack) {
  1048. this.$set(curr, 'initWeight', +curr.weight);
  1049. return Number(this.$math.format(+acc + +curr.weight, 14));
  1050. } else {
  1051. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1052. }
  1053. }, 0);
  1054. this.$set(item, 'weight', count);
  1055. }
  1056. });
  1057. this.$nextTick(() => {
  1058. this.isWeight = true;
  1059. });
  1060. } else {
  1061. row.isPack = false;
  1062. }
  1063. this.$nextTick(() => {
  1064. this.isWrapTable = false;
  1065. this.$nextTick(() => {
  1066. this.isWrapTable = true;
  1067. });
  1068. });
  1069. },
  1070. // 批量修改包装明细
  1071. bulkEditingWrap() {
  1072. // 批量修改包装明细列表状态(已保存)
  1073. this.materialCodeReqList.forEach((item) => {
  1074. item.isPack = true;
  1075. });
  1076. // 改变产品明细重量
  1077. this.warehousingMaterialList.forEach((outItem) => {
  1078. let arr = [];
  1079. this.materialCodeReqList.forEach((inneritem) => {
  1080. if (
  1081. inneritem.assetCode == outItem.assetCode &&
  1082. inneritem.batchNo == outItem.batchNo
  1083. ) {
  1084. arr.push(inneritem);
  1085. }
  1086. });
  1087. const count = arr.reduce((acc, curr) => {
  1088. if (curr.isPack) {
  1089. this.$set(curr, 'initWeight', +curr.weight);
  1090. return Number(this.$math.format(+acc + +curr.weight, 14));
  1091. } else {
  1092. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1093. }
  1094. }, 0);
  1095. this.$set(outItem, 'weight', count);
  1096. });
  1097. },
  1098. // 批量修改物料明细
  1099. bulkEditingMaterial() {
  1100. // 批量修改物料明细列表状态(已保存)
  1101. this.resultArray.forEach((item) => {
  1102. item.isPack = true;
  1103. });
  1104. // 改变包装明细重量
  1105. this.materialCodeReqList.forEach((outItem) => {
  1106. let arr = [];
  1107. this.resultArray.forEach((inneritem) => {
  1108. if (
  1109. inneritem.assetCode == outItem.assetCode &&
  1110. inneritem.batchNo == outItem.batchNo
  1111. ) {
  1112. arr.push(inneritem);
  1113. }
  1114. });
  1115. const count = arr.reduce((acc, curr) => {
  1116. if (curr.isPack) {
  1117. this.$set(curr, 'initWeight', +curr.weight);
  1118. return Number(this.$math.format(+acc + +curr.weight, 14));
  1119. } else {
  1120. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1121. }
  1122. }, 0);
  1123. this.$set(outItem, 'weight', count);
  1124. });
  1125. },
  1126. // 物料明细保存
  1127. materialBtn(row) {
  1128. console.log(row.isPack);
  1129. // true保存 false编辑
  1130. if (!row.isPack) {
  1131. this.$set(row, 'isPack', true);
  1132. row.isPack = true;
  1133. // 物料维度修改质检改变包装维度质检(结果和状态)
  1134. this.materialCodeReqList.forEach((outItem) => {
  1135. let arr = [];
  1136. this.resultArray.forEach((inneritem) => {
  1137. if (inneritem.onlyCode == outItem.onlyCode) {
  1138. arr.push(inneritem);
  1139. }
  1140. });
  1141. console.log(arr);
  1142. // 首先判断是未填/合格不合格
  1143. let boolen = arr.every((item) => {
  1144. return (
  1145. item.result === '' ||
  1146. item.result === undefined ||
  1147. item.result === null
  1148. );
  1149. });
  1150. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  1151. if (boolen) {
  1152. this.$set(outItem, 'result', '');
  1153. this.$set(outItem, 'status', '0');
  1154. } else {
  1155. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  1156. let boolen = arr.some((item) => {
  1157. return item.result === '1';
  1158. });
  1159. if (boolen) {
  1160. this.$set(outItem, 'result', '1');
  1161. this.$set(outItem, 'status', '1');
  1162. } else {
  1163. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  1164. let boolen = arr.some((item) => {
  1165. return item.result === '3';
  1166. });
  1167. if (boolen) {
  1168. // 让步接收 已检
  1169. this.$set(outItem, 'result', '3');
  1170. this.$set(outItem, 'status', '1');
  1171. } else {
  1172. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  1173. let boolen = arr.every((item) => {
  1174. return item.result === '0';
  1175. });
  1176. if (boolen) {
  1177. // 合格 已检
  1178. this.$set(outItem, 'result', '0');
  1179. this.$set(outItem, 'status', '1');
  1180. } else {
  1181. // 合格 部分检
  1182. this.$set(outItem, 'result', '0');
  1183. this.$set(outItem, 'status', '2');
  1184. }
  1185. }
  1186. }
  1187. }
  1188. // this.$set(outItem, 'result', boolen ? '1' : '0');
  1189. });
  1190. // 物料维度修改重量改变包装维度重量
  1191. let onlyCode = row.onlyCode;
  1192. this.materialCodeReqList.forEach((item) => {
  1193. if (item.onlyCode === onlyCode) {
  1194. let arr = [];
  1195. for (const key in this.resultArray) {
  1196. if (this.resultArray[key].onlyCode == item.onlyCode) {
  1197. arr.push(this.resultArray[key]);
  1198. }
  1199. }
  1200. const count = arr.reduce((acc, curr) => {
  1201. if (curr.isPack) {
  1202. this.$set(curr, 'initWeight', +curr.weight);
  1203. return Number(this.$math.format(+acc + +curr.weight, 14));
  1204. } else {
  1205. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1206. }
  1207. }, 0);
  1208. this.$set(item, 'weight', count);
  1209. }
  1210. });
  1211. // 包装维度修改重量改变产品信息
  1212. this.isWeight = false;
  1213. // 批量修改包装明细
  1214. this.bulkEditingWrap();
  1215. this.$nextTick(() => {
  1216. this.isWeight = true;
  1217. });
  1218. } else {
  1219. row.isPack = false;
  1220. }
  1221. this.$nextTick(() => {
  1222. this.isWrapTable = false;
  1223. this.isMaterialTable = false;
  1224. this.$nextTick(() => {
  1225. this.isWrapTable = true;
  1226. this.isMaterialTable = true;
  1227. });
  1228. });
  1229. },
  1230. // 重量计算
  1231. packNum(row, value) {
  1232. const total = {
  1233. packingCount: Number(
  1234. row.minPackingCount > 0 ? row.minPackingCount : 0
  1235. ),
  1236. outInNum: Number(row.outInNum > 0 ? row.outInNum : 0)
  1237. };
  1238. if (row.measuringUnit == row.weightUnit) {
  1239. row.weight = Number(
  1240. this.$math.format(
  1241. total.packingCount * 1 * total.outInNum.toFixed(2),
  1242. 14
  1243. )
  1244. );
  1245. } else {
  1246. const totals = Number(
  1247. this.$math.format(total.packingCount * total.outInNum, 14)
  1248. );
  1249. row.weight = Number(
  1250. this.$math.format(
  1251. totals * (row.netWeight > 0 ? row.netWeight.toFixed(2) : 0),
  1252. 14
  1253. )
  1254. );
  1255. }
  1256. return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
  1257. },
  1258. // 根据单据信息初始化产品信息(外部调用)
  1259. async pickerSuccess(row) {
  1260. console.log('---------------------');
  1261. console.log(row);
  1262. this.isTask = true;
  1263. this.pickerRow = row;
  1264. // this.codeListValue(row.categoryLevelTopId);
  1265. this.formData.bizType = '2';
  1266. this.formData.extInfo.documentSource = row.orderNo;
  1267. this.formData.extInfo.assetType = row.categoryLevelTopId;
  1268. this.selectEquiType = row.categoryLevelTopId;
  1269. this.formData.sourceBizNo = row.receiveNo;
  1270. this.formData.fromId = row.id;
  1271. this.formData.clientName = row.partaName;
  1272. this.formData.clientCode = row.partaId;
  1273. this.formData.extInfo.supplierName = row.supplierName;
  1274. this.formData.extInfo.supplierId = row.supplierId;
  1275. const data = await getReceiveSaleOrderrecordDetail(row.id);
  1276. if (this.warehousingMaterialList.length == 0) {
  1277. let list = data.productList.map((item) => {
  1278. return {
  1279. ...item,
  1280. assetName: item.productName,
  1281. assetCode: item.productCode,
  1282. categoryId: item.productCategoryId,
  1283. minPackUnit: item.packingUnit
  1284. };
  1285. });
  1286. await this.onSelectTableData(await this.serachMainCode(list));
  1287. }
  1288. // 委外发货入库(出库再入库)
  1289. if (row.outsourceSendCode) {
  1290. this.isOutsourcing = true;
  1291. this.formData.bizType = '8';
  1292. this.title = '半成品入库';
  1293. getOutInBySourceBizNoOrError(row.outsourceSendCode).then(
  1294. async (res) => {
  1295. if (res.outInDetailVOList && res.outInDetailVOList.length > 0) {
  1296. const batchNo = await getCode('lot_number_code');
  1297. this.warehousingMaterialList = [];
  1298. let arr = res.outInDetailVOList.map(async (goodsiItem) => {
  1299. return new Promise(async (outResolve) => {
  1300. goodsiItem.isSave = true;
  1301. goodsiItem.houseList = [];
  1302. goodsiItem.batchNo = batchNo;
  1303. goodsiItem.assetName = goodsiItem.name;
  1304. goodsiItem.assetCode = goodsiItem.categoryCode;
  1305. goodsiItem.outInNum =
  1306. goodsiItem.packingCount < 1 ? 1 : goodsiItem.packingCount;
  1307. goodsiItem.minPackingCount = goodsiItem.minPackingCount;
  1308. goodsiItem.minPackUnit = goodsiItem.packingUnit;
  1309. this.warehousingMaterialList.push(goodsiItem);
  1310. let res = await outin.getAssetNum({
  1311. assetCode: goodsiItem.assetCode,
  1312. batchNum: goodsiItem.batchNo,
  1313. num: goodsiItem.outInNum < 1 ? 1 : goodsiItem.outInNum
  1314. });
  1315. let arr = goodsiItem.outInDetailRecordVOList.map(
  1316. (wrapItem, index) => {
  1317. return new Promise(async (resolve) => {
  1318. wrapItem.onlyCode = res.shift().onlyCode;
  1319. wrapItem.packingCount =
  1320. wrapItem.packingCount < 1
  1321. ? 1
  1322. : wrapItem.packingCount;
  1323. wrapItem.isPack = true;
  1324. wrapItem.minPackingCount = wrapItem.totalCount;
  1325. wrapItem.assetName = goodsiItem.name;
  1326. wrapItem.assetCode = goodsiItem.categoryCode;
  1327. wrapItem.batchNo = batchNo;
  1328. wrapItem.result =
  1329. wrapItem.result === null
  1330. ? ''
  1331. : String(wrapItem.result);
  1332. // wrapItem.count =
  1333. // wrapItem.outInDetailRecordMaterialDetailVOList.length; // 增加包装计量数量
  1334. // 增加内部重量(解决重量未保存同时参与计算问题)
  1335. wrapItem.initWeight = wrapItem.weight;
  1336. if (
  1337. wrapItem.outInDetailRecordMaterialDetailVOList
  1338. ?.length > 0
  1339. ) {
  1340. wrapItem.outInDetailRecordMaterialDetailVOList.forEach(
  1341. (materialItem, index) => {
  1342. materialItem.id = '';
  1343. materialItem.onlyCode = wrapItem.onlyCode;
  1344. materialItem.no =
  1345. materialItem.onlyCode +
  1346. index.toString().padStart(4, '0');
  1347. materialItem.result =
  1348. materialItem.result === null
  1349. ? ''
  1350. : String(materialItem.result);
  1351. materialItem.batchNo = batchNo;
  1352. materialItem.minPackingCount = 1;
  1353. materialItem.isPack = true;
  1354. // 增加内部重量(解决重量未保存同时参与计算问题)
  1355. materialItem.initWeight = materialItem.weight;
  1356. this.resultArray.push(materialItem);
  1357. }
  1358. );
  1359. }
  1360. resolve(wrapItem);
  1361. });
  1362. }
  1363. );
  1364. Promise.all(arr).then((data) => {
  1365. console.log(goodsiItem);
  1366. goodsiItem.warehouseLedgerDetails = data;
  1367. outResolve(goodsiItem);
  1368. // console.log(this.resultArray);
  1369. // goodsiItem.warehouseLedgerDetails =
  1370. // goodsiItem.outInDetailRecordVOList;
  1371. // if (this.resultArray.length > 0) {
  1372. // this.isSplit = true;
  1373. // }
  1374. });
  1375. });
  1376. });
  1377. Promise.all(arr).then((data) => {
  1378. console.log(this.warehousingMaterialList);
  1379. console.log(this.resultArray);
  1380. this.warehousingMaterialList = data;
  1381. if (this.resultArray.length > 0) {
  1382. this.isSplit = true;
  1383. }
  1384. });
  1385. // this.warehousingMaterialList.forEach((item, index) => {
  1386. // item.manualBatchNo =
  1387. // warehousingMaterialList[index].manualBatchNo;
  1388. // item.minPackingCount = warehousingMaterialList[index].count;
  1389. // item.outInNum = warehousingMaterialList[index].outInNum;
  1390. // item.weight = warehousingMaterialList[index].weight;
  1391. // });
  1392. // this.listSaveArrs().then(() => {
  1393. // this.materialCodeReqList.forEach((item, index) => {
  1394. // item.materielCode = materialCodeReqList[index].materielCode;
  1395. // item.clientCode = materialCodeReqList[index].clientCode;
  1396. // item.engrave = materialCodeReqList[index].engrave;
  1397. // });
  1398. // if (resultArray.length > 0) {
  1399. // this.handleIsDetail(true);
  1400. // this.resultArray.forEach((item, index) => {
  1401. // item.materielCode = resultArray[index].materielCode;
  1402. // item.clientCode = resultArray[index].clientCode;
  1403. // item.engrave = resultArray[index].engrave;
  1404. // });
  1405. // }
  1406. // });
  1407. // console.log(warehousingMaterialList);
  1408. // console.log(materialCodeReqListOrStorage);
  1409. // console.log(resultArray);
  1410. }
  1411. }
  1412. );
  1413. } else {
  1414. this.formData.bizType = '2';
  1415. this.title = '采购入库';
  1416. }
  1417. },
  1418. // 包装删除
  1419. wrapDelete(row, index) {
  1420. // 删除包装
  1421. this.materialCodeReqList.splice(index, 1);
  1422. let outIndex = 0;
  1423. let arr = this.warehousingMaterialList.filter((item, index) => {
  1424. if (item.assetCode == row.assetCode && item.batchNo == row.batchNo) {
  1425. outIndex = index;
  1426. return true;
  1427. }
  1428. });
  1429. // 修改产品
  1430. if (arr[0].minPackingCount * arr[0].outInNum === row.minPackingCount) {
  1431. this.warehousingMaterialList.splice(outIndex, 1);
  1432. } else {
  1433. this.$set(
  1434. this.warehousingMaterialList[outIndex],
  1435. 'outInNum',
  1436. this.warehousingMaterialList[outIndex].outInNum - 1
  1437. );
  1438. }
  1439. // 删除物料
  1440. if (this.resultArray.length > 0) {
  1441. let indexs = [];
  1442. let arr = this.resultArray.filter((item, index) => {
  1443. if (
  1444. item.assetCode == row.assetCode &&
  1445. item.batchNo == row.batchNo
  1446. ) {
  1447. indexs.push(index);
  1448. return true;
  1449. }
  1450. });
  1451. console.log(indexs);
  1452. console.log(arr);
  1453. this.resultArray = this.resultArray.filter((item, index) => {
  1454. return !indexs.includes(index);
  1455. });
  1456. }
  1457. },
  1458. // 物料删除
  1459. materialDelete(row, index) {
  1460. let isBoolen = false;
  1461. // 删除物料
  1462. this.resultArray.splice(index, 1);
  1463. // 修改包装
  1464. let wrapOutIndex = 0;
  1465. let wrapArr = this.materialCodeReqList.filter((item, index) => {
  1466. if (item.assetCode == row.assetCode && item.batchNo == row.batchNo) {
  1467. wrapOutIndex = index;
  1468. return true;
  1469. }
  1470. });
  1471. if (wrapArr[0].minPackingCount === row.minPackingCount) {
  1472. isBoolen = true;
  1473. // 修改产品
  1474. let materialOutIndex = 0;
  1475. let materialArr = this.warehousingMaterialList.filter(
  1476. (item, index) => {
  1477. console.log(wrapOutIndex);
  1478. console.log(this.materialCodeReqList);
  1479. console.log(item.assetCode);
  1480. console.log(this.materialCodeReqList[wrapOutIndex]);
  1481. console.log(this.materialCodeReqList[wrapOutIndex].assetCode);
  1482. console.log('----------------');
  1483. if (
  1484. item.assetCode ==
  1485. this.materialCodeReqList[wrapOutIndex].assetCode &&
  1486. item.batchNo == this.materialCodeReqList[wrapOutIndex].batchNo
  1487. ) {
  1488. materialOutIndex = index;
  1489. return true;
  1490. }
  1491. }
  1492. );
  1493. if (
  1494. materialArr[0].minPackingCount * materialArr[0].outInNum ===
  1495. this.materialCodeReqList[wrapOutIndex].minPackingCount
  1496. ) {
  1497. this.materialCodeReqList.splice(wrapOutIndex, 1);
  1498. this.warehousingMaterialList.splice(materialOutIndex, 1);
  1499. } else {
  1500. this.$set(
  1501. this.warehousingMaterialList[materialOutIndex],
  1502. 'minPackingCount',
  1503. this.warehousingMaterialList[materialOutIndex].minPackingCount - 1
  1504. );
  1505. }
  1506. } else {
  1507. this.$set(
  1508. this.materialCodeReqList[wrapOutIndex],
  1509. 'minPackingCount',
  1510. this.materialCodeReqList[wrapOutIndex].minPackingCount - 1
  1511. );
  1512. }
  1513. if (!isBoolen) {
  1514. // 修改产品
  1515. let materialOutIndex = 0;
  1516. let materialArr = this.warehousingMaterialList.filter(
  1517. (item, index) => {
  1518. console.log(wrapOutIndex);
  1519. console.log(this.materialCodeReqList);
  1520. console.log(item.assetCode);
  1521. console.log(this.materialCodeReqList[wrapOutIndex]);
  1522. console.log(this.materialCodeReqList[wrapOutIndex].assetCode);
  1523. console.log('----------------');
  1524. if (
  1525. item.assetCode ==
  1526. this.materialCodeReqList[wrapOutIndex].assetCode &&
  1527. item.batchNo == this.materialCodeReqList[wrapOutIndex].batchNo
  1528. ) {
  1529. materialOutIndex = index;
  1530. return true;
  1531. }
  1532. }
  1533. );
  1534. if (
  1535. materialArr[0].minPackingCount * materialArr[0].outInNum ===
  1536. this.materialCodeReqList[wrapOutIndex].minPackingCount
  1537. ) {
  1538. this.warehousingMaterialList.splice(materialOutIndex, 1);
  1539. } else {
  1540. this.$set(
  1541. this.warehousingMaterialList[materialOutIndex],
  1542. 'minPackingCount',
  1543. this.warehousingMaterialList[materialOutIndex].minPackingCount - 1
  1544. );
  1545. }
  1546. }
  1547. },
  1548. async serachMainCode(arr) {
  1549. let newArr = [];
  1550. // 使用 Promise.all 来等待所有异步操作完成
  1551. await Promise.all(
  1552. arr.map(async (item) => {
  1553. const data = await getProductList({
  1554. pageNum: 1,
  1555. size: 10,
  1556. categoryLevelId: item.categoryLevelPathIdParent,
  1557. codeEq: item.assetCode
  1558. });
  1559. newArr.push(data.list); // 将结果存储到 newArr 中
  1560. })
  1561. );
  1562. let re = [];
  1563. for (const item of newArr) {
  1564. for (const it of item) {
  1565. re.push(it);
  1566. }
  1567. }
  1568. return re.map((item) => {
  1569. return {
  1570. ...item,
  1571. minPackUnit: item.packingUnit,
  1572. assetCode: item.code,
  1573. assetName: item.name
  1574. };
  1575. });
  1576. },
  1577. onClear() {
  1578. this.formData.extInfo.documentSource = '';
  1579. this.pickerRow = {};
  1580. this.formData.clientName = '';
  1581. this.formData.clientCode = '';
  1582. this.formData.extInfo.supplierName = '';
  1583. this.formData.extInfo.supplierId = '';
  1584. this.$forceUpdate();
  1585. },
  1586. handlePicker() {
  1587. this.$refs.pickerRef.open();
  1588. },
  1589. // 物品类型选择
  1590. codeListValue(val) {
  1591. this.formData.extInfo.assetType = val.id || val;
  1592. this.$forceUpdate();
  1593. this.title = val?.name;
  1594. this.selectEquiType = val?.id || val;
  1595. },
  1596. //计算金额
  1597. calcSumTotal(PackingCount, outInNum, univalence) {
  1598. //最小包装单元,包装数量,单价
  1599. const total = {
  1600. PackingCount: Number(PackingCount > 0 ? PackingCount : 0),
  1601. outInNum: Number(outInNum > 0 ? outInNum : 0),
  1602. univalence: Number(univalence == undefined ? 0 : univalence)
  1603. };
  1604. return Number(
  1605. this.$math.format(
  1606. total.PackingCount * total.outInNum * total.univalence,
  1607. 14
  1608. )
  1609. );
  1610. },
  1611. handleRowUnit(row) {
  1612. return row.measuringUnit;
  1613. },
  1614. rowClass({ row, column, rowIndex, columnIndex }) {
  1615. if (rowIndex === 1) {
  1616. return {
  1617. display: 'none',
  1618. background: '#EEEEEE',
  1619. border: 'none'
  1620. };
  1621. }
  1622. return { background: '#EEEEEE', border: 'none' };
  1623. },
  1624. // 仓库编辑
  1625. handleWareHouse(row, idx) {
  1626. this.$refs.wareHouseDailogRef.open(row, idx);
  1627. },
  1628. // 入库操作
  1629. listEdit(row) {
  1630. this.$set(row, 'isSave', false);
  1631. row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
  1632. row.warehouseLedgerDetails = [];
  1633. // 重置重量
  1634. this.packNum(row, row.outInNum);
  1635. // 清空物料明细防止数据错乱
  1636. if (this.isSplit && this.resultArray?.length > 0) {
  1637. this.handleIsDetail(false);
  1638. }
  1639. },
  1640. // 产品单个保存
  1641. listSave(row, index) {
  1642. // 清空物料明细防止数据错乱
  1643. if (this.isSplit && this.resultArray?.length > 0) {
  1644. this.handleIsDetail(false);
  1645. }
  1646. const fileds = [
  1647. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1648. `warehousingMaterialList.${index}.batchNo`,
  1649. `warehousingMaterialList.${index}.houseList`
  1650. ];
  1651. if (this.formData.bizType == 1) {
  1652. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1653. } else if (this.formData.bizType == 2) {
  1654. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1655. }
  1656. if (this.formData.bizType != 5) {
  1657. fileds.push(
  1658. ...[
  1659. `warehousingMaterialList.${index}.outInNum`,
  1660. `warehousingMaterialList.${index}.minPackingCount`
  1661. ]
  1662. );
  1663. } else if (
  1664. this.warehousingMaterialList.some(
  1665. (i) => !i.selfWarehouseLedgerDetails?.length
  1666. )
  1667. ) {
  1668. this.$message.error('请选择资产编号!');
  1669. return;
  1670. }
  1671. Promise.all(
  1672. fileds.map(
  1673. (item) =>
  1674. new Promise(async (resolve, rej) => {
  1675. this.$refs.warehousingMaterialListRef.validateField(
  1676. item,
  1677. (err) => {
  1678. if (err) {
  1679. rej(err);
  1680. } else {
  1681. resolve();
  1682. }
  1683. }
  1684. );
  1685. })
  1686. )
  1687. )
  1688. .then((res) => {
  1689. this.$set(row, 'isSave', true);
  1690. this.createMaterialCode(row);
  1691. })
  1692. .catch((err) => {
  1693. this.$message.error('请填入必填项!');
  1694. });
  1695. },
  1696. // 产品批量保存
  1697. listSaveArrs() {
  1698. return new Promise((allResolve) => {
  1699. // 已经拆分(还原到未拆封编辑状态)
  1700. if (this.isSplit && this.resultArray.length > 0) {
  1701. this.handleIsDetail(false);
  1702. }
  1703. const rows = this.warehousingMaterialList;
  1704. const indexes = Array.from(
  1705. { length: this.warehousingMaterialList.length },
  1706. (_, index) => index
  1707. );
  1708. let showMessage = true;
  1709. rows.forEach((row, i) => {
  1710. const index = indexes[i];
  1711. let fileds = [
  1712. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1713. `warehousingMaterialList.${index}.batchNo`,
  1714. `warehousingMaterialList.${index}.houseList`
  1715. ];
  1716. if (this.formData.bizType == 1) {
  1717. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1718. } else if (this.formData.bizType == 2) {
  1719. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1720. }
  1721. if (this.formData.bizType != 5) {
  1722. fileds.push(
  1723. ...[
  1724. `warehousingMaterialList.${index}.outInNum`,
  1725. `warehousingMaterialList.${index}.minPackingCount`
  1726. ]
  1727. );
  1728. } else if (
  1729. this.warehousingMaterialList.some(
  1730. (i) => !i.selfWarehouseLedgerDetails?.length
  1731. )
  1732. ) {
  1733. this.$message.error('请选择资产编号!');
  1734. return;
  1735. }
  1736. Promise.all(
  1737. fileds.map(
  1738. (item) =>
  1739. new Promise(async (resolve, rej) => {
  1740. this.$refs.warehousingMaterialListRef.validateField(
  1741. item,
  1742. (err) => {
  1743. if (err) {
  1744. rej(err);
  1745. } else {
  1746. resolve();
  1747. }
  1748. }
  1749. );
  1750. })
  1751. )
  1752. )
  1753. .then(async (res) => {
  1754. this.$set(row, 'isSave', true);
  1755. await this.createMaterialCode(row);
  1756. allResolve();
  1757. })
  1758. .catch((err) => {
  1759. if (showMessage) {
  1760. showMessage = false;
  1761. this.$message.error('请填入必填项!');
  1762. }
  1763. });
  1764. });
  1765. });
  1766. },
  1767. // 批量设置生产日期
  1768. handleSelectionChange(val) {
  1769. this.materialCodeReqListSelected = val;
  1770. },
  1771. dateSetting() {
  1772. if (!this.materialCodeReqListSelected.length) {
  1773. return this.$message.error(`请选择${this.title}明细!`);
  1774. }
  1775. this.dateVisible = true;
  1776. },
  1777. dateConfirm() {
  1778. this.materialCodeReqListSelected.forEach((item) => {
  1779. this.$set(item, this.curDateType, this.batchTime);
  1780. });
  1781. this.dateVisible = false;
  1782. },
  1783. //入库明细删除
  1784. listDel(row, index) {
  1785. this.warehousingMaterialList.splice(index, 1);
  1786. if (this.isSplit && this.resultArray?.length > 0) {
  1787. this.handleIsDetail(false);
  1788. }
  1789. },
  1790. // 入库明细生成条码信息
  1791. async createMaterialCode(row) {
  1792. // 添加相同物品、批次号重新更新明细 原料编码
  1793. const list = this.warehousingMaterialList.filter(
  1794. (i) =>
  1795. i.assetCode === row.assetCode &&
  1796. i.batchNo === row.batchNo &&
  1797. i.isSave
  1798. );
  1799. const num = list.reduce((num, pre) => {
  1800. num += row.isUnpack
  1801. ? pre.outInNum * pre.minPackingCount
  1802. : pre.outInNum - 0;
  1803. return num;
  1804. }, 0);
  1805. const nums = list.reduce((num, pre) => {
  1806. num += pre.outInNum * pre.minPackingCount;
  1807. return num;
  1808. }, 0);
  1809. const res = await outin.getAssetNum({
  1810. assetCode: row.assetCode,
  1811. batchNum: row.batchNo,
  1812. num: num
  1813. });
  1814. // row.measuringUnit == 'PCS' ? nums :
  1815. list.forEach((item) => {
  1816. if (item.warehouseLedgerDetails?.length) {
  1817. item.warehouseLedgerDetails.forEach((i) => {
  1818. i.onlyCode = res.shift().onlyCode;
  1819. });
  1820. } else {
  1821. this.$set(
  1822. item,
  1823. 'warehouseLedgerDetails',
  1824. Array.from(
  1825. new Array(
  1826. item.isUnpack
  1827. ? item.outInNum * item.minPackingCount
  1828. : // : item.measuringUnit == 'PCS'
  1829. // ? +item.outInNum * parseInt(item.minPackingCount)
  1830. +item.outInNum
  1831. ),
  1832. (val, idx) => {
  1833. return {
  1834. ...item,
  1835. onlyCode: res.shift().onlyCode,
  1836. bizStatus: 1,
  1837. contentImage: []
  1838. };
  1839. }
  1840. )
  1841. );
  1842. }
  1843. });
  1844. // 添加相同物品,重复批次号 重新更新明细 包装编码
  1845. const batchList = this.warehousingMaterialList.filter(
  1846. (i) => i.batchNo === row.batchNo && i.isSave
  1847. );
  1848. if (batchList.length) {
  1849. const num = batchList.reduce((num, pre) => {
  1850. num += +pre.outInNum;
  1851. return num;
  1852. }, 0);
  1853. const res1 = await outin.getAssetNum({
  1854. batchNum: row.batchNo,
  1855. num
  1856. });
  1857. if (res1) {
  1858. batchList.forEach((item) => {
  1859. let num = res1.shift()?.num;
  1860. let minPackingCount = item.minPackingCount;
  1861. if (item.warehouseLedgerDetails?.length) {
  1862. item.warehouseLedgerDetails.forEach((i, index) => {
  1863. this.$set(i, 'num', num);
  1864. if (row.code == i.code) {
  1865. if (item.measuringUnit == item.weightUnit) {
  1866. this.$set(i, 'weight', item.minPackingCount);
  1867. this.$set(i, 'initWeight', item.minPackingCount);
  1868. } else {
  1869. this.$set(
  1870. i,
  1871. 'weight',
  1872. Number(
  1873. this.$math.format(
  1874. 1 * item.minPackingCount * item.netWeight,
  1875. 14
  1876. )
  1877. )
  1878. );
  1879. this.$set(
  1880. i,
  1881. 'initWeight',
  1882. Number(
  1883. this.$math.format(
  1884. 1 * item.minPackingCount * item.netWeight,
  1885. 14
  1886. )
  1887. )
  1888. );
  1889. }
  1890. }
  1891. this.$set(i, 'weightUtil', item.weightUnit);
  1892. this.$set(i, 'packingCount', 1);
  1893. this.$set(i, 'packingUnit ', item.packingUnit);
  1894. this.$set(i, 'minPackingCount ', item.minPackingCount);
  1895. this.$set(i, 'measuringUnit', item.measuringUnit);
  1896. this.$set(i, 'isPack', false);
  1897. console.log('inboundType------------', this.inboundType);
  1898. if (this.inboundType == '1') {
  1899. // 生产性采购(未检)
  1900. this.$set(i, 'result', '');
  1901. this.$set(i, 'status', '0');
  1902. } else {
  1903. // 非生产性采购(已检合格)
  1904. this.$set(i, 'result', '0');
  1905. this.$set(i, 'status', '1');
  1906. }
  1907. if (!item.isUnpack) {
  1908. if (index < item.warehouseLedgerDetails.length - 1) {
  1909. num = res1.shift()?.num;
  1910. }
  1911. } else {
  1912. // 拆包的包装编码一致
  1913. minPackingCount--;
  1914. if (
  1915. minPackingCount === 0 &&
  1916. index < item.warehouseLedgerDetails.length - 1
  1917. ) {
  1918. minPackingCount = item.minPackingCount;
  1919. num = res1.shift()?.num;
  1920. }
  1921. }
  1922. });
  1923. }
  1924. });
  1925. }
  1926. }
  1927. },
  1928. // 包装批量保存
  1929. wrapListSave() {
  1930. // 批量修改包装明细
  1931. this.isWeight = false;
  1932. this.bulkEditingWrap();
  1933. this.$nextTick(() => {
  1934. this.isWeight = true;
  1935. });
  1936. },
  1937. // 物料批量保存
  1938. materialListSave() {
  1939. this.resultArray.forEach((item) => {
  1940. if (!item.isPack) {
  1941. this.materialBtn(item);
  1942. }
  1943. });
  1944. },
  1945. // 外部调用获取入库数据
  1946. getReturnStorage() {
  1947. return new Promise((resolve) => {
  1948. console.log(this.warehousingMaterialList);
  1949. if (this.isOutsourcing) {
  1950. let boolen = this.warehousingMaterialList.every(
  1951. (item) => item.houseList.length > 0
  1952. );
  1953. if (!boolen) {
  1954. this.$message.error('请选择产品仓库!');
  1955. return false;
  1956. }
  1957. }
  1958. this.$refs.formName.validate(async (valid) => {
  1959. if (valid) {
  1960. if (!this.warehousingMaterialList?.length) {
  1961. return this.$message.error('请添加入库明细!');
  1962. } else if (
  1963. this.warehousingMaterialList.some((item) => !item.isSave)
  1964. ) {
  1965. return this.$message.error('请保存入库明细!');
  1966. }
  1967. // 默认全部保存
  1968. if (this.resultArray?.length > 0) {
  1969. // 物料批量保存
  1970. this.materialListSave();
  1971. } else {
  1972. // 包装批量保存
  1973. this.wrapListSave();
  1974. }
  1975. this.formatWarehouseMaterialList();
  1976. let arr = this.warehousingMaterialList.map((item) => {
  1977. console.log(item, 'item');
  1978. return {
  1979. netWeight: item.netWeight > 0 ? item.netWeight : 0,
  1980. num: item.num > 0 ? item.num : 0,
  1981. manualBatchNo: item.manualBatchNo,
  1982. batchNo: item.batchNo,
  1983. categoryId:
  1984. this.formData.bizType == 2 || this.formData.bizType == 8
  1985. ? item.categoryId
  1986. ? item.categoryId
  1987. : item.id
  1988. : item.id,
  1989. count:
  1990. item.outInNum > 0 && item.minPackingCount > 0
  1991. ? this.$math.format(
  1992. parseInt(item.outInNum) *
  1993. parseInt(item.minPackingCount),
  1994. 14
  1995. )
  1996. : 0,
  1997. minPackingCount:
  1998. item.minPackingCount > 0 ? item.minPackingCount : 0,
  1999. packingCount: item.outInNum > 0 ? item.outInNum : 0,
  2000. price: item.univalence > 0 ? item.univalence : 0,
  2001. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  2002. position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  2003. remark: '',
  2004. pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  2005. pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
  2006. totalMoney:
  2007. item.outInNum > 0 &&
  2008. item.minPackingCount > 0 &&
  2009. item.univalence > 0
  2010. ? this.$math.format(
  2011. item.outInNum *
  2012. item.minPackingCount *
  2013. item.univalence,
  2014. 14
  2015. )
  2016. : 0,
  2017. weightUnit: item.weightUnit,
  2018. customCode: item.customCode,
  2019. supplierCode: item.supplierCode,
  2020. weight: item.weight > 0 ? item.weight : 0,
  2021. houseList: [
  2022. `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`
  2023. ]
  2024. };
  2025. });
  2026. arr.forEach((item) => {
  2027. if (item.outInDetailRecordAddPOList.length > 0) {
  2028. let list = item.outInDetailRecordAddPOList.map((it) => {
  2029. return this.formatOutInDetailRecordAddPO(it, item);
  2030. });
  2031. item.outInDetailRecordAddPOList = list;
  2032. }
  2033. });
  2034. let obj = { ...this.formData, type: 1 };
  2035. obj.outInDetailAddPOList = arr;
  2036. resolve(obj);
  2037. }
  2038. });
  2039. });
  2040. },
  2041. // 格式化产品信息入库数据
  2042. formatWarehouseMaterialList() {
  2043. for (let key in this.warehousingMaterialList) {
  2044. for (let k in this.warehousingMaterialList[key].houseList) {
  2045. let house = this.warehousingMaterialList[key].houseList[k];
  2046. this.warehousingMaterialList[key].warehouseName =
  2047. house.warehouseName;
  2048. this.warehousingMaterialList[key].areaName = house.areaName;
  2049. this.warehousingMaterialList[key].shelfCode = house.shelfCode;
  2050. this.warehousingMaterialList[key].cargoSpaceCode =
  2051. house.cargoSpaceCode;
  2052. this.warehousingMaterialList[key].warehouseId = house.warehouseId;
  2053. this.warehousingMaterialList[key].areaId = house.areaId;
  2054. this.warehousingMaterialList[key].shelfId = house.shelfId;
  2055. this.warehousingMaterialList[key].cargoSpaceId = house.cargoSpaceId;
  2056. this.warehousingMaterialList[key].num = house.num;
  2057. }
  2058. }
  2059. },
  2060. // 格式化包装明细入库数据
  2061. formatOutInDetailRecordAddPO(it, item) {
  2062. return {
  2063. code: it.onlyCode,
  2064. dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
  2065. dateValue: it[this.curDateType],
  2066. minUnit: it.minPackingCount,
  2067. minPositionId: it.cargoSpaceId,
  2068. minPackingCount: it.minPackingCount,
  2069. name: it.assetName,
  2070. pathIds: item.pathIds,
  2071. unit: it.unit,
  2072. packageNo: it.num > 0 ? it.num : '',
  2073. clientCode: it.clientCode,
  2074. materielCode: it.materielCode,
  2075. weight: it.weight,
  2076. weightUtil: it.weightUtil,
  2077. engrave: it.engrave,
  2078. materialDetails: this.materialDetails(it.onlyCode),
  2079. packingCount: it.packingCount,
  2080. status: it.status,
  2081. result: it.result
  2082. };
  2083. },
  2084. // 过滤物料明细入库数据
  2085. materialDetails(onlyCode) {
  2086. return this.resultArray.filter((item) => item.onlyCode === onlyCode);
  2087. },
  2088. // 添加物品明细
  2089. addProduct(val) {
  2090. // 已经拆分(还原到未拆封编辑状态)
  2091. if (this.isSplit && this.resultArray.length > 0) {
  2092. this.handleIsDetail(false);
  2093. }
  2094. this.onSelectTableData(val);
  2095. },
  2096. //添加产品明细
  2097. async onSelectTableData(val) {
  2098. const res = await getCode('lot_number_code');
  2099. this.warehousingMaterialList.push(
  2100. ...val.map((next) => {
  2101. next.batchNo = res;
  2102. let cur = {};
  2103. next.realInventoryAmount = next.realInventoryAmount || 0;
  2104. cur = {
  2105. ...next,
  2106. cargoSpaceCode: '', //货位编码
  2107. cargoSpaceId: '', //货位id
  2108. shelfId: '', //货架id
  2109. shelfCode: '', //货架名称
  2110. areaId: '', //库区id
  2111. areaName: '', //库区名称
  2112. warehouseId: '', //仓库id
  2113. warehouseName: '', //仓库名称
  2114. assetType: this.formData.extInfo.assetType,
  2115. expirationDate: '',
  2116. outInNum: '',
  2117. minPackingCount: '',
  2118. bizStatus: 1,
  2119. contentImage: [],
  2120. warehouseLedgerDetails: [],
  2121. houseList: []
  2122. };
  2123. return cur;
  2124. })
  2125. );
  2126. },
  2127. async initData() {
  2128. const { data } = await allCategoryLevel();
  2129. this.codeList = data;
  2130. const res = await warehouseDefinition.tree();
  2131. const info = await getLoginUser();
  2132. let obj = res.find(
  2133. (item) => item.id === info.deptId[info.deptId.length - 1]
  2134. );
  2135. if (!obj) return;
  2136. this.formData.extInfo.deptCode = obj.id;
  2137. this.formData.extInfo.deptName = obj.name;
  2138. this.formData.extInfo.createUserName = info.name;
  2139. this.formData.createUserId = info.id;
  2140. },
  2141. // 添加产品信息
  2142. addStock() {
  2143. if (!this.title) {
  2144. return this.$message.error('请选择入库产品类型');
  2145. }
  2146. if (!this.formData.bizType) {
  2147. return this.$message.error('请选择入库场景');
  2148. }
  2149. this.visibleDialog = true;
  2150. },
  2151. upload(data) {
  2152. this.formData.contentImage = data;
  2153. this.$refs.formName.validateField('contentImage');
  2154. },
  2155. houseData(argum, idx) {
  2156. console.log(argum);
  2157. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  2158. }
  2159. },
  2160. watch: {
  2161. // 解决右侧悬浮操作栏不对称问题
  2162. warehousingMaterialList: {
  2163. handler() {
  2164. this.$nextTick(() => {
  2165. this.$refs.warehousingMaterialListTable?.doLayout();
  2166. });
  2167. },
  2168. deep: true
  2169. },
  2170. // 解决右侧悬浮操作栏不对称问题
  2171. materialCodeReqList: {
  2172. handler() {
  2173. this.$nextTick(() => {
  2174. this.$refs.materialCodeReqListTable?.doLayout();
  2175. });
  2176. },
  2177. deep: true
  2178. },
  2179. // 解决右侧悬浮操作栏不对称问题
  2180. resultArray: {
  2181. handler() {
  2182. this.$nextTick(() => {
  2183. this.$refs.resultArrayTable?.doLayout();
  2184. });
  2185. },
  2186. deep: true
  2187. }
  2188. }
  2189. };
  2190. </script>
  2191. <style lang="scss" scoped>
  2192. ::v-deep.form-table {
  2193. .el-form-item {
  2194. margin-bottom: 0;
  2195. }
  2196. .el-input__inner {
  2197. padding: 0 10px;
  2198. }
  2199. ::-webkit-scrollbar {
  2200. width: 8px;
  2201. height: 8px;
  2202. background-color: transparent;
  2203. }
  2204. }
  2205. .p20 {
  2206. padding: 20px;
  2207. }
  2208. .el-select,
  2209. .el-date-editor {
  2210. width: 100%;
  2211. }
  2212. .el-form-item {
  2213. margin-bottom: 22px;
  2214. }
  2215. .material {
  2216. margin-top: 20px;
  2217. .flex {
  2218. display: flex;
  2219. justify-content: space-between;
  2220. font-size: 14px;
  2221. align-items: center;
  2222. .red {
  2223. color: #ff4949;
  2224. }
  2225. }
  2226. }
  2227. .mt10 {
  2228. margin-top: 10px;
  2229. }
  2230. .mt20 {
  2231. margin-top: 20px;
  2232. }
  2233. .center {
  2234. text-align: center;
  2235. }
  2236. .switch_left li {
  2237. border-right: 1px solid rgba(222, 222, 222, 1);
  2238. border-left: 1px solid rgba(222, 222, 222, 1);
  2239. }
  2240. .fontOmitted {
  2241. text-overflow: ellipsis;
  2242. overflow: hidden;
  2243. word-break: break-all;
  2244. white-space: nowrap;
  2245. }
  2246. .table-fixed {
  2247. .el-table__fixed-right {
  2248. height: 100% !important;
  2249. }
  2250. .el-table__fixed-left {
  2251. height: 100% !important;
  2252. }
  2253. .el-table__fixed {
  2254. height: 100% !important;
  2255. }
  2256. }
  2257. </style>