detail.vue 9.7 KB

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