inventoryTable.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <!-- <template v-if="contractId">
  4. <ele-pro-table
  5. ref="table"
  6. :needPage="false"
  7. :columns="competAnalysisListcolumns"
  8. :toolkit="[]"
  9. :datasource="form.datasource"
  10. row-key="id"
  11. >
  12. </ele-pro-table>
  13. </template> -->
  14. <template>
  15. <ele-pro-table
  16. ref="table"
  17. :needPage="false"
  18. :columns="columns"
  19. :toolkit="[]"
  20. :datasource="form.datasource"
  21. cache-key="systemRoleTable17"
  22. class="time-form"
  23. >
  24. <!-- 表头工具栏 -->
  25. <template v-slot:toolbar>
  26. <div class="headbox" v-if="!contractId">
  27. <el-button
  28. size="small"
  29. type="primary"
  30. icon="el-icon-plus"
  31. class="ele-btn-icon"
  32. @click="handlAdd"
  33. >
  34. 新增
  35. </el-button>
  36. </div>
  37. </template>
  38. <template v-slot:productName="{ row, $index }">
  39. <el-form-item
  40. style="margin-bottom: 20px"
  41. :prop="'datasource.' + $index + '.productName'"
  42. :rules="{
  43. required: true,
  44. message: '请输入',
  45. trigger: 'change'
  46. }"
  47. >
  48. <el-input
  49. v-model="row.productName"
  50. placeholder="请输入"
  51. @click.native="handParent(row, $index)"
  52. ></el-input>
  53. </el-form-item>
  54. </template>
  55. <template v-slot:productCode="scope">
  56. <el-form-item
  57. style="margin-bottom: 20px"
  58. :prop="'datasource.' + scope.$index + '.productCode'"
  59. :rules="{
  60. required: true,
  61. message: '请输入',
  62. trigger: 'change'
  63. }"
  64. >
  65. <el-input v-model="scope.row.productCode" disabled></el-input>
  66. </el-form-item>
  67. </template>
  68. <template v-slot:productCategoryName="scope">
  69. <el-form-item
  70. style="margin-bottom: 20px"
  71. :prop="'datasource.' + scope.$index + '.productCategoryName'"
  72. :rules="{
  73. required: true,
  74. message: '请输入',
  75. trigger: 'change'
  76. }"
  77. >
  78. <el-input
  79. v-model="scope.row.productCategoryName"
  80. disabled
  81. ></el-input>
  82. </el-form-item>
  83. </template>
  84. <template v-slot:totalCount="scope">
  85. <el-form-item
  86. style="margin-bottom: 20px"
  87. :prop="'datasource.' + scope.$index + '.totalCount'"
  88. :rules="{
  89. required: true,
  90. pattern: numberReg,
  91. message: '请输入数字',
  92. trigger: 'blur'
  93. }"
  94. >
  95. <el-input
  96. v-model="scope.row.totalCount"
  97. placeholder="请输入"
  98. @input="getTotalPrice"
  99. ></el-input>
  100. </el-form-item>
  101. </template>
  102. <template v-slot:totalPrice="scope">
  103. <el-form-item
  104. style="margin-bottom: 20px"
  105. :prop="'datasource.' + scope.$index + '.totalPrice'"
  106. >
  107. {{
  108. (scope.row.totalCount * scope.row.singlePrice || 0).toFixed(2)
  109. }}元
  110. </el-form-item>
  111. </template>
  112. <template v-slot:productBrand="scope">
  113. <el-form-item
  114. style="margin-bottom: 20px"
  115. :prop="'datasource.' + scope.$index + '.productBrand'"
  116. >
  117. <el-input v-model="scope.row.productBrand" disabled></el-input>
  118. </el-form-item>
  119. </template>
  120. <template v-slot:modelType="scope">
  121. <el-form-item
  122. style="margin-bottom: 20px"
  123. :prop="'datasource.' + scope.$index + '.modelType'"
  124. >
  125. <el-input v-model="scope.row.modelType" disabled></el-input>
  126. </el-form-item>
  127. </template>
  128. <template v-slot:specification="scope">
  129. <el-form-item
  130. style="margin-bottom: 20px"
  131. :prop="'datasource.' + scope.$index + '.specification'"
  132. >
  133. <el-input v-model="scope.row.specification" disabled></el-input>
  134. </el-form-item>
  135. </template>
  136. <template v-slot:deliveryDays="scope">
  137. <el-form-item
  138. style="margin-bottom: 20px"
  139. :prop="'datasource.' + scope.$index + '.deliveryDays'"
  140. :rules="{
  141. pattern: numberReg,
  142. message: '请输入数字',
  143. trigger: 'blur'
  144. }"
  145. >
  146. <el-input
  147. v-model="scope.row.deliveryDays"
  148. @change="setDeliveryDays(scope.row, scope.$index, 'deliveryDays')"
  149. placeholder="请输入"
  150. ></el-input>
  151. </el-form-item>
  152. </template>
  153. <template v-slot:guaranteePeriod="scope">
  154. <div class="period">
  155. <div class="borderleftnone">
  156. <el-form-item
  157. style="margin-bottom: 20px"
  158. :prop="'datasource.' + scope.$index + '.guaranteePeriod'"
  159. :rules="{
  160. pattern: numberReg,
  161. message: '请输入数字',
  162. trigger: 'blur'
  163. }"
  164. >
  165. <el-input
  166. v-model="scope.row.guaranteePeriod"
  167. @change="
  168. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  169. "
  170. placeholder="请输入"
  171. ></el-input>
  172. </el-form-item>
  173. </div>
  174. <div class="borderrightnone">
  175. <DictSelection
  176. dictName="质保期单位"
  177. clearable
  178. v-model="scope.row.guaranteePeriodUnitCode"
  179. @change="
  180. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  181. "
  182. >
  183. </DictSelection>
  184. </div>
  185. </div>
  186. </template>
  187. <!-- <template v-slot:guaranteePeriodUnitCode="scope"> </template> -->
  188. <template v-slot:measuringUnit="scope">
  189. <el-form-item
  190. style="margin-bottom: 20px"
  191. :prop="'datasource.' + scope.$index + '.measuringUnit'"
  192. >
  193. <el-input
  194. v-model="scope.row.measuringUnit"
  195. disabled
  196. placeholder="请输入"
  197. ></el-input>
  198. </el-form-item>
  199. </template>
  200. <template v-slot:remark="scope">
  201. <el-form-item
  202. style="margin-bottom: 20px"
  203. :prop="'datasource.' + scope.$index + '.remark'"
  204. >
  205. <el-input
  206. v-model="scope.row.remark"
  207. type="textarea"
  208. placeholder="请输入"
  209. ></el-input>
  210. </el-form-item>
  211. </template>
  212. <template v-slot:singlePrice="scope">
  213. <el-form-item
  214. style="margin-bottom: 20px"
  215. :prop="'datasource.' + scope.$index + '.singlePrice'"
  216. :rules="{
  217. required: true,
  218. pattern: numberReg,
  219. message: '请输入正确的单价',
  220. trigger: 'change'
  221. }"
  222. >
  223. <el-input
  224. v-model="scope.row.singlePrice"
  225. placeholder="请输入"
  226. @input="getTotalPrice"
  227. >
  228. <template slot="append">元</template>
  229. </el-input>
  230. </el-form-item>
  231. </template>
  232. <template v-slot:technicalAnswerName="{ row, $index }">
  233. <el-form-item
  234. style="margin-bottom: 20px"
  235. :prop="'datasource.' + $index + '.technicalAnswerName'"
  236. >
  237. <el-input
  238. v-model="row.technicalAnswerName"
  239. placeholder="请输入"
  240. @click.native="handHead(row, $index)"
  241. ></el-input>
  242. </el-form-item>
  243. </template>
  244. <template v-slot:technicalParams="scope">
  245. <el-form-item
  246. style="margin-bottom: 20px"
  247. :prop="'datasource.' + scope.$index + '.technicalParams'"
  248. >
  249. <el-input
  250. type="textarea"
  251. v-model="scope.row.technicalParams"
  252. placeholder="请输入"
  253. ></el-input>
  254. </el-form-item>
  255. </template>
  256. <template v-slot:technicalDrawings="scope">
  257. <el-form-item
  258. style="margin-bottom: 20px"
  259. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  260. >
  261. <fileMain v-model="scope.row.technicalDrawings"></fileMain>
  262. <!-- <fileUpload-->
  263. <!-- v-model="scope.row.technicalDrawings"-->
  264. <!-- module="main"-->
  265. <!-- :showLib="false"-->
  266. <!-- :limit="5"-->
  267. <!-- />-->
  268. </el-form-item>
  269. </template>
  270. <template v-slot:customerReqFiles="scope">
  271. <el-form-item
  272. style="margin-bottom: 20px"
  273. :prop="'datasource.' + scope.$index + '.customerReqFiles'"
  274. >
  275. <fileMain v-model="scope.row.customerReqFiles"></fileMain>
  276. <!-- <fileUpload-->
  277. <!-- v-model="scope.row.customerReqFiles"-->
  278. <!-- module="main"-->
  279. <!-- :showLib="false"-->
  280. <!-- :limit="5"-->
  281. <!-- />-->
  282. </el-form-item>
  283. </template>
  284. <template v-slot:guaranteePeriodDeadline="scope">
  285. <el-form-item
  286. :prop="'datasource.' + scope.$index + '.guaranteePeriodDeadline'"
  287. >
  288. <el-date-picker
  289. style="width: 140px"
  290. v-model="scope.row.guaranteePeriodDeadline"
  291. type="date"
  292. placeholder="选择日期"
  293. >
  294. </el-date-picker>
  295. </el-form-item>
  296. </template>
  297. <template v-slot:deliveryDeadline="scope">
  298. <el-form-item
  299. :prop="'datasource.' + scope.$index + '.deliveryDeadline'"
  300. >
  301. <el-date-picker
  302. style="width: 140px"
  303. v-model="scope.row.deliveryDeadline"
  304. type="date"
  305. placeholder="选择日期"
  306. >
  307. </el-date-picker>
  308. </el-form-item>
  309. </template>
  310. <template v-slot:headerProductName="{ column }">
  311. <span class="is-required">{{ column.label }}</span>
  312. </template>
  313. <template v-slot:headerTotalCount="{ column }">
  314. <span class="is-required">{{ column.label }}</span>
  315. </template>
  316. <template v-slot:headerSinglePrice="{ column }">
  317. <span class="is-required">{{ column.label }}</span>
  318. </template>
  319. <!-- 操作列 -->
  320. <template v-slot:action="{ row }">
  321. <el-popconfirm
  322. class="ele-action"
  323. title="确定要删除吗?"
  324. @confirm="remove(row)"
  325. >
  326. <template v-slot:reference>
  327. <el-link type="danger" :underline="false" icon="el-icon-delete">
  328. 删除
  329. </el-link>
  330. </template>
  331. </el-popconfirm>
  332. </template>
  333. </ele-pro-table>
  334. </template>
  335. <product-list
  336. ref="productListRef"
  337. classType="1"
  338. @changeParent="changeParent"
  339. ></product-list>
  340. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  341. </el-form>
  342. </template>
  343. <script>
  344. import { numberReg } from 'ele-admin';
  345. import productList from '@/views/bpm/handleTask/components/quotation/product-list.vue';
  346. import dictMixins from '@/mixins/dictMixins';
  347. import fileUpload from '@/components/upload/fileUpload';
  348. import headList from '@/components/headList';
  349. // import fileMain from "@/components/addDoc/index.vue";
  350. const dayjs = require('dayjs');
  351. export default {
  352. mixins: [dictMixins],
  353. components: {
  354. // fileMain,
  355. productList,
  356. fileUpload,
  357. headList
  358. },
  359. data() {
  360. const defaultForm = {
  361. key: null,
  362. endTime: '',
  363. isFirst: 0,
  364. name: '',
  365. startTime: '',
  366. workHour: '',
  367. technicalDrawings: []
  368. };
  369. return {
  370. discountTotalPrice: 0.0,
  371. allPrice: 0.0,
  372. numberReg,
  373. defaultForm,
  374. form: {
  375. datasource: []
  376. },
  377. rules: {},
  378. competAnalysisListcolumns: [
  379. {
  380. width: 45,
  381. type: 'index',
  382. columnKey: 'index',
  383. align: 'center',
  384. fixed: 'left'
  385. },
  386. {
  387. width: 200,
  388. prop: 'productName',
  389. label: '名称',
  390. slot: 'productName'
  391. },
  392. {
  393. width: 120,
  394. prop: 'productCode',
  395. label: '编码',
  396. slot: 'productCode'
  397. },
  398. {
  399. width: 200,
  400. prop: 'productCategoryName',
  401. label: '类型',
  402. slot: 'productCategoryName'
  403. },
  404. {
  405. width: 160,
  406. prop: 'productBrand',
  407. label: '牌号',
  408. slot: 'productBrand'
  409. },
  410. {
  411. width: 120,
  412. prop: 'modelType',
  413. label: '型号',
  414. slot: 'modelType'
  415. },
  416. {
  417. width: 120,
  418. prop: 'specification',
  419. label: '规格',
  420. slot: 'specification'
  421. },
  422. {
  423. width: 160,
  424. prop: 'singlePrice',
  425. label: '单价',
  426. slot: 'singlePrice'
  427. },
  428. {
  429. width: 160,
  430. prop: 'discountSinglePrice',
  431. label: '折让单价',
  432. slot: 'discountSinglePrice'
  433. },
  434. {
  435. width: 120,
  436. prop: 'totalCount',
  437. label: '数量',
  438. slot: 'totalCount'
  439. },
  440. {
  441. width: 120,
  442. prop: 'totalPrice',
  443. label: '合计',
  444. slot: 'totalPrice',
  445. formatter: (_row, _column, cellValue) => {
  446. return _row.totalPrice + '元';
  447. }
  448. },
  449. {
  450. width: 120,
  451. prop: 'discountTotalPrice',
  452. label: '折让合计',
  453. slot: 'discountTotalPrice',
  454. formatter: (_row, _column, cellValue) => {
  455. return _row.discountTotalPrice + '元';
  456. }
  457. },
  458. {
  459. width: 120,
  460. prop: 'measuringUnit',
  461. label: '计量单位',
  462. slot: 'measuringUnit'
  463. },
  464. {
  465. width: 120,
  466. prop: 'deliveryDays',
  467. label: '交期(天)',
  468. slot: 'deliveryDays'
  469. },
  470. {
  471. width: 160,
  472. prop: 'deliveryDeadline',
  473. label: '交期截止日期',
  474. slot: 'deliveryDeadline'
  475. },
  476. {
  477. width: 200,
  478. prop: 'guaranteePeriod',
  479. label: '有效期',
  480. slot: 'guaranteePeriod',
  481. formatter: (_row, _column, cellValue) => {
  482. return (_row.guaranteePeriod||'') + _row.guaranteePeriodUnitName;
  483. }
  484. },
  485. {
  486. width: 160,
  487. prop: 'guaranteePeriodDeadline',
  488. label: '有效期截止日期',
  489. slot: 'guaranteePeriodDeadline'
  490. },
  491. // {
  492. // width: 120,
  493. // prop: 'guaranteePeriodUnitCode',
  494. // label: '',
  495. // slot: 'guaranteePeriodUnitCode'
  496. // },
  497. {
  498. width: 240,
  499. prop: 'customerReqFiles',
  500. label: '客户需求',
  501. slot: 'customerReqFiles'
  502. },
  503. {
  504. width: 120,
  505. prop: 'technicalAnswerName',
  506. label: '技术答疑人',
  507. slot: 'technicalAnswerName'
  508. },
  509. {
  510. width: 220,
  511. prop: 'technicalParams',
  512. label: '技术参数',
  513. slot: 'technicalParams'
  514. },
  515. {
  516. width: 240,
  517. prop: 'technicalDrawings',
  518. label: '技术图纸',
  519. slot: 'technicalDrawings',
  520. formatter: (_row, _column, cellValue) => {
  521. return (_row.guaranteePeriod||'') + _row.guaranteePeriodUnitName;
  522. }
  523. },
  524. {
  525. width: 220,
  526. prop: 'remark',
  527. label: '备注',
  528. slot: 'remark'
  529. }
  530. ],
  531. columns: [
  532. {
  533. width: 45,
  534. type: 'index',
  535. columnKey: 'index',
  536. align: 'center',
  537. fixed: 'left'
  538. },
  539. {
  540. width: 200,
  541. prop: 'productName',
  542. label: '名称',
  543. slot: 'productName',
  544. headerSlot: 'headerProductName'
  545. },
  546. {
  547. width: 120,
  548. prop: 'productCode',
  549. label: '编码',
  550. slot: 'productCode'
  551. },
  552. {
  553. width: 200,
  554. prop: 'productCategoryName',
  555. label: '类型',
  556. slot: 'productCategoryName'
  557. },
  558. {
  559. width: 160,
  560. prop: 'productBrand',
  561. label: '牌号',
  562. slot: 'productBrand'
  563. },
  564. {
  565. width: 120,
  566. prop: 'modelType',
  567. label: '型号',
  568. slot: 'modelType'
  569. },
  570. {
  571. width: 120,
  572. prop: 'specification',
  573. label: '规格',
  574. slot: 'specification'
  575. },
  576. {
  577. width: 80,
  578. prop: 'totalCount',
  579. label: '数量',
  580. slot: 'totalCount',
  581. headerSlot: 'headerTotalCount'
  582. },
  583. {
  584. width: 80,
  585. prop: 'measuringUnit',
  586. label: '计量单位',
  587. slot: 'measuringUnit'
  588. },
  589. {
  590. width: 160,
  591. prop: 'singlePrice',
  592. label: '单价',
  593. slot: 'singlePrice',
  594. headerSlot: 'headerSinglePrice'
  595. },
  596. {
  597. width: 120,
  598. prop: 'totalPrice',
  599. label: '合计',
  600. slot: 'totalPrice'
  601. },
  602. {
  603. width: 80,
  604. prop: 'deliveryDays',
  605. label: '交期(天)',
  606. slot: 'deliveryDays'
  607. },
  608. {
  609. width: 160,
  610. prop: 'deliveryDeadline',
  611. label: '交期截止日期',
  612. slot: 'deliveryDeadline'
  613. },
  614. {
  615. width: 200,
  616. prop: 'guaranteePeriod',
  617. label: '有效期',
  618. slot: 'guaranteePeriod'
  619. },
  620. {
  621. width: 160,
  622. prop: 'guaranteePeriodDeadline',
  623. label: '有效期截止日期',
  624. slot: 'guaranteePeriodDeadline'
  625. },
  626. // {
  627. // width: 120,
  628. // prop: 'guaranteePeriodUnitCode',
  629. // label: '',
  630. // slot: 'guaranteePeriodUnitCode'
  631. // },
  632. {
  633. width: 240,
  634. prop: 'customerReqFiles',
  635. label: '客户需求',
  636. slot: 'customerReqFiles'
  637. },
  638. {
  639. width: 130,
  640. prop: 'technicalAnswerName',
  641. label: '技术答疑人',
  642. slot: 'technicalAnswerName'
  643. },
  644. {
  645. width: 220,
  646. prop: 'technicalParams',
  647. label: '技术参数',
  648. slot: 'technicalParams'
  649. },
  650. {
  651. width: 240,
  652. prop: 'technicalDrawings',
  653. label: '技术图纸',
  654. slot: 'technicalDrawings'
  655. },
  656. {
  657. width: 220,
  658. prop: 'remark',
  659. label: '备注',
  660. slot: 'remark'
  661. },
  662. {
  663. columnKey: 'action',
  664. label: '操作',
  665. width: 120,
  666. align: 'center',
  667. resizable: false,
  668. slot: 'action',
  669. fixed: 'right',
  670. showOverflowTooltip: true
  671. }
  672. ]
  673. };
  674. },
  675. computed: {
  676. canHandl() {
  677. return this.form.datasource.length;
  678. },
  679. contractId() {
  680. return this.$store.state.order.contractId;
  681. }
  682. },
  683. methods: {
  684. // 返回列表数据
  685. getTableValue() {
  686. let comitDatasource = this.form.datasource;
  687. if (comitDatasource.length === 0) return [];
  688. comitDatasource.forEach((v) => {
  689. v.totalPrice = (v.totalCount * v.singlePrice)?.toFixed(2) || 0;
  690. v.guaranteePeriodUnitName = this.getDictValue(
  691. '质保期单位',
  692. v.guaranteePeriodUnitCode
  693. );
  694. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  695. ? v.technicalDrawings
  696. : [];
  697. v.customerReqFiles = Array.isArray(v.customerReqFiles)
  698. ? v.customerReqFiles
  699. : [];
  700. });
  701. return comitDatasource;
  702. },
  703. getPrice() {
  704. return [this.allPrice];
  705. },
  706. //计算总金额
  707. getTotalPrice() {
  708. if (this.form.datasource.length) {
  709. let datasource = this.form.datasource,
  710. sum = 0;
  711. datasource.forEach((r) => {
  712. if (r.singlePrice && r.totalCount) {
  713. sum += r.singlePrice * r.totalCount;
  714. }
  715. });
  716. let allsum = sum.toFixed(2);
  717. this.allPrice = allsum;
  718. this.$store.commit('order/setAllcountAmount', allsum);
  719. } else {
  720. this.allPrice = 0.0;
  721. }
  722. },
  723. setDeliveryDays(row, index, type) {
  724. if (type == 'deliveryDays') {
  725. this.$set(
  726. this.form.datasource[index],
  727. 'deliveryDeadline',
  728. this.setDay(row.deliveryDays)
  729. );
  730. }
  731. if (type == 'guaranteePeriod') {
  732. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  733. row.guaranteePeriodUnitCode
  734. );
  735. console.log(guaranteePeriodUnitName,'=======================');
  736. this.$set(
  737. this.form.datasource[index],
  738. 'guaranteePeriodDeadline',
  739. guaranteePeriodUnitName != 'second'
  740. ? this.setDay(row.guaranteePeriod, guaranteePeriodUnitName)
  741. : ''
  742. );
  743. }
  744. },
  745. guaranteePeriodUnit(code) {
  746. return code == 3
  747. ? 'day'
  748. : code == 4
  749. ? 'month'
  750. : code == 5
  751. ? 'year'
  752. : 'second';
  753. },
  754. setDay(addDay, dateType = 'day') {
  755. return dayjs(new Date()).add(addDay, dateType).format('YYYY-MM-DD');
  756. },
  757. //修改回显
  758. putTableValue(data) {
  759. if (data) {
  760. this.form.datasource = data;
  761. }
  762. },
  763. //选择产品
  764. handParent(row, index) {
  765. let item = {
  766. id: row.productCode
  767. };
  768. this.$refs.productListRef.open(item, index);
  769. },
  770. //选择技术人回调
  771. changeAnswer(obj, idx) {
  772. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  773. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  774. },
  775. handHead(row, index) {
  776. let item = {
  777. id: row.technicalAnswerId
  778. };
  779. this.$refs.headRef.open(item, index);
  780. },
  781. //选择产品回调
  782. changeParent(obj, idx) {
  783. console.log(obj, '33333');
  784. this.$set(this.form.datasource[idx], 'categoryName', obj.name);
  785. this.$set(
  786. this.form.datasource[idx],
  787. 'productCategoryId',
  788. obj.categoryLevelId
  789. );
  790. this.$set(this.form.datasource[idx], 'productBrand', obj.brandNum);
  791. this.$set(
  792. this.form.datasource[idx],
  793. 'productCategoryName',
  794. obj.categoryLevelPath
  795. );
  796. this.$set(this.form.datasource[idx], 'productCode', obj.code);
  797. this.$set(this.form.datasource[idx], 'productName', obj.name);
  798. this.$set(this.form.datasource[idx], 'modelType', obj.modelType);
  799. this.$set(
  800. this.form.datasource[idx],
  801. 'measuringUnit',
  802. obj.measuringUnit
  803. );
  804. this.$set(
  805. this.form.datasource[idx],
  806. 'specification',
  807. obj.specification
  808. );
  809. },
  810. remove(row) {
  811. let index = this.form.datasource.findIndex((n) => n.key == row.key);
  812. if (index !== -1) {
  813. this.form.datasource.splice(index, 1);
  814. this.setSort();
  815. }
  816. },
  817. // 清空表格
  818. restTable() {
  819. this.form.datasource = [];
  820. },
  821. // 重新排序
  822. setSort() {
  823. this.form.datasource.forEach((n, index) => {
  824. n.key = index + 1;
  825. });
  826. },
  827. // 添加
  828. handlAdd() {
  829. let item = JSON.parse(JSON.stringify(this.defaultForm));
  830. item.key = this.form.datasource.length + 1;
  831. this.form.datasource.push(item);
  832. },
  833. validateForm(callback) {
  834. //开始表单校验
  835. this.$refs.form.validate((valid) => {
  836. callback(valid);
  837. });
  838. }
  839. }
  840. };
  841. </script>
  842. <style lang="scss" scoped>
  843. .headbox {
  844. display: flex;
  845. justify-content: space-between;
  846. align-items: center;
  847. .amount {
  848. font-size: 14px;
  849. font-weight: bold;
  850. padding-right: 30px;
  851. }
  852. }
  853. .time-form .el-form-item {
  854. margin-bottom: 0 !important;
  855. }
  856. ::v-deep .period {
  857. display: flex;
  858. .borderleftnone {
  859. .el-input--medium .el-input__inner {
  860. border-top-right-radius: 0;
  861. border-bottom-right-radius: 0;
  862. }
  863. }
  864. .borderrightnone {
  865. .el-input--medium .el-input__inner {
  866. border-top-left-radius: 0;
  867. border-bottom-left-radius: 0;
  868. }
  869. }
  870. }
  871. ::v-deep .time-form tbody > tr:hover > td {
  872. background-color: transparent !important;
  873. }
  874. ::v-deep .time-form .el-table tr {
  875. background-color: #ffffff;
  876. }
  877. .pricebox {
  878. display: flex;
  879. justify-content: flex-start;
  880. align-items: center;
  881. font-weight: bold;
  882. }
  883. </style>