123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- <template>
- <div class="chainTransferInDetail-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" class="chainTransferInDetail-cont" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="chainTransferInDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <a-button
- v-if="isEdit&&$hasPermissions('B_allocLinkagePutEdit')"
- type="primary"
- size="small"
- style="background-color: #1890ff;margin-left: 20px;border: #1890ff;"
- id="chainTransferInDetail-edit-btn"
- @click.stop="handleEdit">编辑</a-button>
- </template>
- <!-- 操作区,位于 title 行的行尾 -->
- <template slot="extra" v-if="$hasPermissions('B_allocLinkagePutPrint')">
- <a-radio-group key="3" v-model="printerType">
- <a-radio value="NEEDLE">针式</a-radio>
- <a-radio value="INK">喷墨</a-radio>
- </a-radio-group>
- <a-button key="2" id="chainTransferInDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
- <a-button key="1" type="primary" id="chainTransferInDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
- </template>
- </a-page-header>
- <!-- 基础信息 -->
- <a-card size="small" :bordered="false" class="chainTransferInDetail-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="基础信息">
- <a-descriptions :column="3">
- <a-descriptions-item label="调入单号">{{ (basicInfoData&&basicInfoData.allocationLinkagePutNo) || '--' }}</a-descriptions-item>
- <a-descriptions-item label="调出对象">{{ (basicInfoData&&basicInfoData.outTenantName) || '--' }}</a-descriptions-item>
- <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
- <a-descriptions-item label="财务状态">{{ (basicInfoData&&basicInfoData.settleStateDictValue) || '--' }}</a-descriptions-item>
- </a-descriptions>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
- <a-card size="small" :bordered="false" class="chainTransferInDetail-cont">
- <!-- 总计 -->
- <a-alert type="info" style="margin-bottom:10px">
- <div slot="message">
- 总款数 <strong>{{ (productTotal&&(productTotal.productTotalCategory || productTotal.productTotalCategory==0)) ? productTotal.productTotalCategory : '--' }}</strong> ,
- 总数量 <strong>{{ (productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0)) ? productTotal.productTotalQty : '--' }}</strong> ,
- 总成本 <strong>{{ (productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0)) ? '¥'+productTotal.productTotalCost : '--' }}</strong>
- </div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 1335 }"
- :defaultLoadData="false"
- bordered>
- </s-table>
- </a-card>
- </a-spin>
- <!-- 打印 -->
- <div id="print"></div>
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import { getOperationalPrecision } from '@/libs/tools.js'
- import { allocLinkagePutDetailList, allocLinkagePutDetailSn, allocLinkagePutDetailCount, allocLinkagePutDetailPrint } from '@/api/allocLinkagePut'
- export default {
- components: { STable, VSelect },
- data () {
- return {
- spinning: false,
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
- { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '成本价(¥)', dataIndex: 'putCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '调入数量', dataIndex: 'putQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '成本小计(¥)', dataIndex: 'costSubtotal', width: 115, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' } }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- const params = Object.assign(parameter, { allocationLinkagePutSn: this.$route.params.sn })
- this.spinning = true
- return allocLinkagePutDetailList(params).then(res => {
- const data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
- data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
- }
- this.getDetailCount(params)
- this.localDataSource = data.list
- this.spinning = false
- return data
- })
- },
- basicInfoData: null, // 基本信息
- productTotal: null, // 合计
- localDataSource: [],
- printerType: 'NEEDLE' // 打印机类型
- }
- },
- computed: {
- isEdit () {
- return (this.basicInfoData && this.basicInfoData.state == 'WAIT_AUDIT' && this.$hasPermissions('B_allocLinkagePutEdit'))
- }
- },
- methods: {
- // 返回列表
- handleBack () {
- this.$router.push({ path: '/allocationManagement/chainTransferIn/list', query: { closeLastOldTab: true } })
- },
- // 基本信息
- getDetail () {
- allocLinkagePutDetailSn({ sn: this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- this.basicInfoData = res.data
- } else {
- this.basicInfoData = null
- }
- })
- },
- // 合计
- getDetailCount (params) {
- allocLinkagePutDetailCount(params).then(res => {
- if (res.status == 200) {
- this.productTotal = res.data
- } else {
- this.productTotal = null
- }
- })
- },
- // 编辑
- handleEdit () {
- this.$router.push({ path: `/allocationManagement/chainTransferIn/edit/${this.basicInfoData.id}/${this.basicInfoData.allocationLinkagePutSn}` })
- },
- // 打印预览/快捷打印
- handlePrint (type) {
- const _this = this
- _this.spinning = true
- allocLinkagePutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
- _this.spinning = false
- if (res.type == 'application/json') {
- var reader = new FileReader()
- reader.addEventListener('loadend', function () {
- const obj = JSON.parse(reader.result)
- _this.$notification.error({
- message: '提示',
- description: obj.message
- })
- })
- reader.readAsText(res)
- } else {
- this.print(res, type)
- }
- })
- },
- print (data, type) {
- if (!data) {
- return
- }
- const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
- document.getElementById('print').innerHTML = '<iframe id="printfcid" name="printfcid" src="' + url + '" hidden></iframe>'
- if (type == 'preview') { // 预览
- window.open(url)
- } else if (type == 'print') { // 打印
- window.frames['printfcid'].focus()
- window.frames['printfcid'].print()
- }
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.$refs.table.refresh(true)
- this.getDetail()
- }
- },
- activated () {
- // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
- if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
- this.$refs.table.refresh(true)
- this.getDetail()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .chainTransferInDetail-wrap{
- .chainTransferInDetail-cont{
- margin-bottom: 10px;
- }
- }
- </style>
|