inventoryTable.vue 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <div v-table-scroll-sync class="table-container">
  4. <ele-pro-table
  5. ref="table"
  6. :needPage="false"
  7. :columns="columns"
  8. :datasource="form.datasource"
  9. class="time-form"
  10. @columns-change="handleColumnChange"
  11. :cache-key="cacheKeyUrl"
  12. height="350"
  13. full-height="calc(100vh - 76px)"
  14. :show-summary="true"
  15. :summary-method="getSummaries"
  16. >
  17. <!-- 表头工具栏 -->
  18. <template v-slot:toolbar>
  19. <div class="headbox">
  20. <el-button
  21. v-if="isShowAdd && needProduce != 4"
  22. size="small"
  23. type="primary"
  24. icon="el-icon-plus"
  25. class="ele-btn-icon"
  26. @click="handlAdd"
  27. >
  28. 新增
  29. </el-button>
  30. <el-button
  31. size="small"
  32. type="primary"
  33. icon="el-icon-plus"
  34. class="ele-btn-icon"
  35. @click="handParent()"
  36. v-if="isShowAdd && needProduce == 4"
  37. >
  38. 新增
  39. </el-button>
  40. </div>
  41. </template>
  42. <template v-slot:technicalDrawings="{ row, $index }">
  43. <el-form-item :prop="'datasource.' + $index + '.technicalDrawings'">
  44. <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
  45. </el-form-item>
  46. </template>
  47. <template v-slot:remark="{ row, $index }">
  48. <el-form-item :prop="'datasource.' + $index + '.remark'">
  49. <el-input
  50. clearable
  51. v-model="row.remark"
  52. type="textarea"
  53. placeholder="请输入"
  54. />
  55. </el-form-item>
  56. </template>
  57. <template v-slot:packagingStrength="scope">
  58. <el-form-item>
  59. <DictSelection
  60. dict-name="包装强度"
  61. @change="keyChange(scope.$index, scope.row, 'packagingStrength')"
  62. v-model="scope.row.extField.packagingStrength"
  63. :isOne="scope.$index === 0"
  64. ></DictSelection>
  65. </el-form-item>
  66. </template>
  67. <template v-slot:packagingDensity="scope">
  68. <el-form-item>
  69. <DictSelection
  70. dict-name="包装密度"
  71. @change="keyChange(scope.$index, scope.row, 'packagingDensity')"
  72. v-model="scope.row.extField.packagingDensity"
  73. :isOne="scope.$index === 0"
  74. ></DictSelection>
  75. </el-form-item>
  76. </template>
  77. <template v-slot:batchStockId="scope">
  78. <el-form-item :prop="'datasource.' + scope.$index + '.batchStockId'" :rules="[
  79. {
  80. required: scope.row.isLockSaleOrder == 1 ? true : false,
  81. message: '请选择批次号',
  82. trigger: 'blur'
  83. }
  84. ]">
  85. <!-- <el-input v-model="scope.row.batchNo"></el-input> -->
  86. <el-select
  87. v-model="scope.row.batchStockId"
  88. clearable
  89. placeholder="请选择"
  90. :disabled="scope.row.isLockSaleOrder == 1"
  91. @change="batchNoChange(scope.$index, scope.row)"
  92. >
  93. <el-option
  94. v-for="item in scope.row.batchNoList || []"
  95. :key="item.id"
  96. :label="item.batchNo"
  97. :value="item.id"
  98. >
  99. </el-option>
  100. </el-select>
  101. </el-form-item>
  102. </template>
  103. <!-- 生产编号 可编辑 -->
  104. <template v-slot:productionCodes="{ row }">
  105. <el-form-item>
  106. <el-input v-model="row.productionCodes"></el-input>
  107. </el-form-item>
  108. </template>
  109. <template v-slot:blockCount="scope">
  110. <el-form-item
  111. :prop="'datasource.' + scope.$index + '.blockCount'"
  112. :rules="[{ required: true, message: '请输入', trigger: 'blur' }]"
  113. <ele-pro-table
  114. ref="table"
  115. :needPage="false"
  116. :columns="columns"
  117. :datasource="form.datasource"
  118. class="time-form"
  119. :selection.sync="selection"
  120. @columns-change="handleColumnChange"
  121. @header-dragend="handleHeaderDragend"
  122. :cache-key="cacheKeyUrl"
  123. >
  124. <!-- 表头工具栏 -->
  125. <template v-slot:toolbar>
  126. <div class="headbox">
  127. <el-button
  128. v-if="isShowAdd && needProduce != 4"
  129. size="small"
  130. type="primary"
  131. icon="el-icon-plus"
  132. class="ele-btn-icon"
  133. @click="handlAdd"
  134. >
  135. <el-input
  136. v-model="scope.row.blockCount"
  137. @input="
  138. (val) => tableHandleKeyUp(scope.row, scope.$index, 'blockCount')
  139. "
  140. ></el-input>
  141. </el-form-item>
  142. </template>
  143. <template v-slot:receiveTotalWeight="scope">
  144. <el-form-item
  145. :prop="'datasource.' + scope.$index + '.receiveTotalWeight'"
  146. >
  147. <el-input
  148. type="number"
  149. v-model="scope.row.receiveTotalWeight"
  150. @input="changeSendTotalWeight(scope.row, scope.$index)"
  151. style="width: calc(100% - 70px); margin-right: 10px"
  152. >
  153. <template slot="append">
  154. {{ scope.row.weightUnit }}
  155. </template>
  156. </el-input>
  157. <el-button
  158. size="small"
  159. type="primary"
  160. v-if="entrustedCode"
  161. @click.native="
  162. (e) => handleInnerBound(e, scope.row, scope.$index)
  163. "
  164. >选择
  165. </el-button>
  166. </el-form-item>
  167. </template>
  168. <template v-slot:orderNo="scope">
  169. <el-form-item
  170. :prop="'datasource.' + scope.$index + '.orderNo'"
  171. :rules="[
  172. {
  173. required: false,
  174. message: '请选择订单编号',
  175. trigger: 'blur'
  176. }
  177. ]"
  178. 新增
  179. </el-button>
  180. <el-button
  181. size="small"
  182. type="danger"
  183. icon="el-icon-delete"
  184. class="ele-btn-icon"
  185. :disabled="!selection.length"
  186. @click="batchRemove"
  187. >
  188. 批量删除
  189. </el-button>
  190. </div>
  191. </template>
  192. <template v-slot:technicalDrawings="{ row, $index }">
  193. <el-form-item :prop="'datasource.' + $index + '.technicalDrawings'">
  194. <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
  195. </el-form-item>
  196. </template>
  197. <template v-slot:remark="{ row, $index }">
  198. <el-form-item :prop="'datasource.' + $index + '.remark'">
  199. <el-input
  200. clearable
  201. v-model="row.remark"
  202. type="textarea"
  203. placeholder="请输入"
  204. />
  205. </el-form-item>
  206. </template>
  207. <template v-slot:stockLedger="scope">
  208. <el-form-item>
  209. <el-popover
  210. @hide="() => (selection = [])"
  211. placement="right"
  212. width="60%"
  213. trigger="hover"
  214. >
  215. <el-select
  216. v-if="needProduce == 4 && orderNoList.length > 1"
  217. v-model="scope.row.orderNo"
  218. placeholder="请选择"
  219. >
  220. <el-option
  221. v-for="item in orderNoList"
  222. :key="item.value"
  223. :label="item.label"
  224. :value="item.value"
  225. >
  226. </el-option>
  227. </el-select>
  228. <span v-else>{{ scope.row.orderNo }}</span>
  229. </el-form-item>
  230. </template>
  231. <template v-slot:sendTotalWeight="scope">
  232. <el-form-item
  233. :prop="'datasource.' + scope.$index + '.sendTotalWeight'"
  234. >
  235. <el-input
  236. type="number"
  237. v-model="scope.row.sendTotalWeight"
  238. style="width: 100%"
  239. @input="changeCount(scope.row, scope.$index, true, 'totalWeight')"
  240. >
  241. <template slot="append">
  242. {{ scope.row.weightUnit }}
  243. </template>
  244. </el-input>
  245. </el-form-item>
  246. </template>
  247. <template v-slot:increaseTotalWeight="scope">
  248. <el-form-item
  249. :prop="'datasource.' + scope.$index + '.increaseTotalWeight'"
  250. >
  251. <el-input
  252. type="number"
  253. v-model="scope.row.increaseTotalWeight"
  254. style="width: 100%"
  255. disabled
  256. >
  257. <template slot="append">
  258. {{ scope.row.weightUnit }}
  259. </template>
  260. </el-input>
  261. </el-form-item>
  262. </template>
  263. <template v-slot:warehouseId="scope">
  264. <el-form-item
  265. :prop="'datasource.' + scope.$index + '.warehouseId'"
  266. :rules="[
  267. {
  268. required: isWarehouseId == 1 || scope.row.isLockSaleOrder == 1 ? true : false,
  269. message: '请选择仓库',
  270. trigger: 'blur'
  271. }
  272. ]"
  273. >
  274. <el-select
  275. v-model="scope.row.warehouseId"
  276. clearable
  277. :disabled="scope.row.isLockSaleOrder == 1"
  278. placeholder="请选择"
  279. @change="warehouseChange(scope.$index, scope.row, true)"
  280. >
  281. <el-option
  282. v-for="item in scope.row.warehouseList"
  283. :key="item.warehouseId"
  284. :label="item.warehouseName"
  285. :value="item.warehouseId"
  286. >
  287. </el-option>
  288. </el-select>
  289. </el-form-item>
  290. </template>
  291. <template v-slot:availableCountBase="{ row }">
  292. <span>{{
  293. row.availableCountBase === undefined ||
  294. row.availableCountBase === null
  295. ? 0
  296. : row.availableCountBase
  297. }}</span>
  298. </template>
  299. <template v-slot:singlePrice="scope">
  300. <el-form-item
  301. style="margin-bottom: 20px"
  302. :prop="'datasource.' + scope.$index + '.singlePrice'"
  303. :rules="{
  304. required: true,
  305. message: '请输入正确的单价',
  306. trigger: 'change'
  307. }"
  308. >
  309. <el-input
  310. v-model="scope.row.singlePrice"
  311. placeholder="请输入"
  312. @input="changeCount(scope.row, scope.$index)"
  313. type="number"
  314. >
  315. <template slot="append">元</template>
  316. </el-input>
  317. </el-form-item>
  318. </template>
  319. <template v-slot:singleWeight="scope">
  320. <el-form-item
  321. style="margin-bottom: 20px"
  322. :rules="{
  323. required: false,
  324. trigger: 'change'
  325. }"
  326. :prop="'datasource.' + scope.$index + '.singleWeight'"
  327. >
  328. <el-input
  329. v-model="scope.row.singleWeight"
  330. type="number"
  331. placeholder="请输入"
  332. :disabled="needProduce == 4"
  333. @input="changeCount(scope.row, scope.$index)"
  334. >
  335. <template slot="append">
  336. {{ scope.row.weightUnit }}
  337. </template>
  338. </el-input>
  339. </el-form-item>
  340. </template>
  341. <template v-slot:headerWarehouseNum="{ column }">
  342. <span class="is-required">{{ column.label }}</span>
  343. </template>
  344. <template v-slot:headerWarehouseId="{ column }">
  345. <span :class="isWarehouseId == 1 ? 'is-required' : ''">{{
  346. column.label
  347. }}</span>
  348. </template>
  349. <template v-slot:headerTotalCount="{ column }">
  350. <span class="is-required">{{ column.label }}</span>
  351. </template>
  352. <template v-slot:headerReceiveTotalWeight="{ column }">
  353. <span :class="{ 'is-required': entrustedCode && pricingWay == 2 }">{{
  354. column.label
  355. }}</span>
  356. </template>
  357. <template v-slot:saleCount="scope">
  358. <el-form-item
  359. style="margin-bottom: 20px"
  360. :prop="'datasource.' + scope.$index + '.saleCount'"
  361. :rules="[
  362. {
  363. required: true,
  364. message: '请输入数量',
  365. trigger: 'change'
  366. },
  367. {
  368. validator: (rule, value, callback) => {
  369. if (value === undefined || value === null || value === '') {
  370. callback('请输入数量');
  371. } else if (parseFloat(value) <= 0) {
  372. callback('数量必须大于0');
  373. } else {
  374. callback();
  375. }
  376. },
  377. trigger: 'blur'
  378. }
  379. ]"
  380. >
  381. <el-input
  382. v-model="scope.row.saleCount"
  383. placeholder="请输入"
  384. type="number"
  385. :min="0"
  386. :disabled="sourceType == 4"
  387. @input="changeCount(scope.row, scope.$index, false)"
  388. >
  389. <template slot="append">
  390. <el-select
  391. v-model="scope.row.saleUnitId"
  392. style="width: 80px"
  393. @change="changeCount(scope.row, scope.$index)"
  394. :disabled="clientEnvironmentId == 4 || sourceType == 4"
  395. >
  396. <el-option
  397. :label="item.conversionUnit"
  398. :value="item.id"
  399. v-for="(item, index) in scope.row.packageDispositionList"
  400. :key="index"
  401. ></el-option>
  402. </el-select>
  403. </template>
  404. </el-input>
  405. </el-form-item>
  406. </template>
  407. <template v-slot:cuttingLength="{ row, $index }">
  408. <el-form-item :prop="'datasource.' + $index + '.cuttingLength'">
  409. <el-input v-model="row.cuttingLength" placeholder="请输入">
  410. </el-input>
  411. </el-form-item>
  412. </template>
  413. <!-- <template v-slot:saleUnit="scope">
  414. <el-form-item
  415. style="margin-bottom: 20px"
  416. :prop="'datasource.' + scope.$index + '.saleUnitId'"
  417. >
  418. <el-select
  419. v-model="scope.row.saleUnitId"
  420. style="width: 100%"
  421. @change="changeCount(scope.row, scope.$index)"
  422. :disabled="clientEnvironmentId == 4"
  423. >
  424. <el-option
  425. :label="item.conversionUnit"
  426. :value="item.id"
  427. @click.native="packingChange(item, scope.$index)"
  428. v-for="(item, index) in scope.row.packageDispositionList"
  429. :key="index"
  430. ></el-option>
  431. </el-select>
  432. </el-form-item>
  433. </template> -->
  434. <template v-slot:modelKey="scope">
  435. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'modelKey'">
  436. <DictSelection
  437. dictName="物品机型"
  438. clearable
  439. v-model="scope.row.modelKey"
  440. :isOne="scope.$index === 0"
  441. filterable
  442. allow-create
  443. default-first-option
  444. >
  445. </DictSelection>
  446. </el-form-item>
  447. </template>
  448. <template v-slot:colorKey="scope">
  449. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'colorKey'">
  450. <DictSelection
  451. dictName="物品颜色"
  452. clearable
  453. v-model="scope.row.colorKey"
  454. :isOne="scope.$index === 0"
  455. filterable
  456. allow-create
  457. default-first-option
  458. >
  459. </DictSelection>
  460. </el-form-item>
  461. </template>
  462. <!-- 操作列 -->
  463. <template v-slot:action="scope">
  464. <div>
  465. <el-popconfirm
  466. class="ele-action"
  467. title="确定要删除吗?"
  468. @confirm="remove(scope.$index)"
  469. >
  470. <template v-slot:reference>
  471. <el-link
  472. type="danger"
  473. :underline="false"
  474. icon="el-icon-delete"
  475. >
  476. 删除
  477. </el-link>
  478. </template>
  479. </el-popconfirm>
  480. <el-link
  481. type="primary"
  482. :underline="false"
  483. icon="el-icon-edit"
  484. @click="selectStockLedgerDialogOpen(scope.row)"
  485. >
  486. 替代料
  487. </el-link>
  488. </div>
  489. </template>
  490. </ele-pro-table>
  491. </div>
  492. <productListNew
  493. ref="productListRef"
  494. @changeParent="changeParent"
  495. ></productListNew>
  496. <!--入库详情-->
  497. <innertboundDetailsDialog
  498. v-if="innerboundDetailsDialogFlag"
  499. ref="innerboundDetailsDialogRef"
  500. :innerboundDetailsDialogFlag.sync="innerboundDetailsDialogFlag"
  501. @saveDate="saveInnerDate"
  502. ></innertboundDetailsDialog>
  503. <!-- 库存台账 -->
  504. <stock-ledger-dialog
  505. v-if="stockLedgerDialogFlag"
  506. :stock-ledger-dialog-flag.sync="stockLedgerDialogFlag"
  507. ref="stockLedgerDialogRef"
  508. @getStockLedger="getStockLedger"
  509. ></stock-ledger-dialog>
  510. <selectStockLedgerDialog
  511. ref="selectStockLedgerDialogRef"
  512. @changeParent="replaceTable"
  513. ></selectStockLedgerDialog>
  514. <BIZproductList
  515. ref="BIZproductListRef"
  516. classType="1"
  517. :isGetInventoryTotal="true"
  518. @changeParent="changeParentBiz"
  519. :typeIds="typeIds"
  520. :isFirstRefreshTable="true"
  521. ></BIZproductList>
  522. </el-form>
  523. </template>
  524. <script>
  525. import { numberReg } from 'ele-admin';
  526. import dictMixins from '@/mixins/dictMixins';
  527. import productListNew from './product-listNew.vue';
  528. import {
  529. getWarehouseOutStockInfo,
  530. getIdWarehouseList
  531. } from '@/api/saleManage/saleorder';
  532. import { copyObj } from '@/utils/util';
  533. import innertboundDetailsDialog from '@/BIZComponents/innerboundDetailsDialog.vue';
  534. import stockLedgerDialog from './stockLedger/stockLedgerDialog.vue';
  535. import getDynamicsColumns from '@/mixins/getDynamicsColumns';
  536. import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
  537. import BIZproductList from '@/BIZComponents/product-list.vue';
  538. import tabMixins from '@/mixins/tableColumnsMixin';
  539. import { levelList, pricingWayList, lbjtList } from '@/enum/dict.js';
  540. import { changeCount, formatPrice } from '@/BIZComponents/setProduct.js';
  541. import { parameterGetByCode } from '@/api/main/index.js';
  542. import { getSummaries } from '@/utils/util.js';
  543. import { getBatchList } from '@/api/wms';
  544. import Vue from 'vue';
  545. export default {
  546. mixins: [dictMixins, getDynamicsColumns, tabMixins],
  547. props: {
  548. orderId: String,
  549. orderIds: String,
  550. orderNos: String,
  551. needProduce: [String, Number],
  552. entrustedCode: String,
  553. pricingWay: [String, Number],
  554. isShowAdd: {
  555. type: Boolean,
  556. default: true
  557. },
  558. typeIds: {
  559. type: Array,
  560. default: () => []
  561. },
  562. oldProductList: {
  563. type: Array,
  564. default: () => []
  565. },
  566. sourceType: {
  567. type: [String, Number],
  568. default: ''
  569. },
  570. isTotalCount: {
  571. default: 0
  572. },
  573. isReturnGoodsCreate: {
  574. type: Boolean,
  575. default: false
  576. }
  577. },
  578. components: {
  579. // fileMain,
  580. innertboundDetailsDialog,
  581. productListNew,
  582. stockLedgerDialog,
  583. selectStockLedgerDialog,
  584. BIZproductList
  585. },
  586. data() {
  587. const defaultForm = {
  588. key: null,
  589. endTime: '',
  590. isFirst: 0,
  591. name: '',
  592. startTime: '',
  593. workHour: '',
  594. technicalDrawings: []
  595. // warehouseCode:"",
  596. // warehouseId:'',
  597. // warehouseName:'',
  598. };
  599. return {
  600. cacheKeyUrl: 'eos-saleManage-invoice-inventoryTable-2026082501',
  601. widthsVersion: 0,
  602. current: {},
  603. childrenColumns: [
  604. {
  605. width: 45,
  606. type: 'selection',
  607. columnKey: 'selection',
  608. align: 'center'
  609. },
  610. {
  611. width: 45,
  612. type: 'index',
  613. columnKey: 'index',
  614. align: 'center',
  615. fixed: 'left'
  616. },
  617. {
  618. minWidth: 100,
  619. prop: 'code',
  620. label: '编码',
  621. align: 'center'
  622. },
  623. {
  624. minWidth: 140,
  625. prop: 'barcodes',
  626. label: '发货条码',
  627. align: 'center'
  628. },
  629. {
  630. minWidth: 100,
  631. prop: 'engrave',
  632. label: '刻码',
  633. align: 'center'
  634. }
  635. ],
  636. selection: [],
  637. discountTotalPrice: 0.0,
  638. allPrice: 0.0,
  639. curIndex: null,
  640. innerboundDetailsDialogFlag: false,
  641. stockLedgerDialogFlag: false,
  642. numberReg,
  643. defaultForm,
  644. warehouseList: [],
  645. dynamicsColumns: [],
  646. isWarehouseId: 0,
  647. blockCountColumn: {},
  648. form: {
  649. datasource: []
  650. },
  651. rules: {},
  652. columnsVersion: 1
  653. };
  654. },
  655. created() {
  656. this.requestDict('产地');
  657. this.requestDict('生产类型');
  658. parameterGetByCode({
  659. code: 'eom_saleManage_invoice_warehouseId'
  660. }).then((res) => {
  661. if (res.value) {
  662. this.isWarehouseId = res.value;
  663. }
  664. });
  665. },
  666. computed: {
  667. canHandl() {
  668. return this.form.datasource.length;
  669. },
  670. clientEnvironmentId() {
  671. return this.$store.state.user.info.clientEnvironmentId;
  672. },
  673. orderNoList() {
  674. const temp = this.orderNos?.split(',') || [];
  675. return temp.map((item) => {
  676. return {
  677. label: item,
  678. value: item
  679. };
  680. });
  681. },
  682. columns() {
  683. let columnsVersion = this.columnsVersion;
  684. // 强制重新计算(每次进入时读取缓存宽度)
  685. this.widthsVersion;
  686. const cacheWidths = this.getStorage(this.cacheKeyUrl + 'Widths') || {};
  687. const applyWidth = (col) => {
  688. if (col.prop && cacheWidths[col.prop]) {
  689. return { ...col, width: cacheWidths[col.prop], minWidth: undefined };
  690. }
  691. return col;
  692. };
  693. return [
  694. {
  695. width: 60,
  696. type: 'selection',
  697. columnKey: 'selection',
  698. align: 'center',
  699. fixed: 'left'
  700. },
  701. {
  702. width: 45,
  703. type: 'index',
  704. columnKey: 'index',
  705. align: 'center',
  706. fixed: 'left'
  707. },
  708. {
  709. minWidth: 200,
  710. prop: 'orderNo',
  711. label: '订单编码',
  712. align: 'center',
  713. slot: 'orderNo',
  714. fixed: 'left'
  715. },
  716. {
  717. width: 200,
  718. prop: 'productName',
  719. label: '名称',
  720. slot: 'productName',
  721. align: 'center'
  722. },
  723. {
  724. width: 120,
  725. prop: 'productCode',
  726. label: '编码',
  727. slot: 'productCode',
  728. align: 'center'
  729. },
  730. {
  731. width: 200,
  732. prop: 'productCategoryName',
  733. label: '类型',
  734. slot: 'productCategoryName',
  735. align: 'center'
  736. },
  737. {
  738. width: 140,
  739. prop: 'pricingWay',
  740. label: '计价方式',
  741. align: 'center',
  742. fixed: 'left',
  743. formatter: (row, column) => {
  744. return pricingWayList.find((item) => item.id == row.pricingWay)
  745. ?.name;
  746. }
  747. },
  748. {
  749. width: 160,
  750. prop: 'batchStockId',
  751. label: '批次号',
  752. slot: 'batchStockId',
  753. align: 'center'
  754. },
  755. {
  756. minWidth: 180,
  757. prop: 'systemBatchNo',
  758. label: '系统内部批次号',
  759. align: 'center',
  760. formatter: (row) => row.systemBatchNo || '-'
  761. },
  762. {
  763. width: 160,
  764. prop: 'productBrand',
  765. label: '牌号',
  766. slot: 'productBrand',
  767. align: 'center'
  768. },
  769. {
  770. width: 120,
  771. prop: 'modelType',
  772. label: '型号',
  773. slot: 'modelType',
  774. align: 'center'
  775. },
  776. {
  777. width: 120,
  778. prop: 'specification',
  779. label: '规格',
  780. slot: 'specification',
  781. align: 'center'
  782. },
  783. {
  784. width: 160,
  785. prop: 'modelKey',
  786. label: '机型',
  787. slot: 'modelKey',
  788. align: 'center'
  789. },
  790. {
  791. width: 160,
  792. prop: 'colorKey',
  793. label: '颜色',
  794. slot: 'colorKey',
  795. align: 'center'
  796. },
  797. {
  798. minWidth: 160,
  799. prop: 'productionCodes',
  800. label: '生产编号',
  801. align: 'center',
  802. slot: 'productionCodes'
  803. },
  804. {
  805. minWidth: 280,
  806. prop: 'productionRequirements',
  807. label: '生产要求',
  808. align: 'center'
  809. },
  810. {
  811. minWidth: 120,
  812. prop: 'goodsLevel',
  813. label: '物品级别',
  814. formatter: (_row, _column, cellValue) => {
  815. return levelList.find((item) => item.value == _row.goodsLevel)
  816. ?.label;
  817. },
  818. align: 'center'
  819. },
  820. ...this.dynamicsColumns,
  821. {
  822. width: 120,
  823. prop: 'customerMark',
  824. label: '客户代号',
  825. slot: 'customerMark',
  826. align: 'center'
  827. },
  828. {
  829. width: 200,
  830. prop: 'warehouseId',
  831. label: '仓库名称',
  832. slot: 'warehouseId',
  833. headerSlot: 'headerWarehouseId',
  834. align: 'center'
  835. },
  836. {
  837. width: 100,
  838. prop: 'stockCountBase',
  839. label: '库存数量',
  840. align: 'center'
  841. },
  842. {
  843. width: 100,
  844. prop: 'availableCountBase',
  845. label: '可用数量',
  846. slot: 'availableCountBase',
  847. align: 'center'
  848. },
  849. // {
  850. // width: 100,
  851. // prop: 'stockLedger',
  852. // label: '发货明细',
  853. // slot: 'stockLedger',
  854. // align: 'center'
  855. // },
  856. {
  857. width: 250,
  858. prop: 'saleCount',
  859. label: '发货数量',
  860. slot: 'saleCount',
  861. headerSlot: 'headerTotalCount',
  862. align: 'center'
  863. },
  864. {
  865. width: 150,
  866. prop: 'pendingShipmentQuantity',
  867. label: '待发数量',
  868. align: 'center'
  869. },
  870. {
  871. width: 100,
  872. prop: 'notSendTotalCount',
  873. label: '未出库数量',
  874. align: 'center',
  875. formatter: (row, column) => {
  876. // if (row.notSendTotalCount) {
  877. return row.notSendTotalCount;
  878. // }
  879. }
  880. },
  881. {
  882. width: 100,
  883. prop: 'notGenerateSendCount',
  884. label: '未发数量',
  885. align: 'center',
  886. formatter: (row, column) => {
  887. // if (row.notGenerateSendCount) {
  888. return row.notGenerateSendCount;
  889. // }
  890. }
  891. },
  892. {
  893. width: 120,
  894. prop: 'totalCount',
  895. label: '计量数量',
  896. formatter: (row, column) => {
  897. // if (row.totalCount) {
  898. return row.totalCount + ' ' + row.measuringUnit;
  899. // }
  900. },
  901. align: 'center'
  902. },
  903. {
  904. width: 120,
  905. prop: 'orderTotalCount',
  906. label: '订单数量',
  907. formatter: (row, column) => {
  908. if (row.orderTotalCount) {
  909. return row.orderTotalCount + ' ' + row.measuringUnit;
  910. }
  911. },
  912. align: 'center'
  913. },
  914. {
  915. width: 120,
  916. prop: 'packingSpecification',
  917. align: 'center',
  918. label: '包装规格',
  919. showOverflowTooltip: true
  920. },
  921. // {
  922. // width: 80,
  923. // prop: 'measuringUnit',
  924. // label: '计量单位',
  925. // slot: 'measuringUnit',
  926. // align: 'center'
  927. // },
  928. this.clientEnvironmentId == 4
  929. ? {
  930. width: 150,
  931. prop: 'blockCount',
  932. label: '发货块数',
  933. slot: 'blockCount',
  934. align: 'center'
  935. }
  936. : { width: 1 },
  937. {
  938. width: 200,
  939. prop: 'singleWeight',
  940. slot: 'singleWeight',
  941. label: '单重',
  942. align: 'center'
  943. },
  944. {
  945. width: 250,
  946. prop: 'receiveTotalWeight',
  947. label: '收货总重',
  948. slot: 'receiveTotalWeight',
  949. align: 'center',
  950. headerSlot: 'headerReceiveTotalWeight'
  951. },
  952. {
  953. width: 220,
  954. prop: 'sendTotalWeight',
  955. label: '发货总重',
  956. slot: 'sendTotalWeight',
  957. align: 'center'
  958. },
  959. {
  960. width: 220,
  961. prop: 'increaseTotalWeight',
  962. label: '增重重量',
  963. slot: 'increaseTotalWeight',
  964. align: 'center'
  965. },
  966. {
  967. width: 180,
  968. prop: 'singlePrice',
  969. label: '单价',
  970. slot: 'singlePrice',
  971. align: 'center'
  972. },
  973. {
  974. width: 160,
  975. prop: 'taxRate',
  976. label: '税率',
  977. formatter: (_row, _column, cellValue) => {
  978. return _row.taxRate ? _row.taxRate + '%' : '';
  979. },
  980. align: 'center'
  981. },
  982. {
  983. width: 180,
  984. prop: 'notaxSinglePrice',
  985. label: '不含税单价',
  986. align: 'center'
  987. },
  988. {
  989. width: 160,
  990. prop: 'discountSinglePrice',
  991. label: '折后单价',
  992. slot: 'discountSinglePrice',
  993. align: 'center'
  994. },
  995. {
  996. width: 120,
  997. prop: 'totalPrice',
  998. label: '合计',
  999. slot: 'totalPrice',
  1000. align: 'center'
  1001. },
  1002. {
  1003. width: 160,
  1004. prop: 'notaxTotalPrice',
  1005. label: '含税合计',
  1006. align: 'center'
  1007. },
  1008. {
  1009. width: 120,
  1010. prop: 'discountTotalPrice',
  1011. label: '折后合计',
  1012. slot: 'discountTotalPrice',
  1013. align: 'center'
  1014. },
  1015. {
  1016. minWidth: 280,
  1017. prop: 'cuttingLength',
  1018. label: '裁线米段',
  1019. align: 'center',
  1020. slot: 'cuttingLength'
  1021. },
  1022. {
  1023. width: 120,
  1024. prop: 'imgCode',
  1025. align: 'center',
  1026. label: '图号/件号',
  1027. showOverflowTooltip: true
  1028. },
  1029. {
  1030. width: 120,
  1031. prop: 'produceType',
  1032. align: 'center',
  1033. label: '属性类型',
  1034. formatter: (row, column) => {
  1035. if (row.produceType) {
  1036. return row.produceType
  1037. .map((item) => {
  1038. return lbjtList[item];
  1039. })
  1040. .toString();
  1041. }
  1042. },
  1043. showOverflowTooltip: true
  1044. },
  1045. {
  1046. width: 200,
  1047. prop: 'guaranteePeriod',
  1048. label: '有效期',
  1049. slot: 'guaranteePeriod',
  1050. formatter: (_row, _column, cellValue) => {
  1051. let val = '';
  1052. if (_row.guaranteePeriod) {
  1053. val += _row.guaranteePeriod;
  1054. }
  1055. if (_row.guaranteePeriodUnitName) {
  1056. val += _row.guaranteePeriodUnitName;
  1057. }
  1058. return val;
  1059. },
  1060. align: 'center'
  1061. },
  1062. {
  1063. width: 200,
  1064. prop: 'guaranteePeriodDeadline',
  1065. label: '有效期截止日期',
  1066. slot: 'guaranteePeriodDeadline',
  1067. align: 'center'
  1068. },
  1069. {
  1070. prop: 'provenance',
  1071. label: '产地',
  1072. slot: 'provenance',
  1073. align: 'center',
  1074. // show:this.contractBookType==2,
  1075. minWidth: 200,
  1076. showOverflowTooltip: true,
  1077. formatter: (row, column) => {
  1078. return row.provenance && row.provenance.length
  1079. ? row.provenance
  1080. .map((item) => this.getDictValue('产地', item))
  1081. .join(',')
  1082. : '';
  1083. }
  1084. },
  1085. {
  1086. width: 130,
  1087. prop: 'technicalAnswerName',
  1088. label: '技术答疑人',
  1089. slot: 'technicalAnswerName',
  1090. align: 'center'
  1091. },
  1092. {
  1093. width: 220,
  1094. prop: 'technicalParams',
  1095. label: '技术参数',
  1096. slot: 'technicalParams',
  1097. align: 'center'
  1098. },
  1099. {
  1100. width: 240,
  1101. prop: 'technicalDrawings',
  1102. label: '技术图纸',
  1103. slot: 'technicalDrawings',
  1104. align: 'center'
  1105. },
  1106. {
  1107. width: 220,
  1108. prop: 'remark',
  1109. label: '备注',
  1110. slot: 'remark',
  1111. align: 'center'
  1112. },
  1113. {
  1114. columnKey: 'action',
  1115. label: '操作',
  1116. width: 200,
  1117. align: 'center',
  1118. resizable: false,
  1119. slot: 'action',
  1120. fixed: 'right',
  1121. showOverflowTooltip: true
  1122. }
  1123. ].map(applyWidth);
  1124. }
  1125. },
  1126. mounted() {
  1127. // this.clientEnvironmentId =
  1128. },
  1129. methods: {
  1130. formatPrice,
  1131. getSummaries(param) {
  1132. return getSummaries(
  1133. param,
  1134. ['saleCount', 'blockCount', 'totalCount'],
  1135. ' '
  1136. );
  1137. },
  1138. //发货明细选择
  1139. stockLedgerSelect(row, index) {
  1140. this.curIndex = index;
  1141. this.stockLedgerDialogFlag = true;
  1142. this.$nextTick(() => {
  1143. this.$refs.stockLedgerDialogRef.init(row.sendProductDetail, row);
  1144. });
  1145. },
  1146. packingChange(item, index) {
  1147. this.$set(this.form.datasource[index], 'saleUnit', item.conversionUnit);
  1148. },
  1149. //获取
  1150. getStockLedger(sendProductDetail) {
  1151. if (!this.form.datasource[this.curIndex].sendProductDetail)
  1152. this.form.datasource[this.curIndex].sendProductDetail = [];
  1153. let row = this.form.datasource[this.curIndex];
  1154. row.sendProductDetail.push(...sendProductDetail);
  1155. this.form.datasource[this.curIndex] = row;
  1156. this.$refs['childrenTable' + this.curIndex].reload();
  1157. this.$refs.table.reload();
  1158. },
  1159. //删除发货明细
  1160. stockLedgerRemove(PIndex) {
  1161. let row = this.form.datasource[PIndex];
  1162. this.selection.forEach((item) => {
  1163. let index = row.sendProductDetail.findIndex((i) => i.id == item.id);
  1164. row.sendProductDetail.splice(index, 1);
  1165. });
  1166. this.form.datasource[PIndex] = row;
  1167. this.$refs['childrenTable' + PIndex].reload();
  1168. this.$refs.table.reload();
  1169. this.selection = [];
  1170. },
  1171. // 将接口返回的库存数量和可用数量同步到当前物品清单行。
  1172. setWarehouseOutStock(index, stockInfo) {
  1173. const stockCountBase = stockInfo?.stockCountBase || 0;
  1174. const availableCountBase = stockInfo?.availableCountBase || 0;
  1175. this.$set(
  1176. this.form.datasource[index],
  1177. 'stockCountBase',
  1178. stockCountBase
  1179. );
  1180. this.$set(
  1181. this.form.datasource[index],
  1182. 'availableCountBase',
  1183. availableCountBase
  1184. );
  1185. // 保留原字段,兼容已有发货数量校验和提交逻辑。
  1186. this.$set(
  1187. this.form.datasource[index],
  1188. 'warehouseNum',
  1189. availableCountBase
  1190. );
  1191. },
  1192. async refreshWarehouseOutStock(index, row) {
  1193. if (!row.warehouseId) {
  1194. this.setWarehouseOutStock(index, {});
  1195. return;
  1196. }
  1197. const stockInfo = await getWarehouseOutStockInfo({
  1198. warehouseId: row.warehouseId,
  1199. code: row.productCode,
  1200. batchNo: row.batchNo,
  1201. systemBatchNo: row.systemBatchNo,
  1202. colorKey: row.colorKey,
  1203. modelType: row.modelType
  1204. });
  1205. this.setWarehouseOutStock(index, stockInfo);
  1206. },
  1207. async warehouseChange(index, row, isReset = false) {
  1208. console.log('warehouseChange', index, row.warehouseId, isReset);
  1209. const data = row.warehouseList.find(
  1210. (item) => item.warehouseId == row.warehouseId
  1211. );
  1212. console.log('warehouseChange', data);
  1213. this.$set(
  1214. this.form.datasource[index],
  1215. 'warehouseName',
  1216. data?.warehouseName || ''
  1217. );
  1218. this.$set(
  1219. this.form.datasource[index],
  1220. 'warehouseCode',
  1221. data?.warehouseCode || 0
  1222. );
  1223. const tempBatchNoList = await getBatchList({
  1224. warehouseId: data?.warehouseId || '',
  1225. categoryCode: row.productCode,
  1226. colorKey: row.colorKey,
  1227. modelType: row.modelType,
  1228. });
  1229. this.$set(
  1230. this.form.datasource[index],
  1231. 'batchNoList',
  1232. tempBatchNoList?.list || []
  1233. );
  1234. if (isReset) {
  1235. this.$set(this.form.datasource[index], 'batchStockId', '');
  1236. this.$set(this.form.datasource[index], 'batchNo', '');
  1237. this.$set(this.form.datasource[index], 'systemBatchNo', '');
  1238. }
  1239. await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
  1240. },
  1241. //批次号选择
  1242. async batchNoChange(index, row) {
  1243. if (!row.batchStockId) {
  1244. this.$set(this.form.datasource[index], 'batchStockId', '');
  1245. this.$set(this.form.datasource[index], 'batchNo', '');
  1246. this.$set(this.form.datasource[index], 'systemBatchNo', '');
  1247. // this.$set(this.form.datasource[index], 'warehouseNum', '');
  1248. const tempWarehouse = await getIdWarehouseList({
  1249. categoryId: this.form.datasource[index].productId
  1250. });
  1251. // 有仓库列表
  1252. if (tempWarehouse?.length) {
  1253. console.log('666~~~~!!', index, tempWarehouse);
  1254. this.$set(
  1255. this.form.datasource[index],
  1256. 'warehouseList',
  1257. tempWarehouse
  1258. );
  1259. }
  1260. await this.refreshWarehouseOutStock(
  1261. index,
  1262. this.form.datasource[index]
  1263. );
  1264. return;
  1265. }
  1266. const data = row.batchNoList.find(
  1267. (item) => item.id == row.batchStockId
  1268. );
  1269. this.$set(this.form.datasource[index], 'batchNo', data.batchNo);
  1270. this.$set(
  1271. this.form.datasource[index],
  1272. 'systemBatchNo',
  1273. data.systemBatchNo
  1274. );
  1275. await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
  1276. },
  1277. //改变数量
  1278. changeCount(row, index, isBlockCount = true, weightType) {
  1279. if (weightType == 'totalWeight') {
  1280. this.$set(
  1281. this.form.datasource[index],
  1282. 'totalWeight',
  1283. this.form.datasource[index].sendTotalWeight
  1284. );
  1285. }
  1286. this.$set(
  1287. this.form.datasource,
  1288. index,
  1289. changeCount(
  1290. row,
  1291. {
  1292. countKey: 'saleCount',
  1293. unitKey: 'saleUnit',
  1294. unitIdKey: 'saleUnitId'
  1295. },
  1296. false,
  1297. weightType
  1298. )
  1299. );
  1300. this.$set(
  1301. this.form.datasource[index],
  1302. 'sendTotalWeight',
  1303. this.form.datasource[index].totalWeight
  1304. );
  1305. this.changeSendTotalWeight(row, index);
  1306. this.getNotaxSinglePrice();
  1307. this.$forceUpdate();
  1308. if (this.clientEnvironmentId == 4 && !isBlockCount) {
  1309. this.tableHandleKeyUp(row, index, 'sum');
  1310. }
  1311. },
  1312. //修改发货总重
  1313. changeSendTotalWeight(row, index) {
  1314. this.curIndex = index;
  1315. this.setIcreaseTotalWeight(row);
  1316. },
  1317. keyChange(index, row, key) {
  1318. this.$set(
  1319. this.form.datasource[index],
  1320. 'extField.' + key,
  1321. row.extField[key]
  1322. );
  1323. this.$forceUpdate();
  1324. },
  1325. //设置增重总重
  1326. setIcreaseTotalWeight(row) {
  1327. let receiveTotalWeight = Number(
  1328. this.form.datasource[this.curIndex]?.receiveTotalWeight
  1329. );
  1330. let sendTotalWeight = Number(
  1331. this.form.datasource[this.curIndex]?.sendTotalWeight
  1332. );
  1333. if (sendTotalWeight) {
  1334. let increaseTotalWeight = sendTotalWeight - receiveTotalWeight;
  1335. this.$set(
  1336. this.form.datasource[this.curIndex],
  1337. 'increaseTotalWeight',
  1338. increaseTotalWeight.toFixed(4)
  1339. );
  1340. if (row.pricingWay == 3) {
  1341. this.$set(
  1342. this.form.datasource[this.curIndex],
  1343. 'totalPrice',
  1344. (increaseTotalWeight * row.singlePrice).toFixed(2)
  1345. );
  1346. }
  1347. }
  1348. this.$refs.table.reload();
  1349. this.$forceUpdate();
  1350. },
  1351. //计算不含税单价
  1352. getNotaxSinglePrice() {
  1353. this.form.datasource.forEach((item, index) => {
  1354. if (item.singlePrice && item.taxRate) {
  1355. this.$set(
  1356. this.form.datasource[index],
  1357. 'notaxSinglePrice',
  1358. formatPrice(item.singlePrice / (1 + item.taxRate / 100))
  1359. );
  1360. } else {
  1361. this.$set(this.form.datasource[index], 'notaxSinglePrice', '');
  1362. }
  1363. });
  1364. },
  1365. //入库单详情
  1366. handleInnerBound(e, rows, index) {
  1367. this.curIndex = index;
  1368. this.innerboundDetailsDialogFlag = true;
  1369. this.$nextTick(() => {
  1370. let row = {
  1371. code: this.entrustedCode
  1372. };
  1373. this.$refs.innerboundDetailsDialogRef.init(row);
  1374. });
  1375. },
  1376. //选择入库单信息
  1377. saveInnerDate(data = []) {
  1378. let totalWeight = data.reduce((num, row) => {
  1379. num += Number(row.weight);
  1380. return num;
  1381. }, 0);
  1382. this.$set(
  1383. this.form.datasource[this.curIndex],
  1384. 'receiveTotalWeight',
  1385. totalWeight
  1386. );
  1387. console.log(totalWeight, 'totalWeight');
  1388. this.setIcreaseTotalWeight(this.form.datasource[this.curIndex]);
  1389. },
  1390. // getWeightPrice() {
  1391. // let increaseTotalWeight =
  1392. // this.form.datasource[this.curIndex].increaseTotalWeight;
  1393. // let singlePrice = this.form.datasource[this.curIndex].singlePrice;
  1394. // let discountSinglePrice =
  1395. // this.form.datasource[this.curIndex].discountSinglePrice;
  1396. // this.$set(
  1397. // this.form.datasource[this.curIndex],
  1398. // 'totalPrice',
  1399. // (Number(increaseTotalWeight) * Number(singlePrice)).toFixed(2)
  1400. // );
  1401. // this.$set(
  1402. // this.form.datasource[this.curIndex],
  1403. // 'discountTotalPrice',
  1404. // (Number(discountSinglePrice) * Number(increaseTotalWeight)).toFixed(2)
  1405. // );
  1406. // },
  1407. // 表格:模数、数量(方)、块数输入框 输入事件
  1408. tableHandleKeyUp(row, index, name) {
  1409. if (row.specification) {
  1410. let modelArr = row.specification.split('*');
  1411. let modelLong = modelArr[0]; // model规格长度
  1412. let modeWide = modelArr[1]; // model规格宽度
  1413. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1414. modeHight = Number(modeHight);
  1415. if (name === 'sum') {
  1416. // row.blockCount = Math.floor(
  1417. // row.totalCount / ((modelLong * modeWide * modeHight) / 1000000)
  1418. // );
  1419. this.$set(
  1420. this.form.datasource[index],
  1421. 'blockCount',
  1422. Math.floor(
  1423. row.totalCount / ((modelLong * modeWide * modeHight) / 1000000)
  1424. )
  1425. );
  1426. } else if (name === 'blockCount') {
  1427. row.totalCount =
  1428. (Number(row.blockCount) * modelLong * modeWide * modeHight) /
  1429. 1000000;
  1430. row.saleCount = row.totalCount;
  1431. this.changeCount(row, index, true);
  1432. }
  1433. }
  1434. },
  1435. //选择产品回调
  1436. async changeParent(obj) {
  1437. console.log(obj, 'obj');
  1438. obj.forEach((item) => {
  1439. item.orderTotalCount = item.totalCount;
  1440. item.id = '';
  1441. });
  1442. this.putTableValue(copyObj(obj));
  1443. },
  1444. //选择产品回调
  1445. changeParentBiz(obj = [], idx) {
  1446. console.log('obj~~~', obj, idx);
  1447. obj.forEach(async (item, index) => {
  1448. let i = idx == -1 ? index : idx;
  1449. let row = JSON.parse(JSON.stringify(this.defaultForm));
  1450. row.key = this.form.datasource.length + 1;
  1451. row['tempId'] = this.form.datasource.length + 1;
  1452. let parasm = idx == -1 ? row : this.form.datasource[i];
  1453. console.log('parasm~~~~222', parasm);
  1454. this.$set(parasm, 'productId', item.id);
  1455. this.$set(parasm, 'categoryName', item.name);
  1456. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  1457. this.$set(parasm, 'productBrand', item.brandNum);
  1458. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  1459. this.$set(parasm, 'productCode', item.code);
  1460. this.$set(parasm, 'productName', item.name);
  1461. this.$set(parasm, 'modelType', item.modelType);
  1462. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  1463. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  1464. this.$set(parasm, 'specification', item.specification);
  1465. this.$set(parasm, 'weightUnit', item.weightUnit);
  1466. this.$set(parasm, 'imgCode', item.imgCode);
  1467. this.$set(parasm, 'produceType', item.componentAttribute);
  1468. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  1469. this.$set(parasm, 'extField', item.extField || {});
  1470. this.$set(parasm, 'singleWeight', item.netWeight);
  1471. this.$set(parasm, 'pricingWay', item.pricingWay || 1);
  1472. this.$set(parasm, 'singlePrice', 0);
  1473. this.$set(parasm, 'discountSinglePrice', 0);
  1474. this.$set(parasm, 'goodsLevel', item.goodsLevel);
  1475. this.$set(parasm, 'orderNo', this.orderNoList[0]?.value || '');
  1476. if (item.modelKey) {
  1477. this.$set(parasm, 'modelKey', item.modelKey);
  1478. }
  1479. if (item.colorKey) {
  1480. this.$set(parasm, 'colorKey', item.colorKey);
  1481. }
  1482. this.$set(parasm, 'receiveTotalWeight', 0);
  1483. this.$set(parasm, 'sendTotalWeight', 0);
  1484. this.$set(parasm, 'increaseTotalWeight', 0);
  1485. this.$set(
  1486. parasm,
  1487. 'packageDispositionList',
  1488. item.packageDispositionList
  1489. );
  1490. if (item.packageDispositionList?.length) {
  1491. this.$set(parasm, 'saleUnitId', item.packageDispositionList[0].id);
  1492. this.$set(
  1493. parasm,
  1494. 'saleUnit',
  1495. item.packageDispositionList[0].conversionUnit
  1496. );
  1497. }
  1498. this.$set(
  1499. parasm,
  1500. 'warehouseList',
  1501. await getIdWarehouseList({
  1502. categoryId: item.id
  1503. })
  1504. );
  1505. const templist = await getBatchList({
  1506. categoryCode: item.code,
  1507. warehouseId: item.warehouseId,
  1508. colorKey: item.colorKey,
  1509. modelType: item.modelType,
  1510. size: -1
  1511. });
  1512. this.$set(parasm, 'batchNoList', templist?.list);
  1513. console.log('parasm~~~~333', parasm);
  1514. this.$set(
  1515. parasm,
  1516. 'packingSpecification',
  1517. item.extField?.packingSpecification
  1518. );
  1519. this.$set(
  1520. parasm,
  1521. 'supplierMark',
  1522. this.form.datasource[0]?.supplierMark
  1523. );
  1524. if (item.purchaseOrigins?.length > 0) {
  1525. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  1526. }
  1527. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1528. console.log('parasm~~~~', parasm);
  1529. console.log('row~~~~', row);
  1530. if (idx == -1) {
  1531. this.form.datasource.push(row);
  1532. }
  1533. console.log('this.form.datasource~~~~', this.form.datasource);
  1534. });
  1535. },
  1536. replaceTable(list) {
  1537. console.log('list~~~~', list);
  1538. list.forEach((item) => {
  1539. item['relationId'] = this.current.tempId;
  1540. });
  1541. this.$emit('replaceTableChange', list);
  1542. },
  1543. // validateTotalCount(row) {
  1544. // return (rule, value, callback) => {
  1545. // if (isNaN(value) || Number(value) <= 0) {
  1546. // this.$message.error('请输入大于0的数');
  1547. // callback(false);
  1548. // } else else {
  1549. // callback();
  1550. // }
  1551. // };
  1552. // },
  1553. // 返回列表数据
  1554. getTableValue() {
  1555. let comitDatasource = this.form.datasource;
  1556. if (comitDatasource.length === 0) return [];
  1557. comitDatasource.forEach(async (v) => {
  1558. // 清空批次时同步清理批次库存 ID,避免更新接口残留旧批次。
  1559. if (!v.batchNo) {
  1560. v.batchNo = '';
  1561. v.systemBatchNo = '';
  1562. v.batchStockId = '';
  1563. }
  1564. if (v.modelKey) {
  1565. v.modelKey = v.modelKey;
  1566. }
  1567. if (v.colorKey) {
  1568. v.colorKey = v.colorKey;
  1569. }
  1570. v.totalCount = Number(v.totalCount);
  1571. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  1572. ? v.technicalDrawings
  1573. : [];
  1574. v.customerReqFiles = Array.isArray(v.customerReqFiles)
  1575. ? v.customerReqFiles
  1576. : [];
  1577. v.industryArtFiles = v.industryArtFiles || [];
  1578. v.otherFiles = v.otherFiles || [];
  1579. });
  1580. return comitDatasource;
  1581. },
  1582. getPrice() {
  1583. return [this.allPrice];
  1584. },
  1585. //修改回显
  1586. putTableValue(data, isInit) {
  1587. if (isInit) {
  1588. this.form.datasource = [];
  1589. }
  1590. if (data) {
  1591. this.setValue(data);
  1592. }
  1593. },
  1594. setValue(data) {
  1595. console.log('setValue~~~~~~', data, this.sourceType);
  1596. let indexS = [];
  1597. data.forEach((item, index) => {
  1598. if (item.modelKey) {
  1599. this.$set(data[index], 'modelKey', item.modelKey);
  1600. }
  1601. if (item.colorKey) {
  1602. this.$set(data[index], 'colorKey', item.colorKey);
  1603. }
  1604. item.receiveTotalWeight = item.receiveTotalWeight || 0;
  1605. // console.log('item~~~~', item, this.sourceType);
  1606. // if(!this.isReturnGoodsCreate) {
  1607. // console.log('isReturnGoodsCreate', this.isReturnGoodsCreate)
  1608. // item.totalCount = item.notGenerateSendCount || item.totalCount;
  1609. // // item.saleCount = item.notGenerateSendCount || item.saleCount;
  1610. // let total = item.totalCount || 0;
  1611. // let _endIndex = 0; //计算单重需要
  1612. // if (item.packageDispositionList) {
  1613. // let endIndex = item.packageDispositionList.findIndex(
  1614. // (ite) => item.saleUnitId == ite.id
  1615. // );
  1616. // _endIndex = endIndex;
  1617. // let packageData = item.packageDispositionList.find(
  1618. // (ite) => item.saleUnitId== ite.id
  1619. // );
  1620. // item.saleUnitId = packageData?.conversionUnit;
  1621. // if (item.weightUnit == item.measuringUnit && item.singleWeight) {
  1622. // item.packageDispositionList[1].packageCell = item.singleWeight;
  1623. // }
  1624. // for (; 0 < endIndex; endIndex--) {
  1625. // total = Vue.prototype.$math.format(
  1626. // total / item.packageDispositionList[endIndex].packageCell,
  1627. // 14
  1628. // );
  1629. // }
  1630. // }
  1631. // item.saleCount = total;
  1632. // }
  1633. // this.changeCount(item, index, false);
  1634. if (item.weightUnit == item.measuringUnit) {
  1635. item.sendTotalWeight = item.sendTotalWeight || item.totalCount;
  1636. } else {
  1637. item.sendTotalWeight =
  1638. item.sendTotalWeight || Number(item.totalWeight) || 0;
  1639. }
  1640. if (this.outsourceSendCode) {
  1641. item.increaseTotalWeight =
  1642. Number(item.receiveTotalWeight) - Number(item.sendTotalWeight);
  1643. item.increaseTotalWeight;
  1644. } else {
  1645. item.increaseTotalWeight =
  1646. item.increaseTotalWeight || item.receiveTotalWeight || 0;
  1647. }
  1648. // item['sendTotalWeight'] = item.sendTotalWeigh;
  1649. // item['increaseTotalWeight'] = item.increaseTotalWeight;
  1650. item['tempId'] = this.form.datasource.length;
  1651. indexS.push(this.form.datasource.length);
  1652. this.$set(
  1653. this.form.datasource,
  1654. this.form.datasource.length,
  1655. copyObj(item)
  1656. );
  1657. // this.form.datasource.push(item);
  1658. });
  1659. this.form.datasource.forEach(async (item, index) => {
  1660. if (indexS.includes(index)) {
  1661. if (!item.batchNo) {
  1662. console.log('111~~~~', index);
  1663. this.$set(
  1664. this.form.datasource[index],
  1665. 'warehouseList',
  1666. await getIdWarehouseList({
  1667. categoryId: item.productId
  1668. })
  1669. );
  1670. if (item.warehouseId) {
  1671. await this.refreshWarehouseOutStock(
  1672. index,
  1673. this.form.datasource[index]
  1674. );
  1675. } else if (this.form.datasource[index]?.warehouseList?.length) {
  1676. this.$set(
  1677. this.form.datasource[index],
  1678. 'warehouseId',
  1679. this.form.datasource[index]?.warehouseList[0].warehouseId
  1680. );
  1681. await this.warehouseChange(index, this.form.datasource[index]);
  1682. }
  1683. const templist = await getBatchList({
  1684. categoryCode: item.productCode,
  1685. warehouseId: item.warehouseId,
  1686. colorKey: item.colorKey,
  1687. modelType: item.modelType,
  1688. size: -1
  1689. });
  1690. // console.log('templist~~~~', index, templist.list);
  1691. // 批次号
  1692. this.$set(
  1693. this.form.datasource[index],
  1694. 'batchNoList',
  1695. templist?.list || []
  1696. );
  1697. // console.log(this.form.datasource[index]);
  1698. } else {
  1699. this.setBatchAndWarehouse(item, index);
  1700. }
  1701. }
  1702. });
  1703. },
  1704. async setBatchAndWarehouse(item, index) {
  1705. console.log('333~~~~', index);
  1706. // 通过产品编码查仓库
  1707. const tempWarehouse = await getIdWarehouseList({
  1708. categoryId: item.productId
  1709. });
  1710. // 有仓库列表
  1711. if (tempWarehouse?.length) {
  1712. console.log('666~~~~', index, tempWarehouse);
  1713. this.$set(
  1714. this.form.datasource[index],
  1715. 'warehouseList',
  1716. tempWarehouse
  1717. );
  1718. if (!item.warehouseId) {
  1719. if (this.form.datasource[index]?.warehouseList?.length) {
  1720. this.$set(
  1721. this.form.datasource[index],
  1722. 'warehouseId',
  1723. this.form.datasource[index]?.warehouseList[0].warehouseId
  1724. );
  1725. await this.warehouseChange(index, this.form.datasource[index]);
  1726. }
  1727. }
  1728. const templist1 = await getBatchList({
  1729. categoryCode: item.productCode,
  1730. warehouseId: item.warehouseId,
  1731. colorKey: item.colorKey,
  1732. modelType: item.modelType,
  1733. size: -1
  1734. });
  1735. let tempBatchNoList = templist1?.list || [];
  1736. console.log('888~~~~', index, item.batchNo);
  1737. // 优先按批次明细ID匹配,无ID时按系统批次和业务批次兼容匹配
  1738. const batchNoObj = tempBatchNoList.find(
  1739. (i) =>
  1740. (item.batchStockId && i.id == item.batchStockId) ||
  1741. (!item.batchStockId &&
  1742. i.batchNo == item.batchNo &&
  1743. (!item.systemBatchNo || i.systemBatchNo == item.systemBatchNo))
  1744. );
  1745. if (batchNoObj) {
  1746. this.$set(
  1747. this.form.datasource[index],
  1748. 'batchStockId',
  1749. batchNoObj.id
  1750. );
  1751. this.$set(
  1752. this.form.datasource[index],
  1753. 'systemBatchNo',
  1754. batchNoObj.systemBatchNo || ''
  1755. );
  1756. await this.refreshWarehouseOutStock(
  1757. index,
  1758. this.form.datasource[index]
  1759. );
  1760. } else {
  1761. //不存在
  1762. // 批次列表添加不存在的批次号对象
  1763. tempBatchNoList.push({
  1764. batchNo: item.batchNo,
  1765. id: 999,
  1766. measureQuantity: 0
  1767. });
  1768. // 设置为不存在的批次ID
  1769. this.$set(this.form.datasource[index], 'batchStockId', 999);
  1770. this.$set(this.form.datasource[index], 'warehouseNum', '');
  1771. this.$set(this.form.datasource[index], 'stockCountBase', '');
  1772. this.$set(this.form.datasource[index], 'availableCountBase', '');
  1773. this.$set(this.form.datasource[index], 'warehouseId', '');
  1774. }
  1775. // // 批次号
  1776. this.$set(
  1777. this.form.datasource[index],
  1778. 'batchNoList',
  1779. tempBatchNoList
  1780. );
  1781. } else {
  1782. if (item.batchNo) {
  1783. const tempBatchNoList = [
  1784. {
  1785. batchNo: item.batchNo,
  1786. id: 999,
  1787. measureQuantity: 0
  1788. }
  1789. ];
  1790. this.$set(
  1791. this.form.datasource[index],
  1792. 'batchNoList',
  1793. tempBatchNoList
  1794. );
  1795. this.$set(this.form.datasource[index], 'batchStockId', 999);
  1796. this.$set(this.form.datasource[index], 'warehouseNum', '');
  1797. this.$set(this.form.datasource[index], 'stockCountBase', '');
  1798. this.$set(this.form.datasource[index], 'availableCountBase', '');
  1799. }
  1800. }
  1801. },
  1802. remove(i) {
  1803. this.form.datasource.splice(i, 1);
  1804. this.setSort();
  1805. },
  1806. batchRemove() {
  1807. if (!this.selection.length) return;
  1808. this.$confirm('确定要批量删除选中的物品吗?', '提示', {
  1809. confirmButtonText: '确定',
  1810. cancelButtonText: '取消',
  1811. type: 'warning'
  1812. }).then(() => {
  1813. const ids = this.selection.map(item => item.tempId ?? item.id);
  1814. this.form.datasource = this.form.datasource.filter(
  1815. item => !ids.includes(item.tempId ?? item.id)
  1816. );
  1817. this.selection = [];
  1818. this.setSort();
  1819. this.$refs.table.reload();
  1820. this.$message.success('删除成功');
  1821. }).catch(() => {});
  1822. },
  1823. // 清空表格
  1824. restTable() {
  1825. this.form.datasource = [];
  1826. },
  1827. // 重新排序
  1828. setSort() {
  1829. this.form.datasource.forEach((n, index) => {
  1830. n.key = index + 1;
  1831. });
  1832. },
  1833. //选择产品
  1834. handParent() {
  1835. console.log('this.type~~~~111', this.orderId);
  1836. if (!this.orderId && !this.orderIds)
  1837. return this.$message.error('请先选择订单');
  1838. this.$refs.BIZproductListRef.open('', -1);
  1839. },
  1840. // 添加
  1841. handlAdd() {
  1842. console.log('this.type~~~~222', this.orderId);
  1843. if (!this.orderId && !this.orderIds)
  1844. return this.$message.error('请先选择订单');
  1845. this.$refs.productListRef.open(this.oldProductList);
  1846. },
  1847. //库存台账
  1848. selectStockLedgerDialogOpen(row) {
  1849. this.current = row;
  1850. this.$refs.selectStockLedgerDialogRef.open();
  1851. },
  1852. validateForm(callback) {
  1853. //开始表单校验
  1854. this.$refs.form.validate((valid, obj) => {
  1855. // 找出所有发货数量超过订单剩余数量的产品
  1856. const exceededItems = this.form.datasource.filter(
  1857. (item) => Number(item.totalCount) > item.notGenerateSendCount
  1858. );
  1859. // 退货单退货不校验数量,实物赔偿无法计算
  1860. if (
  1861. exceededItems.length > 0 &&
  1862. this.sourceType != 3 &&
  1863. this.needProduce != 4
  1864. ) {
  1865. // 提取产品名称,生成详细提示消息
  1866. const productNames = exceededItems
  1867. .map((item) => item.productCode)
  1868. .join('、');
  1869. this.$message.warning(`${productNames} 的发货数量大于订单剩余数量`);
  1870. if (this.isTotalCount == 1) {
  1871. callback(false);
  1872. }
  1873. }
  1874. if (obj) {
  1875. let messages = Object.keys(obj).map((key) => obj[key][0]);
  1876. if (messages.length > 0) {
  1877. this.$message.warning(messages[0].message);
  1878. }
  1879. }
  1880. callback(valid);
  1881. });
  1882. },
  1883. // 列头拖拽结束 - 保存列宽到本地缓存
  1884. handleHeaderDragend(newWidth, oldWidth, column) {
  1885. if (!column.property) return;
  1886. const widths = this.getStorage(this.cacheKeyUrl + 'Widths') || {};
  1887. widths[column.property] = newWidth;
  1888. this.setStorage(this.cacheKeyUrl + 'Widths', widths);
  1889. }
  1890. }
  1891. };
  1892. </script>
  1893. <style lang="scss" scoped>
  1894. ::v-deep .el-table .warning-row {
  1895. background: #d9ecff;
  1896. }
  1897. .headbox {
  1898. display: flex;
  1899. justify-content: flex-start;
  1900. align-items: center;
  1901. .amount {
  1902. font-size: 14px;
  1903. font-weight: bold;
  1904. padding-right: 30px;
  1905. }
  1906. }
  1907. .time-form .el-form-item {
  1908. margin-bottom: 0 !important;
  1909. }
  1910. ::v-deep .period {
  1911. display: flex;
  1912. .borderleftnone {
  1913. .el-input--medium .el-input__inner {
  1914. border-top-right-radius: 0;
  1915. border-bottom-right-radius: 0;
  1916. }
  1917. }
  1918. .borderrightnone {
  1919. .el-input--medium .el-input__inner {
  1920. border-top-left-radius: 0;
  1921. border-bottom-left-radius: 0;
  1922. }
  1923. }
  1924. }
  1925. ::v-deep .time-form tbody > tr:hover > td {
  1926. background-color: transparent !important;
  1927. }
  1928. // ::v-deep .time-form .el-table tr {
  1929. // background-color: #ffffff;
  1930. // }
  1931. .pricebox {
  1932. display: flex;
  1933. justify-content: flex-start;
  1934. align-items: center;
  1935. font-weight: bold;
  1936. }
  1937. </style>