detail.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle" v-if="!outBizSn">
  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="outBizSn ? $hasPermissions('B_outboundOrderDetail') : $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" 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. props: {
  74. outBizSn: { // 有值则为弹框,无值则为页面
  75. type: [Number, String],
  76. default: ''
  77. }
  78. },
  79. data () {
  80. return {
  81. spinning: false,
  82. // 表头
  83. columns: [
  84. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  85. { title: '产品编码', dataIndex: 'productCode', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  86. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  87. { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  88. { title: '成本价(¥)', dataIndex: 'outCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  89. { title: '调出仓库', dataIndex: 'warehouseName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  90. { title: '调出数量', dataIndex: 'outQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  91. { title: '成本小计(¥)', dataIndex: 'costSubtotal', width: 115, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  92. ],
  93. // 加载数据方法 必须为 Promise 对象
  94. loadData: parameter => {
  95. this.spinning = true
  96. return storeCallOutDetailList(Object.assign(parameter, { storeCallOutSn: this.outBizSn || this.$route.params.sn })).then(res => {
  97. const data = res.data
  98. const no = (data.pageNo - 1) * data.pageSize
  99. for (var i = 0; i < data.list.length; i++) {
  100. data.list[i].no = no + i + 1
  101. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  102. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].outCost, data.list[i].outQty)
  103. }
  104. this.localDataSource = data.list
  105. this.spinning = false
  106. return data
  107. })
  108. },
  109. localDataSource: [],
  110. basicInfoData: null, // 基本信息
  111. productTotal: null, // 合计
  112. printerType: 'NEEDLE', // 打印机类型
  113. printCostChecked: true // 打印成本
  114. }
  115. },
  116. computed: {
  117. isEdit () {
  118. return ((this.basicInfoData && this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData && this.basicInfoData.state == 'WAIT_AUDIT')) && this.$hasPermissions('B_storeCallOutEdit')
  119. }
  120. },
  121. methods: {
  122. // 返回列表
  123. handleBack () {
  124. this.$router.push({ path: '/allocationManagement/storeTransferOut/list', query: { closeLastOldTab: true } })
  125. },
  126. // 打印预览/快捷打印
  127. handlePrint (type) {
  128. const _this = this
  129. _this.spinning = true
  130. storeCallOutDetailPrint({ sn: this.outBizSn || this.$route.params.sn, type: this.printerType, costFlag: this.printCostChecked ? '1' : '0' }).then(res => {
  131. _this.spinning = false
  132. if (res.type == 'application/json') {
  133. var reader = new FileReader()
  134. reader.addEventListener('loadend', function () {
  135. const obj = JSON.parse(reader.result)
  136. _this.$notification.error({
  137. message: '提示',
  138. description: obj.message
  139. })
  140. })
  141. reader.readAsText(res)
  142. } else {
  143. this.print(res, type)
  144. }
  145. })
  146. },
  147. print (data, type) {
  148. if (!data) {
  149. return
  150. }
  151. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  152. document.getElementById('print').innerHTML = '<iframe id="printfsod" name="printfsod" src="' + url + '" hidden></iframe>'
  153. if (type == 'preview') { // 预览
  154. window.open(url)
  155. } else if (type == 'print') { // 打印
  156. window.frames['printfsod'].focus()
  157. window.frames['printfsod'].print()
  158. }
  159. },
  160. // 基本信息
  161. getDetail () {
  162. storeCallOutDetailSn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  163. if (res.status == 200) {
  164. this.basicInfoData = res.data
  165. } else {
  166. this.basicInfoData = null
  167. }
  168. })
  169. },
  170. // 合计
  171. getDetailCount () {
  172. storeCallOutDetailCount({ storeCallOutSn: this.outBizSn || this.$route.params.sn }).then(res => {
  173. if (res.status == 200) {
  174. this.productTotal = res.data
  175. } else {
  176. this.productTotal = null
  177. }
  178. })
  179. },
  180. // 编辑
  181. handleEdit () {
  182. this.$router.push({ path: `/allocationManagement/storeTransferOut/edit/${this.basicInfoData.id}/${this.basicInfoData.storeCallOutSn}` })
  183. }
  184. },
  185. mounted () {
  186. this.getDetail()
  187. this.getDetailCount()
  188. },
  189. beforeRouteEnter (to, from, next) {
  190. next(vm => {
  191. if (!vm.spinning) {
  192. vm.getDetail()
  193. vm.getDetailCount()
  194. vm.$refs.table.refresh()
  195. }
  196. })
  197. }
  198. }
  199. </script>
  200. <style lang="less">
  201. .storeTransferOutDetail-wrap{
  202. .storeTransferOutDetail-back{
  203. margin-bottom: 10px;
  204. }
  205. .storeTransferOutDetail-cont{
  206. margin-bottom: 10px;
  207. }
  208. }
  209. </style>