confirmModal.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <a-modal
  3. centered
  4. class="replenishmentManagement-confirm-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="modalTit"
  8. v-model="isShow"
  9. @cancel="isShow = false"
  10. :width="800">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-descriptions>
  13. <a-descriptions-item label="补货单号">{{ nowData && nowData.replenishBillNo || '--' }}</a-descriptions-item>
  14. <a-descriptions-item label="创建时间">{{ nowData && nowData.createDate || '--' }}</a-descriptions-item>
  15. </a-descriptions>
  16. <!-- 列表 -->
  17. <s-table
  18. class="sTable"
  19. ref="table"
  20. size="small"
  21. :rowKey="(record) => record.id"
  22. :columns="columns"
  23. :data="loadData"
  24. :defaultLoadData="false"
  25. :showPagination="false"
  26. :scroll="{ y: 450 }"
  27. bordered>
  28. <!-- 实发数量 -->
  29. <template slot="confirmQty" slot-scope="text, record">
  30. <a-input-number
  31. size="small"
  32. id="replenishmentManagement-confirm-confirmQty"
  33. v-model="record.confirmQty"
  34. :precision="0"
  35. :min="0"
  36. :max="record.qty"
  37. placeholder="请输入"
  38. style="width: 100%" />
  39. </template>
  40. </s-table>
  41. <div class="btn-cont">
  42. <a-button type="primary" id="replenishmentManagement-confirm-modal-save" @click="handleSave">确认补货</a-button>
  43. <a-button id="replenishmentManagement-confirm-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  44. </div>
  45. </a-spin>
  46. </a-modal>
  47. </template>
  48. <script>
  49. import { commonMixin } from '@/utils/mixin'
  50. import { STable, VSelect } from '@/components'
  51. import { shelfReplenishDetailList } from '@/api/shelfReplenish'
  52. export default {
  53. name: 'ConfirmModal',
  54. components: { STable, VSelect },
  55. mixins: [commonMixin],
  56. props: {
  57. openModal: { // 弹框显示状态
  58. type: Boolean,
  59. default: false
  60. },
  61. nowData: {
  62. type: Object,
  63. default: () => {
  64. return {}
  65. }
  66. }
  67. },
  68. data () {
  69. return {
  70. spinning: false,
  71. isShow: this.openModal, // 是否打开弹框
  72. columns: [
  73. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  74. { title: '产品编码', dataIndex: 'product.code', width: '22%', align: 'center', customRender: function (text) { return text || '--' } },
  75. { title: '产品名称', dataIndex: 'product.name', width: '32%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  76. { title: '补货应发数量', dataIndex: 'qty', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  77. { title: '实发数量', scopedSlots: { customRender: 'confirmQty' }, width: '15%', align: 'center' },
  78. { title: '单位', dataIndex: 'product.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } }
  79. ],
  80. // 加载数据方法 必须为 Promise 对象
  81. loadData: parameter => {
  82. this.disabled = true
  83. this.spinning = true
  84. return shelfReplenishDetailList({ replenishBillSn: this.nowData && this.nowData.replenishBillSn }).then(res => {
  85. let data
  86. if (res.status == 200) {
  87. data = res.data
  88. for (var i = 0; i < data.length; i++) {
  89. data[i].no = i + 1
  90. data[i].confirmQty = data[i].qty
  91. }
  92. this.disabled = false
  93. }
  94. this.listData = data || []
  95. this.spinning = false
  96. return data
  97. })
  98. },
  99. listData: []
  100. }
  101. },
  102. computed: {
  103. modalTit () {
  104. const hjName = this.nowData && this.nowData.shelfInfo.shelfName ? this.nowData.shelfInfo.shelfName : ''
  105. return '补货单确认 —— ' + hjName
  106. }
  107. },
  108. methods: {
  109. // 确认补货
  110. handleSave () {
  111. const _this = this
  112. this.$confirm({
  113. title: '提示',
  114. content: '确认对该数字货架进行补货吗?',
  115. centered: true,
  116. onOk () {
  117. const arr = []
  118. const arrInd = []
  119. _this.listData.map((item, index) => {
  120. if (item.confirmQty || item.confirmQty == 0) {
  121. arr.push({
  122. productSn: item.productSn,
  123. confirmQty: item.confirmQty,
  124. replenishBillDetailSn: item.replenishBillDetailSn
  125. })
  126. } else {
  127. arrInd.push(index + 1)
  128. }
  129. })
  130. if (arrInd.length > 0) {
  131. _this.$message.warning('操作失败!实发数量不能为空')
  132. return
  133. }
  134. const params = {
  135. replenishBillSn: _this.nowData && _this.nowData.replenishBillSn,
  136. replenishBillNo: _this.nowData && _this.nowData.replenishBillNo,
  137. shelfSn: _this.nowData && _this.nowData.shelfSn,
  138. detailList: arr
  139. }
  140. _this.$emit('ok', 'confirm', params)
  141. }
  142. })
  143. }
  144. },
  145. watch: {
  146. // 父页面传过来的弹框状态
  147. openModal (newValue, oldValue) {
  148. this.isShow = newValue
  149. },
  150. // 重定义的弹框状态
  151. isShow (newValue, oldValue) {
  152. if (!newValue) {
  153. this.$emit('close')
  154. this.$refs.table.clearTable()
  155. } else {
  156. const _this = this
  157. this.$nextTick(() => { // 页面渲染完成后的回调
  158. _this.$refs.table.refresh(true)
  159. })
  160. }
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="less">
  166. .replenishmentManagement-confirm-modal {
  167. .btn-cont {
  168. text-align: center;
  169. margin: 35px 0 10px;
  170. }
  171. }
  172. </style>