setPriceModal.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. :id="'setPrice-const-'+record.id"
  30. style="width: 100%;"
  31. size="small"
  32. v-model="record.lastStockCost"
  33. :precision="2"
  34. :min="0"
  35. :max="999999"
  36. placeholder="请输入成本价"
  37. />
  38. </template>
  39. </a-table>
  40. </div>
  41. <div class="btn-cont">
  42. <a-button id="setPrice-save" type="primary" @click="handleSubmit">保存</a-button>
  43. <a-button id="setPrice-cancel" @click="cancel" style="margin-left: 15px;">取消</a-button>
  44. </div>
  45. </a-spin>
  46. </a-modal>
  47. </template>
  48. <script>
  49. import { commonMixin } from '@/utils/mixin'
  50. import { stockWarnSaveBatch } from '@/api/checkWarehouse'
  51. export default {
  52. name: 'SettleModal',
  53. components: {},
  54. mixins: [commonMixin],
  55. props: {
  56. openModal: { // 弹框显示状态
  57. type: Boolean,
  58. default: false
  59. },
  60. title: { // 标题
  61. type: String,
  62. default: '设置成本价'
  63. }
  64. },
  65. data () {
  66. return {
  67. spinning: false,
  68. confirmLoading: false, // 确认按钮loading
  69. isShow: this.openModal, // 是否打开弹框
  70. row: null, // 当前操作数据
  71. list: [], // 列表数据
  72. // 表头
  73. columns: [
  74. { title: '产品编码', dataIndex: 'productCode', width: '30%', align: 'center', customRender: function (text) { return ((text || text != ' ') ? text : '--') } },
  75. { title: '产品名称', dataIndex: 'productName', width: '50%', align: 'left', customRender: function (text) { return (text || '--') } },
  76. { title: '成本价', scopedSlots: { customRender: 'action' }, width: '20%', align: 'center' }
  77. ]
  78. }
  79. },
  80. methods: {
  81. // 保存
  82. handleSubmit (e) {
  83. const _this = this
  84. const hasEmpty = this.list.filter(item => !item.lastStockCost && item.lastStockCost != 0)
  85. if (hasEmpty.length) {
  86. this.$message.info('成本价不能为空!')
  87. return
  88. }
  89. const params = []
  90. this.list.map(item => {
  91. params.push({
  92. 'id': item.id,
  93. 'lastStockCost': item.lastStockCost
  94. })
  95. })
  96. stockWarnSaveBatch(params).then(res => {
  97. _this.isShow = false
  98. _this.$emit('ok', _this.row, true)
  99. })
  100. },
  101. // 取消
  102. cancel () {
  103. this.isShow = false
  104. },
  105. // 编辑信息
  106. setData (data, row) {
  107. this.list = data
  108. this.row = row
  109. }
  110. },
  111. watch: {
  112. // 父页面传过来的弹框状态
  113. openModal (newValue, oldValue) {
  114. this.isShow = newValue
  115. },
  116. // 重定义的弹框状态
  117. isShow (newValue, oldValue) {
  118. if (!newValue) {
  119. this.$emit('close')
  120. }
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="less">
  126. .setPrice-basicInfo-modal{
  127. .setPrice-title{
  128. text-align: center;
  129. padding-bottom: 20px;
  130. line-height: 24px;
  131. }
  132. .btn-cont{
  133. padding: 30px 0 0;
  134. text-align: center;
  135. }
  136. }
  137. </style>