inventoryTable.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  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. <fileUpload
  262. v-model="scope.row.technicalDrawings"
  263. module="main"
  264. :showLib="false"
  265. :limit="5"
  266. />
  267. </el-form-item>
  268. </template>
  269. <template v-slot:customerReqFiles="scope">
  270. <el-form-item
  271. style="margin-bottom: 20px"
  272. :prop="'datasource.' + scope.$index + '.customerReqFiles'"
  273. >
  274. <fileUpload
  275. v-model="scope.row.customerReqFiles"
  276. module="main"
  277. :showLib="false"
  278. :limit="5"
  279. />
  280. </el-form-item>
  281. </template>
  282. <template v-slot:guaranteePeriodDeadline="scope">
  283. <el-form-item
  284. :prop="'datasource.' + scope.$index + '.guaranteePeriodDeadline'"
  285. >
  286. <el-date-picker
  287. style="width: 140px"
  288. v-model="scope.row.guaranteePeriodDeadline"
  289. type="date"
  290. placeholder="选择日期"
  291. >
  292. </el-date-picker>
  293. </el-form-item>
  294. </template>
  295. <template v-slot:deliveryDeadline="scope">
  296. <el-form-item
  297. :prop="'datasource.' + scope.$index + '.deliveryDeadline'"
  298. >
  299. <el-date-picker
  300. style="width: 140px"
  301. v-model="scope.row.deliveryDeadline"
  302. type="date"
  303. placeholder="选择日期"
  304. >
  305. </el-date-picker>
  306. </el-form-item>
  307. </template>
  308. <template v-slot:headerProductName="{ column }">
  309. <span class="is-required">{{ column.label }}</span>
  310. </template>
  311. <template v-slot:headerTotalCount="{ column }">
  312. <span class="is-required">{{ column.label }}</span>
  313. </template>
  314. <template v-slot:headerSinglePrice="{ column }">
  315. <span class="is-required">{{ column.label }}</span>
  316. </template>
  317. <!-- 操作列 -->
  318. <template v-slot:action="{ row }">
  319. <el-popconfirm
  320. class="ele-action"
  321. title="确定要删除吗?"
  322. @confirm="remove(row)"
  323. >
  324. <template v-slot:reference>
  325. <el-link type="danger" :underline="false" icon="el-icon-delete">
  326. 删除
  327. </el-link>
  328. </template>
  329. </el-popconfirm>
  330. </template>
  331. </ele-pro-table>
  332. </template>
  333. <product-list
  334. ref="productListRef"
  335. classType="1"
  336. @changeParent="changeParent"
  337. ></product-list>
  338. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  339. </el-form>
  340. </template>
  341. <script>
  342. import { numberReg } from 'ele-admin';
  343. import productList from '@/views/bpm/handleTask/components/quotation/product-list.vue';
  344. import dictMixins from '@/mixins/dictMixins';
  345. import fileUpload from '@/components/upload/fileUpload';
  346. import headList from '@/components/headList';
  347. const dayjs = require('dayjs');
  348. export default {
  349. mixins: [dictMixins],
  350. components: {
  351. productList,
  352. fileUpload,
  353. headList
  354. },
  355. data() {
  356. const defaultForm = {
  357. key: null,
  358. endTime: '',
  359. isFirst: 0,
  360. name: '',
  361. startTime: '',
  362. workHour: '',
  363. technicalDrawings: []
  364. };
  365. return {
  366. discountTotalPrice: 0.0,
  367. allPrice: 0.0,
  368. numberReg,
  369. defaultForm,
  370. form: {
  371. datasource: []
  372. },
  373. rules: {},
  374. competAnalysisListcolumns: [
  375. {
  376. width: 45,
  377. type: 'index',
  378. columnKey: 'index',
  379. align: 'center',
  380. fixed: 'left'
  381. },
  382. {
  383. width: 200,
  384. prop: 'productName',
  385. label: '名称',
  386. slot: 'productName'
  387. },
  388. {
  389. width: 120,
  390. prop: 'productCode',
  391. label: '编码',
  392. slot: 'productCode'
  393. },
  394. {
  395. width: 200,
  396. prop: 'productCategoryName',
  397. label: '类型',
  398. slot: 'productCategoryName'
  399. },
  400. {
  401. width: 160,
  402. prop: 'productBrand',
  403. label: '牌号',
  404. slot: 'productBrand'
  405. },
  406. {
  407. width: 120,
  408. prop: 'modelType',
  409. label: '型号',
  410. slot: 'modelType'
  411. },
  412. {
  413. width: 120,
  414. prop: 'specification',
  415. label: '规格',
  416. slot: 'specification'
  417. },
  418. {
  419. width: 160,
  420. prop: 'singlePrice',
  421. label: '单价',
  422. slot: 'singlePrice'
  423. },
  424. {
  425. width: 120,
  426. prop: 'totalCount',
  427. label: '数量',
  428. slot: 'totalCount'
  429. },
  430. {
  431. width: 120,
  432. prop: 'totalPrice',
  433. label: '销售总金额',
  434. slot: 'totalPrice',
  435. formatter: (_row, _column, cellValue) => {
  436. return _row.totalPrice + '元';
  437. }
  438. },
  439. {
  440. width: 120,
  441. prop: 'measuringUnit',
  442. label: '计量单位',
  443. slot: 'measuringUnit'
  444. },
  445. {
  446. width: 120,
  447. prop: 'deliveryDays',
  448. label: '交期(天)',
  449. slot: 'deliveryDays'
  450. },
  451. {
  452. width: 160,
  453. prop: 'deliveryDeadline',
  454. label: '交期截止日期',
  455. slot: 'deliveryDeadline'
  456. },
  457. {
  458. width: 200,
  459. prop: 'guaranteePeriod',
  460. label: '质保期',
  461. slot: 'guaranteePeriod',
  462. formatter: (_row, _column, cellValue) => {
  463. return (_row.guaranteePeriod||'') + _row.guaranteePeriodUnitName;
  464. }
  465. },
  466. {
  467. width: 160,
  468. prop: 'guaranteePeriodDeadline',
  469. label: '质保截止日期',
  470. slot: 'guaranteePeriodDeadline'
  471. },
  472. // {
  473. // width: 120,
  474. // prop: 'guaranteePeriodUnitCode',
  475. // label: '',
  476. // slot: 'guaranteePeriodUnitCode'
  477. // },
  478. {
  479. width: 240,
  480. prop: 'customerReqFiles',
  481. label: '客户需求',
  482. slot: 'customerReqFiles'
  483. },
  484. {
  485. width: 120,
  486. prop: 'technicalAnswerName',
  487. label: '技术答疑人',
  488. slot: 'technicalAnswerName'
  489. },
  490. {
  491. width: 220,
  492. prop: 'technicalParams',
  493. label: '技术参数',
  494. slot: 'technicalParams'
  495. },
  496. {
  497. width: 240,
  498. prop: 'technicalDrawings',
  499. label: '技术图纸',
  500. slot: 'technicalDrawings',
  501. formatter: (_row, _column, cellValue) => {
  502. return (_row.guaranteePeriod||'') + _row.guaranteePeriodUnitName;
  503. }
  504. },
  505. {
  506. width: 220,
  507. prop: 'remark',
  508. label: '备注',
  509. slot: 'remark'
  510. }
  511. ],
  512. columns: [
  513. {
  514. width: 45,
  515. type: 'index',
  516. columnKey: 'index',
  517. align: 'center',
  518. fixed: 'left'
  519. },
  520. {
  521. width: 200,
  522. prop: 'productName',
  523. label: '名称',
  524. slot: 'productName',
  525. headerSlot: 'headerProductName'
  526. },
  527. {
  528. width: 120,
  529. prop: 'productCode',
  530. label: '编码',
  531. slot: 'productCode'
  532. },
  533. {
  534. width: 200,
  535. prop: 'productCategoryName',
  536. label: '类型',
  537. slot: 'productCategoryName'
  538. },
  539. {
  540. width: 160,
  541. prop: 'productBrand',
  542. label: '牌号',
  543. slot: 'productBrand'
  544. },
  545. {
  546. width: 120,
  547. prop: 'modelType',
  548. label: '型号',
  549. slot: 'modelType'
  550. },
  551. {
  552. width: 120,
  553. prop: 'specification',
  554. label: '规格',
  555. slot: 'specification'
  556. },
  557. {
  558. width: 80,
  559. prop: 'totalCount',
  560. label: '数量',
  561. slot: 'totalCount',
  562. headerSlot: 'headerTotalCount'
  563. },
  564. {
  565. width: 80,
  566. prop: 'measuringUnit',
  567. label: '计量单位',
  568. slot: 'measuringUnit'
  569. },
  570. {
  571. width: 160,
  572. prop: 'singlePrice',
  573. label: '单价',
  574. slot: 'singlePrice',
  575. headerSlot: 'headerSinglePrice'
  576. },
  577. {
  578. width: 120,
  579. prop: 'totalPrice',
  580. label: '合计',
  581. slot: 'totalPrice'
  582. },
  583. {
  584. width: 80,
  585. prop: 'deliveryDays',
  586. label: '交期(天)',
  587. slot: 'deliveryDays'
  588. },
  589. {
  590. width: 160,
  591. prop: 'deliveryDeadline',
  592. label: '交期截止日期',
  593. slot: 'deliveryDeadline'
  594. },
  595. {
  596. width: 200,
  597. prop: 'guaranteePeriod',
  598. label: '质保期',
  599. slot: 'guaranteePeriod'
  600. },
  601. {
  602. width: 160,
  603. prop: 'guaranteePeriodDeadline',
  604. label: '质保截止日期',
  605. slot: 'guaranteePeriodDeadline'
  606. },
  607. // {
  608. // width: 120,
  609. // prop: 'guaranteePeriodUnitCode',
  610. // label: '',
  611. // slot: 'guaranteePeriodUnitCode'
  612. // },
  613. {
  614. width: 240,
  615. prop: 'customerReqFiles',
  616. label: '客户需求',
  617. slot: 'customerReqFiles'
  618. },
  619. {
  620. width: 130,
  621. prop: 'technicalAnswerName',
  622. label: '技术答疑人',
  623. slot: 'technicalAnswerName'
  624. },
  625. {
  626. width: 220,
  627. prop: 'technicalParams',
  628. label: '技术参数',
  629. slot: 'technicalParams'
  630. },
  631. {
  632. width: 240,
  633. prop: 'technicalDrawings',
  634. label: '技术图纸',
  635. slot: 'technicalDrawings'
  636. },
  637. {
  638. width: 220,
  639. prop: 'remark',
  640. label: '备注',
  641. slot: 'remark'
  642. },
  643. {
  644. columnKey: 'action',
  645. label: '操作',
  646. width: 120,
  647. align: 'center',
  648. resizable: false,
  649. slot: 'action',
  650. fixed: 'right',
  651. showOverflowTooltip: true
  652. }
  653. ]
  654. };
  655. },
  656. computed: {
  657. canHandl() {
  658. return this.form.datasource.length;
  659. },
  660. contractId() {
  661. return this.$store.state.order.contractId;
  662. }
  663. },
  664. methods: {
  665. // 返回列表数据
  666. getTableValue() {
  667. let comitDatasource = this.form.datasource;
  668. if (comitDatasource.length === 0) return [];
  669. comitDatasource.forEach((v) => {
  670. v.totalPrice = (v.totalCount * v.singlePrice)?.toFixed(2) || 0;
  671. v.guaranteePeriodUnitName = this.getDictValue(
  672. '质保期单位',
  673. v.guaranteePeriodUnitCode
  674. );
  675. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  676. ? v.technicalDrawings
  677. : [];
  678. v.customerReqFiles = Array.isArray(v.customerReqFiles)
  679. ? v.customerReqFiles
  680. : [];
  681. });
  682. return comitDatasource;
  683. },
  684. getPrice() {
  685. return [this.allPrice];
  686. },
  687. //计算总金额
  688. getTotalPrice() {
  689. if (this.form.datasource.length) {
  690. let datasource = this.form.datasource,
  691. sum = 0;
  692. datasource.forEach((r) => {
  693. if (r.singlePrice && r.totalCount) {
  694. sum += r.singlePrice * r.totalCount;
  695. }
  696. });
  697. let allsum = sum.toFixed(2);
  698. this.allPrice = allsum;
  699. this.$store.commit('order/setAllcountAmount', allsum);
  700. } else {
  701. this.allPrice = 0.0;
  702. }
  703. },
  704. setDeliveryDays(row, index, type) {
  705. if (type == 'deliveryDays') {
  706. this.$set(
  707. this.form.datasource[index],
  708. 'deliveryDeadline',
  709. this.setDay(row.deliveryDays)
  710. );
  711. }
  712. if (type == 'guaranteePeriod') {
  713. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  714. row.guaranteePeriodUnitCode
  715. );
  716. console.log(guaranteePeriodUnitName,'=======================');
  717. this.$set(
  718. this.form.datasource[index],
  719. 'guaranteePeriodDeadline',
  720. guaranteePeriodUnitName != 'second'
  721. ? this.setDay(row.guaranteePeriod, guaranteePeriodUnitName)
  722. : ''
  723. );
  724. }
  725. },
  726. guaranteePeriodUnit(code) {
  727. return code == 3
  728. ? 'day'
  729. : code == 4
  730. ? 'month'
  731. : code == 5
  732. ? 'year'
  733. : 'second';
  734. },
  735. setDay(addDay, dateType = 'day') {
  736. return dayjs(new Date()).add(addDay, dateType).format('YYYY-MM-DD');
  737. },
  738. //修改回显
  739. putTableValue(data) {
  740. if (data) {
  741. this.form.datasource = data;
  742. }
  743. },
  744. //选择产品
  745. handParent(row, index) {
  746. let item = {
  747. id: row.productCode
  748. };
  749. this.$refs.productListRef.open(item, index);
  750. },
  751. //选择技术人回调
  752. changeAnswer(obj, idx) {
  753. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  754. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  755. },
  756. handHead(row, index) {
  757. let item = {
  758. id: row.technicalAnswerId
  759. };
  760. this.$refs.headRef.open(item, index);
  761. },
  762. //选择产品回调
  763. changeParent(obj, idx) {
  764. console.log(obj, '33333');
  765. this.$set(this.form.datasource[idx], 'categoryName', obj.name);
  766. this.$set(
  767. this.form.datasource[idx],
  768. 'productCategoryId',
  769. obj.categoryLevelId
  770. );
  771. this.$set(this.form.datasource[idx], 'productBrand', obj.brandNum);
  772. this.$set(
  773. this.form.datasource[idx],
  774. 'productCategoryName',
  775. obj.categoryLevelPath
  776. );
  777. this.$set(this.form.datasource[idx], 'productCode', obj.code);
  778. this.$set(this.form.datasource[idx], 'productName', obj.name);
  779. this.$set(this.form.datasource[idx], 'modelType', obj.modelType);
  780. this.$set(
  781. this.form.datasource[idx],
  782. 'measuringUnit',
  783. obj.measuringUnit
  784. );
  785. this.$set(
  786. this.form.datasource[idx],
  787. 'specification',
  788. obj.specification
  789. );
  790. },
  791. remove(row) {
  792. let index = this.form.datasource.findIndex((n) => n.key == row.key);
  793. if (index !== -1) {
  794. this.form.datasource.splice(index, 1);
  795. this.setSort();
  796. }
  797. },
  798. // 清空表格
  799. restTable() {
  800. this.form.datasource = [];
  801. },
  802. // 重新排序
  803. setSort() {
  804. this.form.datasource.forEach((n, index) => {
  805. n.key = index + 1;
  806. });
  807. },
  808. // 添加
  809. handlAdd() {
  810. let item = JSON.parse(JSON.stringify(this.defaultForm));
  811. item.key = this.form.datasource.length + 1;
  812. this.form.datasource.push(item);
  813. },
  814. validateForm(callback) {
  815. //开始表单校验
  816. this.$refs.form.validate((valid) => {
  817. callback(valid);
  818. });
  819. }
  820. }
  821. };
  822. </script>
  823. <style lang="scss" scoped>
  824. .headbox {
  825. display: flex;
  826. justify-content: space-between;
  827. align-items: center;
  828. .amount {
  829. font-size: 14px;
  830. font-weight: bold;
  831. padding-right: 30px;
  832. }
  833. }
  834. .time-form .el-form-item {
  835. margin-bottom: 0 !important;
  836. }
  837. ::v-deep .period {
  838. display: flex;
  839. .borderleftnone {
  840. .el-input--medium .el-input__inner {
  841. border-top-right-radius: 0;
  842. border-bottom-right-radius: 0;
  843. }
  844. }
  845. .borderrightnone {
  846. .el-input--medium .el-input__inner {
  847. border-top-left-radius: 0;
  848. border-bottom-left-radius: 0;
  849. }
  850. }
  851. }
  852. ::v-deep .time-form tbody > tr:hover > td {
  853. background-color: transparent !important;
  854. }
  855. ::v-deep .time-form .el-table tr {
  856. background-color: #ffffff;
  857. }
  858. .pricebox {
  859. display: flex;
  860. justify-content: flex-start;
  861. align-items: center;
  862. font-weight: bold;
  863. }
  864. </style>