inventoryTable.vue 52 KB

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