addMoistureDetection.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <!-- 添加二程船水运费1-->
  3. <div class="addWagonLoad">
  4. <PageTitle>返回</PageTitle>
  5. <div class="form-box">
  6. <!-- <dil-form :formId="271" v-model="form1" ref="from1"></dil-form> -->
  7. <el-form v-model="form">
  8. <div class="searchSelect">
  9. <span class="text">江船</span>
  10. <el-input class="input" v-model="batchName" disabled> </el-input>
  11. <el-button class="button" type="primary" @click="ondrawer(5)"
  12. >浏览</el-button
  13. >
  14. </div>
  15. <div class="switch">
  16. <el-switch v-model="value1" active-text="拼装" inactive-text="不拼装">
  17. </el-switch>
  18. </div>
  19. <div class="searchSelect">
  20. <span class="text">单价</span>
  21. <el-input
  22. class="input"
  23. v-model="form.unitPrice"
  24. disabled
  25. @change="calculate"
  26. >
  27. </el-input>
  28. <el-button class="button" type="primary" @click="ondrawer(6)"
  29. >浏览</el-button
  30. >
  31. </div>
  32. <div class="preview-group">
  33. <el-form-item label="港口数" v-if="spell == 'true'">
  34. <el-input v-model="form.portNum" type="number"></el-input>
  35. </el-form-item>
  36. <el-form-item label="船数" v-if="noSpell == 'false'">
  37. <el-input v-model="form.shipNum" type="number"></el-input>
  38. </el-form-item>
  39. <el-form-item label="开票日期">
  40. <el-date-picker
  41. v-model="form.makeTime"
  42. type="datetime"
  43. placeholder="选择日期"
  44. >
  45. </el-date-picker>
  46. </el-form-item>
  47. </div>
  48. </el-form>
  49. </div>
  50. <!-- 模态框 -->
  51. <el-drawer
  52. :visible.sync="drawer"
  53. :direction="direction"
  54. :before-close="handleClose"
  55. size="50%"
  56. >
  57. <el-input
  58. placeholder="请输入内容"
  59. v-model="input"
  60. style="margin-top: 10px; margin-left: 20px; width: 250px"
  61. clearable
  62. >
  63. </el-input>
  64. <el-button
  65. type="primary"
  66. class="btn"
  67. @click="onclick(a)"
  68. style="margin-bottom: 15px"
  69. >
  70. <i class="el-icon-search"></i>查询
  71. </el-button>
  72. <div v-show="a == 5">
  73. <dilTable
  74. v-bind.sync="batchOption"
  75. @radio-change="batchChange"
  76. ></dilTable>
  77. </div>
  78. <div v-show="a == 6">
  79. <dilTable
  80. v-bind.sync="contractPriceOption"
  81. @radio-change="priceChange"
  82. ></dilTable>
  83. </div>
  84. </el-drawer>
  85. <!-- 底部按钮 -->
  86. <div class="button-box">
  87. <el-button @click="cancel">取消</el-button>
  88. <el-button type="primary" @click="makeSure" :loading="isLoading"
  89. >确定</el-button
  90. >
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import PageTitle from "@/components/Page/Title";
  96. import { sjTime } from "@/utils/sharedJsFile";
  97. import { getCookie } from "@/utils/util.js";
  98. import { BigNumber } from "bignumber.js";
  99. export default {
  100. components: { PageTitle },
  101. data() {
  102. return {
  103. spell: false,
  104. noSpell: "false",
  105. value1: false,
  106. form: {},
  107. portId: null,
  108. ports: [],
  109. isLoading: false,
  110. drawer: false,
  111. direction: "rtl",
  112. a: 0,
  113. input: null,
  114. batchId: null,
  115. purchaseOrderId: null,
  116. batchName: null,
  117. cargoPictureUrl: "",
  118. batchOption: {
  119. requestUrl: "/api/v1/bms/getShipResult?apiId=112",
  120. selectionType: "radio",
  121. map: []
  122. },
  123. contractPriceOption: {
  124. requestUrl: "/api/v1/rms/selectbmsshipContractPriceList?apiId=500",
  125. selectionType: "radio",
  126. map: []
  127. }
  128. };
  129. },
  130. mounted() {
  131. //this.getPorts();
  132. },
  133. computed: {
  134. portNum() {
  135. return this.form.portNum;
  136. }
  137. },
  138. watch: {
  139. portNum() {
  140. console.log(this.form.portNum);
  141. },
  142. value1() {
  143. if (this.value1) {
  144. this.spell = "true";
  145. this.noSpell = "true";
  146. } else {
  147. this.spell = "false";
  148. this.noSpell = "false";
  149. }
  150. }
  151. },
  152. methods: {
  153. //右侧选中框
  154. ondrawer(num) {
  155. this.drawer = true;
  156. this.a = num;
  157. if (num == 5) {
  158. this.batchOption.requestUrl =
  159. "/api/v1/bms/getShipResult?apiId=112" + "&i=" + new Date();
  160. } else if (num == 6) {
  161. this.contractPriceOption.requestUrl =
  162. "/api/v1/rms/selectbmsshipContractPriceList?apiId=500" +
  163. "&i=" +
  164. new Date();
  165. }
  166. // 清空当前输入框中的数据
  167. this.input = "";
  168. },
  169. handleClose(done) {
  170. done();
  171. },
  172. onclick(a) {
  173. if (a == 5) {
  174. this.batchOption.requestUrl =
  175. "/api/v1/bms/getShipResult?apiId=112&index=" + this.input;
  176. } else if (a == 6) {
  177. this.contractPriceOption.requestUrl =
  178. "/api/v1/rms/selectbmsshipContractPriceList?apiId=500&con=" +
  179. this.input;
  180. }
  181. },
  182. //修改选中
  183. batchChange(selection) {
  184. console.log(selection);
  185. this.batchId = selection.batchId;
  186. this.purchaseOrderId = selection.purchaseOrderId;
  187. this.batchName = selection.materialName + selection.resultForeignShipName;
  188. },
  189. priceChange(selection) {
  190. this.form.unitPriceId = selection.resultId;
  191. this.form.unitPrice = selection.unitPrice;
  192. this.calculate();
  193. },
  194. //计算水运费
  195. calculate() {
  196. console.log(
  197. "能否计算水运费:",
  198. this.form.realTonnage && this.form.unitPrice
  199. );
  200. if (this.form.realTonnage && this.form.unitPrice) {
  201. let fee = new BigNumber(this.form.realTonnage);
  202. this.$set(
  203. this.form,
  204. "fee",
  205. fee.multipliedBy(this.form.unitPrice).toNumber()
  206. );
  207. console.log(this.form.fee);
  208. }
  209. },
  210. makeSure() {
  211. //this.isLoading=true;
  212. let map = {
  213. batchId: this.batchId,
  214. purchaseOrderId: this.purchaseOrderId,
  215. unitPrice: this.form.unitPrice,
  216. unitPriceId: this.form.unitPriceId,
  217. shipNum: this.form.shipNum,
  218. portNum: this.form.portNum,
  219. makeTime: sjTime(this.form.makeTime),
  220. feeType: 5,
  221. userId: getCookie("userId")
  222. };
  223. console.log(map);
  224. if (
  225. map.batchId == null ||
  226. map.purchaseOrderId == null ||
  227. map.unitPrice == null ||
  228. map.unitPriceId == null ||
  229. map.makeTime == null
  230. ) {
  231. this.$message.error("存在空值!");
  232. this.isLoading = false;
  233. } else {
  234. this.axios
  235. .post("/api/v1/bms/addwaterStatement", map)
  236. .then(res => {
  237. if (res.data.code == 200) {
  238. this.$message({
  239. type: "success",
  240. message: "新增成功!"
  241. });
  242. this.cancel();
  243. } else {
  244. this.$message.error(res.data.data);
  245. this.isLoading = false;
  246. }
  247. })
  248. .then(() => {
  249. this.isLoading = false;
  250. });
  251. }
  252. },
  253. // 取消
  254. cancel() {
  255. this.$router.go(-1);
  256. },
  257. //查询港口id
  258. getPorts() {
  259. this.axios.post("/api/v1/rms/getPortName?index=").then(res => {
  260. if (res.data.code == 200) {
  261. this.ports = res.data.data;
  262. console.log(this.ports);
  263. } else {
  264. this.$message.error(res.data.data);
  265. }
  266. });
  267. },
  268. upCLick(val) {
  269. this.num = val;
  270. }
  271. }
  272. };
  273. </script>
  274. <style lang="scss">
  275. .searchSelect {
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. margin: 5px;
  280. .text {
  281. width: 40px;
  282. }
  283. .input {
  284. width: 200px;
  285. }
  286. .button {
  287. margin-left: 6px;
  288. }
  289. }
  290. .switch {
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. margin-top: 20px;
  295. margin-bottom: 20px;
  296. }
  297. .button-box {
  298. display: flex;
  299. justify-content: center;
  300. margin: 20px;
  301. .el-button {
  302. width: 80px;
  303. margin: 10px;
  304. }
  305. }
  306. .form-box {
  307. display: flex;
  308. justify-content: center;
  309. .el-form-item {
  310. display: flex;
  311. justify-content: center;
  312. .el-form-item__label {
  313. display: flex;
  314. align-items: center;
  315. }
  316. .el-form-item__content {
  317. .el-input {
  318. .el-input__inner {
  319. width: 250px;
  320. }
  321. }
  322. }
  323. }
  324. }
  325. </style>