inventoryTable.vue 60 KB

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