| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120 |
- <template>
- <ele-modal
- :before-close="cancel"
- :close-on-click-modal="false"
- :maxable="true"
- :title="'派单'"
- :visible.sync="dispatchVisible"
- :width="modelWidth"
- append-to-body
- custom-class="ele-dialog-form"
- >
- <div class="form-wrapper">
- <el-form
- ref="form"
- :inline="true"
- :model="form"
- label-position="right"
- label-width="100px"
- >
- <el-row :gutter="10" class="basic" style="flex-wrap: wrap" type="flex">
- <el-col
- v-for="item in fieldList"
- :key="item.prop"
- :lg="8"
- :md="12"
- :sm="12"
- :xl="6"
- :xs="12"
- >
- <el-form-item :label="item.label">
- <!-- <div class="item_label">{{ current[item.prop] }}</div> -->
- <el-input v-model="current[item.prop]" disabled />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="10">
- <el-col :lg="8" :md="12" :sm="12" :xl="6" :xs="12">
- <el-form-item label="所属工厂:">
- <el-input v-model="form.factoryName" :disabled="true"></el-input>
- </el-form-item>
- </el-col>
- <el-col :lg="8" :md="12" :sm="12" :xl="6" :xs="12">
- <el-form-item label="所属工作中心:">
- <el-select
- v-model="form.workCenterId"
- placeholder="请选择"
- style="width: 100%"
- @change="changeWork"
- >
- <el-option
- v-for="item in workCenterList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :lg="8" :md="12" :sm="12" :xl="6" :xs="12">
- <el-form-item label="所属班组:" required>
- <el-select
- v-model="form.teamId"
- placeholder="请选择"
- style="width: 100%"
- @change="changeGroups"
- >
- <el-option
- v-for="item in teamList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <!-- <el-row>-->
- <!-- <el-form-item label="报工类型:" required>-->
- <!-- <el-radio-group v-model="form.singleReport">-->
- <!-- <!– v-if="clientEnvironmentId != 2" –>-->
- <!-- <el-radio :label="1">单件报工</el-radio>-->
- <!-- <el-radio :label="0">批量报工</el-radio>-->
- <!-- </el-radio-group>-->
- <!-- </el-form-item>-->
- <!-- </el-row>-->
- <!-- <el-row>-->
- <!-- <el-form-item label="派单方式:" prop="taskAss">-->
- <!-- <el-radio-group v-model="form.taskAss">-->
- <!-- <el-radio :label="1">生产订单派单</el-radio>-->
- <!-- <el-radio :disabled="procTaskDis" :label="0"-->
- <!-- >工序任务派单-->
- <!-- </el-radio-->
- <!-- >-->
- <!-- </el-radio-group>-->
- <!-- </el-form-item>-->
- <!-- </el-row>-->
- <!-- <el-row v-if="form.taskAss == 1">-->
- <!-- <el-col :span="24">-->
- <!-- <el-form-item label="指派:" prop="assignType">-->
- <!-- <el-radio-group-->
- <!-- v-model="form.assignType"-->
- <!-- size="mini"-->
- <!-- @change="assignRadio"-->
- <!-- >-->
- <!-- <el-radio-button :label="1">工位</el-radio-button>-->
- <!-- <el-radio-button :label="2">人员</el-radio-button>-->
- <!-- <!– <el-radio-button :label="3">产线</el-radio-button> –>-->
- <!-- </el-radio-group>-->
- <!-- </el-form-item>-->
- <!-- </el-col>-->
- <!-- <el-form-item v-if="form.assignType == 1" label="工位:" required>-->
- <!-- <el-select-->
- <!-- v-model="form.workstationIds"-->
- <!-- class="ele-block"-->
- <!-- filterable-->
- <!-- multiple-->
- <!-- placeholder="请选择工位"-->
- <!-- size="mini"-->
- <!-- >-->
- <!-- <el-option-->
- <!-- v-for="item in stationList"-->
- <!-- :key="item.id"-->
- <!-- :label="item.name + '(' + item.code + ')'"-->
- <!-- :value="item.id"-->
- <!-- >-->
- <!-- </el-option>-->
- <!-- </el-select>-->
- <!-- </el-form-item>-->
- <!-- <el-form-item-->
- <!-- v-if="form.assignType == 2"-->
- <!-- label="人员:"-->
- <!-- prop="crewIds"-->
- <!-- >-->
- <!-- <el-select-->
- <!-- v-model="form.crewIds"-->
- <!-- class="ele-block"-->
- <!-- filterable-->
- <!-- multiple-->
- <!-- placeholder="请选择人员"-->
- <!-- size="mini"-->
- <!-- >-->
- <!-- <el-option-->
- <!-- v-for="item in crewList"-->
- <!-- :key="item.id"-->
- <!-- :label="item.name"-->
- <!-- :value="item.id"-->
- <!-- >-->
- <!-- </el-option>-->
- <!-- </el-select>-->
- <!-- </el-form-item>-->
- <!-- </el-row>-->
- <!-- v-show="form.taskAss == 0" -->
- <el-tabs
- v-model="processId"
- v-loading="tabsLoading"
- class="process_list"
- style="margin-bottom: 20px"
- type="border-card"
- @tab-click="handleClick"
- >
- <el-tab-pane
- v-for="(item, index) in processList"
- :key="item.id"
- :label="item.name"
- :name="item.id"
- >
- <ele-pro-table
- ref="tableRef"
- v-loading="tabLoading"
- :columns="columns"
- :datasource="item.list"
- :pageSize="20"
- :selection.sync="item.selection"
- cache-key="systemRoleTable"
- class="table"
- >
- <template v-slot:toolbar>
- <div style="display: inline-block" v-if="!item.isSpecialField">
- <el-button
- :loading="toolbarLoading"
- type="primary"
- @click="dispatch(item, 1)"
- >
- 派单
- </el-button>
- <el-button
- :loading="toolbarLoading"
- type="primary"
- @click="dispatch(item, 2)"
- >
- 撤回
- </el-button>
- <el-button
- :loading="toolbarLoading"
- type="primary"
- @click="dispatch(item, 3)"
- >
- 保存
- </el-button>
- </div>
- <div
- style="margin-left: 50px; display: inline-block"
- v-if="!item.isSpecialField"
- >
- <span
- class="text"
- style="
- font-weight: bold;
- font-size: 14px;
- margin-right: 8px;
- "
- >指派:</span
- >
- <el-radio-group
- v-model="item.assignType"
- size="mini"
- @change="(e) => changeRadio(e, index)"
- >
- <el-radio-button
- :disabled="radioBun(item, 'stationDis')"
- :label="1"
- >工位
- </el-radio-button>
- <el-radio-button
- :disabled="radioBun(item, 'staffDis')"
- :label="2"
- >人员
- </el-radio-button>
- <el-radio-button
- :disabled="radioBun(item, 'lineDis')"
- :label="3"
- >产线
- </el-radio-button>
- </el-radio-group>
- </div>
- <div
- v-if="item.isSpecialField"
- class="describe"
- style="color: #67c23a"
- >
- 该工序已完成派单!
- </div>
- </template>
- <template v-slot:quantity="{ row }">
- <el-input
- v-model="row.quantity"
- :disabled="permissions(row, item)"
- placeholder="请输入数量"
- type="number"
- @input="(e) => handleQuantityInput(e, row, item)"
- ></el-input>
- </template>
- <template v-slot:weight="{ row }">
- <el-input
- v-model="row.weight"
- :disabled="permissions(row, item)"
- placeholder="请输入重量"
- type="number"
- @input="(e) => handleWeightInput(e, row, item)"
- ></el-input>
- </template>
- <template v-slot:teamTimeDetailId="{ row }">
- <el-select
- v-model="row.teamTimeDetailId"
- placeholder="班次"
- :disabled="permissions(row, item)"
- @change="(e) => shiftSelection(e, row)"
- >
- <el-option
- v-for="item in shiftList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </template>
- <template v-slot:startTime="{ row }">
- <el-date-picker
- v-model="row.startTime"
- :disabled="permissions(row, item)"
- :picker-options="{
- disabledDate: (time) => {
- return (
- row.endTime && time.getTime() > new Date(row.endTime)
- );
- }
- }"
- class="w100"
- placeholder="开始时间"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- ></el-date-picker>
- </template>
- <template v-slot:endTime="{ row }">
- <el-date-picker
- v-model="row.endTime"
- :disabled="permissions(row, item)"
- :picker-options="{
- disabledDate: (time) => {
- return (
- row.startTime &&
- time.getTime() < new Date(row.startTime)
- );
- }
- }"
- class="w100"
- placeholder="完成时间"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- ></el-date-picker>
- </template>
- <template v-slot:action="{ row }">
- <!-- :disabled="resetBtnDis(row)" -->
- <el-popconfirm
- v-if="resetBtnDis(row)"
- title="确定要重置该条数据吗?"
- @confirm="resetData(row, item)"
- >
- <template v-slot:reference>
- <el-link :underline="false" type="primary"> 重置</el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- </el-tab-pane>
- </el-tabs>
- </el-form>
- </div>
- <!-- <div slot="footer">-->
- <!-- <el-button plain @click="cancel">取消</el-button>-->
- <!-- <el-button :loading="toolbarLoading" type="primary" @click="confirm"-->
- <!-- >确定-->
- <!-- </el-button-->
- <!-- >-->
- <!-- </div>-->
- </ele-modal>
- </template>
- <script>
- import {
- lineByCurrentUser,
- listAssign,
- listByFirstTaskId,
- listByMesWorkOrder,
- listByRoutingIds,
- listUserByIds,
- listWorkCenter,
- resetAssignee,
- taskAssignment,
- taskRevoked,
- taskSave,
- listByFactoryId
- } from '@/api/mainData/index.js';
- export default {
- components: {},
- props: {
- current: {
- type: Object,
- default: () => {}
- },
- dispatchVisible: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- processId: '',
- tabLoading: false,
- dynamicName: '工位名称',
- form: {
- assignType: 1,
- crewIds: '',
- workstationIds: '',
- teamId: '',
- singleReport: '',
- workCenterId: '',
- taskAss: 1,
- factoryName: ''
- },
- toolbarLoading: false,
- processList: [],
- workCenterList: [],
- teamList: [],
- tabsLoading: false,
- stationList: [], // 工位的数据
- productionList: [], // 产线的数据
- crewList: [], // 人员的数据
- // procTaskDis: false, // 工序任务派单选择
- // firstTaskindex: '', // 首工序id 对应的工序列表数据下标
- fieldList: [
- { label: '生产订单号:', prop: 'code' },
- { label: '计划编号:', prop: 'productionPlanCode' },
- { label: '工艺路线:', prop: 'produceRoutingName' },
- // { label: '编码', prop: 'productCode' },
- { label: '名称:', prop: 'productName' },
- { label: '生产编号:', prop: 'productionCodes' },
- { label: '牌号:', prop: 'brandNo' },
- { label: '批次号:', prop: 'batchNo' },
- { label: '型号:', prop: 'model' },
- { label: '要求生产数量:', prop: 'formingNum' },
- { label: '要求生产重量:', prop: 'initialWeight' },
- { label: '计划开始时间:', prop: 'planStartTime' },
- { label: '计划结束时间:', prop: 'planCompleteTime' }
- ],
- shiftList: [],
- dateValue: ''
- };
- },
- computed: {
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- },
- userInfo() {
- return this.$store.state.user.info;
- },
- modelWidth() {
- // if(this.form.taskAss == 1){
- // return '1000px'
- // }
- return '75vw';
- },
- // 重置按钮 的置灰权限 没有进行操作跟派单的数据 置灰
- resetBtnDis() {
- return (row) => {
- if (!row.status) return false;
- let flag = row.status.code != 1;
- return flag;
- };
- },
- // 指派单选框操作 已派单的 其它两个按钮不能操作
- radioBun() {
- return (row, type) => {
- if (!row.radioBun) return false;
- let flag = row.radioBun[type];
- return flag;
- };
- },
- // 列表输入框操作 已派单的不能操作
- permissions() {
- return (row, item) => {
- if (item.isSpecialField) return true;
- if (!row.status) return false;
- if (row.status.code == 1) return true;
- };
- },
- columns() {
- return [
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center',
- fixed: 'left'
- },
- {
- prop: 'name',
- label: this.dynamicName,
- align: 'center',
- showOverflowTooltip: true,
- width: 200
- },
- {
- prop: 'code',
- label: '编码',
- align: 'center',
- showOverflowTooltip: true,
- width: 200
- },
- {
- prop: 'status',
- label: '状态',
- align: 'center',
- showOverflowTooltip: true,
- width: 150,
- formatter: (row) => {
- if (!row.status) return '';
- return row.status.desc || '';
- }
- },
- {
- slot: 'quantity',
- prop: 'quantity',
- label: '数量',
- align: 'center',
- width: 140
- },
- {
- slot: 'weight',
- prop: 'weight',
- label: `重量(${this.current.weightUnit})`,
- align: 'center',
- width: 140
- },
- {
- slot: 'teamTimeDetailId',
- prop: 'teamTimeDetailId',
- label: '班次',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'startTime',
- prop: 'startTime',
- label: '计划开始时间',
- align: 'center',
- minWidth: 240
- },
- {
- slot: 'endTime',
- prop: 'endTime',
- label: '计划完成时间',
- align: 'center',
- minWidth: 240
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 120,
- align: 'center',
- resizable: false,
- fixed: 'right',
- slot: 'action'
- }
- ];
- }
- },
- watch: {},
- created() {
- this.workCenterData();
- this.getClassesData();
- this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
- this.dateValue = this.getFormattedDate();
- },
- methods: {
- // 查询班次
- getClassesData() {
- if (!this.current.factoriesId) return;
- listByFactoryId(this.current.factoriesId).then((res) => {
- if (!res) return;
- this.shiftList = res;
- });
- },
- // 选中班次
- shiftSelection(e, row) {
- let data = this.shiftList.find((item) => item.id == e);
- let startTime = `${this.dateValue} ${data.startTime}`;
- let endTime = `${this.dateValue} ${data.endTime}`;
- this.$set(row, 'startTime', startTime);
- this.$set(row, 'endTime', endTime);
- },
- // 获取当前年月日
- getFormattedDate() {
- const now = new Date();
- const year = now.getFullYear();
- const month = String(now.getMonth() + 1).padStart(2, '0');
- const date = String(now.getDate()).padStart(2, '0');
- return `${year}-${month}-${date}`;
- },
- // 查询工作中心
- async workCenterData() {
- const res = await listWorkCenter(this.current.taskInstanceId);
- this.workCenterList = res;
- if (res.length > 0) {
- this.form.factoryName = res[0].factoryName;
- this.form.workCenterId = res[0].id;
- // 查首工序
- this.changeWork(res[0].id); // 选择工作中心
- this.getProductionData(res[0].id); // 查询产线
- this.FirstTaskIdFn(); // 查询工位数据
- }
- },
- // 查询工序列表数据
- async changeDispatch(e) {
- this.tabsLoading = true;
- try {
- // /aps/assign/listByMesWorkOrder
- let allRes = await listByRoutingIds([this.current.produceRoutingId]); // 查询全部工序数据
- let params = {
- apsWorkOrderId: this.current.apsWorkOrderId,
- categoryId: this.current.categoryId,
- mesWorkOrderId: this.current.id,
- produceRoutingId: this.current.produceRoutingId
- };
- let existRes = await listByMesWorkOrder(params); // 存在的工序数据
- let res = [];
- if (!existRes || existRes.length === 0) {
- res = allRes;
- } else {
- // 先将 存在的工序数据 数组的 id 存入 Set
- const existIds = new Map(
- existRes.map((item) => [item.taskId, true])
- );
- // 过滤 全部工序数据 数组
- // res = allRes.map((aItem) => !existIds.has(aItem.sourceTaskId));
- res = allRes.map((aItem) => {
- return {
- ...aItem,
- isSpecialField: existIds.has(aItem.sourceTaskId)
- };
- });
- }
- // 如果没有首工序的数据 就不能选择工序任务派单
- if (!res || res.length === 0) {
- this.processList = [];
- // this.form.taskAss = 1;
- // this.procTaskDis = true;
- this.$message.warning('当前工单没有工序数据');
- return;
- }
- // this.procTaskDis = false;
- let list = [];
- res.forEach((item, index) => {
- let obj = {
- id: item.sourceTaskId, //工序 id
- name: item.name, //工序 名称
- assignType: 1, // 默认的指派数据
- assignName: '工位', // 默认指派数据名称
- list: [], // 当前工序下面的指派 绑定的表格
- selection: [], // 当前工序下面的指派 选中的数据
- code: item.code, // 工序 编码
- index: index, // 当前工序数据的下标
- isSpecialField: item.isSpecialField,
- radioBun: {
- // 指派按钮的操作状态 绑定 默认false(可操作)
- stationDis: false,
- staffDis: false,
- lineDis: false
- }
- };
- list.push(obj);
- });
- this.processList = list;
- this.handleClick({ name: res[0].sourceTaskId });
- } catch (err) {
- this.processList = [];
- this.$message.error(err.message);
- } finally {
- this.tabsLoading = false;
- }
- },
- // 选择工作中心
- changeWork(e) {
- this.form.workCenterId = e;
- // this.changeDispatch(); // 查询工序列表
- let data = this.workCenterList.find((item) => item.id == e);
- this.form.workCenterName = data.name;
- this.teamList = data.teamList || [];
- if (this.teamList.length > 0) {
- this.form.teamId = this.teamList[0].id;
- this.changeGroups(this.teamList[0].id);
- }
- },
- // 选择班组 查询人员的数据
- async changeGroups(e) {
- let data = this.teamList.find((item) => item.id == e);
- this.form.teamName = data.name;
- try {
- const res = await listUserByIds([e]);
- this.crewList = res || [];
- // 查看当前的工序数据是不是 选择的人员 是的话同步更改
- // if (this.form.taskAss == 1) {
- // return;
- // }
- if (!this.processId || this.processId == 0) {
- return;
- }
- let data = this.processList.find(
- (item) => item.id === this.processId
- );
- if (data.assignType == 2) {
- this.handleClick({ name: this.processId });
- // this.$set(data, 'list', res);
- }
- } catch {
- this.crewList = [];
- }
- },
- // 获取产线数据
- async getProductionData() {
- const res = await lineByCurrentUser(this.form.workCenterId);
- this.productionList = res || [];
- },
- // 查询工位数据
- FirstTaskIdFn() {
- listByFirstTaskId(this.current.taskInstanceId)
- .then((res) => {
- this.stationList = res;
- this.changeDispatch();
- })
- .catch((err) => {
- this.stationList = [];
- this.$message.error(err.message);
- });
- },
- // 重置(单个)
- resetData(row, item) {
- if (!row.changeId) {
- return this.$message.warning('只能对已撤回跟已保存的数据进行重置');
- }
- this.toolbarLoading = true;
- resetAssignee(row.changeId)
- .then((res) => {
- this.toolbarLoading = false;
- if (res) {
- this.$message.success('操作成功');
- // 更改当前表格数据
- this.setCurrentTab(item);
- }
- })
- .catch((err) => {
- this.toolbarLoading = false;
- this.$message.warning(err.message);
- });
- },
- // 撤回的逻辑
- getWithdrawT(row, type) {
- if (type != 2) {
- return true;
- }
- let isFlag = true;
- row.selection.forEach((item) => {
- if (!item.status) {
- isFlag = false;
- return;
- }
- if (!item.status.code) {
- isFlag = false;
- }
- });
- return isFlag;
- },
- // 派单
- dispatch(row, type) {
- if (row.selection.length == 0) {
- return this.$message.warning('请最少选择一条数据');
- }
- let isWithdraw = this.getWithdrawT(row, type);
- if (!isWithdraw) {
- this.$message.warning('只有状态为派单的数据才能进行撤回');
- return;
- }
- let assignees = [];
- let changeIds = [];
- let flag = true; // 是否填写 校验
- let digit = true; // 数字校验
- row.selection.forEach((item) => {
- if (!item.quantity || !item.startTime || !item.endTime) {
- flag = false;
- return;
- }
- if (item.quantity == 0) {
- this.$message.warning('请检查所选数据的数量不能为0');
- digit = false;
- return;
- }
- if (item.weight == 0) {
- this.$message.warning('请检查所选数据的重量不能为0');
- digit = false;
- return;
- }
- let Aobj = {
- assigneeId: item.id,
- quantity: item.quantity,
- weight: item.weight,
- startTime: item.startTime,
- endTime: item.endTime,
- assigneeType: row.assignType,
- assigneeName: item.name
- };
- if (item.teamTimeDetailId) {
- Aobj.teamTimeDetailId = item.teamTimeDetailId;
- }
- assignees.push(Aobj);
- changeIds.push(item.changeId);
- });
- // 校验没过 就不往下进行
- if (!digit) {
- return;
- }
- if (!flag) {
- this.$message.warning(
- '请将所选数据的 数量 ,开始时间,完成时间 填写完毕'
- );
- return;
- }
- let data = null;
- this.toolbarLoading = true;
- if (type == 2) {
- data = changeIds;
- } else {
- data = {
- taskId: this.processId,
- taskName: row.name,
- taskCode: row.code,
- teamName: this.form.teamName,
- teamId: this.form.teamId,
- workCenterId: this.form.workCenterId,
- workCenterName: this.form.workCenterName,
- workOrderId: this.current.apsWorkOrderId,
- sourceType: 2,
- assignees
- };
- }
- const api =
- type == 1 ? taskAssignment : type == 2 ? taskRevoked : taskSave;
- api(data)
- .then((res) => {
- this.toolbarLoading = false;
- if (res) {
- this.$message.success('操作成功');
- // 更改当前表格数据
- this.setCurrentTab(row);
- }
- })
- .catch((err) => {
- this.toolbarLoading = false;
- this.$message.warning(err.message);
- });
- },
- cancel() {
- this.$emit('update:dispatchVisible', false);
- },
- // 按钮操作成功后 更改当前的表格数据
- setCurrentTab(row) {
- let arr = [];
- if (row.assignType == 1) {
- arr = this.stationList;
- } else if (row.assignType == 2) {
- arr = this.crewList;
- } else {
- arr = this.productionList;
- }
- this.getAssignData(row.index, arr);
- },
- // 工序选择
- handleClick(tab) {
- let id = tab.name;
- this.processId = id;
- let data = this.processList.find((item) => item.id == this.processId);
- // if (data.list.length == 0) {
- this.changeRadio(data.assignType, data.index);
- // }
- },
- // 指派选择
- changeRadio(e, index) {
- let data = this.processList[index];
- if (e == 1) {
- this.dynamicName = '工位名称';
- data.assignName = '工位';
- this.getAssignData(index, this.stationList);
- } else if (e == 2) {
- this.dynamicName = '人员名称';
- data.assignName = '人员';
- this.getAssignData(index, this.crewList);
- } else {
- this.dynamicName = '产线名称';
- data.assignName = '产线';
- this.getAssignData(index, this.productionList);
- }
- },
- // 指派数据处理
- async getAssignData(index, arr) {
- let list = JSON.parse(JSON.stringify(arr));
- let dataRow = this.processList[index];
- let params = {
- workOrderId: this.current.apsWorkOrderId,
- workCenterId: this.form.workCenterId,
- teamId: this.form.teamId,
- taskId: this.processId
- };
- this.tabLoading = true;
- try {
- const res = await listAssign(params);
- this.tabLoading = false;
- // 如果 res 没有数据 说明未对数据进行操作 直接赋值
- if (res.length == 0) {
- this.$set(dataRow, 'list', list);
- return;
- }
- // 对有操作过的数据进行赋值
- this.operationalData(index, res, list);
- } catch (err) {
- this.tabLoading = false;
- this.$message.warning(err.message);
- }
- },
- // 操作过的数据 赋值
- operationalData(index, res, list) {
- const dataRow = this.processList[index];
- // 键值对存储 当前工序 操作的数据 指派的code(键) 数据(list:值)
- let arrMap = {};
- // 要先判断有没有操作的数据 如果有的话 其它的指派操作置灰
- let codeT = null; // 表示有已操作的数据(对应的 code)
- res[0].assignees.map((el) => {
- let code = el.assigneeType.code;
- if (arrMap[code]) {
- arrMap[code].arr.push(el);
- arrMap[code].bunDis = arrMap[code].bunDis
- ? arrMap[code].bunDis
- : el.status.desc
- ? true
- : false;
- } else {
- arrMap[code] = {
- arr: [el],
- bunDis: el.status.desc ? true : false
- };
- }
- codeT = codeT ? codeT : el.status.desc ? code : '';
- });
- let radioBun = {
- lineDis: false, // 产线 3
- staffDis: false, // 人员 2
- stationDis: false // 工位 1
- };
- // 默认是传递下来的 list 数据 但是如果 codeT有值 说明 工位 人员 产线 有派单数据
- // 需要自动切换过去
- let listArr = list;
- if (codeT) {
- if (codeT == 1) {
- radioBun.staffDis = true;
- radioBun.lineDis = true;
- radioBun.stationDis = false;
- listArr = JSON.parse(JSON.stringify(this.stationList));
- dataRow.assignType = 1;
- dataRow.assignName = '工位';
- } else if (codeT == 2) {
- radioBun.stationDis = true;
- radioBun.lineDis = true;
- radioBun.staffDis = false;
- listArr = JSON.parse(JSON.stringify(this.crewList));
- dataRow.assignType = 2;
- dataRow.assignName = '人员';
- } else {
- radioBun.stationDis = true;
- radioBun.staffDis = true;
- radioBun.lineDis = false;
- listArr = JSON.parse(JSON.stringify(this.productionList));
- dataRow.assignType = 3;
- dataRow.assignName = '产线';
- }
- }
- // 切换完后 对 指派的数组数据进行赋值
- let listMap = {};
- listArr.map((el, index) => (listMap[el.id] = index));
- let arrList = codeT ? arrMap[codeT].arr : res[0].assignees;
- arrList.map((item) => {
- if (item.assigneeType.code == dataRow.assignType) {
- let idx = listMap[item.assigneeId];
- listArr[idx].status = item.status;
- listArr[idx].startTime = item.startTime;
- listArr[idx].endTime = item.endTime;
- listArr[idx].quantity = item.quantity;
- listArr[idx].weight = item.weight;
- listArr[idx].changeId = item.id;
- listArr[idx].teamTimeDetailId = item.teamTimeDetailId;
- }
- });
- this.$set(dataRow, 'list', listArr);
- this.$set(dataRow, 'radioBun', radioBun);
- },
- assignRadio(e) {},
- // 数量正则 quantity
- handleQuantityInput(e, row, item) {
- // 过滤非数字字符(包括负号)
- let value = e.replace(/[^\d]/g, '');
- // 限制不能以 0 开头(除非是 0 本身)
- if (value.startsWith('0') && value.length > 1) {
- value = value.slice(1);
- }
- // 更新绑定值
- row.quantity = value;
- this.calculateQuantity(row, item);
- this.bringWeight(row.quantity, row);
- },
- // 自动算重量
- bringWeight(value, row) {
- if (!this.current.formingWeight) {
- this.$set(row, 'weight', 0);
- return;
- }
- let weight =
- (this.current.formingWeight / this.current.formingNum) * value;
- if (weight > 0) {
- weight = weight.toFixed(4) - 0;
- }
- this.$set(row, 'weight', weight);
- },
- calculateQuantity(row, item) {
- // 如果没有该字段 就不做判断
- if (!this.current.formingNum) {
- return;
- }
- let total = 0;
- item.list.forEach((el) => {
- if (el.quantity) {
- total = total + (el.quantity - 0);
- }
- });
- if (total > this.current.formingNum - 0) {
- this.$message.warning('列表数量相加不能大于目标要求生产数量');
- row.quantity = 0;
- }
- },
- // 计算重量
- calculateWeight(row, item) {
- // 如果没有该字段 就不做判断
- if (!this.current.formingWeight) {
- return;
- }
- let total = 0;
- item.list.forEach((el) => {
- if (el.weight) {
- total = total + (el.weight - 0);
- }
- });
- if (total > this.current.formingWeight - 0) {
- this.$message.warning('列表数量相加不能大于目标要求生产数量');
- row.weight = 0;
- }
- },
- // 重量正则 weight
- handleWeightInput(e, row, item) {
- // 过滤非数字和非小数点字符(包括负号)
- let value = e.replace(/[^\d.]/g, '');
- // 限制只能有一个小数点
- const dotCount = (value.match(/\./g) || []).length;
- if (dotCount > 1) {
- value = value.slice(0, value.lastIndexOf('.'));
- }
- // 限制不能以小数点开头
- if (value.startsWith('.')) {
- value = '0' + value;
- }
- // 更新绑定值
- row.weight = value;
- this.calculateWeight(row, item);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .top-box {
- display: flex;
- margin-bottom: 10px;
- .item-box {
- flex: 1;
- }
- }
- .radio-box {
- margin: 10px 0;
- }
- .table {
- margin-top: 20px;
- }
- ::v-deep .el-radio-button__orig-radio:checked + .el-radio-button__inner {
- background-color: #10d070;
- border-color: #10d070;
- }
- ::v-deep .el-radio-button__orig-radio:checked + .el-radio-button__inner {
- box-shadow: none;
- }
- // ::v-deep .ele-block{
- // width: 240px;
- // }
- // ::v-deep .basic {
- // .el-form-item {
- // width: 100%;
- // }
- // .form80 {
- // .el-form-item__content {
- // width: calc(100% - 80px);
- // }
- // }
- // .form65 {
- // .el-form-item__content {
- // width: calc(100% - 65px);
- // }
- // }
- // .el-form-item__label {
- // padding: 0 4px 0 0;
- // }
- // .item_label {
- // white-space: nowrap;
- // overflow: hidden;
- // text-overflow: ellipsis;
- // width: 100%;
- // }
- // }
- </style>
|