editThreeSectionFee.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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
  16. class="material"
  17. v-for="(item, index) in form.Array"
  18. :key="index"
  19. style="margin-left:30px"
  20. >
  21. <el-form :inline="true">
  22. <el-form-item label="装船时间">
  23. <el-input
  24. v-model="item.resultLoadShipDate"
  25. placeholder="装船时间"
  26. disabled
  27. ></el-input>
  28. </el-form-item>
  29. <el-form-item label="离港时间">
  30. <el-input
  31. v-model="item.resultOutPortTime"
  32. placeholder="离港时间"
  33. disabled
  34. ></el-input>
  35. </el-form-item>
  36. <el-form-item label="实装吨位">
  37. <el-input
  38. v-model="item.resultActualInstallations"
  39. placeholder="实装吨位"
  40. disabled
  41. ></el-input>
  42. </el-form-item>
  43. <el-form-item label="水运费用">
  44. <el-input v-model="item.fee" type="number" disabled></el-input>
  45. <el-button type="primary" @click="ondrawer(6, index)"
  46. >浏览单价</el-button
  47. >
  48. </el-form-item>
  49. </el-form>
  50. </div>
  51. <div class="preview-group">
  52. <el-form-item label="开票日期">
  53. <el-date-picker
  54. v-model="form.makeTime"
  55. type="datetime"
  56. placeholder="选择日期"
  57. >
  58. </el-date-picker>
  59. </el-form-item>
  60. <el-form-item label="上传水运单图片">
  61. <el-upload
  62. class="upload-demo"
  63. style="width: 270px"
  64. ref="upload1"
  65. accept=".pdf , .jpg, .png, .jpeg, .tif, .gif, .pcx, .tga, .exif, .fpx, .svg , .bmp"
  66. action="/api/v1/bms/uploadBmsshipOrder"
  67. :before-upload="beforeUpload"
  68. :multiple="false"
  69. list-type="picture"
  70. :show-file-list="false"
  71. :on-success="handleAvatarSuccess"
  72. :on-error="onError(1)"
  73. >
  74. <el-input
  75. class="shippingCertificate"
  76. style="width: 270px; display: flex"
  77. placeholder="上传水运单图片(必填项)"
  78. v-model="form.image"
  79. disabled
  80. >
  81. </el-input>
  82. <el-button
  83. size="small"
  84. type="primary"
  85. style="
  86. width: 115px;
  87. height: 35px;
  88. margin-left: 275px;
  89. margin-top: -35px;
  90. display: flex;
  91. "
  92. @click="upCLick(1)"
  93. >
  94. 点击上传附件</el-button
  95. >
  96. </el-upload>
  97. </el-form-item>
  98. </div>
  99. </el-form>
  100. </div>
  101. <!-- 模态框 -->
  102. <el-drawer
  103. :visible.sync="drawer"
  104. :direction="direction"
  105. :before-close="handleClose"
  106. size="50%"
  107. >
  108. <el-input
  109. placeholder="请输入内容"
  110. v-model="input"
  111. style="margin-top: 10px; margin-left: 20px; width: 250px"
  112. clearable
  113. >
  114. </el-input>
  115. <el-button
  116. type="primary"
  117. class="btn"
  118. @click="onclick(a)"
  119. style="margin-bottom: 15px"
  120. >
  121. <i class="el-icon-search"></i>查询
  122. </el-button>
  123. <div v-show="a == 5">
  124. <dilTable
  125. v-bind.sync="batchOption"
  126. @radio-change="batchChange"
  127. ></dilTable>
  128. </div>
  129. <div v-show="a == 6">
  130. <dilTable
  131. v-bind.sync="contractPriceOption"
  132. @radio-change="priceChange"
  133. ></dilTable>
  134. </div>
  135. </el-drawer>
  136. <!-- 底部按钮 -->
  137. <div class="button-box">
  138. <el-button @click="cancel">取消</el-button>
  139. <el-button type="primary" @click="makeSure" :loading="isLoading"
  140. >确定</el-button
  141. >
  142. </div>
  143. </div>
  144. </template>
  145. <script>
  146. import PageTitle from "@/components/Page/Title";
  147. import { sjTime } from "@/utils/sharedJsFile";
  148. import { getCookie } from "@/utils/util.js";
  149. import { BigNumber } from "bignumber.js";
  150. export default {
  151. components: { PageTitle },
  152. data() {
  153. return {
  154. indexNum: null,
  155. form: {},
  156. portId: null,
  157. ports: [],
  158. isLoading: false,
  159. drawer: false,
  160. direction: "rtl",
  161. a: 0,
  162. input: null,
  163. batchId: null,
  164. purchaseOrderId: null,
  165. batchName: null,
  166. cargoPictureUrl: "",
  167. batchOption: {
  168. requestUrl: "/api/v1/uc/findBatchHavingLoad?apiId=502",
  169. selectionType: "radio",
  170. map: []
  171. },
  172. contractPriceOption: {
  173. requestUrl: "/api/v1/rms/selectbmsshipContractPriceList?apiId=500",
  174. selectionType: "radio",
  175. map: []
  176. }
  177. };
  178. },
  179. mounted() {
  180. //this.getPorts();
  181. this.information();
  182. },
  183. computed: {
  184. batch() {
  185. return this.batchId;
  186. }
  187. },
  188. watch: {
  189. batch() {
  190. console.log("无变化l");
  191. this.findLoadByBatch();
  192. }
  193. },
  194. methods: {
  195. information() {
  196. //编辑车皮装车作业
  197. this.axios
  198. .post(
  199. "/api/v1/bms/getBmsshipFee/" + this.$route.params.resultId
  200. )
  201. .then((res) => {
  202. res.data.data.forEach((e) => {
  203. console.log(e);
  204. this.form = e;
  205. this.batchName=e.batchName;
  206. this.batchId=e.batchId;
  207. this.purchaseOrderId=e.purchaseOrderId;
  208. });
  209. }).then(()=>{
  210. this.findLoadByBatch();
  211. });
  212. },
  213. findLoadByBatch() {
  214. if (this.batchId != null) {
  215. this.axios
  216. .post("/api/v1/bms/findLoadByBatch/" + this.batchId)
  217. .then(res => {
  218. console.log(res.data.data);
  219. this.$set(this.form, "Array", res.data.data);
  220. // this.form.Array = res.data.data;
  221. });
  222. }else{
  223. console.log("尚未选择批次");
  224. }
  225. },
  226. //右侧选中框
  227. ondrawer(num, index) {
  228. if (num == 5) {
  229. this.batchOption.requestUrl =
  230. "/api/v1/uc/findBatchHavingLoad?apiId=502" + "&i=" + new Date();
  231. } else if (num == 6) {
  232. this.contractPriceOption.requestUrl =
  233. "/api/v1/rms/selectbmsshipContractPriceList?apiId=500" +
  234. "&i=" +
  235. new Date();
  236. }
  237. this.drawer = true;
  238. this.indexNum = index;
  239. this.a = num;
  240. // 清空当前输入框中的数据
  241. this.input = "";
  242. },
  243. handleClose(done) {
  244. done();
  245. },
  246. onclick(a) {
  247. if (a == 5) {
  248. this.batchOption.requestUrl =
  249. "/api/v1/uc/findBatchHavingLoad?apiId=502&index=" +
  250. this.input +
  251. "&i=" +
  252. new Date();
  253. } else if (a == 6) {
  254. this.contractPriceOption.requestUrl =
  255. "/api/v1/rms/selectbmsshipContractPriceList?apiId=500&con=" +
  256. this.input;
  257. }
  258. },
  259. //修改选中
  260. batchChange(selection) {
  261. console.log(JSON.stringify(selection).length);
  262. if (JSON.stringify(selection).length > 2) {
  263. this.batchId = selection.batchId;
  264. this.purchaseOrderId = selection.purchaseOrderId;
  265. this.batchName =
  266. selection.materialName + selection.resultForeignShipName;
  267. } else {
  268. this.batchId = null;
  269. this.purchaseOrderId = null;
  270. this.batchName = "";
  271. }
  272. },
  273. priceChange(selection) {
  274. this.form.Array[this.indexNum].unitPriceId = selection.resultId;
  275. this.form.Array[this.indexNum].unitPrice = selection.unitPrice;
  276. // this.form.unitPriceId = selection.resultId;
  277. // this.form.unitPrice = selection.unitPrice;
  278. this.calculate();
  279. },
  280. //计算水运费
  281. calculate() {
  282. if (
  283. this.form.Array[this.indexNum].resultActualInstallations &&
  284. this.form.Array[this.indexNum].unitPrice
  285. ) {
  286. let fee = new BigNumber(
  287. this.form.Array[this.indexNum].resultActualInstallations
  288. );
  289. this.$set(
  290. this.form.Array[this.indexNum],
  291. "fee",
  292. fee.multipliedBy(this.form.Array[this.indexNum].unitPrice).toNumber()
  293. );
  294. }
  295. },
  296. makeSure() {
  297. let totalFee = this.form.Array.reduce(function(prev, item) {
  298. return prev + item.fee;
  299. }, 0);
  300. let realTonnage = this.form.Array.reduce(function(prev, item) {
  301. return prev + item.resultActualInstallations;
  302. }, 0);
  303. //this.isLoading=true;
  304. let map = {
  305. resultId:this.$route.params.resultId,
  306. batchId: this.batchId,
  307. purchaseOrderId: this.purchaseOrderId,
  308. realTonnage: realTonnage,
  309. mapList: this.form.Array,
  310. fee: totalFee,
  311. makeTime: sjTime(this.form.makeTime),
  312. image: this.form.image,
  313. feeType: 3,
  314. userId: getCookie("userId")
  315. };
  316. console.log(map);
  317. // if (
  318. // map.batchId == null ||
  319. // map.purchaseOrderId == null ||
  320. // map.unitPrice == null ||
  321. // map.unitPriceId == null ||
  322. // map.realTonnage == null ||
  323. // map.fee == null ||
  324. // map.makeTime == null ||
  325. // map.image == null ||
  326. // map.image == ""
  327. // ) {
  328. // this.$message.error("存在空值!");
  329. // this.isLoading = false;
  330. // } else {
  331. this.axios
  332. .post("/api/v1/bms/updatePortHandlingFee", map)
  333. .then(res => {
  334. if (res.data.code == 0) {
  335. this.$message({
  336. type: "success",
  337. message: "修改成功!"
  338. });
  339. this.cancel();
  340. } else {
  341. this.$message.error(res.data.data);
  342. }
  343. })
  344. .then(() => {
  345. this.isLoading = false;
  346. });
  347. // }
  348. },
  349. // 取消
  350. cancel() {
  351. this.$router.go(-1);
  352. },
  353. //查询港口id
  354. getPorts() {
  355. this.axios.post("/api/v1/rms/getPortName?index=").then(res => {
  356. if (res.data.code == 200) {
  357. this.ports = res.data.data;
  358. console.log(this.ports);
  359. } else {
  360. this.$message.error(res.data.data);
  361. }
  362. });
  363. },
  364. beforeUpload(file) {
  365. this.upBool = true;
  366. const isLt2M = file.size < 1024 * 1024 * 0.5;
  367. if (!isLt2M) {
  368. this.$message.error("上传文件大小不能超过500kb!");
  369. } else {
  370. let size = file.size / 1024;
  371. let _URL = window.URL || window.webkitURL;
  372. let img = new Image();
  373. img.src = _URL.createObjectURL(file);
  374. }
  375. return isLt2M;
  376. },
  377. onError(err) {
  378. if (this.upBool) {
  379. if (this.num == 1) {
  380. this.form.image = null;
  381. this.$message.error("上传失败");
  382. }
  383. }
  384. },
  385. handleAvatarSuccess(res, file) {
  386. if (res.code) {
  387. this.upBool = false;
  388. if (this.num == 1) {
  389. this.form.image = res.data;
  390. }
  391. this.$message.success("上传成功");
  392. }
  393. },
  394. upCLick(val) {
  395. this.num = val;
  396. }
  397. }
  398. };
  399. </script>
  400. <style lang="scss">
  401. .searchSelect {
  402. display: flex;
  403. align-items: center;
  404. justify-content: center;
  405. margin: 5px;
  406. .text {
  407. width: 40px;
  408. }
  409. .input {
  410. width: 200px;
  411. }
  412. .button {
  413. margin-left: 6px;
  414. }
  415. }
  416. .button-box {
  417. display: flex;
  418. justify-content: center;
  419. margin: 20px;
  420. .el-button {
  421. width: 80px;
  422. margin: 10px;
  423. }
  424. }
  425. .material {
  426. display: flex;
  427. justify-content: center;
  428. margin-top: 20px;
  429. margin-right: 100px;
  430. .text {
  431. display: inline-block;
  432. width: 170px;
  433. text-align: right;
  434. }
  435. .el-input {
  436. width: 250px;
  437. }
  438. }
  439. .form-box {
  440. display: flex;
  441. justify-content: center;
  442. .el-form-item {
  443. display: flex;
  444. justify-content: center;
  445. .el-form-item__label {
  446. display: flex;
  447. align-items: center;
  448. }
  449. .el-form-item__content {
  450. .el-input {
  451. .el-input__inner {
  452. width: 250px;
  453. }
  454. }
  455. }
  456. }
  457. }
  458. </style>