ShipmentPlanHeaderList.vue 11.2 KB
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="计划状态">
              <j-multi-select-tag placeholder="请选择计划状态" v-model="queryParam.statusStr" dictCode="shipment_plan_status">
              </j-multi-select-tag>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="机台号或名称">
              <j-input placeholder="请输入机台号或名称" v-model="queryParam.stationCode"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="工单号">
              <j-input placeholder="请输入工单号" v-model="queryParam.orderCode"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="物料编码">
              <j-input placeholder="请输入物料编码" v-model="queryParam.materialCode"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button v-has="'plan:add'" @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button v-has="'plan:startWork'" @click="startWork" type="danger" icon="play-circle">开工</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('生产计划头表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        class="j-table-force-nowrap"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowClassName="rowClassName"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'checkbox'}"
        @change="handleTableChange">

        <span slot="status" slot-scope="status">
          <a-tag :key="status" :color="getStatusColor(status)">
            {{ status }}
          </a-tag>
        </span>

        <span slot="action" slot-scope="text, record">
            <a-popconfirm v-has="'plan:stopRestore'" v-if="record.status === 2" title="确定暂停吗?" @confirm="() => stop(record)">
              <a>暂停<a-divider type="vertical"/></a>
            </a-popconfirm>
            <a-popconfirm v-has="'plan:stopRestore'" v-if="record.status === 3" title="确定恢复吗?" @confirm="() => restore(record)">
              <a>恢复<a-divider type="vertical"/></a>
            </a-popconfirm>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm>
        </span>

      </a-table>
    </div>

    <shipment-plan-header-modal ref="modalForm" @ok="modalFormOk"></shipment-plan-header-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import ShipmentPlanHeaderModal from '@views/system/shipment/modules/ShipmentPlanHeaderModal'
import ShipmentPlanDetailList from "./ShipmentPlanDetailList";
import {postAction} from "@/api/manage";

export default {
  name: 'ShipmentPlanHeaderList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    ShipmentPlanDetailList,
    ShipmentPlanHeaderModal
  },
  data() {
    return {
      description: '生产计划头表管理页面',
      // 表头
      columns: [
        {
          title: '生产计划头ID',
          dataIndex: 'id',
          key: 'id',
          width: 60,
          align: "center"
        },
        {
          title: '机台区域',
          align: "center",
          dataIndex: 'area'
        },
        {
          title: '机台号',
          align: "center",
          dataIndex: 'stationCode'
        },
        {
          title: '机台名称',
          align: "center",
          dataIndex: 'stationName'
        },
        /*{
          title: '工单号',
          align: "center",
          dataIndex: 'orderCode'
        },*/
        {
          title: '物料编码',
          align: "center",
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
          align: "center",
          dataIndex: 'materialName'
        },
        {
          title: '计划出库数量',
          align: "center",
          dataIndex: 'planQty'
        },
        {
          title: '卸料数量',
          align: "center",
          dataIndex: 'pickQty'
        },
        {
          title: '实际送达数量',
          align: "center",
          dataIndex: 'shipmentQty'
        },
        {
          title: '库存托数(良品)',
          align: "center",
          dataIndex: 'inventoryCount',
          customCell: (record, rowIndex) => {
            let color = record.inventoryCount === 0 ? '#ffadd2' : record.inventoryCount > 0 && record.inventoryCount <= 5 ? '#ffbb92' : ''
            return {
              style: {
                'background-color': color
              }
            }
          }
        },
        {
          title: '库存支数(良品)',
          align: "center",
          dataIndex: 'inventoryQty',
          customCell: (record, rowIndex) => {
            let color = record.inventoryCount === 0 ? '#ffadd2' : record.inventoryCount > 0 && record.inventoryCount <= 5 ? '#ffbb92' : ''
            return {
              style: {
                'background-color': color
              }
            }
          }
        },
        {
          title: '状态',
          align: "center",
          dataIndex: 'status_dictText',
          key: "status_dictText",
          scopedSlots: {customRender: 'status'},
          sorter: true,
          defaultSortOrder: 'ascend'
        },
        {
          title: '创建时间',
          align: "center",
          dataIndex: 'createTime',
        },
        {
          title: '更新时间',
          align: "center",
          dataIndex: 'updateTime',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: {customRender: 'action'}
        }
      ],
      ipagination: {
        current: 1,
        pageSize: 20,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      url: {
        list: "/shipmentPlan/shipmentPlanHeader/list",
        delete: "/shipmentPlan/shipmentPlanHeader/delete",
        deleteBatch: "/shipmentPlan/shipmentPlanHeader/deleteBatch",
        exportXlsUrl: "/shipmentPlan/shipmentPlanHeader/exportXls",
        importExcelUrl: "shipmentPlan/shipmentPlanHeader/importExcel",
        startWork: "shipmentPlan/shipmentPlanHeader/startWork",
        stop: "shipmentPlan/shipmentPlanHeader/stop",
        restore: "shipmentPlan/shipmentPlanHeader/restore",
      },
      queryParam: {
        statusStr: '1,2,3'
      }
    }
  },
  created() {
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    startWork() {
      if (this.selectionRows.length <= 0) {
        this.$message.warning('请选择一条记录!');
      } else {
        let that = this;
        that.loading = true;
        let params = this.selectionRows.map(x => {
          return {workOrder: x.workOrder, stationCode: x.stationCode}
        })
        postAction(that.url.startWork, params).then((res) => {
          if (res.success) {
            that.$message.success(res.message);
            that.loadData();
            that.onClearSelected();
          } else {
            that.$message.warning(res.message);
          }
        }).finally(() => {
          that.loading = false;
        });
      }
    },
    stop(record) {
      let that = this;
      let params = {id: record.id};
      postAction(this.url.stop, params).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      }).finally(() => {
        that.loading = false;
      });
    },
    restore(record) {
      let that = this;
      let params = {id: record.id};
      postAction(this.url.restore, params).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      }).finally(() => {
        that.loading = false;
      });
    },
    rowClassName(record, index) {
      //return record.inventoryCount === 0 ? 'table-striped-red' : record.inventoryCount > 0 && record.inventoryCount <= 5 ? 'table-striped-yello' : ''
    },
    getStatusColor(value) {
      const colors = {
        '新建': 'green',
        '开工': 'blue',
        '暂停': 'orange',
        '完成': 'purple',
        '删除': 'red',
        default: '1'
      };
      return colors[value] || colors.default;
    },
    searchReset() {
      this.queryParam = {
        statusStr: '1,2,3'
      }
      this.loadData(1);
    },
  }
}
</script>
<style>
.j-table-force-nowrap .table-striped-yello {
  background-color: #ffbb96;
}

.j-table-force-nowrap .table-striped-red {
  background-color: #ffadd2;
}
</style>
<style scoped>
@import '~@assets/less/common.less';
</style>