detail.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div class="chainTransferInDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="chainTransferInDetail-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="chainTransferInDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <a-button
  9. v-if="isEdit"
  10. type="primary"
  11. size="small"
  12. style="background-color: #1890ff;margin-left: 20px;border: #1890ff;"
  13. id="chainTransferInDetail-edit-btn"
  14. @click.stop="handleEdit">编辑</a-button>
  15. </template>
  16. <!-- 操作区,位于 title 行的行尾 -->
  17. <template slot="extra">
  18. <a-radio-group key="3" v-model="printerType">
  19. <a-radio value="NEEDLE">针式</a-radio>
  20. <a-radio value="INK">喷墨</a-radio>
  21. </a-radio-group>
  22. <a-button key="2" id="chainTransferInDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
  23. <a-button key="1" type="primary" id="chainTransferInDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
  24. </template>
  25. </a-page-header>
  26. <!-- 基础信息 -->
  27. <a-card size="small" :bordered="false" class="chainTransferInDetail-cont">
  28. <a-collapse :activeKey="['1']">
  29. <a-collapse-panel key="1" header="基础信息">
  30. <a-descriptions :column="3">
  31. <a-descriptions-item label="调入单号">{{ (basicInfoData&&basicInfoData.allocationLinkagePutNo) || '--' }}</a-descriptions-item>
  32. <a-descriptions-item label="调出对象">{{ (basicInfoData&&basicInfoData.outTenantName) || '--' }}</a-descriptions-item>
  33. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  34. <a-descriptions-item label="财务状态">{{ (basicInfoData&&basicInfoData.settleStateDictValue) || '--' }}</a-descriptions-item>
  35. </a-descriptions>
  36. </a-collapse-panel>
  37. </a-collapse>
  38. </a-card>
  39. <a-card size="small" :bordered="false" class="chainTransferInDetail-cont">
  40. <!-- 总计 -->
  41. <a-alert type="info" showIcon style="margin-bottom:15px">
  42. <div slot="message">总款数 <strong>{{ (productTotal&&productTotal.productTotalCategory) || 0 }}</strong> ,总数量 <strong>{{ (productTotal&&productTotal.productTotalQty) || 0 }}</strong> ,总成本¥<strong>{{ (productTotal&&productTotal.productTotalCost) || 0 }}</strong></div>
  43. </a-alert>
  44. <!-- 列表 -->
  45. <s-table
  46. class="sTable"
  47. ref="table"
  48. size="small"
  49. :rowKey="(record) => record.id"
  50. :columns="columns"
  51. :data="loadData"
  52. :scroll="{ x: 1335 }"
  53. bordered>
  54. </s-table>
  55. </a-card>
  56. </a-spin>
  57. <!-- 打印 -->
  58. <div id="print"></div>
  59. </div>
  60. </template>
  61. <script>
  62. import { STable, VSelect } from '@/components'
  63. import { getOperationalPrecision } from '@/libs/tools.js'
  64. import { allocLinkagePutDetailList, allocLinkagePutDetailSn, allocLinkagePutDetailCount, allocLinkagePutDetailPrint } from '@/api/allocLinkagePut'
  65. export default {
  66. components: { STable, VSelect },
  67. data () {
  68. return {
  69. spinning: false,
  70. // 表头
  71. columns: [
  72. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  73. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  74. { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  75. { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  76. { title: '成本价(¥)', dataIndex: 'putCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  77. { title: '调入数量', dataIndex: 'putQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  78. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  79. { title: '成本小计(¥)', dataIndex: 'costSubtotal', width: 115, align: 'center' },
  80. { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  81. { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' } }
  82. ],
  83. // 加载数据方法 必须为 Promise 对象
  84. loadData: parameter => {
  85. const params = Object.assign(parameter, { allocationLinkagePutSn: this.$route.params.sn })
  86. return allocLinkagePutDetailList(params).then(res => {
  87. const data = res.data
  88. const no = (data.pageNo - 1) * data.pageSize
  89. for (var i = 0; i < data.list.length; i++) {
  90. data.list[i].no = no + i + 1
  91. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  92. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
  93. }
  94. this.getDetailCount(params)
  95. this.localDataSource = data.list
  96. return data
  97. })
  98. },
  99. basicInfoData: null, // 基本信息
  100. productTotal: null, // 合计
  101. localDataSource: [],
  102. printerType: 'NEEDLE' // 打印机类型
  103. }
  104. },
  105. computed: {
  106. isEdit () {
  107. return (this.basicInfoData && this.basicInfoData.state == 'WAIT_AUDIT')
  108. }
  109. },
  110. methods: {
  111. // 返回列表
  112. handleBack () {
  113. this.$router.push({ path: '/allocationManagement/chainTransferIn/list' })
  114. },
  115. // 基本信息
  116. getDetail () {
  117. allocLinkagePutDetailSn({ sn: this.$route.params.sn }).then(res => {
  118. if (res.status == 200) {
  119. this.basicInfoData = res.data
  120. } else {
  121. this.basicInfoData = null
  122. }
  123. })
  124. },
  125. // 合计
  126. getDetailCount (params) {
  127. allocLinkagePutDetailCount(params).then(res => {
  128. if (res.status == 200) {
  129. this.productTotal = res.data
  130. } else {
  131. this.productTotal = null
  132. }
  133. })
  134. },
  135. // 编辑
  136. handleEdit () {
  137. this.$router.push({ path: `/allocationManagement/chainTransferIn/edit/${this.basicInfoData.id}/${this.basicInfoData.allocationLinkagePutSn}` })
  138. },
  139. // 打印预览/快捷打印
  140. handlePrint (type) {
  141. const _this = this
  142. _this.spinning = true
  143. allocLinkagePutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
  144. _this.spinning = false
  145. if (res.type == 'application/json') {
  146. var reader = new FileReader()
  147. reader.addEventListener('loadend', function () {
  148. const obj = JSON.parse(reader.result)
  149. _this.$notification.error({
  150. message: '提示',
  151. description: obj.message
  152. })
  153. })
  154. reader.readAsText(res)
  155. } else {
  156. this.print(res, type)
  157. }
  158. })
  159. },
  160. print (data, type) {
  161. if (!data) {
  162. return
  163. }
  164. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  165. document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
  166. if (type == 'preview') { // 预览
  167. window.open(url)
  168. } else if (type == 'print') { // 打印
  169. window.frames['printf'].focus()
  170. window.frames['printf'].print()
  171. }
  172. }
  173. },
  174. beforeRouteEnter (to, from, next) {
  175. next(vm => {
  176. vm.getDetail()
  177. })
  178. }
  179. }
  180. </script>
  181. <style lang="less">
  182. .chainTransferInDetail-wrap{
  183. .chainTransferInDetail-cont{
  184. margin-bottom: 15px;
  185. }
  186. }
  187. </style>