inquiryList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <el-dialog
  3. title="选择核价单"
  4. :visible.sync="visible"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. top="5vh"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="80%"
  11. >
  12. <el-card shadow="never">
  13. <searchProduct @search="reload"></searchProduct>
  14. <ele-pro-table
  15. ref="table"
  16. :columns="columns"
  17. :datasource="datasource"
  18. :selection.sync="selection"
  19. cache-key="eomContactPageTable"
  20. height="calc(100vh - 350px)"
  21. class="dict-table"
  22. >
  23. </ele-pro-table>
  24. </el-card>
  25. <div class="btns">
  26. <el-button type="primary" size="small" @click="selected"
  27. >生成合同
  28. </el-button
  29. >
  30. <el-button size="small" @click="handleClose">关闭</el-button>
  31. </div>
  32. </el-dialog>
  33. </template>
  34. <script>
  35. import {
  36. getTableList,
  37. generateContract
  38. } from '@/api/bpm/components/purchasingManage/inquiryManage';
  39. import searchProduct from './searchProduct.vue';
  40. export default {
  41. components: {
  42. searchProduct
  43. },
  44. data() {
  45. return {
  46. visible: false,
  47. currentIndex: null,
  48. selection: [],
  49. columns: [
  50. {
  51. width: 45,
  52. type: 'selection',
  53. columnKey: 'selection',
  54. align: 'center'
  55. },
  56. {
  57. columnKey: 'index',
  58. label: '序号',
  59. type: 'index',
  60. width: 55,
  61. align: 'center',
  62. showOverflowTooltip: true,
  63. fixed: 'left'
  64. },
  65. {
  66. prop: 'inquiryCode',
  67. slot: 'inquiryCode',
  68. label: '采购询价编码',
  69. align: 'center',
  70. showOverflowTooltip: true,
  71. minWidth: 200
  72. },
  73. {
  74. prop: 'planCode',
  75. slot: 'planCode',
  76. label: '采购计划编码',
  77. align: 'center',
  78. showOverflowTooltip: true,
  79. minWidth: 200
  80. },
  81. {
  82. prop: 'supplierNames',
  83. label: '供应商名称',
  84. align: 'center',
  85. showOverflowTooltip: true,
  86. minWidth: 200
  87. },
  88. {
  89. prop: 'winnerName',
  90. label: '中标供应商',
  91. align: 'center',
  92. showOverflowTooltip: true,
  93. minWidth: 200
  94. },
  95. {
  96. prop: 'createTime',
  97. label: '创建时间',
  98. align: 'center',
  99. showOverflowTooltip: true,
  100. minWidth: 180
  101. },
  102. {
  103. prop: 'remark',
  104. label: '备注',
  105. align: 'center',
  106. showOverflowTooltip: true,
  107. minWidth: 170
  108. }
  109. ]
  110. };
  111. },
  112. watch: {},
  113. methods: {
  114. open() {
  115. this.visible = true;
  116. },
  117. /* 表格数据源 */
  118. datasource({page, limit, where, order}) {
  119. return getTableList({
  120. pageNum: page,
  121. size: limit,
  122. ...where,
  123. status: 2
  124. });
  125. },
  126. /* 刷新表格 */
  127. reload(where) {
  128. this.$refs.table.reload({pageNum: 1, where: where});
  129. },
  130. //新增合同
  131. async addGenerateContract() {
  132. let {verify, text, ids} = this.verify();
  133. if (!verify) {
  134. this.$message.warning(text);
  135. return;
  136. }
  137. let data = await generateContract(ids);
  138. return data;
  139. },
  140. // 合同验证
  141. verify() {
  142. let verify = true;
  143. let text = '';
  144. let ids = [];
  145. let winnerIds = this.selection
  146. .filter((item) => item.winnerId)
  147. .map((item) => item.winnerId);
  148. this.selection.forEach((item) => {
  149. this.selection.forEach((val) => {
  150. if (item.winnerId != val.winnerId) {
  151. verify = false;
  152. text = '中标供应商不一致';
  153. }
  154. });
  155. });
  156. if (winnerIds.length != this.selection.length) {
  157. verify = false;
  158. text = '核价单中标供应商为空';
  159. }
  160. if (verify) {
  161. ids = this.selection.map((item) => item.id);
  162. }
  163. return {verify, text, ids};
  164. },
  165. handleClose() {
  166. this.visible = false;
  167. this.current = null;
  168. },
  169. async selected() {
  170. if (this.selection.length == 0) {
  171. return this.$message.warning('请至少选择一条数据');
  172. }
  173. let data = await this.addGenerateContract();
  174. if (data) {
  175. data.contractVO.contractName = data.contractVO.partbName
  176. //获取优惠金额和总计的差价
  177. let diffPrice = Number(data.contractVO.totalPrice) - Number(data.contractVO.discountTotalPrice)
  178. data.productList.forEach((item) => {
  179. if (data.contractVO.discountTotalPrice === 0) {
  180. item.discountTotalPrice = 0
  181. item.discountSinglePrice = 0
  182. return
  183. }
  184. if (!data.contractVO.discountTotalPrice) {
  185. item.discountTotalPrice = item.totalPrice
  186. item.discountSinglePrice = item.singlePrice
  187. return
  188. }
  189. //获取详情每条的小计
  190. // 使用小计除以总价得出该条数据小计占比 在乘以差价或的该条数据应承担的差价 在小计-应承担差价获得折让后的小计
  191. item.discountTotalPrice = (Number(item.totalPrice) - Number(item.totalPrice) / Number(data.contractVO.totalPrice) * diffPrice).toFixed(2)
  192. //使用折让后的小计除以数量得到单价
  193. item.discountSinglePrice = (Number(item.discountTotalPrice) / Number(item.totalCount)).toFixed(2)
  194. })
  195. this.$emit('changeParent', {data, sourceCode: this.selection.map(item => item.inquiryCode).toString()});
  196. this.handleClose();
  197. }
  198. }
  199. }
  200. };
  201. </script>
  202. <style lang="scss" scoped>
  203. .tree_col {
  204. border: 1px solid #eee;
  205. padding: 10px 0;
  206. box-sizing: border-box;
  207. height: 500px;
  208. overflow: auto;
  209. }
  210. .table_col {
  211. padding-left: 10px;
  212. ::v-deep .el-table th.el-table__cell {
  213. background: #f2f2f2;
  214. }
  215. }
  216. .pagination {
  217. text-align: right;
  218. padding: 10px 0;
  219. }
  220. .btns {
  221. text-align: center;
  222. padding: 10px 0;
  223. }
  224. .topsearch {
  225. margin-bottom: 15px;
  226. }
  227. </style>