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