inventoryTable.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  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. <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. <div class="pricebox">
  26. <span class="amount">总计:{{ allPrice }}元</span>
  27. <span v-if="isDiscountTotalPrice"></span>
  28. <el-form-item
  29. style="width: 300px"
  30. v-if="isDiscountTotalPrice"
  31. label="优惠总金额:"
  32. prop="discountTotalPrice"
  33. :rules="{
  34. required: true,
  35. message: '请输入',
  36. trigger: 'change'
  37. }"
  38. >
  39. <el-input
  40. v-model="form.discountTotalPrice"
  41. style="width: 150px"
  42. placeholder="请输入"
  43. @input="discountInput"
  44. >
  45. <template slot="append">元</template>
  46. </el-input
  47. >
  48. </el-form-item>
  49. </div>
  50. </div>
  51. </template>
  52. <template v-slot:productName="{ row, $index }">
  53. <el-form-item
  54. style="margin-bottom: 20px"
  55. :prop="'datasource.' + $index + '.productName'"
  56. :rules="{
  57. required: true,
  58. message: '请输入',
  59. trigger: 'change'
  60. }"
  61. >
  62. <el-input
  63. :disabled="isContractId"
  64. v-model="row.productName"
  65. placeholder="请输入"
  66. @click.native="handParent(row, $index)"
  67. ></el-input>
  68. </el-form-item>
  69. </template>
  70. <template v-slot:headerCustomerMark="{ column }">
  71. <span class="is-required">{{ column.label }}</span>
  72. </template>
  73. <template v-slot:customerMark="{ row, $index }">
  74. <el-form-item
  75. :prop="'datasource.' + $index + '.customerMark'"
  76. :rules="{
  77. required: true,
  78. message: '请输入',
  79. trigger: 'change'
  80. }">
  81. <el-input v-model="row.customerMark" placeholder="请输入"></el-input>
  82. </el-form-item>
  83. </template>
  84. <template v-slot:headerProductName="{ column }">
  85. <span class="is-required">{{ column.label }}</span>
  86. </template>
  87. <template v-slot:productCode="scope">
  88. <el-form-item
  89. style="margin-bottom: 20px"
  90. :prop="'datasource.' + scope.$index + '.productCode'"
  91. >
  92. <el-input :disabled="isContractId" v-model="scope.row.productCode" disabled></el-input>
  93. </el-form-item>
  94. </template>
  95. <template v-slot:productCategoryName="scope">
  96. <el-form-item
  97. style="margin-bottom: 20px"
  98. :prop="'datasource.' + scope.$index + '.productCategoryName'"
  99. >
  100. <el-input v-model="scope.row.productCategoryName" disabled></el-input>
  101. </el-form-item>
  102. </template>
  103. <template v-slot:totalCount="scope">
  104. <el-form-item
  105. style="margin-bottom: 20px"
  106. :prop="'datasource.' + scope.$index + '.totalCount'"
  107. :rules="{
  108. required: pageName == 'businessOpportunity' ? false : true,
  109. pattern: numberReg,
  110. message: '请输入数字',
  111. trigger: 'blur'
  112. }"
  113. >
  114. <el-input
  115. :disabled="isContractId"
  116. v-model="scope.row.totalCount"
  117. placeholder="请输入"
  118. @input="getTotalPrice(scope.row)"
  119. ></el-input>
  120. </el-form-item>
  121. </template>
  122. <template
  123. v-slot:headerTotalCount="{ column }"
  124. v-if="pageName != 'businessOpportunity'"
  125. >
  126. <span class="is-required">{{ column.label }}</span>
  127. </template>
  128. <template v-slot:totalPrice="scope">
  129. <el-form-item
  130. style="margin-bottom: 20px"
  131. :prop="'datasource.' + scope.$index + '.totalPrice'"
  132. >
  133. {{ (scope.row.totalCount * scope.row.singlePrice || 0).toFixed(2) }}元
  134. </el-form-item>
  135. </template>
  136. <template v-slot:productBrand="scope">
  137. <el-form-item
  138. style="margin-bottom: 20px"
  139. :prop="'datasource.' + scope.$index + '.productBrand'"
  140. >
  141. <el-input v-model="scope.row.productBrand" disabled></el-input>
  142. </el-form-item>
  143. </template>
  144. <template v-slot:modelType="scope">
  145. <el-form-item
  146. style="margin-bottom: 20px"
  147. :prop="'datasource.' + scope.$index + '.modelType'"
  148. >
  149. <el-input v-model="scope.row.modelType" disabled></el-input>
  150. </el-form-item>
  151. </template>
  152. <template v-slot:specification="scope">
  153. <el-form-item
  154. style="margin-bottom: 20px"
  155. :prop="'datasource.' + scope.$index + '.specification'"
  156. >
  157. <el-input v-model="scope.row.specification" disabled></el-input>
  158. </el-form-item>
  159. </template>
  160. <template v-slot:deliveryDays="scope">
  161. <el-form-item
  162. style="margin-bottom: 20px"
  163. :prop="'datasource.' + scope.$index + '.deliveryDays'"
  164. :rules="{
  165. pattern: numberReg,
  166. message: '请输入数字',
  167. trigger: 'blur'
  168. }"
  169. >
  170. <el-input
  171. :disabled="isContractId"
  172. v-model="scope.row.deliveryDays"
  173. @change="setDeliveryDays(scope.row, scope.$index, 'deliveryDays')"
  174. placeholder="请输入"
  175. ></el-input>
  176. </el-form-item>
  177. </template>
  178. <template v-slot:guaranteePeriod="scope">
  179. <div class="period">
  180. <div class="borderleftnone">
  181. <el-form-item
  182. style="margin-bottom: 20px"
  183. :prop="'datasource.' + scope.$index + '.guaranteePeriod'"
  184. :rules="{
  185. pattern: numberReg,
  186. message: '请输入数字',
  187. trigger: 'blur'
  188. }"
  189. >
  190. <el-input
  191. :disabled="isContractId"
  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. :disabled="isContractId"
  206. @change="
  207. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  208. "
  209. >
  210. </DictSelection>
  211. </div>
  212. </div>
  213. </template>
  214. <!-- <template v-slot:guaranteePeriodUnitCode="scope"> </template> -->
  215. <template v-slot:measuringUnit="scope">
  216. <el-form-item
  217. style="margin-bottom: 20px"
  218. :prop="'datasource.' + scope.$index + '.measuringUnit'"
  219. >
  220. <el-input
  221. v-model="scope.row.measuringUnit"
  222. :disabled="true"
  223. placeholder="请输入"
  224. ></el-input>
  225. </el-form-item>
  226. </template>
  227. <template v-slot:remark="scope">
  228. <el-form-item
  229. style="margin-bottom: 20px"
  230. :prop="'datasource.' + scope.$index + '.remark'"
  231. >
  232. <el-input
  233. :disabled="isContractId"
  234. v-model="scope.row.remark"
  235. type="textarea"
  236. placeholder="请输入"
  237. ></el-input>
  238. </el-form-item>
  239. </template>
  240. <template v-slot:singlePrice="scope">
  241. <el-form-item
  242. style="margin-bottom: 20px"
  243. :prop="'datasource.' + scope.$index + '.singlePrice'"
  244. :rules="{
  245. required: pageName == 'businessOpportunity' ? false : true,
  246. pattern: numberReg,
  247. message: '请输入正确的单价',
  248. trigger: 'change'
  249. }"
  250. >
  251. <el-input
  252. :disabled="isContractId"
  253. v-model="scope.row.singlePrice"
  254. placeholder="请输入"
  255. @input="getTotalPrice"
  256. >
  257. <template slot="append">元</template>
  258. </el-input>
  259. </el-form-item>
  260. </template>
  261. <template
  262. v-slot:headerSinglePrice="{ column }"
  263. v-if="pageName != 'businessOpportunity'"
  264. >
  265. <span class="is-required">{{ column.label }}</span>
  266. </template>
  267. <template v-slot:headerCustomerExpectDeliveryDeadline="{ column }">
  268. <span class="is-required">{{ column.label }}</span>
  269. </template>
  270. <template v-slot:technicalAnswerName="{ row, $index }">
  271. <el-form-item
  272. style="margin-bottom: 20px"
  273. :prop="'datasource.' + $index + '.technicalAnswerName'"
  274. >
  275. <el-input
  276. v-model="row.technicalAnswerName"
  277. placeholder="请输入"
  278. :disabled="isContractId"
  279. @click.native="handHead(row, $index)"
  280. ></el-input>
  281. </el-form-item>
  282. </template>
  283. <template v-slot:technicalParams="scope">
  284. <el-form-item
  285. style="margin-bottom: 20px"
  286. :prop="'datasource.' + scope.$index + '.technicalParams'"
  287. >
  288. <el-input
  289. type="textarea"
  290. v-model="scope.row.technicalParams"
  291. :disabled="isContractId"
  292. placeholder="请输入"
  293. ></el-input>
  294. </el-form-item>
  295. </template>
  296. <template v-slot:technicalDrawings="scope">
  297. <el-form-item
  298. style="margin-bottom: 20px"
  299. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  300. >
  301. <fileUpload
  302. v-if="!isContractId"
  303. v-model="scope.row.technicalDrawings"
  304. :disabled="isContractId"
  305. module="main"
  306. :showLib="false"
  307. :limit="5"
  308. />
  309. <div v-else v-if="scope.row.technicalDrawings && scope.row.technicalDrawings?.length">
  310. <el-link
  311. v-for="link in scope.row.technicalDrawings"
  312. :key="link.id"
  313. type="primary"
  314. :underline="false"
  315. @click="downloadFile(link)"
  316. >
  317. {{ link.name }}</el-link
  318. >
  319. </div>
  320. </el-form-item>
  321. </template>
  322. <template v-slot:customerReqFiles="scope">
  323. <el-form-item
  324. style="margin-bottom: 20px"
  325. :prop="'datasource.' + scope.$index + '.customerReqFiles'"
  326. >
  327. <fileUpload
  328. v-model="scope.row.customerReqFiles"
  329. v-if="!isContractId"
  330. module="main"
  331. :showLib="false"
  332. :limit="5"
  333. />
  334. <div v-else v-if="scope.row.customerReqFiles && scope.row.customerReqFiles?.length">
  335. <el-link
  336. v-for="link in scope.row.customerReqFiles"
  337. :key="link.id"
  338. type="primary"
  339. :underline="false"
  340. @click="downloadFile(link)"
  341. >
  342. {{ link.name }}</el-link
  343. >
  344. </div>
  345. </el-form-item>
  346. </template>
  347. <template v-slot:industryArtFiles="scope">
  348. <el-form-item
  349. style="margin-bottom: 20px"
  350. :prop="'datasource.' + scope.$index + '.industryArtFiles'"
  351. :rules="{
  352. required: false,
  353. message: '请输入',
  354. trigger: 'change'
  355. }"
  356. >
  357. <fileUpload
  358. v-model="scope.row.industryArtFiles"
  359. module="main"
  360. v-if="!isContractId"
  361. :showLib="false"
  362. :limit="5"
  363. />
  364. <div v-else v-if="scope.row.industryArtFiles && scope.row.industryArtFiles?.length">
  365. <el-link
  366. v-for="link in scope.row.industryArtFiles"
  367. :key="link.id"
  368. type="primary"
  369. :underline="false"
  370. @click="downloadFile(link)"
  371. >
  372. {{ link.name }}</el-link
  373. >
  374. </div>
  375. </el-form-item>
  376. </template>
  377. <template v-slot:otherFiles="scope">
  378. <el-form-item
  379. style="margin-bottom: 20px"
  380. :prop="'datasource.' + scope.$index + '. otherFiles'"
  381. >
  382. <fileUpload
  383. v-model="scope.row.otherFiles"
  384. module="main"
  385. v-if="!isContractId"
  386. :showLib="false"
  387. :limit="5"
  388. />
  389. <div v-else v-if="scope.row.otherFiles && scope.row.otherFiles?.length">
  390. <el-link
  391. v-for="link in scope.row.otherFiles"
  392. :key="link.id"
  393. type="primary"
  394. :underline="false"
  395. @click="downloadFile(link)"
  396. >
  397. {{ link.name }}</el-link
  398. >
  399. </div>
  400. </el-form-item>
  401. </template>
  402. <template v-slot:produceDeliveryDeadline="scope">
  403. <el-form-item
  404. :prop="'datasource.' + scope.$index + '.produceDeliveryDeadline'"
  405. >
  406. <el-date-picker
  407. style="width: 140px"
  408. v-model="scope.row.produceDeliveryDeadline"
  409. :disabled="isContractId"
  410. type="date"
  411. placeholder="选择日期"
  412. >
  413. </el-date-picker>
  414. </el-form-item>
  415. </template>
  416. <template v-slot:customerExpectDeliveryDeadline="scope">
  417. <el-form-item
  418. :rules="{
  419. required: true,
  420. message: '请选择日期',
  421. trigger: 'change'
  422. }"
  423. :prop="
  424. 'datasource.' + scope.$index + '.customerExpectDeliveryDeadline'
  425. "
  426. >
  427. <el-date-picker
  428. style="width: 140px"
  429. :disabled="isContractId"
  430. v-model="scope.row.customerExpectDeliveryDeadline"
  431. type="date"
  432. placeholder="选择日期"
  433. >
  434. </el-date-picker>
  435. </el-form-item>
  436. </template>
  437. <template v-slot:guaranteePeriodDeadline="scope">
  438. <el-form-item
  439. :prop="'datasource.' + scope.$index + '.guaranteePeriodDeadline'"
  440. >
  441. <el-date-picker
  442. style="width: 140px"
  443. :disabled="isContractId"
  444. v-model="scope.row.guaranteePeriodDeadline"
  445. type="date"
  446. placeholder="选择日期"
  447. >
  448. </el-date-picker>
  449. </el-form-item>
  450. </template>
  451. <template v-slot:singleWeight="scope">
  452. <el-form-item
  453. style="margin-bottom: 20px"
  454. :rules="{
  455. required: false,
  456. pattern: numberReg,
  457. trigger: 'change'
  458. }"
  459. :prop="'datasource.' + scope.$index + '.singleWeight'"
  460. >
  461. <el-input
  462. :disabled="isContractId"
  463. v-model="scope.row.singleWeight"
  464. @input="singleWeightChange(scope.row)"
  465. placeholder="请输入"
  466. ></el-input>
  467. </el-form-item>
  468. </template>
  469. <template v-slot:technologyRouteName="scope">
  470. <el-form-item
  471. :prop="'datasource.' + scope.$index + '.technologyRouteName'"
  472. :rules="{
  473. required: false,
  474. message: '请选择',
  475. trigger: 'change'
  476. }"
  477. >
  478. <el-input
  479. v-model="scope.row.technologyRouteName"
  480. :disabled="isContractId"
  481. placeholder="请选择"
  482. @click.native="openVersion(scope.$index)"
  483. ></el-input>
  484. </el-form-item>
  485. </template>
  486. <!-- 操作列 -->
  487. <template v-slot:action="{ row }">
  488. <el-popconfirm
  489. class="ele-action"
  490. title="确定要删除吗?"
  491. @confirm="remove(row)"
  492. >
  493. <template v-slot:reference>
  494. <el-link type="danger" :underline="false" icon="el-icon-delete">
  495. 删除
  496. </el-link>
  497. </template>
  498. </el-popconfirm>
  499. </template>
  500. </ele-pro-table>
  501. <product-list
  502. ref="productListRef"
  503. classType="1"
  504. @changeParent="changeParent"
  505. ></product-list>
  506. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  507. <ProductionVersion
  508. ref="versionRefs"
  509. @changeProduct="changeProduct"
  510. ></ProductionVersion>
  511. </el-form>
  512. </template>
  513. <script>
  514. import {numberReg} from 'ele-admin';
  515. import productList from './product-list.vue';
  516. import dictMixins from '@/mixins/dictMixins';
  517. import fileUpload from '@/components/upload/fileUpload';
  518. import headList from '@/views/saleManage/businessOpportunity/components/headList.vue';
  519. import ProductionVersion from '@/components/ProductionVersion2/index.vue';
  520. import {getFile} from "@/api/system/file";
  521. const dayjs = require('dayjs');
  522. export default {
  523. mixins: [dictMixins],
  524. components: {
  525. productList,
  526. fileUpload,
  527. headList,
  528. ProductionVersion,
  529. },
  530. props: {
  531. pageName: {
  532. default: '',
  533. type: String
  534. },
  535. isDiscountTotalPrice: {
  536. default: false,
  537. type: Boolean
  538. },
  539. isDeliveryDeadline: {
  540. default: true,
  541. type: Boolean
  542. },
  543. isGuaranteePeriod: {
  544. default: true,
  545. type: Boolean
  546. },
  547. isCustomerMark: {
  548. default: true,
  549. type: Boolean
  550. },
  551. contractBookType: {
  552. default: 1
  553. },
  554. isContractId: {
  555. type: Boolean,
  556. default: false
  557. },
  558. },
  559. data() {
  560. const defaultForm = {
  561. key: null,
  562. endTime: '',
  563. isFirst: 0,
  564. name: '',
  565. startTime: '',
  566. workHour: '',
  567. guaranteePeriodUnitCode: '',
  568. technicalDrawings: []
  569. };
  570. return {
  571. allPrice: 0.0,
  572. numberReg,
  573. defaultForm,
  574. form: {
  575. discountTotalPrice: '',
  576. datasource: []
  577. },
  578. rules: {},
  579. columns: [
  580. {
  581. width: 45,
  582. type: 'index',
  583. columnKey: 'index',
  584. align: 'center',
  585. fixed: 'left'
  586. },
  587. {
  588. width: 200,
  589. prop: 'productName',
  590. label: '名称',
  591. slot: 'productName',
  592. headerSlot: 'headerProductName'
  593. },
  594. {
  595. width: 120,
  596. prop: 'productCode',
  597. label: '编码',
  598. slot: 'productCode'
  599. },
  600. {
  601. width: 200,
  602. prop: 'productCategoryName',
  603. label: '类型',
  604. slot: 'productCategoryName'
  605. },
  606. {
  607. width: 160,
  608. prop: 'productBrand',
  609. label: '牌号',
  610. slot: 'productBrand'
  611. },
  612. {
  613. width: 120,
  614. prop: 'modelType',
  615. label: '型号',
  616. slot: 'modelType'
  617. },
  618. {
  619. width: 120,
  620. prop: 'specification',
  621. label: '规格',
  622. slot: 'specification'
  623. },
  624. {
  625. width: 200,
  626. prop: 'customerMark',
  627. label: '客户代号',
  628. slot: 'customerMark',
  629. headerSlot: 'headerCustomerMark',
  630. show: this.isCustomerMark
  631. },
  632. {
  633. width: 160,
  634. prop: 'singlePrice',
  635. label: '单价',
  636. slot: 'singlePrice',
  637. headerSlot: 'headerSinglePrice'
  638. },
  639. {
  640. width: 120,
  641. prop: 'totalCount',
  642. label: '数量',
  643. slot: 'totalCount',
  644. headerSlot: 'headerTotalCount'
  645. },
  646. {
  647. width: 120,
  648. prop: 'measuringUnit',
  649. label: '计量单位',
  650. slot: 'measuringUnit'
  651. },
  652. {
  653. width: 120,
  654. prop: 'totalPrice',
  655. label: '合计',
  656. slot: 'totalPrice'
  657. },
  658. {
  659. width: 120,
  660. prop: 'singleWeight',
  661. label: '单重',
  662. slot: 'singleWeight'
  663. },
  664. {
  665. width: 120,
  666. prop: 'totalWeight',
  667. label: '总重',
  668. slot: 'totalWeight'
  669. },
  670. {
  671. width: 120,
  672. prop: 'weightUnit',
  673. label: '重量单位',
  674. slot: 'weightUnit'
  675. },
  676. // {
  677. // width: 80,
  678. // prop: 'deliveryDays',
  679. // label: '交期(天)',
  680. // slot: 'deliveryDays'
  681. // },
  682. // {
  683. // width: 160,
  684. // prop: 'deliveryDeadline',
  685. // label: '交期截止日期',
  686. // slot: 'deliveryDeadline',
  687. // show: this.isDeliveryDeadline
  688. // },
  689. {
  690. width: 160,
  691. prop: 'customerExpectDeliveryDeadline',
  692. label: this.contractBookType == 1 ? '客户期望交期' : '交付日期',
  693. slot: 'customerExpectDeliveryDeadline',
  694. headerSlot: 'headerCustomerExpectDeliveryDeadline'
  695. },
  696. {
  697. width: 160,
  698. prop: 'produceDeliveryDeadline',
  699. label: '生产交付交期',
  700. slot: 'produceDeliveryDeadline',
  701. show: this.contractBookType == 1 ? true : false
  702. },
  703. {
  704. width: 200,
  705. prop: 'guaranteePeriod',
  706. label: '质保期',
  707. slot: 'guaranteePeriod'
  708. },
  709. {
  710. width: 200,
  711. prop: 'guaranteePeriodDeadline',
  712. label: '质保期截止日期',
  713. slot: 'guaranteePeriodDeadline',
  714. show: this.isGuaranteePeriod
  715. },
  716. // {
  717. // width: 120,
  718. // prop: 'guaranteePeriodUnitCode',
  719. // label: '',
  720. // slot: 'guaranteePeriodUnitCode'
  721. // },
  722. {
  723. width: 220,
  724. prop: 'customerReqFiles',
  725. label: '客户需求',
  726. slot: 'customerReqFiles'
  727. },
  728. {
  729. width: 130,
  730. prop: 'technicalAnswerName',
  731. label: '技术答疑人',
  732. slot: 'technicalAnswerName'
  733. },
  734. {
  735. width: 220,
  736. prop: 'technicalParams',
  737. label: '技术参数',
  738. slot: 'technicalParams'
  739. },
  740. {
  741. width: 240,
  742. prop: 'technicalDrawings',
  743. label: '技术图纸',
  744. slot: 'technicalDrawings'
  745. },
  746. {
  747. width: 240,
  748. prop: 'technologyRouteName',
  749. label: '工艺路线',
  750. slot: 'technologyRouteName',
  751. show: this.contractBookType == 1 ? true : false
  752. },
  753. {
  754. width: 240,
  755. prop: 'industryArtFiles',
  756. label: '工艺附件',
  757. slot: 'industryArtFiles'
  758. },
  759. {
  760. width: 240,
  761. prop: 'otherFiles',
  762. label: '其他附件',
  763. slot: 'otherFiles'
  764. },
  765. {
  766. width: 220,
  767. prop: 'remark',
  768. label: '备注',
  769. slot: 'remark'
  770. },
  771. {
  772. columnKey: 'action',
  773. label: '操作',
  774. width: 120,
  775. align: 'center',
  776. resizable: false,
  777. slot: 'action',
  778. fixed: 'right',
  779. showOverflowTooltip: true
  780. }
  781. ]
  782. };
  783. },
  784. computed: {
  785. canHandl() {
  786. return this.form.datasource.length;
  787. }
  788. },
  789. watch: {
  790. contractBookType(n) {
  791. this.columns.forEach((item) => {
  792. if (item.label == '生产交付交期' || item.label == '工艺路线') {
  793. item.show = n == 1 ? true : false;
  794. }
  795. if (item.prop == 'customerExpectDeliveryDeadline') {
  796. item.label = n == 1 ? '客户期望交期' : '交付日期';
  797. }
  798. });
  799. this.$refs.table.reRenderTable();
  800. }
  801. },
  802. methods: {
  803. downloadFile(file) {
  804. getFile({ objectName: file.storePath }, file.name);
  805. },
  806. openVersion(index) {
  807. this.$refs.versionRefs.open(index);
  808. },
  809. //工艺路线
  810. changeProduct(data, index) {
  811. this.$set(
  812. this.form.datasource[index],
  813. 'technologyRouteName',
  814. data.name
  815. );
  816. this.$set(this.form.datasource[index], 'technologyRouteId', data.id);
  817. },
  818. setDeliveryDays(row, index, type, isAll) {
  819. if (isAll) {
  820. this.form.datasource.forEach((item, i) => {
  821. // if (item.deliveryDays) {
  822. // this.$set(
  823. // this.form.datasource[i],
  824. // 'deliveryDeadline',
  825. // this.setDay(item.deliveryDays)
  826. // );
  827. // }
  828. // if (item.guaranteePeriodUnitCode) {
  829. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  830. item.guaranteePeriodUnitCode
  831. );
  832. this.$set(
  833. this.form.datasource[i],
  834. 'guaranteePeriodDeadline',
  835. guaranteePeriodUnitName != 'second'
  836. ? this.setDay(item.guaranteePeriod, guaranteePeriodUnitName)
  837. : ''
  838. );
  839. // }
  840. });
  841. return;
  842. }
  843. // if (type == 'deliveryDays') {
  844. // this.$set(
  845. // this.form.datasource[index],
  846. // 'deliveryDeadline',
  847. // this.setDay(row.deliveryDays)
  848. // );
  849. // }
  850. if (type == 'guaranteePeriod') {
  851. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  852. row.guaranteePeriodUnitCode
  853. );
  854. this.$set(
  855. this.form.datasource[index],
  856. 'guaranteePeriodDeadline',
  857. guaranteePeriodUnitName != 'second'
  858. ? this.setDay(row.guaranteePeriod, guaranteePeriodUnitName)
  859. : ''
  860. );
  861. }
  862. },
  863. guaranteePeriodUnit(code) {
  864. return code == 3
  865. ? 'day'
  866. : code == 4
  867. ? 'month'
  868. : code == 5
  869. ? 'year'
  870. : 'second';
  871. },
  872. setDay(addDay, dateType = 'day') {
  873. return dayjs(this.contractStartDate || new Date())
  874. .add(addDay, dateType)
  875. .format('YYYY-MM-DD');
  876. },
  877. // 返回列表数据
  878. getTableValue() {
  879. let comitDatasource = this.form.datasource;
  880. if (comitDatasource.length === 0) return [];
  881. comitDatasource.forEach((v) => {
  882. v.totalPrice =
  883. (v.totalCount &&
  884. v.singlePrice &&
  885. (v.totalCount * v.singlePrice)?.toFixed(2)) ||
  886. '';
  887. if (v.guaranteePeriodUnitCode) {
  888. v.guaranteePeriodUnitName = this.getDictValue(
  889. '保质期单位',
  890. v.guaranteePeriodUnitCode
  891. );
  892. }
  893. v.technicalDrawings = v.technicalDrawings ? v.technicalDrawings : [];
  894. v.customerReqFiles = v.customerReqFiles || [];
  895. v.industryArtFiles = v.industryArtFiles || [];
  896. v.otherFiles = v.otherFiles || [];
  897. });
  898. return comitDatasource;
  899. },
  900. getPrice() {
  901. return [this.allPrice, this.form.discountTotalPrice];
  902. },
  903. //计算总金额
  904. getTotalPrice(row) {
  905. this.singleWeightChange(row);
  906. if (this.form.datasource.length) {
  907. let datasource = this.form.datasource,
  908. sum = 0;
  909. datasource.forEach((r) => {
  910. if (r.singlePrice && r.totalCount) {
  911. sum += r.singlePrice * r.totalCount;
  912. }
  913. });
  914. let allsum = sum.toFixed(2);
  915. this.allPrice = allsum;
  916. this.form.discountTotalPrice = allsum;
  917. this.$store.commit('concact/setDiscountAmount', allsum);
  918. this.$store.commit('order/setAllcountAmount', allsum);
  919. return allsum;
  920. } else {
  921. this.allPrice = 0.0;
  922. this.form.discountTotalPrice = 0.0;
  923. return 0.0;
  924. }
  925. },
  926. //更新优惠总金额
  927. discountInput(val) {
  928. this.$store.commit('concact/setDiscountAmount', val);
  929. },
  930. //修改回显
  931. putTableValue(data) {
  932. let productList =
  933. (data && (data.quoteProductList || data.productList)) || [];
  934. if (productList) {
  935. productList.forEach((item) => {
  936. item.guaranteePeriodUnitCode = item.guaranteePeriodUnitCode ? item.guaranteePeriodUnitCode + '' : '';
  937. // if (item.deliveryDays) {
  938. // item['deliveryDeadline'] =
  939. // item['deliveryDeadline'] || this.setDay(item.deliveryDays);
  940. // }
  941. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  942. item.guaranteePeriodUnitCode
  943. );
  944. if (item.guaranteePeriod && item.guaranteePeriodUnitCode) {
  945. item['guaranteePeriodDeadline'] =
  946. item['guaranteePeriodDeadline'] ||
  947. guaranteePeriodUnitName != 'second'
  948. ? this.setDay(item.guaranteePeriod, guaranteePeriodUnitName)
  949. : '';
  950. }
  951. });
  952. this.form.datasource = productList;
  953. this.allPrice = data?.contractVO?.totalPrice;
  954. this.getTotalPrice();
  955. this.form.discountTotalPrice = data?.contractVO?.discountTotalPrice;
  956. this.discountInput(data?.contractVO?.discountTotalPrice);
  957. }
  958. },
  959. //计算单重
  960. singleWeightChange(row) {
  961. if (row && row.singleWeight && row.totalCount) {
  962. row.totalWeight = (row.singleWeight * row.totalCount).toFixed(2) || 0;
  963. }
  964. },
  965. //选择产品
  966. handParent(row, index) {
  967. let item = {
  968. id: row.productCode
  969. };
  970. this.$refs.productListRef.open(item, index);
  971. },
  972. //选择技术人回调
  973. changeAnswer(obj, idx) {
  974. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  975. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  976. },
  977. handHead(row, index) {
  978. let item = {
  979. id: row.technicalAnswerId
  980. };
  981. this.$refs.headRef.open(item, index);
  982. },
  983. //选择产品回调
  984. changeParent(obj, idx) {
  985. this.$set(this.form.datasource[idx], 'categoryName', obj.name);
  986. this.$set(
  987. this.form.datasource[idx],
  988. 'productCategoryId',
  989. obj.categoryLevelId
  990. );
  991. this.$set(this.form.datasource[idx], 'productBrand', obj.brandNum);
  992. this.$set(
  993. this.form.datasource[idx],
  994. 'productCategoryName',
  995. obj.categoryLevelPath
  996. );
  997. this.$set(this.form.datasource[idx], 'productCode', obj.code);
  998. this.$set(this.form.datasource[idx], 'productName', obj.name);
  999. this.$set(this.form.datasource[idx], 'modelType', obj.modelType);
  1000. this.$set(
  1001. this.form.datasource[idx],
  1002. 'measuringUnit',
  1003. obj.measuringUnit
  1004. );
  1005. this.$set(
  1006. this.form.datasource[idx],
  1007. 'specification',
  1008. obj.specification
  1009. );
  1010. this.$set(this.form.datasource[idx], 'weightUnit', obj.weightUnit);
  1011. },
  1012. remove(row) {
  1013. let index = this.form.datasource.findIndex((n) => n.key == row.key);
  1014. if (index !== -1) {
  1015. this.form.datasource.splice(index, 1);
  1016. this.setSort();
  1017. }
  1018. },
  1019. // 清空表格
  1020. restTable() {
  1021. this.form.datasource = [];
  1022. },
  1023. // 重新排序
  1024. setSort() {
  1025. this.form.datasource.forEach((n, index) => {
  1026. n.key = index + 1;
  1027. });
  1028. },
  1029. // 添加
  1030. handlAdd() {
  1031. let item = JSON.parse(JSON.stringify(this.defaultForm));
  1032. item.key = this.form.datasource.length + 1;
  1033. this.form.datasource.push(item);
  1034. },
  1035. validateForm(callback) {
  1036. //开始表单校验
  1037. this.$refs.form.validate((valid) => {
  1038. callback(valid);
  1039. });
  1040. }
  1041. }
  1042. };
  1043. </script>
  1044. <style lang="scss" scoped>
  1045. .headbox {
  1046. display: flex;
  1047. justify-content: space-between;
  1048. align-items: center;
  1049. .amount {
  1050. font-size: 14px;
  1051. font-weight: bold;
  1052. padding-right: 30px;
  1053. }
  1054. }
  1055. .time-form .el-form-item {
  1056. margin-bottom: 0 !important;
  1057. }
  1058. ::v-deep .period {
  1059. display: flex;
  1060. .borderleftnone {
  1061. .el-input--medium .el-input__inner {
  1062. border-top-right-radius: 0;
  1063. border-bottom-right-radius: 0;
  1064. }
  1065. }
  1066. .borderrightnone {
  1067. .el-input--medium .el-input__inner {
  1068. border-top-left-radius: 0;
  1069. border-bottom-left-radius: 0;
  1070. }
  1071. }
  1072. }
  1073. ::v-deep .time-form tbody > tr:hover > td {
  1074. background-color: transparent !important;
  1075. }
  1076. ::v-deep .time-form .el-table tr {
  1077. background-color: #ffffff;
  1078. }
  1079. .pricebox {
  1080. display: flex;
  1081. justify-content: flex-start;
  1082. align-items: center;
  1083. font-weight: bold;
  1084. }
  1085. </style>