wagonPleaseEdit.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <!-- 修改请车作业页面 -->
  3. <div class="contractDetails">
  4. <page-title>返回</page-title>
  5. <div class="form">
  6. <div class="form_box">
  7. <dil-form :formId="117" v-model="form1"></dil-form>
  8. </div>
  9. </div>
  10. <div class="formOther">
  11. <div class="form_box">
  12. <el-form :inline="true" class="demo-form-inline" label-width="80px">
  13. <el-form-item label="发货单位">
  14. <el-autocomplete
  15. class="inline-input"
  16. v-model="stateSupplier"
  17. :fetch-suggestions="querySearchSupplier"
  18. placeholder="请输入发货单位名称"
  19. :trigger-on-focus="false"
  20. @select="handleSelectSupplier"
  21. >
  22. <template slot-scope="{ item }">
  23. <div class="name">{{ item.supplierName }}</div>
  24. </template>
  25. </el-autocomplete>
  26. </el-form-item>
  27. <el-form-item label="发站">
  28. <el-autocomplete
  29. class="inline-input"
  30. v-model="sendStation"
  31. :fetch-suggestions="querySearchSendStation"
  32. placeholder="请输入发站名称"
  33. :trigger-on-focus="false"
  34. @select="handleSelectSendStation"
  35. >
  36. <template slot-scope="{ item }">
  37. <div class="name">{{ item.arrivalName }}</div>
  38. </template>
  39. </el-autocomplete>
  40. </el-form-item>
  41. <el-form-item label="到站">
  42. <el-autocomplete
  43. class="inline-input"
  44. v-model="toTheStation"
  45. :fetch-suggestions="querySearchToTheStation"
  46. placeholder="请输入到站名称"
  47. :trigger-on-focus="false"
  48. @select="handleSelectToTheStation"
  49. >
  50. <template slot-scope="{ item }">
  51. <div class="name">{{ item.arrivalName }}</div>
  52. </template>
  53. </el-autocomplete>
  54. </el-form-item>
  55. </el-form>
  56. </div>
  57. </div>
  58. <div class="button_box">
  59. <el-button @click="onClickCancel">返回</el-button>
  60. <el-button type="primary" @click="onClickConfirm">确认</el-button>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import PageTitle from "@/components/Page/Title";
  66. import { sjTime } from "@/utils/sharedJsFile";
  67. export default {
  68. components: { PageTitle },
  69. data(){
  70. return {
  71. form1: {},
  72. stateSupplier:null,
  73. supplierId:null,
  74. sendStationId:null,
  75. toTheStationId:null,
  76. sendStation:"",
  77. toTheStation:""
  78. }
  79. },
  80. mounted() {
  81. this.information();
  82. },
  83. methods: {
  84. information() {
  85. //编辑请车作业
  86. this.axios
  87. .post("/api/v1/tms/getWagonPleaseById/" + this.$route.params.resultId)
  88. .then((res) => {
  89. res.data.data.forEach((e) => {
  90. this.form1 = e;
  91. console.log(e)
  92. this.supplierId = e.supplierId
  93. this.stateSupplier = e.supplierName
  94. this.toTheStationId = e.toTheStationId
  95. this.sendStationId = e.sendStationId
  96. this.sendStation = e.sendName
  97. this.toTheStation = e.arrivalName
  98. });
  99. });
  100. },
  101. // 返回
  102. onClickCancel() {
  103. this.$router.go(-1);
  104. },
  105. //发货单位弹出层
  106. handleSelectSupplier(item){
  107. this.supplierId = item.supplierId
  108. item.supplierName = this.stateSupplier
  109. },
  110. //以下是发货单位边输边查搜索
  111. querySearchSupplier(queryString, cb) {
  112. this.axios.post('/api/v1/uc/getSupplierMesByLike?index='+this.stateSupplier).then((res)=>{
  113. if(res.data.code == "200"){
  114. var restaurantsSupplier = res.data.data
  115. var results = queryString ? restaurantsSupplier.filter(this.createFilterSupplier(queryString)) :restaurantsSupplier;
  116. // 调用 callback 返回建议列表的数据
  117. cb(results);
  118. }
  119. })
  120. },
  121. createFilterSupplier(queryString) {
  122. return (restaurantsSupplier) => {
  123. return (restaurantsSupplier.value.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
  124. };
  125. },
  126. //发站弹出层
  127. handleSelectSendStation(item) {
  128. this.sendStationId = item.arrivalId;
  129. this.sendStation = item.arrivalName;
  130. },
  131. //以下是发站边输边查搜索
  132. querySearchSendStation(queryString, cb) {
  133. this.axios
  134. .get("/api/v1/uc/getArrivalByLike?index=" + this.sendStation)
  135. .then((res) => {
  136. if (res.data.code == "200") {
  137. var restaurantsSupplier = res.data.data;
  138. console.log(restaurantsSupplier)
  139. var results = queryString
  140. ? restaurantsSupplier.filter(
  141. this.createFilterSendStation(queryString)
  142. )
  143. : restaurantsSupplier;
  144. // 调用 callback 返回建议列表的数据
  145. cb(results);
  146. }
  147. });
  148. },
  149. //发站
  150. createFilterSendStation(queryString) {
  151. return (restaurantsSupplier) => {
  152. return (
  153. restaurantsSupplier.arrivalName
  154. .toLowerCase()
  155. .indexOf(queryString.toLowerCase()) > -1
  156. );
  157. };
  158. },
  159. //到站弹出层
  160. handleSelectToTheStation(item) {
  161. this.toTheStationId = item.arrivalId;
  162. this.toTheStation = item.arrivalName;
  163. },
  164. //以下是到站边输边查搜索
  165. querySearchToTheStation(queryString, cb) {
  166. this.axios
  167. .get("/api/v1/uc/getArrivalByLike?index=" + this.toTheStation)
  168. .then((res) => {
  169. if (res.data.code == "200") {
  170. var restaurantsSupplier = res.data.data;
  171. console.log(restaurantsSupplier)
  172. var results = queryString
  173. ? restaurantsSupplier.filter(
  174. this.createFilterToTheStation(queryString)
  175. )
  176. : restaurantsSupplier;
  177. // 调用 callback 返回建议列表的数据
  178. cb(results);
  179. }
  180. });
  181. },
  182. //到站
  183. createFilterToTheStation(queryString) {
  184. return (restaurantsSupplier) => {
  185. return (
  186. restaurantsSupplier.arrivalName
  187. .toLowerCase()
  188. .indexOf(queryString.toLowerCase()) > -1
  189. );
  190. };
  191. },
  192. // 确认
  193. onClickConfirm() {
  194. let tmstrainPleaseApproveResult = {
  195. resultId: this.$route.params.resultId,
  196. resultPlanDate: sjTime(this.form1.resultPlanDate),
  197. resultCategory: this.form1.resultCategory,
  198. supplierId: this.supplierId,
  199. sendStationId: this.sendStationId,
  200. toTheStationId: this.toTheStationId,
  201. resultPleaseNumber: this.form1.resultPleaseNumber
  202. };
  203. console.log(tmstrainPleaseApproveResult)
  204. function isNumber() {
  205. var value = tmstrainPleaseApproveResult.resultPleaseNumber;
  206. //验证是否为数字
  207. var patrn = /^(-)?\d+(\.\d+)?$/;
  208. if (patrn.exec(value) == null || value == "") {
  209. return false;
  210. } else {
  211. return true;
  212. }
  213. }
  214. var val = this.value;
  215. if (
  216. tmstrainPleaseApproveResult.resultPlanDate==null||
  217. tmstrainPleaseApproveResult.resultCategory==null||
  218. tmstrainPleaseApproveResult.supplierId == null ||
  219. tmstrainPleaseApproveResult.sendStationId==null||
  220. tmstrainPleaseApproveResult.toTheStationId==null||
  221. tmstrainPleaseApproveResult.resultPleaseNumber==null
  222. ) this.$message.error("存在空值!");
  223. else
  224. if (!isNumber(val)) this.$message.error("请车数必须是数字!");
  225. else
  226. this.axios
  227. .post("/api/v1/tms/updateApproveWagonPlease", tmstrainPleaseApproveResult)
  228. .then(() => {
  229. this.$message({
  230. type: "success",
  231. message: "修改成功!",
  232. });
  233. this.$router.go(-1);
  234. });
  235. },
  236. },
  237. };
  238. </script>
  239. <style lang="scss">
  240. .contractDetails {
  241. .form {
  242. display: flex;
  243. .form_box {
  244. width: 340px;
  245. margin-left: 36%;
  246. margin-top: 30px;
  247. margin-right: 20px;
  248. .el-form {
  249. .preview-group {
  250. .el-form-item {
  251. .el-form-item__label {
  252. display: inline-block;
  253. width: 70px !important;
  254. }
  255. .el-form-item__content {
  256. .el-select {
  257. width: 250px;
  258. }
  259. .el-input {
  260. width: 250px;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
  268. .button_box {
  269. margin-left: 42%;
  270. margin-top: 55px;
  271. }
  272. }
  273. .formOther {
  274. display: flex;
  275. .form_box {
  276. width: 340px;
  277. margin-left: 36%;
  278. margin-top: 30px;
  279. margin-right: 20px;
  280. .el-form {
  281. .el-form-item {
  282. .el-form-item__label {
  283. display: inline-block;
  284. width: 70px !important;
  285. }
  286. .el-form-item__content {
  287. .inline-input{
  288. width:250px;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. </style>
  296. </style>