inventoryTable.vue 46 KB

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