inventoryTable.vue 38 KB

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