goodsSettings.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="bg" id="index">
  3. <div class="row1">
  4. <div class="right">
  5. <el-button type="primary" size="small" @click="add" class="add">添加</el-button>
  6. </div>
  7. </div>
  8. <el-table ref="singleTable" :data="goodsList" highlight-current-row style="width: 100%" class="table">
  9. <el-table-column type="index" width="50" label="序号">
  10. </el-table-column>
  11. <el-table-column property="goodsName" label="货名" width="120">
  12. </el-table-column>
  13. <el-table-column property="storage" label="剩余库存(吨)" width="120">
  14. </el-table-column>
  15. <el-table-column property="setDefault" label="默认货名">
  16. <template scope="scope">
  17. <el-checkbox v-model="scope.row.scope">设为默认</el-checkbox>
  18. </template>
  19. </el-table-column>
  20. <el-table-column prop="address" label="操作" show-overflow-tooltip>
  21. <template scope="scope">
  22. <span style="color: #409EFF;margin-right:5px" @click="edit(scope.row)">编辑</span>
  23. <span style="color: red;" @click="del(scope.row)">删除</span>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. <el-dialog width="320px" :title="goodsNameTitle" :visible.sync="show" :append-to-body="true" :close="inventoryClose">
  28. <el-form class="goodsName" label-position="right" label-width="80px">
  29. <el-form-item class="customer-item" label="货名">
  30. <el-input placeholder="请输入货名" maxlength="100" size="small" v-model="dataObj.goodsName" />
  31. </el-form-item>
  32. </el-form>
  33. <div slot="footer" class="dialog-footer">
  34. <el-button @click="goodsNameConfirm" type='primary'>确 定</el-button>
  35. </div>
  36. </el-dialog>
  37. </div>
  38. </template>
  39. <script>
  40. import {
  41. speedGoodsList,
  42. speedGoodsAdd,
  43. speedGoodsEdit
  44. } from '@/model/speedGoods'
  45. export default {
  46. components: {
  47. },
  48. data() {
  49. return {
  50. goodsNameTitle:'新增',
  51. dataObj: {
  52. compId: localStorage.getItem('ws-pf_compId'),
  53. goodsName:''
  54. },
  55. deptCircularPage: {},
  56. deptBudgetTotal: 0,
  57. currentPage: 1,
  58. pageSize: 10,
  59. show: false,
  60. checked: true,
  61. goodsList: [],
  62. };
  63. },
  64. filters: {
  65. numsFilter(msg) {
  66. return msg || 0;
  67. },
  68. },
  69. created() {
  70. this.getList()
  71. },
  72. mounted() {
  73. },
  74. beforeDestroy() {
  75. },
  76. methods: {
  77. getList() {
  78. speedGoodsList({
  79. compId: localStorage.getItem('ws-pf_compId')
  80. })
  81. .toPromise()
  82. .then((response) => {
  83. console.log(response)
  84. this.deptBudgetTotal = response.total
  85. this.goodsList = response
  86. })
  87. },
  88. inventoryClose() {
  89. this.show = false
  90. },
  91. handleSizeChange(val) {
  92. console.log(`每页 ${val} 条`)
  93. this.pageSize = val
  94. // this.getList()
  95. },
  96. handleCurrentChange(val) {
  97. this.currentPage = val
  98. console.log(`当前页: ${val}`)
  99. // this.getList()
  100. },
  101. add() {
  102. this.show = true
  103. },
  104. edit(val) {
  105. console.log(val)
  106. this.goodsNameTitle = "编辑"
  107. this.dataObj = val
  108. this.show = true
  109. },
  110. del(val) {
  111. this.$confirm('确定删除货名?', '提示', {
  112. confirmButtonText: '确定',
  113. cancelButtonText: '取消',
  114. type: 'warning'
  115. }).then(() => {
  116. }).catch(() => {
  117. return false
  118. });
  119. },
  120. goodsNameConfirm() {
  121. if(this.goodsNameTitle=='新增'){
  122. speedGoodsAdd(this.dataObj)
  123. .toPromise()
  124. .then((response) => {
  125. if(response.code=="200"){
  126. this.show = false
  127. this.getList()
  128. }
  129. console.log(response)
  130. })
  131. }else{
  132. speedGoodsEdit(this.dataObj)
  133. .toPromise()
  134. .then((response) => {debugger
  135. if(response=="ok"){
  136. this.show = false
  137. this.$message.success('操作成功!')
  138. this.getList()
  139. }
  140. console.log(response)
  141. })
  142. }
  143. }
  144. },
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .bg {
  149. width: 100%;
  150. height: 100%;
  151. padding: 16px 16px 10px 16px;
  152. box-sizing: border-box;
  153. // background-image: url("../../assets/images/pageBg.png");
  154. background-size: cover;
  155. background-position: center center;
  156. }
  157. .table {
  158. margin-top: 20px;
  159. }
  160. </style>