detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="bulkWarehousingOrderDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderDetail-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="bulkWarehousingOrderDetail-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="bulkWarehousingOrderDetail-edit-btn"
  14. @click.stop="handleEdit">编辑</a-button>
  15. <p style=" display: inline-block;margin: 0 0 0 60px;color: #000;font-size: 16px;font-weight: 600;">单号:{{ (basicInfoData&&basicInfoData.sparePartsPurchaseNo) || '--' }}</p>
  16. </template>
  17. <template slot="tags">
  18. <a-tag color="red" v-if="basicInfoData&&basicInfoData.stateDictValue">{{ basicInfoData.stateDictValue }}</a-tag>
  19. <a-tag color="orange" v-if="basicInfoData&&basicInfoData.settleStateDictValue">{{ basicInfoData.settleStateDictValue }}</a-tag>
  20. </template>
  21. <!-- 操作区,位于 title 行的行尾 -->
  22. <template slot="extra" v-if="$hasPermissions('B_bulkWarehousingOrder_print')">
  23. <a-radio-group key="3" v-model="printerType">
  24. <a-radio value="NEEDLE">针式</a-radio>
  25. <a-radio value="INK">喷墨</a-radio>
  26. </a-radio-group>
  27. <a-button key="2" id="bulkWarehousingOrderDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
  28. <a-button key="1" type="primary" id="bulkWarehousingOrderDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
  29. </template>
  30. </a-page-header>
  31. <!-- 基础信息 -->
  32. <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
  33. <a-collapse :activeKey="['1']">
  34. <a-collapse-panel key="1" header="基础信息">
  35. <a-descriptions :column="3">
  36. <a-descriptions-item label="供应商">{{ (basicInfoData&&basicInfoData.supplierName) || '--' }}</a-descriptions-item>
  37. <a-descriptions-item label="散件入库类型">{{ (basicInfoData&&basicInfoData.sparePartsTypeName) || '--' }}</a-descriptions-item>
  38. <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remarks) || '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="联系人">
  40. {{ (basicInfoData&&basicInfoData.supplierContactPerson) || '--' }}
  41. <span v-if="basicInfoData&&basicInfoData.supplierContactTel">({{ basicInfoData.supplierContactTel }})</span>
  42. </a-descriptions-item>
  43. <a-descriptions-item label="联系地址">
  44. <div v-if="basicInfoData&&(basicInfoData.supplierProvinceName || basicInfoData.supplierCityName || basicInfoData.supplierCountyName || basicInfoData.supplierAddress)">
  45. {{ (basicInfoData&&basicInfoData.supplierProvinceName) || '' }}
  46. {{ (basicInfoData&&basicInfoData.supplierCityName) || '' }}
  47. {{ (basicInfoData&&basicInfoData.supplierCountyName) || '' }}
  48. {{ (basicInfoData&&basicInfoData.supplierAddress) || '' }}
  49. </div>
  50. <span v-else>--</span>
  51. </a-descriptions-item>
  52. </a-descriptions>
  53. </a-collapse-panel>
  54. </a-collapse>
  55. </a-card>
  56. <!-- 产品详情 -->
  57. <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
  58. <a-collapse :activeKey="['1']">
  59. <a-collapse-panel key="1" header="产品详情">
  60. <!-- 总计 -->
  61. <a-alert type="info" style="margin-bottom:10px">
  62. <div slot="message">
  63. 总款数 <strong>{{ (productTotal&&(productTotal.productTotalCategory || productTotal.productTotalCategory==0)) ? productTotal.productTotalCategory : '--' }}</strong> ,
  64. 总数量 <strong>{{ (productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0)) ? productTotal.productTotalQty : '--' }}</strong> ,
  65. 总成本 <strong>{{ (productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0)) ? '¥'+productTotal.productTotalCost : '--' }}</strong>
  66. </div>
  67. </a-alert>
  68. <!-- 列表 -->
  69. <s-table
  70. class="sTable"
  71. ref="table"
  72. size="small"
  73. :rowKey="(record) => record.id"
  74. :columns="columns"
  75. :data="loadData"
  76. :scroll="{ x: 1180 }"
  77. bordered>
  78. </s-table>
  79. </a-collapse-panel>
  80. </a-collapse>
  81. </a-card>
  82. <!-- 单据记录 二期 -->
  83. <!-- <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
  84. <a-collapse :activeKey="['1']">
  85. <a-collapse-panel key="1" header="单据记录">
  86. <a-timeline class="timeline-box">
  87. <a-timeline-item>2021-02-01 15:22:38 王凯 审核通过</a-timeline-item>
  88. <a-timeline-item>
  89. <p>2021-02-01 15:22:38 王凯 审核通过</p>
  90. <p class="auxiliary-txt">产品编号JA-11076P的采购数量,由【10】修改为【5】</p>
  91. <p class="auxiliary-txt">产品编号JA-11076P的采购数量,由【10】修改为【5】</p>
  92. </a-timeline-item>
  93. <a-timeline-item>Technical testing 2015-09-01</a-timeline-item>
  94. <a-timeline-item>Network problems being solved 2015-09-01</a-timeline-item>
  95. </a-timeline>
  96. </a-collapse-panel>
  97. </a-collapse>
  98. </a-card> -->
  99. </a-spin>
  100. <!-- 打印 -->
  101. <div id="print"></div>
  102. </div>
  103. </template>
  104. <script>
  105. import { STable, VSelect } from '@/components'
  106. import { getOperationalPrecision } from '@/libs/tools.js'
  107. import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailPrint } from '@/api/sparePartsPur'
  108. export default {
  109. components: { STable, VSelect },
  110. data () {
  111. return {
  112. spinning: false,
  113. // 表头
  114. columns: [
  115. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  116. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  117. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  118. { title: '采购单价', dataIndex: 'putCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  119. { title: '采购数量', dataIndex: 'putQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  120. { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '采购金额', dataIndex: 'purchaseAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  122. { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  123. { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  124. ],
  125. // 加载数据方法 必须为 Promise 对象
  126. loadData: parameter => {
  127. this.disabled = true
  128. return sparePartsPurDetailList(Object.assign(parameter, { sparePartsPurchaseSn: this.$route.params.sn })).then(res => {
  129. const data = res.data
  130. const no = (data.pageNo - 1) * data.pageSize
  131. for (var i = 0; i < data.list.length; i++) {
  132. data.list[i].no = no + i + 1
  133. // 采购金额 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  134. data.list[i].purchaseAmount = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
  135. }
  136. this.localDataSource = data.list
  137. this.disabled = false
  138. return data
  139. })
  140. },
  141. localDataSource: [],
  142. basicInfoData: null, // 基本信息
  143. productTotal: null, // 合计
  144. printerType: 'NEEDLE' // 打印机类型
  145. }
  146. },
  147. computed: {
  148. isEdit () {
  149. return this.basicInfoData && this.basicInfoData.state != 'FINISH'
  150. }
  151. },
  152. methods: {
  153. // 返回列表
  154. handleBack () {
  155. this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list', query: { closeLastOldTab: true } })
  156. },
  157. // 打印预览/快捷打印
  158. handlePrint (type) {
  159. const _this = this
  160. _this.spinning = true
  161. sparePartsPurDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
  162. _this.spinning = false
  163. if (res.type == 'application/json') {
  164. var reader = new FileReader()
  165. reader.addEventListener('loadend', function () {
  166. const obj = JSON.parse(reader.result)
  167. _this.$notification.error({
  168. message: '提示',
  169. description: obj.message
  170. })
  171. })
  172. reader.readAsText(res)
  173. } else {
  174. this.print(res, type)
  175. }
  176. })
  177. },
  178. print (data, type) {
  179. if (!data) {
  180. return
  181. }
  182. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  183. document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
  184. if (type == 'preview') { // 预览
  185. window.open(url)
  186. } else if (type == 'print') { // 打印
  187. window.frames['printf'].focus()
  188. window.frames['printf'].print()
  189. }
  190. },
  191. // 基本信息
  192. getDetail () {
  193. sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
  194. if (res.status == 200) {
  195. this.basicInfoData = res.data
  196. } else {
  197. this.basicInfoData = null
  198. }
  199. })
  200. },
  201. // 合计
  202. getDetailCount () {
  203. sparePartsPurDetailCount({ sparePartsPurchaseSn: this.$route.params.sn }).then(res => {
  204. if (res.status == 200) {
  205. this.productTotal = res.data
  206. } else {
  207. this.productTotal = null
  208. }
  209. })
  210. },
  211. // 编辑
  212. handleEdit () {
  213. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/edit/${this.basicInfoData.id}/${this.basicInfoData.sparePartsPurchaseSn}` })
  214. }
  215. },
  216. beforeRouteEnter (to, from, next) {
  217. next(vm => {
  218. vm.getDetail()
  219. vm.getDetailCount()
  220. })
  221. }
  222. }
  223. </script>
  224. <style lang="less">
  225. .bulkWarehousingOrderDetail-cont{
  226. margin-bottom: 10px;
  227. .timeline-box{
  228. margin-top: 30px;
  229. .auxiliary-txt{
  230. color: #808695;
  231. }
  232. }
  233. }
  234. </style>