oilPrice.vue 4.3 KB

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