fabRemQuaModal.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <!-- 面料 余下数量 弹框 成本分配统计表 -->
  3. <a-modal
  4. title="面料 - 余下数量"
  5. v-model="fabRemQuaModVis"
  6. :confirmLoading="confirmLoading"
  7. width="86%"
  8. style="top:330px;left:100px;"
  9. :footer="null"
  10. @cancel='cancel'
  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" @change="changeUnitCost(record)" @blur="blurUnitCost(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: 'FabRemQuaModal', // 面料 余下数量 弹框
  39. mixins: [JeecgListMixin],
  40. components: { JEllipsis, moment },
  41. data() {
  42. return {
  43. recordF:{},
  44. columns: [
  45. {
  46. title: '存货名称',
  47. dataIndex: 'goodsName',
  48. width: 120,
  49. className: 'replacecolor'
  50. },
  51. {
  52. title: '颜色',
  53. dataIndex: 'color',
  54. width: 120,
  55. className: 'replacecolor'
  56. },
  57. {
  58. title: '计划单号',
  59. dataIndex: 'planCode',
  60. width: 120,
  61. className: 'replacecolor'
  62. },
  63. {
  64. title: '使用数量',
  65. dataIndex: 'number',
  66. width: 120,
  67. className: 'replacecolor',
  68. customRender: (text, record, index) => {
  69. var re = Number(text).toFixed(4)
  70. return re
  71. }
  72. },
  73. {
  74. title: '单位成本',
  75. dataIndex: 'unitCost',
  76. width: 120,
  77. className: 'replacecolor',
  78. scopedSlots: { customRender: 'unitCost' },
  79. },
  80. {
  81. title: '总成本',
  82. dataIndex: 'cost',
  83. width: 120,
  84. className: 'replacecolor'
  85. }
  86. ],
  87. data: [],
  88. loading: false,
  89. confirmLoading: false,
  90. fabRemQuaModVis: false,
  91. planNum:'',
  92. }
  93. },
  94. // 接收父组件 方法
  95. props: {
  96. father: {
  97. type: Function,
  98. default: null
  99. },
  100. planNum:{
  101. type: String,
  102. default: null
  103. }
  104. },
  105. methods: {
  106. // 导出
  107. handleExportXls(fileName) {
  108. console.log('需导出的fileName:', fileName)
  109. const params = {
  110. planNum:this.planNum,
  111. syRemaining :this.data,
  112. sheetName:'面料余下'
  113. }
  114. console.log('导出参数', params)
  115. // var json = JSON.stringify(params)
  116. // debugger
  117. downFile1('/cost/syCostAllocation/exportXlsSyCostAllocation', params).then(data => {
  118. console.log('888')
  119. if (!data) {
  120. this.$message.warning('文件下载失败')
  121. return
  122. }
  123. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  124. window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), this.planNum+'-'+fileName + '.xlsx')
  125. } else {
  126. let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
  127. let link = document.createElement('a')
  128. link.style.display = 'none'
  129. link.href = url
  130. link.setAttribute('download', this.planNum+'-'+fileName + '.xlsx')
  131. document.body.appendChild(link)
  132. link.click()
  133. document.body.removeChild(link) // 下载完成移除元素
  134. window.URL.revokeObjectURL(url) // 释放掉blob对象
  135. }
  136. })
  137. },
  138. // 打印
  139. print() {},
  140. changeUnitCost(record){
  141. var all = (Number(record.unitCost)*Number(record.number)).toFixed(2)
  142. this.$set(record,'cost',all)
  143. },
  144. blurUnitCost(record){
  145. record.unitCost = Number(record.unitCost).toFixed(4)
  146. },
  147. cancel() {
  148. console.log('返回成本分配统计表')
  149. this.fabRemQuaModVis = false
  150. var all = 0
  151. this.data.map(item=>{
  152. if(item.cost&&item.cost!==''){
  153. all+=Number(item.cost)
  154. }
  155. })
  156. this.$emit('close',all,this.recordF)
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="less" scoped>
  162. @import '~@assets/less/common.less';
  163. @import '~@assets/less/overwriter.less';
  164. /deep/ .ant-table-thead > tr > th {
  165. text-align: center;
  166. // font-weight: 700;
  167. }
  168. /deep/ .ant-table-tbody {
  169. text-align: center;
  170. }
  171. // /deep/ th.replacecolor {
  172. // background-color: #ccc;
  173. // }
  174. </style>