addPlan.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // 新增计划
  2. <template>
  3. <div class="addInwardPlan">
  4. <page-title>新增计划</page-title>
  5. <div class="form-box">
  6. <el-form class="demo-form-inline" label-width="80px" label-position="left">
  7. <el-form-item label="承运商">
  8. <el-autocomplete
  9. class="inline-input"
  10. v-model="state2"
  11. :fetch-suggestions="querySearch"
  12. placeholder="请输入承运商名称"
  13. :trigger-on-focus="false"
  14. @select="handleSelect"
  15. @input="oninput"
  16. >
  17. <template slot-scope="{ item }">
  18. <div class="name">{{ item.value }}</div>
  19. </template>
  20. </el-autocomplete>
  21. </el-form-item>
  22. <el-form class="demo-form-inline" label-width="80px" label-position="left">
  23. <el-form-item label="车数">
  24. <el-input v-model="planTruckNumber" placeholder="必填" class="input"></el-input>
  25. </el-form-item>
  26. </el-form>
  27. </el-form>
  28. </div>
  29. <template>
  30. <div>
  31. <dilTable v-bind.sync="first" @radio-change="currentRadioChange">
  32. </dilTable>
  33. </div>
  34. </template>
  35. <div class="button-box">
  36. <el-button type="primary" @click="makeSure">确认新增</el-button>
  37. <el-button type="primary" @click="cancel">返回</el-button>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import PageTitle from "@/components/Page/Title";
  43. export default {
  44. components: { PageTitle },
  45. data() {
  46. return {
  47. restaurants: [],
  48. state2:null,
  49. planTruckNumber:null,
  50. carrierId:null,
  51. requirementId:null,
  52. form: {},
  53. first:{
  54. requestUrl:"/api/v1/ams/getTruckRequirementList?apiId=250&requirementStatus=2",
  55. selectionType: "radio",
  56. mapList: {},
  57. },
  58. numberValidateForm: {
  59. planTruckNumber: null,
  60. }
  61. };
  62. },
  63. methods: {
  64. handleSelect(item){
  65. this.carrierId = item.carrierId
  66. item.carrierName = this.state2
  67. },
  68. oninput(){
  69. this.axios.post('/api/v1/uc/getCarrierMesByLike?index='+this.state2).then((res)=>{
  70. if(res.data.code == "200"){
  71. console.log(res)
  72. this.restaurants = res.data.data
  73. }
  74. })
  75. },
  76. //搜索
  77. querySearch(queryString, cb) {
  78. var restaurants = this.restaurants;
  79. console.log(this.restaurants,"this.restaurants");
  80. var results = queryString ? restaurants.filter(this.createFilter(queryString)) :restaurants;
  81. // 调用 callback 返回建议列表的数据
  82. console.log(results,"results");
  83. cb(results);
  84. },
  85. createFilter(queryString) {
  86. return (restaurants) => {
  87. return (restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
  88. };
  89. },
  90. currentRadioChange(selection){
  91. this.mapList = selection
  92. this.requirementId = selection.requirementId
  93. console.log(this.mapList)
  94. },
  95. // 新增
  96. makeSure() {
  97. console.log(typeof(this.planTruckNumber))
  98. if(this.carrierId == null){
  99. this.$alert('请输入承运商!')
  100. return
  101. }else if(this.planTruckNumber == null){
  102. this.$alert('请输入车数!')
  103. return
  104. }else if(this.requirementId== null){
  105. this.$alert('请选择需要制定计划的需求!')
  106. return
  107. }
  108. let plan = {
  109. requirementId : this.mapList.requirementId,
  110. planTruckNumber: this.planTruckNumber,
  111. carrierId: this.carrierId
  112. };
  113. this.axios
  114. .post(
  115. "/api/v1/ams/addTruckPlan",
  116. plan
  117. )
  118. .then((res) => {
  119. console.log(res)
  120. if (res.data.code == 200) {
  121. this.$message({
  122. type: "success",
  123. message: "新增成功!",
  124. });
  125. this.$router.go(-1);
  126. } else {
  127. this.$message.error("新增失败!");
  128. }
  129. });
  130. },
  131. // 返回
  132. cancel() {
  133. this.$router.go(-1);
  134. },
  135. },
  136. };
  137. </script>
  138. <style lang="scss" scoped>
  139. .addInwardPlan{
  140. .form-box{
  141. display: inline-block;
  142. margin-left: 38%;
  143. .el-input{
  144. width:288px
  145. }
  146. .input{
  147. margin-left: -10px;
  148. }
  149. .el-form{
  150. padding: 10px;
  151. }
  152. }
  153. .button-box
  154. {
  155. margin-left: 25px !important;
  156. }
  157. }
  158. </style>