fabInQuaModal.vue 4.9 KB

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