detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. import { STable, VSelect } from '@/components'
  99. import print from './print.vue'
  100. import { allocReturnDetailQueryPage, allocateReturnQueryBySn } from '@/api/allocateReturn'
  101. export default {
  102. name: 'TransferReturnDetail',
  103. mixins: [commonMixin],
  104. components: { STable, VSelect, print },
  105. props: {
  106. outBizSn: { // 有值则为弹框,无值则为页面
  107. type: [Number, String],
  108. default: ''
  109. },
  110. showPrice: {
  111. type: Boolean,
  112. default: false
  113. },
  114. pageType: {
  115. type: String,
  116. default: 'pages'
  117. }
  118. },
  119. data () {
  120. return {
  121. spinning: false,
  122. // 加载数据方法 必须为 Promise 对象
  123. loadData: parameter => {
  124. this.spinning = true
  125. return allocReturnDetailQueryPage(Object.assign(parameter, { allocateReturnSn: this.outBizSn || this.$route.params.sn })).then(res => {
  126. let data
  127. if (res.status == 200) {
  128. data = res.data
  129. const no = (data.pageNo - 1) * data.pageSize
  130. for (var i = 0; i < data.list.length; i++) {
  131. data.list[i].no = no + i + 1
  132. }
  133. this.localDataSource = data.list
  134. }
  135. this.spinning = false
  136. return data
  137. })
  138. },
  139. basicInfoData: null, // 基本信息
  140. localDataSource: [],
  141. openModal: false,
  142. nowType: null,
  143. showDetail: true,
  144. tableHeight: 0
  145. }
  146. },
  147. computed: {
  148. isEdit () {
  149. return this.basicInfoData && ((this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData.state == 'FINANCIAL_REJECT') || (this.basicInfoData.state == 'AUDIT_REJECT')) && this.$hasPermissions('B_transferReturnEdit')
  150. },
  151. columns () {
  152. const _this = this
  153. const arr = [
  154. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  155. { title: '产品编码', dataIndex: 'product.code', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
  156. { title: '产品名称', dataIndex: 'product.name', width: '27%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  157. { title: '单位', dataIndex: 'product.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '退货数量', dataIndex: 'returnQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  159. { title: '坏件数量', dataIndex: 'badQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  160. { title: '返库数量', dataIndex: 'backStockQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  161. ]
  162. if (this.basicInfoData && this.basicInfoData.grabFlag == '1') {
  163. arr.splice(1, 0, { title: '调拨单号', dataIndex: 'allocateNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } })
  164. }
  165. if (this.showPrice || this.$hasPermissions('M_transferReturnDetail_salesPrice')) {
  166. const ind = this.basicInfoData && this.basicInfoData.grabFlag == '1' ? 1 : 0
  167. arr.splice(4 + ind, 0, { title: '退货单价', dataIndex: 'price', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  168. arr.splice(8 + ind, 0, { title: '退货金额', dataIndex: 'totalReturnPrice', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  169. }
  170. return arr
  171. }
  172. },
  173. watch: {
  174. showDetail (newValue, oldValue) {
  175. const _this = this
  176. this.$nextTick(() => { // 页面渲染完成后的回调
  177. _this.setTableH()
  178. })
  179. },
  180. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  181. this.setTableH()
  182. },
  183. outBizSn (newValue, oldValue) {
  184. if (newValue) {
  185. this.pageInit()
  186. }
  187. }
  188. },
  189. methods: {
  190. // 返回列表
  191. handleBack () {
  192. this.$router.push({ name: 'transferReturnList', query: { closeLastOldTab: true } })
  193. },
  194. // 基本信息
  195. getDetail () {
  196. allocateReturnQueryBySn({ allocateReturnSn: this.outBizSn || this.$route.params.sn }).then(res => {
  197. if (res.status == 200) {
  198. this.basicInfoData = res.data
  199. } else {
  200. this.basicInfoData = null
  201. }
  202. })
  203. },
  204. // 编辑
  205. handleEdit () {
  206. const row = this.basicInfoData
  207. this.$router.push({ name: row.grabFlag == 1 ? 'transferReturnGrpEdit' : 'transferReturnEdit', params: { sn: row.allocateReturnSn, targetType: row.targetType, dealerLevel: row.dealerLevel } })
  208. },
  209. pageInit () {
  210. if (this.outBizSn || this.$route.params.sn) {
  211. this.$refs.table.refresh(true)
  212. this.getDetail()
  213. this.setTableH()
  214. }
  215. },
  216. setTableH () {
  217. const tableSearchH = this.$refs.tableSearch.offsetHeight
  218. this.tableHeight = window.innerHeight - tableSearchH - 285
  219. }
  220. },
  221. mounted () {
  222. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  223. this.pageInit()
  224. }
  225. },
  226. activated () {
  227. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  228. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  229. this.pageInit()
  230. }
  231. },
  232. beforeRouteEnter (to, from, next) {
  233. next(vm => {})
  234. }
  235. }
  236. </script>
  237. <style lang="less">
  238. .allocateBillDetail-wrap{
  239. .allocateBillDetail-back{
  240. margin-bottom: 6px;
  241. }
  242. .allocateBillDetail-cont{
  243. margin-bottom: 6px;
  244. }
  245. }
  246. </style>