inventoryTable.vue 46 KB

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