inventoryTable.vue 40 KB

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