GoodsOrder.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="goods-order-cont">
  3. <!-- 标题 -->
  4. <div class="goods-order-header">
  5. <!-- 待发货 -->
  6. <div class="unDelivered" v-if="type == 'orderGoods'">
  7. <p class="order-status">待发货</p>
  8. <a-button v-if="$hasPermissions('B_order_sendGoods')" id="goodsOrder-send" type="primary" size="small" @click="sendGoods">立即发货</a-button>
  9. </div>
  10. <!-- 已发货 -->
  11. <div class="delivered" v-if="type == 'express'">
  12. <p class="companyInfo">快递公司:<span>{{ orderData.expressName }}</span></p>
  13. <div class="orderNoInfo">
  14. <p class="orderNo">运单编号:<span>{{ orderData.expressNum }}</span></p>
  15. <a-button id="goodsOrder-copy" size="small" v-clipboard:copy="orderData.expressNum" v-clipboard:success="onCopy">复制</a-button>
  16. </div>
  17. </div>
  18. </div>
  19. <!-- 表格 -->
  20. <a-table
  21. v-if="dataSource.length>0"
  22. ref="table"
  23. size="default"
  24. :row-selection="rowSelection"
  25. :columns="columns"
  26. :rowKey="(record) => record.orderGoodsNo"
  27. :data-source="dataSource"
  28. :pagination="false"
  29. bordered>
  30. </a-table>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'GoodsOrder',
  36. props: {
  37. orderData: {
  38. type: [Object, Array],
  39. default: () => {
  40. return {}
  41. }
  42. },
  43. type: {
  44. type: String,
  45. default: ''
  46. },
  47. isReset: {
  48. type: Boolean,
  49. default: false
  50. }
  51. },
  52. computed: {
  53. dataSource: function () {
  54. if (this.type == 'orderGoods') {
  55. return this.orderData
  56. } else if (this.type == 'express') {
  57. return this.orderData.orderGoodsList
  58. } else {
  59. return []
  60. }
  61. },
  62. rowSelection: function () {
  63. // type=='orderGoods' ? { selectedRowKeys: selectedRowKeys, onChange: onSelectChange } : null,
  64. if (this.type == 'orderGoods' && this.$hasPermissions('B_order_sendGoods')) {
  65. return { selectedRowKeys: this.selectedRowKeys, onChange: this.onSelectChange }
  66. } else {
  67. return null
  68. }
  69. }
  70. },
  71. data () {
  72. return {
  73. selectedRowKeys: [], // 已选项
  74. columns: [
  75. { title: '商品名称', dataIndex: 'goodsName', width: 200, align: 'center' },
  76. { title: '商品价格', dataIndex: 'payGold', width: 200, align: 'center' },
  77. { title: '购买数量', dataIndex: 'buyQty', width: 200, align: 'center' }
  78. ]
  79. }
  80. },
  81. methods: {
  82. // 选择商品
  83. onSelectChange (selectedRowKeys) {
  84. this.selectedRowKeys = selectedRowKeys
  85. },
  86. // 立即发货
  87. sendGoods () {
  88. if (this.selectedRowKeys.length < 1) {
  89. this.$message.warning('请勾选需要发货的商品')
  90. return
  91. }
  92. this.$emit('sendGoods', this.selectedRowKeys)
  93. },
  94. // 复制成功
  95. onCopy (e) {
  96. this.$message.success('复制成功')
  97. }
  98. },
  99. watch: {
  100. // 是否重置表格选中状态
  101. isReset (newValue, oldValue) {
  102. if (newValue) {
  103. this.selectedRowKeys = []
  104. }
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="less" scoped>
  110. .goods-order-cont{
  111. p{
  112. margin: 0;
  113. }
  114. .goods-order-header{
  115. border-left: 5px solid #ff9900;
  116. padding-left: 10px;
  117. margin: 25px 0 20px;
  118. .unDelivered{
  119. .order-status{
  120. display: inline-block;
  121. margin-right: 65px;
  122. }
  123. }
  124. .delivered{
  125. .companyInfo{
  126. display: inline-block;
  127. margin-right: 65px;
  128. }
  129. .orderNoInfo{
  130. display: inline-block;
  131. .orderNo{
  132. display: inline-block;
  133. margin-right: 20px;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. </style>