index.vue 16.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
<template>
  <div>
    <el-form class="form-header" :model="queryParams" ref="queryForm" size="small" :inline="true" label-position="right"
      label-width="auto">
      <el-form-item label="原航班">
        <el-input type="text" v-model="sourceFlightNo" placeholder="请输入原航班" clearable></el-input>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择" clearable>
          <el-option v-for="dict in statusList" :key="dict.id" :label="dict.name" :value="dict.id" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" :loading="loading" @click="handleQuery">查询原航班配置
        </el-button>
      </el-form-item>
      <br />
      <el-form-item label="日期" prop="flightDate">
        <el-date-picker value-format="yyyy-MM-dd" v-model="queryParams.flightDate" type="date" placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="findSourceFlightAndFlightDate">查询实际配载航班
        </el-button>&#12288;
        <span style="color:#ff4949">注:原航班+日期查询该日期的航班实际情况</span>
      </el-form-item>
      <br />
      <el-form-item>
        <el-button type="primary" icon="el-icon-plus" size="mini" v-hasPermi="['allocation:rand:add']"
          @click="handleAdd">添加规则</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <Tables ref="newTables" ductName="flightRand" :data="sourceFlightRulesList" :headerData="tableHeaders['flightRand']"
      :order="true" :totalCount="total" :loading="loading" :limitSize="queryParams.limit"
      :limitStart="queryParams.start" :page="queryParams.pageNum" :pageSizes="[20]" :height="tableHeight"
      @currentChange="currentChange">
      <template slot="optionColumn">
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" v-hasPermi="['allocation:rand:update']"
              @click="handleUpdate(scope.row)">修改</el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" style="color:#ff4949"
              v-hasPermi="['allocation:rand:delete']" @click="handleDeleteorPlayorpause(scope.row, 0, '删除')">
              删除</el-button>
            <el-button size="mini" type="text" icon="el-icon-video-play" v-if="scope.row.status == '3'"
              v-hasPermi="['allocation:rand:openClose']" @click="handleDeleteorPlayorpause(scope.row, 1, '启用')">启用
            </el-button>
            <el-button size="mini" type="text" icon="el-icon-video-pause" v-if="scope.row.status != '3'"
              v-hasPermi="['allocation:rand:openClose']" @click="handleDeleteorPlayorpause(scope.row, 3, '停用')">停用
            </el-button>
          </template>
        </el-table-column>
      </template>
    </Tables>
    <!-- 查看目的航班对话框 -->
    <el-dialog title="实际配载航班" :visible.sync="openFlightDate" width="70%" :close-on-click-modal="false"
      :show-close="false" :append-to-body="true">
      <el-table v-loading="loadingFlightDate" :data="sourceFlightAndFlightDate">
        <el-table-column type="index" label="序号" align="center">
          <template slot-scope="scope">{{ scope.$index + 1 }}</template>
        </el-table-column>
        <el-table-column label="原航班" align="center" prop="sourceFlightNo" />
        <el-table-column label="实际配载航班" align="center" prop="actualFlight" width="280" />
        <el-table-column label="航班日期" align="center" prop="flightDate" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit"
              @click="handleClick(scope.row.actualFlight, 'detail')">查看配置维度</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelFlightDate">返 回</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="55%" :append-to-body="true" :close-on-click-modal="false"
      :show-close="false">
      <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="auto" size="small">
        <el-row>
          <el-col :span="8">
            <el-form-item label="原航班" prop="sourceFlightNo">
              <el-input v-model="form.sourceFlightNo" placeholder="请输入原航班号" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="口岸" prop="portName">
              <el-select :disabled="true" v-model="form.portName" placeholder="选择口岸">
                <el-option v-for="item in portNameList" :label="item" :value="item" :key="item">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="有效开始时间" prop="startDate">
              <el-date-picker clearable :picker-options="pickerOptionsStart" v-model="form.startDate" type="date"
                value-format="yyyy-MM-dd" placeholder="选择开始时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有效结束时间" prop="endDate">
              <el-date-picker clearable :picker-options="pickerOptionsEnd" v-model="form.endDate" type="date"
                value-format="yyyy-MM-dd" placeholder="选择结束时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24" style="margin-bottom: 5%">
            <span style="color: #ff4949; margin-left: 10%">提示:配载航班之间请用分号分隔【符号不区分中英文】,例:CA1053;C7433</span><br />
            <span
              style="color: #ff4949; margin-left: 10%">提示:如果需要设置配载航班延迟或提前可以直接在目的航斑后加减【+-】天数。如:CA1053+1;CZ433-1</span>
          </el-col>
          <el-col :span="24">
            <el-form-item label="配载航班" prop="flightRank">
              <el-input type="textarea" v-model="form.flightRank" :rows="4"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="周期段">
              <el-checkbox-group v-model="dayOfWeek">
                <el-row :gutter="10">
                  <el-col :span="2" v-for="item in dayOfWeekList" :key="item">
                    <el-checkbox :label="item" :name="item"></el-checkbox>
                  </el-col>
                </el-row>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  findSourceFlightRulesApi,
  sourceFlightRulesSaveApi,
  delOrEnableORDisableApi,
  findSourceFlightAndFlightDateApi,
} from "@/api/sourceFlightRules";
export default {
  name: "FlightRandConfig",
  data() {
    return {
      portNameList: [],
      // data 中设定
      pickerOptionsStart: {
        disabledDate: (time) => {
          let endDateVal = this.form.endDate;
          if (endDateVal) {
            return (
              time.getTime() > new Date(endDateVal).getTime() ||
              time.getTime() < new Date().getTime() - 24 * 60 * 60 * 1000
            );
          } else {
            return time.getTime() < new Date().getTime() - 24 * 60 * 60 * 1000;
          }
        },
      },
      pickerOptionsEnd: {
        disabledDate: (time) => {
          let beginDateVal = this.form.startDate;
          if (beginDateVal) {
            return time.getTime() < new Date(beginDateVal).getTime();
          } else {
            return time.getTime() < new Date().getTime() - 24 * 60 * 60 * 1000;
          }
        },
      },
      //周期段
      dayOfWeekList: ["D1", "D2", "D3", "D4", "D5", "D6", "D7"],
      // 遮罩层
      loading: false,
      // 遮罩层
      loadingFlightDate: false,
      // 弹出层标题
      title: "",
      // 总条数
      total: 0,
      //table高度
      tableHeight: null,
      // 原航班规则数据
      sourceFlightRulesList: [],
      //目的航班数据
      sourceFlightAndFlightDate: [],
      statusList: [
        {
          id: 1,
          name: "有效",
        },
        {
          id: 3,
          name: "停用",
        },
      ],
      // 新增修改查看规则弹出层
      open: false,
      // 是否显示查看目的航班弹出层
      openFlightDate: false,
      // 查询参数
      queryParams: {
        portName: undefined,
        start: 0, //当前条数【代表第几条数据 +1开始】
        pageNum: 1,
        limit: 20, //一页显示多少条数据
        sourceFlightNo: undefined, //原航班号
        status: undefined, //状态
        flightDate: undefined, //日期
      },
      dayOfWeek: [],
      // 表单参数
      form: {
        dayOfWeek: [],
      },
      // 表单校验
      rules: {
        sourceFlightNo: [
          {
            required: true,
            message: "ACCS原航班号不能为空",
            trigger: "blur",
          },
        ],
        flightRank: [
          {
            required: true,
            message: "配载航班不能为空",
            trigger: "blur",
          },
        ],
      },
    };
  },
  created() {
    this.queryParams.portName = this.$store.state.user.activePortName;
    this.portNameList = this.$store.state.user.portNames;
    if (this.$store.state.tagsView.cachedViews.length == 0) {
      this.findSourceFlightRules();
    }
  },
  mounted() {
    this.tableHeight = window.innerHeight - this.$refs.queryForm.$el.offsetHeight - 200
  },
  activated() {
    this.findSourceFlightRules();
  },
  deactivated() {
    this.sourceFlightRulesList = []
  },
  watch: {
    open(val, oldVal) {
      if (val) {
        this.queryParams.portName = this.$store.state.user.activePortName;
        this.form.portName = this.$store.state.user.activePortName;
      }
    }
  },
  methods: {
    //跳转到查看,修改页面
    handleClick(flightiId, handle) {
      this.openFlightDate = false;
      this.$router.push({
        name: "FlightAllocConfigInfo",
        params: {
          handle: handle,
          id: flightiId,
        },
      });
    },
    /** 查询原航班顺位规则*/
    findSourceFlightRules() {
      this.loading = true;
      if (this.queryParams.pageNum > 1) {
        this.queryParams.start =
          (this.queryParams.pageNum - 1) * this.queryParams.limit;
      } else {
        this.queryParams.start = 0;
      }
      findSourceFlightRulesApi(this.queryParams).then((response) => {
        this.loading = false;
        if (response.code == 200) {
          this.sourceFlightRulesList = response.data.list;
          this.total = response.data.totalCount;
        } else {
          this.msgError(response.msg);
        }
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.form = {};
      this.open = true;
      this.title = "添加原航班顺位规则";
      this.form.id = -1;
      this.dayOfWeek = [];
      this.form.portName = this.$store.state.user.activePortName;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.form = {};
      this.dayOfWeek = [];
      this.open = true;
      this.title = "修改原航班顺位规则";
      this.form = JSON.parse(JSON.stringify(row));
      this.dayOfWeek = this.form.dayOfWeek
        ? this.form.dayOfWeek.split(";")
        : [];
      //this.form.dayOfWeek = this.form.dayOfWeek ? this.form.dayOfWeek.split(";") : [];
    },
    /** 删除 启用 停用按钮操作 */
    handleDeleteorPlayorpause(row, status, statusText) {
      //删除前需要停用
      if (status === 0 && row.status != "3") {
        this.msgWarning('请停用后删除')
        return;
      }

      this.$confirm("是否确认" + statusText + "此数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let disable = {
            id: row.id,
            status: status,
          };

          return delOrEnableORDisableApi(disable);
        })
        .then((response) => {
          if (response.code == 200) {
            this.findSourceFlightRules();
            this.msgSuccess(statusText + "成功");
          } else {
            this.msgError(response.msg);
          }
        })
        .catch(() => { });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.form.dayOfWeek = this.dayOfWeek.sort();
          let formdata = JSON.parse(JSON.stringify(this.form));
          formdata.sourceFlightNo = formdata.sourceFlightNo.trim().toUpperCase();
          formdata.flightRank = formdata.flightRank.trim().toUpperCase();
          if (formdata.startDate === undefined || formdata.startDate == null) {
            formdata.startDate = "";
          }
          if (formdata.endDate === undefined || formdata.endDate == null) {
            formdata.endDate = "";
          }
          //处理数据
          sourceFlightRulesSaveApi(formdata).then((response) => {
            if (response.code === 200) {
              this.msgSuccess("保存成功");
              this.open = false;
              this.findSourceFlightRules();
            } else {
              this.msgError(response.msg);
            }
          });
        }
      });
    },
    // 表单重置
    reset() {
      this.form = {
        dayOfWeek: [],
      };
      this.resetForm("form");
    },
    /** 查询目的航班*/
    findSourceFlightAndFlightDate() {
      //校验原航班号非空
      if (
        this.queryParams.sourceFlightNo === null ||
        this.queryParams.sourceFlightNo === undefined ||
        this.queryParams.sourceFlightNo.trim() === ""
      ) {
        this.$message.warning("ACCS原航班号为空");
        return;
      }
      //校验原日期非空
      if (
        this.queryParams.flightDate === null ||
        this.queryParams.flightDate === undefined
      ) {
        this.$message.warning("日期为空");
        return;
      }
      this.openFlightDate = true;
      this.loadingFlightDate = true;
      this.sourceFlightAndFlightDate = [];
      findSourceFlightAndFlightDateApi(this.queryParams).then((response) => {
        if (response.code === 200) {
          this.sourceFlightAndFlightDate = response.data;
          this.loadingFlightDate = false;
        } else {
          this.msgError(response.msg);
        }
      });
    },
    // 目的航班弹出框返回
    cancelFlightDate() {
      this.openFlightDate = false;
      this.findSourceFlightRules();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.findSourceFlightRules();
      //this.reset();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.sourceFlightNo = undefined;
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.queryParams.start = 0;
      this.findSourceFlightRules();
    },
    //翻页
    currentChange(val) {
      this.queryParams.start = val.start;
      this.queryParams.pageNum = val.page;
      this.findSourceFlightRules();
    }
  },
  computed: {
    sourceFlightNo: {
      get: function () {
        return this.queryParams.sourceFlightNo;
      },
      set: function (val) {
        this.queryParams.sourceFlightNo = this.upCase(val);
      },
    },
  },
};
</script>
<style>
</style>