detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="urgentItemsOffsetDetail-page-wrapper" :style="{'paddingBottom': (!isWriteDown&&$hasPermissions('B_urgentWriteDown')) ? '64px' : '0px'}">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 操作 -->
  5. <a-page-header :ghost="false" :backIcon="false" class="urgentItemsOffsetDetail-operation-wrapper" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }" >
  6. <!-- 自定义的二级文字标题 -->
  7. <template slot="subTitle" v-if="!outBizSn">
  8. <a id="urgentItemsOffsetDetail-btn-back" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  9. <a style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">单号:{{ detailData&&detailData.urgentBillNo || '--' }}</a>
  10. </template>
  11. </a-page-header>
  12. <!-- 急件单信息 -->
  13. <a-card size="small" :bordered="false" class="urgentItemsOffsetDetail-info-wrapper">
  14. <a-collapse :activeKey="['1']" v-if="detailData&&detailData.bizType!='REPLENISH'">
  15. <a-collapse-panel key="1" header="基础信息">
  16. <a-descriptions :column="3">
  17. <a-descriptions-item label="客户名称">{{ (detailData&&detailData.buyerNameCurrent) || '--' }}{{ detailData&&detailData.buyerName?detailData.buyerName==detailData.buyerNameCurrent?'':'('+detailData.buyerName+')':'' }}</a-descriptions-item>
  18. <a-descriptions-item label="单位地址">
  19. <div v-if="detailData&&(detailData.shippingAddressProvinceName || detailData.shippingAddressCityName || detailData.shippingAddressCountyName || detailData.shippingAddress)">
  20. {{ (detailData&&detailData.shippingAddressProvinceName) || '' }}
  21. {{ (detailData&&detailData.shippingAddressCityName) || '' }}
  22. {{ (detailData&&detailData.shippingAddressCountyName) || '' }}
  23. {{ (detailData&&detailData.shippingAddress) || '' }}
  24. </div>
  25. <span v-else>--</span>
  26. </a-descriptions-item>
  27. <a-descriptions-item label="联系电话">{{ detailData&&detailData.consigneeTel || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleDictValue || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="急件单号">{{ (detailData&&detailData.urgentBillNo) || '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="状态">{{ (detailData&&detailData.statusDictValue) || '--' }}</a-descriptions-item>
  31. </a-descriptions>
  32. </a-collapse-panel>
  33. </a-collapse>
  34. <a-collapse :activeKey="['1']" v-else>
  35. <a-collapse-panel key="1" header="基础信息">
  36. <a-descriptions :column="3">
  37. <a-descriptions-item label="关联客户">{{ (detailData&&detailData.customerName) || '--' }}</a-descriptions-item>
  38. <a-descriptions-item label="货架名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="急件单号">{{ (detailData&&detailData.urgentBillNo) || '--' }}</a-descriptions-item>
  40. <a-descriptions-item label="状态">{{ (detailData&&detailData.statusDictValue) || '--' }}</a-descriptions-item>
  41. </a-descriptions>
  42. </a-collapse-panel>
  43. </a-collapse>
  44. </a-card>
  45. <!-- 表格 -->
  46. <a-card size="small" :bordered="false" class="urgentItemsOffsetDetail-table-wrapper">
  47. <!-- 合计 -->
  48. <a-alert type="info" style="margin-bottom:15px" v-if="detailData">
  49. <div class="ftext" slot="message">
  50. 总款数:<strong>{{ (detailData&&(detailData.totalCategory || detailData.totalCategory == 0)) ? detailData.totalCategory : '--' }}</strong>;
  51. 总数量:<strong>{{ (detailData&&(detailData.totalQty || detailData.totalQty == 0)) ? detailData.totalQty : '--' }}</strong>。
  52. </div>
  53. </a-alert>
  54. <s-table
  55. class="sTable"
  56. ref="table"
  57. size="small"
  58. :rowKey="(record) => record.id"
  59. :columns="isWriteDown ? columns : unColumns"
  60. :data="loadData"
  61. :defaultLoadData="false"
  62. bordered>
  63. <!-- 库存数量 -->
  64. <template slot="inventoryQuantity" slot-scope="text, record">
  65. <span v-if="record.stockEntity&&(record.stockEntity.currentStockQty||record.stockEntity.currentStockQty==0)" :class="[record.stockEntity.currentStockQty < record.qty ? 'red' : '']" :style="{fontWeight: record.stockEntity.currentStockQty < record.qty?'bold':''}">{{ record.stockEntity.currentStockQty }}</span>
  66. <span v-else>--</span>
  67. </template>
  68. </s-table>
  69. </a-card>
  70. </a-spin>
  71. <div class="affix-cont" v-if="!isWriteDown&&$hasPermissions('B_urgentWriteDown')&&!spinning">
  72. <a-button
  73. size="large"
  74. style="padding: 0 60px;"
  75. type="primary"
  76. :disabled="spinning"
  77. class="button-primary"
  78. @click="handleSubmit"
  79. id="urgentItemsOffsetDetail-btn-submit">冲减</a-button>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import { commonMixin } from '@/utils/mixin'
  85. import { STable, VSelect } from '@/components'
  86. import { urgentWriteDown, urgentDetailSn, urgentDetailList } from '@/api/urgent'
  87. export default {
  88. name: 'UrgentOffsetDetail',
  89. components: { STable, VSelect },
  90. mixins: [commonMixin],
  91. props: {
  92. outBizSn: { // 有值则为弹框,无值则为页面
  93. type: [Number, String],
  94. default: ''
  95. }
  96. },
  97. data () {
  98. return {
  99. spinning: false,
  100. unColumns: [
  101. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  102. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  104. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '20%', customRender: function (text) { return text || '--' }, align: 'center' },
  105. { title: '库存数量', scopedSlots: { customRender: 'inventoryQuantity' }, width: '12%', align: 'center' },
  106. { title: '未冲减数量', dataIndex: 'qty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  107. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '11%', align: 'center', customRender: function (text) { return text || '--' } }
  108. ],
  109. // 加载数据方法 必须为 Promise 对象
  110. loadData: parameter => {
  111. this.disabled = true
  112. return urgentDetailList(Object.assign(parameter, { urgentBillSn: this.outBizSn || this.$route.params.sn })).then(res => {
  113. let data
  114. if (res.status == 200) {
  115. data = res.data
  116. const no = (data.pageNo - 1) * data.pageSize
  117. for (var i = 0; i < data.list.length; i++) {
  118. data.list[i].no = no + i + 1
  119. data.list[i].warehouseName = data.list[i].warehouseEntity && data.list[i].warehouseEntity.name || '--'
  120. data.list[i].warehouseLocationName = data.list[i].warehouseLocationEntity && data.list[i].warehouseLocationEntity.name || '--'
  121. }
  122. this.disabled = false
  123. }
  124. return data
  125. })
  126. },
  127. detailData: null // 详情数据
  128. }
  129. },
  130. computed: {
  131. // 是否已经冲减
  132. isWriteDown () {
  133. return this.detailData && this.detailData.status == 'FINISH'
  134. },
  135. columns () {
  136. const _this = this
  137. const arr = [
  138. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  139. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '17%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  141. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '入库时间', dataIndex: 'stockInDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '仓库', dataIndex: 'warehouseName', width: '7%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  144. { title: '仓位', dataIndex: 'warehouseLocationName', width: '7%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  145. // { title: '成本价', dataIndex: 'cost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  146. { title: '已冲减数量', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  147. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } }
  148. // { title: '成本小计', dataIndex: 'totalCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  149. ]
  150. // 成本价权限
  151. if (this.$hasPermissions('M_ShowAllCost')) {
  152. arr.splice(7, 0, { title: '成本价', dataIndex: 'cost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  153. arr.splice(10, 0, { title: '成本小计', dataIndex: 'totalCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  154. }
  155. return arr
  156. }
  157. },
  158. methods: {
  159. // 返回
  160. handleBack () {
  161. this.$router.push({ name: 'urgentItemsOffsetList' })
  162. },
  163. // 详情
  164. getDetail () {
  165. urgentDetailSn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  166. if (res.status == 200) {
  167. this.detailData = res.data
  168. } else {
  169. this.detailData = null
  170. }
  171. })
  172. },
  173. // 冲减
  174. handleSubmit () {
  175. const _this = this
  176. this.$confirm({
  177. title: '提示',
  178. content: '确定要进行冲减吗?',
  179. centered: true,
  180. onOk () {
  181. _this.spinning = true
  182. urgentWriteDown({ urgentBillSn: _this.outBizSn || _this.$route.params.sn }).then(res => {
  183. if (res.status == 200) {
  184. _this.$message.success(res.message)
  185. // 刷新页面
  186. _this.getDetail()
  187. _this.$refs.table.refresh()
  188. _this.spinning = false
  189. } else {
  190. _this.spinning = false
  191. }
  192. })
  193. }
  194. })
  195. }
  196. },
  197. mounted () {
  198. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  199. this.$refs.table.refresh(true)
  200. this.getDetail()
  201. }
  202. },
  203. activated () {
  204. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  205. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  206. this.$refs.table.refresh(true)
  207. this.getDetail()
  208. }
  209. },
  210. beforeRouteEnter (to, from, next) {
  211. next(vm => {})
  212. }
  213. }
  214. </script>
  215. <style lang="less">
  216. .urgentItemsOffsetDetail-page-wrapper{
  217. position: relative;
  218. height: 100%;
  219. box-sizing: border-box;
  220. >.ant-spin-nested-loading{
  221. overflow-y: auto;
  222. height: 100%;
  223. }
  224. .urgentItemsOffsetDetail-info-wrapper{
  225. margin: 6px 0;
  226. .item-cont {
  227. margin-bottom: 10px;
  228. display: flex;
  229. .item-label {
  230. width: 115px;
  231. font-size: 14px;
  232. color: rgba(0, 0, 0);
  233. flex-shrink: 0;
  234. }
  235. .item-main {
  236. flex-grow: 1;
  237. word-break: break-all;
  238. }
  239. }
  240. }
  241. .urgentItemsOffsetDetail-table-wrapper{
  242. .red{
  243. color: #ed1c24;
  244. }
  245. }
  246. }
  247. </style>