editWagonPlease.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div class="contractDetails">
  3. <page-title>返回</page-title>
  4. <div class="form">
  5. <div class="form_box">
  6. <dil-form :formId="117" v-model="form1"></dil-form>
  7. </div>
  8. </div>
  9. <div class="fromOther">
  10. <el-form :inline="true" class="demo-form-inline" label-width="80px">
  11. <el-form-item label="发货单位">
  12. <el-autocomplete
  13. class="inline-input"
  14. v-model="stateSupplier"
  15. :fetch-suggestions="querySearchSupplier"
  16. placeholder="请输入发货单位名称"
  17. :trigger-on-focus="false"
  18. @select="handleSelectSupplier"
  19. >
  20. <template slot-scope="{ item }">
  21. <div class="name">{{ item.supplierName }}</div>
  22. </template>
  23. </el-autocomplete>
  24. </el-form-item>
  25. </el-form>
  26. </div>
  27. <!-- 确定和取消 -->
  28. <div class="button_box">
  29. <el-button @click="onClickCancel">返回</el-button>
  30. <el-button type="primary" @click="onClickConfirm">确认</el-button>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import PageTitle from "@/components/Page/Title";
  36. import { sjTime,isNumber } from "@/utils/sharedJsFile";
  37. export default {
  38. components: { PageTitle },
  39. data() {
  40. return {
  41. form1: {},
  42. supplierId: null,
  43. supplierName: "",
  44. stateSupplier: "",
  45. };
  46. },
  47. mounted() {
  48. this.information();
  49. },
  50. methods: {
  51. information() {
  52. //编辑请车作业
  53. this.axios
  54. .post("/api/v1/tms/getWagonPleaseById/" + this.$route.params.resultId)
  55. .then((res) => {
  56. res.data.data.forEach((e) => {
  57. this.form1 = e;
  58. });
  59. this.stateSupplier = res.data.data[0].supplierName;
  60. this.supplierId = res.data.data[0].supplierId;
  61. });
  62. },
  63. // 返回
  64. onClickCancel() {
  65. this.$router.go(-1);
  66. },
  67. //发货单位弹出层
  68. handleSelectSupplier(item){
  69. this.supplierId = item.supplierId
  70. item.supplierName = this.supplierName
  71. },
  72. //以下是发货单位边输边查搜索
  73. querySearchSupplier(queryString, cb) {
  74. this.axios.post('/api/v1/uc/getSupplierMesByLike?index='+this.stateSupplier).then((res)=>{
  75. if(res.data.code == "200"){
  76. var restaurantsSupplier = res.data.data
  77. var results = queryString ? restaurantsSupplier.filter(this.createFilterSupplier(queryString)) :restaurantsSupplier;
  78. // 调用 callback 返回建议列表的数据
  79. cb(results);
  80. }
  81. })
  82. },
  83. createFilterSupplier(queryString) {
  84. return (restaurantsSupplier) => {
  85. return (restaurantsSupplier.value.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
  86. };
  87. },
  88. // 确认
  89. onClickConfirm() {
  90. let tmstrainPleaseApproveResult = {
  91. resultId: this.$route.params.resultId,
  92. resultPlanDate: sjTime(this.form1.resultPlanDate),
  93. resultCategory: this.form1.resultCategory,
  94. supplierId: this.supplierId,
  95. sendStationId: this.form1.sendStationId,
  96. toTheStationId: this.form1.toTheStationId,
  97. resultPleaseNumber: this.form1.resultPleaseNumber,
  98. };
  99. function isNumber() {
  100. var value = tmstrainPleaseApproveResult.resultPleaseNumber;
  101. //验证是否为数字
  102. var patrn = /^(-)?\d+(\.\d+)?$/;
  103. if (patrn.exec(value) == null || value == "") {
  104. return false;
  105. } else {
  106. return true;
  107. }
  108. }
  109. var val = this.value;
  110. if (
  111. tmstrainPleaseApproveResult.resultPlanDate == null ||
  112. tmstrainPleaseApproveResult.resultCategory == null ||
  113. tmstrainPleaseApproveResult.supplierId == null ||
  114. tmstrainPleaseApproveResult.sendStationId == null ||
  115. tmstrainPleaseApproveResult.toTheStationId == null ||
  116. tmstrainPleaseApproveResult.resultPleaseNumber == null
  117. )
  118. this.$message.error("存在空值!");
  119. else if (!isNumber(val)) this.$message.error("请车数必须是数字!");
  120. else
  121. this.axios
  122. .post(
  123. "/api/v1/tms/updateApproveWagonPlease",
  124. tmstrainPleaseApproveResult
  125. )
  126. .then(() => {
  127. this.$message({
  128. type: "success",
  129. message: "修改成功!",
  130. });
  131. this.$router.go(-1);
  132. });
  133. },
  134. },
  135. };
  136. </script>
  137. <style lang="scss">
  138. .contractDetails {
  139. .form {
  140. display: flex;
  141. .form_box {
  142. width: 340px;
  143. margin-left: 35%;
  144. margin-top: 30px;
  145. margin-right: 20px;
  146. .el-form {
  147. .preview-group {
  148. .el-form-item {
  149. .el-form-item__label {
  150. display: inline-block;
  151. width: 70px !important;
  152. }
  153. .el-form-item__content {
  154. .el-select {
  155. width: 250px;
  156. }
  157. .el-input {
  158. width: 250px;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. .button_box {
  167. margin-left: 42%;
  168. margin-top: 55px;
  169. }
  170. }
  171. .fromOther {
  172. margin-left: 34.5%;
  173. width: 50%;
  174. .inline-input {
  175. width: 300px;
  176. }
  177. }
  178. </style>