inventoryTable.vue 52 KB

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