inventoryTable.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436
  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. max-height="500px"
  8. :datasource="form.datasource"
  9. class="time-form"
  10. :cache-key="cacheKeyUrl"
  11. :selection.sync="selection"
  12. @columns-change="handleColumnChange"
  13. >
  14. <!-- 表头工具栏 -->
  15. <template v-slot:toolbar>
  16. <div class="headbox">
  17. <el-button
  18. v-if="modalType === 'add'"
  19. size="small"
  20. type="primary"
  21. icon="el-icon-plus"
  22. class="ele-btn-icon"
  23. @click="handlAdd"
  24. >
  25. 新增
  26. </el-button>
  27. <warehouseAll
  28. @success="warehouseAllChange"
  29. :disabled="!selection.length"
  30. ></warehouseAll>
  31. </div>
  32. </template>
  33. <template v-slot:technicalDrawings="{ row, $index }">
  34. <el-form-item
  35. style="margin-bottom: 20px"
  36. :prop="'datasource.' + $index + '.technicalDrawings'"
  37. >
  38. <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
  39. </el-form-item>
  40. </template>
  41. <template v-slot:remark="{ row, $index }">
  42. <el-form-item
  43. style="margin-bottom: 20px"
  44. :prop="'datasource.' + $index + '.remark'"
  45. >
  46. <el-input
  47. clearable
  48. v-model="row.remark"
  49. type="textarea"
  50. placeholder="请输入"
  51. />
  52. </el-form-item>
  53. </template>
  54. <!-- <template v-slot:totalCount="scope">
  55. <el-form-item
  56. style="margin-bottom: 20px"
  57. :prop="'datasource.' + scope.$index + '.totalCount'"
  58. :rules="[{ required: true, message: '请输入数字', trigger: 'blur' }]"
  59. >
  60. <el-input
  61. v-model="scope.row.totalCount"
  62. @input="(val) => changeNum(val, scope.$index, scope.row)"
  63. ></el-input>
  64. </el-form-item>
  65. </template> -->
  66. <template v-slot:batchNo="scope">
  67. <el-form-item
  68. style="margin-bottom: 20px"
  69. :prop="'datasource.' + scope.$index + '.batchNo'"
  70. :rules="[
  71. {
  72. required: isBatchNo == 1 ? true : false,
  73. message: '请输入批号',
  74. trigger: 'blur'
  75. }
  76. ]"
  77. >
  78. <el-input v-model="scope.row.batchNo"></el-input>
  79. </el-form-item>
  80. </template>
  81. <template v-slot:productionDate="scope">
  82. <el-form-item :prop="'datasource.' + scope.$index + '.productionDate'">
  83. <el-date-picker
  84. style="width: 140px"
  85. v-model="scope.row.productionDate"
  86. type="date"
  87. placeholder="选择日期"
  88. @change="setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')"
  89. >
  90. </el-date-picker>
  91. </el-form-item>
  92. </template>
  93. <!-- :disabled="!outsourceSendCode" -->
  94. <template v-slot:sendTotalWeight="scope">
  95. <el-form-item
  96. style="margin-bottom: 20px"
  97. :prop="'datasource.' + scope.$index + '.sendTotalWeight'"
  98. >
  99. <el-input
  100. type="number"
  101. v-model="scope.row.sendTotalWeight"
  102. @blur="setIcreaseTotalWeight(scope.$index)"
  103. style="width: calc(100% - 67px); margin-right: 10px"
  104. :disabled="!outsourceSendCode"
  105. >
  106. <template slot="append">
  107. {{ scope.row.weightUnit }}
  108. </template>
  109. </el-input>
  110. <el-button
  111. size="small"
  112. type="primary"
  113. v-if="outsourceSendCode"
  114. @click.native="(e) => handleOutBound(e, scope.row, scope.$index)"
  115. >选择
  116. </el-button>
  117. </el-form-item>
  118. </template>
  119. <template v-slot:receiveTotalWeight="scope">
  120. <el-form-item
  121. :prop="'datasource.' + scope.$index + '.receiveTotalWeight'"
  122. >
  123. <el-input
  124. type="number"
  125. v-model="scope.row.receiveTotalWeight"
  126. @input="changeCount(scope.row, scope.$index, 'totalWeight')"
  127. style="width: 100%"
  128. :disabled="isDis(scope.row)"
  129. >
  130. <template slot="append">
  131. {{ scope.row.weightUnit }}
  132. </template>
  133. </el-input>
  134. </el-form-item>
  135. </template>
  136. <template v-slot:increaseTotalWeight="scope">
  137. <el-form-item
  138. :prop="'datasource.' + scope.$index + '.increaseTotalWeight'"
  139. >
  140. <el-input
  141. type="number"
  142. :controls="false"
  143. v-model="scope.row.increaseTotalWeight"
  144. :disabled="true"
  145. style="width: 100%"
  146. >
  147. <template slot="append">
  148. {{ scope.row.weightUnit }}
  149. </template>
  150. </el-input>
  151. </el-form-item>
  152. </template>
  153. <template v-slot:warehouseId="scope">
  154. <el-form-item
  155. style="margin-bottom: 20px"
  156. :prop="'datasource.' + scope.$index + '.warehouseId'"
  157. :rules="[{ required: true, message: '请选择仓库', trigger: 'blur' }]"
  158. >
  159. <el-select
  160. v-model="scope.row.warehouseId"
  161. placeholder="请选择"
  162. @change="warehouseChange(scope.$index, scope.row)"
  163. >
  164. <!-- .filter((item) => item.inventoryType == (scope.row.categoryLevelRootId||scope.row.categoryRootLevelId)) -->
  165. <el-option
  166. v-for="item in warehouseList"
  167. :key="item.id"
  168. :label="item.name"
  169. :value="item.id"
  170. >
  171. </el-option>
  172. </el-select>
  173. </el-form-item>
  174. </template>
  175. <template v-slot:singlePrice="scope">
  176. <el-form-item
  177. style="margin-bottom: 20px"
  178. :prop="'datasource.' + scope.$index + '.singlePrice'"
  179. >
  180. <el-input
  181. v-model="scope.row.singlePrice"
  182. placeholder="请输入"
  183. type="number"
  184. @input="changeCount(scope.row, scope.$index)"
  185. >
  186. </el-input>
  187. </el-form-item>
  188. </template>
  189. <template v-slot:specification="scope">
  190. <el-form-item
  191. style="margin-bottom: 20px"
  192. :prop="'datasource.' + scope.$index + '.specification'"
  193. >
  194. <el-input v-model="scope.row.specification"></el-input>
  195. </el-form-item>
  196. </template>
  197. <template v-slot:warehouseNum="scope">
  198. <el-form-item style="margin-bottom: 20px">
  199. {{ scope.row.warehouseNum }}
  200. </el-form-item>
  201. </template>
  202. <template v-slot:headerWarehouseId="{ column }">
  203. <span class="is-required">{{ column.label }}</span>
  204. </template>
  205. <template v-slot:headerTotalCount="{ column }">
  206. <span
  207. :class="{
  208. 'is-required':
  209. [2, 3].includes(Number(sourceType)) && pricingWay == 2
  210. }"
  211. >{{ column.label }}</span
  212. >
  213. </template>
  214. <template v-slot:guaranteePeriod="scope">
  215. <div class="period">
  216. <div class="borderleftnone">
  217. <el-form-item
  218. style="margin-bottom: 20px"
  219. :prop="'datasource.' + scope.$index + '.guaranteePeriod'"
  220. :rules="{
  221. pattern: numberReg,
  222. message: '请输入数字',
  223. trigger: 'blur'
  224. }"
  225. >
  226. <el-input
  227. v-model="scope.row.guaranteePeriod"
  228. @change="
  229. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  230. "
  231. placeholder="请输入"
  232. ></el-input>
  233. </el-form-item>
  234. </div>
  235. <div class="borderrightnone">
  236. <DictSelection
  237. dictName="质保期单位"
  238. clearable
  239. v-model="scope.row.guaranteePeriodUnitCode"
  240. :isOne="scope.$index === 0"
  241. @change="
  242. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  243. "
  244. >
  245. </DictSelection>
  246. </div>
  247. </div>
  248. </template>
  249. <template v-slot:guaranteePeriodDeadline="scope">
  250. <el-form-item
  251. :prop="'datasource.' + scope.$index + '.guaranteePeriodDeadline'"
  252. >
  253. <el-date-picker
  254. style="width: 140px"
  255. v-model="scope.row.guaranteePeriodDeadline"
  256. type="date"
  257. placeholder="选择日期"
  258. >
  259. </el-date-picker>
  260. </el-form-item>
  261. </template>
  262. <template v-slot:purchaseCount="scope">
  263. <el-form-item
  264. style="margin-bottom: 20px"
  265. :prop="'datasource.' + scope.$index + '.purchaseCount'"
  266. :rules="{
  267. required: true,
  268. message: '请输入数量',
  269. trigger: 'change'
  270. }"
  271. >
  272. <el-input
  273. v-model="scope.row.purchaseCount"
  274. placeholder="请输入"
  275. type="number"
  276. :min="0"
  277. @input="changeCount(scope.row, scope.$index)"
  278. >
  279. <template slot="append">
  280. <el-select
  281. v-model="scope.row.purchaseUnitId"
  282. style="width: 80px"
  283. @change="changeCount(scope.row, scope.$index)"
  284. >
  285. <el-option
  286. :label="item.conversionUnit"
  287. :value="item.id"
  288. v-for="(item, index) in scope.row.packageDispositionList"
  289. :key="index"
  290. ></el-option>
  291. </el-select>
  292. </template>
  293. </el-input>
  294. </el-form-item>
  295. </template>
  296. <!-- <template v-slot:purchaseUnit="scope">
  297. <el-form-item
  298. style="margin-bottom: 20px"
  299. :prop="'datasource.' + scope.$index + '.purchaseUnitId'"
  300. >
  301. <el-select
  302. v-model="scope.row.purchaseUnitId"
  303. style="width: 100%"
  304. @change="changeCount(scope.row, scope.$index)"
  305. >
  306. <el-option
  307. :label="item.conversionUnit"
  308. :value="item.id"
  309. @click.native="packingChange(item, scope.$index)"
  310. v-for="(item, index) in scope.row.packageDispositionList"
  311. :key="index"
  312. ></el-option>
  313. </el-select>
  314. </el-form-item>
  315. </template> -->
  316. <template v-slot:modelKey="scope">
  317. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'modelKey'">
  318. <DictSelection
  319. dictName="物品机型"
  320. clearable
  321. v-model="scope.row.modelKey"
  322. :isOne="scope.$index === 0"
  323. filterable
  324. allow-create
  325. default-first-option
  326. >
  327. </DictSelection>
  328. </el-form-item>
  329. </template>
  330. <template v-slot:colorKey="scope">
  331. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'colorKey'">
  332. <DictSelection
  333. dictName="物品颜色"
  334. clearable
  335. v-model="scope.row.colorKey"
  336. :isOne="scope.$index === 0"
  337. filterable
  338. allow-create
  339. default-first-option
  340. >
  341. </DictSelection>
  342. </el-form-item>
  343. </template>
  344. <template v-slot:isRequired="{ column }">
  345. <span :class="isBatchNo == 1 ? 'is-required' : ''">{{
  346. column.label
  347. }}</span>
  348. </template>
  349. <!-- 操作列 -->
  350. <template v-slot:action="scope">
  351. <el-popconfirm
  352. class="ele-action"
  353. title="确定要删除吗?"
  354. @confirm="remove(scope.$index)"
  355. >
  356. <template v-slot:reference>
  357. <el-link type="danger" :underline="false" icon="el-icon-delete">
  358. 删除
  359. </el-link>
  360. </template>
  361. </el-popconfirm>
  362. </template>
  363. <template v-slot:taskName="scope">
  364. <el-form-item
  365. style="margin-bottom: 20px"
  366. :prop="'datasource.' + scope.$index + '.taskName'"
  367. >
  368. <el-input
  369. v-model="scope.row.taskName"
  370. placeholder="请选择"
  371. style="width: 60%; margin-right: 10px"
  372. disabled
  373. ></el-input>
  374. <el-button
  375. v-if="scope.row.productCode"
  376. size="small"
  377. type="primary"
  378. @click.native="handleTaskinstance(scope.row, scope.$index)"
  379. >选择
  380. </el-button>
  381. </el-form-item>
  382. </template>
  383. </ele-pro-table>
  384. <product-list
  385. ref="productListRef"
  386. :orderId="orderId"
  387. type="purchase"
  388. @changeParent="changeParent"
  389. :productType="productType"
  390. ></product-list>
  391. <product-list-main
  392. ref="productListMainRef"
  393. @changeParent="changeParentMain"
  394. ></product-list-main>
  395. <!--出库详情-->
  396. <outbound-details-dialog
  397. v-if="outboundDetailsDialogFlag"
  398. ref="outboundDetailsDialogRef"
  399. :outboundDetailsDialogFlag.sync="outboundDetailsDialogFlag"
  400. @saveDate="saveDate"
  401. ></outbound-details-dialog>
  402. <taskinstance-dialog
  403. ref="taskinstanceDialogRef"
  404. v-if="taskinstanceDialogFlag"
  405. @saveTaskInstance="saveTaskInstance"
  406. :visible.sync="taskinstanceDialogFlag"
  407. ></taskinstance-dialog>
  408. </el-form>
  409. </template>
  410. <script>
  411. import { numberReg } from 'ele-admin';
  412. import productList from '@/views/saleManage/saleOrder/invoice/components/product-list.vue';
  413. import dictMixins from '@/mixins/dictMixins';
  414. import { getWarehouseList } from '@/api/saleManage/saleorder';
  415. import { copyObj } from '@/utils/util';
  416. import outboundDetailsDialog from './outboundDetailsDialog.vue';
  417. import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
  418. import { lbjtList, orderSourceType, pricingWayList } from '@/enum/dict.js';
  419. import { parameterGetByCode } from '@/api/main/index.js';
  420. import tabMixins from '@/mixins/tableColumnsMixin';
  421. import productListMain from '@/BIZComponents/product-list.vue';
  422. import warehouseAll from '@/BIZComponents/warehouseAll.vue';
  423. import { levelList } from '@/enum/dict.js';
  424. import { changeCount, getAllPrice, formatPrice } from '@/BIZComponents/setProduct.js';
  425. const dayjs = require('dayjs');
  426. export default {
  427. mixins: [dictMixins, tabMixins],
  428. props: {
  429. orderId: String,
  430. outsourceSendCode: String,
  431. pricingWay: [String, Number],
  432. sourceType: [String, Number],
  433. productType: '',
  434. modalType: {
  435. type: String,
  436. default: 'add'
  437. }
  438. },
  439. components: {
  440. productList,
  441. taskinstanceDialog,
  442. productListMain,
  443. warehouseAll
  444. },
  445. data() {
  446. const defaultForm = {
  447. key: null,
  448. endTime: '',
  449. isFirst: 0,
  450. name: '',
  451. startTime: '',
  452. workHour: '',
  453. technicalDrawings: []
  454. // warehouseCode:"",
  455. // warehouseId:'',
  456. // warehouseName:'',
  457. };
  458. return {
  459. discountTotalPrice: 0.0,
  460. selection: [],
  461. allPrice: 0.0,
  462. outboundDetailsDialogFlag: false,
  463. taskinstanceDialogFlag: false,
  464. curIndex: undefined,
  465. numberReg,
  466. defaultForm,
  467. cacheKeyUrl: 'eos-purchaseOrder-invoice-inventoryTable',
  468. warehouseList: [],
  469. form: {
  470. datasource: []
  471. },
  472. oldSendTotalWeightList: [],
  473. outboundInfo: {},
  474. rules: {},
  475. columns: [
  476. {
  477. width: 45,
  478. type: 'index',
  479. columnKey: 'index',
  480. align: 'center',
  481. fixed: 'left'
  482. },
  483. {
  484. label: '选择',
  485. width: 45,
  486. type: 'selection',
  487. columnKey: 'selection',
  488. align: 'center',
  489. fixed: 'left'
  490. },
  491. {
  492. width: 200,
  493. prop: 'productName',
  494. label: '名称',
  495. slot: 'productName',
  496. align: 'center'
  497. },
  498. {
  499. width: 120,
  500. prop: 'productCode',
  501. label: '编码',
  502. slot: 'productCode',
  503. align: 'center'
  504. },
  505. {
  506. width: 200,
  507. prop: 'productCategoryName',
  508. label: '类型',
  509. slot: 'productCategoryName',
  510. align: 'center'
  511. },
  512. {
  513. minWidth: 240,
  514. prop: 'taskName',
  515. label: '工序',
  516. slot: 'taskName',
  517. align: 'center'
  518. },
  519. {
  520. width: 110,
  521. prop: 'batchNo',
  522. label: '批次号',
  523. slot: 'batchNo',
  524. headerSlot: 'isRequired',
  525. align: 'center'
  526. },
  527. {
  528. width: 160,
  529. prop: 'productBrand',
  530. label: '牌号',
  531. slot: 'productBrand',
  532. align: 'center'
  533. },
  534. {
  535. width: 120,
  536. prop: 'modelType',
  537. label: '型号',
  538. slot: 'modelType',
  539. align: 'center'
  540. },
  541. {
  542. width: 160,
  543. prop: 'modelKey',
  544. label: '机型',
  545. slot: 'modelKey',
  546. align: 'center'
  547. },
  548. {
  549. width: 160,
  550. prop: 'colorKey',
  551. label: '颜色',
  552. slot: 'colorKey',
  553. align: 'center'
  554. },
  555. {
  556. width: 120,
  557. prop: 'produceType',
  558. align: 'center',
  559. label: '属性类型',
  560. showOverflowTooltip: true,
  561. formatter: (row, column) => {
  562. if (row.produceType) {
  563. return row.produceType
  564. .map((item) => {
  565. return lbjtList[item];
  566. })
  567. .toString();
  568. }
  569. }
  570. },
  571. // {
  572. // width: 120,
  573. // prop: 'approvalNumber',
  574. // align: 'center',
  575. // label: '批准文号',
  576. // showOverflowTooltip: true
  577. // },
  578. {
  579. width: 120,
  580. prop: 'supplierMark',
  581. label: '供应商代号',
  582. slot: 'supplierMark',
  583. align: 'center'
  584. },
  585. {
  586. width: 160,
  587. prop: 'specification',
  588. label: '规格',
  589. slot: 'specification',
  590. align: 'center'
  591. },
  592. {
  593. width: 200,
  594. prop: 'warehouseId',
  595. label: '仓库名称',
  596. slot: 'warehouseId',
  597. headerSlot: 'headerWarehouseId',
  598. align: 'center'
  599. },
  600. {
  601. width: 250,
  602. prop: 'purchaseCount',
  603. label: '收货数量',
  604. slot: 'purchaseCount',
  605. headerSlot: 'headerTotalCount',
  606. align: 'center'
  607. },
  608. // {
  609. // width: 150,
  610. // prop: 'purchaseUnit',
  611. // label: '单位',
  612. // slot: 'purchaseUnit',
  613. // align: 'center'
  614. // },
  615. {
  616. width: 120,
  617. prop: 'packingSpecification',
  618. align: 'center',
  619. label: '包装规格',
  620. showOverflowTooltip: true
  621. },
  622. {
  623. width: 140,
  624. prop: 'totalCount',
  625. label: '计量数量',
  626. align: 'center',
  627. formatter: (row, column) => {
  628. if (row.totalCount) {
  629. return row.totalCount + ' ' + row.measuringUnit;
  630. }
  631. }
  632. },
  633. {
  634. width: 140,
  635. prop: 'orderTotalCount',
  636. label: '采购总数',
  637. slot: 'orderTotalCount',
  638. align: 'center',
  639. formatter: (row, column) => {
  640. if (row.orderTotalCount) {
  641. return row.orderTotalCount + ' ' + row.measuringUnit;
  642. }
  643. }
  644. },
  645. {
  646. width: 140,
  647. prop: 'receiveTotalCount',
  648. label: '已收货总数',
  649. align: 'center',
  650. formatter: (row, column) => {
  651. if (row.receiveTotalCount) {
  652. return row.receiveTotalCount + ' ' + row.measuringUnit;
  653. }
  654. }
  655. },
  656. // {
  657. // width: 80,
  658. // prop: 'measuringUnit',
  659. // label: '计量单位',
  660. // slot: 'measuringUnit',
  661. // align: 'center'
  662. // },
  663. {
  664. width: 140,
  665. prop: 'singleWeight',
  666. label: '单重',
  667. slot: 'singleWeight',
  668. align: 'center',
  669. formatter: (row, column) => {
  670. if (row.singleWeight) {
  671. return row.singleWeight + ' ' + row.weightUnit;
  672. }
  673. }
  674. },
  675. {
  676. width: 250,
  677. prop: 'sendTotalWeight',
  678. label: '发货总重',
  679. slot: 'sendTotalWeight',
  680. align: 'center',
  681. },
  682. {
  683. width: 170,
  684. prop: 'receiveTotalWeight',
  685. label: '收货总重',
  686. slot: 'receiveTotalWeight',
  687. align: 'center'
  688. },
  689. {
  690. width: 170,
  691. prop: 'increaseTotalWeight',
  692. label: '增重重量',
  693. slot: 'increaseTotalWeight',
  694. align: 'center'
  695. },
  696. {
  697. width: 140,
  698. prop: 'pricingWay',
  699. label: '计价方式',
  700. align: 'center',
  701. fixed: 'left',
  702. formatter: (row, column) => {
  703. return pricingWayList.find((item) => item.id == row.pricingWay)
  704. ?.name;
  705. }
  706. },
  707. {
  708. width: 160,
  709. prop: 'singlePrice',
  710. label: '单价',
  711. slot: 'singlePrice',
  712. align: 'center'
  713. },
  714. {
  715. minWidth: 120,
  716. prop: 'goodsLevel',
  717. label: '物品级别',
  718. formatter: (_row, _column, cellValue) => {
  719. return levelList.find((item) => item.value == _row.goodsLevel)
  720. ?.label;
  721. },
  722. align: 'center'
  723. },
  724. {
  725. width: 120,
  726. prop: 'taxRate',
  727. label: '税率',
  728. formatter: (_row, _column, cellValue) => {
  729. return _row.taxRate ? _row.taxRate + '%' : '';
  730. },
  731. align: 'center'
  732. },
  733. {
  734. width: 180,
  735. prop: 'notaxSinglePrice',
  736. label: '不含税单价',
  737. // slot: 'notaxSinglePrice',
  738. align: 'center'
  739. },
  740. {
  741. width: 160,
  742. prop: 'discountSinglePrice',
  743. label: '折后单价',
  744. slot: 'discountSinglePrice',
  745. align: 'center'
  746. },
  747. {
  748. width: 120,
  749. prop: 'totalPrice',
  750. label: '合计',
  751. slot: 'totalPrice',
  752. align: 'center'
  753. },
  754. {
  755. width: 120,
  756. prop: 'discountTotalPrice',
  757. label: '折后合计',
  758. slot: 'discountTotalPrice',
  759. align: 'center'
  760. },
  761. {
  762. prop: 'provenance',
  763. label: '产地',
  764. slot: 'provenance',
  765. align: 'center',
  766. minWidth: 200,
  767. showOverflowTooltip: true,
  768. formatter: (row, column) => {
  769. return row.provenance && row.provenance.length
  770. ? row.provenance
  771. .map((item) => this.getDictValue('产地', item))
  772. .join(',')
  773. : '';
  774. }
  775. },
  776. {
  777. prop: 'productionDate',
  778. label: '生产日期',
  779. slot: 'productionDate',
  780. align: 'center',
  781. showOverflowTooltip: true,
  782. minWidth: 200
  783. },
  784. {
  785. width: 160,
  786. prop: 'deliveryDeadline',
  787. label: '交期截止日期',
  788. slot: 'deliveryDeadline',
  789. align: 'center'
  790. },
  791. {
  792. width: 250,
  793. prop: 'guaranteePeriod',
  794. label: '有效期',
  795. slot: 'guaranteePeriod',
  796. align: 'center'
  797. // formatter: (_row, _column, cellValue) => {
  798. // let name = '';
  799. // if (_row.guaranteePeriod) {
  800. // name += _row.guaranteePeriod;
  801. // }
  802. // if (_row.guaranteePeriodUnitName) {
  803. // name += _row.guaranteePeriodUnitName;
  804. // }
  805. // return name || '';
  806. // },
  807. // align: 'center'
  808. // },
  809. },
  810. {
  811. width: 160,
  812. prop: 'guaranteePeriodDeadline',
  813. label: '有效期截止日期',
  814. slot: 'guaranteePeriodDeadline',
  815. align: 'center'
  816. },
  817. {
  818. width: 120,
  819. prop: 'isComeCheck',
  820. label: '是否来料检验',
  821. align: 'center',
  822. formatter: (_row, _column, cellValue) => {
  823. return _row.isComeCheck == 1
  824. ? '是'
  825. : _row.isComeCheck === 0
  826. ? '否'
  827. : '';
  828. }
  829. },
  830. {
  831. width: 130,
  832. prop: 'technicalAnswerName',
  833. label: '技术答疑人',
  834. slot: 'technicalAnswerName',
  835. align: 'center'
  836. },
  837. {
  838. width: 220,
  839. prop: 'technicalParams',
  840. label: '技术参数',
  841. slot: 'technicalParams',
  842. align: 'center'
  843. },
  844. {
  845. width: 240,
  846. prop: 'technicalDrawings',
  847. label: '技术图纸',
  848. slot: 'technicalDrawings',
  849. align: 'center'
  850. },
  851. {
  852. width: 220,
  853. prop: 'remark',
  854. label: '备注',
  855. slot: 'remark',
  856. align: 'center'
  857. },
  858. {
  859. columnKey: 'action',
  860. label: '操作',
  861. width: 120,
  862. align: 'center',
  863. resizable: false,
  864. slot: 'action',
  865. fixed: 'right',
  866. showOverflowTooltip: true
  867. }
  868. ],
  869. isTotalCount: 0, //采购收货数量是否限制不能大于采购总数 //0否 1是
  870. isBatchNo: 0,
  871. isWarehouseId: 0
  872. };
  873. },
  874. created() {
  875. this.requestDict('产地');
  876. this.requestDict('生产类型');
  877. getWarehouseList().then((res) => {
  878. this.warehouseList = res;
  879. });
  880. //采购收货数量是否限制不能大于采购总数//0否 1是
  881. parameterGetByCode({
  882. code: 'purchaseOrder_invoice_productList_totalCount'
  883. }).then((res) => {
  884. this.isTotalCount = res.value;
  885. });
  886. //批次号是否必填//0否 1是
  887. parameterGetByCode({
  888. code: 'eom_purchaseOrder_invoice_batchNo'
  889. }).then((res) => {
  890. this.isBatchNo = res.value;
  891. });
  892. //采购收货是否默认选择仓库(0:否 1:是)
  893. parameterGetByCode({
  894. code: 'emo_purchaseOrder_invoice_warehouseId'
  895. }).then((res) => {
  896. this.isWarehouseId = res.value;
  897. });
  898. },
  899. computed: {},
  900. methods: {
  901. async warehouseChange(index, row) {
  902. let data = null;
  903. if (row.warehouseId) {
  904. data = this.warehouseList.find((item) => item.id == row.warehouseId);
  905. } else {
  906. data = this.warehouseList.find(
  907. (item) => item.inventoryType == row.categoryRootLevelId
  908. );
  909. }
  910. if (data) {
  911. this.$set(this.form.datasource[index], 'warehouseName', data.name);
  912. this.$set(this.form.datasource[index], 'warehouseCode', data.code);
  913. this.$set(this.form.datasource[index], 'warehouseId', data.id);
  914. }
  915. },
  916. warehouseAllChange(data) {
  917. console.log(this.selection, 'this.selection');
  918. let keyS = this.selection.map((item) => item.key - 1);
  919. keyS.forEach((key) => {
  920. this.$set(this.form.datasource[key], 'warehouseName', data.name);
  921. this.$set(this.form.datasource[key], 'warehouseCode', data.code);
  922. this.$set(this.form.datasource[key], 'warehouseId', data.id);
  923. });
  924. },
  925. handleTaskinstance(row, index) {
  926. this.taskinstanceDialogFlag = true;
  927. this.$nextTick(() => {
  928. this.$refs.taskinstanceDialogRef.open(row, index);
  929. });
  930. },
  931. saveTaskInstance(row = {}) {
  932. this.$set(this.form.datasource[row.index], 'taskId', row.id);
  933. this.$set(this.form.datasource[row.index], 'taskName', row.name);
  934. this.$set(
  935. this.form.datasource[row.index],
  936. 'routingId',
  937. row.produceRoutingId
  938. );
  939. },
  940. packingChange(item, index) {
  941. this.$set(
  942. this.form.datasource[index],
  943. 'purchaseUnit',
  944. item.conversionUnit
  945. );
  946. },
  947. //出库单详情
  948. handleOutBound(e, rows, index) {
  949. this.curIndex = index;
  950. this.outboundDetailsDialogFlag = true;
  951. this.$nextTick(() => {
  952. let row = {
  953. sendNo: this.outsourceSendCode,
  954. productCode: rows.productCode
  955. };
  956. this.$refs.outboundDetailsDialogRef.init(row);
  957. });
  958. },
  959. //选择退货信息回调
  960. saveDate(data = []) {
  961. let totalWeight = data.reduce((num, row) => {
  962. num += Number(row.weight);
  963. return num;
  964. }, 0);
  965. this.$set(
  966. this.form.datasource[this.curIndex],
  967. 'sendTotalWeight',
  968. totalWeight || 0
  969. );
  970. this.$forceUpdate();
  971. this.$refs.table.reload();
  972. this.setIcreaseTotalWeight(this.curIndex);
  973. },
  974. isDis(row) {
  975. if (row.weightUnit == row.purchaseUnit) {
  976. return true;
  977. }
  978. return false;
  979. },
  980. //改变数量
  981. changeCount(row, index, weightType) {
  982. if (weightType == 'totalWeight') {
  983. this.$set(
  984. this.form.datasource[index],
  985. 'totalWeight',
  986. this.form.datasource[index].receiveTotalWeight
  987. );
  988. }
  989. this.$set(
  990. this.form.datasource,
  991. index,
  992. changeCount(
  993. row,
  994. {
  995. countKey: 'purchaseCount',
  996. unitKey: 'purchaseUnit',
  997. unitIdKey: 'purchaseUnitId'
  998. },
  999. false,
  1000. weightType
  1001. )
  1002. );
  1003. this.$set(
  1004. this.form.datasource[index],
  1005. 'receiveTotalWeight',
  1006. this.form.datasource[index].totalWeight
  1007. );
  1008. this.setIcreaseTotalWeight(index);
  1009. this.getNotaxSinglePrice();
  1010. this.$forceUpdate();
  1011. },
  1012. getNotaxSinglePrice() {
  1013. this.form.datasource.forEach((item, index) => {
  1014. if (item.singlePrice && item.taxRate) {
  1015. this.$set(
  1016. this.form.datasource[index],
  1017. 'notaxSinglePrice',
  1018. formatPrice(
  1019. item.singlePrice / (1 + item.taxRate / 100)
  1020. )
  1021. );
  1022. } else {
  1023. this.$set(this.form.datasource[index], 'notaxSinglePrice', '');
  1024. }
  1025. });
  1026. },
  1027. //设置增重总重
  1028. setIcreaseTotalWeight(index) {
  1029. let pricingWay = this.form.datasource[index].pricingWay;
  1030. let receiveTotalWeight = Number(
  1031. this.form.datasource[index].receiveTotalWeight
  1032. );
  1033. let sendTotalWeight = Number(
  1034. this.form.datasource[index].sendTotalWeight
  1035. );
  1036. this.$set(
  1037. this.form.datasource[index],
  1038. 'increaseTotalWeight',
  1039. (receiveTotalWeight - sendTotalWeight).toFixed(2)
  1040. );
  1041. if (pricingWay == 2) {
  1042. this.$set(
  1043. this.form.datasource[index],
  1044. 'totalPrice',
  1045. (
  1046. receiveTotalWeight * this.form.datasource[index].singlePrice
  1047. ).toFixed(2)
  1048. );
  1049. }
  1050. if (pricingWay == 3) {
  1051. let increaseTotalWeight = Number(
  1052. this.form.datasource[index].increaseTotalWeight
  1053. );
  1054. this.$set(
  1055. this.form.datasource[index],
  1056. 'totalPrice',
  1057. (
  1058. increaseTotalWeight * this.form.datasource[index].singlePrice
  1059. ).toFixed(2)
  1060. );
  1061. }
  1062. this.$refs.table.reload();
  1063. },
  1064. //选择产品回调
  1065. changeParent(obj, idx) {
  1066. if (this.form.datasource?.find((item) => item.id == obj.id)) {
  1067. return this.$message.error('选择的产品已经存在列表了');
  1068. }
  1069. obj.orderTotalCount = obj.orderTotalCount || obj.totalCount;
  1070. obj.id = '';
  1071. this.$set(
  1072. this.form.datasource,
  1073. this.form.datasource.length,
  1074. copyObj(obj)
  1075. );
  1076. },
  1077. changeParentMain(obj) {
  1078. obj.forEach((item, index) => {
  1079. let row = JSON.parse(JSON.stringify(this.defaultForm));
  1080. row.key = this.form.datasource.length + 1;
  1081. let parasm = row;
  1082. this.$set(parasm, 'productId', item.id);
  1083. this.$set(parasm, 'categoryName', item.name);
  1084. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  1085. this.$set(parasm, 'productBrand', item.brandNum);
  1086. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  1087. this.$set(parasm, 'productCode', item.code);
  1088. this.$set(parasm, 'productName', item.name);
  1089. this.$set(parasm, 'modelType', item.modelType);
  1090. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  1091. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  1092. this.$set(parasm, 'specification', item.specification);
  1093. this.$set(parasm, 'weightUnit', item.weightUnit);
  1094. this.$set(parasm, 'imgCode', item.imgCode);
  1095. this.$set(parasm, 'produceType', item.componentAttribute);
  1096. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  1097. this.$set(parasm, 'singleWeight', item.netWeight);
  1098. this.$set(parasm, 'pricingWay', item.pricingWay || 1);
  1099. this.$set(parasm, 'singlePrice', 0);
  1100. this.$set(parasm, 'discountSinglePrice', 0);
  1101. this.$set(parasm, 'sendTotalWeight', 0);
  1102. this.$set(parasm, 'increaseTotalWeight', 0);
  1103. this.$set(parasm, 'goodsLevel', item.goodsLevel);
  1104. if (item.modelKey) {
  1105. this.$set(parasm, 'modelKey', item.modelKey?.split(',')?.[0] || '');
  1106. }
  1107. if (item.colorKey) {
  1108. this.$set(parasm, 'colorKey', item.colorKey?.split(',')?.[0] || '');
  1109. }
  1110. this.$set(
  1111. parasm,
  1112. 'categoryRootLevelId',
  1113. item.categoryLevelPathIdParent
  1114. );
  1115. this.$set(
  1116. parasm,
  1117. 'packingSpecification',
  1118. item.extField?.packingSpecification
  1119. );
  1120. this.$set(
  1121. parasm,
  1122. 'supplierMark',
  1123. this.form.datasource[0]?.supplierMark
  1124. );
  1125. this.$set(
  1126. parasm,
  1127. 'packingSpecification',
  1128. item.extField?.packingSpecification
  1129. );
  1130. this.$set(
  1131. parasm,
  1132. 'packageDispositionList',
  1133. item.packageDispositionList
  1134. );
  1135. if (item.packageDispositionList?.length) {
  1136. this.$set(
  1137. parasm,
  1138. 'purchaseUnitId',
  1139. item.packageDispositionList[0].id
  1140. );
  1141. this.$set(
  1142. parasm,
  1143. 'purchaseUnit',
  1144. item.packageDispositionList[0].conversionUnit
  1145. );
  1146. }
  1147. if (item.purchaseOrigins?.length > 0) {
  1148. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  1149. }
  1150. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1151. this.form.datasource.push(row);
  1152. });
  1153. this.form.datasource.forEach((item, index) => {
  1154. if (!item.warehouseId && this.isWarehouseId == 1) {
  1155. this.warehouseChange(index, item);
  1156. }
  1157. });
  1158. },
  1159. getTotalCount(row) {
  1160. let num = 0;
  1161. this.form.datasource
  1162. .filter((item) => item.productCode == row.productCode)
  1163. .forEach((item) => {
  1164. num += Number(item.totalCount);
  1165. });
  1166. return num;
  1167. },
  1168. // 返回列表数据
  1169. getTableValue() {
  1170. let comitDatasource = this.form.datasource;
  1171. if (comitDatasource.length === 0) return [];
  1172. comitDatasource.forEach(async (v) => {
  1173. if (v.modelKey) {
  1174. v.modelKey = v.modelKey;
  1175. }
  1176. if (v.colorKey) {
  1177. v.colorKey = v.colorKey;
  1178. }
  1179. if (v.guaranteePeriodUnitCode) {
  1180. v.guaranteePeriodUnitName = this.getDictValue(
  1181. '保质期单位',
  1182. v.guaranteePeriodUnitCode
  1183. );
  1184. }
  1185. v.totalCount = Number(v.totalCount);
  1186. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  1187. ? v.technicalDrawings
  1188. : [];
  1189. });
  1190. return comitDatasource;
  1191. },
  1192. getPrice() {
  1193. return [this.allPrice];
  1194. },
  1195. setDeliveryDays(row, index, type) {
  1196. if (type == 'deliveryDays') {
  1197. this.$set(
  1198. this.form.datasource[index],
  1199. 'deliveryDeadline',
  1200. this.setDay(row.deliveryDays)
  1201. );
  1202. }
  1203. if (type == 'guaranteePeriod') {
  1204. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1205. row.guaranteePeriodUnitCode
  1206. );
  1207. this.$set(
  1208. this.form.datasource[index],
  1209. 'guaranteePeriodUnitName',
  1210. guaranteePeriodUnitName
  1211. );
  1212. this.$set(
  1213. this.form.datasource[index],
  1214. 'guaranteePeriodDeadline',
  1215. guaranteePeriodUnitName != 'second'
  1216. ? this.setDay(
  1217. row.guaranteePeriod,
  1218. guaranteePeriodUnitName,
  1219. row.productionDate
  1220. )
  1221. : ''
  1222. );
  1223. }
  1224. },
  1225. guaranteePeriodUnit(code) {
  1226. return code == 3
  1227. ? 'day'
  1228. : code == 4
  1229. ? 'month'
  1230. : code == 5
  1231. ? 'year'
  1232. : 'second';
  1233. },
  1234. setDay(addDay, dateType = 'day', startDate) {
  1235. return dayjs(startDate || new Date())
  1236. .add(addDay, dateType)
  1237. .format('YYYY-MM-DD');
  1238. },
  1239. //修改回显
  1240. async putTableValue(data = [], code) {
  1241. this.$nextTick(() => {
  1242. this.form.datasource = data;
  1243. this.oldSendTotalWeightList = this.form.datasource.map((item) => {
  1244. return {
  1245. productCode: item.productCode,
  1246. oldSendTotalWeight: item.sendTotalWeight
  1247. };
  1248. });
  1249. this.form.datasource.forEach((item, index) => {
  1250. if (item.modelKey) {
  1251. this.$set(
  1252. this.form.datasource[index],
  1253. 'modelKey',
  1254. item.modelKey?.split(',')?.[0] || ''
  1255. );
  1256. }
  1257. if (item.colorKey) {
  1258. this.$set(
  1259. this.form.datasource[index],
  1260. 'colorKey',
  1261. item.colorKey?.split(',')?.[0] || ''
  1262. );
  1263. }
  1264. if (!item.warehouseId && this.isWarehouseId == 1) {
  1265. this.warehouseChange(index, item);
  1266. }
  1267. item.guaranteePeriodUnitCode = item.guaranteePeriodUnitCode
  1268. ? item.guaranteePeriodUnitCode + ''
  1269. : '';
  1270. item.key = index + 1;
  1271. this.init(item, index);
  1272. // this.getTotalPrice(index);
  1273. });
  1274. this.$refs.table.reload();
  1275. this.$forceUpdate();
  1276. });
  1277. },
  1278. init(item, index) {
  1279. this.$set(
  1280. this.form.datasource[index],
  1281. 'receiveTotalWeight',
  1282. item.receiveTotalWeight || item.totalWeight || 0
  1283. );
  1284. if (this.outsourceSendCode) {
  1285. this.$set(
  1286. this.form.datasource[index],
  1287. 'sendTotalWeight',
  1288. item.totalWeight || 0
  1289. );
  1290. this.$set(
  1291. this.form.datasource[index],
  1292. 'increaseTotalWeight',
  1293. Number(this.form.datasource[index].receiveTotalWeight) -
  1294. Number(this.form.datasource[index].sendTotalWeight)
  1295. );
  1296. } else {
  1297. this.$set(this.form.datasource[index], 'sendTotalWeight', 0);
  1298. this.$set(
  1299. this.form.datasource[index],
  1300. 'increaseTotalWeight',
  1301. item.increaseTotalWeight || item.receiveTotalWeight || 0
  1302. );
  1303. }
  1304. },
  1305. remove(i) {
  1306. this.form.datasource.splice(i, 1);
  1307. this.setSort();
  1308. },
  1309. // 清空表格
  1310. restTable() {
  1311. this.form.datasource = [];
  1312. },
  1313. // 重新排序
  1314. setSort() {
  1315. this.form.datasource.forEach((n, index) => {
  1316. n.key = index + 1;
  1317. });
  1318. },
  1319. // 添加
  1320. handlAdd() {
  1321. this.$refs.productListMainRef.open('', -1);
  1322. // if (!this.orderId) return this.$message.error('请先选择订单');
  1323. // if (orderSourceType.includes(this.sourceType)) {
  1324. // this.$refs.productListMainRef.open('', -1);
  1325. // } else {
  1326. // this.$refs.productListRef.open(this.form.datasource);
  1327. // }
  1328. },
  1329. validateForm(callback) {
  1330. //开始表单校验
  1331. this.$refs.form.validate((valid, obj) => {
  1332. let is = false;
  1333. this.form.datasource.forEach((item) => {
  1334. if (
  1335. Number(item.totalCount) + Number(item.receiveTotalCount) >
  1336. item.orderTotalCount
  1337. ) {
  1338. is = true;
  1339. }
  1340. });
  1341. if (is && !orderSourceType.includes(this.sourceType)) {
  1342. this.$message.warning('收货数量大于采购总数量');
  1343. if (this.isTotalCount == 1) {
  1344. callback(false);
  1345. }
  1346. }
  1347. if (obj) {
  1348. let messages = Object.keys(obj).map((key) => obj[key][0]);
  1349. if (messages.length > 0) {
  1350. this.$message.warning(messages[0].message);
  1351. }
  1352. }
  1353. callback(valid);
  1354. });
  1355. }
  1356. }
  1357. };
  1358. </script>
  1359. <style lang="scss" scoped>
  1360. .headbox {
  1361. display: flex;
  1362. // justify-content: space-between;
  1363. align-items: center;
  1364. .amount {
  1365. font-size: 14px;
  1366. font-weight: bold;
  1367. padding-right: 30px;
  1368. }
  1369. }
  1370. .time-form .el-form-item {
  1371. margin-bottom: 0 !important;
  1372. }
  1373. ::v-deep .period {
  1374. display: flex;
  1375. .borderleftnone {
  1376. .el-input--medium .el-input__inner {
  1377. border-top-right-radius: 0;
  1378. border-bottom-right-radius: 0;
  1379. }
  1380. }
  1381. .borderrightnone {
  1382. .el-input--medium .el-input__inner {
  1383. border-top-left-radius: 0;
  1384. border-bottom-left-radius: 0;
  1385. }
  1386. }
  1387. }
  1388. ::v-deep .time-form tbody > tr:hover > td {
  1389. background-color: transparent !important;
  1390. }
  1391. ::v-deep .time-form .el-table tr {
  1392. background-color: #ffffff;
  1393. }
  1394. .pricebox {
  1395. display: flex;
  1396. justify-content: flex-start;
  1397. align-items: center;
  1398. font-weight: bold;
  1399. }
  1400. </style>