detail.vue 8.8 KB

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