replaceTable.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules" :disabled="disabled">
  3. <ele-pro-table
  4. ref="table"
  5. :needPage="false"
  6. :columns="columns"
  7. :toolkit="[]"
  8. :datasource="form.datasource"
  9. cache-key="systemRoleTable17"
  10. class="time-form"
  11. @header-dragend="handleHeaderDragend">
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <!-- <div class="headbox">
  15. <el-button
  16. v-if="isShowAdd"
  17. size="small"
  18. type="primary"
  19. icon="el-icon-plus"
  20. class="ele-btn-icon"
  21. @click="handlAdd"
  22. >
  23. 新增
  24. </el-button>
  25. </div> -->
  26. </template>
  27. <template v-slot:technicalDrawings="{ row, $index }">
  28. <el-form-item :prop="'datasource.' + $index + '.technicalDrawings'">
  29. <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
  30. <!-- <div v-if="row.technicalDrawings && row.technicalDrawings?.length">-->
  31. <!-- <el-link-->
  32. <!-- v-for="link in row.technicalDrawings"-->
  33. <!-- :key="link.id"-->
  34. <!-- type="primary"-->
  35. <!-- :underline="false"-->
  36. <!-- @click="download(link)"-->
  37. <!-- >-->
  38. <!-- {{ link.name }}-->
  39. <!-- </el-link>-->
  40. <!-- </div>-->
  41. </el-form-item>
  42. </template>
  43. <template v-slot:remark="{ row, $index }">
  44. <el-form-item :prop="'datasource.' + $index + '.remark'">
  45. <el-input
  46. clearable
  47. v-model="row.remark"
  48. type="textarea"
  49. placeholder="请输入"
  50. />
  51. </el-form-item>
  52. </template>
  53. <!-- 编码:本行编码 + 所替代的原物品编码,一眼看清替的是哪个物料 -->
  54. <template v-slot:productCode="{ row, $index }">
  55. <div
  56. v-for="(origin, originIndex) in [getOriginInfo(row)]"
  57. :key="(origin && origin.id) || 'code-' + $index + '-' + originIndex"
  58. class="replace-code-cell"
  59. >
  60. <span class="code-text" :title="row.productCode">{{
  61. row.productCode || '-'
  62. }}</span>
  63. <el-tooltip v-if="origin" placement="top" effect="dark">
  64. <div class="replace-origin-code">
  65. <el-tag type="warning" size="mini" effect="dark">替</el-tag>
  66. <span class="origin-code-text">{{
  67. origin.productCode || '-'
  68. }}</span>
  69. </div>
  70. <div slot="content" class="relation-tip">
  71. <div>替原物品名称:{{ origin.productName || '-' }}</div>
  72. <div>替原物品编码:{{ origin.productCode || '-' }}</div>
  73. <div>规格:{{ origin.specification || '-' }}</div>
  74. <div v-if="origin.orderNo">订单编码:{{ origin.orderNo }}</div>
  75. </div>
  76. </el-tooltip>
  77. <span v-else class="relation-empty">未关联</span>
  78. </div>
  79. </template>
  80. <template v-slot:stockLedger="scope">
  81. <el-form-item>
  82. <el-popover
  83. @hide="() => (selection = [])"
  84. placement="right"
  85. width="60%"
  86. trigger="hover"
  87. >
  88. <ele-pro-table
  89. :ref="'childrenTable' + scope.$index"
  90. row-key="id"
  91. max-height="300px"
  92. :selection.sync="selection"
  93. :needPage="false"
  94. :columns="sub1ChildrenColumns"
  95. :toolkit="[]"
  96. :datasource="scope.row.sendProductDetail"
  97. cache-key="stockLedgerRoleTable"
  98. class="time-form"
  99. @header-dragend="onSub1HeaderDragend">
  100. <!-- 表头工具栏 -->
  101. <template v-slot:toolbar="childrenScope">
  102. <div class="headbox">
  103. <el-button
  104. size="small"
  105. type="primary"
  106. icon="el-icon-plus"
  107. class="ele-btn-icon"
  108. @click="stockLedgerSelect(scope.row, scope.$index)"
  109. >
  110. 选择
  111. </el-button>
  112. <el-button
  113. size="small"
  114. type="danger"
  115. icon="el-icon-delete"
  116. class="ele-btn-icon"
  117. :disabled="!selection.length"
  118. @click="stockLedgerRemove(scope.$index)"
  119. >
  120. 删除
  121. </el-button>
  122. </div>
  123. </template>
  124. </ele-pro-table>
  125. <el-button type="text" slot="reference">明细</el-button>
  126. </el-popover>
  127. </el-form-item>
  128. </template>
  129. <template v-slot:packagingStrength="scope">
  130. <el-form-item
  131. :prop="'datasource.' + scope.$index + '.packagingStrength'"
  132. >
  133. <DictSelection
  134. dict-name="包装强度"
  135. v-model="scope.row.extField.packagingStrength"
  136. ></DictSelection>
  137. </el-form-item>
  138. </template>
  139. <template v-slot:packagingDensity="scope">
  140. <el-form-item
  141. :prop="'datasource.' + scope.$index + '.packagingDensity'"
  142. >
  143. <DictSelection
  144. dict-name="包装密度"
  145. v-model="scope.row.extField.packagingDensity"
  146. ></DictSelection>
  147. </el-form-item>
  148. </template>
  149. <template v-slot:totalCount="scope">
  150. <el-form-item
  151. :prop="'datasource.' + scope.$index + '.totalCount'"
  152. :rules="[
  153. { required: true, message: '请输入数字', trigger: 'blur' },
  154. { validator: validateTotalCount(scope.row), trigger: 'blur' }
  155. ]"
  156. >
  157. <el-input
  158. v-model="scope.row.totalCount"
  159. @input="(val) => changeNum(val, scope.$index)"
  160. ></el-input>
  161. </el-form-item>
  162. </template>
  163. <template v-slot:batchNo="scope">
  164. <el-form-item :prop="'datasource.' + scope.$index + '.batchNo'">
  165. <el-input v-model="scope.row.batchNo"></el-input>
  166. </el-form-item>
  167. </template>
  168. <template v-slot:blockCount="scope">
  169. <el-form-item
  170. :prop="'datasource.' + scope.$index + '.blockCount'"
  171. :rules="[{ required: true, message: '请输入', trigger: 'blur' }]"
  172. >
  173. <el-input
  174. v-model="scope.row.blockCount"
  175. @input="
  176. (val) => tableHandleKeyUp(scope.row, scope.$index, 'blockCount')
  177. "
  178. ></el-input>
  179. </el-form-item>
  180. </template>
  181. <template v-slot:receiveTotalWeight="scope">
  182. <el-form-item
  183. :prop="'datasource.' + scope.$index + '.receiveTotalWeight'"
  184. :rules="[
  185. {
  186. required: entrustedCode && pricingWay == 2,
  187. message: '请输入数字',
  188. trigger: 'blur'
  189. }
  190. ]"
  191. >
  192. <!-- :disabled="!entrustedCode" -->
  193. <el-input-number
  194. :controls="false"
  195. v-model="scope.row.receiveTotalWeight"
  196. @blur="changeSendTotalWeight(scope.$index)"
  197. style="width: 60%; margin-right: 10px"
  198. >
  199. </el-input-number>
  200. <el-button
  201. size="small"
  202. type="primary"
  203. v-if="entrustedCode"
  204. @click.native="(e) => handleInnerBound(e, scope.row, scope.$index)"
  205. >选择
  206. </el-button>
  207. </el-form-item>
  208. </template>
  209. <template v-slot:sendTotalWeight="scope">
  210. <el-form-item :prop="'datasource.' + scope.$index + '.sendTotalWeight'">
  211. <el-input-number
  212. :controls="false"
  213. v-model="scope.row.sendTotalWeight"
  214. style="width: 100%"
  215. >
  216. </el-input-number>
  217. </el-form-item>
  218. </template>
  219. <template v-slot:increaseTotalWeight="scope">
  220. <el-form-item
  221. :prop="'datasource.' + scope.$index + '.increaseTotalWeight'"
  222. >
  223. <el-input-number
  224. :controls="false"
  225. v-model="scope.row.increaseTotalWeight"
  226. style="width: 100%"
  227. >
  228. </el-input-number>
  229. </el-form-item>
  230. </template>
  231. <template v-slot:warehouseId="scope">
  232. <el-form-item
  233. :prop="'datasource.' + scope.$index + '.warehouseId'"
  234. :rules="[{ required: true, message: '请选择仓库', trigger: 'blur' }]"
  235. >
  236. <el-select
  237. v-model="scope.row.warehouseId"
  238. placeholder="请选择"
  239. @change="warehouseChange(scope.$index, scope.row)"
  240. >
  241. <el-option
  242. v-for="item in warehouseList"
  243. :key="item.id"
  244. :label="item.name"
  245. :value="item.id"
  246. >
  247. </el-option>
  248. </el-select>
  249. </el-form-item>
  250. </template>
  251. <template v-slot:customerMark="{ row, $index }">
  252. <el-form-item
  253. :prop="'datasource.' + $index + '.customerMark'"
  254. :rules="{
  255. required: false,
  256. message: '请输入客户代号',
  257. trigger: 'change'
  258. }"
  259. >
  260. <el-input v-model="row.customerMark" placeholder="请输入"></el-input>
  261. </el-form-item>
  262. </template>
  263. <template v-slot:guaranteePeriod="scope">
  264. <div class="period">
  265. <div class="borderleftnone">
  266. <el-form-item
  267. style="margin-bottom: 20px"
  268. :prop="'datasource.' + scope.$index + '.guaranteePeriod'"
  269. :rules="{
  270. pattern: numberReg,
  271. message: '请输入数字',
  272. trigger: 'blur'
  273. }"
  274. >
  275. <el-input
  276. v-model="scope.row.guaranteePeriod"
  277. @change="
  278. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  279. "
  280. placeholder="请输入"
  281. ></el-input>
  282. </el-form-item>
  283. </div>
  284. <div class="borderrightnone">
  285. <DictSelection
  286. dictName="质保期单位"
  287. clearable
  288. v-model="scope.row.guaranteePeriodUnitCode"
  289. @change="
  290. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  291. "
  292. >
  293. </DictSelection>
  294. </div>
  295. </div>
  296. </template>
  297. <template v-slot:singleWeight="scope">
  298. <el-form-item
  299. style="margin-bottom: 20px"
  300. :rules="{
  301. required: false,
  302. trigger: ['change', 'blur']
  303. }"
  304. :prop="'datasource.' + scope.$index + '.singleWeight'"
  305. >
  306. <el-input
  307. v-model="scope.row.singleWeight"
  308. @input="singleWeightChange(scope.row, scope.$index)"
  309. placeholder="请输入"
  310. ></el-input>
  311. </el-form-item>
  312. </template>
  313. <template v-slot:singlePrice="scope">
  314. <el-form-item
  315. style="margin-bottom: 20px"
  316. :prop="'datasource.' + scope.$index + '.singlePrice'"
  317. :rules="{
  318. required: false,
  319. pattern: numberReg,
  320. message: '请输入正确的单价',
  321. trigger: 'change'
  322. }"
  323. >
  324. <el-input
  325. v-model="scope.row.singlePrice"
  326. placeholder="请输入"
  327. @input="getNumTotalPrice"
  328. >
  329. <template slot="append">元</template>
  330. </el-input>
  331. </el-form-item>
  332. </template>
  333. <template v-slot:warehouseNum="scope">
  334. <el-form-item>
  335. {{ scope.row.warehouseNum }}
  336. </el-form-item>
  337. </template>
  338. <template v-slot:headerWarehouseId="{ column }">
  339. <span class="is-required">{{ column.label }}</span>
  340. </template>
  341. <template v-slot:headerTotalCount="{ column }">
  342. <span :class="{ 'is-required': entrustedCode && pricingWay == 2 }">{{
  343. column.label
  344. }}</span>
  345. </template>
  346. <!-- 操作列 -->
  347. <template v-slot:action="scope">
  348. <el-popconfirm
  349. class="ele-action"
  350. title="确定要删除吗?"
  351. @confirm="remove(scope.$index)"
  352. >
  353. <template v-slot:reference>
  354. <el-link type="danger" :underline="false" icon="el-icon-delete">
  355. 删除
  356. </el-link>
  357. </template>
  358. </el-popconfirm>
  359. </template>
  360. </ele-pro-table>
  361. <!--入库详情-->
  362. <innertboundDetailsDialog
  363. v-if="innerboundDetailsDialogFlag"
  364. ref="innerboundDetailsDialogRef"
  365. :innerboundDetailsDialogFlag.sync="innerboundDetailsDialogFlag"
  366. @saveDate="saveInnerDate"
  367. ></innertboundDetailsDialog>
  368. </el-form>
  369. </template>
  370. <script>
  371. import { numberReg } from 'ele-admin';
  372. import dictMixins from '@/mixins/dictMixins';
  373. import {
  374. getWarehouseList,
  375. getWarehouseOutStock
  376. } from '@/api/saleManage/saleorder';
  377. import { copyObj } from '@/utils/util';
  378. import innertboundDetailsDialog from '@/BIZComponents/innerboundDetailsDialog.vue';
  379. import stockLedgerDialog from './stockLedger/stockLedgerDialog.vue';
  380. import getDynamicsColumns from '@/mixins/getDynamicsColumns';
  381. // import fileMain from '@/components/addDoc/index.vue';
  382. import { lbjtList } from '@/enum/dict.js';
  383. import tabMixins from '@/mixins/tableColumnsMixin';
  384. export default {
  385. mixins: [dictMixins, getDynamicsColumns, tabMixins],
  386. props: {
  387. orderId: String,
  388. entrustedCode: String,
  389. pricingWay: [String, Number],
  390. isShowAdd: {
  391. type: Boolean,
  392. default: true
  393. },
  394. disabled:{
  395. type: Boolean,
  396. default: false
  397. },
  398. // 原产品列表(只读详情场景直接传数组)
  399. originList: {
  400. type: Array,
  401. default: () => []
  402. },
  403. // 编辑场景下由父组件实时提供物品清单,避免两边数据不同步
  404. getOriginList: {
  405. type: Function,
  406. default: null
  407. },
  408. },
  409. components: {
  410. // fileMain,
  411. innertboundDetailsDialog,
  412. stockLedgerDialog
  413. },
  414. emits: ['relation-change'],
  415. data() {
  416. const defaultForm = {
  417. key: null,
  418. endTime: '',
  419. isFirst: 0,
  420. name: '',
  421. startTime: '',
  422. workHour: '',
  423. technicalDrawings: []
  424. // warehouseCode:"",
  425. // warehouseId:'',
  426. // warehouseName:'',
  427. };
  428. return {
  429. cacheKeyUrl: 'views_saleManage_saleOrder_invoice_components_replaceTable',
  430. current: {},
  431. childrenColumns: [
  432. {
  433. width: 45,
  434. type: 'selection',
  435. columnKey: 'selection',
  436. align: 'center'
  437. },
  438. {
  439. width: 45,
  440. type: 'index',
  441. columnKey: 'index',
  442. align: 'center',
  443. fixed: 'left'
  444. },
  445. {
  446. minWidth: 100,
  447. prop: 'code',
  448. label: '编码',
  449. align: 'center'
  450. },
  451. {
  452. minWidth: 140,
  453. prop: 'barcodes',
  454. label: '发货条码',
  455. align: 'center'
  456. },
  457. {
  458. minWidth: 100,
  459. prop: 'engrave',
  460. label: '刻码',
  461. align: 'center'
  462. }
  463. ],
  464. selection: [],
  465. discountTotalPrice: 0.0,
  466. allPrice: 0.0,
  467. curIndex: null,
  468. innerboundDetailsDialogFlag: false,
  469. stockLedgerDialogFlag: false,
  470. numberReg,
  471. defaultForm,
  472. warehouseList: [],
  473. dynamicsColumns: [],
  474. form: {
  475. datasource: []
  476. },
  477. rules: {}
  478. };
  479. },
  480. created() {
  481. getWarehouseList().then((res) => {
  482. this.warehouseList = res;
  483. });
  484. // 子表列宽缓存,与主表列配置隔离
  485. this.loadScopedColumnWidth('sub1');
  486. },
  487. computed: {
  488. // 子表(childrenColumns)列宽持久化,scope: sub1
  489. sub1ChildrenColumns() {
  490. return this.applyScopedColumnWidth(this.childrenColumns, 'sub1');
  491. },
  492. canHandl() {
  493. return this.form.datasource.length;
  494. },
  495. contractId() {
  496. return this.$store.state.order.contractId;
  497. },
  498. clientEnvironmentId() {
  499. return this.$store.state.user.info.clientEnvironmentId;
  500. },
  501. columns() {
  502. this.columnsVersion; // mixin 触发重算
  503. return this.applyColumnWidth([
  504. {
  505. width: 45,
  506. type: 'index',
  507. columnKey: 'index',
  508. align: 'center',
  509. fixed: 'left'
  510. },
  511. {
  512. width: 200,
  513. prop: 'productName',
  514. label: '名称',
  515. slot: 'productName',
  516. align: 'center'
  517. },
  518. {
  519. width: 190,
  520. prop: 'productCode',
  521. label: '编码',
  522. slot: 'productCode',
  523. align: 'center'
  524. },
  525. {
  526. width: 120,
  527. prop: 'specification',
  528. label: '规格',
  529. slot: 'specification',
  530. align: 'center'
  531. },
  532. {
  533. width: 120,
  534. prop: 'totalCount',
  535. label: '发货数量',
  536. slot: 'totalCount',
  537. headerSlot: 'headerTotalCount',
  538. align: 'center'
  539. },
  540. {
  541. width: 80,
  542. prop: 'measuringUnit',
  543. label: '计量单位',
  544. slot: 'measuringUnit',
  545. align: 'center'
  546. },
  547. {
  548. width: 120,
  549. prop: 'blockCount',
  550. label: '发货块数',
  551. slot: 'blockCount',
  552. align: 'center',
  553. show: this.clientEnvironmentId == '4'
  554. },
  555. {
  556. width: 120,
  557. prop: 'customerMark',
  558. label: '客户代号',
  559. slot: 'customerMark',
  560. align: 'center'
  561. },
  562. {
  563. width: 200,
  564. prop: 'warehouseId',
  565. label: '仓库名称',
  566. slot: 'warehouseId',
  567. headerSlot: 'headerWarehouseId',
  568. align: 'center'
  569. },
  570. {
  571. width: 100,
  572. prop: 'stockLedger',
  573. label: '发货明细',
  574. slot: 'stockLedger',
  575. align: 'center'
  576. },
  577. {
  578. width: 120,
  579. prop: 'singleWeight',
  580. label: '单重',
  581. slot: 'singleWeight',
  582. align: 'center'
  583. },
  584. {
  585. width: 200,
  586. prop: 'receiveTotalWeight',
  587. label: '收货总重',
  588. slot: 'receiveTotalWeight',
  589. align: 'center',
  590. headerSlot: 'headerTotalCount'
  591. },
  592. {
  593. width: 100,
  594. prop: 'sendTotalWeight',
  595. label: '发货总重',
  596. slot: 'sendTotalWeight',
  597. align: 'center'
  598. },
  599. {
  600. width: 100,
  601. prop: 'increaseTotalWeight',
  602. label: '增重重量',
  603. slot: 'increaseTotalWeight',
  604. align: 'center'
  605. },
  606. {
  607. width: 100,
  608. prop: 'weightUnit',
  609. label: '重量单位',
  610. slot: 'weightUnit',
  611. align: 'center'
  612. },
  613. {
  614. width: 160,
  615. prop: 'singlePrice',
  616. label: '单价',
  617. slot: 'singlePrice',
  618. align: 'center'
  619. },
  620. {
  621. width: 160,
  622. prop: 'discountSinglePrice',
  623. label: '折后单价',
  624. slot: 'discountSinglePrice',
  625. align: 'center'
  626. },
  627. {
  628. width: 120,
  629. prop: 'totalPrice',
  630. label: '合计',
  631. slot: 'totalPrice',
  632. align: 'center'
  633. },
  634. {
  635. width: 120,
  636. prop: 'discountTotalPrice',
  637. label: '折后合计',
  638. slot: 'discountTotalPrice',
  639. align: 'center'
  640. },
  641. {
  642. width: 200,
  643. prop: 'productCategoryName',
  644. label: '类型',
  645. slot: 'productCategoryName',
  646. align: 'center'
  647. },
  648. {
  649. width: 160,
  650. prop: 'batchNo',
  651. label: '批次号',
  652. slot: 'batchNo',
  653. align: 'center'
  654. },
  655. {
  656. minWidth: 180,
  657. prop: 'systemBatchNo',
  658. label: '系统内部批次号',
  659. align: 'center',
  660. formatter: (row) => row.systemBatchNo || '-'
  661. },
  662. {
  663. width: 160,
  664. prop: 'productBrand',
  665. label: '牌号',
  666. slot: 'productBrand',
  667. align: 'center'
  668. },
  669. {
  670. width: 120,
  671. prop: 'modelType',
  672. label: '型号',
  673. slot: 'modelType',
  674. align: 'center'
  675. },
  676. {
  677. width: 120,
  678. prop: 'imgCode',
  679. align: 'center',
  680. label: '图号/件号',
  681. showOverflowTooltip: true
  682. },
  683. {
  684. width: 120,
  685. prop: 'produceType',
  686. align: 'center',
  687. label: '属性类型',
  688. showOverflowTooltip: true,
  689. formatter: (row, column) => {
  690. if(row.produceType){
  691. return row.produceType.map(item=>{
  692. return lbjtList[item]
  693. }).toString()
  694. }
  695. }
  696. },
  697. ...this.dynamicsColumns,
  698. {
  699. width: 80,
  700. prop: 'deliveryDays',
  701. label: '交期(天)',
  702. slot: 'deliveryDays',
  703. align: 'center'
  704. },
  705. {
  706. width: 160,
  707. prop: 'deliveryDeadline',
  708. label: '交期截止日期',
  709. slot: 'deliveryDeadline',
  710. align: 'center'
  711. },
  712. {
  713. width: 200,
  714. prop: 'guaranteePeriod',
  715. label: '有效期',
  716. slot: 'guaranteePeriod',
  717. formatter: (_row, _column, cellValue) => {
  718. return (
  719. (_row.guaranteePeriod || '') + _row.guaranteePeriodUnitName
  720. );
  721. },
  722. align: 'center'
  723. },
  724. {
  725. width: 160,
  726. prop: 'guaranteePeriodDeadline',
  727. label: '有效截止日期',
  728. slot: 'guaranteePeriodDeadline',
  729. align: 'center'
  730. },
  731. {
  732. width: 130,
  733. prop: 'technicalAnswerName',
  734. label: '技术答疑人',
  735. slot: 'technicalAnswerName',
  736. align: 'center'
  737. },
  738. {
  739. width: 220,
  740. prop: 'technicalParams',
  741. label: '技术参数',
  742. slot: 'technicalParams',
  743. align: 'center'
  744. },
  745. {
  746. width: 240,
  747. prop: 'technicalDrawings',
  748. label: '技术图纸',
  749. slot: 'technicalDrawings',
  750. align: 'center'
  751. },
  752. {
  753. width: 220,
  754. prop: 'remark',
  755. label: '备注',
  756. slot: 'remark',
  757. align: 'center'
  758. },
  759. {
  760. columnKey: 'action',
  761. label: '操作',
  762. width: 180,
  763. align: 'center',
  764. resizable: false,
  765. slot: 'action',
  766. fixed: 'right',
  767. showOverflowTooltip: true
  768. }
  769. ]);
  770. }
  771. },
  772. methods: {
  773. // 取当前生效的原产品列表:优先实时 getter,其次静态数组
  774. resolveOriginRows() {
  775. if (typeof this.getOriginList === 'function') {
  776. const rows = this.getOriginList();
  777. if (Array.isArray(rows)) {
  778. return rows;
  779. }
  780. }
  781. return Array.isArray(this.originList) ? this.originList : [];
  782. },
  783. // relationId 指向被替代的原产品(新增时是 tempId,回显时是产品 id)
  784. getOriginInfo(row) {
  785. const relationId = row && row.relationId;
  786. if (
  787. relationId === undefined ||
  788. relationId === null ||
  789. relationId === ''
  790. ) {
  791. return null;
  792. }
  793. const key = String(relationId);
  794. return (
  795. this.resolveOriginRows().find((item) => {
  796. if (
  797. item.id !== undefined &&
  798. item.id !== null &&
  799. item.id !== '' &&
  800. String(item.id) === key
  801. ) {
  802. return true;
  803. }
  804. return (
  805. item.tempId !== undefined &&
  806. item.tempId !== null &&
  807. item.tempId !== '' &&
  808. String(item.tempId) === key
  809. );
  810. }) || null
  811. );
  812. },
  813. // 子表表头拖拽列宽持久化(scope: sub1)
  814. onSub1HeaderDragend(newWidth, oldWidth, column) {
  815. this.persistScopedColumnWidth(
  816. 'sub1',
  817. column && (column.property || column.columnKey),
  818. newWidth
  819. );
  820. },
  821. //发货明细选择
  822. stockLedgerSelect(row, index) {
  823. this.curIndex = index;
  824. this.stockLedgerDialogFlag = true;
  825. this.$nextTick(() => {
  826. this.$refs.stockLedgerDialogRef.init(row.sendProductDetail, row);
  827. });
  828. },
  829. //获取
  830. getStockLedger(sendProductDetail) {
  831. if (!this.form.datasource[this.curIndex].sendProductDetail)
  832. this.form.datasource[this.curIndex].sendProductDetail = [];
  833. let row = this.form.datasource[this.curIndex];
  834. row.sendProductDetail.push(...sendProductDetail);
  835. this.form.datasource[this.curIndex] = row;
  836. this.$refs['childrenTable' + this.curIndex].reload();
  837. this.$refs.table.reload();
  838. },
  839. //删除发货明细
  840. stockLedgerRemove(PIndex) {
  841. let row = this.form.datasource[PIndex];
  842. this.selection.forEach((item) => {
  843. let index = row.sendProductDetail.findIndex((i) => i.id == item.id);
  844. row.sendProductDetail.splice(index, 1);
  845. });
  846. this.form.datasource[PIndex] = row;
  847. this.$refs['childrenTable' + PIndex].reload();
  848. this.$refs.table.reload();
  849. this.selection = [];
  850. },
  851. async warehouseChange(index, row) {
  852. let warehouseIds =
  853. this.form.datasource
  854. .filter(
  855. (item, i) => row.productCode == item.productCode && index != i
  856. )
  857. .map((item) => item.warehouseId) || [];
  858. const data = this.warehouseList.find(
  859. (item) => item.id == row.warehouseId
  860. );
  861. if (warehouseIds.length > 0 && warehouseIds.includes(row.warehouseId)) {
  862. row.warehouseId = '';
  863. return this.$message.error('同一个产品不能选择相同的仓库');
  864. }
  865. this.$set(this.form.datasource[index], 'warehouseName', data.name);
  866. this.$set(this.form.datasource[index], 'warehouseCode', data.code);
  867. const warehouseOutStock = await getWarehouseOutStock({
  868. warehouseId: data.id,
  869. code: row.productCode
  870. });
  871. this.$set(
  872. this.form.datasource[index],
  873. 'warehouseNum',
  874. warehouseOutStock
  875. );
  876. },
  877. //修改发货总重
  878. changeSendTotalWeight(index) {
  879. this.curIndex = index;
  880. this.setIcreaseTotalWeight();
  881. },
  882. //入库单详情
  883. handleInnerBound(e, rows, index) {
  884. this.curIndex = index;
  885. this.innerboundDetailsDialogFlag = true;
  886. this.$nextTick(() => {
  887. let row = {
  888. code: this.entrustedCode
  889. };
  890. this.$refs.innerboundDetailsDialogRef.init(row);
  891. });
  892. },
  893. //选择入库单信息
  894. saveInnerDate(data = []) {
  895. let totalWeight = data.reduce((num, row) => {
  896. num += Number(row.weight);
  897. return num;
  898. }, 0);
  899. this.$set(
  900. this.form.datasource[this.curIndex],
  901. 'receiveTotalWeight',
  902. totalWeight
  903. );
  904. this.setIcreaseTotalWeight();
  905. },
  906. //修改数量更新合计/总重
  907. changeNum(val, index,type) {
  908. this.curIndex = index;
  909. if (this.pricingWay == 2) {
  910. if (val != this.form.datasource[index].orderTotalCount) {
  911. this.$set(this.form.datasource[index], 'receiveTotalWeight', '');
  912. this.$set(
  913. this.form.datasource[index],
  914. 'sendTotalWeight',
  915. Number(val) * Number(this.form.datasource[index].singleWeight)
  916. );
  917. } else {
  918. let find =
  919. this.oldReceiveTotalWeight.find(
  920. (key) =>
  921. key.productCode == this.form.datasource[index].productCode
  922. ) || {};
  923. this.$set(
  924. this.form.datasource[index],
  925. 'receiveTotalWeight',
  926. find.oldReceiveTotalWeight || ''
  927. );
  928. this.$set(
  929. this.form.datasource[index],
  930. 'sendTotalWeight',
  931. Number(val) * Number(this.form.datasource[index].singleWeight)
  932. );
  933. }
  934. this.setIcreaseTotalWeight();
  935. this.getWeightPrice();
  936. } else {
  937. if (this.form.datasource[index].singlePrice) {
  938. this.$set(
  939. this.form.datasource[index],
  940. 'totalPrice',
  941. (Number(this.form.datasource[index].singlePrice) * val).toFixed(2)
  942. );
  943. this.$set(
  944. this.form.datasource[index],
  945. 'discountTotalPrice',
  946. (
  947. Number(this.form.datasource[index].discountSinglePrice) * val
  948. ).toFixed(2)
  949. );
  950. }
  951. this.$set(
  952. this.form.datasource[index],
  953. 'sendTotalWeight',
  954. Number(this.form.datasource[index].totalCount) *
  955. Number(this.form.datasource[index].singleWeight)
  956. );
  957. this.$set(
  958. this.form.datasource[index],
  959. 'increaseTotalWeight',
  960. Number(this.form.datasource[index].totalCount) *
  961. Number(this.form.datasource[index].singleWeight)
  962. );
  963. }
  964. if(!type){
  965. this.tableHandleKeyUp(this.form.datasource[index], index, 'sum');
  966. }
  967. },
  968. //计算单重
  969. singleWeightChange(row, index) {
  970. if (row && row.singleWeight && row.totalCount) {
  971. row.totalWeight = (row.singleWeight * row.totalCount).toFixed(2) || 0;
  972. this.$set(
  973. this.form.datasource[index],
  974. 'totalWeight',
  975. row.totalWeight
  976. );
  977. } else {
  978. this.$set(this.form.datasource[index], 'totalWeight', '');
  979. }
  980. },
  981. getWeightPrice() {
  982. let increaseTotalWeight =
  983. this.form.datasource[this.curIndex].increaseTotalWeight;
  984. let singlePrice = this.form.datasource[this.curIndex].singlePrice;
  985. let discountSinglePrice =
  986. this.form.datasource[this.curIndex].discountSinglePrice;
  987. this.$set(
  988. this.form.datasource[this.curIndex],
  989. 'totalPrice',
  990. (Number(increaseTotalWeight) * Number(singlePrice)).toFixed(2)
  991. );
  992. this.$set(
  993. this.form.datasource[this.curIndex],
  994. 'discountTotalPrice',
  995. (Number(discountSinglePrice) * Number(increaseTotalWeight)).toFixed(2)
  996. );
  997. },
  998. //设置增重总重
  999. setIcreaseTotalWeight() {
  1000. let receiveTotalWeight = Number(
  1001. this.form.datasource[this.curIndex].receiveTotalWeight
  1002. );
  1003. let sendTotalWeight = Number(
  1004. this.form.datasource[this.curIndex].sendTotalWeight
  1005. );
  1006. this.$set(
  1007. this.form.datasource[this.curIndex],
  1008. 'increaseTotalWeight',
  1009. (sendTotalWeight - receiveTotalWeight).toFixed(2)
  1010. );
  1011. if (this.pricingWay == 2) {
  1012. this.getWeightPrice();
  1013. }
  1014. this.$refs.table.reload();
  1015. },
  1016. // 表格:模数、数量(方)、块数输入框 输入事件
  1017. tableHandleKeyUp(row, index, name) {
  1018. console.log(row, 'row');
  1019. // && this.clientEnvironmentId == '4'
  1020. if (row.specification && this.clientEnvironmentId == '4') {
  1021. let modelArr = row.specification.split('*');
  1022. let modelLong = modelArr[0]; // model规格长度
  1023. let modeWide = modelArr[1]; // model规格宽度
  1024. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1025. modeHight = Number(modeHight);
  1026. if (name === 'sum') {
  1027. row.blockCount = Math.floor(
  1028. row.totalCount / ((modelLong * modeWide * modeHight) / 1000000)
  1029. );
  1030. } else if (name === 'blockCount') {
  1031. row.totalCount =
  1032. (Number(row.blockCount) * modelLong * modeWide * modeHight) /
  1033. 1000000;
  1034. this.changeNum(row.totalCount, index,true);
  1035. }
  1036. }
  1037. },
  1038. //改变数量
  1039. changeCount(row, index, type) {
  1040. this.getNumTotalPrice();
  1041. if (type != 'tableHandleKeyUp') {
  1042. this.tableHandleKeyUp(this.form.datasource[index], index, 'sum');
  1043. }
  1044. },
  1045. //计算总金额
  1046. getNumTotalPrice(sum = 0) {
  1047. this.form.datasource.forEach((r, index) => {
  1048. this.$set(
  1049. r,
  1050. 'discountSinglePrice',
  1051. r.singlePrice ? Number(r.singlePrice) : ''
  1052. );
  1053. if (r.singlePrice && r.totalCount) {
  1054. console.log(r, 'r.totalPrice');
  1055. r.totalPrice = this.getAllPrice(r);
  1056. r.discountTotalPrice = this.getDiscountTotalPrice(r);
  1057. this.$set(
  1058. this.form.datasource[index],
  1059. 'totalPrice',
  1060. Number(r.totalPrice)
  1061. );
  1062. this.$set(
  1063. this.form.datasource[index],
  1064. 'discountTotalPrice',
  1065. Number(r.discountTotalPrice)
  1066. );
  1067. sum += Number(r.totalPrice);
  1068. } else {
  1069. this.$set(r, 'totalPrice', '');
  1070. this.$set(r, 'discountTotalPrice', '');
  1071. }
  1072. });
  1073. return isNaN(sum) ? 0 : sum;
  1074. },
  1075. //设置优惠后总金额修改产品单价
  1076. discountInputByOrder(val) {
  1077. this.form.discountTotalPrice = val;
  1078. //获取优惠金额和总计的差价
  1079. this.form.datasource.forEach((item) => {
  1080. if (val === 0) {
  1081. item.discountTotalPrice = 0;
  1082. item.discountSinglePrice = 0;
  1083. return;
  1084. }
  1085. if (!val) {
  1086. item.discountTotalPrice = item.totalPrice;
  1087. item.discountSinglePrice = item.singlePrice;
  1088. return;
  1089. }
  1090. //获取折让单价
  1091. item.discountSinglePrice = this.getDiscountSinglePrice(item);
  1092. item.discountTotalPrice = this.getDiscountTotalPrice(item);
  1093. });
  1094. this.$refs.table.reload();
  1095. },
  1096. //获取折让单价
  1097. getDiscountSinglePrice(row) {
  1098. let num =
  1099. (Number(this.form.discountTotalPrice) / Number(this.allPrice)) *
  1100. Number(row.singlePrice);
  1101. return isNaN(num) ? '' : num;
  1102. },
  1103. //获取合计
  1104. getAllPrice(row) {
  1105. let num = 0;
  1106. switch (this.pricingWay) {
  1107. case 1: //按数量计价计算总金额
  1108. num = Number(row.singlePrice) * Number(row.totalCount);
  1109. break;
  1110. case 2: //按重量计价计算总金额
  1111. num =
  1112. Number(row.singlePrice) *
  1113. Number(row.totalCount) *
  1114. Number(row.singleWeight);
  1115. break;
  1116. }
  1117. return isNaN(num) ? '' : num.toFixed(2);
  1118. },
  1119. //获取折让合计
  1120. getDiscountTotalPrice(row) {
  1121. let num = 0;
  1122. switch (this.pricingWay) {
  1123. case 1: //按数量计价计算折让合计
  1124. num = Number(row.discountSinglePrice) * Number(row.totalCount);
  1125. break;
  1126. case 2: //按重量计价计算折让合计
  1127. num =
  1128. Number(row.discountSinglePrice) *
  1129. Number(row.totalCount) *
  1130. Number(row.singleWeight);
  1131. break;
  1132. }
  1133. return isNaN(num) ? '' : num.toFixed(2);
  1134. },
  1135. validateTotalCount(row) {
  1136. return (rule, value, callback) => {
  1137. if (isNaN(value) || Number(value) <= 0) {
  1138. this.$message.error('请输入大于0的数');
  1139. callback(new Error('请输入大于0的数字'));
  1140. } else if (Number(value) > row.warehouseNum) {
  1141. // this.$message.error('输入的数字不能大于仓库物品数');
  1142. // callback(new Error('输入的数字不能大于仓库物品数'));
  1143. callback();
  1144. } else if (Number(value) > row.orderTotalCount) {
  1145. this.$message.error('输入的数字不能大于最大发货值');
  1146. callback(new Error('输入的数字不能大于最大发货值'));
  1147. } else {
  1148. callback();
  1149. }
  1150. };
  1151. },
  1152. // 返回列表数据
  1153. getTableValue() {
  1154. let comitDatasource = this.form.datasource;
  1155. if (comitDatasource.length === 0) return [];
  1156. comitDatasource.forEach(async (v) => {
  1157. v.totalCount = Number(v.totalCount);
  1158. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  1159. ? v.technicalDrawings
  1160. : [];
  1161. v.customerReqFiles = Array.isArray(v.customerReqFiles)
  1162. ? v.customerReqFiles
  1163. : [];
  1164. v.industryArtFiles = v.industryArtFiles || [];
  1165. v.otherFiles = v.otherFiles || [];
  1166. });
  1167. return comitDatasource;
  1168. },
  1169. getPrice() {
  1170. return [this.allPrice];
  1171. },
  1172. //修改回显
  1173. putTableValue(data, type) {
  1174. if (data) {
  1175. if (type == 'add') {
  1176. data.forEach((item) => {
  1177. // 库存台账带入的仓库可能不在仓库下拉列表中,找不到时保留原值,避免中断添加流程
  1178. const warehouse = this.warehouseList.find(
  1179. (val) => val.id == item.warehouseId
  1180. );
  1181. if (warehouse) {
  1182. item['warehouseId'] = warehouse.id;
  1183. item['warehouseName'] = warehouse.name;
  1184. item['warehouseCode'] = warehouse.code;
  1185. }
  1186. item.totalPrice = 0;
  1187. item.singlePrice = 0;
  1188. item.discountSinglePrice = 0;
  1189. item.discountTotalPrice = 0;
  1190. });
  1191. }
  1192. const appendStart = this.form.datasource.length;
  1193. this.form.datasource = [...this.form.datasource,...data];
  1194. const startIndex = this.form.datasource.length - data.length;
  1195. data.forEach(async (item, i) => {
  1196. const index = startIndex + i;
  1197. if (item.warehouseId) {
  1198. this.$set(
  1199. this.form.datasource[appendStart + index],
  1200. 'warehouseNum',
  1201. await getWarehouseOutStock({
  1202. warehouseId: item.warehouseId,
  1203. code: item.productCode
  1204. })
  1205. );
  1206. }
  1207. //保存初始收货总重
  1208. this.oldReceiveTotalWeight = this.form.datasource.map((item) => {
  1209. return {
  1210. productCode: item.productCode,
  1211. oldReceiveTotalWeight: item.receiveTotalWeight
  1212. };
  1213. });
  1214. this.form.datasource.forEach((item, index) => {
  1215. item.sendTotalWeight =
  1216. item.sendTotalWeight ||
  1217. Number(item.totalCount) * Number(item.singleWeight) ||
  1218. 0;
  1219. if (this.outsourceSendCode) {
  1220. item.increaseTotalWeight =
  1221. Number(item.receiveTotalWeight) -
  1222. Number(item.sendTotalWeight);
  1223. } else {
  1224. item.increaseTotalWeight =
  1225. item.increaseTotalWeight || item.receiveTotalWeight || 0;
  1226. }
  1227. this.changeNum(item.totalCount, index);
  1228. });
  1229. });
  1230. }
  1231. this.$emit('relation-change');
  1232. },
  1233. remove(i) {
  1234. this.form.datasource.splice(i, 1);
  1235. this.setSort();
  1236. this.$emit('relation-change');
  1237. },
  1238. // 清空表格
  1239. restTable() {
  1240. this.form.datasource = [];
  1241. this.$emit('relation-change');
  1242. },
  1243. // 重新排序
  1244. setSort() {
  1245. this.form.datasource.forEach((n, index) => {
  1246. n.key = index + 1;
  1247. });
  1248. },
  1249. validateForm(callback) {
  1250. //开始表单校验
  1251. this.$refs.form.validate((valid) => {
  1252. callback(valid);
  1253. });
  1254. }
  1255. }
  1256. };
  1257. </script>
  1258. <style lang="scss" scoped>
  1259. .headbox {
  1260. display: flex;
  1261. justify-content: flex-start;
  1262. align-items: center;
  1263. .amount {
  1264. font-size: 14px;
  1265. font-weight: bold;
  1266. padding-right: 30px;
  1267. }
  1268. }
  1269. .time-form .el-form-item {
  1270. margin-bottom: 0 !important;
  1271. }
  1272. ::v-deep .period {
  1273. display: flex;
  1274. .borderleftnone {
  1275. .el-input--medium .el-input__inner {
  1276. border-top-right-radius: 0;
  1277. border-bottom-right-radius: 0;
  1278. }
  1279. }
  1280. .borderrightnone {
  1281. .el-input--medium .el-input__inner {
  1282. border-top-left-radius: 0;
  1283. border-bottom-left-radius: 0;
  1284. }
  1285. }
  1286. }
  1287. ::v-deep .time-form tbody > tr:hover > td {
  1288. background-color: transparent !important;
  1289. }
  1290. ::v-deep .time-form .el-table tr {
  1291. background-color: #ffffff;
  1292. }
  1293. .pricebox {
  1294. display: flex;
  1295. justify-content: flex-start;
  1296. align-items: center;
  1297. font-weight: bold;
  1298. }
  1299. .replace-code-cell {
  1300. display: flex;
  1301. flex-direction: column;
  1302. align-items: center;
  1303. line-height: 1.5;
  1304. }
  1305. .code-text {
  1306. max-width: 100%;
  1307. overflow: hidden;
  1308. text-overflow: ellipsis;
  1309. white-space: nowrap;
  1310. }
  1311. .replace-origin-code {
  1312. display: flex;
  1313. align-items: center;
  1314. justify-content: center;
  1315. max-width: 100%;
  1316. margin-top: 2px;
  1317. }
  1318. .origin-code-text {
  1319. margin-left: 4px;
  1320. color: #e6a23c;
  1321. overflow: hidden;
  1322. text-overflow: ellipsis;
  1323. white-space: nowrap;
  1324. }
  1325. .relation-empty {
  1326. margin-top: 2px;
  1327. font-size: 12px;
  1328. color: #c0c4cc;
  1329. }
  1330. </style>