addModal.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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="confirmQty" slot-scope="text, record">
  32. <a-input-number
  33. size="small"
  34. id="shelfMonitoring-add-confirmQty"
  35. v-model="record.confirmQty"
  36. :precision="0"
  37. :min="0"
  38. :max="record.qty"
  39. placeholder="请输入"
  40. :style="{width: '100%', color: record.confirmQty==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" :disabled="listData.length==0" 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 { shelfControlList } from '@/api/shelf'
  63. import { shelfRecallSave } from '@/api/shelfRecall'
  64. export default {
  65. name: 'ShelfMonitoringAddModal',
  66. components: { STable, VSelect },
  67. mixins: [commonMixin],
  68. props: {
  69. openModal: { // 弹框显示状态
  70. type: Boolean,
  71. default: false
  72. },
  73. nowData: {
  74. type: Object,
  75. default: () => {
  76. return {}
  77. }
  78. }
  79. },
  80. data () {
  81. return {
  82. spinning: false,
  83. isShow: this.openModal, // 是否打开弹框
  84. columns: [
  85. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  86. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  87. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  88. { title: '产品名称', dataIndex: 'productName', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  89. { title: '当前库存', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  90. { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  91. { title: '滞销天数', dataIndex: 'unsalableDays', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  92. { title: '调货数量', scopedSlots: { customRender: 'confirmQty' }, width: '10%', align: 'center' },
  93. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  95. ],
  96. listData: []
  97. }
  98. },
  99. methods: {
  100. // 确认调回
  101. handleSave () {
  102. const _this = this
  103. const arr = []
  104. const arrInd = []
  105. this.listData.map((item, index) => {
  106. if (item.confirmQty) {
  107. arr.push({
  108. shelfSn: this.nowData && this.nowData.shelfInfo && this.nowData.shelfInfo.shelfSn,
  109. shelfPlaceSn: item.shelfPlaceSn,
  110. shelfPlaceCode: item.shelfPlaceCode,
  111. productSn: item.productSn,
  112. productCode: item.productCode,
  113. productName: item.productName,
  114. qty: item.confirmQty
  115. })
  116. } else {
  117. arrInd.push(index + 1)
  118. }
  119. })
  120. if (arrInd.length > 0) {
  121. this.$message.warning('调回数量不能为空或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. getList () {
  144. const params = []
  145. this.nowData.list.map((item, index) => {
  146. params.push(item.shelfProductSn)
  147. })
  148. shelfControlList({ shelfProductSnList: params }).then(res => {
  149. if (res.status == 200 && res.data) {
  150. res.data.map((item, index) => {
  151. item.no = index + 1
  152. item.confirmQty = item.qty
  153. })
  154. this.listData = res.data
  155. }
  156. })
  157. }
  158. },
  159. watch: {
  160. // 父页面传过来的弹框状态
  161. openModal (newValue, oldValue) {
  162. this.isShow = newValue
  163. },
  164. // 重定义的弹框状态
  165. isShow (newValue, oldValue) {
  166. if (!newValue) {
  167. this.$emit('close')
  168. this.listData = []
  169. } else {
  170. if (this.nowData && this.nowData.list) {
  171. this.getList()
  172. } else {
  173. this.listData = []
  174. }
  175. }
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="less">
  181. .shelfMonitoring-add-modal {
  182. .btn-cont {
  183. text-align: center;
  184. margin: 35px 0 10px;
  185. }
  186. }
  187. </style>