detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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: pageType=='pages' ? '16px 24px' : '0px 24px' }" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle" v-if="pageType=='pages'">
  7. <a id="allocateBillDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <a-button
  9. v-if="isEdit"
  10. type="link"
  11. class="button-default"
  12. id="allocateBillDetail-edit-btn"
  13. @click.stop="handleEdit">
  14. <a-icon type="edit"/>编辑
  15. </a-button>
  16. <a-button type="link" class="button-default" @click="showDetail=!showDetail">
  17. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  18. </a-button>
  19. </template>
  20. <!-- 操作区,位于 title 行的行尾 -->
  21. <template slot="extra" v-if="pageType=='pages'">
  22. <print :params="{allocateReturnSn: $route.params.sn || outBizSn}" :basicInfoData="basicInfoData" :disabled="localDataSource.length==0" @loading="spinning=true" @unloading="spinning=false"></print>
  23. </template>
  24. </a-page-header>
  25. <div ref="tableSearch">
  26. <a-card size="small" :bordered="false" :class="pageType=='pages'?'allocateBillDetail-cont':''" v-show="showDetail">
  27. <a-descriptions :column="3" v-if="pageType=='pages'">
  28. <a-descriptions-item label="调拨退货单号">{{ (basicInfoData&&basicInfoData.allocateReturnNo) || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="调拨退货对象">{{ (basicInfoData&&basicInfoData.targetTypeDictValue) || '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="调拨退货对象名称">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  31. <a-descriptions-item label="调入仓库">{{ (basicInfoData&&basicInfoData.warehouseName) || '--' }}</a-descriptions-item>
  32. <a-descriptions-item label="费用类型">
  33. {{ (basicInfoData&&basicInfoData.costTypeName) || '--' }}
  34. </a-descriptions-item>
  35. <a-descriptions-item label="调拨退货类型">
  36. <div>
  37. <span v-if="basicInfoData&&basicInfoData.allocateSortName">{{ basicInfoData.allocateSortName || '--' }}</span>
  38. <span v-if="basicInfoData&&basicInfoData.allocateReturnTypeName">/{{ basicInfoData.allocateReturnTypeName || '--' }}</span>
  39. </div>
  40. </a-descriptions-item>
  41. <a-descriptions-item label="是否抓单">{{ basicInfoData&&basicInfoData.grabFlagDictValue || '--' }}</a-descriptions-item>
  42. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  43. <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remarks) || '--' }}</a-descriptions-item>
  44. </a-descriptions>
  45. <a-collapse :activeKey="['1']" v-else>
  46. <a-collapse-panel key="1" header="基础信息">
  47. <a-descriptions :column="3">
  48. <a-descriptions-item label="调拨退货单号">{{ (basicInfoData&&basicInfoData.allocateReturnNo) || '--' }}</a-descriptions-item>
  49. <a-descriptions-item label="调拨退货对象">{{ (basicInfoData&&basicInfoData.targetTypeDictValue) || '--' }}</a-descriptions-item>
  50. <a-descriptions-item label="调拨退货对象名称">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  51. <a-descriptions-item label="调入仓库">{{ (basicInfoData&&basicInfoData.warehouseName) || '--' }}</a-descriptions-item>
  52. <a-descriptions-item label="费用类型">
  53. {{ (basicInfoData&&basicInfoData.costTypeName) || '--' }}
  54. </a-descriptions-item>
  55. <a-descriptions-item label="调拨退货类型">
  56. <div>
  57. <span v-if="basicInfoData&&basicInfoData.allocateSortName">{{ basicInfoData.allocateSortName || '--' }}</span>
  58. <span v-if="basicInfoData&&basicInfoData.allocateReturnTypeName">/{{ basicInfoData.allocateReturnTypeName || '--' }}</span>
  59. </div>
  60. </a-descriptions-item>
  61. <a-descriptions-item label="是否抓单">{{ basicInfoData&&basicInfoData.grabFlagDictValue || '--' }}</a-descriptions-item>
  62. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  63. <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remarks) || '--' }}</a-descriptions-item>
  64. </a-descriptions>
  65. </a-collapse-panel>
  66. </a-collapse>
  67. </a-card>
  68. </div>
  69. <a-card size="small" :bordered="false">
  70. <!-- 总计 -->
  71. <a-alert type="info" style="margin-bottom:10px">
  72. <div slot="message">
  73. 退货总数量:<strong>{{ (basicInfoData&&(basicInfoData.totalQty || basicInfoData.totalQty==0)) ? basicInfoData.totalQty : '--' }}</strong> ;
  74. 坏件总数量:<strong>{{ (basicInfoData&&(basicInfoData.totalBadQty || basicInfoData.totalBadQty==0)) ? basicInfoData.totalBadQty : '--' }}</strong> ;
  75. 返库总数量:<strong>{{ (basicInfoData&&(basicInfoData.totalBackStockQty || basicInfoData.totalBackStockQty==0)) ? basicInfoData.totalBackStockQty : '--' }}</strong> ;
  76. <span v-if="showPrice||$hasPermissions('M_transferReturnDetail_salesPrice')">退货总金额:<strong>{{ (basicInfoData&&(basicInfoData.totalPrice || basicInfoData.totalPrice==0)) ? toThousands(basicInfoData.totalPrice) : '--' }}</strong>;</span>
  77. </div>
  78. </a-alert>
  79. <!-- 列表 -->
  80. <s-table
  81. class="sTable"
  82. ref="table"
  83. size="small"
  84. :rowKey="(record) => record.id"
  85. :columns="columns"
  86. :data="loadData"
  87. :style="{ height:outBizSn? '260px': tableHeight+70+'px' }"
  88. :scroll="{ y:outBizSn?260: tableHeight }"
  89. :defaultLoadData="false"
  90. bordered>
  91. </s-table>
  92. </a-card>
  93. </a-spin>
  94. </div>
  95. </template>
  96. <script>
  97. import { commonMixin } from '@/utils/mixin'
  98. // 组件
  99. import { STable, VSelect } from '@/components'
  100. import print from './print.vue'
  101. // 接口
  102. import { allocReturnDetailQueryPage, allocateReturnQueryBySn } from '@/api/allocateReturn'
  103. export default {
  104. name: 'TransferReturnDetail',
  105. mixins: [commonMixin],
  106. components: { STable, VSelect, print },
  107. props: {
  108. outBizSn: { // 有值则为弹框,无值则为页面
  109. type: [Number, String],
  110. default: ''
  111. },
  112. showPrice: {// 是否显示价格
  113. type: Boolean,
  114. default: false
  115. },
  116. pageType: {// 页面类型
  117. type: String,
  118. default: 'pages'
  119. }
  120. },
  121. data () {
  122. return {
  123. spinning: false,
  124. // 加载数据方法 必须为 Promise 对象
  125. loadData: parameter => {
  126. this.spinning = true
  127. // 获取列表数据 有分页
  128. return allocReturnDetailQueryPage(Object.assign(parameter, { allocateReturnSn: this.outBizSn || this.$route.params.sn })).then(res => {
  129. let data
  130. if (res.status == 200) {
  131. data = res.data
  132. // 计算表格序号
  133. const no = (data.pageNo - 1) * data.pageSize
  134. for (var i = 0; i < data.list.length; i++) {
  135. data.list[i].no = no + i + 1
  136. }
  137. this.localDataSource = data.list
  138. }
  139. this.spinning = false
  140. return data
  141. })
  142. },
  143. basicInfoData: null, // 基本信息
  144. localDataSource: [], // 表格数据
  145. showDetail: true, // 显示隐藏基础信息
  146. tableHeight: 0// 表格高度
  147. }
  148. },
  149. computed: {
  150. // 是否可编辑基础信息
  151. isEdit () {
  152. return this.basicInfoData && ((this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData.state == 'FINANCIAL_REJECT') || (this.basicInfoData.state == 'AUDIT_REJECT')) && this.$hasPermissions('B_transferReturnEdit')
  153. },
  154. // 表头
  155. columns () {
  156. const _this = this
  157. const arr = [
  158. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  159. { title: '产品编码', dataIndex: 'product.code', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
  160. { title: '产品名称', dataIndex: 'product.name', width: '27%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  161. { title: '单位', dataIndex: 'product.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  162. { title: '退货数量', dataIndex: 'returnQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  163. { title: '坏件数量', dataIndex: 'badQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  164. { title: '返库数量', dataIndex: 'backStockQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  165. ]
  166. if (this.basicInfoData && this.basicInfoData.grabFlag == '1') {
  167. arr.splice(1, 0, { title: '调拨单号', dataIndex: 'allocateNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } })
  168. }
  169. if (this.showPrice || this.$hasPermissions('M_transferReturnDetail_salesPrice')) {
  170. const ind = this.basicInfoData && this.basicInfoData.grabFlag == '1' ? 1 : 0
  171. arr.splice(4 + ind, 0, { title: '退货单价', dataIndex: 'price', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  172. arr.splice(8 + ind, 0, { title: '退货金额', dataIndex: 'totalReturnPrice', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  173. }
  174. return arr
  175. }
  176. },
  177. watch: {
  178. // 显示隐藏基础信息 监听表格高度变化
  179. showDetail (newValue, oldValue) {
  180. const _this = this
  181. this.$nextTick(() => { // 页面渲染完成后的回调
  182. _this.setTableH()
  183. })
  184. },
  185. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  186. this.setTableH()
  187. },
  188. // 根据页面类型计算表格高度
  189. outBizSn (newValue, oldValue) {
  190. if (newValue) {
  191. this.pageInit()
  192. }
  193. }
  194. },
  195. methods: {
  196. // 返回列表
  197. handleBack () {
  198. this.$router.push({ name: 'transferReturnList', query: { closeLastOldTab: true } })
  199. },
  200. // 基本信息
  201. getDetail () {
  202. allocateReturnQueryBySn({ allocateReturnSn: this.outBizSn || this.$route.params.sn }).then(res => {
  203. if (res.status == 200) {
  204. this.basicInfoData = res.data
  205. } else {
  206. this.basicInfoData = null
  207. }
  208. })
  209. },
  210. // 编辑
  211. handleEdit () {
  212. const row = this.basicInfoData
  213. this.$router.push({ name: row.grabFlag == 1 ? 'transferReturnGrpEdit' : 'transferReturnEdit', params: { sn: row.allocateReturnSn, targetType: row.targetType, dealerLevel: row.dealerLevel } })
  214. },
  215. // 初始化
  216. pageInit () {
  217. if (this.outBizSn || this.$route.params.sn) {
  218. this.$refs.table.refresh(true)
  219. this.getDetail()
  220. this.setTableH()
  221. }
  222. },
  223. // 计算表格高度
  224. setTableH () {
  225. const tableSearchH = this.$refs.tableSearch.offsetHeight
  226. this.tableHeight = window.innerHeight - tableSearchH - 285
  227. }
  228. },
  229. mounted () {
  230. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  231. this.pageInit()
  232. }
  233. },
  234. activated () {
  235. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  236. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  237. this.pageInit()
  238. }
  239. },
  240. beforeRouteEnter (to, from, next) {
  241. next(vm => {})
  242. }
  243. }
  244. </script>
  245. <style lang="less">
  246. .allocateBillDetail-wrap{
  247. .allocateBillDetail-back{
  248. margin-bottom: 6px;
  249. }
  250. .allocateBillDetail-cont{
  251. margin-bottom: 6px;
  252. }
  253. }
  254. </style>