addContractPrice.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <!-- 添加合同单价信息 -->
  3. <div class="addWagonLoad">
  4. <PageTitle>返回</PageTitle>
  5. <div class="form-box">
  6. <!-- <dil-form :formId="271" v-model="form1" ref="from1"></dil-form> -->
  7. <el-form v-model="form">
  8. <div class="preview-group">
  9. <el-form-item label="合同号">
  10. <el-input v-model="form.contractNo"></el-input>
  11. </el-form-item>
  12. <el-form-item label="单价">
  13. <el-input v-model="form.unitPrice" type="number"></el-input>
  14. </el-form-item>
  15. <el-form-item label="港口">
  16. <el-select v-model="form.portId" filterable multiple>
  17. <el-option
  18. v-for="port in ports"
  19. :key="port.portId"
  20. :label="port.portName"
  21. :value="port.portId"
  22. >
  23. </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="起始日期">
  27. <el-date-picker
  28. v-model="form.startTime"
  29. type="datetime"
  30. placeholder="选择日期">
  31. </el-date-picker>
  32. </el-form-item>
  33. <el-form-item label="截止日期">
  34. <el-date-picker
  35. v-model="form.endTime"
  36. type="datetime"
  37. placeholder="选择日期">
  38. </el-date-picker>
  39. </el-form-item>
  40. </div>
  41. </el-form>
  42. </div>
  43. <div class="button-box">
  44. <el-button @click="cancel">取消</el-button>
  45. <el-button type="primary" @click="makeSure" :loading="isLoading">确定</el-button>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import PageTitle from "@/components/Page/Title";
  51. import { sjTime } from "@/utils/sharedJsFile";
  52. import { getCookie } from "@/utils/util.js";
  53. export default {
  54. components: { PageTitle },
  55. data() {
  56. return {
  57. form: {
  58. portId:[],
  59. contractNo:null,
  60. unitPrice:null,
  61. startTime:null,
  62. endTime:null,
  63. userId:getCookie("userId")
  64. },
  65. ports:[],
  66. isLoading:false
  67. };
  68. },
  69. mounted() {
  70. this.getPorts();
  71. },
  72. methods: {
  73. makeSure() {
  74. this.isLoading=true;
  75. if (this.form.contractNo == null ||
  76. this.form.contractNo =='' ||
  77. this.form.unitPrice =='' ||
  78. this.form.unitPrice == null ||
  79. this.form.startTime == null ||
  80. this.form.endTime == null){
  81. this.$message.error("存在空值!");
  82. this.isLoading=false;
  83. }else if(this.form.startTime>=this.form.endTime){
  84. this.$message.error("起始日期必须小于截止日期!");
  85. this.isLoading=false;
  86. }
  87. else{
  88. let map=this.form;
  89. map.userId=getCookie("userId");
  90. console.log(map);
  91. map.startTime = sjTime(this.form.startTime);
  92. map.endTime = sjTime(this.form.endTime);
  93. this.axios.post("/api/v1/rms/insertBmsshipContractPrice",map).then(res => {
  94. if (res.data.code == 200) {
  95. this.$message({
  96. type: "success",
  97. message: "新增成功!"
  98. });
  99. this.cancel();
  100. } else {
  101. this.$message.error(res.data.data);
  102. }
  103. }).then(()=>{
  104. this.isLoading=false;
  105. });
  106. }
  107. },
  108. // 取消
  109. cancel() {
  110. this.$router.go(-1);
  111. },
  112. //查询港口id
  113. getPorts(){
  114. this.axios.post("/api/v1/rms/getPortName?index=").then(res => {
  115. if (res.data.code == 200) {
  116. this.ports=res.data.data;
  117. console.log(this.ports);
  118. } else {
  119. this.$message.error(res.data.data);
  120. }
  121. }).then(()=>{
  122. let copy=this.$route.query;
  123. console.log("copy:",copy);
  124. //如果有值,则复制新增
  125. if(copy){
  126. if(copy.portId){
  127. copy.portId=[copy.portId * 1];
  128. }
  129. this.$set(this,"form",copy);
  130. }
  131. });
  132. }
  133. }
  134. };
  135. </script>
  136. <style lang="scss">
  137. .button-box {
  138. display: flex;
  139. justify-content: center;
  140. margin: 20px;
  141. .el-button {
  142. width: 80px;
  143. margin: 10px;
  144. }
  145. }
  146. .form-box {
  147. display: flex;
  148. justify-content: center;
  149. .el-form-item {
  150. display: flex;
  151. justify-content: center;
  152. .el-form-item__label {
  153. display: flex;
  154. align-items: center;
  155. }
  156. .el-form-item__content {
  157. .el-input {
  158. .el-input__inner {
  159. width: 250px;
  160. }
  161. }
  162. }
  163. }
  164. }
  165. </style>