123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <template>
- <!-- 新增装船作业 -->
- <div class="shipTransport">
- <page-title>返回</page-title>
- <!-- 第一部分 -->
- <div class="top">
- <el-input placeholder="请输入内容" v-model="input" clearable> </el-input>
- <el-button type="primary" class="btn" @click="onclick()">
- <i class="el-icon-search"></i>查询
- </el-button>
- </div>
- <dilTable v-bind.sync="option" @radio-change="currentRadioChange">
- </dilTable>
- <div class="form">
- <div class="form_box">
- <dil-form :formId="120" v-model="form"></dil-form>
- <!-- <el-form :inline="true">
- <el-form-item>
- <label class="el-form-item__label" style="width: auto;margin: left 2px;"
- >含水率</label
- >
- </el-form-item>
- <el-form-item>
- <el-input placeholder="" v-model="resultMoistureContent"></el-input>
- </el-form-item>
- <el-form-item>
- <label class="el-form-item__label" style="width: auto"
- >合同水分值</label
- >
- </el-form-item>
- <el-form-item>
- <el-input
- placeholder=""
- v-model="contractMoistureValue"
- :disabled="true"
- ></el-input>
- </el-form-item>
- <el-form-item>
- <label class="el-form-item__label" style="width: auto"
- >水分吨位</label
- >
- </el-form-item>
- <el-form-item>
- <el-input
- placeholder=""
- v-model="moistureTonnage"
- :disabled="true"
- ></el-input>
- </el-form-item>
- </el-form> -->
- </div>
- </div>
- <div class="button_box_addLoadShip">
- <el-button type="primary" @click="makeSure">新增装船作业</el-button>
- </div>
- </div>
- </template>
- <script>
- import PageTitle from "@/components/Page/Title";
- import { sjTime } from "@/utils/sharedJsFile";
- import { getCookie } from "@/utils/util.js";
- export default {
- components: { PageTitle },
- data() {
- return {
- input: "",
- resultMoistureContent:"",
- moistureTonnage:"",
- contractMoistureValue:"",
- batchInfactoryId:"",
- restaurants: [],
- state: "",
- form: {
- waterUnitPrice:null,
- },
- option: {
- // 表格请求数据的地址
- requestUrl: "/api/v1/tms/getCapacityList?apiId=138",
- // 控制显示当选列
- selectionType: "radio",
- },
- rowMap: {},
- unitPrices:[]
- };
- },
- mounted() {
- this.getUnitPrice();
- },
- watch: {
- resultMoistureContent() {
- this.pipeiContarct();
- },
- batchId() {
- this.pipeiContarct();
- },
- "form.resultOutWharyTime":{
- handler(newVal,oldVal){
- this.findUnitPrice();
- },
- deep: true,
- immediate: true
- }
- },
- methods: {
- getUnitPrice(){
- this.axios
- .post("/api/v1/rms/selectbmsshipContractPriceList?apiId=500")
- .then((res) => {
- this.unitPrices=res.data.data.list;
- });
- },
- findUnitPrice(){
- if(this.rowMap && this.form.resultOutWharyTime){
- let contract=this.unitPrices.find(item=>
- item.portId==this.rowMap.startPortId
- && sjTime(this.form.resultOutWharyTime)>=sjTime(item.startTime)
- && sjTime(this.form.resultOutWharyTime)<=sjTime(item.endTime));
- if(contract){
- this.form.waterUnitPrice=contract.unitPrice;
- this.form.unitPriceId=contract.resultId;
- console.log("contract:",contract);
- }
- }
- },
- currentRadioChange(row) {
- this.rowMap = row;
- this.batchInfactoryId=this.rowMap.batchInfactoryId;
- this.findUnitPrice();
- },
- pipeiContarct() {
- if (
- this.resultMoistureContent != null &&
- this.resultMoistureContent != ""
- ) {
- let map = {
- batchInfactoryId: this.batchInfactoryId,
- resultMoistureContent: this.resultMoistureContent,
- resultActualInstallations:this.form.resultActualInstallations,
- };
- this.axios
- .post("/api/v1/tms/getMoistureAndInstallations", map)
- .then(res => {
- if (res.data.code == 200) {
- console.log("res" +res.data.data.purchaseContractMoisture);
- this.contractMoistureValue =
- res.data.data.purchaseContractMoisture;
- this.moistureTonnage = res.data.data.resultWaterTonnage;
- } else {
- this.$message.warning(res.data.data);
- }
- });
- }
- },
- // 新增
- makeSure() {
- if (JSON.stringify(this.rowMap).length == 2) {
- this.$message.error("未选择江船");
- return;
- }
- let mapVal = {
- resultActualInstallations: this.form.resultActualInstallations,
- resultLoadShipDate: sjTime(this.form.resultLoadShipDate),
- resultIsClear: this.form.resultIsClear,
- resultArrivalTime: sjTime(this.form.resultArrivalTime),
- resultOutWharyName: this.form.resultOutWharyName,
- resultOutWharyTime: sjTime(this.form.resultOutWharyTime),
- resultMemo: this.form.resultMemo,
- //resultPlannedDate: sjTime(this.form.planDate),
- //expectNoticeDate: sjTime(this.form.expectNoticeDate),
- resultEmptyHeavyWaterMeter: this.form.resultEmptyHeavyWaterMeter,
- resultMoistureContent: this.resultMoistureContent,
- //resultInspectionFees: this.form.resultInspectionFees,
- contractMoistureValue: this.contractMoistureValue,
- moistureTonnage: this.moistureTonnage,
- waterUnitPrice:this.form.waterUnitPrice,
- unitPriceId:this.form.unitPriceId,
- //isNeedAssemble:this.form.isNeedAssemble,
- userId: getCookie("userId"),
- };
- console.log("mapVal:",mapVal);
- //判断放货数量是否为数字
- function isNumber() {
- var value = mapVal.resultActualInstallations;
- //验证是否为数字
- var patrn = /^(-)?\d+(\.\d+)?$/;
- if (patrn.exec(value) == null || value == "") {
- return false;
- } else {
- return true;
- }
- }
- var val = this.value;
- if (
- mapVal.resultActualInstallations == null ||
- mapVal.resultLoadShipDate == null ||
- mapVal.resultIsClear == null ||
- mapVal.resultArrivalTime == null ||
- mapVal.resultOutWharyName == null ||
- mapVal.resultOutWharyTime == null
- )
- this.$message.error("存在空值!");
- else if (!isNumber(val)) this.$message.warning("实装数量必须为数字!");
- else
- this.axios
- .post("/api/v1/tms/addLoadShip", {
- mapVal: mapVal,
- rowMap: this.rowMap,
- })
- .then((res) => {
- if (res.data.code == 200) {
- this.$message({
- type: "success",
- message: "新增成功!",
- });
- this.$router.go(-1);
- } else if (res.data.code == 201) {
- this.$message.warning(res.data.data);
- } else {
- this.$message.error("新增失败!");
- }
- this.$refs["table"].resetField();
- });
- // if (
- // mapVal.resultActualInstallations == null ||
- // // mapVal.portId==null||
- // mapVal.resultLoadShipDate == null ||
- // mapVal.resultIsClear == null ||
- // mapVal.resultPortDeclarationTime == null ||
- // mapVal.resultPortDeclarationName == null ||
- // mapVal.resultArrivalTime == null ||
- // mapVal.resultOutWharyName == null ||
- // mapVal.resultOutWharyTime == null
- // )
- // this.$message.error("存在空值!");
- // else if (!isNumber(val)) this.$message.warning("实装数量必须为数字!");
- // else
- },
- handleSelect(item) {
- console.log(item);
- },
- onclick() {
- this.option.requestUrl =
- "/api/v1/tms/getCapacityList?apiId=138&con=" + this.input;
- },
- },
- };
- </script>
- <style lang="scss">
- .shipTransport {
- .form {
- display: flex;
- .form_box {
- width: 320px;
- margin-left: 35%;
- margin-top: 30px;
- margin-right: 20px;
- .el-form {
- .preview-group {
- .el-form-item {
- .el-form-item__label {
- display: inline-block;
- width: 70px !important;
- }
- .el-form-item__content {
- .el-select {
- width: 250px;
- }
- .el-input {
- width: 250px;
- }
- }
- }
- }
- }
- }
- }
- .top {
- padding: 1.25rem 0.375rem;
- .el-input {
- width: 20%;
- margin-right: 1.25rem;
- }
- }
- .button_box_addLoadShip {
- margin-left: 45%;
- }
- }
- </style>
|