instructionsCapacity.vue 6.8 KB

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