detail.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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="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 slot="extra" v-if="pageType=='pages'">
  18. <print :params="{allocateReturnSn: $route.params.sn || outBizSn}" :basicInfoData="basicInfoData" :disabled="localDataSource.length==0" @loading="spinning=true" @unloading="spinning=false"></print>
  19. </template>
  20. </a-page-header>
  21. <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
  22. <a-collapse :activeKey="['1']">
  23. <a-collapse-panel key="1" header="基础信息">
  24. <a-descriptions :column="3">
  25. <a-descriptions-item label="调拨退货单号">{{ (basicInfoData&&basicInfoData.allocateReturnNo) || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="调拨退货对象">{{ (basicInfoData&&basicInfoData.targetTypeDictValue) || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="调拨退货对象名称">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="调入仓库">{{ (basicInfoData&&basicInfoData.warehouseName) || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="费用类型">
  30. {{ (basicInfoData&&basicInfoData.costTypeName) || '--' }}
  31. </a-descriptions-item>
  32. <a-descriptions-item label="调拨退货类型">
  33. <div>
  34. <span v-if="basicInfoData&&basicInfoData.allocateSortName">{{ basicInfoData.allocateSortName || '--' }}</span>
  35. <span v-if="basicInfoData&&basicInfoData.allocateReturnTypeName">/{{ basicInfoData.allocateReturnTypeName || '--' }}</span>
  36. </div>
  37. </a-descriptions-item>
  38. <a-descriptions-item label="是否抓单">{{ basicInfoData&&basicInfoData.grabFlagDictValue || '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  40. <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remarks) || '--' }}</a-descriptions-item>
  41. </a-descriptions>
  42. </a-collapse-panel>
  43. </a-collapse>
  44. </a-card>
  45. <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
  46. <!-- 总计 -->
  47. <a-alert type="info" style="margin-bottom:10px">
  48. <div slot="message">
  49. 退货总数量:<strong>{{ (basicInfoData&&(basicInfoData.totalQty || basicInfoData.totalQty==0)) ? basicInfoData.totalQty : '--' }}</strong> ;
  50. 坏件总数量:<strong>{{ (basicInfoData&&(basicInfoData.totalBadQty || basicInfoData.totalBadQty==0)) ? basicInfoData.totalBadQty : '--' }}</strong> ;
  51. 返库总数量:<strong>{{ (basicInfoData&&(basicInfoData.totalBackStockQty || basicInfoData.totalBackStockQty==0)) ? basicInfoData.totalBackStockQty : '--' }}</strong> ;
  52. <span v-if="showPrice||$hasPermissions('M_transferReturnDetail_salesPrice')">退货总金额:<strong>{{ (basicInfoData&&(basicInfoData.totalPrice || basicInfoData.totalPrice==0)) ? toThousands(basicInfoData.totalPrice) : '--' }}</strong>;</span>
  53. </div>
  54. </a-alert>
  55. <!-- 列表 -->
  56. <s-table
  57. class="sTable"
  58. ref="table"
  59. size="small"
  60. :rowKey="(record) => record.id"
  61. :columns="columns"
  62. :data="loadData"
  63. :defaultLoadData="false"
  64. bordered>
  65. </s-table>
  66. </a-card>
  67. </a-spin>
  68. </div>
  69. </template>
  70. <script>
  71. import { commonMixin } from '@/utils/mixin'
  72. import { STable, VSelect } from '@/components'
  73. import print from './print.vue'
  74. import { allocReturnDetailQueryPage, allocateReturnQueryBySn } from '@/api/allocateReturn'
  75. export default {
  76. name: 'TransferReturnDetail',
  77. mixins: [commonMixin],
  78. components: { STable, VSelect, print },
  79. props: {
  80. outBizSn: { // 有值则为弹框,无值则为页面
  81. type: [Number, String],
  82. default: ''
  83. },
  84. showPrice:{
  85. type: Boolean,
  86. default: false
  87. },
  88. pageType: {
  89. type: String,
  90. default: 'pages'
  91. }
  92. },
  93. data () {
  94. return {
  95. spinning: false,
  96. // 加载数据方法 必须为 Promise 对象
  97. loadData: parameter => {
  98. this.spinning = true
  99. return allocReturnDetailQueryPage(Object.assign(parameter, { allocateReturnSn: this.outBizSn || this.$route.params.sn })).then(res => {
  100. let data
  101. if (res.status == 200) {
  102. data = res.data
  103. const no = (data.pageNo - 1) * data.pageSize
  104. for (var i = 0; i < data.list.length; i++) {
  105. data.list[i].no = no + i + 1
  106. }
  107. this.localDataSource = data.list
  108. }
  109. this.spinning = false
  110. return data
  111. })
  112. },
  113. basicInfoData: null, // 基本信息
  114. localDataSource: [],
  115. openModal: false,
  116. nowType: null
  117. }
  118. },
  119. computed: {
  120. isEdit () {
  121. return this.basicInfoData && ((this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData.state == 'FINANCIAL_REJECT') || (this.basicInfoData.state == 'AUDIT_REJECT')) && this.$hasPermissions('B_transferReturnEdit')
  122. },
  123. columns () {
  124. const _this = this
  125. const arr = [
  126. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  127. { title: '产品编码', dataIndex: 'product.code', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  128. { title: '产品名称', dataIndex: 'product.name', width: '27%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  129. { title: '单位', dataIndex: 'product.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '退货数量', dataIndex: 'returnQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  131. { title: '坏件数量', dataIndex: 'badQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '返库数量', dataIndex: 'backStockQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  133. ]
  134. if (this.basicInfoData && this.basicInfoData.grabFlag == '1') {
  135. arr.splice(1, 0, { title: '调拨单号', dataIndex: 'allocateNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } })
  136. }
  137. if(this.showPrice||this.$hasPermissions('M_transferReturnDetail_salesPrice')){
  138. const ind = this.basicInfoData && this.basicInfoData.grabFlag == '1' ? 1 : 0
  139. arr.splice(4+ind,0,{ title: '退货单价', dataIndex: 'price', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  140. arr.splice(8+ind,0,{ title: '退货金额', dataIndex: 'totalReturnPrice', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  141. }
  142. return arr
  143. }
  144. },
  145. methods: {
  146. // 返回列表
  147. handleBack () {
  148. this.$router.push({ name: 'transferReturnList', query: { closeLastOldTab: true } })
  149. },
  150. // 基本信息
  151. getDetail () {
  152. allocateReturnQueryBySn({ allocateReturnSn: this.outBizSn || this.$route.params.sn }).then(res => {
  153. if (res.status == 200) {
  154. this.basicInfoData = res.data
  155. } else {
  156. this.basicInfoData = null
  157. }
  158. })
  159. },
  160. // 编辑
  161. handleEdit () {
  162. const row = this.basicInfoData
  163. this.$router.push({ name: row.grabFlag == 1 ? 'transferReturnGrpEdit' : 'transferReturnEdit', params: { sn: row.allocateReturnSn, targetType: row.targetType, dealerLevel: row.dealerLevel } })
  164. },
  165. pageInit () {
  166. if (this.outBizSn || this.$route.params.sn) {
  167. this.$refs.table.refresh(true)
  168. this.getDetail()
  169. }
  170. }
  171. },
  172. mounted () {
  173. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  174. this.pageInit()
  175. }
  176. },
  177. activated () {
  178. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  179. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  180. this.pageInit()
  181. }
  182. },
  183. watch: {
  184. outBizSn (newValue, oldValue) {
  185. if (newValue) {
  186. this.pageInit()
  187. }
  188. }
  189. },
  190. beforeRouteEnter (to, from, next) {
  191. next(vm => {})
  192. }
  193. }
  194. </script>
  195. <style lang="less">
  196. .allocateBillDetail-wrap{
  197. .allocateBillDetail-back{
  198. margin-bottom: 10px;
  199. }
  200. .allocateBillDetail-cont{
  201. margin-bottom: 10px;
  202. }
  203. }
  204. </style>