addModal.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <a-modal
  3. centered
  4. class="shelfMonitoring-add-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="新增调回单"
  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="货架名称">{{ nowData && nowData.shelfInfo && nowData.shelfInfo.shelfName || '--' }}</a-descriptions-item>
  14. </a-descriptions>
  15. <!-- 提示 -->
  16. <a-alert type="info" style="margin-bottom:10px">
  17. <div slot="message">调回数量不能大于当前库存。如果调回数量为0,请移除此产品。</div>
  18. </a-alert>
  19. <!-- 列表 -->
  20. <a-table
  21. class="sTable"
  22. ref="table"
  23. size="small"
  24. :rowKey="(record) => record.id"
  25. :columns="columns"
  26. :dataSource="listData"
  27. :scroll="{ y: 400 }"
  28. :pagination="false"
  29. bordered>
  30. <!-- 调回数量 -->
  31. <template slot="outQty" slot-scope="text, record">
  32. <a-input-number
  33. size="small"
  34. id="shelfMonitoring-add-outQty"
  35. v-model="record.outQty"
  36. :precision="0"
  37. :min="0"
  38. :max="record.qty"
  39. placeholder="请输入"
  40. :style="{width: '100%', color: record.outQty==0 ? 'red': ''}" />
  41. </template>
  42. <!-- 操作 -->
  43. <template slot="action" slot-scope="text, record, index">
  44. <a-button
  45. size="small"
  46. type="link"
  47. class="button-primary"
  48. @click="handleDel(record, index)"
  49. id="shelfMonitoring-add-btn">移除</a-button>
  50. </template>
  51. </a-table>
  52. <div class="btn-cont">
  53. <a-button type="primary" id="shelfMonitoring-add-modal-save" @click="handleSave">确认调回</a-button>
  54. <a-button id="shelfMonitoring-add-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  55. </div>
  56. </a-spin>
  57. </a-modal>
  58. </template>
  59. <script>
  60. import { commonMixin } from '@/utils/mixin'
  61. import { STable, VSelect } from '@/components'
  62. import { shelfRecallSave } from '@/api/shelfRecall'
  63. export default {
  64. name: 'ShelfMonitoringAddModal',
  65. components: { STable, VSelect },
  66. mixins: [commonMixin],
  67. props: {
  68. openModal: { // 弹框显示状态
  69. type: Boolean,
  70. default: false
  71. },
  72. nowData: {
  73. type: Object,
  74. default: () => {
  75. return {}
  76. }
  77. }
  78. },
  79. data () {
  80. return {
  81. spinning: false,
  82. isShow: this.openModal, // 是否打开弹框
  83. columns: [
  84. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  85. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  86. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  87. { title: '产品名称', dataIndex: 'productName', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  88. { title: '当前库存', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  89. { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  90. { title: '滞销天数', dataIndex: 'unsalableDays', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '调货数量', scopedSlots: { customRender: 'outQty' }, width: '10%', align: 'center' },
  92. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  94. ],
  95. listData: []
  96. }
  97. },
  98. methods: {
  99. // 确认调回
  100. handleSave () {
  101. const _this = this
  102. const arr = []
  103. const arrInd = []
  104. this.listData.map((item, index) => {
  105. if (item.outQty) {
  106. arr.push({
  107. shelfPlaceSn: item.shelfPlaceSn,
  108. productSn: item.productSn,
  109. qty: item.outQty
  110. })
  111. } else {
  112. arrInd.push(index)
  113. }
  114. })
  115. if (arrInd.length > 0) {
  116. let str = ''
  117. arrInd.map(item => {
  118. str += item + '、'
  119. })
  120. str = str.substr(0, str.length - 1)
  121. this.$message.warning('第' + str + '条数据调回数量为空或0,请移除后提交')
  122. return
  123. }
  124. const params = {
  125. shelfSn: this.nowData && this.nowData.shelfInfo && this.nowData.shelfInfo.shelfSn,
  126. detailList: arr
  127. }
  128. shelfRecallSave(params).then(res => {
  129. if (res.status == 200) {
  130. _this.$emit('ok')
  131. _this.isShow = false
  132. _this.$message.success('保存并确认成功,返回并刷新列表')
  133. }
  134. })
  135. },
  136. // 移除
  137. handleDel (row, ind) {
  138. this.listData.splice(ind, 1)
  139. this.listData.map((item, index) => {
  140. item.no = index + 1
  141. })
  142. }
  143. },
  144. watch: {
  145. // 父页面传过来的弹框状态
  146. openModal (newValue, oldValue) {
  147. this.isShow = newValue
  148. },
  149. // 重定义的弹框状态
  150. isShow (newValue, oldValue) {
  151. if (!newValue) {
  152. this.$emit('close')
  153. this.listData = []
  154. } else {
  155. if (this.nowData && this.nowData.list) {
  156. this.nowData.list.map((item, index) => {
  157. item.no = index + 1
  158. item.outQty = item.qty
  159. })
  160. }
  161. this.listData = JSON.parse(JSON.stringify(this.nowData && this.nowData.list || []))
  162. }
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="less">
  168. .shelfMonitoring-add-modal {
  169. .btn-cont {
  170. text-align: center;
  171. margin: 35px 0 10px;
  172. }
  173. }
  174. </style>