addOilPrice.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <!-- 添加油价信息 -->
  3. <div class="addWagonLoad">
  4. <page-title>返回</page-title>
  5. <div class="form_box" style="margin-right: 10rem">
  6. <dil-form :formId="357" v-model="form1" ref="from1" @change="onchang"></dil-form>
  7. <div class="addbtn">
  8. <el-button type="primary" @click="dialogVisible = true">新增油品名称</el-button>
  9. </div>
  10. </div>
  11. <div class="button_box">
  12. <el-button @click="cancel">取消</el-button>
  13. <el-button type="primary" @click="makeSure">确定</el-button>
  14. </div>
  15. <el-dialog
  16. title="新增油品名称"
  17. :visible.sync="dialogVisible"
  18. width="30%"
  19. >
  20. <el-input v-model="input" placeholder="请输入内容"></el-input>
  21. <span slot="footer" class="dialog-footer">
  22. <el-button @click="dialogCancel">取 消</el-button>
  23. <el-button type="primary" @click="dialogMakeSure">确 定</el-button>
  24. </span>
  25. </el-dialog>
  26. </div>
  27. </template>
  28. <script>
  29. import PageTitle from "@/components/Page/Title";
  30. import { isNumber } from '@/utils/sharedJsFile'
  31. export default {
  32. components: { PageTitle },
  33. data() {
  34. return {
  35. isagain:false,
  36. loading:false,
  37. input:null,
  38. dialogVisible:false,
  39. form1: {
  40. priceOilName:'',
  41. priceValue:'',
  42. priceDate:new Date(),
  43. enableStatus:false,
  44. },
  45. };
  46. },
  47. methods: {
  48. dialogCancel(){
  49. },
  50. onchang(val){
  51. if(val.enableStatus){
  52. this.$message.warning('确认启用后将停用现在正在执行的油品价格')
  53. }
  54. },
  55. dialogMakeSure(){
  56. // this.loading = true;
  57. // if(this.input){
  58. // this.axios.post('',{text:this.input}).then((res)=>{
  59. // if(res.data.code == "200"){
  60. // this.loading = false;
  61. // this.$message.success('新增成功')
  62. this.dialogVisible = false;
  63. // }
  64. // })
  65. // }else{
  66. // this.$message.warning('请输入油品名称')
  67. // }
  68. },
  69. makeSure() {
  70. this.loading = true;
  71. let state = false;
  72. if(!this.form1.priceOilName){
  73. this.$message.warning('请填写油品名称')
  74. }else if(!this.form1.priceValue){
  75. this.$message.warning('请填写油品价格')
  76. }else if(!isNumber(this.form1.priceValue)){
  77. this.$message.warning('油品价格必修为整数或者小数')
  78. }else{
  79. // state = true;
  80. }
  81. if(state){
  82. let RmsOilPrice = this.form1;
  83. this.axios.post("/api/v1/rms/insertOilPrice" , RmsOilPrice)
  84. .then((res) => {
  85. if (res.data.code == "200") {
  86. this.loading = true;
  87. this.$message.success('新增成功');
  88. this.cancel();
  89. }
  90. });
  91. }else{
  92. this.loading = true;
  93. }
  94. },
  95. // 取消
  96. cancel() {
  97. this.$router.push("/oilPrice");
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang='scss'>
  103. .addWagonLoad{
  104. .form_box{
  105. margin-left: 35%;
  106. padding-top: 30px;
  107. width: 470px;
  108. display: flex;
  109. .el-form{
  110. .el-form-item{
  111. display: flex;
  112. align-items: center;
  113. .el-form-item__content{
  114. .el-input{
  115. width: 250px;
  116. }
  117. .el-switch{
  118. margin-left: -250px;
  119. }
  120. }
  121. }
  122. }
  123. .addbtn{
  124. margin-left: 30px;
  125. }
  126. }
  127. .button_box{
  128. margin-left: 40%;
  129. padding-top: 30px;
  130. width: 310px;
  131. display: flex;
  132. justify-content: center;
  133. }
  134. }
  135. </style>