oilPrice.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //资源管理油价管理
  2. <template>
  3. <!-- -->
  4. <div class="steel_inbound">
  5. <div class="sache">
  6. <el-input
  7. placeholder="请输入内容"
  8. v-model="textInput"
  9. clearable>
  10. </el-input>
  11. <el-button type="primary" class="btn1" @click="onclick" :loading="selectLoading">
  12. <i class="el-icon-search"></i>查询
  13. </el-button>
  14. <el-button type="primary" class="btn" @click="toInsert">
  15. <i class="el-icon-plus"></i>新增
  16. </el-button>
  17. </div>
  18. <div class="table">
  19. <dilTable
  20. v-bind.sync="options"
  21. :isKuang="isKuang"
  22. @func="func"
  23. :loading="tableLoading"
  24. >
  25. <el-table-column fixed="right" label="操作" width="100">
  26. <template slot-scope="scope">
  27. <el-button
  28. type="text"
  29. size="small"
  30. @click="onEnable(scope)"
  31. v-if="scope.row.priceStatus !== '启用'"
  32. >
  33. 启用
  34. </el-button>
  35. <el-button
  36. type="text"
  37. size="mini"
  38. @click="deleteOilPrice(scope)"
  39. >
  40. 删除
  41. </el-button>
  42. </template>
  43. </el-table-column>
  44. </dilTable>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. export default {
  50. name:"homeworkPath",
  51. data(){
  52. return{
  53. tableLoading:false,
  54. selectLoading:false,
  55. isKuang:false,
  56. //切换是否启用按钮和停用按钮
  57. enableStatus:true,
  58. textInput: "" ,
  59. restaurants: [],
  60. options:{
  61. // first请求数据的地址
  62. requestUrl: "/api/v1/rms/getOilPriceResultList?apiId=380",
  63. },
  64. }
  65. },
  66. methods:{
  67. func(res){
  68. if(this.selectLoading){
  69. this.selectLoading = false;
  70. }
  71. this.isKuang = false;
  72. this.tableLoading = false;
  73. },
  74. onclick(){
  75. this.isKuang = true;
  76. this.selectLoading = true;
  77. this.tableLoading = true;
  78. if(this.textInput!=null){
  79. this.textInput=this.textInput.replace('#','%23')
  80. this.textInput=this.textInput.replace('%','%25')
  81. this.options.requestUrl = "/api/v1/rms/getOilPriceResultList?apiId=380&con=" +this.textInput+"&i="+ new Date();
  82. }else{
  83. this.options.requestUrl = "/api/v1/rms/getOilPriceResultList?apiId=380&i="+ new Date();
  84. }
  85. },
  86. //跳转到新增页面
  87. toInsert() {
  88. this.$router.push("/addOilPrice");
  89. },
  90. deleteOilPrice(scope){
  91. this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  92. confirmButtonText: '确定',
  93. cancelButtonText: '取消',
  94. type: 'warning'
  95. }).then(() => {
  96. this.tableLoading = true;
  97. this.axios.post('/api/v1/rms/deleteOilPrice/'+scope.row.priceId).then((res)=>{
  98. if(res.data.code == "200"){
  99. this.$message.success('删除成功')
  100. this.options.requestUrl = "/api/v1/rms/getOilPriceResultList?apiId=380&i="+ new Date();
  101. }else{
  102. this.$message.error('删除失败,该油价正在启用!')
  103. this.options.requestUrl = "/api/v1/rms/getOilPriceResultList?apiId=380&i="+ new Date();
  104. }
  105. })
  106. }).catch(() => {
  107. this.$message.info('已取消删除');
  108. });
  109. },
  110. onEnable(scope){
  111. this.$confirm('将要启用该油价, 是否继续?', '提示', {
  112. confirmButtonText: '确定',
  113. cancelButtonText: '取消',
  114. type: 'warning'
  115. }).then(() => {
  116. this.axios.post("/api/v1/rms/updateOilPrice",{"priceId":scope.row.priceId}).then((res) => {
  117. if (res.data.code == "200") {
  118. this.$message({ type: "success", message: "启用成功!",});
  119. this.options.requestUrl = "/api/v1/rms/getOilPriceResultList?apiId=380&i="+ new Date();
  120. }else{
  121. this.$message({ type: "error", message: "启用失败,请联系管理员!",});
  122. }
  123. });
  124. }).catch(() => {
  125. this.$message.info('已取消启用该油价!');
  126. });
  127. }
  128. },
  129. }
  130. </script>
  131. <style lang="scss" scode>
  132. .steel_inbound{
  133. .sache{
  134. width: 100%;height: 100px;
  135. display: flex;
  136. align-items: center;
  137. .el-input {
  138. width: 250px;
  139. margin-left: 50px;
  140. margin-right: 30px;
  141. }
  142. .btn1{
  143. margin-right: 30px;
  144. }
  145. }
  146. }
  147. </style>