saleGeneralityInventoryTable.vue 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <ele-pro-table
  4. ref="table"
  5. :needPage="false"
  6. :columns="columns"
  7. :datasource="form.datasource"
  8. :toolkit="[]"
  9. class="time-form"
  10. >
  11. <!-- 表头工具栏 -->
  12. <template v-slot:toolbar>
  13. <div class="headbox">
  14. <div>
  15. <!-- <el-button-->
  16. <!-- size="small"-->
  17. <!-- type="primary"-->
  18. <!-- icon="el-icon-plus"-->
  19. <!-- class="ele-btn-icon"-->
  20. <!-- @click="handlAdd"-->
  21. <!-- v-if="!isContractId"-->
  22. <!-- >-->
  23. <!-- 新增-->
  24. <!-- </el-button>-->
  25. <el-button
  26. size="small"
  27. type="primary"
  28. icon="el-icon-plus"
  29. class="ele-btn-icon"
  30. @click="handParent('', -1)"
  31. v-if="!isContractId"
  32. >
  33. 新增
  34. </el-button>
  35. <el-button
  36. size="small"
  37. type="primary"
  38. icon="el-icon-plus"
  39. class="ele-btn-icon"
  40. v-if="!isContractId"
  41. @click="handlAdd">
  42. 新增临时产品
  43. </el-button>
  44. </div>
  45. <div class="pricebox">
  46. <span class="amount">总计:{{ allPrice }}元</span>
  47. <span v-if="isDiscountTotalPrice"></span>
  48. <el-form-item
  49. style="width: 300px"
  50. v-if="isDiscountTotalPrice"
  51. label="优惠后总金额:"
  52. prop="discountTotalPrice"
  53. :rules="{
  54. required: true,
  55. message: '请输入优惠后总金额',
  56. trigger: 'change'
  57. }"
  58. >
  59. <el-input
  60. type="number"
  61. :min="0"
  62. :max="allPrice"
  63. :disabled="!allPrice"
  64. v-model="form.discountTotalPrice"
  65. style="width: 180px"
  66. placeholder="请输入"
  67. @input="discountInput"
  68. @blur="discountInputByOrder(form.discountTotalPrice)"
  69. >
  70. <template slot="append">元</template>
  71. </el-input>
  72. </el-form-item>
  73. </div>
  74. </div>
  75. </template>
  76. <template v-slot:productName="{ row, $index }">
  77. <el-form-item
  78. style="margin-bottom: 20px"
  79. :prop="'datasource.' + $index + '.productName'"
  80. :rules="{
  81. required: true,
  82. message: '请输入',
  83. trigger: 'change'
  84. }"
  85. >
  86. <el-input
  87. :disabled="isContractId||row.productCode"
  88. v-model="row.productName"
  89. placeholder="请输入"
  90. style="width: 60%;margin-right: 10px;"
  91. ></el-input>
  92. <el-button
  93. size="small"
  94. type="primary"
  95. @click.native="handParent(row, $index)"
  96. >选择
  97. </el-button>
  98. </el-form-item>
  99. </template>
  100. <template v-slot:headerCustomerMark="{ column }">
  101. <span >{{ column.label }}</span>
  102. </template>
  103. <template v-slot:customerMark="{ row, $index }">
  104. <el-form-item
  105. :prop="'datasource.' + $index + '.customerMark'"
  106. >
  107. <el-input v-model="row.customerMark" placeholder="请输入"></el-input>
  108. </el-form-item>
  109. </template>
  110. <template v-slot:headerProductName="{ column }">
  111. <span class="is-required">{{ column.label }}</span>
  112. </template>
  113. <template v-slot:productCode="scope">
  114. <el-form-item
  115. style="margin-bottom: 20px"
  116. :prop="'datasource.' + scope.$index + '.productCode'"
  117. >
  118. <el-input
  119. :disabled="isContractId"
  120. v-model="scope.row.productCode"
  121. disabled
  122. ></el-input>
  123. </el-form-item>
  124. </template>
  125. <template v-slot:productCategoryName="scope">
  126. <el-form-item
  127. style="margin-bottom: 20px"
  128. :prop="'datasource.' + scope.$index + '.productCategoryName'"
  129. >
  130. <el-input v-model="scope.row.productCategoryName" disabled></el-input>
  131. </el-form-item>
  132. </template>
  133. <template v-slot:totalCount="scope">
  134. <el-form-item
  135. style="margin-bottom: 20px"
  136. :prop="'datasource.' + scope.$index + '.totalCount'"
  137. :rules="{
  138. required: pageName == 'businessOpportunity' ? false : true,
  139. pattern: numberReg,
  140. message: '请输入数量',
  141. trigger: 'blur'
  142. }"
  143. >
  144. <el-input
  145. :disabled="isContractId"
  146. v-model="scope.row.totalCount"
  147. placeholder="请输入"
  148. @input="changeCount(scope.row, scope.$index)"
  149. ></el-input>
  150. </el-form-item>
  151. </template>
  152. <template
  153. v-slot:headerTotalCount="{ column }"
  154. v-if="pageName != 'businessOpportunity'"
  155. >
  156. <span class="is-required">{{ column.label }}</span>
  157. </template>
  158. <template
  159. v-slot:headerSingleWeight="{ column }"
  160. v-if="pageName != 'businessOpportunity'"
  161. >
  162. <span :class="{ 'is-required': pricingWay == 2 }" class="is-required">{{
  163. column.label
  164. }}</span>
  165. </template>
  166. <template v-slot:totalPrice="scope">
  167. <el-form-item
  168. style="margin-bottom: 20px"
  169. :prop="'datasource.' + scope.$index + '.totalPrice'"
  170. >
  171. {{ (Number(scope.row.totalPrice) || 0).toFixed(2) }}元
  172. </el-form-item>
  173. </template>
  174. <template v-slot:productBrand="scope">
  175. <el-form-item
  176. style="margin-bottom: 20px"
  177. :prop="'datasource.' + scope.$index + '.productBrand'"
  178. >
  179. <el-input v-model="scope.row.productBrand"
  180. :disabled="scope.row.productCode"
  181. ></el-input>
  182. </el-form-item>
  183. </template>
  184. <template v-slot:modelType="scope">
  185. <el-form-item
  186. style="margin-bottom: 20px"
  187. :prop="'datasource.' + scope.$index + '.modelType'"
  188. >
  189. <el-input v-model="scope.row.modelType"
  190. :disabled="scope.row.productCode"
  191. ></el-input>
  192. </el-form-item>
  193. </template>
  194. <template v-slot:specification="scope">
  195. <el-form-item
  196. style="margin-bottom: 20px"
  197. :prop="'datasource.' + scope.$index + '.specification'"
  198. >
  199. <el-input v-model="scope.row.specification"
  200. :disabled="scope.row.productCode"
  201. ></el-input>
  202. </el-form-item>
  203. </template>
  204. <template v-slot:deliveryDays="scope">
  205. <el-form-item
  206. style="margin-bottom: 20px"
  207. :prop="'datasource.' + scope.$index + '.deliveryDays'"
  208. :rules="{
  209. pattern: numberReg,
  210. message: '请输入数字',
  211. trigger: 'blur'
  212. }"
  213. >
  214. <el-input
  215. :disabled="isContractId"
  216. v-model="scope.row.deliveryDays"
  217. @change="setDeliveryDays(scope.row, scope.$index, 'deliveryDays')"
  218. placeholder="请输入"
  219. ></el-input>
  220. </el-form-item>
  221. </template>
  222. <template v-slot:guaranteePeriod="scope">
  223. <div class="period">
  224. <div class="borderleftnone">
  225. <el-form-item
  226. style="margin-bottom: 20px"
  227. :prop="'datasource.' + scope.$index + '.guaranteePeriod'"
  228. :rules="{
  229. pattern: numberReg,
  230. message: '请输入数字',
  231. trigger: 'blur'
  232. }"
  233. >
  234. <el-input
  235. :disabled="isContractId"
  236. v-model="scope.row.guaranteePeriod"
  237. @change="
  238. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  239. "
  240. placeholder="请输入"
  241. ></el-input>
  242. </el-form-item>
  243. </div>
  244. <div class="borderrightnone">
  245. <DictSelection
  246. dictName="质保期单位"
  247. clearable
  248. v-model="scope.row.guaranteePeriodUnitCode"
  249. :disabled="isContractId"
  250. @change="
  251. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  252. "
  253. >
  254. </DictSelection>
  255. </div>
  256. </div>
  257. </template>
  258. <!-- <template v-slot:guaranteePeriodUnitCode="scope"> </template> -->
  259. <template v-slot:measuringUnit="scope">
  260. <el-form-item
  261. style="margin-bottom: 20px"
  262. :prop="'datasource.' + scope.$index + '.measuringUnit'"
  263. >
  264. <el-input
  265. v-model="scope.row.measuringUnit"
  266. :disabled="scope.row.productCode"
  267. placeholder="请输入"
  268. ></el-input>
  269. </el-form-item>
  270. </template>
  271. <template v-slot:remark="scope">
  272. <el-form-item
  273. style="margin-bottom: 20px"
  274. :prop="'datasource.' + scope.$index + '.remark'"
  275. >
  276. <el-input
  277. :disabled="isContractId"
  278. v-model="scope.row.remark"
  279. type="textarea"
  280. placeholder="请输入"
  281. ></el-input>
  282. </el-form-item>
  283. </template>
  284. <template v-slot:singlePrice="scope">
  285. <el-form-item
  286. style="margin-bottom: 20px"
  287. :prop="'datasource.' + scope.$index + '.singlePrice'"
  288. :rules="{
  289. required: pageName == 'businessOpportunity' ? false : true,
  290. pattern: numberReg,
  291. message: '请输入正确的单价',
  292. trigger: 'change'
  293. }"
  294. >
  295. <el-input
  296. :disabled="isContractId"
  297. v-model="scope.row.singlePrice"
  298. placeholder="请输入"
  299. @input="getTotalPrice"
  300. >
  301. <template slot="append">元</template>
  302. </el-input>
  303. </el-form-item>
  304. </template>
  305. <template
  306. v-slot:headerSinglePrice="{ column }"
  307. v-if="pageName != 'businessOpportunity'"
  308. >
  309. <span class="is-required">{{ column.label }}</span>
  310. </template>
  311. <template v-slot:headerCustomerExpectDeliveryDeadline="{ column }">
  312. <span class="is-required">{{ column.label }}</span>
  313. </template>
  314. <template v-slot:technicalAnswerName="{ row, $index }">
  315. <el-form-item
  316. style="margin-bottom: 20px"
  317. :prop="'datasource.' + $index + '.technicalAnswerName'"
  318. >
  319. <el-input
  320. v-model="row.technicalAnswerName"
  321. placeholder="请输入"
  322. :disabled="isContractId"
  323. @click.native="handHead(row, $index)"
  324. ></el-input>
  325. </el-form-item>
  326. </template>
  327. <template v-slot:technicalParams="scope">
  328. <el-form-item
  329. style="margin-bottom: 20px"
  330. :prop="'datasource.' + scope.$index + '.technicalParams'"
  331. >
  332. <el-input
  333. type="textarea"
  334. v-model="scope.row.technicalParams"
  335. :disabled="isContractId"
  336. placeholder="请输入"
  337. ></el-input>
  338. </el-form-item>
  339. </template>
  340. <template v-slot:technicalDrawings="scope">
  341. <el-form-item
  342. style="margin-bottom: 20px"
  343. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  344. >
  345. <fileMain
  346. v-model="scope.row.technicalDrawings"
  347. :type="isContractId ? 'view' : ''"
  348. ></fileMain>
  349. <!-- <fileUpload-->
  350. <!-- v-if="!isContractId"-->
  351. <!-- v-model="scope.row.technicalDrawings"-->
  352. <!-- :disabled="isContractId"-->
  353. <!-- module="main"-->
  354. <!-- :showLib="false"-->
  355. <!-- :limit="5"-->
  356. <!-- />-->
  357. <!-- <div-->
  358. <!-- v-else-if="-->
  359. <!-- scope.row.technicalDrawings && scope.row.technicalDrawings?.length-->
  360. <!-- "-->
  361. <!-- >-->
  362. <!-- <el-link-->
  363. <!-- v-for="link in scope.row.technicalDrawings"-->
  364. <!-- :key="link.id"-->
  365. <!-- type="primary"-->
  366. <!-- :underline="false"-->
  367. <!-- @click="downloadFile(link)"-->
  368. <!-- >-->
  369. <!-- {{ link.name }}-->
  370. <!-- </el-link>-->
  371. <!-- </div>-->
  372. </el-form-item>
  373. </template>
  374. <template v-slot:customerReqFiles="scope">
  375. <el-form-item
  376. style="margin-bottom: 20px"
  377. :prop="'datasource.' + scope.$index + '.customerReqFiles'"
  378. >
  379. <fileMain
  380. v-model="scope.row.customerReqFiles"
  381. :type="isContractId ? 'view' : ''"
  382. ></fileMain>
  383. <!-- <fileUpload-->
  384. <!-- v-model="scope.row.customerReqFiles"-->
  385. <!-- v-if="!isContractId"-->
  386. <!-- module="main"-->
  387. <!-- :showLib="false"-->
  388. <!-- :limit="5"-->
  389. <!-- />-->
  390. <!-- <div-->
  391. <!-- v-else-if="-->
  392. <!-- scope.row.customerReqFiles && scope.row.customerReqFiles?.length-->
  393. <!-- "-->
  394. <!-- >-->
  395. <!-- <el-link-->
  396. <!-- v-for="link in scope.row.customerReqFiles"-->
  397. <!-- :key="link.id"-->
  398. <!-- type="primary"-->
  399. <!-- :underline="false"-->
  400. <!-- @click="downloadFile(link)"-->
  401. <!-- >-->
  402. <!-- {{ link.name }}-->
  403. <!-- </el-link>-->
  404. <!-- </div>-->
  405. </el-form-item>
  406. </template>
  407. <template v-slot:industryArtFiles="scope">
  408. <el-form-item
  409. style="margin-bottom: 20px"
  410. :prop="'datasource.' + scope.$index + '.industryArtFiles'"
  411. :rules="{
  412. required: false,
  413. message: '请输入',
  414. trigger: 'change'
  415. }"
  416. >
  417. <fileMain
  418. v-model="scope.row.industryArtFiles"
  419. :type="isContractId ? 'view' : ''"
  420. ></fileMain>
  421. <!-- <fileUpload-->
  422. <!-- v-model="scope.row.industryArtFiles"-->
  423. <!-- module="main"-->
  424. <!-- v-if="!isContractId"-->
  425. <!-- :showLib="false"-->
  426. <!-- :limit="5"-->
  427. <!-- />-->
  428. <!-- <div-->
  429. <!-- v-else-if="-->
  430. <!-- scope.row.industryArtFiles && scope.row.industryArtFiles?.length-->
  431. <!-- "-->
  432. <!-- >-->
  433. <!-- <el-link-->
  434. <!-- v-for="link in scope.row.industryArtFiles"-->
  435. <!-- :key="link.id"-->
  436. <!-- type="primary"-->
  437. <!-- :underline="false"-->
  438. <!-- @click="downloadFile(link)"-->
  439. <!-- >-->
  440. <!-- {{ link.name }}-->
  441. <!-- </el-link>-->
  442. <!-- </div>-->
  443. </el-form-item>
  444. </template>
  445. <template v-slot:otherFiles="scope">
  446. <el-form-item
  447. style="margin-bottom: 20px"
  448. :prop="'datasource.' + scope.$index + '. otherFiles'"
  449. >
  450. <fileMain
  451. v-model="scope.row.otherFiles"
  452. :type="isContractId ? 'view' : ''"
  453. ></fileMain>
  454. <!-- <fileUpload-->
  455. <!-- v-model="scope.row.otherFiles"-->
  456. <!-- module="main"-->
  457. <!-- v-if="!isContractId"-->
  458. <!-- :showLib="false"-->
  459. <!-- :limit="5"-->
  460. <!-- />-->
  461. <!-- <div v-else-if="scope.row.otherFiles && scope.row.otherFiles?.length">-->
  462. <!-- <el-link-->
  463. <!-- v-for="link in scope.row.otherFiles"-->
  464. <!-- :key="link.id"-->
  465. <!-- type="primary"-->
  466. <!-- :underline="false"-->
  467. <!-- @click="downloadFile(link)"-->
  468. <!-- >-->
  469. <!-- {{ link.name }}-->
  470. <!-- </el-link>-->
  471. <!-- </div>-->
  472. </el-form-item>
  473. </template>
  474. <template v-slot:produceDeliveryDeadline="scope">
  475. <el-form-item
  476. :prop="'datasource.' + scope.$index + '.produceDeliveryDeadline'"
  477. >
  478. <el-date-picker
  479. style="width: 140px"
  480. v-model="scope.row.produceDeliveryDeadline"
  481. :disabled="isContractId"
  482. type="date"
  483. placeholder="选择日期"
  484. >
  485. </el-date-picker>
  486. </el-form-item>
  487. </template>
  488. <template v-slot:customerExpectDeliveryDeadline="scope">
  489. <el-form-item
  490. :rules="{
  491. required: true,
  492. message: '请选择'+(contractBookType == 1 ? '客户期望交期' : '交付日期'),
  493. trigger: 'change'
  494. }"
  495. :prop="
  496. 'datasource.' + scope.$index + '.customerExpectDeliveryDeadline'
  497. "
  498. >
  499. <el-date-picker
  500. style="width: 140px"
  501. :disabled="isContractId"
  502. v-model="scope.row.customerExpectDeliveryDeadline"
  503. type="date"
  504. placeholder="选择日期"
  505. >
  506. </el-date-picker>
  507. </el-form-item>
  508. </template>
  509. <template v-slot:guaranteePeriodDeadline="scope">
  510. <el-form-item
  511. :prop="'datasource.' + scope.$index + '.guaranteePeriodDeadline'"
  512. >
  513. <el-date-picker
  514. style="width: 140px"
  515. :disabled="isContractId"
  516. v-model="scope.row.guaranteePeriodDeadline"
  517. type="date"
  518. placeholder="选择日期"
  519. >
  520. </el-date-picker>
  521. </el-form-item>
  522. </template>
  523. <template v-slot:singleWeight="scope">
  524. <!-- pricingWay == 2 -->
  525. <el-form-item
  526. style="margin-bottom: 20px"
  527. :rules="{
  528. required: true,
  529. message: '请输入单重',
  530. pattern: numberReg,
  531. trigger: ['change', 'blur']
  532. }"
  533. :prop="'datasource.' + scope.$index + '.singleWeight'"
  534. >
  535. <el-input
  536. :disabled="isContractId"
  537. v-model="scope.row.singleWeight"
  538. @input="singleWeightChange(scope.row, scope.$index)"
  539. placeholder="请输入"
  540. ></el-input>
  541. </el-form-item>
  542. </template>
  543. <template v-slot:technologyRouteName="scope">
  544. <el-form-item
  545. :prop="'datasource.' + scope.$index + '.technologyRouteName'"
  546. :rules="{
  547. required: false,
  548. message: '请选择',
  549. trigger: 'change'
  550. }"
  551. >
  552. <el-input
  553. v-model="scope.row.technologyRouteName"
  554. :disabled="isContractId"
  555. placeholder="请选择"
  556. @click.native="openVersion(scope.$index)"
  557. ></el-input>
  558. </el-form-item>
  559. </template>
  560. <!-- 操作列 -->
  561. <template v-slot:action="{ row }">
  562. <el-popconfirm
  563. class="ele-action"
  564. title="确定要删除吗?"
  565. @confirm="remove(row)"
  566. >
  567. <template v-slot:reference>
  568. <el-link type="danger" :underline="false" icon="el-icon-delete">
  569. 删除
  570. </el-link>
  571. </template>
  572. </el-popconfirm>
  573. </template>
  574. </ele-pro-table>
  575. <product-list
  576. ref="productListRef"
  577. classType="1"
  578. :is-get-inventory-total="true"
  579. @changeParent="changeParent"
  580. ></product-list>
  581. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  582. <ProductionVersion
  583. ref="versionRefs"
  584. @changeProduct="changeProduct"
  585. ></ProductionVersion>
  586. </el-form>
  587. </template>
  588. <script>
  589. import { numberReg } from 'ele-admin';
  590. import productList from '@/BIZComponents/product-list.vue';
  591. import dictMixins from '@/mixins/dictMixins';
  592. import fileUpload from '@/components/upload/fileUpload';
  593. import headList from '@/BIZComponents/user-select/user-select.vue';
  594. import ProductionVersion from '@/components/ProductionVersion2/index.vue';
  595. import { getFile } from '@/api/system/file';
  596. import { getInventoryTotalAPI } from '@/api/wms';
  597. import { getByCode } from '@/api/system/dictionary-data';
  598. // import fileMain from '@/components/addDoc/index.vue';
  599. import { lbjtList } from '@/enum/dict.js';
  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. if(row.produceType){
  810. return row.produceType.map(item=>{
  811. return lbjtList[item]
  812. }).toString()
  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.filter((item) => item.productCode).map((item) => item.productCode);
  1264. //获取仓库库存
  1265. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  1266. this.form.datasource.filter((item) => item.productCode).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.componentAttribute);
  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>