inventoryTable.vue 42 KB

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