inventoryTableNew.vue 50 KB

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