inventoryTableNew.vue 50 KB

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