inventoryTable.vue 58 KB

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