addUnloadShip.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <!-- 新增卸船作业 -->
  3. <div class="shipTransport">
  4. <page-title>返回</page-title>
  5. <!-- 第一部分 -->
  6. <div class="top">
  7. <el-input placeholder="请输入内容" v-model="input" clearable> </el-input>
  8. <el-button type="primary" class="btn" @click="onclick()">
  9. <i class="el-icon-search"></i>查询
  10. </el-button>
  11. </div>
  12. <dilTable v-bind.sync="option" @radio-change="currentRadioChange">
  13. </dilTable>
  14. <div class="form">
  15. <!-- 第二部分 -->
  16. <div class="form_box">
  17. <dil-form :formId="121" v-model="form"></dil-form>
  18. </div>
  19. </div>
  20. <div class="button_box_unloadShip">
  21. <el-button type="primary" :loading="isLoading" @click="makeSure"
  22. >新增卸船作业</el-button
  23. >
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import PageTitle from '@/components/Page/Title'
  29. import { sjTime } from '@/utils/sharedJsFile'
  30. import { getCookie } from '@/utils/util.js'
  31. export default {
  32. components: { PageTitle },
  33. data() {
  34. return {
  35. input: '',
  36. isLoading: false,
  37. restaurants: [],
  38. state: '',
  39. form: {},
  40. option: {
  41. // 表格请求数据的地址
  42. requestUrl: '/api/v1/tms/getCapacityList?apiId=138',
  43. // 控制显示当选列
  44. selectionType: 'radio'
  45. },
  46. unloadMap: {}
  47. }
  48. },
  49. computed: {
  50. a1() {
  51. return this.form.resultEndTime
  52. }
  53. },
  54. watch: {
  55. a1() {
  56. this.unloadShipMes()
  57. }
  58. },
  59. methods: {
  60. unloadShipMes() {
  61. if (
  62. typeof this.form.resultStartTime == 'undefined' ||
  63. this.form.resultStartTime == null ||
  64. this.form.resultStartTime == 'null' ||
  65. this.form.resultStartTime == 'undefined'
  66. ) {
  67. this.$message.warning('请先填写卸船开始时间!')
  68. this.form.resultEndTime = null
  69. }
  70. return
  71. },
  72. currentRadioChange(row) {
  73. this.unloadMap = {}
  74. this.unloadMap = row
  75. console.log(row)
  76. },
  77. onclick() {
  78. this.option.requestUrl =
  79. '/api/v1/tms/getCapacityList?apiId=138&con=' + this.input
  80. },
  81. // 新增
  82. makeSure() {
  83. this.isLoading = true
  84. console.log(this.unloadMap)
  85. if (JSON.stringify(this.unloadMap).length == 2) {
  86. this.$message.error('请先选择卸船的船只!')
  87. this.isLoading = false
  88. return
  89. }
  90. if (
  91. !this.form.resultArrivalDate ||
  92. !this.form.resultStartTime ||
  93. !this.form.resultEndTime ||
  94. !this.form.resultStatus
  95. ) {
  96. this.$message.warning("请填写时间信息!");
  97. this.isLoading = false
  98. return;
  99. }
  100. let resultArrivalDate = null
  101. let resultStartTime = null
  102. let resultEndTime = null
  103. if (this.form.resultArrivalDate ) {
  104. resultArrivalDate = sjTime(this.form.resultArrivalDate)
  105. }
  106. if (this.form.resultStartTime) {
  107. resultStartTime = sjTime(this.form.resultStartTime)
  108. }
  109. if (this.form.resultEndTime) {
  110. resultEndTime = sjTime(this.form.resultEndTime)
  111. }
  112. let mapVal = {
  113. resultArrivalDate: resultArrivalDate,
  114. resultStartTime: resultStartTime,
  115. resultEndTime: resultEndTime,
  116. resultStatus: this.form.resultStatus
  117. }
  118. this.axios
  119. .post('/api/v1/tms/addUnLoadShip', {
  120. mapVal: mapVal,
  121. unloadMap: this.unloadMap,
  122. userId: getCookie('userId')
  123. })
  124. .then(res => {
  125. if (res.data.code == 200) {
  126. this.$message({
  127. type: 'success',
  128. message: '新增成功!'
  129. })
  130. // this.$refs.table.refreshData();
  131. this.$router.go(-1)
  132. } else {
  133. this.$message.error('新增失败!')
  134. }
  135. this.isLoading = false
  136. })
  137. },
  138. loadAll() {
  139. return []
  140. },
  141. handleSelect(item) {
  142. console.log(item)
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .shipTransport {
  149. .form {
  150. display: flex;
  151. .form_box {
  152. width: 320px;
  153. margin-left: 35%;
  154. margin-top: 30px;
  155. margin-right: 20px;
  156. .el-form {
  157. .preview-group {
  158. .el-form-item {
  159. .el-form-item__label {
  160. display: inline-block;
  161. width: 70px !important;
  162. }
  163. .el-form-item__content {
  164. .el-select {
  165. width: 250px;
  166. }
  167. .el-input {
  168. width: 250px;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. }
  175. }
  176. .top {
  177. padding: 1.25rem 0.375rem;
  178. .el-input {
  179. width: 20%;
  180. margin-right: 1.25rem;
  181. }
  182. }
  183. .button_box_unloadShip {
  184. margin-left: 45%;
  185. width: 160px;
  186. }
  187. }
  188. </style>