setPriceModal.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <a-modal
  3. centered
  4. class="setPrice-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="title"
  8. v-model="isShow"
  9. @cancel="cancel"
  10. :width="800">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div class="setPrice-title">
  13. <div>以下产品没有成本价,无法进行财务盘点审核!</div>
  14. <div>请先设置成本价,然后再审核。</div>
  15. </div>
  16. <div class="setPrice-table">
  17. <a-table
  18. class="sTable fixPagination"
  19. ref="table"
  20. size="small"
  21. :rowKey="(record,index) => record.id +'-'+ index"
  22. :columns="columns"
  23. :data-source="list"
  24. :scroll="{ y:400 }"
  25. :pagination="false"
  26. bordered>
  27. <template slot="action" slot-scope="text,record">
  28. <a-input-number
  29. style="width: 100%;"
  30. size="small"
  31. v-model="record.lastStockCost"
  32. :precision="2"
  33. :min="0"
  34. :max="999999"
  35. placeholder="请输入成本价"
  36. />
  37. </template>
  38. </a-table>
  39. </div>
  40. <div class="btn-cont">
  41. <a-button type="primary" @click="handleSubmit">保存</a-button>
  42. <a-button @click="cancel" style="margin-left: 15px;">取消</a-button>
  43. </div>
  44. </a-spin>
  45. </a-modal>
  46. </template>
  47. <script>
  48. import { commonMixin } from '@/utils/mixin'
  49. import { stockWarnSaveBatch } from '@/api/checkWarehouse'
  50. export default {
  51. name: 'SettleModal',
  52. components: {},
  53. mixins: [commonMixin],
  54. props: {
  55. openModal: { // 弹框显示状态
  56. type: Boolean,
  57. default: false
  58. },
  59. title: {
  60. type: String,
  61. default: '设置成本价'
  62. }
  63. },
  64. data () {
  65. return {
  66. spinning: false,
  67. confirmLoading: false,
  68. isShow: this.openModal, // 是否打开弹框
  69. row: null,
  70. list: [],
  71. // 表头
  72. columns: [
  73. { title: '产品编码', dataIndex: 'productCode', width: '30%', align: 'center', customRender: function (text) { return ((text || text != ' ') ? text : '--') } },
  74. { title: '产品名称', dataIndex: 'productName', width: '50%', align: 'left', customRender: function (text) { return (text || '--') } },
  75. { title: '成本价', scopedSlots: { customRender: 'action' }, width: '20%', align: 'center' }
  76. ]
  77. }
  78. },
  79. methods: {
  80. // 保存
  81. handleSubmit (e) {
  82. const _this = this
  83. const hasEmpty = this.list.filter(item => !item.lastStockCost && item.lastStockCost != 0)
  84. if (hasEmpty.length) {
  85. this.$message.info('成本价不能为空!')
  86. return
  87. }
  88. const params = []
  89. this.list.map(item => {
  90. params.push({
  91. 'id': item.id,
  92. 'lastStockCost': item.lastStockCost
  93. })
  94. })
  95. stockWarnSaveBatch(params).then(res => {
  96. _this.isShow = false
  97. _this.$emit('ok', _this.row, true)
  98. })
  99. },
  100. cancel () {
  101. this.isShow = false
  102. },
  103. // 编辑信息
  104. setData (data, row) {
  105. this.list = data
  106. this.row = row
  107. }
  108. },
  109. watch: {
  110. // 父页面传过来的弹框状态
  111. openModal (newValue, oldValue) {
  112. this.isShow = newValue
  113. },
  114. // 重定义的弹框状态
  115. isShow (newValue, oldValue) {
  116. if (!newValue) {
  117. this.$emit('close')
  118. }
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="less">
  124. .setPrice-basicInfo-modal{
  125. .setPrice-title{
  126. text-align: center;
  127. padding-bottom: 20px;
  128. line-height: 24px;
  129. }
  130. .btn-cont{
  131. padding: 30px 0 0;
  132. text-align: center;
  133. }
  134. }
  135. </style>