instructionsCapacity.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <!-- 船只信息页面 -->
  3. <div class="homeworkPath">
  4. <page-title>船只信息</page-title>
  5. <div class="shipName">
  6. <span class="text">江船船名</span>
  7. <el-autocomplete
  8. v-model="state"
  9. :fetch-suggestions="querySearch"
  10. placeholder="请输入内容"
  11. :trigger-on-focus="false"
  12. @select="handleSelect"
  13. >
  14. <template slot-scope="{ item }">
  15. <div class="name">{{ item.capacityName }}</div>
  16. </template></el-autocomplete
  17. >
  18. </div>
  19. <div class="form">
  20. <dil-form :formId="119" v-model="form"></dil-form>
  21. </div>
  22. <div class="btn">
  23. <el-button type="primary" @click="makeSure">新增船只</el-button>
  24. </div>
  25. <dilTable v-bind.sync="option">
  26. <el-table-column fixed="right" label="操作" align="center" width="150">
  27. <template slot-scope="scope">
  28. <el-button
  29. type="text"
  30. size="mini"
  31. @click="deleteclick(scope.row.orderId)"
  32. >删除</el-button
  33. >
  34. </template>
  35. </el-table-column>
  36. </dilTable>
  37. </div>
  38. </template>
  39. <script>
  40. import PageTitle from "@/components/Page/Title";
  41. import { sjTime } from "@/utils/sharedJsFile";
  42. export default {
  43. components: { PageTitle },
  44. data() {
  45. return {
  46. restaurants: [],
  47. state: "",
  48. form: {},
  49. capacityIds: "",
  50. option: {
  51. // 表格请求数据的地址
  52. requestUrl:
  53. "/api/v1/tms/getCapacities?apiId=76&instructionsId=" +
  54. this.$route.params.instructionsId
  55. }
  56. };
  57. },
  58. methods: {
  59. querySearch(queryString, cb) {
  60. this.axios
  61. .post("/api/v1/tms/getShipNameList?state=" + this.state)
  62. .then(res => {
  63. console.log(res.data.data);
  64. var restaurants = res.data.data;
  65. var results = queryString
  66. ? restaurants.filter(this.createFilter(queryString))
  67. : restaurants;
  68. // 调用 callback 返回建议列表的数据
  69. cb(results);
  70. });
  71. },
  72. createFilter(queryString) {
  73. return restaurant => {
  74. return (
  75. restaurant.capacityName
  76. .toLowerCase()
  77. .indexOf(queryString.toLowerCase()) > -1
  78. );
  79. };
  80. },
  81. handleSelect(item) {
  82. this.capacityIds = item.capacityId;
  83. this.state = item.capacityName;
  84. console.log(this.capacityIds);
  85. this.axios
  86. .get("/api/v1/uc/getCapacityTel?capacityId=" + item.capacityId)
  87. .then(res => {
  88. console.log(res.data);
  89. if (res.data) {
  90. this.$set(this.form, "instructionContactInf", res.data.capacityTel);
  91. }
  92. });
  93. //根据运力ID查询联系方式
  94. },
  95. // 新增
  96. makeSure() {
  97. let omsshipInstructionsCapacity = {
  98. instructionsId: this.$route.params.instructionsId,
  99. state: this.state,
  100. capacityName: this.state,
  101. capacityIds: this.capacityIds,
  102. instructionPlannedLoading: this.form.instructionPlannedLoading,
  103. instructionsShipPosition: this.form.instructionsShipPosition,
  104. instructionContactInf: this.form.instructionContactInf,
  105. instructionsCapacityStatus: this.form.instructionsCapacityStatus,
  106. instructionEsarrivalTime: sjTime(this.form.instructionEsarrivalTime)
  107. };
  108. //判断是否为电话号码
  109. function isTelePhone() {
  110. var value2 = omsshipInstructionsCapacity.instructionContactInf;
  111. //验证是否为数字
  112. var patrn = /^1[3-9]\d{9}$/;
  113. // var patrn2 = /^(\d{3,4}-)?\d{7,8}$/;
  114. if (patrn.exec(value2) == null || value2 == "") {
  115. return false;
  116. } else {
  117. return true;
  118. }
  119. }
  120. //判断放货数量是否为数字
  121. function isNumber() {
  122. var value = omsshipInstructionsCapacity.instructionPlannedLoading;
  123. //验证是否为数字
  124. var patrn = /^(-)?\d+(\.\d+)?$/;
  125. if (patrn.exec(value) == null || value == "") {
  126. return false;
  127. } else {
  128. return true;
  129. }
  130. }
  131. var val = this.value;
  132. var val2 = this.value2;
  133. if (
  134. omsshipInstructionsCapacity.state == null ||
  135. omsshipInstructionsCapacity.instructionPlannedLoading == null ||
  136. omsshipInstructionsCapacity.instructionsShipPosition == null ||
  137. omsshipInstructionsCapacity.instructionContactInf == null ||
  138. omsshipInstructionsCapacity.instructionsCapacityStatus == null ||
  139. omsshipInstructionsCapacity.instructionEsarrivalTime == null ||
  140. omsshipInstructionsCapacity.capacityName == null
  141. )
  142. this.$message.error("存在空值!");
  143. else if (!isNumber(val)) this.$message.warning("计划装载吨位必须为数字");
  144. else if (!isTelePhone(val2)) this.$message.warning("联系方式格式错误");
  145. else
  146. this.axios
  147. .post(
  148. "/api/v1/tms/addInstructionsCapacity",
  149. omsshipInstructionsCapacity
  150. )
  151. .then(res => {
  152. if (res.data.code == 200) {
  153. this.$message({
  154. type: "success",
  155. message: "新增成功!"
  156. });
  157. // this.$refs.table.refreshData();
  158. this.option.requestUrl =
  159. "/api/v1/tms/getCapacities?apiId=76&instructionsId=" +
  160. this.$route.params.instructionsId +
  161. "&i=" +
  162. new Date();
  163. // this.$router.go(this.option);
  164. } else {
  165. this.$message.error("新增失败!");
  166. }
  167. this.$refs["table"].resetField();
  168. });
  169. },
  170. click(orderId, instructionsId) {
  171. this.$router.push(
  172. "/ship/updateInstructionsCapacity/" +
  173. orderId +
  174. "?instructionsId=" +
  175. instructionsId
  176. );
  177. },
  178. deleteclick(scope) {
  179. let orderId = scope;
  180. this.$confirm("是否删除", "提示", {
  181. confirmButtonText: "确定",
  182. cancelButtonText: "取消",
  183. type: "warning",
  184. center: true
  185. })
  186. .then(() => {
  187. this.axios
  188. .post("/api/v1/tms/deleteInstructionsCapacity/" + orderId)
  189. .then(() => {
  190. this.$message({
  191. type: "success",
  192. message: "删除成功!"
  193. });
  194. this.option.requestUrl =
  195. "/api/v1/tms/getCapacities?apiId=76&instructionsId=" +
  196. this.$route.params.instructionsId +
  197. "&i=" +
  198. new Date();
  199. });
  200. })
  201. .catch(() => {
  202. this.$message({
  203. type: "info",
  204. message: "取消删除!"
  205. });
  206. });
  207. }
  208. }
  209. };
  210. </script>
  211. <style lang="scss">
  212. .homeworkPath {
  213. .shipName {
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. margin-top: 1.25rem;
  218. .text {
  219. width: 6.25rem;
  220. text-align: right;
  221. padding-right: 0.9375rem;
  222. font-size: 0.9375rem;
  223. font-weight: 600;
  224. color: #606266;
  225. }
  226. }
  227. .form {
  228. margin-top: 1.25rem;
  229. display: flex;
  230. justify-content: center;
  231. align-items: center;
  232. }
  233. }
  234. </style>