detail.vue 9.7 KB

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