goodsSettings.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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="200">
  12. </el-table-column>
  13. <el-table-column property="storage" label="剩余库存(吨)" width="200">
  14. </el-table-column>
  15. <el-table-column property="setDefault" label="默认货名" width="200">
  16. <template scope="scope">
  17. <!-- <el-checkbox v-hasPermission="`speedEdition.goodsNameJsb.default` " v-model="scope.row.checked" @change="change($event,scope.row)">设为默认</el-checkbox> -->
  18. <el-checkbox v-model="scope.row.checked" @change="change($event,scope.row)">设为默认</el-checkbox>
  19. </template>
  20. </el-table-column>
  21. <el-table-column prop="address" label="操作" show-overflow-tooltip>
  22. <template scope="scope">
  23. <!-- <span style="color: #409EFF;margin-right:5px" @click="edit(scope.row)">编辑</span> -->
  24. <!-- <span v-hasPermission="`speedEdition.goodsNameJsb.delete` " style="color: red;" @click="del(scope.row)">删除</span> -->
  25. <span style="color: red;" @click="del(scope.row)">删除</span>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. <el-dialog width="320px" :title="goodsNameTitle" :visible.sync="show" :append-to-body="true" :close="inventoryClose">
  30. <el-form class="goodsName" label-position="right" label-width="80px">
  31. <el-form-item class="customer-item" label="货名">
  32. <el-input placeholder="请输入货名" maxlength="100" size="small" v-model="dataObj.goodsName" />
  33. </el-form-item>
  34. </el-form>
  35. <div slot="footer" class="dialog-footer">
  36. <el-button @click="goodsNameConfirm" type='primary'>确 定</el-button>
  37. </div>
  38. </el-dialog>
  39. </div>
  40. </template>
  41. <script>
  42. import {
  43. speedGoodsList,
  44. speedGoodsAdd,
  45. speedGoodsEdit,
  46. speedGoodsDel
  47. } from '@/model/speedGoods'
  48. import { floralwhite } from 'color-name';
  49. export default {
  50. components: {
  51. },
  52. data() {
  53. return {
  54. goodsNameTitle: '新增',
  55. dataObj: {
  56. compId: localStorage.getItem('ws-pf_compId'),
  57. goodsName: ''
  58. },
  59. deptCircularPage: {},
  60. deptBudgetTotal: 0,
  61. currentPage: 1,
  62. pageSize: 10,
  63. show: false,
  64. checked: true,
  65. goodsList: [],
  66. };
  67. },
  68. filters: {
  69. numsFilter(msg) {
  70. return msg || 0;
  71. },
  72. },
  73. created() {
  74. this.getList()
  75. },
  76. mounted() {
  77. },
  78. beforeDestroy() {
  79. },
  80. methods: {
  81. change(val1,val2){
  82. console.log(val1,val2)
  83. if(val1){
  84. val2.setDefault=1
  85. }else{
  86. val2.setDefault=0
  87. }
  88. val2.flag=1
  89. speedGoodsEdit(val2)
  90. .toPromise()
  91. .then((response) => {
  92. debugger
  93. if (response == "ok") {
  94. this.show = false
  95. this.$message.success('操作成功!')
  96. this.getList()
  97. }
  98. console.log(response)
  99. })
  100. },
  101. getList() {
  102. speedGoodsList({
  103. compId: localStorage.getItem('ws-pf_compId')
  104. })
  105. .toPromise()
  106. .then((response) => {
  107. console.log(response)
  108. this.goodsList = response
  109. for(let i = 0;i<this.goodsList.length;i++){
  110. if(this.goodsList[i].setDefault==0){
  111. this.goodsList[i].checked = false
  112. }else{
  113. this.goodsList[i].checked = true
  114. }
  115. }
  116. })
  117. },
  118. inventoryClose() {
  119. this.show = false
  120. },
  121. handleSizeChange(val) {
  122. console.log(`每页 ${val} 条`)
  123. this.pageSize = val
  124. // this.getList()
  125. },
  126. handleCurrentChange(val) {
  127. this.currentPage = val
  128. console.log(`当前页: ${val}`)
  129. // this.getList()
  130. },
  131. add() {
  132. this.show = true
  133. },
  134. edit(val) {
  135. console.log(val)
  136. this.goodsNameTitle = "编辑"
  137. this.dataObj = val
  138. this.show = true
  139. },
  140. del(val) {
  141. if(val.storage&&val.storage>0){
  142. this.$message.error('当前'+val.goodsName+'有剩余库存!')
  143. return
  144. }
  145. this.$confirm('确定删除货名?', '提示', {
  146. confirmButtonText: '确定',
  147. cancelButtonText: '取消',
  148. type: 'warning'
  149. }).then(() => {
  150. speedGoodsDel({ id: val.id })
  151. .toPromise()
  152. .then((response) => {
  153. debugger
  154. if (response == "200") {
  155. this.show = false
  156. this.$message.success('删除成功!')
  157. this.getList()
  158. }
  159. console.log(response)
  160. })
  161. }).catch(() => {
  162. return false
  163. });
  164. },
  165. goodsNameConfirm() {
  166. if (this.goodsNameTitle == '新增') {
  167. speedGoodsAdd(this.dataObj)
  168. .toPromise()
  169. .then((response) => {
  170. debugger
  171. if (response == "ok") {
  172. this.$message.success('操作成功!')
  173. this.show = false
  174. this.getList()
  175. }
  176. console.log(response)
  177. })
  178. } else {
  179. speedGoodsEdit(this.dataObj)
  180. .toPromise()
  181. .then((response) => {
  182. debugger
  183. if (response == "ok") {
  184. this.show = false
  185. this.$message.success('操作成功!')
  186. this.getList()
  187. }
  188. console.log(response)
  189. })
  190. }
  191. }
  192. },
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. .bg {
  197. width: 100%;
  198. height: 100%;
  199. padding: 16px 16px 10px 16px;
  200. box-sizing: border-box;
  201. // background-image: url("../../assets/images/pageBg.png");
  202. background-size: cover;
  203. background-position: center center;
  204. }
  205. .table {
  206. margin-top: 20px;
  207. }
  208. </style>