recoveryPriceSet.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <a-card :bordered="false">
  3. <a-tabs type="card" @change="callback">
  4. <a-tab-pane key="1" tab="上门回收价格设置">
  5. </a-tab-pane>
  6. <a-tab-pane key="2" tab="工厂回收价格设置">
  7. </a-tab-pane>
  8. </a-tabs>
  9. <a-table
  10. class="table"
  11. ref="table"
  12. size="default"
  13. :rowKey="record => record.id"
  14. :columns="columns"
  15. :dataSource="loadData"
  16. :pagination="false"
  17. :scroll="{ y: 650 }"
  18. :loading="loadingPage"
  19. bordered>
  20. <!-- 序号 -->
  21. <template slot="no">
  22. <span>{{ }}</span>
  23. </template>
  24. <!-- 门店结算价 -->
  25. <template slot="advicePrice" slot-scope="text, record" >
  26. <a-input-number
  27. id="storeSettlementPrice-price"
  28. :value="record.advicePrice"
  29. :precision="2"
  30. :min="0"
  31. :max="999"
  32. style="width: 70%;"
  33. placeholder="请输入回收价格"
  34. @change="e => handleChange(e, record.id)" />
  35. <!-- <template v-else> {{ record.accountPrice }} </template> -->
  36. </template>
  37. <!-- 操作 -->
  38. <template slot="action" slot-scope="text, record">
  39. <div class="editable-row-operations">
  40. <span >
  41. <!-- <a @click="() => save(record.id, record.accountPrice)" style="margin-right: 8px;">保存</a> -->
  42. <a-popconfirm title="确定要保存吗?" @confirm="() => save(record.id,record.advicePrice)">
  43. <a>保存</a>
  44. </a-popconfirm>
  45. </span>
  46. <!-- <span v-else>
  47. <a v-if="$hasPermissions('B_store_jsj_edit')" :disabled="editingId !== ''" @click="() => edit(record.id)">编辑</a>
  48. <span v-else>--</span>
  49. </span> -->
  50. </div>
  51. </template>
  52. </a-table>
  53. </a-card>
  54. </template>
  55. <script>
  56. import { gePriceList, savPrice } from '@/api/recoveryManage.js'
  57. export default {
  58. data () {
  59. return {
  60. loadingPage: false, // 列表加载状态
  61. type: '',
  62. // 表头
  63. columns: [
  64. { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
  65. { title: '回收类型', dataIndex: 'fatherName', width: 100, align: 'center' },
  66. { title: '回收名称', dataIndex: 'name', width: 100, align: 'center' },
  67. { title: '回收价格(元/kg)', dataIndex: 'advicePrice', width: 100, align: 'center', scopedSlots: { customRender: 'advicePrice' } },
  68. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center' }
  69. ],
  70. // 表格列表数据
  71. loadData: []
  72. }
  73. },
  74. mounted () {
  75. this.getListData()
  76. },
  77. methods: {
  78. callback (key) {
  79. this.type = key
  80. gePriceList({ adviceType: key }).then(res => {
  81. if (res.status == 200) {
  82. this.loadData = res.data
  83. this.loadData.forEach((item, index) => {
  84. item.no = index + 1
  85. })
  86. }
  87. })
  88. // this.save()
  89. console.log(key, this.type)
  90. },
  91. getListData () {
  92. gePriceList({ adviceType: '1' }).then(res => {
  93. if (res.status == 200) {
  94. this.loadData = res.data
  95. this.loadData.forEach((item, index) => {
  96. item.no = index + 1
  97. })
  98. }
  99. })
  100. },
  101. // 改变回收价格
  102. handleChange (value, id) {
  103. const newData = [...this.loadData]
  104. const target = newData.filter(item => id === item.id)[0]
  105. console.log(target, '-----------')
  106. if (target) {
  107. target['advicePrice'] = value
  108. this.loadData = newData
  109. }
  110. },
  111. // 保存价格
  112. save (id, advicePrice) {
  113. savPrice({ adviceType: this.type ? this.type : 1, id: id, advicePrice: advicePrice }).then(res => {
  114. if (res.status == 200) {
  115. this.$message.success(res.message)
  116. gePriceList({ adviceType: this.type ? this.type : 1 }).then(res => {
  117. if (res.status == 200) {
  118. this.loadData = res.data
  119. this.loadData.forEach((item, index) => {
  120. item.no = index + 1
  121. })
  122. }
  123. })
  124. } else {
  125. this.$message.warning(res.message)
  126. }
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <style>
  133. </style>