detail.vue 9.0 KB

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