saleGeneralityInventoryTable.vue 46 KB

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