inventoryTable.vue 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688
  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. :class="{ 'time-form-busy': tableBusy }"
  11. :selection.sync="selection"
  12. @columns-change="handleColumnChange"
  13. @header-dragend="handleHeaderDragend"
  14. :cache-key="cacheKeyUrl"
  15. height="350"
  16. full-height="calc(100vh - 76px)"
  17. :show-summary="true"
  18. :summary-method="getSummaries"
  19. >
  20. <!-- 表头工具栏 -->
  21. <template v-slot:toolbar>
  22. <div class="headbox">
  23. <div>
  24. <el-button
  25. v-if="isShowAdd && needProduce != 4"
  26. size="small"
  27. type="primary"
  28. icon="el-icon-plus"
  29. class="ele-btn-icon"
  30. @click="handlAdd"
  31. >
  32. 新增
  33. </el-button>
  34. <el-button
  35. size="small"
  36. type="primary"
  37. icon="el-icon-plus"
  38. class="ele-btn-icon"
  39. @click="handParent()"
  40. v-if="isShowAdd && needProduce == 4"
  41. >
  42. 新增
  43. </el-button>
  44. <el-button
  45. size="small"
  46. type="danger"
  47. icon="el-icon-delete"
  48. class="ele-btn-icon"
  49. :disabled="!selection.length"
  50. @click="batchRemove"
  51. >
  52. 批量删除
  53. </el-button>
  54. <!-- 批量设置发货数量:仅开发环境提供 -->
  55. <setAllCountPrice
  56. :disabled="tableBusy || !selection.length || sourceType == 4"
  57. :show-price="false"
  58. count-title="发货数量"
  59. button-text="批量设置发货数量"
  60. @success="setAllSendCountChange"
  61. />
  62. </div>
  63. </div>
  64. </template>
  65. <template v-slot:technicalDrawings="{ row, $index }">
  66. <el-form-item :prop="'datasource.' + $index + '.technicalDrawings'">
  67. <fileMain
  68. v-model="row.technicalDrawings"
  69. type="view"
  70. lazy-render
  71. defer-modal
  72. ></fileMain>
  73. </el-form-item>
  74. </template>
  75. <template v-slot:remark="{ row, $index }">
  76. <el-form-item :prop="'datasource.' + $index + '.remark'">
  77. <el-input
  78. clearable
  79. v-model="row.remark"
  80. type="textarea"
  81. placeholder="请输入"
  82. />
  83. </el-form-item>
  84. </template>
  85. <template v-slot:packagingStrength="scope">
  86. <el-form-item>
  87. <DictSelection
  88. dict-name="包装强度"
  89. @change="keyChange(scope.$index, scope.row, 'packagingStrength')"
  90. v-model="scope.row.extField.packagingStrength"
  91. :isOne="scope.$index === 0"
  92. ></DictSelection>
  93. </el-form-item>
  94. </template>
  95. <template v-slot:packagingDensity="scope">
  96. <el-form-item>
  97. <DictSelection
  98. dict-name="包装密度"
  99. @change="keyChange(scope.$index, scope.row, 'packagingDensity')"
  100. v-model="scope.row.extField.packagingDensity"
  101. :isOne="scope.$index === 0"
  102. ></DictSelection>
  103. </el-form-item>
  104. </template>
  105. <template v-slot:batchStockId="scope">
  106. <el-form-item :prop="'datasource.' + scope.$index + '.batchStockId'" :rules="[
  107. {
  108. required: scope.row.isLockSaleOrder == 1,
  109. message: '请选择批次号',
  110. trigger: 'blur'
  111. }
  112. ]">
  113. <!-- <el-input v-model="scope.row.batchNo"></el-input> -->
  114. <el-select
  115. v-model="scope.row.batchStockId"
  116. clearable
  117. placeholder="请选择"
  118. :disabled="isSaleOrderLockReadonly(scope.row)"
  119. :loading="lookupLoading(scope.row, 'batch')"
  120. @visible-change="
  121. (visible) => visible && loadBatchOptions(scope.row)
  122. "
  123. @change="batchNoChange(scope.$index, scope.row)"
  124. >
  125. <el-option
  126. v-for="item in batchOptions(scope.row)"
  127. :key="item.id"
  128. :label="item.id == 999 ? `${item.batchNo}(无匹配可发库存)` : item.batchNo"
  129. :value="item.id"
  130. :disabled="item.id == 999"
  131. >
  132. </el-option>
  133. </el-select>
  134. </el-form-item>
  135. </template>
  136. <!-- 生产编号 可编辑 -->
  137. <template v-slot:productionCodes="{ row }">
  138. <el-form-item>
  139. <el-input v-model="row.productionCodes"></el-input>
  140. </el-form-item>
  141. </template>
  142. <template v-slot:blockCount="scope">
  143. <el-form-item
  144. :prop="'datasource.' + scope.$index + '.blockCount'"
  145. :rules="[{ required: true, message: '请输入', trigger: 'blur' }]"
  146. >
  147. <el-input
  148. v-model="scope.row.blockCount"
  149. @input="
  150. (val) => tableHandleKeyUp(scope.row, scope.$index, 'blockCount')
  151. "
  152. ></el-input>
  153. </el-form-item>
  154. </template>
  155. <template v-slot:receiveTotalWeight="scope">
  156. <el-form-item
  157. :prop="'datasource.' + scope.$index + '.receiveTotalWeight'"
  158. >
  159. <el-input
  160. type="number"
  161. v-model="scope.row.receiveTotalWeight"
  162. @input="changeSendTotalWeight(scope.row, scope.$index)"
  163. style="width: calc(100% - 70px); margin-right: 10px"
  164. >
  165. <template slot="append">
  166. {{ scope.row.weightUnit }}
  167. </template>
  168. </el-input>
  169. <el-button
  170. size="small"
  171. type="primary"
  172. v-if="entrustedCode"
  173. @click.native="
  174. (e) => handleInnerBound(e, scope.row, scope.$index)
  175. "
  176. >选择
  177. </el-button>
  178. </el-form-item>
  179. </template>
  180. <!-- 编码:该产品存在替代料时给出“替”标识 -->
  181. <template v-slot:productCode="{ row }">
  182. <div class="replace-code-cell">
  183. <span class="code-text" :title="row.productCode">{{
  184. row.productCode
  185. }}</span>
  186. <el-tooltip v-if="isRowReplaced(row)" placement="top" effect="dark">
  187. <el-tag type="warning" size="mini" effect="dark">替</el-tag>
  188. <div slot="content" class="replace-tip">
  189. 该产品存在替代料,详见“替代料”页签,发货时以替代料为准
  190. </div>
  191. </el-tooltip>
  192. </div>
  193. </template>
  194. <template v-slot:orderNo="scope">
  195. <el-form-item
  196. :prop="'datasource.' + scope.$index + '.orderNo'"
  197. :rules="[
  198. {
  199. required: false,
  200. message: '请选择订单编号',
  201. trigger: 'blur'
  202. }
  203. ]"
  204. >
  205. <el-select
  206. v-if="needProduce == 4 && orderNoList.length > 1"
  207. v-model="scope.row.orderNo"
  208. placeholder="请选择"
  209. >
  210. <el-option
  211. v-for="item in orderNoList"
  212. :key="item.value"
  213. :label="item.label"
  214. :value="item.value"
  215. >
  216. </el-option>
  217. </el-select>
  218. <span v-else>{{ scope.row.orderNo }}</span>
  219. </el-form-item>
  220. </template>
  221. <template v-slot:sendTotalWeight="scope">
  222. <el-form-item
  223. :prop="'datasource.' + scope.$index + '.sendTotalWeight'"
  224. >
  225. <el-input
  226. type="number"
  227. v-model="scope.row.sendTotalWeight"
  228. style="width: 100%"
  229. @input="changeCount(scope.row, scope.$index, true, 'totalWeight')"
  230. >
  231. <template slot="append">
  232. {{ scope.row.weightUnit }}
  233. </template>
  234. </el-input>
  235. </el-form-item>
  236. </template>
  237. <template v-slot:increaseTotalWeight="scope">
  238. <el-form-item
  239. :prop="'datasource.' + scope.$index + '.increaseTotalWeight'"
  240. >
  241. <el-input
  242. type="number"
  243. v-model="scope.row.increaseTotalWeight"
  244. style="width: 100%"
  245. disabled
  246. >
  247. <template slot="append">
  248. {{ scope.row.weightUnit }}
  249. </template>
  250. </el-input>
  251. </el-form-item>
  252. </template>
  253. <template v-slot:warehouseId="scope">
  254. <el-form-item
  255. :prop="'datasource.' + scope.$index + '.warehouseId'"
  256. :rules="[
  257. {
  258. required: isWarehouseId == 1 || scope.row.isLockSaleOrder == 1,
  259. message: '请选择仓库',
  260. trigger: 'blur'
  261. }
  262. ]"
  263. >
  264. <el-select
  265. v-model="scope.row.warehouseId"
  266. clearable
  267. :disabled="isSaleOrderLockReadonly(scope.row)"
  268. placeholder="请选择"
  269. :loading="lookupLoading(scope.row, 'warehouse')"
  270. @visible-change="
  271. (visible) => visible && loadWarehouseOptions(scope.row)
  272. "
  273. @change="warehouseChange(scope.$index, scope.row, true)"
  274. >
  275. <el-option
  276. v-for="(item, optIndex) in warehouseOptions(scope.row)"
  277. :key="`${item.warehouseId}_${optIndex}`"
  278. :label="item.warehouseName"
  279. :value="item.warehouseId"
  280. >
  281. </el-option>
  282. </el-select>
  283. </el-form-item>
  284. </template>
  285. <template v-slot:availableCountBase="{ row }">
  286. <span>{{
  287. row.availableCountBase === undefined ||
  288. row.availableCountBase === null
  289. ? 0
  290. : row.availableCountBase
  291. }}</span>
  292. </template>
  293. <template v-slot:singlePrice="scope">
  294. <el-form-item
  295. style="margin-bottom: 20px"
  296. :prop="'datasource.' + scope.$index + '.singlePrice'"
  297. :rules="{
  298. required: true,
  299. message: '请输入正确的单价',
  300. trigger: 'change'
  301. }"
  302. >
  303. <el-input
  304. v-model="scope.row.singlePrice"
  305. placeholder="请输入"
  306. @input="changeCount(scope.row, scope.$index)"
  307. type="number"
  308. >
  309. <template slot="append">元</template>
  310. </el-input>
  311. </el-form-item>
  312. </template>
  313. <template v-slot:singleWeight="scope">
  314. <el-form-item
  315. style="margin-bottom: 20px"
  316. :rules="{
  317. required: false,
  318. trigger: 'change'
  319. }"
  320. :prop="'datasource.' + scope.$index + '.singleWeight'"
  321. >
  322. <el-input
  323. v-model="scope.row.singleWeight"
  324. type="number"
  325. placeholder="请输入"
  326. :disabled="needProduce == 4"
  327. @input="changeCount(scope.row, scope.$index)"
  328. >
  329. <template slot="append">
  330. {{ scope.row.weightUnit }}
  331. </template>
  332. </el-input>
  333. </el-form-item>
  334. </template>
  335. <template v-slot:headerWarehouseNum="{ column }">
  336. <span class="is-required">{{ column.label }}</span>
  337. </template>
  338. <template v-slot:headerWarehouseId="{ column }">
  339. <span :class="isWarehouseId == 1 ? 'is-required' : ''">{{
  340. column.label
  341. }}</span>
  342. </template>
  343. <template v-slot:headerTotalCount="{ column }">
  344. <span class="is-required">{{ column.label }}</span>
  345. </template>
  346. <template v-slot:headerReceiveTotalWeight="{ column }">
  347. <span :class="{ 'is-required': entrustedCode && pricingWay == 2 }">{{
  348. column.label
  349. }}</span>
  350. </template>
  351. <template v-slot:saleCount="scope">
  352. <el-form-item
  353. style="margin-bottom: 20px"
  354. :prop="'datasource.' + scope.$index + '.saleCount'"
  355. :rules="[
  356. {
  357. required: true,
  358. message: '请输入数量',
  359. trigger: 'change'
  360. },
  361. {
  362. validator: (rule, value, callback) => {
  363. if (value === undefined || value === null || value === '') {
  364. callback('请输入数量');
  365. } else if (parseFloat(value) <= 0) {
  366. callback('数量必须大于0');
  367. } else {
  368. callback();
  369. }
  370. },
  371. trigger: 'blur'
  372. }
  373. ]"
  374. >
  375. <el-input
  376. v-model="scope.row.saleCount"
  377. placeholder="请输入"
  378. type="number"
  379. :min="0"
  380. :disabled="sourceType == 4"
  381. @input="changeCount(scope.row, scope.$index, false)"
  382. >
  383. <template slot="append">
  384. <el-select
  385. v-model="scope.row.saleUnitId"
  386. style="width: 80px"
  387. @change="changeCount(scope.row, scope.$index)"
  388. :disabled="clientEnvironmentId == 4 || sourceType == 4"
  389. >
  390. <el-option
  391. :label="item.conversionUnit"
  392. :value="item.id"
  393. v-for="(item, index) in scope.row.packageDispositionList"
  394. :key="index"
  395. ></el-option>
  396. </el-select>
  397. </template>
  398. </el-input>
  399. </el-form-item>
  400. </template>
  401. <template v-slot:cuttingLength="{ row, $index }">
  402. <el-form-item :prop="'datasource.' + $index + '.cuttingLength'">
  403. <el-input v-model="row.cuttingLength" placeholder="请输入">
  404. </el-input>
  405. </el-form-item>
  406. </template>
  407. <!-- <template v-slot:saleUnit="scope">
  408. <el-form-item
  409. style="margin-bottom: 20px"
  410. :prop="'datasource.' + scope.$index + '.saleUnitId'"
  411. >
  412. <el-select
  413. v-model="scope.row.saleUnitId"
  414. style="width: 100%"
  415. @change="changeCount(scope.row, scope.$index)"
  416. :disabled="clientEnvironmentId == 4"
  417. >
  418. <el-option
  419. :label="item.conversionUnit"
  420. :value="item.id"
  421. @click.native="packingChange(item, scope.$index)"
  422. v-for="(item, index) in scope.row.packageDispositionList"
  423. :key="index"
  424. ></el-option>
  425. </el-select>
  426. </el-form-item>
  427. </template> -->
  428. <template v-slot:modelKey="scope">
  429. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'modelKey'">
  430. <DictSelection
  431. dictName="物品机型"
  432. clearable
  433. v-model="scope.row.modelKey"
  434. :isOne="scope.$index === 0"
  435. filterable
  436. allow-create
  437. default-first-option
  438. >
  439. </DictSelection>
  440. </el-form-item>
  441. </template>
  442. <template v-slot:colorKey="scope">
  443. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'colorKey'">
  444. <DictSelection
  445. dictName="物品颜色"
  446. clearable
  447. v-model="scope.row.colorKey"
  448. :isOne="scope.$index === 0"
  449. filterable
  450. allow-create
  451. default-first-option
  452. >
  453. </DictSelection>
  454. </el-form-item>
  455. </template>
  456. <!-- 操作列 -->
  457. <template v-slot:action="scope">
  458. <el-popconfirm
  459. class="ele-action"
  460. title="确定要删除吗?"
  461. @confirm="remove(scope.$index)"
  462. >
  463. <template v-slot:reference>
  464. <el-link type="danger" :underline="false" icon="el-icon-delete">
  465. 删除
  466. </el-link>
  467. </template>
  468. </el-popconfirm>
  469. <el-link
  470. type="primary"
  471. :underline="false"
  472. icon="el-icon-edit"
  473. @click="selectStockLedgerDialogOpen(scope.row)"
  474. >
  475. 替代料
  476. </el-link>
  477. </template>
  478. </ele-pro-table>
  479. <!-- 遮罩放在表格之后,保证盖在内容上方;v-if 直接绑定 tableLoading,全部批次渲染完成后才卸载 -->
  480. <div v-if="tableLoading" class="table-loading-mask">
  481. <i class="el-icon-loading"></i>
  482. <span class="table-loading-text">
  483. {{
  484. batchLoading
  485. ? `正在加载 ${loadedCount}/${batchTotal}`
  486. : '正在加载,请稍候'
  487. }}
  488. </span>
  489. </div>
  490. </div>
  491. <productListNew
  492. ref="productListRef"
  493. @changeParent="changeParent"
  494. ></productListNew>
  495. <!--入库详情-->
  496. <innertboundDetailsDialog
  497. v-if="innerboundDetailsDialogFlag"
  498. ref="innerboundDetailsDialogRef"
  499. :innerboundDetailsDialogFlag.sync="innerboundDetailsDialogFlag"
  500. @saveDate="saveInnerDate"
  501. ></innertboundDetailsDialog>
  502. <!-- 库存台账 -->
  503. <stock-ledger-dialog
  504. v-if="stockLedgerDialogFlag"
  505. :stock-ledger-dialog-flag.sync="stockLedgerDialogFlag"
  506. ref="stockLedgerDialogRef"
  507. @getStockLedger="getStockLedger"
  508. ></stock-ledger-dialog>
  509. <selectStockLedgerDialog
  510. ref="selectStockLedgerDialogRef"
  511. @changeParent="replaceTable"
  512. ></selectStockLedgerDialog>
  513. <BIZproductList
  514. ref="BIZproductListRef"
  515. classType="1"
  516. :isGetInventoryTotal="true"
  517. @changeParent="changeParentBiz"
  518. :typeIds="typeIds"
  519. :isFirstRefreshTable="true"
  520. ></BIZproductList>
  521. </el-form>
  522. </template>
  523. <script>
  524. import { numberReg } from 'ele-admin';
  525. import dictMixins from '@/mixins/dictMixins';
  526. import productListNew from './product-listNew.vue';
  527. import {
  528. getWarehouseOutStockInfo,
  529. getIdWarehouseList
  530. } from '@/api/saleManage/saleorder';
  531. import { copyObj } from '@/utils/util';
  532. import innertboundDetailsDialog from '@/BIZComponents/innerboundDetailsDialog.vue';
  533. import stockLedgerDialog from './stockLedger/stockLedgerDialog.vue';
  534. import getDynamicsColumns from '@/mixins/getDynamicsColumns';
  535. import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
  536. import BIZproductList from '@/BIZComponents/product-list.vue';
  537. import setAllCountPrice from '@/BIZComponents/setAllCountPrice.vue'; //批量设置发货数量
  538. import { IS_DEV } from '@/config/setting'; //是否开发环境
  539. import tabMixins from '@/mixins/tableColumnsMixin';
  540. import { levelList, pricingWayList, lbjtList } from '@/enum/dict.js';
  541. import { changeCount, formatPrice } from '@/BIZComponents/setProduct.js';
  542. import { parameterGetByCode } from '@/api/main/index.js';
  543. import { getSummaries } from '@/utils/util.js';
  544. import { getBatchList, getWarehouseOutStockBatchAPI } from '@/api/wms';
  545. /**
  546. * ==========================================================================
  547. * 辅助数据请求调度器
  548. * 一次选中上百个物品时,仓库列表 / 批次列表会按行发起上百个请求,
  549. * 打满浏览器连接池,页面长时间无响应。这里统一做三件事:
  550. * 1. 同键合并:相同查询条件的并发请求复用同一个 Promise,只打一次
  551. * 2. 短时缓存:仓库 / 批次列表在 TTL 内直接复用上一次结果
  552. * 3. 并发限流:全局最多 LOOKUP_MAX_CONCURRENCY 个请求同时在飞
  553. * ==========================================================================
  554. */
  555. const LOOKUP_CACHE_TTL = 30 * 1000; // 仓库 / 批次列表缓存时长
  556. const LOOKUP_MAX_CONCURRENCY = 6; // 同时在飞的请求上限
  557. const lookupCache = new Map(); // key -> { expire, data }
  558. const lookupPending = new Map(); // key -> Promise(同键合并)
  559. const lookupQueue = []; // 等待队列
  560. let lookupActive = 0; // 当前在飞的请求数
  561. function pumpLookupQueue() {
  562. while (lookupActive < LOOKUP_MAX_CONCURRENCY && lookupQueue.length) {
  563. const task = lookupQueue.shift();
  564. lookupActive++;
  565. Promise.resolve()
  566. .then(task.factory)
  567. .then(
  568. (data) => {
  569. lookupActive--;
  570. task.resolve(data);
  571. pumpLookupQueue();
  572. },
  573. (error) => {
  574. lookupActive--;
  575. task.reject(error);
  576. pumpLookupQueue();
  577. }
  578. );
  579. }
  580. }
  581. /**
  582. * 走调度器的请求:命中缓存直接返回;相同 key 的并发请求合并成一次
  583. * @param {string} key 查询键
  584. * @param {Function} factory 真正发起请求的工厂函数
  585. * @param {number} ttl 缓存时长,0 表示不缓存(只做同键合并 + 限流)
  586. */
  587. function scheduleLookup(key, factory, ttl = LOOKUP_CACHE_TTL) {
  588. if (ttl) {
  589. const cached = lookupCache.get(key);
  590. if (cached) {
  591. if (cached.expire > Date.now()) {
  592. return Promise.resolve(cached.data);
  593. }
  594. lookupCache.delete(key);
  595. }
  596. }
  597. const pending = lookupPending.get(key);
  598. if (pending) {
  599. return pending;
  600. }
  601. const promise = new Promise((resolve, reject) => {
  602. lookupQueue.push({ factory, resolve, reject });
  603. pumpLookupQueue();
  604. });
  605. lookupPending.set(key, promise);
  606. promise.then(
  607. (data) => {
  608. lookupPending.delete(key);
  609. if (ttl) {
  610. lookupCache.set(key, { expire: Date.now() + ttl, data });
  611. }
  612. },
  613. () => {
  614. lookupPending.delete(key);
  615. }
  616. );
  617. return promise;
  618. }
  619. export default {
  620. mixins: [dictMixins, getDynamicsColumns, tabMixins],
  621. props: {
  622. orderId: String,
  623. orderIds: String,
  624. orderNos: String,
  625. needProduce: [String, Number],
  626. entrustedCode: String,
  627. pricingWay: [String, Number],
  628. isShowAdd: {
  629. type: Boolean,
  630. default: true
  631. },
  632. typeIds: {
  633. type: Array,
  634. default: () => []
  635. },
  636. oldProductList: {
  637. type: Array,
  638. default: () => []
  639. },
  640. sourceType: {
  641. type: [String, Number],
  642. default: ''
  643. },
  644. isTotalCount: {
  645. default: 0
  646. },
  647. isReturnGoodsCreate: {
  648. type: Boolean,
  649. default: false
  650. },
  651. // 替代料关联的原产品 id 集合,用于标记“已替代”的原产品
  652. replaceRelationIds: {
  653. type: Array,
  654. default: () => []
  655. }
  656. },
  657. components: {
  658. // fileMain,
  659. innertboundDetailsDialog,
  660. productListNew,
  661. stockLedgerDialog,
  662. selectStockLedgerDialog,
  663. BIZproductList,
  664. setAllCountPrice
  665. },
  666. data() {
  667. const defaultForm = {
  668. key: null,
  669. endTime: '',
  670. isFirst: 0,
  671. name: '',
  672. startTime: '',
  673. workHour: '',
  674. technicalDrawings: []
  675. // warehouseCode:"",
  676. // warehouseId:'',
  677. // warehouseName:'',
  678. };
  679. return {
  680. cacheKeyUrl: 'eos-saleManage-invoice-inventoryTable-2026102201',
  681. current: {},
  682. childrenColumns: [
  683. {
  684. width: 45,
  685. type: 'selection',
  686. columnKey: 'selection',
  687. align: 'center'
  688. },
  689. {
  690. width: 45,
  691. type: 'index',
  692. columnKey: 'index',
  693. align: 'center',
  694. fixed: 'left'
  695. },
  696. {
  697. minWidth: 100,
  698. prop: 'code',
  699. label: '编码',
  700. align: 'center'
  701. },
  702. {
  703. minWidth: 140,
  704. prop: 'barcodes',
  705. label: '发货条码',
  706. align: 'center'
  707. },
  708. {
  709. minWidth: 100,
  710. prop: 'engrave',
  711. label: '刻码',
  712. align: 'center'
  713. }
  714. ],
  715. selection: [],
  716. discountTotalPrice: 0.0,
  717. allPrice: 0.0,
  718. curIndex: null,
  719. innerboundDetailsDialogFlag: false,
  720. stockLedgerDialogFlag: false,
  721. numberReg,
  722. defaultForm,
  723. warehouseList: [],
  724. dynamicsColumns: [],
  725. isWarehouseId: 0,
  726. blockCountColumn: {},
  727. form: {
  728. datasource: []
  729. },
  730. batchLookupPending: 0,
  731. // 仓库 / 批次列表的懒加载状态:key = 行唯一标识 + 类型。
  732. // 独立于行对象存放,行对象会整体提交给后端,不能塞内部标记。
  733. lookupState: {},
  734. // 回填令牌:新的回填开始时丢弃上一次未完成的回填,避免乱序追加
  735. loadToken: 0,
  736. // 一次追加的行数较多时按批渲染,避免一次性入表长时间阻塞主线程
  737. appendBatchSize: 20,
  738. // 自绘 loading 遮罩状态:ele-pro-table 内置 loading 会在每次 reload 时被重置
  739. tableLoading: false,
  740. batchLoading: false,
  741. loadedCount: 0,
  742. batchTotal: 0,
  743. rules: {},
  744. columnsVersion: 1
  745. };
  746. },
  747. created() {
  748. // 行唯一标识(弱引用,不参与响应式,也不会写入行对象)
  749. this._rowUidMap = new WeakMap();
  750. this._rowUidSeq = 0;
  751. this.requestDict('产地');
  752. this.requestDict('生产类型');
  753. parameterGetByCode({
  754. code: 'eom_saleManage_invoice_warehouseId'
  755. }).then((res) => {
  756. if (res.value) {
  757. this.isWarehouseId = res.value;
  758. }
  759. });
  760. },
  761. computed: {
  762. canHandl() {
  763. return this.form.datasource.length;
  764. },
  765. // 批量回填期间禁止会改动数据源的操作
  766. tableBusy() {
  767. return this.tableLoading || this.batchLoading;
  768. },
  769. // 已被替代的原产品 id 集合(转成字符串便于与行上的 id/tempId 比较)
  770. replaceRelationKeySet() {
  771. return new Set(
  772. this.replaceRelationIds
  773. .filter((v) => v !== undefined && v !== null && v !== '')
  774. .map((v) => String(v))
  775. );
  776. },
  777. clientEnvironmentId() {
  778. return this.$store.state.user.info.clientEnvironmentId;
  779. },
  780. orderNoList() {
  781. const temp = this.orderNos?.split(',') || [];
  782. return temp.map((item) => {
  783. return {
  784. label: item,
  785. value: item
  786. };
  787. });
  788. },
  789. columns() {
  790. let columnsVersion = this.columnsVersion;
  791. return this.applyColumnWidth([
  792. {
  793. width: 45,
  794. type: 'selection',
  795. columnKey: 'selection',
  796. align: 'center',
  797. fixed: 'left'
  798. },
  799. {
  800. width: 60,
  801. type: 'index',
  802. columnKey: 'index',
  803. align: 'center',
  804. fixed: 'left'
  805. },
  806. {
  807. minWidth: 200,
  808. prop: 'orderNo',
  809. label: '订单编码',
  810. align: 'center',
  811. slot: 'orderNo',
  812. fixed: 'left'
  813. },
  814. {
  815. width: 200,
  816. prop: 'productName',
  817. label: '名称',
  818. slot: 'productName',
  819. align: 'center'
  820. },
  821. {
  822. width: 150,
  823. prop: 'productCode',
  824. label: '编码',
  825. slot: 'productCode',
  826. align: 'center'
  827. },
  828. {
  829. width: 200,
  830. prop: 'productCategoryName',
  831. label: '类型',
  832. slot: 'productCategoryName',
  833. align: 'center'
  834. },
  835. {
  836. width: 140,
  837. prop: 'pricingWay',
  838. label: '计价方式',
  839. align: 'center',
  840. fixed: 'left',
  841. formatter: (row, column) => {
  842. return pricingWayList.find((item) => item.id == row.pricingWay)
  843. ?.name;
  844. }
  845. },
  846. {
  847. width: 160,
  848. prop: 'batchStockId',
  849. label: '批次号',
  850. slot: 'batchStockId',
  851. align: 'center'
  852. },
  853. {
  854. minWidth: 180,
  855. prop: 'systemBatchNo',
  856. label: '系统内部批次号',
  857. align: 'center',
  858. formatter: (row) => row.systemBatchNo || '-'
  859. },
  860. {
  861. width: 160,
  862. prop: 'productBrand',
  863. label: '牌号',
  864. slot: 'productBrand',
  865. align: 'center'
  866. },
  867. {
  868. width: 120,
  869. prop: 'modelType',
  870. label: '型号',
  871. slot: 'modelType',
  872. align: 'center'
  873. },
  874. {
  875. width: 120,
  876. prop: 'specification',
  877. label: '规格',
  878. slot: 'specification',
  879. align: 'center'
  880. },
  881. {
  882. width: 160,
  883. prop: 'modelKey',
  884. label: '机型',
  885. slot: 'modelKey',
  886. align: 'center'
  887. },
  888. {
  889. width: 160,
  890. prop: 'colorKey',
  891. label: '颜色',
  892. slot: 'colorKey',
  893. align: 'center'
  894. },
  895. {
  896. minWidth: 160,
  897. prop: 'productionCodes',
  898. label: '生产编号',
  899. align: 'center',
  900. slot: 'productionCodes'
  901. },
  902. {
  903. minWidth: 280,
  904. prop: 'productionRequirements',
  905. label: '生产要求',
  906. align: 'center'
  907. },
  908. {
  909. minWidth: 120,
  910. prop: 'goodsLevel',
  911. label: '物品级别',
  912. formatter: (_row, _column, cellValue) => {
  913. return levelList.find((item) => item.value == _row.goodsLevel)
  914. ?.label;
  915. },
  916. align: 'center'
  917. },
  918. {
  919. width: 120,
  920. prop: 'customerMark',
  921. label: '客户代号',
  922. slot: 'customerMark',
  923. align: 'center'
  924. },
  925. {
  926. width: 200,
  927. prop: 'warehouseId',
  928. label: '仓库名称',
  929. slot: 'warehouseId',
  930. headerSlot: 'headerWarehouseId',
  931. align: 'center'
  932. },
  933. {
  934. width: 100,
  935. prop: 'stockCountBase',
  936. label: '库存数量',
  937. align: 'center'
  938. },
  939. {
  940. width: 100,
  941. prop: 'availableCountBase',
  942. label: '可用数量',
  943. slot: 'availableCountBase',
  944. align: 'center'
  945. },
  946. // {
  947. // width: 100,
  948. // prop: 'stockLedger',
  949. // label: '发货明细',
  950. // slot: 'stockLedger',
  951. // align: 'center'
  952. // },
  953. {
  954. width: 250,
  955. prop: 'saleCount',
  956. label: '发货数量',
  957. slot: 'saleCount',
  958. headerSlot: 'headerTotalCount',
  959. align: 'center'
  960. },
  961. {
  962. width: 150,
  963. prop: 'pendingShipmentQuantity',
  964. label: '待发数量',
  965. align: 'center'
  966. },
  967. {
  968. width: 100,
  969. prop: 'notSendTotalCount',
  970. label: '未出库数量',
  971. align: 'center',
  972. formatter: (row, column) => {
  973. // if (row.notSendTotalCount) {
  974. return row.notSendTotalCount;
  975. // }
  976. }
  977. },
  978. {
  979. width: 100,
  980. prop: 'notGenerateSendCount',
  981. label: '未发数量',
  982. align: 'center',
  983. formatter: (row, column) => {
  984. // if (row.notGenerateSendCount) {
  985. return row.notGenerateSendCount;
  986. // }
  987. }
  988. },
  989. {
  990. width: 120,
  991. prop: 'totalCount',
  992. label: '计量数量',
  993. formatter: (row, column) => {
  994. // if (row.totalCount) {
  995. return row.totalCount + ' ' + row.measuringUnit;
  996. // }
  997. },
  998. align: 'center'
  999. },
  1000. {
  1001. width: 120,
  1002. prop: 'orderTotalCount',
  1003. label: '订单数量',
  1004. formatter: (row, column) => {
  1005. if (row.orderTotalCount) {
  1006. return row.orderTotalCount + ' ' + row.measuringUnit;
  1007. }
  1008. },
  1009. align: 'center'
  1010. },
  1011. {
  1012. width: 120,
  1013. prop: 'packingSpecification',
  1014. align: 'center',
  1015. label: '包装规格',
  1016. showOverflowTooltip: true
  1017. },
  1018. // {
  1019. // width: 80,
  1020. // prop: 'measuringUnit',
  1021. // label: '计量单位',
  1022. // slot: 'measuringUnit',
  1023. // align: 'center'
  1024. // },
  1025. this.clientEnvironmentId == 4
  1026. ? {
  1027. width: 150,
  1028. prop: 'blockCount',
  1029. label: '发货块数',
  1030. slot: 'blockCount',
  1031. align: 'center'
  1032. }
  1033. : { width: 1 },
  1034. {
  1035. width: 200,
  1036. prop: 'singleWeight',
  1037. slot: 'singleWeight',
  1038. label: '单重',
  1039. align: 'center'
  1040. },
  1041. {
  1042. width: 250,
  1043. prop: 'receiveTotalWeight',
  1044. label: '收货总重',
  1045. slot: 'receiveTotalWeight',
  1046. align: 'center',
  1047. headerSlot: 'headerReceiveTotalWeight'
  1048. },
  1049. {
  1050. width: 220,
  1051. prop: 'sendTotalWeight',
  1052. label: '发货总重',
  1053. slot: 'sendTotalWeight',
  1054. align: 'center'
  1055. },
  1056. {
  1057. width: 220,
  1058. prop: 'increaseTotalWeight',
  1059. label: '增重重量',
  1060. slot: 'increaseTotalWeight',
  1061. align: 'center'
  1062. },
  1063. {
  1064. width: 180,
  1065. prop: 'singlePrice',
  1066. label: '单价',
  1067. slot: 'singlePrice',
  1068. align: 'center'
  1069. },
  1070. {
  1071. width: 160,
  1072. prop: 'taxRate',
  1073. label: '税率',
  1074. formatter: (_row, _column, cellValue) => {
  1075. return _row.taxRate ? _row.taxRate + '%' : '';
  1076. },
  1077. align: 'center'
  1078. },
  1079. {
  1080. width: 180,
  1081. prop: 'notaxSinglePrice',
  1082. label: '不含税单价',
  1083. align: 'center'
  1084. },
  1085. {
  1086. width: 160,
  1087. prop: 'discountSinglePrice',
  1088. label: '折后单价',
  1089. slot: 'discountSinglePrice',
  1090. align: 'center'
  1091. },
  1092. {
  1093. width: 120,
  1094. prop: 'totalPrice',
  1095. label: '合计',
  1096. slot: 'totalPrice',
  1097. align: 'center'
  1098. },
  1099. {
  1100. width: 160,
  1101. prop: 'notaxTotalPrice',
  1102. label: '含税合计',
  1103. align: 'center'
  1104. },
  1105. {
  1106. width: 120,
  1107. prop: 'discountTotalPrice',
  1108. label: '折后合计',
  1109. slot: 'discountTotalPrice',
  1110. align: 'center'
  1111. },
  1112. {
  1113. minWidth: 280,
  1114. prop: 'cuttingLength',
  1115. label: '裁线米段',
  1116. align: 'center',
  1117. slot: 'cuttingLength'
  1118. },
  1119. {
  1120. width: 120,
  1121. prop: 'imgCode',
  1122. align: 'center',
  1123. label: '图号/件号',
  1124. showOverflowTooltip: true
  1125. },
  1126. {
  1127. width: 120,
  1128. prop: 'produceType',
  1129. align: 'center',
  1130. label: '属性类型',
  1131. formatter: (row, column) => {
  1132. if (row.produceType) {
  1133. return row.produceType
  1134. .map((item) => {
  1135. return lbjtList[item];
  1136. })
  1137. .toString();
  1138. }
  1139. },
  1140. showOverflowTooltip: true
  1141. },
  1142. {
  1143. width: 200,
  1144. prop: 'guaranteePeriod',
  1145. label: '有效期',
  1146. slot: 'guaranteePeriod',
  1147. formatter: (_row, _column, cellValue) => {
  1148. let val = '';
  1149. if (_row.guaranteePeriod) {
  1150. val += _row.guaranteePeriod;
  1151. }
  1152. if (_row.guaranteePeriodUnitName) {
  1153. val += _row.guaranteePeriodUnitName;
  1154. }
  1155. return val;
  1156. },
  1157. align: 'center'
  1158. },
  1159. {
  1160. width: 200,
  1161. prop: 'guaranteePeriodDeadline',
  1162. label: '有效期截止日期',
  1163. slot: 'guaranteePeriodDeadline',
  1164. align: 'center'
  1165. },
  1166. {
  1167. prop: 'provenance',
  1168. label: '产地',
  1169. slot: 'provenance',
  1170. align: 'center',
  1171. // show:this.contractBookType==2,
  1172. minWidth: 200,
  1173. showOverflowTooltip: true,
  1174. formatter: (row, column) => {
  1175. return row.provenance && row.provenance.length
  1176. ? row.provenance
  1177. .map((item) => this.getDictValue('产地', item))
  1178. .join(',')
  1179. : '';
  1180. }
  1181. },
  1182. {
  1183. width: 130,
  1184. prop: 'technicalAnswerName',
  1185. label: '技术答疑人',
  1186. slot: 'technicalAnswerName',
  1187. align: 'center'
  1188. },
  1189. {
  1190. width: 220,
  1191. prop: 'technicalParams',
  1192. label: '技术参数',
  1193. slot: 'technicalParams',
  1194. align: 'center'
  1195. },
  1196. {
  1197. width: 240,
  1198. prop: 'technicalDrawings',
  1199. label: '技术图纸',
  1200. slot: 'technicalDrawings',
  1201. align: 'center'
  1202. },
  1203. {
  1204. width: 220,
  1205. prop: 'remark',
  1206. label: '备注',
  1207. slot: 'remark',
  1208. align: 'center'
  1209. },
  1210. // 动态扩展字段默认排在最后(操作列固定在右侧,需留在最后)
  1211. ...this.dynamicsColumns,
  1212. {
  1213. columnKey: 'action',
  1214. label: '操作',
  1215. width: 200,
  1216. align: 'center',
  1217. resizable: false,
  1218. slot: 'action',
  1219. fixed: 'right',
  1220. showOverflowTooltip: true
  1221. }
  1222. ]);
  1223. }
  1224. },
  1225. mounted() {
  1226. // this.clientEnvironmentId =
  1227. },
  1228. methods: {
  1229. formatPrice,
  1230. isSaleOrderLockReadonly(row) {
  1231. if (row.hasSendRejectedOrWithdrawn == 1) {
  1232. return false;
  1233. }
  1234. const orderType = row.needProduce ?? this.needProduce;
  1235. return orderType == 0 || (orderType == 1 && row.isLockSaleOrder == 1);
  1236. },
  1237. dedupeBatchNoList(list) {
  1238. const seen = new Set();
  1239. return (list || []).filter((item) => {
  1240. if (seen.has(item.id)) {
  1241. return false;
  1242. }
  1243. seen.add(item.id);
  1244. return true;
  1245. });
  1246. },
  1247. getSummaries(param) {
  1248. return getSummaries(
  1249. param,
  1250. ['saleCount', 'blockCount', 'totalCount'],
  1251. ' '
  1252. );
  1253. },
  1254. //发货明细选择
  1255. stockLedgerSelect(row, index) {
  1256. this.curIndex = index;
  1257. this.stockLedgerDialogFlag = true;
  1258. this.$nextTick(() => {
  1259. this.$refs.stockLedgerDialogRef.init(row.sendProductDetail, row);
  1260. });
  1261. },
  1262. packingChange(item, index) {
  1263. this.$set(this.form.datasource[index], 'saleUnit', item.conversionUnit);
  1264. },
  1265. //获取
  1266. getStockLedger(sendProductDetail) {
  1267. if (!this.form.datasource[this.curIndex].sendProductDetail)
  1268. this.form.datasource[this.curIndex].sendProductDetail = [];
  1269. let row = this.form.datasource[this.curIndex];
  1270. row.sendProductDetail.push(...sendProductDetail);
  1271. this.form.datasource[this.curIndex] = row;
  1272. this.$refs['childrenTable' + this.curIndex].reload();
  1273. this.$refs.table.reload();
  1274. },
  1275. //删除发货明细
  1276. stockLedgerRemove(PIndex) {
  1277. let row = this.form.datasource[PIndex];
  1278. this.selection.forEach((item) => {
  1279. let index = row.sendProductDetail.findIndex((i) => i.id == item.id);
  1280. row.sendProductDetail.splice(index, 1);
  1281. });
  1282. this.form.datasource[PIndex] = row;
  1283. this.$refs['childrenTable' + PIndex].reload();
  1284. this.$refs.table.reload();
  1285. this.selection = [];
  1286. },
  1287. // 将接口返回的库存数量和可用数量同步到当前物品清单行。
  1288. setWarehouseOutStock(index, stockInfo) {
  1289. const stockCountBase = stockInfo?.stockCountBase || 0;
  1290. const availableCountBase = stockInfo?.availableCountBase || 0;
  1291. this.$set(
  1292. this.form.datasource[index],
  1293. 'stockCountBase',
  1294. stockCountBase
  1295. );
  1296. this.$set(
  1297. this.form.datasource[index],
  1298. 'availableCountBase',
  1299. availableCountBase
  1300. );
  1301. // 保留原字段,兼容已有发货数量校验和提交逻辑。
  1302. this.$set(
  1303. this.form.datasource[index],
  1304. 'warehouseNum',
  1305. availableCountBase
  1306. );
  1307. },
  1308. async refreshWarehouseOutStock(index, row) {
  1309. if (!row.warehouseId) {
  1310. this.setWarehouseOutStock(index, {});
  1311. return;
  1312. }
  1313. const query = {
  1314. warehouseId: row.warehouseId,
  1315. code: row.productCode,
  1316. batchNo: row.batchNo,
  1317. systemBatchNo: row.systemBatchNo,
  1318. colorKey: row.colorKey,
  1319. modelType: row.modelType
  1320. };
  1321. const stockInfo = await scheduleLookup(
  1322. `stock:${this.stockLookupKey(row)}`,
  1323. () => getWarehouseOutStockInfo(query),
  1324. 0
  1325. );
  1326. if (this.form.datasource[index] === row &&
  1327. row.warehouseId == query.warehouseId &&
  1328. row.batchNo == query.batchNo &&
  1329. row.systemBatchNo == query.systemBatchNo &&
  1330. row.colorKey == query.colorKey &&
  1331. row.modelType == query.modelType) {
  1332. this.setWarehouseOutStock(index, stockInfo);
  1333. }
  1334. },
  1335. async warehouseChange(index, row, isReset = false) {
  1336. console.log('warehouseChange', index, row.warehouseId, isReset);
  1337. const warehouseId = row.warehouseId;
  1338. const colorKey = row.colorKey;
  1339. const modelType = row.modelType;
  1340. // 仓库列表改成懒加载后,列表可能还没加载出来,这里做兜底查找
  1341. const data = (row.warehouseList || []).find(
  1342. (item) => item.warehouseId == row.warehouseId
  1343. );
  1344. console.log('warehouseChange', data);
  1345. this.$set(
  1346. this.form.datasource[index],
  1347. 'warehouseName',
  1348. data?.warehouseName || row.warehouseName || ''
  1349. );
  1350. this.$set(
  1351. this.form.datasource[index],
  1352. 'warehouseCode',
  1353. data?.warehouseCode || row.warehouseCode || 0
  1354. );
  1355. if (isReset) {
  1356. this.$set(row, 'batchStockId', '');
  1357. this.$set(row, 'batchNo', '');
  1358. this.$set(row, 'systemBatchNo', '');
  1359. }
  1360. const batchStockId = row.batchStockId;
  1361. // 换仓后原仓库的批次失效,先清空再拉新仓库的批次
  1362. const batchKey = this.lookupStateKey(row, 'batch');
  1363. this.$set(row, 'batchNoList', []);
  1364. this.$set(this.lookupState, batchKey, 'loading');
  1365. let tempBatchNoList = [];
  1366. let batchFailed = false;
  1367. try {
  1368. tempBatchNoList = await this.fetchBatchList({
  1369. warehouseId: data?.warehouseId || '',
  1370. categoryCode: row.productCode,
  1371. colorKey: row.colorKey,
  1372. modelType: row.modelType
  1373. });
  1374. } catch (e) {
  1375. batchFailed = true;
  1376. }
  1377. this.$set(
  1378. this.lookupState,
  1379. batchKey,
  1380. batchFailed ? 'error' : 'loaded'
  1381. );
  1382. if (this.form.datasource[index] !== row || row.warehouseId != warehouseId ||
  1383. row.colorKey != colorKey || row.modelType != modelType ||
  1384. row.batchStockId != batchStockId) return;
  1385. this.$set(
  1386. this.form.datasource[index],
  1387. 'batchNoList',
  1388. (tempBatchNoList || []).slice()
  1389. );
  1390. await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
  1391. },
  1392. //批次号选择
  1393. async batchNoChange(index, row) {
  1394. if (!row.batchStockId) {
  1395. this.$set(this.form.datasource[index], 'batchStockId', '');
  1396. this.$set(this.form.datasource[index], 'batchNo', '');
  1397. this.$set(this.form.datasource[index], 'systemBatchNo', '');
  1398. // 仓库列表改成懒加载后,这里不再预取仓库列表
  1399. // this.$set(this.form.datasource[index], 'warehouseNum', '');
  1400. await this.refreshWarehouseOutStock(
  1401. index,
  1402. this.form.datasource[index]
  1403. );
  1404. return;
  1405. }
  1406. const data = (row.batchNoList || []).find(
  1407. (item) => item.id == row.batchStockId
  1408. );
  1409. if (!data) {
  1410. // 批次列表还没加载出来时(占位项),保留已有批次号,不做覆盖
  1411. await this.refreshWarehouseOutStock(
  1412. index,
  1413. this.form.datasource[index]
  1414. );
  1415. return;
  1416. }
  1417. this.$set(this.form.datasource[index], 'batchNo', data.batchNo);
  1418. this.$set(
  1419. this.form.datasource[index],
  1420. 'systemBatchNo',
  1421. data.systemBatchNo
  1422. );
  1423. await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
  1424. },
  1425. //改变数量
  1426. changeCount(row, index, isBlockCount = true, weightType) {
  1427. if (weightType == 'totalWeight') {
  1428. this.$set(
  1429. this.form.datasource[index],
  1430. 'totalWeight',
  1431. this.form.datasource[index].sendTotalWeight
  1432. );
  1433. }
  1434. this.$set(
  1435. this.form.datasource,
  1436. index,
  1437. changeCount(
  1438. row,
  1439. {
  1440. countKey: 'saleCount',
  1441. unitKey: 'saleUnit',
  1442. unitIdKey: 'saleUnitId'
  1443. },
  1444. false,
  1445. weightType
  1446. )
  1447. );
  1448. this.$set(
  1449. this.form.datasource[index],
  1450. 'sendTotalWeight',
  1451. this.form.datasource[index].totalWeight
  1452. );
  1453. this.changeSendTotalWeight(row, index);
  1454. // 只重算当前行的不含税单价,避免每次输入都遍历整张表
  1455. this.getNotaxSinglePrice(index);
  1456. if (this.clientEnvironmentId == 4 && !isBlockCount) {
  1457. this.tableHandleKeyUp(row, index, 'sum');
  1458. }
  1459. },
  1460. //修改发货总重
  1461. changeSendTotalWeight(row, index) {
  1462. this.curIndex = index;
  1463. this.setIcreaseTotalWeight(row);
  1464. },
  1465. keyChange(index, row, key) {
  1466. // 字典值已由 v-model 写回 extField,这里把该字段补成响应式属性:
  1467. // 初始没有该键时 v-model 写入的是普通属性,视图不会随下一次选择更新
  1468. if (row.extField) {
  1469. const value = row.extField[key];
  1470. if (Object.prototype.hasOwnProperty.call(row.extField, key)) {
  1471. delete row.extField[key];
  1472. }
  1473. this.$set(row.extField, key, value);
  1474. }
  1475. },
  1476. //设置增重总重
  1477. setIcreaseTotalWeight(row) {
  1478. let receiveTotalWeight = Number(
  1479. this.form.datasource[this.curIndex]?.receiveTotalWeight
  1480. );
  1481. let sendTotalWeight = Number(
  1482. this.form.datasource[this.curIndex]?.sendTotalWeight
  1483. );
  1484. if (sendTotalWeight) {
  1485. let increaseTotalWeight = sendTotalWeight - receiveTotalWeight;
  1486. this.$set(
  1487. this.form.datasource[this.curIndex],
  1488. 'increaseTotalWeight',
  1489. increaseTotalWeight.toFixed(4)
  1490. );
  1491. if (row.pricingWay == 3) {
  1492. this.$set(
  1493. this.form.datasource[this.curIndex],
  1494. 'totalPrice',
  1495. (increaseTotalWeight * row.singlePrice).toFixed(2)
  1496. );
  1497. }
  1498. }
  1499. this.$refs.table.reload();
  1500. this.$forceUpdate();
  1501. },
  1502. //计算不含税单价:只重算指定行,不传时退化为全量重算
  1503. getNotaxSinglePrice(index) {
  1504. const calc = (item, i) => {
  1505. if (item.singlePrice && item.taxRate) {
  1506. this.$set(
  1507. this.form.datasource[i],
  1508. 'notaxSinglePrice',
  1509. formatPrice(item.singlePrice / (1 + item.taxRate / 100))
  1510. );
  1511. } else {
  1512. this.$set(this.form.datasource[i], 'notaxSinglePrice', '');
  1513. }
  1514. };
  1515. if (index === undefined || index === null) {
  1516. this.form.datasource.forEach((item, i) => calc(item, i));
  1517. return;
  1518. }
  1519. const item = this.form.datasource[index];
  1520. if (item) {
  1521. calc(item, index);
  1522. }
  1523. },
  1524. //入库单详情
  1525. handleInnerBound(e, rows, index) {
  1526. this.curIndex = index;
  1527. this.innerboundDetailsDialogFlag = true;
  1528. this.$nextTick(() => {
  1529. let row = {
  1530. code: this.entrustedCode
  1531. };
  1532. this.$refs.innerboundDetailsDialogRef.init(row);
  1533. });
  1534. },
  1535. //选择入库单信息
  1536. saveInnerDate(data = []) {
  1537. let totalWeight = data.reduce((num, row) => {
  1538. num += Number(row.weight);
  1539. return num;
  1540. }, 0);
  1541. this.$set(
  1542. this.form.datasource[this.curIndex],
  1543. 'receiveTotalWeight',
  1544. totalWeight
  1545. );
  1546. console.log(totalWeight, 'totalWeight');
  1547. this.setIcreaseTotalWeight(this.form.datasource[this.curIndex]);
  1548. },
  1549. // getWeightPrice() {
  1550. // let increaseTotalWeight =
  1551. // this.form.datasource[this.curIndex].increaseTotalWeight;
  1552. // let singlePrice = this.form.datasource[this.curIndex].singlePrice;
  1553. // let discountSinglePrice =
  1554. // this.form.datasource[this.curIndex].discountSinglePrice;
  1555. // this.$set(
  1556. // this.form.datasource[this.curIndex],
  1557. // 'totalPrice',
  1558. // (Number(increaseTotalWeight) * Number(singlePrice)).toFixed(2)
  1559. // );
  1560. // this.$set(
  1561. // this.form.datasource[this.curIndex],
  1562. // 'discountTotalPrice',
  1563. // (Number(discountSinglePrice) * Number(increaseTotalWeight)).toFixed(2)
  1564. // );
  1565. // },
  1566. // 表格:模数、数量(方)、块数输入框 输入事件
  1567. tableHandleKeyUp(row, index, name) {
  1568. if (row.specification) {
  1569. let modelArr = row.specification.split('*');
  1570. let modelLong = modelArr[0]; // model规格长度
  1571. let modeWide = modelArr[1]; // model规格宽度
  1572. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1573. modeHight = Number(modeHight);
  1574. if (name === 'sum') {
  1575. // row.blockCount = Math.floor(
  1576. // row.totalCount / ((modelLong * modeWide * modeHight) / 1000000)
  1577. // );
  1578. this.$set(
  1579. this.form.datasource[index],
  1580. 'blockCount',
  1581. Math.floor(
  1582. row.totalCount / ((modelLong * modeWide * modeHight) / 1000000)
  1583. )
  1584. );
  1585. } else if (name === 'blockCount') {
  1586. row.totalCount =
  1587. (Number(row.blockCount) * modelLong * modeWide * modeHight) /
  1588. 1000000;
  1589. row.saleCount = row.totalCount;
  1590. this.changeCount(row, index, true);
  1591. }
  1592. }
  1593. },
  1594. //选择产品回调(订单来源物品)
  1595. async changeParent(obj) {
  1596. if (!obj || !obj.length) return;
  1597. // 先在普通对象上组装行,不直接改动选品弹窗里的原始数据
  1598. const rows = obj.map((item) => {
  1599. const row = copyObj(item);
  1600. row.orderTotalCount = row.totalCount;
  1601. // 清空选入行ID前保留订单来源,避免换成同一批次后误合并额度。
  1602. row.orderProductId = row.orderProductId || row.id;
  1603. row.id = '';
  1604. return row;
  1605. });
  1606. await this.appendOrderRows(rows);
  1607. },
  1608. //选择产品回调(不定向订单:从产品库选物品)
  1609. async changeParentBiz(obj = [], idx) {
  1610. if (!obj || !obj.length) return;
  1611. const startIndex = this.form.datasource.length;
  1612. const supplierMark = this.form.datasource[0]?.supplierMark;
  1613. const rows = obj.map((item, index) =>
  1614. this.buildBizProductRow(item, startIndex + index + 1, supplierMark)
  1615. );
  1616. if (idx === undefined || idx === null || idx === -1) {
  1617. await this.appendBizRows(rows);
  1618. return;
  1619. }
  1620. // 编辑已有行:整行替换(保留原行的 key / tempId,替代料关联不能断)
  1621. await this.fillBizLookups(rows);
  1622. const oldRow = this.form.datasource[idx];
  1623. if (oldRow) {
  1624. rows[0].key = oldRow.key;
  1625. rows[0].tempId = oldRow.tempId;
  1626. }
  1627. this.$set(this.form.datasource, idx, rows[0]);
  1628. },
  1629. replaceTable(list) {
  1630. console.log('list~~~~', list);
  1631. list.forEach((item) => {
  1632. item['relationId'] = this.current.id || this.current.tempId;
  1633. });
  1634. this.$emit('replaceTableChange', list);
  1635. },
  1636. // 该产品是否已被替代料替代(新增时按 tempId,回显时按产品 id)
  1637. isRowReplaced(row) {
  1638. const keys = this.replaceRelationKeySet;
  1639. if (!keys.size) {
  1640. return false;
  1641. }
  1642. if (row.id !== undefined && row.id !== null && row.id !== '') {
  1643. return keys.has(String(row.id));
  1644. }
  1645. return (
  1646. row.tempId !== undefined &&
  1647. row.tempId !== null &&
  1648. row.tempId !== '' &&
  1649. keys.has(String(row.tempId))
  1650. );
  1651. },
  1652. // validateTotalCount(row) {
  1653. // return (rule, value, callback) => {
  1654. // if (isNaN(value) || Number(value) <= 0) {
  1655. // this.$message.error('请输入大于0的数');
  1656. // callback(false);
  1657. // } else else {
  1658. // callback();
  1659. // }
  1660. // };
  1661. // },
  1662. // 返回列表数据
  1663. getTableValue() {
  1664. let comitDatasource = this.form.datasource;
  1665. if (comitDatasource.length === 0) return [];
  1666. comitDatasource.forEach((v) => {
  1667. // 清空批次时同步清理批次库存 ID,避免更新接口残留旧批次。
  1668. if (!v.batchNo) {
  1669. v.batchNo = '';
  1670. v.systemBatchNo = '';
  1671. v.batchStockId = '';
  1672. }
  1673. v.totalCount = Number(v.totalCount);
  1674. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  1675. ? v.technicalDrawings
  1676. : [];
  1677. v.customerReqFiles = Array.isArray(v.customerReqFiles)
  1678. ? v.customerReqFiles
  1679. : [];
  1680. v.industryArtFiles = v.industryArtFiles || [];
  1681. v.otherFiles = v.otherFiles || [];
  1682. });
  1683. return comitDatasource;
  1684. },
  1685. getPrice() {
  1686. return [this.allPrice];
  1687. },
  1688. //修改回显
  1689. // mode='edit' 表示回显的是"已经保存过的发货单":只原样显示用户保存的数据,
  1690. // 不替用户选仓库 / 配批次(否则会在回显时凭空写入用户没选过的值)。
  1691. putTableValue(data, isInit, mode) {
  1692. if (isInit) {
  1693. this.form.datasource = [];
  1694. }
  1695. if (data && data.length) {
  1696. this.setValue(data, mode);
  1697. }
  1698. },
  1699. // 回显:先组装好所有行,再批量取数、分批入表
  1700. setValue(data, mode) {
  1701. const rows = data.map((item) => this.buildOrderRow(item));
  1702. if (mode === 'edit') {
  1703. return this.appendEditRows(rows);
  1704. }
  1705. return this.appendOrderRows(rows);
  1706. },
  1707. // ==================== 大批量回显(性能相关) ====================
  1708. /**
  1709. * 订单来源物品组装成一行(普通对象,暂不进响应式数组,赋值零成本)
  1710. */
  1711. buildOrderRow(item) {
  1712. const row = copyObj(item);
  1713. row.receiveTotalWeight = row.receiveTotalWeight || 0;
  1714. if (row.weightUnit == row.measuringUnit) {
  1715. row.sendTotalWeight = row.sendTotalWeight || row.totalCount;
  1716. } else {
  1717. row.sendTotalWeight =
  1718. row.sendTotalWeight || Number(row.totalWeight) || 0;
  1719. }
  1720. if (this.outsourceSendCode) {
  1721. row.increaseTotalWeight =
  1722. Number(row.receiveTotalWeight) - Number(row.sendTotalWeight);
  1723. } else {
  1724. row.increaseTotalWeight =
  1725. row.increaseTotalWeight || row.receiveTotalWeight || 0;
  1726. }
  1727. return row;
  1728. },
  1729. /**
  1730. * 不定向订单:从产品库选中的物品组装成一行(普通对象)
  1731. */
  1732. buildBizProductRow(item, key, supplierMark) {
  1733. const row = JSON.parse(JSON.stringify(this.defaultForm));
  1734. row.key = key;
  1735. row.tempId = key;
  1736. row.productId = item.id;
  1737. row.categoryName = item.name;
  1738. row.productCategoryId = item.categoryLevelId;
  1739. row.productBrand = item.brandNum;
  1740. row.productCategoryName = item.categoryLevelPath;
  1741. row.productCode = item.code;
  1742. row.productName = item.name;
  1743. row.modelType = item.modelType;
  1744. row.availableCountBase = item.availableCountBase;
  1745. row.measuringUnit = item.measuringUnit;
  1746. row.specification = item.specification;
  1747. row.weightUnit = item.weightUnit;
  1748. row.imgCode = item.imgCode;
  1749. row.produceType = item.componentAttribute;
  1750. row.approvalNumber = item.extField?.approvalNumber;
  1751. row.extField = copyObj(item.extField || {});
  1752. row.singleWeight = item.netWeight;
  1753. row.pricingWay = item.pricingWay || 1;
  1754. row.singlePrice = 0;
  1755. row.discountSinglePrice = 0;
  1756. row.goodsLevel = item.goodsLevel;
  1757. row.orderNo = this.orderNoList[0]?.value || '';
  1758. if (item.modelKey) {
  1759. row.modelKey = item.modelKey;
  1760. }
  1761. if (item.colorKey) {
  1762. row.colorKey = item.colorKey;
  1763. }
  1764. row.receiveTotalWeight = 0;
  1765. row.sendTotalWeight = 0;
  1766. row.increaseTotalWeight = 0;
  1767. row.packageDispositionList = item.packageDispositionList;
  1768. if (item.packageDispositionList?.length) {
  1769. row.saleUnitId = item.packageDispositionList[0].id;
  1770. row.saleUnit = item.packageDispositionList[0].conversionUnit;
  1771. }
  1772. row.packingSpecification = item.extField?.packingSpecification;
  1773. row.supplierMark = supplierMark;
  1774. // 提交给 EOM 的产地必须是编码数组,不能是库存台账里的展示字符串
  1775. row.provenance =
  1776. item.purchaseOrigins?.length > 0
  1777. ? item.purchaseOrigins.map((val) => val + '')
  1778. : [];
  1779. return row;
  1780. },
  1781. /**
  1782. * 批量回填入口:先把 loading 遮罩画出来,再取辅助数据,最后分批入表。
  1783. * 取数期间用 batchLookupPending 挡住保存,避免提交到半成品数据。
  1784. */
  1785. async runBatchAppend(rows, prepareFn) {
  1786. const token = ++this.loadToken;
  1787. const startIndex = this.form.datasource.length;
  1788. this.batchLookupPending++;
  1789. this.startTableLoading();
  1790. try {
  1791. await this.nextFrame();
  1792. const prepared = await prepareFn(rows, startIndex);
  1793. if (token !== this.loadToken) return;
  1794. await this.appendRowsInBatches(prepared, startIndex, token);
  1795. } catch (error) {
  1796. console.error('物品清单批量回显失败', error);
  1797. this.$message.error('物品清单加载失败,请重试');
  1798. } finally {
  1799. this.batchLookupPending--;
  1800. if (token === this.loadToken) {
  1801. this.endTableLoading();
  1802. }
  1803. }
  1804. },
  1805. // 订单来源物品:批量补齐仓库/批次/可发库存后入表
  1806. appendOrderRows(rows) {
  1807. return this.runBatchAppend(rows, (list, startIndex) =>
  1808. this.prepareOrderRows(list, startIndex)
  1809. );
  1810. },
  1811. // 编辑回显:仓库 / 批次列表全部懒加载,库存用一次批量接口刷新
  1812. appendEditRows(rows) {
  1813. return this.runBatchAppend(rows, (list, startIndex) =>
  1814. this.prepareEditRows(list, startIndex)
  1815. );
  1816. },
  1817. // 不定向订单:仓库 / 批次列表改为懒加载,入表时不再预取
  1818. appendBizRows(rows) {
  1819. return this.runBatchAppend(rows, async (list) => {
  1820. await this.fillBizLookups(list);
  1821. return list;
  1822. });
  1823. },
  1824. /**
  1825. * 分批追加:一次选中上百个物品时一次性塞进表格会让主线程长时间阻塞,
  1826. * 这里按 appendBatchSize 分批写入,每批之间让出一帧,
  1827. * 浏览器可以正常绘制 loading 遮罩和已经渲染出来的行。
  1828. */
  1829. appendRowsInBatches(
  1830. rows,
  1831. startIndex = this.form.datasource.length,
  1832. token
  1833. ) {
  1834. return new Promise((resolve) => {
  1835. if (!rows.length) {
  1836. resolve();
  1837. return;
  1838. }
  1839. const batchSize = Math.max(1, this.appendBatchSize || 20);
  1840. const total = rows.length;
  1841. this.batchLoading = true;
  1842. this.loadedCount = 0;
  1843. this.batchTotal = total;
  1844. let done = 0;
  1845. const step = () => {
  1846. // 已被新的回填取代时直接放弃,避免旧数据插到新数据前面
  1847. if (token !== undefined && token !== this.loadToken) {
  1848. this.batchLoading = false;
  1849. resolve();
  1850. return;
  1851. }
  1852. const batch = rows.slice(done, done + batchSize);
  1853. if (batch.length) {
  1854. this.form.datasource = this.form.datasource.concat(batch);
  1855. done += batch.length;
  1856. this.loadedCount = done;
  1857. }
  1858. if (done < total) {
  1859. requestAnimationFrame(step);
  1860. return;
  1861. }
  1862. this.batchLoading = false;
  1863. resolve();
  1864. };
  1865. requestAnimationFrame(step);
  1866. });
  1867. },
  1868. // 让出一帧,保证 loading 遮罩先绘制出来再执行会阻塞主线程的计算
  1869. nextFrame() {
  1870. return new Promise((resolve) => {
  1871. this.$nextTick(() => {
  1872. requestAnimationFrame(() => resolve());
  1873. });
  1874. });
  1875. },
  1876. startTableLoading() {
  1877. this._loadingStart = Date.now();
  1878. this.tableLoading = true;
  1879. },
  1880. // 保证遮罩最短展示时间,避免一闪而过
  1881. endTableLoading(minDuration = 200) {
  1882. const start = this._loadingStart || Date.now();
  1883. const rest = minDuration - (Date.now() - start);
  1884. if (rest > 0) {
  1885. setTimeout(() => {
  1886. this.tableLoading = false;
  1887. }, rest);
  1888. } else {
  1889. this.tableLoading = false;
  1890. }
  1891. },
  1892. /**
  1893. * 订单来源物品的辅助数据回填:
  1894. * 仓库 / 批次列表改成"按需懒加载"——只有业务判断真正依赖的行才立即查询,
  1895. * 其余行等用户展开下拉时再查;库存数量统一走一次批量接口。
  1896. * 这样一次回显上百个物品时,请求数从"上百个"降到"个位数 + 按需查询"。
  1897. */
  1898. async prepareOrderRows(rows, startIndex) {
  1899. // 1. 仓库列表:只有"还没定仓库"的行需要立即查询(要自动选中第一个仓库);
  1900. // 已有仓库的行改为懒加载,避免一百个物品打出一百个仓库列表请求
  1901. const autoPickRows = rows.filter((row) => !row.warehouseId);
  1902. const warehouseMap = await this.loadWarehouseListMap(autoPickRows);
  1903. rows.forEach((row) => {
  1904. if (row.warehouseId) {
  1905. this.$set(row, 'warehouseList', []);
  1906. return;
  1907. }
  1908. const list = (warehouseMap.get(String(row.productId)) || []).slice();
  1909. this.$set(row, 'warehouseList', list);
  1910. if (list.length) {
  1911. const first = list[0];
  1912. row.warehouseId = first.warehouseId;
  1913. row.warehouseName = first.warehouseName || '';
  1914. row.warehouseCode = first.warehouseCode || 0;
  1915. }
  1916. });
  1917. // 2. 批次列表:只有"指定了批次号"的行需要立即查询(要按批次明细匹配),
  1918. // 其余行改为懒加载
  1919. const needBatchRows = rows.filter((row) => row.batchNo);
  1920. const batchMap = await this.loadBatchListMap(needBatchRows);
  1921. const stockRows = [];
  1922. let lookupFailed = false;
  1923. rows.forEach((row) => {
  1924. if (!row.batchNo) {
  1925. this.$set(row, 'batchNoList', []);
  1926. if (row.warehouseId) {
  1927. stockRows.push(row);
  1928. }
  1929. return;
  1930. }
  1931. const list = batchMap.get(this.batchLookupKey(row));
  1932. if (list === null) {
  1933. // 批次查询失败:按无匹配批次处理
  1934. lookupFailed = true;
  1935. row.batchStockId = 999;
  1936. this.$set(row, 'batchNoList', [{ id: 999, batchNo: row.batchNo }]);
  1937. row.warehouseNum = '';
  1938. row.stockCountBase = '';
  1939. row.availableCountBase = '';
  1940. return;
  1941. }
  1942. // 优先按批次明细ID匹配,无ID时按系统批次和业务批次兼容匹配
  1943. const matched = (list || []).filter(
  1944. (item) =>
  1945. item.categoryId == row.productId &&
  1946. item.warehouseId == row.warehouseId &&
  1947. (item.colorKey || '') == (row.colorKey || '') &&
  1948. item.batchNo == row.batchNo &&
  1949. (!row.systemBatchNo || item.systemBatchNo == row.systemBatchNo) &&
  1950. (!row.batchStockId || item.id == row.batchStockId)
  1951. );
  1952. if (matched.length == 1) {
  1953. row.batchStockId = matched[0].id;
  1954. row.systemBatchNo = matched[0].systemBatchNo || '';
  1955. this.$set(row, 'batchNoList', (list || []).slice());
  1956. stockRows.push(row);
  1957. } else {
  1958. // 批次不存在:列表里补一条"无匹配可发库存"
  1959. this.$set(
  1960. row,
  1961. 'batchNoList',
  1962. this.dedupeBatchNoList(
  1963. (list || []).concat([
  1964. {
  1965. batchNo: row.batchNo,
  1966. systemBatchNo: row.systemBatchNo,
  1967. id: 999,
  1968. measureQuantity: 0
  1969. }
  1970. ])
  1971. )
  1972. );
  1973. row.batchStockId = 999;
  1974. row.warehouseNum = '';
  1975. row.stockCountBase = '';
  1976. row.availableCountBase = '';
  1977. }
  1978. });
  1979. // 3. 库存数量(一次批量接口查完)
  1980. const stockMap = await this.loadStockInfoMap(stockRows);
  1981. stockRows.forEach((row) => {
  1982. const stockInfo = stockMap.get(this.stockLookupKey(row));
  1983. if (!stockInfo) return;
  1984. row.stockCountBase = stockInfo.stockCountBase || 0;
  1985. row.availableCountBase = stockInfo.availableCountBase || 0;
  1986. row.warehouseNum = row.availableCountBase;
  1987. });
  1988. if (lookupFailed) {
  1989. this.$message.error('批次库存查询失败,请重新打开后重试');
  1990. }
  1991. // 4. 统一分配 key / tempId(替代料关联用,必须在清单内唯一)
  1992. rows.forEach((row, index) => {
  1993. row.key = startIndex + index + 1;
  1994. row.tempId = row.id || startIndex + index;
  1995. });
  1996. return rows;
  1997. },
  1998. /**
  1999. * 编辑回显的行数据准备:
  2000. * 编辑只是把用户已经保存的数据原样显示出来,不应该再替用户"选仓库"或"配批次",
  2001. * 所以这里不做任何写入型预取——仓库 / 批次列表全部懒加载(展开下拉时才查),
  2002. * 库存数量统一走一次批量接口刷新(只针对已选仓库的行)。
  2003. * 否则一百行的发货单一打开就会打出上百个 getBatchWarehouseList 请求。
  2004. */
  2005. async prepareEditRows(rows, startIndex) {
  2006. // 1. 仓库 / 批次列表:清空,等用户展开下拉时再按需查询
  2007. rows.forEach((row) => {
  2008. this.$set(row, 'warehouseList', []);
  2009. this.$set(row, 'batchNoList', []);
  2010. });
  2011. // 2. 库存数量:一次批量接口查完(没有仓库的行查不到库存,保持空)
  2012. const stockRows = rows.filter((row) => !!row.warehouseId);
  2013. const stockMap = await this.loadStockInfoMap(stockRows);
  2014. stockRows.forEach((row) => {
  2015. const stockInfo = stockMap.get(this.stockLookupKey(row));
  2016. if (!stockInfo) return;
  2017. row.stockCountBase = stockInfo.stockCountBase || 0;
  2018. row.availableCountBase = stockInfo.availableCountBase || 0;
  2019. row.warehouseNum = row.availableCountBase;
  2020. });
  2021. // 3. 统一分配 key / tempId(替代料关联用,必须在清单内唯一)
  2022. rows.forEach((row, index) => {
  2023. row.key = startIndex + index + 1;
  2024. row.tempId = row.id || startIndex + index;
  2025. });
  2026. return rows;
  2027. },
  2028. // 不定向订单:仓库 / 批次列表只用于下拉展示,没有任何业务判断依赖,
  2029. // 改成懒加载(展开下拉时才查询),一次选上百个物品不再打出上百个请求
  2030. async fillBizLookups(rows) {
  2031. rows.forEach((row) => {
  2032. this.$set(row, 'warehouseList', []);
  2033. this.$set(row, 'batchNoList', []);
  2034. });
  2035. },
  2036. // 查询键:同一批新增行里仓库/批次/库存的查询条件可能完全相同,按键去重后只查一次
  2037. lookupKey(...parts) {
  2038. return JSON.stringify(
  2039. parts.map((item) => {
  2040. if (item === undefined) return 'u';
  2041. if (item === null) return 'n';
  2042. return 's' + String(item);
  2043. })
  2044. );
  2045. },
  2046. // 批次查询键:仓库 + 物品编码 + 颜色 + 型号
  2047. batchLookupKey(row) {
  2048. return this.lookupKey(
  2049. row.warehouseId,
  2050. row.productCode,
  2051. row.colorKey,
  2052. row.modelType
  2053. );
  2054. },
  2055. // 库存查询键:仓库 + 物品编码 + 批次 + 系统批次 + 颜色 + 型号
  2056. stockLookupKey(row) {
  2057. return this.lookupKey(
  2058. row.warehouseId,
  2059. row.productCode,
  2060. row.batchNo,
  2061. row.systemBatchNo,
  2062. row.colorKey,
  2063. row.modelType
  2064. );
  2065. },
  2066. // 批量查询产品对应的仓库列表(按物品去重)
  2067. async loadWarehouseListMap(rows) {
  2068. const map = new Map();
  2069. const ids = [
  2070. ...new Set(
  2071. rows
  2072. .map((row) => row.productId)
  2073. .filter((id) => id !== undefined && id !== null && id !== '')
  2074. )
  2075. ];
  2076. await Promise.all(
  2077. ids.map(async (productId) => {
  2078. try {
  2079. map.set(String(productId), await this.fetchWarehouseList(productId));
  2080. } catch (e) {
  2081. map.set(String(productId), []);
  2082. }
  2083. })
  2084. );
  2085. return map;
  2086. },
  2087. // 批量查询批次列表(按 仓库+物品+颜色+型号 去重)
  2088. async loadBatchListMap(rows) {
  2089. const map = new Map();
  2090. const paramsMap = new Map();
  2091. rows.forEach((row) => {
  2092. const key = this.batchLookupKey(row);
  2093. if (paramsMap.has(key)) return;
  2094. paramsMap.set(key, {
  2095. warehouseId: row.warehouseId,
  2096. categoryCode: row.productCode,
  2097. colorKey: row.colorKey,
  2098. modelType: row.modelType
  2099. });
  2100. });
  2101. await Promise.all(
  2102. [...paramsMap.entries()].map(async ([key, params]) => {
  2103. try {
  2104. map.set(key, await this.fetchBatchList(params));
  2105. } catch (e) {
  2106. // null 表示查询失败,调用方按无匹配批次处理
  2107. map.set(key, null);
  2108. }
  2109. })
  2110. );
  2111. return map;
  2112. },
  2113. /**
  2114. * 批量查询库存数量:一次 POST 批量接口替代 N 次单条 GET。
  2115. * 后端返回顺序与请求顺序一一对应,条数不一致时回退逐条查询。
  2116. */
  2117. async loadStockInfoMap(rows) {
  2118. const map = new Map();
  2119. const paramsMap = new Map();
  2120. rows.forEach((row) => {
  2121. if (!row.warehouseId) return;
  2122. const key = this.stockLookupKey(row);
  2123. if (paramsMap.has(key)) return;
  2124. paramsMap.set(key, {
  2125. warehouseId: row.warehouseId,
  2126. code: row.productCode,
  2127. batchNo: row.batchNo,
  2128. systemBatchNo: row.systemBatchNo,
  2129. colorKey: row.colorKey,
  2130. modelType: row.modelType
  2131. });
  2132. });
  2133. const entries = [...paramsMap.entries()];
  2134. if (!entries.length) {
  2135. return map;
  2136. }
  2137. const requests = entries.map(([, params]) => params);
  2138. try {
  2139. const list = await getWarehouseOutStockBatchAPI(requests);
  2140. if (Array.isArray(list) && list.length === requests.length) {
  2141. entries.forEach(([key], index) => {
  2142. const item = list[index] || {};
  2143. map.set(key, {
  2144. stockCountBase: Number(item.stockCountBase || 0),
  2145. availableCountBase: Number(item.availableCountBase || 0)
  2146. });
  2147. });
  2148. return map;
  2149. }
  2150. console.warn(
  2151. '[发货单] 批量库存返回条数与请求不一致,回退逐条查询',
  2152. list?.length,
  2153. requests.length
  2154. );
  2155. } catch (e) {
  2156. console.warn('[发货单] 批量库存查询失败,回退逐条查询', e);
  2157. }
  2158. // 回退:逐条查询(走调度器限流,不会一次性打满连接池)
  2159. await Promise.all(
  2160. entries.map(async ([key, params]) => {
  2161. try {
  2162. map.set(
  2163. key,
  2164. await scheduleLookup(
  2165. `stock:${key}`,
  2166. () => getWarehouseOutStockInfo(params),
  2167. 0
  2168. )
  2169. );
  2170. } catch (e) {
  2171. map.set(key, null);
  2172. }
  2173. })
  2174. );
  2175. return map;
  2176. },
  2177. // ==================== 仓库 / 批次列表懒加载 ====================
  2178. // 行唯一标识:懒加载状态存组件上,不写进行对象(行对象会整体提交给后端)
  2179. rowUid(row) {
  2180. if (!this._rowUidMap) {
  2181. this._rowUidMap = new WeakMap();
  2182. this._rowUidSeq = 0;
  2183. }
  2184. let uid = this._rowUidMap.get(row);
  2185. if (!uid) {
  2186. this._rowUidSeq += 1;
  2187. uid = `r${this._rowUidSeq}`;
  2188. this._rowUidMap.set(row, uid);
  2189. }
  2190. return uid;
  2191. },
  2192. lookupStateKey(row, type) {
  2193. return `${this.rowUid(row)}__${type}`;
  2194. },
  2195. lookupLoading(row, type) {
  2196. return this.lookupState[this.lookupStateKey(row, type)] === 'loading';
  2197. },
  2198. // 仓库下拉选项:未加载时用已选仓库占位,保证仓库名能回显
  2199. warehouseOptions(row) {
  2200. const list = row.warehouseList;
  2201. if (Array.isArray(list) && list.length) {
  2202. return list;
  2203. }
  2204. if (row.warehouseId) {
  2205. return [
  2206. {
  2207. warehouseId: row.warehouseId,
  2208. warehouseName: row.warehouseName || row.warehouseId
  2209. }
  2210. ];
  2211. }
  2212. return [];
  2213. },
  2214. // 批次下拉选项:未加载时用已选批次占位
  2215. batchOptions(row) {
  2216. const list = row.batchNoList;
  2217. if (Array.isArray(list) && list.length) {
  2218. return list;
  2219. }
  2220. if (row.batchStockId) {
  2221. return [{ id: row.batchStockId, batchNo: row.batchNo || '' }];
  2222. }
  2223. return [];
  2224. },
  2225. // 展开仓库下拉时才加载该行的仓库列表
  2226. async loadWarehouseOptions(row) {
  2227. const key = this.lookupStateKey(row, 'warehouse');
  2228. const state = this.lookupState[key];
  2229. if (state === 'loading' || state === 'loaded') {
  2230. return;
  2231. }
  2232. this.$set(this.lookupState, key, 'loading');
  2233. try {
  2234. const list = await this.fetchWarehouseList(row.productId);
  2235. const options = (list || []).slice();
  2236. // 当前仓库不在列表里时补一条,保证已选仓库仍可回显
  2237. if (
  2238. row.warehouseId &&
  2239. !options.some((item) => item.warehouseId == row.warehouseId)
  2240. ) {
  2241. options.push({
  2242. warehouseId: row.warehouseId,
  2243. warehouseName: row.warehouseName || row.warehouseId
  2244. });
  2245. }
  2246. this.$set(row, 'warehouseList', options);
  2247. this.$set(this.lookupState, key, 'loaded');
  2248. } catch (e) {
  2249. this.$set(this.lookupState, key, 'error');
  2250. this.$message.error('仓库列表加载失败,请重试');
  2251. }
  2252. },
  2253. // 展开批次下拉时才加载该行的批次列表
  2254. async loadBatchOptions(row) {
  2255. const key = this.lookupStateKey(row, 'batch');
  2256. const state = this.lookupState[key];
  2257. if (state === 'loading' || state === 'loaded') {
  2258. return;
  2259. }
  2260. if (!row.warehouseId) {
  2261. this.$message.warning('请先选择仓库');
  2262. return;
  2263. }
  2264. this.$set(this.lookupState, key, 'loading');
  2265. try {
  2266. const list = await this.fetchBatchList({
  2267. warehouseId: row.warehouseId,
  2268. categoryCode: row.productCode,
  2269. colorKey: row.colorKey,
  2270. modelType: row.modelType
  2271. });
  2272. const options = (list || []).slice();
  2273. // 已选批次不在最新列表里时补一条,保证回显的批次号仍然能显示出来
  2274. if (
  2275. row.batchStockId &&
  2276. !options.some((item) => item.id == row.batchStockId)
  2277. ) {
  2278. options.unshift({
  2279. id: row.batchStockId,
  2280. batchNo: row.batchNo || ''
  2281. });
  2282. }
  2283. this.$set(row, 'batchNoList', options);
  2284. this.$set(this.lookupState, key, 'loaded');
  2285. } catch (e) {
  2286. this.$set(this.lookupState, key, 'error');
  2287. this.$message.error('批次列表加载失败,请重试');
  2288. }
  2289. },
  2290. // 仓库列表请求(走同键合并 + 缓存 + 限流)
  2291. fetchWarehouseList(productId) {
  2292. return scheduleLookup(`warehouse:${productId}`, async () => {
  2293. const list = await getIdWarehouseList({ categoryId: productId });
  2294. return Array.isArray(list) ? list : [];
  2295. });
  2296. },
  2297. // 批次列表请求(走同键合并 + 缓存 + 限流)
  2298. fetchBatchList(params) {
  2299. const key = `batch:${params.warehouseId || ''}|${
  2300. params.categoryCode || ''
  2301. }|${params.colorKey || ''}|${params.modelType || ''}`;
  2302. return scheduleLookup(key, async () => {
  2303. const res = await getBatchList({ ...params, size: -1 });
  2304. return this.dedupeBatchNoList(res?.list);
  2305. });
  2306. },
  2307. remove(i) {
  2308. this.form.datasource.splice(i, 1);
  2309. this.setSort();
  2310. },
  2311. // 批量删除选中的物品
  2312. batchRemove() {
  2313. if (!this.selection.length) {
  2314. return this.$message.warning('请先勾选要删除的数据');
  2315. }
  2316. this.$confirm(
  2317. `确定要删除选中的 ${this.selection.length} 条物品吗?`,
  2318. '提示',
  2319. { type: 'warning' }
  2320. )
  2321. .then(() => {
  2322. const rows = this.selection;
  2323. this.form.datasource = this.form.datasource.filter(
  2324. (row) => !rows.includes(row)
  2325. );
  2326. this.selection = [];
  2327. if (this.$refs.table && this.$refs.table.clearSelection) {
  2328. this.$refs.table.clearSelection();
  2329. }
  2330. this.setSort();
  2331. this.$message.success('删除成功');
  2332. })
  2333. .catch(() => {});
  2334. },
  2335. // 批量设置发货数量:只作用于勾选的行,仅开发环境可用
  2336. setAllSendCountChange({ count }) {
  2337. if (!IS_DEV) return;
  2338. if (this.tableBusy) {
  2339. return this.$message.warning('物品清单加载中,请稍后再试');
  2340. }
  2341. if (count === undefined || count === null || count === '') {
  2342. return this.$message.warning('请输入发货数量');
  2343. }
  2344. const indexS = this.getSelectedIndexes();
  2345. if (!indexS.length) {
  2346. return this.$message.warning('请先勾选需要设置的行');
  2347. }
  2348. const countObj = {
  2349. countKey: 'saleCount',
  2350. unitKey: 'saleUnit',
  2351. unitIdKey: 'saleUnitId'
  2352. };
  2353. // changeCount 会返回新对象,这里只把算出来的字段写回原行对象,
  2354. // 保持行引用不变,否则勾选状态(selection 存的是行引用)会与表格失联
  2355. const calcFields = [
  2356. 'totalCount',
  2357. 'totalWeight',
  2358. 'singleWeight',
  2359. 'saleUnit',
  2360. 'discountSinglePrice',
  2361. 'totalPrice',
  2362. 'discountTotalPrice'
  2363. ];
  2364. const exceedItems = [];
  2365. indexS.forEach((i) => {
  2366. const row = this.form.datasource[i];
  2367. if (!row) return;
  2368. this.$set(row, 'saleCount', count);
  2369. const next = changeCount(row, countObj, false);
  2370. calcFields.forEach((key) => {
  2371. if (next[key] !== undefined) {
  2372. this.$set(row, key, next[key]);
  2373. }
  2374. });
  2375. // 发货总重 / 增重总重:与单行 changeCount 逻辑保持一致
  2376. this.$set(row, 'sendTotalWeight', row.totalWeight);
  2377. const receiveTotalWeight = Number(row.receiveTotalWeight) || 0;
  2378. const sendTotalWeight = Number(row.sendTotalWeight) || 0;
  2379. if (sendTotalWeight) {
  2380. const increaseTotalWeight = sendTotalWeight - receiveTotalWeight;
  2381. this.$set(row, 'increaseTotalWeight', increaseTotalWeight.toFixed(4));
  2382. if (row.pricingWay == 3) {
  2383. this.$set(
  2384. row,
  2385. 'totalPrice',
  2386. (increaseTotalWeight * row.singlePrice).toFixed(2)
  2387. );
  2388. }
  2389. }
  2390. // 不含税单价
  2391. this.getNotaxSinglePrice(i);
  2392. // 客户环境 4:按模数换算发货块数
  2393. if (this.clientEnvironmentId == 4) {
  2394. this.tableHandleKeyUp(row, i, 'sum');
  2395. }
  2396. // 超过订单剩余数量的行先提示,提交时仍会被拦截
  2397. const remainingCount = Number(row.notGenerateSendCount) || 0;
  2398. if (remainingCount && Number(row.totalCount) > remainingCount) {
  2399. exceedItems.push(row.productCode || row.productName);
  2400. }
  2401. });
  2402. this.$message.success(`已设置 ${indexS.length} 行的发货数量`);
  2403. if (exceedItems.length) {
  2404. this.$message.warning(
  2405. `${exceedItems.join('、')} 的发货数量大于订单剩余数量,请提交前调整`
  2406. );
  2407. }
  2408. // datasource 变化会触发表格 reload,reload 会清空勾选,
  2409. // 这里把本次设置的行重新勾上,方便连续设置不同的数量
  2410. this.$nextTick(() => {
  2411. const table = this.$refs.table;
  2412. if (!table || !table.toggleRowSelection) return;
  2413. indexS.forEach((i) => {
  2414. const row = this.form.datasource[i];
  2415. if (row) {
  2416. table.toggleRowSelection(row, true);
  2417. }
  2418. });
  2419. });
  2420. },
  2421. // 勾选行在数据源中的下标:按 row-key 匹配,不依赖 key 与下标一一对应
  2422. getSelectedIndexes() {
  2423. const keys = new Set(this.selection.map((item) => item.key));
  2424. const indexS = [];
  2425. this.form.datasource.forEach((row, index) => {
  2426. if (keys.has(row.key)) {
  2427. indexS.push(index);
  2428. }
  2429. });
  2430. return indexS;
  2431. },
  2432. // 重新排序
  2433. setSort() {
  2434. this.form.datasource.forEach((n, index) => {
  2435. n.key = index + 1;
  2436. });
  2437. },
  2438. //选择产品
  2439. handParent() {
  2440. console.log('this.type~~~~111', this.orderId);
  2441. if (!this.orderId && !this.orderIds)
  2442. return this.$message.error('请先选择订单');
  2443. this.$refs.BIZproductListRef.open('', -1);
  2444. },
  2445. // 添加
  2446. handlAdd() {
  2447. console.log('this.type~~~~222', this.orderId);
  2448. if (!this.orderId && !this.orderIds)
  2449. return this.$message.error('请先选择订单');
  2450. this.$refs.productListRef.open(this.oldProductList);
  2451. },
  2452. //库存台账
  2453. selectStockLedgerDialogOpen(row) {
  2454. this.current = row;
  2455. this.$refs.selectStockLedgerDialogRef.open();
  2456. },
  2457. validateForm(callback) {
  2458. if (this.batchLookupPending) {
  2459. this.$message.warning('批次库存查询中,请稍后重试');
  2460. callback(false);
  2461. return;
  2462. }
  2463. //开始表单校验
  2464. this.$refs.form.validate((valid, obj) => {
  2465. if (this.form.datasource.some((item) => item.batchStockId == 999)) {
  2466. this.$message.warning('订单批次无匹配的可发库存,请核对仓库、批次和颜色');
  2467. callback(false);
  2468. return;
  2469. }
  2470. // 同一订单产品可能拆成多条发货明细,删除明细后只按当前有效行汇总校验。
  2471. const groups = this.form.datasource.reduce((result, item) => {
  2472. const key = item.orderProductId
  2473. ? `order:${item.orderProductId}`
  2474. : `product:${item.productCode}|${item.batchNo || ''}|${item.colorKey || ''}|${item.modelType || ''}`;
  2475. const group = result[key] || { totalCount: 0, remainingCount: Number(item.notGenerateSendCount) || 0, productCode: item.productCode };
  2476. group.totalCount += Number(item.totalCount) || 0;
  2477. group.remainingCount = Math.max(group.remainingCount, Number(item.notGenerateSendCount) || 0);
  2478. result[key] = group;
  2479. return result;
  2480. }, {});
  2481. const exceededItems = Object.values(groups).filter(
  2482. (item) => item.totalCount > item.remainingCount
  2483. );
  2484. // 退货单退货不校验数量,实物赔偿无法计算
  2485. if (
  2486. exceededItems.length > 0 &&
  2487. this.sourceType != 3 &&
  2488. this.needProduce != 4
  2489. ) {
  2490. // 提取产品名称,生成详细提示消息
  2491. const productNames = exceededItems
  2492. .map((item) => item.productCode)
  2493. .join('、');
  2494. this.$message.warning(`${productNames} 的发货数量大于订单剩余数量`);
  2495. callback(false);
  2496. return;
  2497. }
  2498. if (obj) {
  2499. let messages = Object.keys(obj).map((key) => obj[key][0]);
  2500. if (messages.length > 0) {
  2501. this.$message.warning(messages[0].message);
  2502. }
  2503. }
  2504. callback(valid);
  2505. });
  2506. }
  2507. }
  2508. };
  2509. </script>
  2510. <style lang="scss" scoped>
  2511. ::v-deep .el-table .warning-row {
  2512. background: #d9ecff;
  2513. }
  2514. .headbox {
  2515. display: flex;
  2516. justify-content: flex-start;
  2517. align-items: center;
  2518. .amount {
  2519. font-size: 14px;
  2520. font-weight: bold;
  2521. padding-right: 30px;
  2522. }
  2523. }
  2524. .replace-code-cell {
  2525. display: flex;
  2526. flex-direction: column;
  2527. align-items: center;
  2528. line-height: 1.5;
  2529. }
  2530. .code-text {
  2531. max-width: 100%;
  2532. overflow: hidden;
  2533. text-overflow: ellipsis;
  2534. white-space: nowrap;
  2535. }
  2536. .time-form .el-form-item {
  2537. margin-bottom: 0 !important;
  2538. }
  2539. /* 遮罩层:批量回显期间盖在表格上方,避免用户看到半成品数据 */
  2540. .table-container {
  2541. position: relative;
  2542. }
  2543. .table-loading-mask {
  2544. position: absolute;
  2545. top: 0;
  2546. left: 0;
  2547. right: 0;
  2548. bottom: 0;
  2549. z-index: 10;
  2550. display: flex;
  2551. flex-direction: column;
  2552. align-items: center;
  2553. justify-content: center;
  2554. background-color: rgba(255, 255, 255, 0.75);
  2555. }
  2556. .table-loading-mask .el-icon-loading {
  2557. font-size: 30px;
  2558. color: #409eff;
  2559. }
  2560. .table-loading-text {
  2561. margin-top: 10px;
  2562. font-size: 13px;
  2563. color: #909399;
  2564. }
  2565. /* 批量追加期间禁止单元格交互:只关掉 .cell 的指针事件,
  2566. 滚轮事件仍会落在滚动容器上,所以表格照常可以滚动 */
  2567. ::v-deep .time-form-busy .el-table__body-wrapper .cell,
  2568. ::v-deep .time-form-busy .el-table__fixed-body-wrapper .cell {
  2569. pointer-events: none;
  2570. }
  2571. ::v-deep .period {
  2572. display: flex;
  2573. .borderleftnone {
  2574. .el-input--medium .el-input__inner {
  2575. border-top-right-radius: 0;
  2576. border-bottom-right-radius: 0;
  2577. }
  2578. }
  2579. .borderrightnone {
  2580. .el-input--medium .el-input__inner {
  2581. border-top-left-radius: 0;
  2582. border-bottom-left-radius: 0;
  2583. }
  2584. }
  2585. }
  2586. ::v-deep .time-form tbody > tr:hover > td {
  2587. background-color: transparent !important;
  2588. }
  2589. // ::v-deep .time-form .el-table tr {
  2590. // background-color: #ffffff;
  2591. // }
  2592. .pricebox {
  2593. display: flex;
  2594. justify-content: flex-start;
  2595. align-items: center;
  2596. font-weight: bold;
  2597. }
  2598. </style>