ingInQuaModal.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <!-- 辅料 转入数量 成本分配统计表 -->
  3. <a-modal
  4. title="转入数量"
  5. v-model="ingInQuaModVis"
  6. :confirmLoading="confirmLoading"
  7. width="86%"
  8. style="top:330px;left:100px;"
  9. @cancel="cancel"
  10. :footer="null"
  11. >
  12. <!-- tabel 加载 -->
  13. <a-spin :spinning="confirmLoading">
  14. <a-table :loading="loading" bordered :columns="columns" :data-source="data" :pagination="false">
  15. <span slot="unitCost" slot-scope="text,record">
  16. <a-input placeholder="请输入" v-model="record.unitCost" @blur="changeUnitCost(record)"/>
  17. </span>
  18. </a-table>
  19. <!-- 导出 打印 返回 -->
  20. <a-row style="marginTop:20px;">
  21. <a-col :md="24" :sm="12">
  22. <span style="float: right;" class="table-operator">
  23. <a-button type="primary" icon="download" @click="handleExportXls('辅料转入')">导出</a-button>
  24. <!-- <a-button type="primary" @click="print" icon="printer" style="margin:0 10px;">打印</a-button> -->
  25. <a-button type="primary" @click="cancel" icon="rollback">取消</a-button>
  26. </span>
  27. </a-col>
  28. </a-row>
  29. </a-spin>
  30. </a-modal>
  31. </template>
  32. <script>
  33. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  34. import JEllipsis from '@/components/jeecg/JEllipsis'
  35. import moment from 'moment'
  36. import { downFile,downFile1 } from '@/api/manage'
  37. export default {
  38. name: 'IngInQuaModal', // 辅料 转入数量 弹框
  39. mixins: [JeecgListMixin],
  40. components: { JEllipsis, moment },
  41. data() {
  42. return {
  43. // 辅料- 转入数量 表头
  44. columns: [
  45. {
  46. title: '存货名称',
  47. dataIndex: 'goodsName',
  48. width: 120,
  49. className: 'replacecolor'
  50. },
  51. {
  52. title: '计划单号',
  53. dataIndex: 'planCode',
  54. width: 120,
  55. className: 'replacecolor'
  56. },
  57. {
  58. title: '转入数量',
  59. dataIndex: 'number',
  60. width: 120,
  61. className: 'replacecolor',
  62. customRender: (text, record, index) => {
  63. var re = Number(text).toFixed(4)
  64. return re
  65. }
  66. },
  67. {
  68. title: '单位成本',
  69. dataIndex: 'unitCost',
  70. width: 120,
  71. className: 'replacecolor',
  72. scopedSlots: { customRender: 'unitCost' },
  73. },
  74. {
  75. title: '总成本',
  76. dataIndex: 'cost',
  77. width: 120,
  78. className: 'replacecolor',
  79. }
  80. ],
  81. data: [],
  82. loading: false, // 表格加载
  83. planNum:'',
  84. record:'',
  85. // orderDataform: this.$form.createForm(this),
  86. confirmLoading: false,
  87. ingInQuaModVis: false
  88. }
  89. },
  90. // 接收父组件 方法
  91. props: {
  92. father: {
  93. type: Function,
  94. default: null
  95. },
  96. planNum:{
  97. type: String,
  98. default: null
  99. }
  100. },
  101. methods: {
  102. // 导出
  103. handleExportXls(fileName) {
  104. console.log('需导出的fileName:', fileName)
  105. const params = {
  106. planNum:this.planNum,
  107. sytransferIngreDeent :this.data,
  108. sheetName:'辅料转入'
  109. }
  110. console.log('导出参数', params)
  111. downFile1('/cost/syCostAllocation/exportXlsSyCostAllocation', params).then(data => {
  112. console.log('888')
  113. if (!data) {
  114. this.$message.warning('文件下载失败')
  115. return
  116. }
  117. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  118. window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), this.planNum+'-'+fileName + '.xlsx')
  119. } else {
  120. let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
  121. let link = document.createElement('a')
  122. link.style.display = 'none'
  123. link.href = url
  124. link.setAttribute('download', this.planNum+'-'+fileName + '.xlsx')
  125. document.body.appendChild(link)
  126. link.click()
  127. document.body.removeChild(link) // 下载完成移除元素
  128. window.URL.revokeObjectURL(url) // 释放掉blob对象
  129. }
  130. })
  131. },
  132. // 打印
  133. print() {},
  134. changeUnitCost(record){
  135. record.unitCost = Number(record.unitCost).toFixed(4)
  136. this.$set(record,'cost',(Number(record.unitCost)* Number(record.number)).toFixed(4))
  137. },
  138. cancel() {
  139. console.log('返回成本分配统计表')
  140. this.ingInQuaModVis = false
  141. var allCost = 0
  142. this.data.map(item=>{
  143. if(item.cost){
  144. allCost +=Number(item.cost)
  145. }else{
  146. allCost +=0
  147. }
  148. })
  149. this.$emit('close',allCost,this.record)
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="less" scoped>
  155. @import '~@assets/less/common.less';
  156. @import '~@assets/less/overwriter.less';
  157. /deep/ .ant-table-thead > tr > th {
  158. text-align: center;
  159. // font-weight: 700;
  160. }
  161. /deep/ .ant-table-tbody {
  162. text-align: center;
  163. }
  164. // /deep/ th.replacecolor {
  165. // background-color: #ccc;
  166. // }
  167. </style>