detail.vue 9.2 KB

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