detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="allocateBillDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="allocateBillDetail-back" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle" v-if="!outBizSn">
  7. <a id="allocateBillDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <a-button
  9. v-if="isEdit"
  10. type="primary"
  11. size="small"
  12. style="background-color: #1890ff;margin-left: 20px;border: #1890ff;"
  13. id="allocateBillDetail-edit-btn"
  14. @click.stop="handleEdit">编辑</a-button>
  15. </template>
  16. <!-- 操作区,位于 title 行的行尾 -->
  17. <template slot="extra">
  18. <a-button
  19. key="3"
  20. type="primary"
  21. class="button-warning"
  22. v-if="$hasPermissions('B_transferOut_detail_export')"
  23. id="allocateBillDetail-export-btn"
  24. :disabled="localDataSource.length==0"
  25. @click="handleExcel">导出Excel</a-button>
  26. <a-button
  27. key="2"
  28. type="primary"
  29. class="button-error"
  30. v-if="$hasPermissions('B_transferOut_print')"
  31. id="allocateBillDetail-db-print-btn"
  32. :disabled="localDataSource.length==0"
  33. @click="handlePrint('dbPrint')">调拨打印</a-button>
  34. <a-button
  35. key="1"
  36. type="primary"
  37. class="button-info"
  38. v-if="$hasPermissions('B_transferOut_print')"
  39. id="allocateBillDetail-dbfl-print-btn"
  40. :disabled="localDataSource.length==0"
  41. @click="handlePrint('dbflPrint')">调拨分类打印</a-button>
  42. </template>
  43. </a-page-header>
  44. <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
  45. <a-collapse :activeKey="['1']">
  46. <a-collapse-panel key="1" header="基础信息">
  47. <a-descriptions :column="3">
  48. <a-descriptions-item label="调往对象">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  49. <a-descriptions-item label="调拨单号">{{ (basicInfoData&&basicInfoData.allocateNo) || '--' }}</a-descriptions-item>
  50. <a-descriptions-item label="调拨类型">{{ (basicInfoData&&basicInfoData.allocateTypeName) || '--' }}</a-descriptions-item>
  51. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  52. <a-descriptions-item label="起止时间">
  53. <span v-if="basicInfoData&&(basicInfoData.promoStartDate || basicInfoData.promoEndDate)">{{ (basicInfoData&&basicInfoData.promoStartDate) || '--' }} ~ {{ (basicInfoData&&basicInfoData.promoEndDate) || '--' }}</span>
  54. <span v-else>--</span>
  55. </a-descriptions-item>
  56. <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remark) || '--' }}</a-descriptions-item>
  57. </a-descriptions>
  58. </a-collapse-panel>
  59. </a-collapse>
  60. </a-card>
  61. <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
  62. <!-- 总计 -->
  63. <a-alert type="info" style="margin-bottom:10px">
  64. <div slot="message">
  65. 总数量:<strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}</strong> ,
  66. <span v-if="$hasPermissions('B_isShowCost')">总成本(¥):<strong>{{ (productTotal&&(productTotal.totalCost || productTotal.totalCost==0)) ? productTotal.totalCost : '--' }}</strong> ,</span>
  67. 总售价(¥):<strong>{{ (productTotal&&(productTotal.totalPrice || productTotal.totalPrice==0)) ? productTotal.totalPrice : '--' }}</strong>
  68. </div>
  69. </a-alert>
  70. <!-- 列表 -->
  71. <s-table
  72. class="sTable"
  73. ref="table"
  74. size="small"
  75. :rowKey="(record) => record.id"
  76. :columns="columns"
  77. :data="loadData"
  78. :defaultLoadData="false"
  79. bordered>
  80. </s-table>
  81. </a-card>
  82. </a-spin>
  83. <!-- 打印导出 -->
  84. <print-modal :openModal="openModal" :itemData="basicInfoData" :nowType="nowType" @ok="handleOk" @close="openModal=false" />
  85. <!-- 打印 -->
  86. <div id="print"></div>
  87. </div>
  88. </template>
  89. <script>
  90. import { STable, VSelect } from '@/components'
  91. import printModal from './printModal.vue'
  92. import { hdExportExcel } from '@/libs/exportExcel'
  93. import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount, allocateBillDetailPrint, allocateBillDetailExcel } from '@/api/allocateBill'
  94. export default {
  95. components: { STable, VSelect, printModal },
  96. props: {
  97. outBizSn: { // 有值则为弹框,无值则为页面
  98. type: [Number, String],
  99. default: ''
  100. }
  101. },
  102. data () {
  103. return {
  104. spinning: false,
  105. // 加载数据方法 必须为 Promise 对象
  106. loadData: parameter => {
  107. this.spinning = true
  108. return allocateBillDetailList(Object.assign(parameter, { allocateSn: this.outBizSn || this.$route.params.sn })).then(res => {
  109. const data = res.data
  110. const no = (data.pageNo - 1) * data.pageSize
  111. for (var i = 0; i < data.list.length; i++) {
  112. data.list[i].no = no + i + 1
  113. }
  114. this.localDataSource = data.list
  115. this.spinning = false
  116. return data
  117. })
  118. },
  119. basicInfoData: null, // 基本信息
  120. productTotal: null, // 合计
  121. localDataSource: [],
  122. openModal: false,
  123. nowType: null
  124. }
  125. },
  126. computed: {
  127. isEdit () {
  128. return this.basicInfoData && ((this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData.state == 'WAIT_AUDIT') || (this.basicInfoData.state == 'AUDIT_REJECT')) && this.$hasPermissions('M_transferOut_edit')
  129. },
  130. columns () {
  131. const arr = [
  132. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  133. { title: '产品编码', dataIndex: 'productEntity.code', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '产品名称', dataIndex: 'productEntity.name', width: '27%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  135. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  136. { title: '单位', dataIndex: 'productEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '售价', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  138. { title: '调出数量', dataIndex: 'qty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  139. { title: '售价小计(¥)', dataIndex: 'totalPrice', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  140. ]
  141. if (this.$hasPermissions('B_isShowCost')) {
  142. arr.splice(5, 0, { title: '成本价', dataIndex: 'cost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  143. arr.splice(8, 0, { title: '成本小计(¥)', dataIndex: 'totalCost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  144. }
  145. return arr
  146. }
  147. },
  148. methods: {
  149. // 返回列表
  150. handleBack () {
  151. this.$router.push({ path: '/allocationManagement/transferOut/list', query: { closeLastOldTab: true } })
  152. },
  153. // 基本信息
  154. getDetail () {
  155. allocateBillDetail({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  156. if (res.status == 200) {
  157. this.basicInfoData = res.data
  158. } else {
  159. this.basicInfoData = null
  160. }
  161. })
  162. },
  163. // 合计
  164. getDetailCount () {
  165. allocateBillDetailCount({ allocateSn: this.outBizSn || this.$route.params.sn }).then(res => {
  166. if (res.status == 200) {
  167. this.productTotal = res.data
  168. } else {
  169. this.productTotal = null
  170. }
  171. })
  172. },
  173. // 编辑
  174. handleEdit () {
  175. this.$router.push({ path: `/allocationManagement/transferOut/edit/${this.basicInfoData.allocateSn}/${this.basicInfoData.dealerLevel}` })
  176. },
  177. // 导出
  178. handleExcel () {
  179. const _this = this
  180. this.spinning = true
  181. hdExportExcel(allocateBillDetailExcel, { allocateSn: this.outBizSn || this.$route.params.sn }, '调拨明细', function () {
  182. _this.spinning = false
  183. })
  184. },
  185. // 打印预览/快捷打印
  186. handlePrint (type) {
  187. this.nowType = type
  188. this.openModal = true
  189. },
  190. handleOk (objs) {
  191. const _this = this
  192. const params = JSON.parse(JSON.stringify(objs))
  193. delete params.type
  194. _this.spinning = true
  195. allocateBillDetailPrint(params).then(res => {
  196. _this.spinning = false
  197. if (res.type == 'application/json') {
  198. var reader = new FileReader()
  199. reader.addEventListener('loadend', function () {
  200. const obj = JSON.parse(reader.result)
  201. _this.$notification.error({
  202. message: '提示',
  203. description: obj.message
  204. })
  205. })
  206. reader.readAsText(res)
  207. } else {
  208. this.print(res, objs.isPreview)
  209. }
  210. })
  211. },
  212. print (data, type) {
  213. if (!data) {
  214. return
  215. }
  216. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  217. document.getElementById('print').innerHTML = '<iframe id="printftod" name="printftod" src="' + url + '" hidden></iframe>'
  218. if (type == '1') { // 预览
  219. window.open(url)
  220. } else if (type == '0') { // 打印
  221. window.frames['printftod'].focus()
  222. window.frames['printftod'].print()
  223. }
  224. },
  225. pageInit () {
  226. this.$refs.table.refresh(true)
  227. this.getDetail()
  228. this.getDetailCount()
  229. }
  230. },
  231. mounted () {
  232. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  233. this.pageInit()
  234. }
  235. },
  236. activated () {
  237. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  238. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  239. this.pageInit()
  240. }
  241. },
  242. beforeRouteEnter (to, from, next) {
  243. next(vm => {})
  244. }
  245. }
  246. </script>
  247. <style lang="less">
  248. .allocateBillDetail-wrap{
  249. .allocateBillDetail-back{
  250. margin-bottom: 10px;
  251. }
  252. .allocateBillDetail-cont{
  253. margin-bottom: 10px;
  254. }
  255. }
  256. </style>