| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269 |
- <template>
- <div class="ele-body">
- <el-card v-loading="loading" shadow="never">
- <order-search ref="searchRef" @search="reload"></order-search>
- <div class="btn_box">
- <el-button
- class="ele-btn-icon"
- icon="el-icon-truck"
- size="small"
- type="primary"
- v-if="
- $hasPermission('aps:batchReleaseWorkOrder:release') && !planDotLine
- "
- @click="batchDispatch"
- >批量派单
- <!-- -->
- </el-button>
- <el-button
- class="ele-btn-icon"
- size="small"
- type="primary"
- v-if="$hasPermission('aps:workorder:teamScheduling')"
- @click="openFactoryScheduling"
- >班组排程
- </el-button>
- </div>
- <el-tabs v-model="tabValue" type="card" @tab-click="handleTabClick">
- <el-tab-pane label="全部订单" name="1"></el-tab-pane>
- <el-tab-pane label="暂停/终止订单" name="2"></el-tab-pane>
- <!-- <el-tab-pane label="我的任务" name="1"></el-tab-pane>
- <el-tab-pane label="全部任务" name="2"></el-tab-pane> -->
- </el-tabs>
- <!-- <el-tabs v-model="activeName" type="card">
- <el-tab-pane label="未完成工单" name="first"></el-tab-pane>
- <el-tab-pane label="已完成工单" name="second"></el-tab-pane>
- </el-tabs> -->
- <!-- 数据表格 -->
- <!-- <plan-statistics></plan-statistics> -->
- <!-- <ele-pro-table
- ref="table"
- :columns="newColumns"
- :datasource="datasource"
- cache-key="workOrderTable"
- row-key="code"
- @sort-change="onSortChange"
- height="calc(100vh - 380px)"
- autoAmendPage
- :parse-data="parseData"
- <el-link
- :underline="false"
- type="primary"
- @click="checkInventory(row)"
- >
- 库存
- </el-link>
- > -->
- <ele-pro-table
- ref="table"
- :cache-key="cacheKeyUrl"
- :columns="columns"
- :datasource="datasource"
- :parse-data="parseData"
- autoAmendPage
- row-key="id"
- @sort-change="onSortChange"
- @columns-change="handleColumnChange"
- @select-all="selectAll"
- default-expand-all
- :height="tableHeight"
- full-height="calc(100vh - 116px)"
- :page-size="20"
- >
- <!-- :key="activeName" -->
- <!-- :selection.sync="selection" -->
- <!-- @update:selection="handleSelectionChange" -->
- <template v-slot:toolbar> </template>
- <template v-slot:selection="{ row }">
- <el-checkbox
- :disabled="!dispatchPermission(row)"
- :value="checkRowData(row)"
- class="batch_checked"
- @change="(e) => selectRow(e, row)"
- ></el-checkbox>
- </template>
- <template v-slot:code="{ row }">
- <el-link
- type="primary"
- :underline="false"
- style="padding-left: 16px"
- @click="openDetails(row)"
- >
- <el-tag type="success" size="mini" v-if="row.originalCode">
- 拆</el-tag
- >
- {{ row.code }}
- </el-link>
- </template>
- <template v-slot:formingWeight="{ row }">
- {{ row.formingWeight }} {{ row.newWeightUnit }}
- </template>
- <template v-slot:priority="{ row }">
- <div style="display: flex">
- <el-input
- v-model="row.priority"
- :max="10"
- :min="0"
- size="mini"
- style="width: 80px"
- type="number"
- @change="priorityChange(row)"
- ></el-input>
- <el-popover
- content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
- placement="right"
- trigger="hover"
- width="200"
- >
- <div slot="reference" class="sort-wrap">
- <i class="el-icon-caret-top" @click="sortTop(row)"></i>
- <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
- </div>
- </el-popover>
- </div>
- </template>
- <template v-slot:werks="{ row }">
- <el-link
- :underline="false"
- type="primary"
- @click="checkInventory(row)"
- >查看库存</el-link
- >
- </template>
- <template v-slot:sourceType="{ row }">
- <span v-if="row.sourceType == 1">生产计划</span>
- <span v-if="row.sourceType == 2">临时生产计划</span>
- <span v-if="row.sourceType == 3">受托转订单</span>
- </template>
- <template v-slot:workOrderType="{ row }">
- <span v-if="row.workOrderType == 1">普通订单</span>
- <span v-if="row.workOrderType == 2">临时订单</span>
- <span v-if="row.workOrderType == 3">受托订单</span>
- </template>
- <template v-slot:status="{ row }">
- <span :class="{ 'ele-text-danger': row.status == 3 }">
- {{ statusFormatter(row.status) }}
- </span>
- </template>
- <!-- 操作列 -->
- <template v-slot:selectionHeader="{ column }">
- <span>123</span>
- </template>
- <template v-slot:action="{ row }">
- <el-link
- v-if="
- dispatchPermission(row) &&
- $hasPermission('aps:workorder:dispatch') &&
- row.workCenterId &&
- userWorkCenter &&
- userWorkCenter.includes(row.workCenterId)
- "
- :underline="false"
- icon="el-icon-truck"
- type="primary"
- @click="toReleaseOpen(row)"
- >
- 首工序派单
- </el-link>
- <el-link
- v-if="
- unpackShow(row) &&
- row.splitResidue !== 0 &&
- $hasPermission('aps:workorder:ordersplitting') &&
- !planDotLine
- "
- :underline="false"
- type="primary"
- @click="toUnpack(row)"
- >
- 拆单
- </el-link>
- <el-link
- type="primary"
- :underline="false"
- @click="productionPreparations(row)"
- >
- 生产准备
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除此子单吗?"
- @confirm="remove(row)"
- v-if="removeShow(row) && $hasPermission('aps:workorder:delete')"
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- </el-card>
- <unpackDialog ref="unpackRef" @success="createSuccess" />
- <releaseDialog
- v-if="dispatchVisible"
- ref="releaseRef"
- :current="dispatchRow"
- :dispatchVisible.sync="dispatchVisible"
- @createSuccess="createSuccess"
- />
- <planDotLinReleaseDialog
- v-if="planDotLineVisible"
- ref="planDotLinReleaseDialogRef"
- :current="dispatchRow"
- :dispatchVisible.sync="planDotLineVisible"
- @createSuccess="createSuccess"
- />
- <BatchDialog ref="batchRef" @createSuccess="createSuccess" />
- <Details
- ref="detailsRef"
- v-if="detailsVisible"
- :current="dispatchRow"
- :detailsVisible.sync="detailsVisible"
- />
- <AssetsDialog ref="assetsRef" :treeIds="treeId"></AssetsDialog>
- <checkProductionPreparations
- ref="checkProductionPreparationsRef"
- type="order"
- @update="reload"
- />
- <newFactoryProductionScheduling ref="newFactoryProductionSchedulingRef" />
- </div>
- </template>
- <script>
- import {
- getList,
- releaseWorkOrder,
- updatePriority,
- unpackDel,
- getListStop
- } from '@/api/workOrder/index.js';
- import {
- listByFirstTaskId,
- listByWorkCenterId,
- listUserByIds
- } from '@/api/mainData/index.js';
- import OrderSearch from './components/order-search.vue';
- import unpackDialog from './components/unpackDialog.vue';
- import releaseDialog from './components/releaseDialog.vue';
- import { fieldModel } from '@/api/saleOrder';
- import { debounce } from 'lodash';
- import PlanStatistics from '@/components/statistics/PlanStatistics.vue';
- import tabMixins from '@/mixins/tableColumnsMixin';
- import BatchDialog from '@/views/workOrder/components/batchDialog.vue';
- import Details from './components/details.vue';
- import AssetsDialog from './components/AssetsDialog.vue';
- import checkProductionPreparations from '@/views/productionPlan/components/checkProductionPreparations.vue';
- import newFactoryProductionScheduling from '@/views/productionPlan/components/newFactoryProductionScheduling.vue';
- import { getProductPlanDetail } from '@/api/productionPlan/index';
- import { parameterGetByCode } from '@/api/mainData/index';
- import planDotLinReleaseDialog from './components/planDotLinReleaseDialog.vue';
- export default {
- mixins: [tabMixins],
- components: {
- PlanStatistics,
- OrderSearch,
- unpackDialog,
- releaseDialog,
- BatchDialog,
- Details,
- AssetsDialog,
- checkProductionPreparations,
- planDotLinReleaseDialog,
- newFactoryProductionScheduling
- },
- data() {
- return {
- visible: false,
- loading: false,
- form: {
- assignType: 1,
- crewIds: '',
- workstationIds: '',
- teamId: '',
- singleReport: ''
- },
- rules: {
- singleReport: [
- {
- required: true,
- message: '请选择报工类型',
- trigger: ['blur', 'change']
- }
- ],
- workstationIds: [
- {
- required: true,
- message: '请选择工位',
- trigger: ['blur']
- }
- ],
- teamId: [
- {
- required: true,
- message: '请选择班组',
- trigger: ['blur']
- }
- ]
- },
- teamList: [],
- statusOpt: [
- { label: '待生产', value: 4 },
- { label: '生产中', value: 5 },
- { label: '待下达', value: 8 }
- ],
- columns: [],
- stationList: [],
- teamsList: [],
- orderSchedulingTeamMap: {},
- crewList: [],
- current: null,
- cacheKeyUrl: '3cbbdff9-aps-workOrder-index',
- columnsVersion: 1,
- dispatchRow: {},
- dispatchVisible: false,
- selectionMap: {},
- detailsVisible: false,
- tabMixinsInit: false,
- tabValue: '1',
- currentOrderListWhere: {},
- treeId: [],
- tableHeight: 'calc(100vh - 345px)',
- userWorkCenter: this.$store.state.user.info.workCenterIds,
- planDotLine: false,
- planDotLineVisible: false
- };
- },
- computed: {
- // 派单按钮显示
- dispatchPermission() {
- return (row) => {
- if (!row.firstTaskId) {
- return false;
- }
- return (
- (row.isSplit != 1 &&
- this.clientEnvironmentId != '4' &&
- row.status == 8) ||
- (this.clientEnvironmentId == '4' &&
- !row.productName.includes('板材') &&
- row.status == 8)
- );
- };
- },
- // 删除按钮显示
- removeShow() {
- return (row) => {
- return row.originalCode && !row.mesStatus;
- };
- },
- // 拆单按钮显示
- unpackShow() {
- return (row) => {
- if (row.originalCode) return false;
- return (
- (this.clientEnvironmentId != '4' && row.status == 8) ||
- (this.clientEnvironmentId == '4' &&
- !row.productName.includes('板材') &&
- row.status == 8)
- );
- };
- },
- teamId() {
- return this.$store.state.user.info.teamId;
- },
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- },
- checkRowData() {
- return (row) => {
- return row.checkedata ? true : false;
- };
- }
- },
- created() {
- this.setColumns();
- this.getFieldModel();
- this.getPlanDotLine();
- },
- methods: {
- getPlanDotLine() {
- parameterGetByCode({
- code: 'plan_dot_line'
- }).then((res) => {
- if (res) {
- this.planDotLine = res.value == '1' ? true : false;
- }
- });
- },
- setColumns() {
- this.columns = [
- {
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center',
- slot: 'selection',
- fixed: 'left',
- headerSlot: 'selectionHeader'
- // selectable: (row, index) => {
- // if (row.children) {
- // }
- // return this.dispatchPermission(row);
- // }
- },
- {
- columnKey: 'index',
- slot: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- slot: 'code',
- label: '生产订单号',
- align: 'center',
- minWidth: 220,
- sortable: true,
- showOverflowTooltip: true
- },
- {
- prop: 'lineNumber',
- label: '行号',
- align: 'center',
- minWidth: 100,
- showOverflowTooltip: true
- },
- {
- prop: 'factoryName',
- label: '所属工厂',
- align: 'center',
- minWidth: 100
- },
- {
- prop: 'taskName',
- action: 'taskName',
- label: '工序进度',
- align: 'center',
- minWidth: 160
- },
- {
- prop: 'werks',
- slot: 'werks',
- label: '库存',
- align: 'center',
- minWidth: 160
- },
- {
- prop: 'mesStatusName',
- label: '状态',
- align: 'center',
- minWidth: 160
- },
- {
- prop: 'list',
- label: '派单对象',
- align: 'center',
- minWidth: 160,
- formatter: (row) => {
- if (row?.list?.length) {
- let assignees = row.list.map((item) => item.assignees)?.flat();
- return assignees?.map((item) => item.assigneeName).join(',');
- }
- },
- showOverflowTooltip: true
- },
- {
- prop: 'productionPlanCode',
- label: '计划编号',
- align: 'center',
- minWidth: 150,
- showOverflowTooltip: true
- },
- {
- prop: 'productType',
- label: 'BOM类型',
- align: 'center',
- width: 120,
- formatter: (row) => {
- if (row.produceType == 1) {
- return 'PBOM';
- }
- if (row.produceType == 2) {
- return 'MBOM';
- }
- if (row.produceType == 3) {
- return 'ABOM';
- }
- }
- },
- {
- prop: 'bomCategoryName',
- label: 'BOM版本',
- align: 'center',
- width: 130,
- showOverflowTooltip: true,
- formatter: (row) => {
- if (row.bomCategoryName) {
- return `${row.bomCategoryName} (V${row.bomCategoryVersions}.0)`;
- }
- return '';
- }
- },
- {
- prop: 'produceRoutingName',
- label: '工艺路线',
- align: 'center',
- minWidth: 170,
- showOverflowTooltip: true
- },
- {
- prop: 'modelKey',
- label: '机型',
- align: 'center',
- minWidth: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'colorKey',
- label: '颜色',
- align: 'center',
- minWidth: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'productCode',
- label: '编码',
- align: 'center',
- minWidth: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'productName',
- label: '名称',
- align: 'center',
- minWidth: 170,
- showOverflowTooltip: true
- },
- {
- prop: 'productionCodes',
- label: '生产编号',
- align: 'center',
- minWidth: 150,
- showOverflowTooltip: true
- },
- {
- prop: 'productionRequirements',
- label: '生产要求',
- align: 'center',
- minWidth: 200,
- showOverflowTooltip: true
- },
- {
- prop: 'brandNo',
- label: '牌号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'teamName',
- label: '首工序班组',
- align: 'center',
- minWidth: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'teamLeaderUserName',
- label: '班组长',
- align: 'center',
- minWidth: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'batchNo',
- label: '批次号',
- align: 'center',
- minWidth: 100,
- showOverflowTooltip: true
- },
- {
- prop: 'model',
- label: '型号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'specification',
- label: '规格',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'priority',
- label: '优先级',
- align: 'center',
- minWidth: 120,
- slot: 'priority',
- sortable: 'custom'
- },
- {
- prop: 'formingNum',
- label: '要求生产数量',
- formatter: (row) => {
- if (row.measuringUnit) {
- return `${row.formingNum} ${row.measuringUnit}`;
- } else {
- return row.formingNum;
- }
- },
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'formingWeight',
- label: '要求生产重量',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- slot: 'formingWeight'
- },
- {
- prop: 'sourceType',
- label: '来源类型',
- slot: 'sourceType',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'sourceCode',
- label: '来源编码',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'workOrderType',
- label: '订单类型',
- slot: 'workOrderType',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'planStartTime',
- label: '计划开始时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'planCompleteTime',
- label: '计划结束时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'workCenterName',
- label: '工作中心',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'firstTaskName',
- label: '首工序',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'createTime',
- label: '创建时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- sortable: 'custom'
- },
- // {
- // slot: 'status',
- // label: '状态',
- // align: 'center',
- // formatter: (row) => {
- // const obj = this.statusOpt.find((i) => i.value == row.status);
- // return obj && obj.label;
- // }
- // },
- {
- prop: 'customerName',
- label: '客户名称',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'serialNo',
- label: '客户代号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'simpleName',
- label: '客户简称',
- align: 'center',
- showOverflowTooltip: true
- }
- ];
- },
- // 进入详情
- openDetails(row) {
- let dispatchRow = { ...row };
- this.dispatchRow = { ...row };
- dispatchRow.initialWeight = row.formingWeight
- ? row.formingWeight + row.newWeightUnit
- : '';
- this.dispatchRow = dispatchRow;
- this.detailsVisible = true;
- },
- // 全选/取消全选
- selectAll(selection) {
- if (selection.length == 0) {
- // 取消全选
- let list = this.$refs.table._data.tableData;
- list.map((el) => {
- this.$set(el, 'checkedata', false);
- if (el.children && el.children.length > 0) {
- el.children.map((item) => {
- this.$set(item, 'checkedata', false);
- delete this.selectionMap[item.id];
- });
- }
- delete this.selectionMap[el.id];
- });
- return;
- }
- // 全选
- let list = [];
- selection.map((item) => {
- let flag = this.dispatchPermission(item);
- this.$set(item, 'checkedata', flag);
- if (flag) {
- list.push(item);
- }
- if (item.children && item.children.length > 0) {
- item.children.map((el) => {
- let flags = this.dispatchPermission(el);
- this.$set(el, 'checkedata', flags);
- if (flags) {
- list.push(el);
- }
- });
- }
- list.map((row) => {
- this.selectionMap[row.id] = {
- id: row.id,
- firstTaskId: row.firstTaskId,
- productionPlanId: row.productionPlanId,
- productName: row.productName,
- productCode: row.productCode,
- code: row.code,
- productionPlanCode: row.productionPlanCode,
- batchNo: row.batchNo,
- formingNum: row.formingNum,
- productionCodes: row.productionCodes,
- planStartTime: row.planStartTime,
- planCompleteTime: row.planCompleteTime,
- firstTaskName: row.firstTaskName,
- workCenterName: row.workCenterName,
- workCenterId: row.workCenterId,
- productionRequirements: row.productionRequirements,
- specification: row.specification,
- model: row.model,
- brandNo: row.brandNo,
- bomCategoryId: row.bomCategoryId,
- produceRoutingId: row.produceRoutingId,
- produceRoutingName: row.produceRoutingName
- };
- });
- });
- },
- // 单选数据
- selectRow(e, row) {
- this.$set(row, 'checkedata', e);
- if (e) {
- this.selectionMap[row.id] = {
- id: row.id,
- firstTaskId: row.firstTaskId,
- productionPlanId: row.productionPlanId,
- productName: row.productName,
- productCode: row.productCode,
- code: row.code,
- productionPlanCode: row.productionPlanCode,
- batchNo: row.batchNo,
- formingNum: row.formingNum,
- productionCodes: row.productionCodes,
- planStartTime: row.planStartTime,
- planCompleteTime: row.planCompleteTime,
- firstTaskName: row.firstTaskName,
- workCenterName: row.workCenterName,
- workCenterId: row.workCenterId,
- productionRequirements: row.productionRequirements,
- specification: row.specification,
- model: row.model,
- brandNo: row.brandNo,
- bomCategoryId: row.bomCategoryId,
- produceRoutingId: row.produceRoutingId,
- produceRoutingName: row.produceRoutingName
- };
- } else {
- delete this.selectionMap[row.id];
- }
- },
- // 批量派单
- batchDispatch() {
- let list = Object.values(this.selectionMap);
- if (list.length === 0) {
- this.$message.warning('请至少选择一条派单的数据');
- return;
- }
- if (list.length > 1) {
- for (let i = 1; i < list.length; i++) {
- let el = list[i];
- if (list[0].firstTaskId !== el.firstTaskId) {
- this.$message.warning('请选择首工序相同的数据进行批量派单');
- return;
- }
- }
- }
- this.$refs.batchRef.open(list);
- },
- getCurrentMonthCreateTimeRange() {
- const now = new Date();
- const year = now.getFullYear();
- const month = String(now.getMonth() + 1).padStart(2, '0');
- const lastDay = String(
- new Date(year, now.getMonth() + 1, 0).getDate()
- ).padStart(2, '0');
- return {
- createTimeStart: `${year}-${month}-01 00:00:00`,
- createTimeEnd: `${year}-${month}-${lastDay} 23:59:59`
- };
- },
- getOrderCreateTimeRange(dateRange) {
- if (!Array.isArray(dateRange) || dateRange.length !== 2) {
- return this.getCurrentMonthCreateTimeRange();
- }
- const [startDate, endDate] = dateRange;
- if (!startDate || !endDate) {
- return this.getCurrentMonthCreateTimeRange();
- }
- const start = String(startDate).slice(0, 10);
- const end = String(endDate).slice(0, 10);
- return {
- createTimeStart: `${start} 00:00:00`,
- createTimeEnd: `${end} 23:59:59`
- };
- },
- buildCurrentMonthOrderWhere(dateRange) {
- const createTimeRange = this.getOrderCreateTimeRange(dateRange);
- const where = {
- ...(this.currentOrderListWhere || {})
- };
- delete where.createTime;
- delete where.createTimeStart;
- delete where.createTimeEnd;
- Object.assign(where, createTimeRange);
- if (where.status) {
- where.statusList = [where.status];
- delete where.status;
- }
- return where;
- },
- getSingleTeamId(value = this.teamId) {
- if (Array.isArray(value)) {
- return value.length ? this.getSingleTeamId(value[0]) : '';
- }
- if (value === null || value === undefined) {
- return '';
- }
- const text = String(value).trim();
- return text.includes(',') ? text.split(',')[0].trim() : text;
- },
- async getDefaultTeamByWorkCenter(workCenterId) {
- if (!workCenterId) {
- return null;
- }
- const key = String(workCenterId);
- if (this.orderSchedulingTeamMap[key] !== undefined) {
- return this.orderSchedulingTeamMap[key];
- }
- try {
- const list = await listByWorkCenterId(workCenterId);
- const teams = Array.isArray(list) ? list : [];
- const userTeamId = this.getSingleTeamId();
- const matchedTeam = teams.find(
- (item) => String(item.id) === String(userTeamId)
- );
- const team = matchedTeam || teams[0] || null;
- this.$set(this.orderSchedulingTeamMap, key, team);
- return team;
- } catch {
- this.$set(this.orderSchedulingTeamMap, key, null);
- return null;
- }
- },
- async fillOrderSchedulingTeamInfo(list = []) {
- const rows = Array.isArray(list) ? list : [];
- const result = await Promise.all(
- rows.map(async (row) => {
- if (row.teamId && row.teamName) {
- return row;
- }
- const team = await this.getDefaultTeamByWorkCenter(
- row.workCenterId
- );
- if (!team) {
- return row;
- }
- return {
- ...row,
- teamId: row.teamId || team.id,
- teamName: row.teamName || team.name
- };
- })
- );
- return result;
- },
- async loadCurrentMonthOrderList(dateRange, extraWhere = {}) {
- const URL = this.tabValue == '1' ? getList : getListStop;
- const data = await URL({
- pageNum: 1,
- size: -1,
- ...this.buildCurrentMonthOrderWhere(dateRange),
- ...extraWhere,
- ...this.sort
- });
- return this.fillOrderSchedulingTeamInfo(data?.list || []);
- },
- async openFactoryScheduling() {
- const loading = this.$loading({ text: '加载当月订单数据中...' });
- let list = [];
- try {
- list = await this.loadCurrentMonthOrderList();
- } catch (e) {
- this.$message.error(e.message || '获取当月订单数据失败');
- return;
- } finally {
- loading.close();
- }
- const ids = Array.from(
- new Set(
- list
- .map((item) => item.productionPlanId)
- .filter((id) => id !== null && id !== undefined && id !== '')
- )
- );
- // 班组排程入口:
- // 显式传 mode = order,让排程弹窗切换到工单表格、工位/设备页签,
- // 并启用“工序配置按任务派单逻辑筛选工位”的专属处理。
- // 订单表格不再取勾选缓存,统一使用订单列表接口返回的当月订单数据。
- this.$refs.newFactoryProductionSchedulingRef.open({
- ids,
- readonly: true,
- mode: 'order',
- selectedWorkOrders: list,
- orderListLoader: (dateRange, extraWhere) =>
- this.loadCurrentMonthOrderList(dateRange, extraWhere)
- });
- },
- // 删除拆单数据
- remove(row) {
- unpackDel(row.id).then((res) => {
- if (res) {
- this.$message.success('操作成功');
- this.createSuccess();
- }
- });
- },
- // assignTypeFn(e) {},
- statusFormatter(status) {
- const obj = this.statusOpt.find((i) => i.value == status);
- return obj && obj.label;
- },
- /* 表格数据源 */
- datasource({ page, limit, where }) {
- this.selectionMap = {};
- const requestWhere = { ...(where || {}) };
- this.currentOrderListWhere = { ...requestWhere };
- if (requestWhere.status) {
- requestWhere.statusList = [];
- requestWhere.statusList.push(requestWhere.status);
- delete requestWhere.status;
- }
- const URL = this.tabValue == '1' ? getList : getListStop;
- return URL({
- pageNum: page,
- size: limit,
- ...requestWhere,
- ...this.sort
- });
- },
- /* 数据转为树形结构 */
- parseData(data) {
- const obj = {
- ...data,
- list: this.$util.toTreeData({
- data: data.list,
- count: data.total,
- idField: 'code',
- parentIdField: 'originalCode'
- })
- };
- return obj;
- },
- getFieldModel() {
- fieldModel({ fieldModel: 't_main_category' }).then((res) => {
- const privateColumn = [
- {
- columnKey: 'action',
- label: '操作',
- width: 260,
- align: 'center',
- resizable: false,
- fixed: 'right',
- slot: 'action'
- }
- ];
- let newRes = res.map((m) => {
- return {
- prop: 'extField.' + m.prop,
- label: m.label,
- align: 'center',
- showOverflowTooltip: true
- };
- });
- this.columns = [...this.columns, ...newRes, ...privateColumn];
- this.getTabColumns();
- // this.$forceUpdate();
- });
- },
- productionPreparations(row) {
- this.$refs.checkProductionPreparationsRef.open(row);
- },
- // 下达
- toRelease(row) {
- this.current = row;
- this.visible = true;
- this.FirstTaskIdFn();
- this.WorkCenterIdFn();
- this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
- },
- // 下达
- confirm() {
- this.$refs.form.validate((valid) => {
- if (valid) {
- const loading = this.$loading({ text: '加载中...' });
- if (this.form.assignType * 1 == 2) {
- this.form.workstationIds = [];
- } else {
- this.form.crewIds = [];
- }
- releaseWorkOrder({
- id: this.current.id,
- ...this.form
- })
- .then((res) => {
- if (res) {
- this.$message.success('成功');
- this.reData();
- this.reload();
- this.visible = false;
- }
- })
- .finally(() => {
- loading.close();
- });
- }
- });
- },
- close() {
- this.visible = false;
- this.reData();
- },
- reData() {
- this.form = {
- assignType: 1,
- crewIds: '',
- workstationIds: '',
- teamId: '',
- singleReport: this.clientEnvironmentId == 2 ? 0 : 1
- };
- },
- /* 刷新表格 */
- reload(where) {
- this.currentOrderListWhere = { ...(where || {}) };
- this.$nextTick(() => {
- this.$refs.table.reload({ page: 1, where });
- });
- },
- handleTabClick(e) {
- console.log(e.name);
- this.tabValue = e.name;
- this.reload();
- },
- onSortChange(e) {
- let sort = {
- orderBy: e.order,
- sortName: e.prop
- };
- this.sort = sort;
- this.reload();
- },
- sortTop(row) {
- row.priority = Number(row.priority) + 1;
- this.priorityChange(row);
- },
- sortBottom(row) {
- if (row.priority <= 1) {
- return;
- }
- row.priority = Number(row.priority) - 1;
- this.priorityChange(row);
- },
- FirstTaskIdFn() {
- listByFirstTaskId(this.current.firstTaskId).then((res) => {
- this.stationList = res;
- });
- },
- WorkCenterIdFn() {
- listByWorkCenterId(this.current.workCenterId).then((res) => {
- this.teamsList = res;
- this.$nextTick(() => {
- if (this.teamId) {
- this.$set(this.form, 'teamId', this.teamId);
- this.stationChange();
- }
- // this.$refs.form.clearValidate();
- });
- });
- },
- // 拆分
- toUnpack(row) {
- this.$refs.unpackRef.open(row);
- },
- //派单
- toReleaseOpen(row) {
- this.dispatchRow = { ...row };
- this.dispatchRow.initialWeight = row.formingWeight
- ? row.formingWeight + row.newWeightUnit
- : '';
- if (!this.planDotLine) {
- this.dispatchVisible = true;
- } else {
- this.planDotLineVisible = true;
- }
- // getTaskIdByInstanceId(row.firstTaskId)
- // .then((res) => {
- // if (res) {
- // }
- // })
- // .catch((err) => {
- // this.$message.error(err.message);
- // });
- },
- createSuccess() {
- this.reload();
- },
- checkInventory(item) {
- this.treeId.push(item.rootCategoryLevelId);
- this.$refs.assetsRef.open(item);
- },
- stationChange() {
- this.crewList = [];
- this.crewIds = [];
- listUserByIds([this.form.teamId]).then((res) => {
- this.crewList = res;
- });
- },
- priorityChange(row) {
- if (row.priority > 10) {
- row.priority = 10; // 如果大于 10,则设置为 10
- } else if (row.priority < 0) {
- row.priority = 0; // 如果小于 0,则设置为 0
- }
- this.priorityFn(row);
- },
- priorityFn: debounce(function (row) {
- let params = {
- id: row.id,
- priority: row.priority
- };
- updatePriority(params).then((res) => {});
- }, 800)
- }
- };
- </script>
- <style lang="scss" scoped>
- // ::v-deep .el-table__row {
- // height: 51px !important;
- // }
- .btn_box {
- margin-bottom: 6px;
- }
- </style>
|