inventoryTable.vue 34 KB

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