addModal.vue 7.0 KB

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