confirmModal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. @cancle="isShow = false"
  10. :width="800">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-descriptions>
  13. <a-descriptions-item label="补货单号">{{ this.nowData && this.nowData.replenishBillNo || '--' }}</a-descriptions-item>
  14. <!-- <a-descriptions-item label="单据来源">{{this.nowData && this.nowData.billType || '--'}}</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: 'productCode', width: '22%', align: 'center', customRender: function (text) { return text || '--' } },
  75. { title: '产品名称', dataIndex: 'productName', 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: 'productUnit', 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.shelfName ? this.nowData.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. })
  125. } else {
  126. arrInd.push(index + 1)
  127. }
  128. })
  129. if (arrInd.length > 0) {
  130. let str = ''
  131. arrInd.map(item => {
  132. str += item + '、'
  133. })
  134. str = str.substr(0, str.length - 1)
  135. _this.$message.warning('请完善第' + str + '行数据后再提交')
  136. return
  137. }
  138. const params = {
  139. replenishBillSn: _this.nowData && _this.nowData.replenishBillSn,
  140. detailList: arr
  141. }
  142. _this.$emit('ok', 'confirm', params)
  143. }
  144. })
  145. }
  146. },
  147. watch: {
  148. // 父页面传过来的弹框状态
  149. openModal (newValue, oldValue) {
  150. this.isShow = newValue
  151. },
  152. // 重定义的弹框状态
  153. isShow (newValue, oldValue) {
  154. if (!newValue) {
  155. this.$emit('close')
  156. this.$refs.table.clearTable()
  157. } else {
  158. const _this = this
  159. this.$nextTick(() => { // 页面渲染完成后的回调
  160. _this.$refs.table.refresh(true)
  161. })
  162. }
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="less">
  168. .replenishmentManagement-confirm-modal {
  169. .btn-cont {
  170. text-align: center;
  171. margin: 35px 0 10px;
  172. }
  173. }
  174. </style>