inventoryTable.vue 46 KB

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