| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811 |
- <template>
- <!-- :close-on-click-modal="false" -->
- <ele-modal
- width="80vw"
- :visible.sync="visible"
- custom-class="ele-dialog-form"
- :before-close="cancel"
- :title="title"
- :maxable="true"
- >
- <div class="form-wrapper">
- <el-form
- ref="form"
- :model="form"
- :rules="rules"
- label-width="110px"
- class="formbox"
- >
- <headerTitle title="基本信息"> </headerTitle>
- <el-row :gutter="10">
- <el-col :span="6">
- <el-form-item label="计划编号:" prop="code">
- <el-input
- placeholder="计划编号"
- size="mini"
- disabled
- v-model="form.code"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="计划类型:" prop="planType">
- <el-select
- v-model="form.planType"
- style="width: 100%"
- @change="changeProduceType"
- size="mini"
- >
- <el-option
- v-for="item of planTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="批次号:" prop="batchNo">
- <el-input
- placeholder="输入批次号"
- size="mini"
- v-model="form.batchNo"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="客户名称:">
- <el-input
- clearable
- v-model="form.customerName"
- style="width: calc(100% - 80px)"
- />
- <contactDialog
- style="margin-left: 3px"
- @changeParent="contactDialogSuccess"
- ></contactDialog>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="24">
- <el-col :span="6">
- <el-form-item
- label="生产编号:"
- label-width="110px"
- prop="productionCodes"
- >
- <el-input
- v-model="form.productionCodes"
- size="mini"
- type="text"
- style="width: 100%"
- placeholder=" "
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="计划开始日期:"
- label-width="110px"
- prop="startTime"
- >
- <el-date-picker
- style="width: 100%"
- size="mini"
- v-model="form.startTime"
- @change="handleStartTimeChange(form)"
- type="datetime"
- placeholder="选择日期"
- value-format="yyyy-MM-dd HH:mm:ss"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="计划结束日期:"
- label-width="110px"
- prop="endTime"
- >
- <el-date-picker
- style="width: 100%"
- size="mini"
- v-model="form.endTime"
- @change="handleEndTimeChange(form)"
- type="datetime"
- placeholder="选择日期"
- value-format="yyyy-MM-dd HH:mm:ss"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="要求完成日期:"
- label-width="110px"
- prop="reqMoldTime"
- >
- <el-date-picker
- style="width: 100%"
- size="mini"
- v-model="form.reqMoldTime"
- type="datetime"
- placeholder="选择日期"
- value-format="yyyy-MM-dd HH:mm:ss"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- </el-row>
- <headerTitle title="产品信息"> </headerTitle>
- <el-row :gutter="24">
- <ele-pro-table
- ref="tableRef"
- :columns="columns"
- row-key="code"
- :cache-key="`ProductionPlanTable`"
- :datasource="form.productInfoList"
- border
- height="40vh"
- key="id"
- >
- <template v-slot:modelKey="{ row, $index }">
- <el-select
- clearable
- v-model="row.modelKey"
- multiple
- filterable
- allow-create
- default-first-option
- >
- <el-option
- v-for="item in modelList"
- :key="item.label"
- :value="item.label"
- :label="item.label"
- >
- </el-option>
- </el-select>
- </template>
- <template v-slot:colorKey="{ row, $index }">
- <el-select
- clearable
- v-model="row.colorKey"
- multiple
- filterable
- allow-create
- default-first-option
- >
- <el-option
- v-for="item in colorList"
- :key="item.label"
- :value="item.label"
- :label="item.label"
- >
- </el-option>
- </el-select>
- </template>
- <template v-slot:requiredFormingNum="{ row, $index }">
- <el-input
- v-model="row.requiredFormingNum"
- size="small"
- type="text"
- style="width: 100%"
- placeholder="输入要求生产数量"
- @input="(e) => handleQuantityInput(e, row)"
- ></el-input>
- <!-- placeholder="输入要求生产数量" @input="tableHandleKeyUp(row, 'sum')"></el-input> -->
- </template>
- <!-- <template v-slot:productionCodes="{ row, $index }">
- <el-input
- v-model="row.productionCodes"
- size="small"
- type="text"
- style="width: 100%"
- placeholder=" "
- ></el-input>
- </template> -->
- <template v-slot:productType="{ row, $index }">
- <el-select
- v-model="row.productType"
- @change="changeProductType(row, $index)"
- :key="$index"
- >
- <el-option
- v-for="item of row.producedList"
- :key="$index + item.code"
- :label="item.name"
- :value="item.code"
- ></el-option>
- </el-select>
- </template>
- <template v-slot:bomCategoryId="{ row, $index }">
- <el-select v-model="row.bomCategoryId">
- <el-option
- v-for="item of row.bomVersionList"
- :key="item.id"
- :label="item.name + '(V' + item.versions + '.0)'"
- :value="item.id"
- @click.native="changeBomId(row, $index, item)"
- ></el-option>
- </el-select>
- </template>
- <!-- //权重等级 -->
- <template
- v-slot:weight="{ row, $index }"
- v-if="clientEnvironmentId == 4"
- >
- <el-select
- v-model="row.weight"
- style="width: 100%"
- @change="changeProduceType"
- size="mini"
- >
- <el-option
- v-for="item of weightList"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- ></el-option>
- </el-select>
- </template>
- <!-- 是否开槽 -->
- <template
- v-slot:isSlotting="{ row, $index }"
- v-if="clientEnvironmentId == 4"
- >
- <el-select
- v-model="row.isSlotting"
- style="width: 100%"
- @change="changeProduceType"
- size="mini"
- >
- <el-option
- v-for="item of isSlotting"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- ></el-option>
- </el-select>
- </template>
- <!-- 开槽类型 -->
- <template
- v-slot:slottingType="{ row, $index }"
- v-if="clientEnvironmentId == 4"
- >
- <DictSelection
- dictName="开槽类型"
- v-model="row.slottingType"
- size="mini"
- >
- </DictSelection>
- </template>
- <!-- 工艺路线 -->
- <template
- v-slot:produceRoutingId="{ row, $index }"
- v-if="clientEnvironmentId != 4"
- >
- <!-- <el-form-item required> -->
- <div style="display: flex">
- <el-select
- v-model="row.produceRoutingId"
- v-show="isRouteSelect(row)"
- >
- <el-option
- v-for="item of row.routingList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- <div style="display: flex">
- <el-input
- v-show="!isRouteSelect(row)"
- disabled
- v-model="row.produceRoutingName"
- ></el-input>
- <el-button
- v-show="isSelectShow"
- type="primary"
- size="mini"
- @click="openDialog($index)"
- >选择</el-button
- >
- </div>
- </div>
- <!-- </el-form-item> -->
- </template>
- <template v-slot:produceRoutingId="{ row, $index }" v-else>
- <el-input
- v-model="row.produceRoutingName"
- style="width: 100%"
- readonly
- ></el-input>
- </template>
- <template v-slot:factoriesId="{ row, $index }">
- <el-select
- v-model="row.factoriesId"
- :key="row.factoriesId"
- @change="(e) => selectFactory(e, row)"
- :disabled="factoriesId"
- >
- <el-option
- v-for="item of factoryList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </template>
- <!-- <el-table-column label="所属工厂" width="140" align="center" prop="factoriesId">
- <template slot-scope="scope">
- <el-form-item label-width="0px">
- <el-select v-model="scope.row.factoriesId" :key="scope.row.factoriesId">
- <el-option v-for="item of factoryList" :key="item.id" :label="item.name"
- :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- </template>
- </el-table-column> -->
- <!-- 模具数量 -->
- <template
- v-slot:moCount="{ row, $index }"
- v-if="clientEnvironmentId == '4'"
- >
- <div>
- <el-input
- style="width: 100%"
- size="small"
- v-model="row.moCount"
- oninput="value=value.replace(/[^0-9.]/g,'')"
- @input="tableHandleKeyUp(row, 'moCount')"
- placeholder="请输入"
- >
- </el-input>
- </div>
- </template>
- <!-- 块数 -->
- <template
- v-slot:blockCount="{ row, $index }"
- v-if="clientEnvironmentId == '4'"
- >
- <div>
- <el-input
- size="small"
- style="width: 100%"
- @input="tableHandleKeyUp(row, 'blockCount')"
- v-model="row.blockCount"
- placeholder="请输入"
- ></el-input>
- </div>
- </template>
- <!-- <template v-slot:productWeight="{ row, $index }">
- <span>{{ row.productWeight ? row.productWeight : '-' }}</span>
- </template> -->
- <template v-slot:set="{ row, $index }">
- <el-button type="text" @click="handleDeleteItem($index)"
- >删除</el-button
- >
- </template>
- <template v-slot:headerProduceRoutingId="{ column }">
- <div class="header_required"
- ><span class="is-required">{{ column.label }}</span></div
- >
- </template>
- <template v-slot:headeRequiredFormingNum="{ column }">
- <div class="header_required"
- ><span class="is-required">{{ column.label }}</span></div
- >
- </template>
- <template v-slot:headerProcessingBOM="{ column }">
- <div :class="isRequired ? 'header_required' : ''"
- ><span class="is-required">{{ column.label }}</span></div
- >
- </template>
- </ele-pro-table>
- <div class="add-product" @click="addEquipment">
- <i class="el-icon-circle-plus-outline"></i>
- </div>
- </el-row>
- </el-form>
- <!-- 选择产品 -->
- <EquipmentDialog
- @choose="confirmChoose"
- :treeType="['9']"
- :selectList="[]"
- ref="equipmentRefs"
- >
- </EquipmentDialog>
- </div>
- <template v-slot:footer>
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" @click="save" :loading="loading">
- 确定
- </el-button>
- <el-button type="primary" @click="save('sub')" :loading="loading">
- 发布
- </el-button>
- </template>
- <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
- </ele-modal>
- </template>
- <script>
- import { findBomCategoryByCategoryId } from '@/api/productionPlan/index';
- import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
- import { getCode } from '@/api/codeManagement';
- import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
- import { parameterGetByCode } from '@/api/mainData/index';
- import { getByCode } from '@/api/system/dictionary-data';
- import {
- bomRoutingList,
- bomListByPlan,
- getFactoryList,
- saveAndRelease,
- temporaryPlanSave,
- getUpdateInfoByCode
- } from '@/api/saleOrder';
- import contactDialog from '@/components/contactDialog/openContactDialog.vue';
- import { deepClone } from '@/utils';
- export default {
- components: {
- EquipmentDialog,
- ProcessRoute,
- contactDialog
- },
- props: {
- factoryType: {
- type: Number,
- default: 3
- },
- factoryObj: {
- type: Object,
- default: () => {}
- },
- isAdd: {
- type: Boolean,
- default: true
- }
- },
- watch: {
- // factoryObj: {
- // immediate: true,
- // deep: true,
- // handler(val) {
- // // 修改
- // // this.$nextTick(() => {
- // // if (val.id) {
- // // this.bomListVersion();
- // // if (val.bomCategoryId) {
- // // this.getPlanRouting();
- // // }
- // // }
- // // });
- // }
- // }
- },
- computed: {
- // 是否必填 字段 ( 首先看计划类型 如果是返工返修)
- // 就不是必填 否则就看配置参数
- // 必填的时候 不显示选择按钮 跟 展示输入框 只能有下拉选择框 ( 选择了生产类型 带出 BOM 版本 带出 工艺路线 工艺路线不能选择)
- // 不必填的时候 显示 选择按钮跟 展示输入框 并且可以存在选择框 一开始默认展示选择框
- // 选择按钮选择数据后 隐藏选择框 显示展示框(input) 情况 生产类型 跟 BOM版本
- // 选择了生产类型 清空 选择框选择的工艺路线
- // 是否必填字段
- isRequired() {
- if (this.form.planType == 5) {
- return false;
- }
- return this.processingRequired == 1;
- },
- // 工艺路线 输入框展示跟选择框判断
- isRouteSelect() {
- return (row) => {
- if (this.isRequired) {
- return true;
- }
- if (!row.selectionRowShow) {
- return true;
- }
- return false;
- };
- },
- // 选择按钮的显示
- isSelectShow() {
- if (this.form.planType == 5) {
- return true;
- }
- return this.processingRequired == 0;
- },
- // clientEnvironmentId() {
- // return this.$store.state.user.info.clientEnvironmentId;
- // },
- columns() {
- return [
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true
- },
- {
- slot: 'lineNumber',
- prop: 'lineNumber',
- label: '行号',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'productName',
- prop: 'productName',
- label: '名称',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'productCode',
- prop: 'productCode',
- label: '编码',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'brandNo',
- prop: 'brandNo',
- label: '牌号',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'model',
- prop: 'model',
- label: '型号',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'specification',
- prop: 'specification',
- label: '规格',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'productUnitWeight',
- prop: 'productUnitWeight',
- label: '单重',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'weightUnit',
- prop: 'weightUnit',
- label: '重量单位',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'modelKey',
- prop: 'modelKey',
- label: '机型',
- align: 'center',
- minWidth: 240
- },
- {
- slot: 'colorKey',
- prop: 'colorKey',
- label: '颜色',
- align: 'center',
- minWidth: 240
- },
- {
- slot: 'requiredFormingNum',
- prop: 'requiredFormingNum',
- headerSlot: 'headeRequiredFormingNum',
- label: '要求生产数量',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'measuringUnit',
- prop: 'measuringUnit',
- label: '计量单位',
- align: 'center',
- minWidth: 140
- },
- // {
- // slot: 'productionCodes',
- // prop: 'productionCodes',
- // label: '生产编号',
- // align: 'center',
- // minWidth: 140
- // },
- {
- slot: 'moCount',
- prop: 'moCount',
- label: '模数',
- headerSlot: 'headeRequiredFormingNum',
- align: 'center',
- minWidth: 140,
- show: this.clientEnvironmentId == 4
- },
- {
- slot: 'blockCount',
- prop: 'blockCount',
- label: '块数',
- headerSlot: 'headeRequiredFormingNum',
- align: 'center',
- minWidth: 140,
- show: this.clientEnvironmentId == 4
- },
- {
- slot: 'productType',
- prop: 'productType',
- label: '生产类型',
- headerSlot: 'headerProcessingBOM',
- align: 'center',
- minWidth: 180
- },
- {
- slot: 'bomCategoryId',
- prop: 'bomCategoryId',
- label: 'BOM版本',
- headerSlot: 'headerProcessingBOM',
- align: 'center',
- minWidth: 180,
- show: this.clientEnvironmentId !== 4
- },
- {
- slot: 'produceRoutingId',
- prop: 'produceRoutingId',
- headerSlot: 'headerProduceRoutingId',
- label: '工艺路线',
- align: 'center',
- minWidth: 240
- },
- {
- slot: 'factoriesId',
- prop: 'factoriesId',
- headerSlot: 'headerProduceRoutingId',
- label: '所属工厂',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'weight',
- prop: 'weight',
- label: '权重等级',
- align: 'center',
- minWidth: 140,
- show: this.clientEnvironmentId == 4
- },
- {
- slot: 'isSlotting',
- prop: 'isSlotting',
- label: '是否开槽',
- align: 'center',
- minWidth: 140,
- show: this.clientEnvironmentId == 4
- },
- {
- slot: 'slottingType',
- prop: 'slottingType',
- label: '开槽类型',
- align: 'center',
- minWidth: 140,
- show: this.clientEnvironmentId == 4
- },
- {
- slot: 'newSumOrderWeight',
- prop: 'newSumOrderWeight',
- label: '计划重量',
- align: 'center',
- minWidth: 140
- },
- {
- slot: 'set',
- prop: 'set',
- label: '操作',
- align: 'center',
- minWidth: 140,
- fixed: 'right'
- }
- ];
- }
- },
- data() {
- return {
- visible: false,
- factoriesId: '',
- clientEnvironmentId: '',
- title: '新增临时生产计划',
- type: 3,
- weightList: [
- { code: 1, name: 'A' },
- { code: 2, name: 'B' },
- { code: 3, name: 'C' }
- ],
- factoryList: [],
- isSlotting: [
- { code: 1, name: '是' },
- { code: 2, name: '否' }
- ], //是否开槽
- planTypeList: [
- { label: '内销计划', value: 1 },
- { label: '外销计划', value: 2 },
- { label: '预制计划', value: 3 },
- { label: '改型计划', value: 4 },
- { label: '返工返修计划', value: 5 }
- ],
- loading: false,
- form: {
- timeDimensionPlanType: 3,
- categoryId: '',
- productName: '',
- planType: '',
- moCount: '', // 模具数量
- blockCount: 0, // 块数
- noWordCount: '', // 无字数量
- weight: '',
- startTime: '',
- endTime: '',
- isSlotting: '', //是否开槽
- slottingType: '', //开槽类型
- id: '',
- produceType: 2,
- bomCategoryId: '',
- produceRoutingId: '',
- requiredFormingNum: '',
- productInfoList: []
- },
- disabledList: [],
- bomVersionList: [],
- routingList: [],
- rules: {
- productName: [
- { required: true, message: '请选择名称', trigger: 'change' }
- ],
- bomCategoryId: [
- { required: true, message: '请选择BOM版本', trigger: 'blur' }
- ],
- planType: [
- { required: true, message: '请选择计划类型', trigger: 'blur' }
- ],
- produceType: [
- { required: true, message: '请选择工艺路线', trigger: 'blur' }
- ],
- produceRoutingId: [
- { required: true, message: '请选择工艺路线', trigger: 'blur' }
- ],
- startTime: [
- { required: true, message: '请选择计划开始日期', trigger: 'blur' }
- ],
- endTime: [
- { required: true, message: '请选择计划结束日期', trigger: 'blur' }
- ],
- // reqMoldTime: [
- // { required: true, message: '请选择要求完成日期', trigger: 'blur' }
- // ],
- requiredFormingNum: [
- { required: true, message: '请输入生产数量', trigger: 'blur' }
- ]
- },
- producedList: [
- { code: 2, name: '加工(MBOM)' },
- { code: 3, name: '装配(ABOM)' }
- ],
- selectIndex: 0, // 选择工艺路线的当前数据下标
- processingRequired: 0, // 生产类型跟BOM 版本是否必填 1:是 0:否
- isReview: false
- // selectionRowShow: false // 工艺路线输入框展示 状态
- };
- },
- // computed: {
- // clientEnvironmentId() {
- // return this.$store.state.user.info.clientEnvironmentId;
- // }
- // },
- mounted() {
- this.getCodeData();
- // 生产类型跟BOM版本字段是否必填
- parameterGetByCode({
- code: 'production_plan_code'
- }).then((res) => {
- console.log(res, 'res 1');
- if (res) {
- this.processingRequired = res.value;
- }
- });
- this.getplannedReleaseRequire('planned_release_require');
- },
- methods: {
- // 获取
- async getCodeData() {
- let arr1 = await this.getLevelCode('product_model_key');
- let arr2 = await this.getLevelCode('product_color_key');
- this.modelList = arr1;
- this.colorList = arr2;
- },
- async getLevelCode(code) {
- try {
- const res = await getByCode(code);
- if (res.code == 0) {
- let list = Object.values(res.data).map((el) => {
- let k = Object.keys(el)[0];
- let v = Object.values(el)[0];
- return {
- label: v,
- value: k
- };
- });
- return list;
- }
- } catch (err) {
- this.$message.error(err.message);
- }
- },
- selectFactory(e, row) {
- let data = this.factoryList.find((item) => item.id === e);
- this.$set(row, 'factoriesName', data.name);
- },
- async getplannedReleaseRequire(code) {
- parameterGetByCode({ code }).then((res) => {
- if (res) {
- this.isReview = res.value == '1' ? true : false;
- }
- });
- },
- // 打开工艺路线
- openDialog(index) {
- this.selectIndex = index;
- this.$refs.processRouteRef.open();
- },
- // 选择工艺路线
- changeParent(item) {
- let data = this.form.productInfoList[this.selectIndex];
- this.$set(data, 'bomVersionList', []);
- this.$set(data, 'bomCategoryId', '');
- this.$set(data, 'model', '');
- this.$set(data, 'routingList', []);
- this.$set(data, 'productType', '');
- this.$set(data, 'produceRoutingName', item.name);
- this.$set(data, 'produceRoutingId', item.id);
- this.$set(data, 'selectionRowShow', true);
- // this.selectionRowShow = true;
- },
- async getFactoryList() {
- this.factoryList = await getFactoryList();
- },
- async open(val) {
- await this.getFactoryList();
- this.clientEnvironmentId =
- this.$store.state.user.info.clientEnvironmentId;
- this.factoriesId = this.$store.state.user.info.factoryId;
- if (val) {
- if (val.planType == null || val.planType == 'null') {
- val.planType = '';
- }
- this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
- val.planType = String(val.planType);
- this.form = await getUpdateInfoByCode(val.code);
- // 修改
- if (val.id) {
- if (
- Array.isArray(val.productInfoList) &&
- val.productInfoList.length
- ) {
- this.form.productInfoList.map(async (v, index) => {
- if (!v.bomCategoryId) {
- v.productType = '';
- v.selectionRowShow = true;
- } else {
- v.selectionRowShow = false;
- }
- if (v.productType) {
- this.$set(
- this.form.productInfoList[index],
- 'bomVersionList',
- await this.bomListVersionFn(v.productType, v.categoryId)
- );
- }
- if (v.bomCategoryId) {
- this.$set(
- this.form.productInfoList[index],
- 'routingList',
- await this.changeBomIdFn(
- v.bomCategoryId,
- this.form.productInfoList[index]
- )
- );
- }
- });
- }
- // let categoryId = this.form.productInfoList[0].categoryId;
- // const res = await findBomCategoryByCategoryId(categoryId);
- let promiseAll = [];
- this.form.productInfoList.forEach(async (item) => {
- let categoryId = item.categoryId;
- promiseAll.push(findBomCategoryByCategoryId(categoryId));
- });
- const resAll = await Promise.all(promiseAll);
- console.log(this.form.productInfoList);
- this.form.productInfoList.forEach((item, index) => {
- if (item.colorKey && typeof item.colorKey == 'string') {
- this.$set(
- this.form.productInfoList[index],
- 'colorKey',
- item.colorKey.split(',')
- );
- }
- if (item.modelKey && typeof item.modelKey == 'string') {
- this.$set(
- this.form.productInfoList[index],
- 'modelKey',
- item.modelKey.split(',')
- );
- }
- if (resAll[index]) {
- let list = [];
- let listMap = {};
- resAll[index].map((el) => {
- if (el.bomType == '2' || el.bomType == '3') {
- console.log(listMap, 'listMap');
- if (listMap[el.bomType]) {
- listMap[el.bomType].push(el);
- } else {
- listMap[el.bomType] = [el];
- }
- }
- });
- if (listMap[2]) {
- list.push({ code: 2, name: 'MBOM' });
- }
- if (listMap[3]) {
- list.push({ code: 3, name: 'ABOM' });
- }
- if (!item.factoriesId) {
- this.$set(
- this.form.productInfoList[index],
- 'factoriesId',
- this.factoriesId
- );
- this.$set(
- this.form.productInfoList[index],
- 'factoriesName',
- this.factoryList?.find(
- (factoryData) => factoryData.id === this.factoriesId
- )?.name
- );
- }
- this.$set(
- this.form.productInfoList[index],
- 'producedList',
- list
- );
- }
- });
- }
- this.$forceUpdate();
- } else {
- this.title = '新增临时生产计划';
- }
- this.visible = true;
- // this.$nextTick(async () => {
- // console.log(val.productInfoList);
- // this.$set(this.form, 'productInfoList', val.productInfoList);
- // this.$set(this.form, 'routingList', val.routingList);
- // });
- //this.clientEnvironmentId 环境判断 宝悦环境
- // if (this.clientEnvironmentId == 4) {
- // this.getPlanRoutingNew();
- // }
- // this.getPlanRoutingNew();
- },
- addEquipment() {
- this.$refs.equipmentRefs.open();
- },
- async confirmChoose(data) {
- let list = deepClone(data);
- list.map((el) => (el.selectionRowShow = false));
- if (this.clientEnvironmentId == 4) {
- list.map((v) => {
- if (v.name.includes('板材')) {
- v.produceRoutingId = '1856970794952372226';
- v.produceRoutingName = '板材';
- v.produceVersionName = '板材';
- } else {
- (v.produceRoutingId = '1857313733642596353'),
- (v.produceRoutingName = '砌块'),
- (v.produceVersionName = '砌块');
- }
- });
- }
- let ids = this.form.productInfoList.map((item) => item.categoryId);
- let result = list
- .filter((i) => !ids.includes(i.id))
- .map((item, index) => {
- return {
- categoryId: item.id,
- productCode: item.code,
- productName: item.name,
- productUnitWeight: item.netWeight,
- weightUnit: item.weightUnit,
- model: item.modelType,
- specification: item.specification,
- brandNo: item.brandNum,
- measuringUnit: item.measuringUnit,
- produceRoutingId: item.produceRoutingId,
- produceRoutingName: item.produceRoutingName,
- produceVersionName: item.produceVersionName,
- factoriesId: this.factoriesId,
- colorKey: item.colorKey ? item.colorKey.split(',') : [],
- modelKey: item.modelKey ? item.modelKey.split(',') : [],
- factoriesName: this.factoryList?.find(
- (factoryData) => factoryData.id === this.factoriesId
- )?.name
- };
- });
- // this.form.productInfoList = [];
- // 取出在弹窗中选中并且不在表格中的数据
- // const result = list.filter(
- // (i) =>
- // this.form.productInfoList.findIndex(
- // (p) => p.productCode === i.productCode
- // ) === -1
- // );
- // // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
- // const del = this.form.productInfoList.filter(
- // (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
- // );
- // for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
- // for (let j in del) {
- // if (
- // this.form.productInfoList[i].productCode === del[j].productCode
- // ) {
- // this.form.productInfoList.splice(i, 1);
- // break;
- // }
- // }
- // }
- let promiseAll = [];
- result.forEach(async (item) => {
- let categoryId = item.categoryId;
- promiseAll.push(findBomCategoryByCategoryId(categoryId));
- });
- const resAll = await Promise.all(promiseAll);
- try {
- await result.forEach(async (item, index) => {
- if (resAll[index]) {
- let listMap = {};
- let list = [];
- let arr = [];
- resAll[index].map((el) => {
- if (el.bomType == '2' || el.bomType == '3') {
- console.log(listMap, 'listMap');
- if (listMap[el.bomType]) {
- listMap[el.bomType].push(el);
- } else {
- listMap[el.bomType] = [el];
- }
- }
- });
- if (listMap[2]) {
- list.push({ code: 2, name: 'MBOM' });
- arr = listMap[2];
- item.productType = 2;
- }
- if (listMap[3]) {
- list.push({ code: 3, name: 'ABOM' });
- if (!listMap[2]) {
- arr = listMap[3];
- item.productType = 3;
- }
- }
- if (arr.length > 0) {
- arr.map((el) => (el.bomCategoryId = el.id));
- item.bomCategoryId = arr[0].id;
- await this.changeBomId(arr[0], 0);
- this.$set(item, 'produceRoutingId', arr[0].produceRoutingId);
- this.$set(
- item,
- 'produceVersionName',
- arr[0].produceVersionName
- );
- this.$set(
- item,
- 'produceRoutingName',
- arr[0].produceRoutingName
- );
- console.log(arr[0], 'arr[0]');
- this.$set(item, 'routingList', arr[0].routingList);
- this.$set(item, 'bomCategoryName', arr[0].name);
- this.$set(item, 'bomCategoryVersions', arr[0].versions);
- }
- item.producedList = list;
- item.bomVersionList = arr;
- return item;
- }
- });
- } catch (err) {}
- console.log(result, 'result');
- // return
- this.form.productInfoList.push(...result);
- this.changeLineNumber();
- console.log(this.form.productInfoList, 'this.form.productInfoList');
- this.$refs.tableRef.setData(this.form.productInfoList);
- // console.log(this.form.productInfoList, 'this.form.productInfoList');
- //重置
- this.$set(this.form, 'produceType', '');
- this.$set(this.form, 'bomCategoryId', '');
- this.$set(this.form, 'produceRoutingId', '');
- },
- changeLineNumber() {
- this.form.productInfoList.forEach((item, index) => {
- let data = this.form.productInfoList[index - 1];
- this.$set(
- this.form.productInfoList[index],
- 'lineNumber',
- data ? data.lineNumber + 10 : 10
- );
- });
- },
- handleDeleteItem(index) {
- this.$confirm('确定删除当前数据?', '提示')
- .then(() => {
- const newArray = this.form.productInfoList.filter(
- (item, i) => i !== index
- );
- this.form.productInfoList = newArray;
- this.$refs.tableRef.setData(newArray);
- })
- .catch(() => {});
- },
- async getPlanCode() {
- this.loading = true;
- try {
- const code = await getCode('product_code');
- this.$set(this.form, 'code', code);
- } catch (err) {}
- },
- initForm() {
- this.form = {
- timeDimensionPlanType: 3,
- categoryId: '',
- productName: '',
- planType: '',
- moCount: '', // 模具数量
- blockCount: 0, // 块数
- noWordCount: '', // 无字数量
- weight: '',
- isSlotting: '', //是否开槽
- slottingType: '', //开槽类型
- id: '',
- produceType: 2,
- status: 2,
- bomCategoryId: '',
- produceRoutingId: '',
- productInfoList: [],
- requiredFormingNum: ''
- };
- // console.log(this.$refs);
- // this.$refs.tableRef.setData([]);
- },
- changeBomIdFn(bomCategoryId, row) {
- return new Promise((resolve, reject) => {
- bomRoutingList(bomCategoryId).then((res) => {
- let arr = res || [];
- if (arr.length == 0) {
- row.produceRoutingId = '';
- }
- resolve(arr);
- });
- });
- },
- // 选择BOM
- async changeBomId(row, index, bomData, typeChange) {
- if (bomData) {
- row.bomCategoryName = bomData.name;
- row.bomCategoryVersions = bomData.versions;
- }
- // row.routingList = []
- return await bomRoutingList(row.bomCategoryId).then((res) => {
- let arr = res || [];
- if (arr.length > 0) {
- // this.$nextTick(() => {
- row.produceRoutingName = arr[0].name;
- row.produceVersionName = arr[0].version;
- row.produceRoutingId = arr[0].id;
- row.routingList = arr;
- if (typeChange) {
- this.$set(this.form.productInfoList[index], 'routingList', arr);
- this.$set(
- this.form.productInfoList[index],
- 'produceRoutingId',
- arr[0].id
- );
- } else {
- this.$set(row, 'produceRoutingId', arr[0].id);
- this.$set(row, 'routingList', arr);
- }
- row.selectionRowShow = false;
- console.log(row.routingList, 'this.form.productInfoList');
- // });
- }
- this.$forceUpdate();
- });
- },
- contactDialogSuccess(data) {
- console.log(data, 'data 11');
- // serialNo
- this.form.serialNo = data.serialNo;
- this.$set(this.form, 'customerName', data.name);
- },
- // 清空BOM 跟工艺路线
- wipeData(index) {
- this.$set(this.form.productInfoList[index], 'bomCategoryId', '');
- this.$set(this.form.productInfoList[index], 'routingList', []);
- this.$set(this.form.productInfoList[index], 'bomVersionList', []);
- this.$set(this.form.productInfoList[index], 'produceRoutingId', '');
- this.$set(this.form.productInfoList[index], 'produceRoutingName', '');
- this.$set(this.form.productInfoList[index], 'produceVersionName', '');
- this.$set(this.form.productInfoList[index], 'selectionRowShow', false);
- // this.selectionRowShow = false;
- },
- // 选择生产类型
- changeProductType(row, index) {
- let param = {
- bomType: row.productType,
- categoryId: row.categoryId
- };
- this.wipeData(index);
- // row.bomCategoryId = '';
- // this.form.productInfoList[index].bomVersionList = [];
- bomListByPlan(param).then((res) => {
- let arr = res || [];
- this.$nextTick(() => {
- if (arr.length) {
- row.bomVersionList = arr;
- this.form.productInfoList[index].bomVersionList = arr;
- row.bomCategoryId = arr[0].id;
- this.changeBomId(row, index, arr[0], 'typeChange');
- let arrAll = JSON.parse(JSON.stringify(this.form));
- this.$set(this, 'form', arrAll);
- }
- });
- // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
- });
- },
- // 参数校验
- parameterVerification() {
- let flag = true;
- this.form.productInfoList.forEach((v) => {
- if (this.isRequired) {
- if (!v.productType) {
- flag = false;
- this.$message.warning('请选择生产类型');
- return;
- }
- if (!v.bomCategoryId) {
- flag = false;
- this.$message.warning('请选择BOM版本');
- return;
- }
- }
- if (!v.produceRoutingId) {
- flag = false;
- this.$message.warning('请选择工艺路线');
- return;
- }
- if (!v.factoriesId) {
- flag = false;
- this.$message.warning('请选择所属工厂');
- return;
- }
- if (v.requiredFormingNum == 0) {
- flag = false;
- this.$message.warning('要求生产数量不能为0');
- return;
- }
- if (!v.requiredFormingNum) {
- flag = false;
- this.$message.warning('请输入要求生产数量');
- return;
- }
- if (!v.moCount && this.clientEnvironmentId == 4) {
- flag = false;
- this.$message.warning('请输入模数');
- return;
- }
- if (!v.blockCount && this.clientEnvironmentId == 4) {
- flag = false;
- this.$message.warning('请输入块数');
- return;
- }
- });
- return flag;
- },
- save(type) {
- this.$refs.form.validate(async (valid) => {
- if (!valid) {
- return false;
- }
- let flag = this.parameterVerification();
- // 必填参数校验
- if (!flag) return;
- this.form.productInfoList.forEach((item, index) => {
- this.$set(
- this.form.productInfoList[index],
- 'colorKey',
- item.colorKey.toString()
- );
- this.$set(
- this.form.productInfoList[index],
- 'modelKey',
- item.modelKey.toString()
- );
- });
- // this.
- if (!this.form.id) {
- if (this.form.productInfoList.length) {
- this.form.productInfoList.map((item, index) => {
- delete item.selectionRowShow;
- // if (item.bomVersionList && item.bomVersionList.length) {
- // item.bomCategoryName = item.bomVersionList[0].name;
- // item.bomCategoryVersions = item.bomVersionList[0].versions;
- // item.produceRoutingName = item.routingList[0].name;
- // }
- });
- }
- this.form.timeDimensionPlanType = this.type;
- await this.getPlanCode();
- this.loading = true;
- let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
- api(this.form)
- .then((res) => {
- this.$message.success('新增成功!');
- this.visible = false;
- this.initForm();
- this.$emit('close', true);
- })
- .finally(() => {
- this.loading = false;
- });
- } else {
- this.loading = true;
- let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
- // return
- api(this.form)
- .then((res) => {
- this.$message.success('修改成功!');
- this.visible = false;
- this.initForm();
- this.$emit('close', true);
- })
- .finally(() => {
- this.loading = false;
- });
- }
- });
- },
- bomListVersionFn(produceType, categoryId) {
- return new Promise((resolve, reject) => {
- let param = {
- bomType: produceType,
- categoryId: categoryId
- };
- bomListByPlan(param).then((res) => {
- this.bomVersionList = res || [];
- resolve(res || []);
- });
- });
- },
- bomListVersion() {
- let param = {
- bomType: this.form.produceType,
- categoryId: this.form.categoryId
- };
- bomListByPlan(param).then((res) => {
- this.$nextTick(() => {
- this.bomVersionList = res || [];
- console.log(res, 'res 000');
- });
- });
- },
- // 工艺路线
- getPlanRouting() {
- bomRoutingList(this.form.bomCategoryId).then((res) => {
- this.routingList = res || [];
- });
- },
- // 宝悦 工艺路线
- getPlanRoutingNew() {
- // bomRoutingList(this.form.bomCategoryId).then((res) => {
- // this.routingList = res || []
- // })
- },
- tableHandleKeyUp(row, name) {
- // return
- // , index, e, name
- if (name == 'procut') {
- return;
- }
- if (row.specification && this.clientEnvironmentId == 4) {
- let modelArr = row.specification.split('*');
- let modelLong = modelArr[0]; // model规格长度
- let modeWide = modelArr[1]; // model规格宽度
- let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
- modeHight = Number(modeHight);
- if (name === 'moCount') {
- // 模数
- this.$set(row, 'moCount', row.moCount);
- // 计算块数的公式:
- // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
- // 每一模的块数*模数moCount = 总块数
- if (row.productName.includes('板材')) {
- // 块数
- let blockCount =
- Math.floor(600 / modelLong) *
- Math.floor(120 / modeHight) *
- Math.floor(60 / modeWide) *
- row.moCount;
- row['blockCount'] = blockCount;
- // this.$set(row, 'blockCount', blockCount);
- } else if (row.productName.includes('砌块')) {
- let modelLongFixed = (600 / modelLong).toFixed(2);
- modelLongFixed = modelLongFixed.substring(
- 0,
- modelLongFixed.length - 1
- );
- let modeWideFixed = (120 / modeWide).toFixed(2);
- modeWideFixed = modeWideFixed.substring(
- 0,
- modeWideFixed.length - 1
- );
- let modeHightFixed = (60 / modeHight).toFixed(2);
- modeHightFixed = modeHightFixed.substring(
- 0,
- modeHightFixed.length - 1
- );
- let num =
- Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
- row.moCount;
- row['blockCount'] = num;
- }
- let numNew = (
- Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
- row.blockCount
- ).toFixed(5);
- row['requiredFormingNum'] = numNew;
- } else if (name === 'sum') {
- let e = row.requiredFormingNum;
- row.blockCount = Math.floor(
- e / ((modelLong * modeWide * modeHight) / 1000000)
- );
- if (row.productName.includes('板材')) {
- let num = Math.ceil(
- row.blockCount /
- (Math.floor(600 / modelLong) *
- Math.floor(120 / modeHight) *
- Math.floor(60 / modeWide))
- );
- // 48 480 4807 480
- row.moCount = num;
- } else if (row.productName.includes('砌块')) {
- row.moCount = Math.ceil(
- row.blockCount /
- Math.floor(
- (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
- )
- );
- }
- } else if (name === 'blockCount') {
- //块数
- // row.blockCount = row.moCount;
- row.blockCount = row.blockCount;
- if (row.productName.includes('板材')) {
- let moCount = Math.ceil(
- row.blockCount /
- (Math.floor(600 / modelLong) *
- Math.floor(120 / modeHight) *
- Math.floor(60 / modeWide))
- );
- row.moCount = moCount;
- } else if (row.productName.includes('砌块')) {
- let moCount = Math.ceil(
- row.blockCount /
- Math.floor(
- (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
- )
- );
- this.$set(this.form, 'moCount', moCount);
- row.moCount = moCount;
- }
- let a = (
- (Number(row.blockCount) * modelLong * modeWide * modeHight) /
- 1000000
- ).toFixed(5);
- row.requiredFormingNum = a;
- }
- }
- },
- // 数量正则 quantity
- handleQuantityInput(e, row) {
- // 过滤非数字字符(包括负号)
- let value = e.replace(/[^\d.]/g, '');
- // value = value.replace(/-/g, '');
- // 限制不能以 0 开头(除非是 0 本身)
- // if (value.startsWith('0') && value.length > 1) {
- // value = value.slice(1);
- // }
- // 更新绑定值
- row.requiredFormingNum = value;
- // if (
- // item.weightUnit == 'G' ||
- // item.weightUnit == 'g' ||
- // item.weightUnit == '克'
- // ) {
- // let total =
- // ((item.requiredFormingNum - 0) * item.productUnitWeight) /
- // 1000;
- // item.newSumOrderWeight = total.toFixed(2);
- // item.newWeightUnit = 'KG';
- // } else {
- // item.newWeightUnit = item.weightUnit;
- // item.newSumOrderWeight = item.requiredFormingNum;
- // }
- row.newWeightUnit = row.weightUnit;
- if (row.weightUnit == row.measuringUnit) {
- row.newSumOrderWeight = row.requiredFormingNum;
- } else if (row.requiredFormingNum && row.productUnitWeight) {
- row.newSumOrderWeight =
- row.requiredFormingNum * row.productUnitWeight;
- } else {
- row.newSumOrderWeight = 0;
- }
- row.productWeight = row.newSumOrderWeight;
- this.tableHandleKeyUp(row, 'sum');
- },
- changeProduceType(e) {
- if (this.clientEnvironmentId !== 4) {
- this.form.bomCategoryId = '';
- this.form['bomCategoryName'] = '';
- this.form['bomCategoryVersions'] = '';
- this.bomVersionList = [];
- this.routingList = [];
- this.form.produceRoutingId = '';
- this.form.produceRoutingName = '';
- this.form.produceVersionName = '';
- this.bomListVersion();
- }
- },
- // changeBomId() {
- // this.routingList = [];
- // this.form.produceRoutingId = '';
- // this.form.produceRoutingName = '';
- // this.form.produceVersionName = '';
- // this.bomVersionList.forEach((f) => {
- // if (f.id == this.form.bomCategoryId) {
- // this.$set(this.form, 'bomCategoryName', f.name);
- // this.$set(this.form, 'bomCategoryVersions', f.versions);
- // }
- // });
- // this.getPlanRouting();
- // },
- changeRoute() {
- this.$forceUpdate();
- this.routingList.forEach((f) => {
- if (f.id == this.form.produceRoutingId) {
- this.$set(this.form, 'produceRoutingId', f.id);
- this.$set(this.form, 'produceRoutingName', f.name);
- this.$set(this.form, 'produceVersionName', f.version);
- }
- });
- },
- cancel() {
- this.visible = false;
- this.initForm();
- this.$emit('close');
- },
- // 【开始时间变化时】触发
- handleStartTimeChange(row) {
- // 校验 是否 大于结束时间 wda
- this.checkEndTimeValid(row);
- },
- // 【结束时间变化时】触发
- handleEndTimeChange(row) {
- // 校验 是否 大于结束时间 wda
- this.checkEndTimeValid(row);
- },
- handleCompleteChange(row) {
- const { reqMoldTime } = row;
- if (!row.startTime) {
- row.reqMoldTime = '';
- return this.$message.warning('请选择计划开始时间');
- }
- this.handleComplete(reqMoldTime, row);
- },
- handleComplete(reqMoldTime, row) {
- const startTime = new Date(row.startTime).getTime();
- const completeTime = new Date(reqMoldTime).getTime();
- if (completeTime < startTime) {
- row.reqMoldTime = ''; // 修正为开始时间
- return this.$message.warning(
- '要求完成时间不能早于计划开始时间, 请重新选择要求完成时间'
- );
- }
- },
- // 时间校验
- checkEndTimeValid(row) {
- const { startTime: start, endTime: end } = row;
- this.handleChange(start, end, row);
- // // if (!start || !end) return; // 开始/结束时间未填,跳过
- // const startTime = new Date(start); // 开始时间
- // const endTime = new Date(end); // 结束时间
- // if (endTime < startTime) {
- // row.endTime = new Date(startTime); // 修正为开始时间
- // this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
- // }
- },
- handleChange(start, end, row) {
- const startTime = new Date(start).getTime();
- const endTime = new Date(end).getTime();
- if (endTime < startTime) {
- row.endTime = ''; // 修正为开始时间
- return this.$message.warning(
- '计划结束时间不能早于计划开始时间,请重新选择计划结束时间'
- );
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .el-form-item {
- margin-bottom: 14px !important;
- }
- .add-product {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- font-size: 30px;
- color: #1890ff;
- margin: 10px 0;
- cursor: pointer;
- }
- .header_required {
- .is-required:before {
- content: '*';
- color: #f56c6c;
- margin-right: 4px;
- }
- }
- </style>
|