inquiryTable.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. <template>
  2. <el-form :model="form" ref="form">
  3. <el-row
  4. type="flex"
  5. justify="space-between"
  6. align="middle"
  7. style="margin-top: 20px; margin-bottom: 10px"
  8. >
  9. <el-row type="flex" align="middle">
  10. <h4>供应商:{{ form.supplierName }}</h4>
  11. </el-row>
  12. <el-row type="flex" align="end">
  13. <el-radio
  14. v-model="radio1"
  15. @input="changeValue"
  16. :label="form.supplierId"
  17. style="margin-right;: 10px"
  18. :disabled="status == 'Detail'"
  19. >是否中标</el-radio
  20. >
  21. <el-popconfirm
  22. class="ele-action"
  23. title="确定要删除吗?"
  24. @confirm="removeSupplier"
  25. :disabled="status == 'Detail'"
  26. >
  27. <template v-slot:reference>
  28. <el-link type="danger" :underline="false" icon="el-icon-delete">
  29. 删除
  30. </el-link>
  31. </template>
  32. </el-popconfirm>
  33. </el-row>
  34. </el-row>
  35. <ele-pro-table
  36. ref="table"
  37. :needPage="false"
  38. :columns="columns"
  39. :toolkit="[]"
  40. :datasource="form.resultList"
  41. cache-key="systemRoleTable17"
  42. class="time-form"
  43. >
  44. <!-- 表头工具栏 -->
  45. <template v-slot:toolbar>
  46. <div class="headbox">
  47. <div>
  48. <el-row>
  49. <!-- <el-col :span="12" style="margin-bottom: 22px">
  50. <el-form-item
  51. label="供应商"
  52. prop="supplierName"
  53. label-width="120px"
  54. >
  55. <el-input disabled v-model="form.supplierName"></el-input>
  56. </el-form-item>
  57. </el-col> -->
  58. <el-col :span="12" style="margin-bottom: 22px">
  59. <el-form-item
  60. prop="supplierCode"
  61. label="编码"
  62. label-width="120px"
  63. >
  64. <el-input v-model="form.supplierCode" disabled></el-input>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="12" style="margin-bottom: 22px">
  68. <el-form-item
  69. label-width="120px"
  70. prop="settlementMode"
  71. label="结算方式"
  72. :rules="{
  73. required: true,
  74. message: '请选择结算方式',
  75. trigger: 'blur'
  76. }"
  77. >
  78. <DictSelection
  79. dictName="结算方式"
  80. clearable
  81. v-model="form.settlementMode"
  82. @itemChange="chaengMode"
  83. :disabled="status == 'Detail'"
  84. >
  85. </DictSelection>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="12" style="margin-bottom: 22px">
  89. <el-form-item
  90. label-width="120px"
  91. prop="totalPrice"
  92. label="总价"
  93. :rules="{
  94. required: true,
  95. trigger: 'blur'
  96. }"
  97. >
  98. <el-input v-model="form.totalPrice" disabled>
  99. <template slot="suffix">元</template>
  100. </el-input>
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="12" style="margin-bottom: 22px">
  104. <el-form-item
  105. label-width="120px"
  106. prop="preferentialPrice"
  107. style="margin-bottom: 22px"
  108. label="优惠价"
  109. :rules="{
  110. required: true,
  111. message: '请输入优惠价',
  112. trigger: 'blur'
  113. }"
  114. >
  115. <el-input
  116. v-model="form.preferentialPrice"
  117. :disabled="status == 'Detail'"
  118. ></el-input>
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="12" style="margin-bottom: 22px">
  122. <el-form-item prop="taxRate" label="税率" label-width="120px">
  123. <el-input
  124. v-model="form.taxRate"
  125. style="width: 100%"
  126. :disabled="status == 'Detail'"
  127. >
  128. <template slot="suffix">%</template>
  129. </el-input>
  130. </el-form-item>
  131. </el-col>
  132. <el-col :span="12" style="margin-bottom: 22px">
  133. <el-form-item
  134. label-width="120px"
  135. prop="deliveryDate"
  136. label="交货日期"
  137. :rules="{
  138. required: true,
  139. message: '请选择日期',
  140. trigger: 'blur'
  141. }"
  142. >
  143. <el-date-picker
  144. style="width: 100%"
  145. clearable
  146. type="date"
  147. :disabled="status == 'Detail'"
  148. v-model="form.deliveryDate"
  149. value-format="yyyy-MM-dd"
  150. placeholder="请选择日期"
  151. >
  152. </el-date-picker>
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="12" style="margin-bottom: 22px">
  156. <el-form-item label-width="120px" prop="files" label="附件">
  157. <fileUpload
  158. v-if="status != 'Detail'"
  159. v-model="form.files"
  160. module="main"
  161. :showLib="false"
  162. :limit="5"
  163. />
  164. <div
  165. v-if="
  166. form.files && form.files?.length && status == 'Detail'
  167. "
  168. >
  169. <el-link
  170. v-for="link in form.files"
  171. :key="link.id"
  172. type="primary"
  173. :underline="false"
  174. @click="downloadFile(link)"
  175. >
  176. {{ link.name }}</el-link
  177. >
  178. </div>
  179. </el-form-item>
  180. </el-col>
  181. </el-row>
  182. </div>
  183. </div>
  184. </template>
  185. <template v-slot:supplierProductName="{ row, $index }">
  186. <el-form-item
  187. style="margin-bottom: 20px"
  188. :prop="'resultList.' + $index + '.supplierProductName'"
  189. :rules="{
  190. required: true,
  191. message: '请输入',
  192. trigger: 'change'
  193. }"
  194. >
  195. <el-input
  196. v-model="row.supplierProductName"
  197. placeholder="请输入"
  198. :disabled="status == 'Detail'"
  199. ></el-input>
  200. </el-form-item>
  201. </template>
  202. <!-- <template v-slot:productCode="scope">
  203. <el-form-item
  204. style="margin-bottom: 20px"
  205. :prop="'resultList.' + scope.$index + '.productCode'"
  206. :rules="{
  207. required: true,
  208. message: '请输入',
  209. trigger: 'change'
  210. }"
  211. >
  212. <el-input v-model="scope.row.productCode" disabled></el-input>
  213. </el-form-item>
  214. </template> -->
  215. <template v-slot:supplierProductCode="scope">
  216. <el-form-item
  217. style="margin-bottom: 20px"
  218. :prop="'resultList.' + scope.$index + '.supplierProductCode'"
  219. :rules="{
  220. required: false,
  221. message: '请输入',
  222. trigger: 'blur'
  223. }"
  224. >
  225. <el-input
  226. v-model="scope.row.supplierProductCode"
  227. :disabled="status == 'Detail'"
  228. ></el-input>
  229. </el-form-item>
  230. </template>
  231. <template v-slot:deliveryDays="scope">
  232. <el-form-item
  233. style="margin-bottom: 20px"
  234. :prop="'resultList.' + scope.$index + '.deliveryDays'"
  235. >
  236. <el-input
  237. v-model="scope.row.deliveryDays"
  238. :disabled="status == 'Detail'"
  239. ></el-input>
  240. </el-form-item>
  241. </template>
  242. <template v-slot:guaranteePeriod="scope">
  243. <el-form-item
  244. style="margin-bottom: 20px"
  245. :prop="'resultList.' + scope.$index + '.guaranteePeriod'"
  246. >
  247. <el-input
  248. v-model="scope.row.guaranteePeriod"
  249. :disabled="status == 'Detail'"
  250. ></el-input>
  251. </el-form-item>
  252. </template>
  253. <template v-slot:guaranteePeriodUnitCode="scope">
  254. <el-form-item
  255. style="margin-bottom: 20px"
  256. :prop="'resultList.' + scope.$index + '.guaranteePeriodUnitCode'"
  257. >
  258. <DictSelection
  259. dictName="质保期单位"
  260. clearable
  261. v-model="scope.row.guaranteePeriodUnitCode"
  262. :disabled="status == 'Detail'"
  263. @itemChange="chaengUnitCode"
  264. >
  265. </DictSelection>
  266. </el-form-item>
  267. </template>
  268. <template v-slot:singlePrice="scope">
  269. <el-form-item
  270. style="margin-bottom: 20px"
  271. :prop="'resultList.' + scope.$index + '.singlePrice'"
  272. :rules="{
  273. required: true,
  274. message: '请输入',
  275. trigger: 'change'
  276. }"
  277. >
  278. <el-input
  279. v-model="scope.row.singlePrice"
  280. :disabled="status == 'Detail'"
  281. ></el-input>
  282. </el-form-item>
  283. </template>
  284. <template v-slot:totalCount="scope">
  285. <el-form-item
  286. style="margin-bottom: 20px"
  287. :prop="'resultList.' + scope.$index + '.totalCount'"
  288. :rules="{
  289. required: true,
  290. pattern: numberReg,
  291. message: '请输入数字',
  292. trigger: 'blur'
  293. }"
  294. >
  295. <el-input
  296. v-model="scope.row.totalCount"
  297. :disabled="status == 'Detail'"
  298. placeholder="请输入"
  299. ></el-input>
  300. </el-form-item>
  301. </template>
  302. <template v-slot:totalPrice="scope">
  303. <span>{{
  304. totalPrice(scope.row.totalCount, scope.row.singlePrice, scope.row)
  305. }}</span>
  306. </template>
  307. <template v-slot:modelType="scope">
  308. <el-form-item
  309. style="margin-bottom: 20px"
  310. :prop="'resultList.' + scope.$index + '.modelType'"
  311. >
  312. <el-input
  313. v-model="scope.row.modelType"
  314. :disabled="status == 'Detail'"
  315. ></el-input>
  316. </el-form-item>
  317. </template>
  318. <template v-slot:specification="scope">
  319. <el-form-item
  320. style="margin-bottom: 20px"
  321. :prop="'resultList.' + scope.$index + '.specification'"
  322. >
  323. <el-input
  324. v-model="scope.row.specification"
  325. :disabled="status == 'Detail'"
  326. ></el-input>
  327. </el-form-item>
  328. </template>
  329. <template v-slot:measuringUnit="scope">
  330. <el-form-item
  331. style="margin-bottom: 20px"
  332. :prop="'resultList.' + scope.$index + '.measuringUnit'"
  333. :rules="{
  334. required: false,
  335. message: '请输入',
  336. trigger: 'blur'
  337. }"
  338. >
  339. <el-input
  340. v-model="scope.row.measuringUnit"
  341. placeholder="请输入"
  342. :disabled="true"
  343. ></el-input>
  344. </el-form-item>
  345. </template>
  346. <template v-slot:remark="scope">
  347. <el-form-item
  348. style="margin-bottom: 20px"
  349. :prop="'resultList.' + scope.$index + '.remark'"
  350. >
  351. <el-input
  352. v-model="scope.row.remark"
  353. type="textarea"
  354. placeholder="请输入"
  355. :disabled="status == 'Detail'"
  356. ></el-input>
  357. </el-form-item>
  358. </template>
  359. <!-- <template v-slot:files="scope">
  360. <el-form-item prop="files">
  361. <fileUpload
  362. v-model="scope.row.files"
  363. module="main"
  364. :showLib="false"
  365. :limit="5"
  366. />
  367. </el-form-item>
  368. </template> -->
  369. </ele-pro-table>
  370. </el-form>
  371. </template>
  372. <script>
  373. import { numberReg } from 'ele-admin';
  374. import dictMixins from '@/mixins/dictMixins';
  375. import fileUpload from '@/components/upload/fileUpload';
  376. import { copyObj } from '@/utils/util';
  377. // import headList from '@/views/saleManage/businessOpportunity/components/headList.vue';
  378. const defaultColumns = [
  379. {
  380. width: 45,
  381. type: 'index',
  382. columnKey: 'index',
  383. align: 'center',
  384. fixed: 'left'
  385. },
  386. {
  387. width: 140,
  388. prop: 'productCode',
  389. label: '编码',
  390. slot: 'productCode',
  391. fixed: 'left'
  392. },
  393. {
  394. width: 200,
  395. prop: 'productName',
  396. label: '产品名称',
  397. slot: 'productName',
  398. fixed: 'left'
  399. },
  400. {
  401. width: 240,
  402. prop: 'supplierProductCode',
  403. label: '供应商产品编码',
  404. slot: 'supplierProductCode'
  405. },
  406. {
  407. width: 200,
  408. prop: 'supplierProductName',
  409. label: '供应商产品名称',
  410. slot: 'supplierProductName'
  411. },
  412. {
  413. width: 130,
  414. prop: 'modelType',
  415. label: '型号',
  416. slot: 'modelType'
  417. },
  418. {
  419. width: 120,
  420. prop: 'specification',
  421. label: '规格',
  422. slot: 'specification'
  423. },
  424. {
  425. width: 80,
  426. prop: 'totalCount',
  427. label: '购买数量',
  428. slot: 'totalCount'
  429. },
  430. {
  431. width: 120,
  432. prop: 'singlePrice',
  433. label: '销售单价(元)',
  434. slot: 'singlePrice'
  435. },
  436. {
  437. width: 150,
  438. prop: 'totalPrice',
  439. label: '销售金额(元)',
  440. slot: 'totalPrice'
  441. },
  442. {
  443. width: 100,
  444. prop: 'measuringUnit',
  445. label: '计量单位',
  446. slot: 'measuringUnit'
  447. },
  448. // {
  449. // width: 130,
  450. // prop: 'brand',
  451. // label: '品牌',
  452. // slot: 'brand'
  453. // },
  454. {
  455. width: 80,
  456. prop: 'deliveryDays',
  457. label: '交期(天)',
  458. slot: 'deliveryDays'
  459. },
  460. {
  461. width: 120,
  462. prop: 'guaranteePeriod',
  463. label: '质保期',
  464. slot: 'guaranteePeriod'
  465. },
  466. {
  467. width: 120,
  468. prop: 'guaranteePeriodUnitCode',
  469. label: '质保期单位',
  470. slot: 'guaranteePeriodUnitCode'
  471. },
  472. {
  473. width: 220,
  474. prop: 'remark',
  475. label: '备注',
  476. slot: 'remark'
  477. }
  478. ];
  479. export default {
  480. mixins: [dictMixins],
  481. components: {
  482. fileUpload
  483. // headList
  484. },
  485. props: {
  486. obj: {},
  487. status: {
  488. default: 'edit'
  489. },
  490. radio: {
  491. default: ''
  492. },
  493. isUpdate: {
  494. default: false
  495. }
  496. },
  497. data() {
  498. const defaultForm = {
  499. key: null,
  500. endTime: '',
  501. isFirst: 0,
  502. name: ''
  503. };
  504. return {
  505. numberReg,
  506. defaultForm,
  507. radio1: '',
  508. form: {
  509. resultList: [
  510. {
  511. supplierProductCode: '',
  512. deliveryDays: '',
  513. guaranteePeriod: '',
  514. guaranteePeriodUnitCode: '',
  515. guaranteePeriodUnitName: '',
  516. measuringUnit: '',
  517. modelType: '',
  518. productCode: '',
  519. remark: '',
  520. singlePrice: '',
  521. specification: '',
  522. supplierProductName: '',
  523. technicalAnswerName: '',
  524. technicalParams: '',
  525. totalCount: '',
  526. totalPrice: ''
  527. }
  528. ]
  529. },
  530. dataList: [],
  531. columns: [...defaultColumns]
  532. };
  533. },
  534. computed: {},
  535. watch: {
  536. radio(n, v) {
  537. this.radio1 = n;
  538. }
  539. },
  540. created() {
  541. this.form = copyObj(this.obj);
  542. this.radio1 = this.radio;
  543. // this.dataList=copyObj(this.list)
  544. },
  545. methods: {
  546. changeValue() {
  547. this.$refs.form.validate((valid) => {
  548. if (valid) {
  549. this.$emit('setSupplierId', {
  550. supplierName: this.form.supplierName,
  551. supplierId: this.form.supplierId
  552. });
  553. }else{
  554. this.radio1=''
  555. }
  556. });
  557. },
  558. //计算销售金额
  559. totalPrice(a, b, row) {
  560. if (!a || !b) {
  561. return;
  562. }
  563. row.totalPrice = parseFloat((a * b).toFixed(2));
  564. this.totalPriceAll();
  565. return row.totalPrice;
  566. },
  567. //计算销售总价
  568. totalPriceAll() {
  569. let num = 0;
  570. this.form.resultList.forEach((item) => {
  571. num += item.totalPrice;
  572. });
  573. this.form.totalPrice = parseFloat(num.toFixed(2));
  574. // this.form.preferentialPrice = parseFloat(num.toFixed(2));
  575. // console.log(this.form.resultList,'dasdasd')
  576. },
  577. // 返回列表数据
  578. getTableValue() {
  579. console.log(this.form, 'this.form');
  580. return this.form;
  581. },
  582. chaengMode(data) {
  583. this.form.settlementModeName = data.dictValue;
  584. },
  585. chaengUnitCode(data) {
  586. this.form.settlementModeName = data.dictValue;
  587. },
  588. //修改回显
  589. putTableValue(data) {
  590. this.form.resultList = copyObj(data);
  591. },
  592. remove(productCode) {
  593. let index = this.form.resultList.findIndex(
  594. (item) => item.productCode == productCode
  595. );
  596. this.form.resultList.splice(index, 1);
  597. this.setSort();
  598. },
  599. removeSupplier() {
  600. this.$emit('removeSupplier', this.form.supplierId);
  601. },
  602. // 清空表格
  603. restTable() {
  604. this.form.resultList = [];
  605. },
  606. // 重新排序
  607. setSort() {
  608. this.form.resultList.forEach((n, index) => {
  609. n.key = index + 1;
  610. });
  611. },
  612. validateForm(callback) {
  613. //开始表单校验
  614. this.$refs.form.validate((valid) => {
  615. callback(valid);
  616. });
  617. }
  618. }
  619. };
  620. </script>
  621. <style lang="scss" scoped>
  622. .headbox {
  623. display: flex;
  624. justify-content: space-between;
  625. align-items: center;
  626. .amount {
  627. font-size: 14px;
  628. font-weight: bold;
  629. }
  630. }
  631. .time-form .el-form-item {
  632. margin-bottom: 0 !important;
  633. }
  634. ::v-deep .period {
  635. display: flex;
  636. .borderleftnone {
  637. .el-input--medium .el-input__inner {
  638. border-top-right-radius: 0;
  639. border-bottom-right-radius: 0;
  640. }
  641. }
  642. .borderrightnone {
  643. .el-input--medium .el-input__inner {
  644. border-top-left-radius: 0;
  645. border-bottom-left-radius: 0;
  646. }
  647. }
  648. }
  649. ::v-deep .time-form tbody > tr:hover > td {
  650. background-color: transparent !important;
  651. }
  652. ::v-deep .time-form .el-table tr {
  653. background-color: #ffffff;
  654. }
  655. </style>