addModal.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <a-modal
  3. centered
  4. class="satelliteWarehouseInventory-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="补货清单"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="960">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <!-- 补货清单 -->
  13. <div>
  14. <h4 style="font-weight: bold;font-size: 16px;">{{ (nowData&&nowData.customerName) || '--' }}</h4>
  15. <s-table
  16. class="sTable"
  17. ref="table"
  18. size="small"
  19. :rowKey="(record) => record.id"
  20. :columns="columns"
  21. :data="loadData"
  22. :scroll="{ x: 1260 }"
  23. :defaultLoadData="false"
  24. bordered>
  25. <!-- 补货数量 -->
  26. <template slot="productQty" slot-scope="text, record">
  27. <a-button
  28. type="primary"
  29. @click="handleNumSubtract(record)"
  30. shape="circle"
  31. icon="minus"
  32. size="small"
  33. id="satelliteWarehouseInventoryList-num-add-btn"></a-button>
  34. <a-input-number
  35. size="small"
  36. v-model="record.productQty"
  37. :min="0"
  38. :max="999999"
  39. :precision="0"
  40. :step="1"
  41. @change="e => onChange(e, record)"
  42. class="stepper" />
  43. <a-button
  44. type="primary"
  45. @click="handleNumAdd(record)"
  46. shape="circle"
  47. icon="plus"
  48. size="small"
  49. id="satelliteWarehouseInventoryList-num-subtract-btn"></a-button>
  50. </template>
  51. <!-- 操作 -->
  52. <template slot="action" slot-scope="text, record">
  53. <a-button type="link" @click="handleConfirm(record)" id="satelliteWarehouseInventoryList-remove-btn">移除</a-button>
  54. </template>
  55. </s-table>
  56. <div class="btn-cont">
  57. <a-button type="primary" id="satellite-warehouse-inventory-add-modal-add" @click="handleAdd">创建销售单</a-button>
  58. <a-button id="satellite-warehouse-inventory-add-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
  59. </div>
  60. </div>
  61. </a-spin>
  62. </a-modal>
  63. </template>
  64. <script>
  65. import { commonMixin } from '@/utils/mixin'
  66. import { STable } from '@/components'
  67. import { satelliteWHSupplyList, satelliteWHSupplyUpdate, satelliteWHSupplyDel, satelliteWHSupplyValidateStock, satelliteWHSupplyAddSales } from '@/api/satelliteWH'
  68. export default {
  69. name: 'SatelliteWarehouseInventoryAddModal',
  70. components: { STable },
  71. mixins: [commonMixin],
  72. props: {
  73. openModal: { // 弹框显示状态
  74. type: Boolean,
  75. default: false
  76. },
  77. nowData: {
  78. type: Object,
  79. default: null
  80. }
  81. },
  82. data () {
  83. return {
  84. spinning: false,
  85. isShow: this.openModal, // 是否打开弹框
  86. columns: [
  87. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  88. { title: '客户名称', dataIndex: 'customer.customerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  89. { title: '仓库名称', dataIndex: 'satelliteWarehouseName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  90. { title: '配件名称', dataIndex: 'dealerProduct.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  91. { title: '产品编码', dataIndex: 'dealerProduct.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  92. { title: '产品原厂编码', dataIndex: 'dealerProduct.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '补货数量', scopedSlots: { customRender: 'productQty' }, width: 200, align: 'center' },
  94. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  95. ],
  96. // 加载数据方法 必须为 Promise 对象
  97. loadData: parameter => {
  98. this.spinning = true
  99. return satelliteWHSupplyList(Object.assign(parameter, { customerSn: this.nowData.customerSn })).then(res => {
  100. let data
  101. if (res.status == 200) {
  102. data = res.data
  103. const no = (data.pageNo - 1) * data.pageSize
  104. for (var i = 0; i < data.list.length; i++) {
  105. data.list[i].no = no + i + 1
  106. }
  107. }
  108. this.spinning = false
  109. return data
  110. })
  111. },
  112. val: 1
  113. }
  114. },
  115. methods: {
  116. // 创建销售单
  117. handleAdd () {
  118. const _this = this
  119. // 校验库存
  120. satelliteWHSupplyValidateStock({ sn: this.nowData.customerSn }).then(res => {
  121. if (res.status == 200) {
  122. if (res.data.length == 0) {
  123. // 创建销售单
  124. _this.createSalesFun()
  125. } else {
  126. const str = res.data.join('、')
  127. _this.$confirm({
  128. title: '提示',
  129. content: '产品编码为:【' + str + '】的产品库存不足!是否提交?',
  130. centered: true,
  131. onOk () {
  132. _this.createSalesFun()
  133. }
  134. })
  135. }
  136. }
  137. })
  138. },
  139. // 创建销售单
  140. createSalesFun () {
  141. this.spinning = true
  142. satelliteWHSupplyAddSales({ sn: this.nowData.customerSn }).then(res => {
  143. if (res.status == 200) {
  144. this.$router.push({ name: 'salesEdit', params: { id: res.data.id, sn: res.data.salesBillSn, priceType: res.data.priceType } })
  145. this.spinning = false
  146. } else {
  147. this.spinning = false
  148. }
  149. })
  150. },
  151. // 补货数量 加
  152. handleNumAdd (row) {
  153. row.productQty < 999999 ? this.handleQty(++row.productQty, row) : row.productQty
  154. },
  155. // 补货数量 减
  156. handleNumSubtract (row) {
  157. row.productQty > 1 ? this.handleQty(--row.productQty, row) : this.handleRemove(row)
  158. },
  159. // 删除配件信息
  160. handleRemove (row) {
  161. this.spinning = true
  162. satelliteWHSupplyDel({ sn: row.satelliteWarehouseSupplySn }).then(res => {
  163. if (res.status == 200) {
  164. this.$refs.table.refresh(true)
  165. this.spinning = false
  166. } else {
  167. this.spinning = false
  168. }
  169. })
  170. },
  171. // 弹框确认
  172. handleConfirm (row) {
  173. const _this = this
  174. this.$confirm({
  175. title: '提示',
  176. content: '移除后不可恢复,确定要进行移除吗?',
  177. centered: true,
  178. onOk () {
  179. _this.handleRemove(row)
  180. }
  181. })
  182. },
  183. // 补货数量 change
  184. onChange (val, row) {
  185. val > 0 ? this.handleQty(val, row) : this.handleRemove(row)
  186. },
  187. handleQty (val, row) {
  188. const params = {
  189. satelliteWarehouseSupplySn: row.satelliteWarehouseSupplySn,
  190. productSn: row.productSn,
  191. productQty: val
  192. }
  193. this.spinning = true
  194. satelliteWHSupplyUpdate(params).then(res => {
  195. if (res.status == 200) {
  196. this.$refs.table.refresh(true)
  197. this.spinning = false
  198. } else {
  199. this.spinning = false
  200. }
  201. })
  202. }
  203. },
  204. watch: {
  205. // 父页面传过来的弹框状态
  206. openModal (newValue, oldValue) {
  207. this.isShow = newValue
  208. },
  209. // 重定义的弹框状态
  210. isShow (newValue, oldValue) {
  211. if (!newValue) {
  212. this.$emit('close')
  213. } else {
  214. const _this = this
  215. setTimeout(() => {
  216. _this.$refs.table.refresh(true)
  217. }, 100)
  218. }
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="less">
  224. .satelliteWarehouseInventory-modal{
  225. .sTable{
  226. margin-top: 20px;
  227. }
  228. .ant-modal-body {
  229. padding: 40px 40px 24px;
  230. }
  231. .item-cont {
  232. margin-bottom: 10px;
  233. display: flex;
  234. .item-label {
  235. width: 115px;
  236. font-size: 14px;
  237. color: rgba(0, 0, 0);
  238. flex-shrink: 0;
  239. }
  240. .item-main {
  241. flex-grow: 1;
  242. word-break: break-all;
  243. }
  244. }
  245. .btn-cont {
  246. text-align: center;
  247. margin: 35px 0 10px;
  248. }
  249. .stepper{
  250. margin: 0 10px;
  251. input{
  252. text-align: center;
  253. }
  254. }
  255. }
  256. </style>