index.vue 18.7 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 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
<template>
  <div class="app-container">
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane label="主表" name="first">
        <el-form :model="queryHeaderParams" ref="queryHeaderForm" :inline="true" v-show="showHeaderSearch">
          <el-form-item label="容器编码" prop="containerCode">
            <el-input
              v-model="queryHeaderParams.containerCode"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="headerQuery"
            />
          </el-form-item>
          <el-form-item label="库位编码" prop="locationCode">
            <el-input
              v-model="queryHeaderParams.locationCode"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="headerQuery"
            />
          </el-form-item>
          <el-form-item label="任务类型" prop="taskType">
            <el-select v-model="queryHeaderParams.taskType" placeholder="所有" clearable size="small">
              <el-option
                v-for="dict in taskOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="容器任务状态" prop="status">
            <el-select v-model="queryHeaderParams.status" placeholder="所有" clearable size="small">
              <el-option
                v-for="dict in statusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="创建人" prop="createdBy">
            <el-input
              v-model="queryHeaderParams.createdBy"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="headerQuery"
            />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-date-picker
              v-model="dateRange"
              size="small"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="cyan" icon="el-icon-search" size="small" @click="headerQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="small" @click="resetHeaderQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="mini"
              :disabled="headerMultiple"
              @click="buildTask"
              v-hasPermi="['shipment:container:add']"
            >批量生成任务</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              :disabled="headerMultiple"
              @click="headerDelete"
              v-hasPermi="['shipment:container:remove']"
            >批量撤销组盘</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showHeaderSearch" @queryTable="getHeaderList" :col-data="colData" @selectData="selectData"></right-toolbar>
        </el-row>

        <el-table v-loading="headerLoading" :data="HeaderList" @selection-change="headerSelectionChange" highlight-current-row ref="table">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="组盘头id" align="center" prop="id" width="95" v-if="colData[0].istrue" />
          <el-table-column label="库位编号" align="center" prop="locationCode" width="150" sortable v-if="colData[1].istrue" />
          <el-table-column label="容器编号" align="center" prop="containerCode" width="150" sortable v-if="colData[2].istrue"/>
          <el-table-column label="仓库id" align="center" prop="warehouseId" width="150" v-if="colData[3].istrue"/>
          <el-table-column label="仓库编号" align="center" prop="warehouseCode" width="150" v-if="colData[4].istrue"/>
          <el-table-column label="出库站台" align="center" prop="stationCode" v-if="colData[5].istrue" :show-overflow-tooltip="true" />
          <el-table-column label="容器任务状态" align="center" prop="status" sortable v-if="colData[6].istrue" width="150" >
            <template slot-scope="scope">
              <el-button size="mini" type="success" round>{{
                statusFormat(scope.row, scope.column)
                }}</el-button>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" align="center" width="180" prop="created" sortable v-if="colData[7].istrue">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.created) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="创建人" align="center" width="150" prop="createdBy" sortable v-if="colData[8].istrue" :show-overflow-tooltip="true" />
          <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" v-if="colData[9].istrue">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-my-detail"
                @click="handleDetail(scope.row)"
                v-hasPermi="['shipment:container:edit']"
              >明细</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                v-if="scope.row.status == '0'"
                @click="buildTask(scope.row)"
                v-hasPermi="['shipment:container:add']"
              >生成任务</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                v-if="scope.row.status == '0'"
                @click="headerDelete(scope.row)"
                v-hasPermi="['shipment:container:remove']"
              >取消配盘</el-button>

            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="headerTotal > 0"
          :total="headerTotal"
          :page.sync="queryHeaderParams.pageNum"
          :limit.sync="queryHeaderParams.pageSize"
          @pagination="getHeaderList"
        />
      </el-tab-pane>
      <el-tab-pane label="明细" name="second" v-if="queryDetailParams.shippingContainerId !== undefined">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              :disabled="detailMultiple"
              @click="detailDelete"
              v-hasPermi="['shipment:container:remove']"
            >删除</el-button>
          </el-col>
          <!--<el-col :span="1.5">
            <el-button
              type="warning"
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['shipment:container:export']"
            >导出</el-button>
          </el-col>-->
          <right-toolbar @queryTable="getDetailList" :col-data="colDataDetail" @selectData="selectDataDetail" :no-search="noSearch"></right-toolbar>
        </el-row>

        <el-table v-loading="detailLoading" :data="DetailList" @selection-change="detailSelectionChange" ref="table">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="明细id" align="center" prop="shipmentDetailId" sortable  v-if="colDataDetail[0].istrue" />
          <el-table-column label="出库单号" align="center" prop="shipmentCode" v-if="colDataDetail[1].istrue"/>
          <el-table-column label="物料编码" align="center" prop="materialCode" v-if="colDataDetail[2].istrue" />
          <el-table-column label="物料名称" align="center" prop="materialName" v-if="colDataDetail[3].istrue" :show-overflow-tooltip="true" />
          <el-table-column label="项目号" align="center" prop="project" v-if="colDataDetail[4].istrue" />
          <el-table-column label="组盘数量" align="center" prop="qty" v-if="colDataDetail[5].istrue" />
          <el-table-column label="创建时间" align="center" prop="created" sortable width="180" v-if="colDataDetail[6].istrue">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.created) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="创建用户" align="center" prop="createdBy" v-if="colDataDetail[7].istrue" />
          <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" v-if="colDataDetail[8].istrue">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                v-if="scope.row.status == '0'"
                @click="detailDelete(scope.row)"
                v-hasPermi="['shipment:container:remove']"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="detailTotal > 0"
          :total="detailTotal"
          :page.sync="queryDetailParams.pageNum"
          :limit.sync="queryDetailParams.pageSize"
          @pagination="getDetailList"
        />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
  import {listHeader,addHeader,getHeader,updateHeader,delHeader,createTask,} from "@/api/shipment/shipmentContainerHeader/header";
  import {listDetail,addDetail,getDetail,updateDetail,delDetail,exportSch} from "@/api/shipment/shipmentContainerHeader/detail";
  export default {
    name: "ShipmentContainerHeader",
    data() {
      return {
        // 主表遮罩层
        headerLoading: true,
        // 主表选中数组
        headerIds: [],
        //隐藏表格中的ID
        showId:false,
        // 主表非单个禁用
        headerSingle: true,
        // 主表非多个禁用
        headerMultiple: true,
        // 主表显示搜索条件
        showHeaderSearch: true,
        // 主表总条数
        headerTotal: 0,
        // 主表表格数据
        HeaderList: [],
        // 主表弹出层标题
        headerTitle: "",
        // 主表是否显示弹出层
        headerOpen: false,
        // 主表数据字典
        taskOptions: [],
        statusOptions: [],
        // 创建时间
        dateRange: [],
        // 主表查询参数
        queryHeaderParams: {
          pageNum: 1,
          pageSize: 10,
          containerCode: undefined,
          locationCode: undefined,
          taskType: undefined,
          status: undefined,
          createdBy: undefined,
        },
        // 主表表单参数
        headerForm: {},
        // 主表表单校验
        headerRules: {},
        // 明细遮罩层
        detailLoading: true,
        // 明细选中数组
        detailIds: [],
        // 明细非单个禁用
        detailSingle: true,
        // 明细非多个禁用
        detailMultiple: true,
        // 明细显示搜索条件
        showDetailSearch: true,
        // 明细总条数
        detailTotal: 0,
        // 明细表格数据
        DetailList: [],
        // 明细弹出层标题
        detailTitle: "",
        // 明细是否显示弹出层
        detailOpen: false,

        // 明细查询参数
        queryDetailParams: {
          shipmentDetailId:undefined,
          pageNum: 1,
          pageSize: 10,
        },
        // 明细表单参数
        detailForm: {},
        // 明细表单校验
        detailRules: {},
        activeName: "first",
        shippingContainerId:'',
        noSearch:false,
        colData: [
          { title: "组盘头id", istrue: false },
          { title: "库位编号", istrue: true },
          { title: "容器编号", istrue: true },
          { title: "仓库id", istrue: false },
          { title: "仓库编号", istrue: false },
          { title: "出库站台", istrue: true },
          { title: "容器任务状态", istrue: true },
          { title: "创建日期", istrue: true },
          { title: "创建人", istrue: true },
          { title: "操作", istrue: true, disabled: true },
        ],
        colDataDetail: [
          { title: "明细id", istrue: false },
          { title: "出库单号", istrue: true },
          { title: "物料编码", istrue: true },
          { title: "物料名称", istrue: true },
          { title: "项目号", istrue: true },
          { title: "组盘数量", istrue: true },
          { title: "创建时间", istrue: true },
          { title: "创建用户", istrue: true },
          { title: "操作", istrue: true, disabled: true },
        ],
      };
    },
    created() {
      this.getHeaderList();
      this.getDicts("taskType").then((response) => {
        this.taskOptions = response.data;
      });
      this.getDicts("shipmentContainerHeaderStatus").then(response => {
        this.statusOptions = response.data;
      });

    },


    beforeUpdate() {
      this.$nextTick(() => {
        this.$refs["table"].doLayout();
      });
    },

    methods: {
      /** 查询主表列表 */
      getHeaderList() {
        this.headerLoading = true;
        listHeader(
          this.addDateRange(this.queryHeaderParams, this.dateRange)
        )
          .then((response) => {
            this.HeaderList = response.rows;
            this.headerTotal = response.total;
            this.headerLoading = false;
          });
      },

      // 主表字典翻译(任务类型、容器任务状态)
      taskFormat(row, column){
        return this.selectDictLabel(this.taskOptions, row.taskType);
      },
      statusFormat(row, column) {
        return this.selectDictLabel(this.statusOptions, row.status);
      },


      // 主表取消按钮
      headerCancel() {
        this.headerOpen = false;
        this.headerReset();
      },

      /** 主表搜索按钮操作 */
      headerQuery() {
        this.queryHeaderParams.pageNum = 1;
        this.getHeaderList();
      },
      /** 主表重置按钮操作 */
      resetHeaderQuery() {
        this.dateRange = [];
        this.resetForm("queryHeaderForm");
        this.getHeaderList();
      },

      /** 主表多选框选中数据 */
      headerSelectionChange(selection) {
        this.headerIds = selection.map((item) => item.id);
        this.locationCode = selection.map((item) => item.locationCode);
        this.headerSingle = selection.length != 1;
        this.headerMultiple = !selection.length;
      },

      /** 主表撤销阻盘按钮操作 */
      headerDelete(row) {
        const headerIds = row.id || this.headerIds;
        this.$confirm(
          row.id?'是否确认撤销该条组盘信息吗?':'是否确认撤销选中的' + this.headerIds.length + '条数据项?',
          "警告",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        )
          .then(function() {
            return delHeader(headerIds);
          })
          .then(() => {
            this.getHeaderList();
            this.msgSuccess("撤销组盘成功");
          })
          .catch(function() {});
      },

      // 主表明细按钮操作
      handleDetail(row) {
        this.queryDetailParams.shippingContainerId = row.id
        this.id = row.id;
        this.activeName = 'second'
        this.detailLoading = true;

        listDetail({shippingContainerId:row.id}).then((response) => {
          this.DetailList = response.rows;
          this.detailTotal = response.total;
          this.detailLoading = false;
        });

        // this.getDetailList();
      },

      /** 查询明细列表 */
      getDetailList() {
        this.detailLoading = true;
        listDetail(this.queryDetailParams)
          .then((response) => {
          this.DetailList = response.rows;
          this.detailTotal = response.total;
          this.detailLoading = false;
        });
      },


      /** 明细多选框选中数据 */
      detailSelectionChange(selection) {
        this.detailIds = selection.map((item) => item.shipmentDetailId);
        this.shipmentCode = selection.map((item) => item.shipmentCode);
        this.detailSingle = selection.length != 1;
        this.detailMultiple = !selection.length;
      },

      /** 明细删除按钮操作 */
      detailDelete(row) {
        const detailIds = row.shipmentDetailId || this.detailIds.toString();
        this.$confirm(
          row.shipmentDetailId?'是否确认撤销该条组盘明细信息吗?':'是否确认撤销选中的' + this.detailIds.length + '条数据项?',
          "警告",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        )
          .then(function () {
            return delDetail(detailIds);
          })
          .then(() => {
            this.getDetailList();
            this.msgSuccess("删除成功");
          })
          .catch(function () {});
      },

      /** 明细导出按钮操作 */
      handleExport() {
        this.download('system/role/export', {
          ...this.queryDetailParams
        }, `shipmentContainerHeader_${new Date().getTime()}.xlsx`)
      },

      //生成任务
      buildTask(row)  {
        const headerId = row.id || this.headerIds;
        createTask(headerId).then(response => {
          if(response.code == 200) {
            this.msgSuccess(response.msg);
            this.getHeaderList();
          }
          else {
            this.msgError(response.msg)
          }
        })
      },

      /** 表格切换字段显示操作 */
      selectData(val) {
        if (val) {
          this.colData.filter((i) => {
            if (val.indexOf(i.title) !== -1) {
              i.istrue = true;
            } else {
              i.istrue = false;
            }
          });
        }
      },
      selectDataDetail(val) {
        if (val) {
          this.colDataDetail.filter((i) => {
            if (val.indexOf(i.title) !== -1) {
              i.istrue = true;
            } else {
              i.istrue = false;
            }
          });
        }
      },

    },
  };
</script>


<style lang="scss" scoped>
  .el-form-item {
    margin-bottom: 10px;
  }
  .el-form-item__error {
    position: relative;
  }
  .el-dialog__body {
    padding: 20px 50px;
  }
  /*.el-dialog__footer {
    padding: 10px 50px 20px;
  }*/
  .el-button--mini.is-round {
    padding: 5px 10px;
  }
</style>