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. :disabled="sourceType == 4"
  305. @input="changeCount(scope.row, scope.$index, false)"
  306. >
  307. <template slot="append">
  308. <el-select
  309. v-model="scope.row.saleUnitId"
  310. style="width: 80px"
  311. @change="changeCount(scope.row, scope.$index)"
  312. :disabled="clientEnvironmentId == 4 || sourceType == 4"
  313. >
  314. <el-option
  315. :label="item.conversionUnit"
  316. :value="item.id"
  317. v-for="(item, index) in scope.row.packageDispositionList"
  318. :key="index"
  319. ></el-option>
  320. </el-select>
  321. </template>
  322. </el-input>
  323. </el-form-item>
  324. </template>
  325. <template v-slot:warehouseNum="scope">
  326. <el-form-item :prop="'datasource.' + scope.$index + '.warehouseNum'">
  327. <span>{{ scope.row.warehouseNum }}</span>
  328. </el-form-item>
  329. </template>
  330. <!-- <template v-slot:saleUnit="scope">
  331. <el-form-item
  332. style="margin-bottom: 20px"
  333. :prop="'datasource.' + scope.$index + '.saleUnitId'"
  334. >
  335. <el-select
  336. v-model="scope.row.saleUnitId"
  337. style="width: 100%"
  338. @change="changeCount(scope.row, scope.$index)"
  339. :disabled="clientEnvironmentId == 4"
  340. >
  341. <el-option
  342. :label="item.conversionUnit"
  343. :value="item.id"
  344. @click.native="packingChange(item, scope.$index)"
  345. v-for="(item, index) in scope.row.packageDispositionList"
  346. :key="index"
  347. ></el-option>
  348. </el-select>
  349. </el-form-item>
  350. </template> -->
  351. <template v-slot:modelKey="scope">
  352. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'modelKey'">
  353. <DictSelection
  354. dictName="物品机型"
  355. clearable
  356. v-model="scope.row.modelKey"
  357. :isOne="scope.$index === 0"
  358. filterable
  359. allow-create
  360. default-first-option
  361. multiple
  362. >
  363. </DictSelection>
  364. </el-form-item>
  365. </template>
  366. <template v-slot:colorKey="scope">
  367. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'colorKey'">
  368. <DictSelection
  369. dictName="物品颜色"
  370. clearable
  371. v-model="scope.row.colorKey"
  372. :isOne="scope.$index === 0"
  373. filterable
  374. allow-create
  375. default-first-option
  376. multiple
  377. >
  378. </DictSelection>
  379. </el-form-item>
  380. </template>
  381. <!-- 操作列 -->
  382. <template v-slot:action="scope">
  383. <el-popconfirm
  384. class="ele-action"
  385. title="确定要删除吗?"
  386. @confirm="remove(scope.$index)"
  387. >
  388. <template v-slot:reference>
  389. <el-link type="danger" :underline="false" icon="el-icon-delete">
  390. 删除
  391. </el-link>
  392. </template>
  393. </el-popconfirm>
  394. <el-link
  395. type="primary"
  396. :underline="false"
  397. icon="el-icon-edit"
  398. @click="selectStockLedgerDialogOpen(scope.row)"
  399. >
  400. 替代料
  401. </el-link>
  402. </template>
  403. </ele-pro-table>
  404. <productListNew
  405. ref="productListRef"
  406. @changeParent="changeParent"
  407. ></productListNew>
  408. <!--入库详情-->
  409. <innertboundDetailsDialog
  410. v-if="innerboundDetailsDialogFlag"
  411. ref="innerboundDetailsDialogRef"
  412. :innerboundDetailsDialogFlag.sync="innerboundDetailsDialogFlag"
  413. @saveDate="saveInnerDate"
  414. ></innertboundDetailsDialog>
  415. <!-- 库存台账 -->
  416. <stock-ledger-dialog
  417. v-if="stockLedgerDialogFlag"
  418. :stock-ledger-dialog-flag.sync="stockLedgerDialogFlag"
  419. ref="stockLedgerDialogRef"
  420. @getStockLedger="getStockLedger"
  421. ></stock-ledger-dialog>
  422. <selectStockLedgerDialog
  423. ref="selectStockLedgerDialogRef"
  424. @changeParent="replaceTable"
  425. ></selectStockLedgerDialog>
  426. <BIZproductList
  427. ref="BIZproductListRef"
  428. classType="1"
  429. :isGetInventoryTotal="true"
  430. @changeParent="changeParentBiz"
  431. :typeIds="typeIds"
  432. :isFirstRefreshTable="true"
  433. ></BIZproductList>
  434. </el-form>
  435. </template>
  436. <script>
  437. import { numberReg } from 'ele-admin';
  438. import dictMixins from '@/mixins/dictMixins';
  439. import productListNew from './product-listNew.vue';
  440. import {
  441. getWarehouseOutStock,
  442. getIdWarehouseList
  443. } from '@/api/saleManage/saleorder';
  444. import { copyObj } from '@/utils/util';
  445. import innertboundDetailsDialog from '@/BIZComponents/innerboundDetailsDialog.vue';
  446. import stockLedgerDialog from './stockLedger/stockLedgerDialog.vue';
  447. import getDynamicsColumns from '@/mixins/getDynamicsColumns';
  448. import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
  449. import BIZproductList from '@/BIZComponents/product-list.vue';
  450. import tabMixins from '@/mixins/tableColumnsMixin';
  451. import { levelList, pricingWayList, lbjtList } from '@/enum/dict.js';
  452. import { changeCount, formatPrice } from '@/BIZComponents/setProduct.js';
  453. import { parameterGetByCode } from '@/api/main/index.js';
  454. import { getSummaries } from '@/utils/util.js';
  455. import { getBatchList } from '@/api/wms';
  456. export default {
  457. mixins: [dictMixins, getDynamicsColumns, tabMixins],
  458. props: {
  459. orderId: String,
  460. orderIds: String,
  461. orderNos: String,
  462. needProduce: [String, Number],
  463. entrustedCode: String,
  464. pricingWay: [String, Number],
  465. isShowAdd: {
  466. type: Boolean,
  467. default: true
  468. },
  469. typeIds: {
  470. type: Array,
  471. default: () => []
  472. },
  473. oldProductList: {
  474. type: Array,
  475. default: () => []
  476. },
  477. sourceType: {
  478. type: [String, Number],
  479. default: ''
  480. },
  481. isTotalCount: {
  482. default: 0
  483. }
  484. },
  485. components: {
  486. // fileMain,
  487. innertboundDetailsDialog,
  488. productListNew,
  489. stockLedgerDialog,
  490. selectStockLedgerDialog,
  491. BIZproductList
  492. },
  493. data() {
  494. const defaultForm = {
  495. key: null,
  496. endTime: '',
  497. isFirst: 0,
  498. name: '',
  499. startTime: '',
  500. workHour: '',
  501. technicalDrawings: []
  502. // warehouseCode:"",
  503. // warehouseId:'',
  504. // warehouseName:'',
  505. };
  506. return {
  507. cacheKeyUrl: 'eos-saleManage-invoice-inventoryTable',
  508. current: {},
  509. childrenColumns: [
  510. {
  511. width: 45,
  512. type: 'selection',
  513. columnKey: 'selection',
  514. align: 'center'
  515. },
  516. {
  517. width: 45,
  518. type: 'index',
  519. columnKey: 'index',
  520. align: 'center',
  521. fixed: 'left'
  522. },
  523. {
  524. minWidth: 100,
  525. prop: 'code',
  526. label: '编码',
  527. align: 'center'
  528. },
  529. {
  530. minWidth: 140,
  531. prop: 'barcodes',
  532. label: '发货条码',
  533. align: 'center'
  534. },
  535. {
  536. minWidth: 100,
  537. prop: 'engrave',
  538. label: '刻码',
  539. align: 'center'
  540. }
  541. ],
  542. selection: [],
  543. discountTotalPrice: 0.0,
  544. allPrice: 0.0,
  545. curIndex: null,
  546. innerboundDetailsDialogFlag: false,
  547. stockLedgerDialogFlag: false,
  548. numberReg,
  549. defaultForm,
  550. warehouseList: [],
  551. dynamicsColumns: [],
  552. isWarehouseId: 0,
  553. blockCountColumn: {},
  554. form: {
  555. datasource: []
  556. },
  557. rules: {},
  558. columnsVersion: 1
  559. };
  560. },
  561. created() {
  562. this.requestDict('产地');
  563. this.requestDict('生产类型');
  564. parameterGetByCode({
  565. code: 'eom_saleManage_invoice_warehouseId'
  566. }).then((res) => {
  567. if (res.value) {
  568. this.isWarehouseId = res.value;
  569. }
  570. });
  571. },
  572. computed: {
  573. canHandl() {
  574. return this.form.datasource.length;
  575. },
  576. clientEnvironmentId() {
  577. return this.$store.state.user.info.clientEnvironmentId;
  578. },
  579. orderNoList() {
  580. const temp = this.orderNos?.split(',') || []
  581. return temp.map(item => {
  582. return {
  583. label: item,
  584. value: item
  585. }
  586. });
  587. },
  588. columns() {
  589. let columnsVersion = this.columnsVersion;
  590. return [
  591. {
  592. width: 60,
  593. type: 'index',
  594. columnKey: 'index',
  595. align: 'center',
  596. fixed: 'left'
  597. },
  598. {
  599. minWidth: 200,
  600. prop: 'orderNo',
  601. label: '订单编码',
  602. align: 'center',
  603. slot: 'orderNo',
  604. fixed: 'left'
  605. },
  606. {
  607. width: 200,
  608. prop: 'productName',
  609. label: '名称',
  610. slot: 'productName',
  611. align: 'center'
  612. },
  613. {
  614. width: 120,
  615. prop: 'productCode',
  616. label: '编码',
  617. slot: 'productCode',
  618. align: 'center'
  619. },
  620. {
  621. width: 200,
  622. prop: 'productCategoryName',
  623. label: '类型',
  624. slot: 'productCategoryName',
  625. align: 'center'
  626. },
  627. {
  628. width: 140,
  629. prop: 'pricingWay',
  630. label: '计价方式',
  631. align: 'center',
  632. fixed: 'left',
  633. formatter: (row, column) => {
  634. return pricingWayList.find((item) => item.id == row.pricingWay)
  635. ?.name;
  636. }
  637. },
  638. {
  639. width: 160,
  640. prop: 'batchStockId',
  641. label: '批次号',
  642. slot: 'batchStockId',
  643. align: 'center'
  644. },
  645. {
  646. width: 160,
  647. prop: 'productBrand',
  648. label: '牌号',
  649. slot: 'productBrand',
  650. align: 'center'
  651. },
  652. {
  653. width: 120,
  654. prop: 'modelType',
  655. label: '型号',
  656. slot: 'modelType',
  657. align: 'center'
  658. },
  659. {
  660. width: 120,
  661. prop: 'specification',
  662. label: '规格',
  663. slot: 'specification',
  664. align: 'center'
  665. },
  666. {
  667. width: 160,
  668. prop: 'modelKey',
  669. label: '机型',
  670. slot: 'modelKey',
  671. align: 'center'
  672. },
  673. {
  674. width: 160,
  675. prop: 'colorKey',
  676. label: '颜色',
  677. slot: 'colorKey',
  678. align: 'center'
  679. },
  680. {
  681. minWidth: 160,
  682. prop: 'productionCodes',
  683. label: '生产编号',
  684. align: 'center',
  685. slot: 'productionCodes'
  686. },
  687. {
  688. minWidth: 280,
  689. prop: 'productionRequirements',
  690. label: '生产要求',
  691. align: 'center'
  692. },
  693. {
  694. minWidth: 120,
  695. prop: 'goodsLevel',
  696. label: '物品级别',
  697. formatter: (_row, _column, cellValue) => {
  698. return levelList.find((item) => item.value == _row.goodsLevel)
  699. ?.label;
  700. },
  701. align: 'center'
  702. },
  703. ...this.dynamicsColumns,
  704. {
  705. width: 120,
  706. prop: 'customerMark',
  707. label: '客户代号',
  708. slot: 'customerMark',
  709. align: 'center'
  710. },
  711. {
  712. width: 200,
  713. prop: 'warehouseId',
  714. label: '仓库名称',
  715. slot: 'warehouseId',
  716. headerSlot: 'headerWarehouseId',
  717. align: 'center'
  718. },
  719. {
  720. width: 100,
  721. prop: 'warehouseNum',
  722. label: '库存',
  723. align: 'center',
  724. slot: 'warehouseNum'
  725. },
  726. // {
  727. // width: 100,
  728. // prop: 'stockLedger',
  729. // label: '发货明细',
  730. // slot: 'stockLedger',
  731. // align: 'center'
  732. // },
  733. {
  734. width: 250,
  735. prop: 'saleCount',
  736. label: '发货数量',
  737. slot: 'saleCount',
  738. headerSlot: 'headerTotalCount',
  739. align: 'center'
  740. },
  741. {
  742. width: 100,
  743. prop: 'notSendTotalCount',
  744. label: '未发数量',
  745. align: 'center',
  746. formatter: (row, column) => {
  747. if (row.notSendTotalCount) {
  748. return row.notSendTotalCount + ' ' + row.measuringUnit;
  749. }
  750. }
  751. },
  752. {
  753. width: 120,
  754. prop: 'packingSpecification',
  755. align: 'center',
  756. label: '包装规格',
  757. showOverflowTooltip: true
  758. },
  759. {
  760. width: 120,
  761. prop: 'totalCount',
  762. label: '计量数量',
  763. formatter: (row, column) => {
  764. if (row.totalCount) {
  765. return row.totalCount + ' ' + row.measuringUnit;
  766. }
  767. },
  768. align: 'center'
  769. },
  770. {
  771. width: 120,
  772. prop: 'orderTotalCount',
  773. label: '订单数量',
  774. formatter: (row, column) => {
  775. if (row.orderTotalCount) {
  776. return row.orderTotalCount + ' ' + row.measuringUnit;
  777. }
  778. },
  779. align: 'center'
  780. },
  781. // {
  782. // width: 80,
  783. // prop: 'measuringUnit',
  784. // label: '计量单位',
  785. // slot: 'measuringUnit',
  786. // align: 'center'
  787. // },
  788. this.clientEnvironmentId == 4 ? {
  789. width: 150,
  790. prop: 'blockCount',
  791. label: '发货块数',
  792. slot: 'blockCount',
  793. align: 'center'
  794. }
  795. : { width: 1 },
  796. {
  797. width: 200,
  798. prop: 'singleWeight',
  799. slot: 'singleWeight',
  800. label: '单重',
  801. align: 'center'
  802. },
  803. {
  804. width: 250,
  805. prop: 'receiveTotalWeight',
  806. label: '收货总重',
  807. slot: 'receiveTotalWeight',
  808. align: 'center',
  809. headerSlot: 'headerReceiveTotalWeight'
  810. },
  811. {
  812. width: 220,
  813. prop: 'sendTotalWeight',
  814. label: '发货总重',
  815. slot: 'sendTotalWeight',
  816. align: 'center'
  817. },
  818. {
  819. width: 220,
  820. prop: 'increaseTotalWeight',
  821. label: '增重重量',
  822. slot: 'increaseTotalWeight',
  823. align: 'center'
  824. },
  825. {
  826. width: 180,
  827. prop: 'singlePrice',
  828. label: '单价',
  829. slot: 'singlePrice',
  830. align: 'center'
  831. },
  832. {
  833. width: 160,
  834. prop: 'taxRate',
  835. label: '税率',
  836. formatter: (_row, _column, cellValue) => {
  837. return _row.taxRate ? _row.taxRate + '%' : '';
  838. },
  839. align: 'center'
  840. },
  841. {
  842. width: 180,
  843. prop: 'notaxSinglePrice',
  844. label: '不含税单价',
  845. align: 'center'
  846. },
  847. {
  848. width: 160,
  849. prop: 'discountSinglePrice',
  850. label: '折后单价',
  851. slot: 'discountSinglePrice',
  852. align: 'center'
  853. },
  854. {
  855. width: 120,
  856. prop: 'totalPrice',
  857. label: '合计',
  858. slot: 'totalPrice',
  859. align: 'center'
  860. },
  861. {
  862. width: 160,
  863. prop: 'notaxTotalPrice',
  864. label: '含税合计',
  865. align: 'center'
  866. },
  867. {
  868. width: 120,
  869. prop: 'discountTotalPrice',
  870. label: '折后合计',
  871. slot: 'discountTotalPrice',
  872. align: 'center'
  873. },
  874. {
  875. width: 120,
  876. prop: 'imgCode',
  877. align: 'center',
  878. label: '图号/件号',
  879. showOverflowTooltip: true
  880. },
  881. {
  882. width: 120,
  883. prop: 'produceType',
  884. align: 'center',
  885. label: '属性类型',
  886. formatter: (row, column) => {
  887. if (row.produceType) {
  888. return row.produceType
  889. .map((item) => {
  890. return lbjtList[item];
  891. })
  892. .toString();
  893. }
  894. },
  895. showOverflowTooltip: true
  896. },
  897. {
  898. width: 200,
  899. prop: 'guaranteePeriod',
  900. label: '有效期',
  901. slot: 'guaranteePeriod',
  902. formatter: (_row, _column, cellValue) => {
  903. let val = '';
  904. if (_row.guaranteePeriod) {
  905. val += _row.guaranteePeriod;
  906. }
  907. if (_row.guaranteePeriodUnitName) {
  908. val += _row.guaranteePeriodUnitName;
  909. }
  910. return val;
  911. },
  912. align: 'center'
  913. },
  914. {
  915. width: 200,
  916. prop: 'guaranteePeriodDeadline',
  917. label: '有效期截止日期',
  918. slot: 'guaranteePeriodDeadline',
  919. align: 'center'
  920. },
  921. {
  922. prop: 'provenance',
  923. label: '产地',
  924. slot: 'provenance',
  925. align: 'center',
  926. // show:this.contractBookType==2,
  927. minWidth: 200,
  928. showOverflowTooltip: true,
  929. formatter: (row, column) => {
  930. return row.provenance && row.provenance.length
  931. ? row.provenance
  932. .map((item) => this.getDictValue('产地', item))
  933. .join(',')
  934. : '';
  935. }
  936. },
  937. {
  938. width: 130,
  939. prop: 'technicalAnswerName',
  940. label: '技术答疑人',
  941. slot: 'technicalAnswerName',
  942. align: 'center'
  943. },
  944. {
  945. width: 220,
  946. prop: 'technicalParams',
  947. label: '技术参数',
  948. slot: 'technicalParams',
  949. align: 'center'
  950. },
  951. {
  952. width: 240,
  953. prop: 'technicalDrawings',
  954. label: '技术图纸',
  955. slot: 'technicalDrawings',
  956. align: 'center'
  957. },
  958. {
  959. width: 220,
  960. prop: 'remark',
  961. label: '备注',
  962. slot: 'remark',
  963. align: 'center'
  964. },
  965. {
  966. columnKey: 'action',
  967. label: '操作',
  968. width: 200,
  969. align: 'center',
  970. resizable: false,
  971. slot: 'action',
  972. fixed: 'right',
  973. showOverflowTooltip: true
  974. }
  975. ];
  976. }
  977. },
  978. mounted() {
  979. // this.clientEnvironmentId =
  980. },
  981. methods: {
  982. formatPrice,
  983. getSummaries(param) {
  984. if (this.clientEnvironmentId != 4) {
  985. return;
  986. }
  987. return getSummaries(
  988. param,
  989. ['saleCount', 'blockCount', 'totalCount'],
  990. ' '
  991. );
  992. },
  993. //发货明细选择
  994. stockLedgerSelect(row, index) {
  995. this.curIndex = index;
  996. this.stockLedgerDialogFlag = true;
  997. this.$nextTick(() => {
  998. this.$refs.stockLedgerDialogRef.init(row.sendProductDetail, row);
  999. });
  1000. },
  1001. packingChange(item, index) {
  1002. this.$set(this.form.datasource[index], 'saleUnit', item.conversionUnit);
  1003. },
  1004. //获取
  1005. getStockLedger(sendProductDetail) {
  1006. if (!this.form.datasource[this.curIndex].sendProductDetail)
  1007. this.form.datasource[this.curIndex].sendProductDetail = [];
  1008. let row = this.form.datasource[this.curIndex];
  1009. row.sendProductDetail.push(...sendProductDetail);
  1010. this.form.datasource[this.curIndex] = row;
  1011. this.$refs['childrenTable' + this.curIndex].reload();
  1012. this.$refs.table.reload();
  1013. },
  1014. //删除发货明细
  1015. stockLedgerRemove(PIndex) {
  1016. let row = this.form.datasource[PIndex];
  1017. this.selection.forEach((item) => {
  1018. let index = row.sendProductDetail.findIndex((i) => i.id == item.id);
  1019. row.sendProductDetail.splice(index, 1);
  1020. });
  1021. this.form.datasource[PIndex] = row;
  1022. this.$refs['childrenTable' + PIndex].reload();
  1023. this.$refs.table.reload();
  1024. this.selection = [];
  1025. },
  1026. async warehouseChange(index, row, isReset = false) {
  1027. // console.log('warehouseChange', index, row.isSuspend, isReset);
  1028. const data = row.warehouseList.find(
  1029. (item) => item.warehouseId == row.warehouseId
  1030. );
  1031. this.$set(
  1032. this.form.datasource[index],
  1033. 'warehouseName',
  1034. data.warehouseName
  1035. );
  1036. this.$set(
  1037. this.form.datasource[index],
  1038. 'warehouseCode',
  1039. data.warehouseCode
  1040. );
  1041. const warehouseOutStock = await getWarehouseOutStock({
  1042. warehouseId: data.warehouseId,
  1043. code: row.productCode
  1044. });
  1045. this.$set(
  1046. this.form.datasource[index],
  1047. 'warehouseNum',
  1048. warehouseOutStock || 0
  1049. );
  1050. const tempBatchNoList = await getBatchList({
  1051. warehouseId: data.warehouseId,
  1052. categoryCode: row.productCode
  1053. });
  1054. this.$set(
  1055. this.form.datasource[index],
  1056. 'batchNoList',
  1057. tempBatchNoList?.list || []
  1058. );
  1059. if (isReset) {
  1060. this.$set(this.form.datasource[index], 'batchStockId', '');
  1061. this.$set(this.form.datasource[index], 'batchNo', '');
  1062. }
  1063. },
  1064. //批次号选择
  1065. async batchNoChange(index, row) {
  1066. if (!row.batchStockId) {
  1067. this.$set(this.form.datasource[index], 'batchNo', '');
  1068. // this.$set(this.form.datasource[index], 'warehouseNum', '');
  1069. const tempWarehouse = await getIdWarehouseList({
  1070. categoryId: this.form.datasource[index].productId
  1071. });
  1072. // 有仓库列表
  1073. if (tempWarehouse?.length) {
  1074. console.log('666~~~~!!', index, tempWarehouse);
  1075. this.$set(
  1076. this.form.datasource[index],
  1077. 'warehouseList',
  1078. tempWarehouse
  1079. );
  1080. }
  1081. this.$set(
  1082. this.form.datasource[index],
  1083. 'warehouseNum',
  1084. row.warehouseId
  1085. ? await getWarehouseOutStock({
  1086. warehouseId: row.warehouseId,
  1087. code: row.productCode
  1088. })
  1089. : ''
  1090. );
  1091. return;
  1092. }
  1093. const data = row.batchNoList.find(
  1094. (item) => item.id == row.batchStockId
  1095. );
  1096. this.$set(this.form.datasource[index], 'batchNo', data.batchNo);
  1097. this.$set(
  1098. this.form.datasource[index],
  1099. 'warehouseNum',
  1100. data.measureQuantity || 0
  1101. );
  1102. },
  1103. //改变数量
  1104. changeCount(row, index, isBlockCount = true, weightType) {
  1105. if (weightType == 'totalWeight') {
  1106. this.$set(
  1107. this.form.datasource[index],
  1108. 'totalWeight',
  1109. this.form.datasource[index].sendTotalWeight
  1110. );
  1111. }
  1112. this.$set(
  1113. this.form.datasource,
  1114. index,
  1115. changeCount(
  1116. row,
  1117. {
  1118. countKey: 'saleCount',
  1119. unitKey: 'saleUnit',
  1120. unitIdKey: 'saleUnitId'
  1121. },
  1122. false,
  1123. weightType
  1124. )
  1125. );
  1126. this.$set(
  1127. this.form.datasource[index],
  1128. 'sendTotalWeight',
  1129. this.form.datasource[index].totalWeight
  1130. );
  1131. this.changeSendTotalWeight(row, index);
  1132. this.getNotaxSinglePrice();
  1133. this.$forceUpdate();
  1134. if (this.clientEnvironmentId == 4 && !isBlockCount) {
  1135. this.tableHandleKeyUp(row, index, 'sum');
  1136. }
  1137. },
  1138. //修改发货总重
  1139. changeSendTotalWeight(row, index) {
  1140. this.curIndex = index;
  1141. this.setIcreaseTotalWeight(row);
  1142. },
  1143. keyChange(index, row, key) {
  1144. this.$set(
  1145. this.form.datasource[index],
  1146. 'extField.' + key,
  1147. row.extField[key]
  1148. );
  1149. this.$forceUpdate();
  1150. },
  1151. //设置增重总重
  1152. setIcreaseTotalWeight(row) {
  1153. let receiveTotalWeight = Number(
  1154. this.form.datasource[this.curIndex]?.receiveTotalWeight
  1155. );
  1156. let sendTotalWeight = Number(
  1157. this.form.datasource[this.curIndex]?.sendTotalWeight
  1158. );
  1159. if (sendTotalWeight) {
  1160. let increaseTotalWeight = sendTotalWeight - receiveTotalWeight;
  1161. this.$set(
  1162. this.form.datasource[this.curIndex],
  1163. 'increaseTotalWeight',
  1164. increaseTotalWeight.toFixed(4)
  1165. );
  1166. if (row.pricingWay == 3) {
  1167. this.$set(
  1168. this.form.datasource[this.curIndex],
  1169. 'totalPrice',
  1170. (increaseTotalWeight * row.singlePrice).toFixed(2)
  1171. );
  1172. }
  1173. }
  1174. this.$refs.table.reload();
  1175. this.$forceUpdate();
  1176. },
  1177. //计算不含税单价
  1178. getNotaxSinglePrice() {
  1179. this.form.datasource.forEach((item, index) => {
  1180. if (item.singlePrice && item.taxRate) {
  1181. this.$set(
  1182. this.form.datasource[index],
  1183. 'notaxSinglePrice',
  1184. formatPrice(item.singlePrice / (1 + item.taxRate / 100))
  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>