| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982 |
- <template>
- <div class="ele-body">
- <el-card shadow="never">
- <div class="body-title">
- <div class="title-left">{{
- type == 'edit' ? '计划修改' : '销售订单转生产计划'
- }}</div>
- <div class="title-right">
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" @click="toSubmit" :loading="loading">
- 提交计划
- </el-button>
- </div>
- </div>
- <el-form
- ref="form"
- :model="form"
- :rules="rules"
- label-width="110px"
- class="formbox"
- >
- <el-row :gutter="24">
- <el-col v-bind="styleResponsive ? { lg: 4, md: 8 } : { span: 4 }">
- <el-form-item label="计划类型:">
- <DictSelection
- dictName="订单计划类型"
- clearable
- v-model="form.planType"
- disabled
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 5, md: 8 } : { span: 4 }">
- <el-form-item
- label="BOM类型:"
- :class="isRequired ? 'header_required' : ''"
- >
- <el-select
- v-model="form.produceType"
- style="width: 100%"
- @change="changeProduceType"
- >
- <el-option
- v-for="item of producedList"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col
- v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }"
- v-if="clientEnvironmentId != 4"
- >
- <el-form-item
- label="BOM版本:"
- :class="isRequired ? 'header_required' : ''"
- >
- <el-select
- v-model="form.bomCategoryId"
- style="width: 100%"
- @change="changeBomId"
- >
- <el-option
- v-for="item of bomVersionList"
- :key="item.id"
- :label="item.name + '(V' + item.versions + '.0)'"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col
- v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }"
- v-if="clientEnvironmentId != 4"
- >
- <el-form-item label="工艺路线:" prop="produceRoutingId">
- <!-- @click.native="openVersion" -->
- <div style="display: flex">
- <el-select
- v-model="form.produceRoutingId"
- style="width: 100%"
- @change="changeRoute"
- v-show="isRouteSelect"
- >
- <el-option
- v-for="item of routingList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- <div
- :style="{
- display: 'flex',
- width: !isRouteSelect ? '100%' : ''
- }"
- >
- <el-input
- v-show="!isRouteSelect"
- disabled
- v-model="form.produceRoutingName"
- style="width: 100%"
- ></el-input>
- <el-button
- v-show="isSelectShow"
- type="primary"
- size="mini"
- @click="openDialog"
- >选择</el-button
- >
- </div>
- </div>
- </el-form-item>
- </el-col>
- <el-col
- v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }"
- v-if="clientEnvironmentId == 4"
- >
- <el-form-item label="工艺路线:" prop="produceRoutingId">
- <el-input
- v-model="form.produceRoutingName"
- style="width: 100%"
- readonly
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }">
- <el-form-item label="库存数量:" prop="stockCountBase">
- <el-input
- v-model="form.stockCountBase"
- style="width: 100%"
- readonly
- :disabled="true"
- ></el-input>
- </el-form-item>
- </el-col>
- <!-- <el-col v-bind="styleResponsive ? { lg: 3, md: 6 } : { span: 3 }">
- <el-form-item label="使用改型:" prop="modification">
- <el-checkbox
- v-model="form.modification"
- :true-label="1"
- :false-label="0"
- ></el-checkbox>
- </el-form-item>
- </el-col> -->
- </el-row>
- <el-row :gutter="24">
- <el-col v-bind="styleResponsive ? { lg: 4, md: 8 } : { span: 4 }">
- <el-form-item label="余量系数:" prop="marginCoefficient">
- <el-select
- v-model="form.marginCoefficient"
- filterable
- allow-create
- @change="itemChange"
- >
- <el-option
- v-for="(item, index) in marginList"
- :key="index"
- :label="item.name"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }">
- <el-form-item
- class="header_time_required"
- label="计划开始日期:"
- prop="startTime"
- >
- <el-date-picker
- style="width: 100%"
- v-model="form.startTime"
- :pickerOptions="{
- disabledDate: function (time) {
- return validDate.startDisabledDate(form, 'endTime', time);
- }
- // time.getTime() <
- // new Date(new Date().setHours(0, 0, 0, 0)).getTime()
- }"
- type="datetime"
- placeholder="选择日期"
- value-format="yyyy-MM-dd HH:mm:ss"
- @change="handleStartTimeChange(form)"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }">
- <el-form-item
- class="header_time_required"
- label="计划结束日期:"
- prop="endTime"
- >
- <el-date-picker
- style="width: 100%"
- v-model="form.endTime"
- :pickerOptions="{
- disabledDate: (time) =>
- validDate.endDisabledDate(form, 'startTime', time),
- disabledTime: (date) =>
- validDate.endDisabledTime(form, 'startTime', date)
- // time.getTime() <
- // new Date(new Date().setHours(0, 0, 0, 0)).getTime()
- }"
- type="datetime"
- placeholder="选择日期"
- value-format="yyyy-MM-dd HH:mm:ss"
- @change="handleEndTimeChange(form)"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }">
- <!-- prop="factoriesId" -->
- <el-form-item label="所属工厂:" required>
- <el-select
- v-model="form.factoriesId"
- style="width: 100%"
- @change="factoriesIdFn"
- >
- <el-option
- v-for="item of factoryList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <!-- <el-form-item label="生产类型:" prop="produceType">
- <el-select v-model="form.produceType" style="width: 100%" @change="changeProduceType" >
- <el-option
- v-for="item of producedList"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- ></el-option>
- </el-select>
- </el-form-item> -->
- </el-row>
- <el-row> </el-row>
- <el-row :gutter="24" class="row-intro product_info">
- <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
- <el-form-item label-width="88px" label="销售单数量:">{{
- form.codeNum
- }}</el-form-item>
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
- <el-form-item label-width="88px" label="订单总数量:"
- >{{ form.contractNum }}{{ form.measuringUnit }}</el-form-item
- >
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 4 }">
- <el-form-item label-width="88px" label="订单总重量:">{{
- form.sumOrderWeight
- }}</el-form-item>
- </el-col>
- <el-col
- style="padding: 0 0"
- v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }"
- >
- <el-form-item
- label-width="80px"
- class="product_code_name"
- label="产品编码:"
- ><span>{{ form.productCode }}</span></el-form-item
- >
- </el-col>
- <el-col
- style="padding: 0 0 0 5px"
- v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }"
- >
- <el-form-item label-width="50px" label="牌号:">{{
- form.brandNo
- }}</el-form-item>
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 5 }">
- <el-form-item label-width="50px" label="型号:">{{
- form.model
- }}</el-form-item>
- </el-col>
- <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 3 }">
- <el-form-item label-width="50px" label="规格:">{{
- form.specification
- }}</el-form-item>
- </el-col>
- <!-- <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
- <el-form-item label="库存数量:">{{
- form.stockCountBase
- }}</el-form-item>
- </el-col> -->
- </el-row>
- <el-table :data="form.salesOrders" border>
- <el-table-column label="序号" align="center" width="60">
- <template slot-scope="scope">
- <span>{{ scope.$index + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="销售订单号"
- align="center"
- prop="code"
- width="120"
- sortable
- >
- </el-table-column>
- <el-table-column
- label="产品名称"
- align="center"
- prop="productName"
- width="120"
- >
- </el-table-column>
- <el-table-column label="行号" align="center" prop="lineNumber">
- </el-table-column>
- <el-table-column
- :label="'订单数量' + (clientEnvironmentId == '4' ? '(方)' : '')"
- align="center"
- prop="contractNum"
- width="120"
- >
- <template slot-scope="scope">
- {{ scope.row.contractNum }}
- {{ scope.row.measuringUnit }}
- </template>
- </el-table-column>
- <el-table-column
- label="订单重量"
- align="center"
- prop="productSumWeight"
- width="120"
- >
- <template slot-scope="scope">
- {{ scope.row.productSumWeight }} {{ form.weightUnit }}
- </template>
- </el-table-column>
- <el-table-column
- label="下达时间"
- align="center"
- prop="releaseTime"
- width="170"
- >
- </el-table-column>
- <el-table-column label="规格" align="center" prop="specification">
- </el-table-column>
- <el-table-column
- label="生产编号"
- align="center"
- prop="productionCodes"
- >
- </el-table-column>
- <el-table-column
- :label="'欠交数量' + (clientEnvironmentId == '4' ? '(方)' : '')"
- align="center"
- prop="lackNum"
- >
- </el-table-column>
- <el-table-column
- label="机型"
- align="center"
- prop="modelKey"
- width="240"
- >
- <template slot-scope="scope">
- <el-select
- clearable
- v-model="scope.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>
- </el-table-column>
- <el-table-column
- label="颜色"
- align="center"
- prop="colorKey"
- width="240"
- >
- <template slot-scope="scope">
- <el-select
- clearable
- v-model="scope.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>
- </el-table-column>
- <el-table-column
- label="批次号"
- width="160"
- align="center"
- prop="batchNo"
- >
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.batchNo"
- size="small"
- style="width: 100%"
- placeholder="批次号"
- @input="
- (value) =>
- (scope.row.batchNo = value.replace(/[^a-zA-Z0-9_-]/g, ''))
- "
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column
- :label="'计划生产数量' + (clientEnvironmentId == '4' ? '(方)' : '')"
- align="center"
- prop="planProductNum"
- width="140"
- >
- <template slot-scope="scope">
- <el-form-item
- label-width="0px"
- :prop="'salesOrders.' + scope.$index + '.planProductNum'"
- :rules="{
- required: true,
- message: '请输入计划生产数量',
- trigger: 'blur'
- }"
- class="table-item"
- >
- <el-input
- v-model.number="scope.row.planProductNum"
- size="small"
- type="number"
- style="width: 100%"
- @input="
- tableHandleKeyUp(scope.row, scope.$index, $event, 'sum')
- "
- placeholder="输入数量"
- ></el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- :label="'要求生产数量' + (clientEnvironmentId == '4' ? '(方)' : '')"
- align="center"
- prop="requiredFormingNum"
- width="120"
- >
- <template slot-scope="scope">
- <el-form-item
- label-width="0px"
- :prop="'salesOrders.' + scope.$index + '.requiredFormingNum'"
- :rules="{
- required: true,
- message: '请输入要求生产数量',
- trigger: 'blur'
- }"
- class="table-item"
- >
- <el-input
- v-model.number="scope.row.requiredFormingNum"
- size="small"
- disabled
- oninput="value=value.replace(/[^\d]/g,'')"
- style="width: 100%"
- placeholder="输入数量"
- ></el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="模数"
- align="center"
- width="100"
- v-if="clientEnvironmentId == '4'"
- >
- <template slot-scope="scope">
- <div>
- <el-input
- style="width: 100%"
- size="small"
- v-model="scope.row.moCount"
- oninput="value=value.replace(/[^0-9.]/g,'')"
- @input="
- tableHandleKeyUp(scope.row, scope.$index, $event, 'moCount')
- "
- placeholder="请输入"
- >
- </el-input>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- width="100"
- v-if="clientEnvironmentId == '4'"
- >
- <template slot="header">
- <span style="color: red">*</span>
- <span>块数</span>
- </template>
- <template slot-scope="scope">
- <div>
- <el-input
- size="small"
- style="width: 100%"
- oninput="value=value.replace(/[^0-9.]/g,'')"
- @input="
- tableHandleKeyUp(
- scope.row,
- scope.$index,
- $event,
- 'blockCount'
- )
- "
- v-model="scope.row.blockCount"
- placeholder="请输入"
- ></el-input>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="权重等级"
- align="center"
- width="120"
- v-if="clientEnvironmentId == '4'"
- >
- <template slot-scope="scope">
- <div>
- <el-select v-model="scope.row.weight" style="width: 100%">
- <el-option
- v-for="item of weightList"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- ></el-option>
- </el-select>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- width="120"
- label="是否开槽"
- v-if="clientEnvironmentId == '4'"
- >
- <template slot-scope="scope">
- <div>
- <el-select
- style="width: 100%"
- v-model="scope.row.isSlotting"
- placeholder="请选择"
- >
- <el-option
- v-for="item of isSlotting"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- />
- </el-select>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- width="120"
- label="开槽类型"
- v-if="clientEnvironmentId == '4'"
- >
- <template slot-scope="scope">
- <DictSelection
- dictName="开槽类型"
- v-model="scope.row.slottingType"
- v-if="scope.row.isSlotting == 1"
- >
- </DictSelection>
- </template>
- </el-table-column>
- <el-table-column
- label="按单按库"
- align="center"
- prop="orderLibraryType"
- >
- <template slot-scope="{ row }">
- {{ getDictValue('按单按库', row.orderLibraryType) }}
- </template>
- </el-table-column>
- <el-table-column label="订单类型" align="center" prop="orderType">
- <template slot-scope="{ row }">
- {{ getDictValue('订单类型', row.orderType) }}
- </template>
- </el-table-column>
- <el-table-column
- label="客户期望交期"
- align="center"
- prop="deliveryTime"
- width="160"
- >
- <template slot-scope="scope">
- <el-form-item
- label-width="0px"
- :prop="'salesOrders.' + scope.$index + '.deliveryTime'"
- :rules="{
- required: false,
- message: '请选择客户期望交期',
- trigger: 'blur'
- }"
- class="table-item"
- >
- <el-date-picker
- style="width: 100%"
- v-model="scope.row.deliveryTime"
- @change="changeDate(scope.row, scope.$index)"
- :pickerOptions="{
- disabledDate: (time) =>
- time.getTime() <
- new Date(new Date().setHours(0, 0, 0, 0)).getTime()
- }"
- type="date"
- placeholder="选择日期"
- value-format="yyyy-MM-dd"
- >
- </el-date-picker>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="生产交期" align="center" width="160">
- <template slot-scope="scope">
- <el-form-item
- label-width="0px"
- :rules="{
- required: true,
- message: '请选择生产交期',
- trigger: 'blur'
- }"
- class="table-item"
- >
- <el-date-picker
- style="width: 100%"
- v-model="scope.row.produceDeliveryDeadline"
- @change="changeDate(scope.row, scope.$index)"
- :pickerOptions="{
- disabledDate: (time) =>
- time.getTime() <
- new Date(new Date().setHours(0, 0, 0, 0)).getTime()
- }"
- type="date"
- placeholder="选择日期"
- value-format="yyyy-MM-dd"
- disabled
- >
- </el-date-picker>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="要求完成日期"
- align="center"
- prop="reqMoldTime"
- width="180"
- >
- <template slot-scope="scope">
- <el-form-item
- label-width="0px"
- :prop="'salesOrders.' + scope.$index + '.reqMoldTime'"
- :rules="{
- required: true,
- message: '请选择要求完成日期',
- trigger: 'blur'
- }"
- class="table-item"
- >
- <el-date-picker
- style="width: 100%"
- v-model="scope.row.reqMoldTime"
- :pickerOptions="{
- disabledDate: (time) =>
- time.getTime() <
- new Date(new Date().setHours(0, 0, 0, 0)).getTime()
- }"
- type="date"
- placeholder="选择日期"
- value-format="yyyy-MM-dd"
- >
- </el-date-picker>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="客户名称" align="center" prop="customerName">
- </el-table-column>
- <el-table-column label="业务员" align="center" prop="salesman">
- </el-table-column>
- <el-table-column
- label="交付要求"
- align="center"
- prop="deliveryRequirements"
- >
- <template slot-scope="{ row }">
- {{ getDictValue('交付要求', row.deliveryRequirements) }}
- </template>
- </el-table-column>
- <el-table-column
- prop="priority"
- label="优先级"
- width="100"
- align="center"
- >
- <template slot-scope="{ row, $index }">
- <div style="display: flex">
- <el-input
- v-if="$index == 0"
- v-model="row.priority"
- type="number"
- size="mini"
- :min="0"
- :max="10"
- @change="priorityChange(row)"
- style="width: 80px"
- ></el-input>
- <el-popover
- v-if="$index == 0"
- placement="right"
- width="200"
- trigger="hover"
- content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
- >
- <div class="sort-wrap" slot="reference">
- <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>
- </el-table-column>
- <el-table-column label="操作" align="center" width="70" fixed="right">
- <template slot-scope="scope">
- <el-button
- type="text"
- @click="handleDeleteItem(scope.$index)"
- v-if="type != 'edit'"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <div class="add-product" @click="addEquipment" v-if="type != 'edit'">
- <i class="el-icon-circle-plus-outline"></i>
- </div>
- <el-row :gutter="24">
- <el-col v-bind="styleResponsive ? { lg: 24, md: 24 } : { span: 24 }">
- <el-form-item label="计划备注:">
- <el-input
- type="textarea"
- :rows="4"
- v-model="form.notes"
- resize="none"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <AdditionalOrder
- ref="additionalRefs"
- :productCode="form.productCode"
- :selectList="form.salesOrders"
- @choose="confirmChoose"
- ></AdditionalOrder>
- <ProductionVersion
- ref="versionRefs"
- @changeProduct="changeProduct"
- ></ProductionVersion>
- <PlanSubmit
- ref="submitRefs"
- :type="$route.query.type"
- :info="form"
- @publish="publishData"
- ></PlanSubmit>
- <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
- </el-card>
- </div>
- </template>
- <script>
- import validDate from '@/utils/date';
- import AdditionalOrder from './components/AdditionalOrder.vue';
- import PlanSubmit from './components/plan-submit.vue';
- import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
- import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
- import {
- productionToPlan,
- saveSaleToPlan,
- updateSaleToPlan,
- releaseSave,
- getInventory,
- getUpdateInfoById,
- bomRoutingList,
- bomListByPlan,
- getFactoryList,
- getInventoryTotalAPI
- } from '@/api/saleOrder';
- import {
- findBomCategoryByCategoryId,
- planIsReview
- } from '@/api/productionPlan/index';
- import { getByCode } from '@/api/system/dictionary-data';
- import { parameterGetByCode } from '@/api/mainData/index';
- import dictMixins from '@/mixins/dictMixins';
- import { deepClone } from '@/utils/index';
- import { getRouteTabKey, removePageTab } from '@/utils/page-tab-util';
- import { getCode } from '@/api/codeManagement';
- import dayjs from 'dayjs';
- import { debounce } from 'lodash';
- import { log } from 'bpmn-js-token-simulation';
- export default {
- mixins: [dictMixins],
- components: {
- AdditionalOrder,
- ProductionVersion,
- PlanSubmit,
- ProcessRoute
- },
- data() {
- return {
- type: this.$route.query.type,
- weightList: [
- { code: 1, name: 'A' },
- { code: 2, name: 'B' },
- { code: 3, name: 'C' }
- ],
- isSlotting: [
- { code: 1, name: '是' },
- { code: 2, name: '否' }
- ], //是否开槽
- producedList: [
- // { code: 2, name: '加工(MBOM)' }, //2 待确认
- // { code: 3, name: '装配(ABOM)' }
- ],
- form: {
- planType: 1,
- produceRoutingId: '',
- stockCountBase: '',
- salesOrders: [],
- produceRoutingName: '',
- marginCoefficient: '1.0',
- batchNo: null,
- produceType: '',
- bomCategoryId: null,
- factoriesId: '',
- startTime: '',
- endTime: ''
- },
- marginList: [],
- bomVersionList: [],
- routingList: [],
- init: '1',
- factoryList: [],
- // 表单验证规则
- rules: {
- produceRoutingId: [
- { required: true, message: '请选择工艺路线', trigger: 'blur' }
- ]
- // startTime: [
- // {
- // type: 'date',
- // required: true,
- // message: '请选择计划开始日期',
- // trigger: 'change'
- // }
- // ],
- // endTime: [
- // {
- // type: 'date',
- // required: true,
- // message: '请选择计划结束日期',
- // trigger: 'change'
- // }
- // ],
- // produceType: [
- // { required: true, message: '请选择生产类型', trigger: 'blur' }
- // ],
- // bomCategoryId: [
- // { required: true, message: '请选择BOM版本', trigger: 'blur' }
- // ],
- // factoriesId: [
- // { required: true, message: '请选择所属工厂', trigger: 'change' }
- // ]
- },
- // selection: [],
- loading: false,
- processingRequired: 0, // 生产类型跟BOM 版本是否必填 1:是 0:否
- selectionRowShow: false, // 工艺路线输入框展示 状态
- validDate,
- modelList: [], // 机型数据
- colorList: [], // 颜色数据
- isReview: false
- };
- },
- props: {
- objData: {
- type: Object,
- default: {}
- }
- },
- watch: {
- objData: {
- async handler(val) {
- await this.getProducedData();
- this.requestDict('按单按库');
- this.requestDict('订单类型');
- this.requestDict('交付要求');
- this.getByCodeFn();
- this.getFactoryList();
- // 查询库存数量
- // this.inventory(val.id);
- if (val.type == 'edit') {
- this.getPlanInfo(val.id);
- } else {
- this.getSaleInfo();
- }
- },
- deep: true,
- immediate: true
- },
- 'form.produceType'(newVal, oldVal) {
- console.log(newVal, '值');
- },
- form: {
- handler(newVal) {
- console.log(newVal, 'newVal 33');
- },
- deep: true,
- immediate: true
- }
- },
- mounted() {
- this.mandatoryField();
- this.getCodeData();
- this.getplannedReleaseRequire('planned_release_require');
- },
- computed: {
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- },
- // 是否开启响应式布局
- styleResponsive() {
- return this.$store.state.theme.styleResponsive;
- },
- // 是否必填字段
- isRequired() {
- // if (this.form.planType == 5) {
- // return false;
- // }
- return this.processingRequired == 1;
- },
- // 工艺路线 输入框展示跟选择框判断
- isRouteSelect() {
- if (this.isRequired) {
- return true;
- }
- if (!this.selectionRowShow) {
- return true;
- }
- return false;
- },
- // 选择按钮的显示
- isSelectShow() {
- // if (this.form.planType == 5) {
- // return true;
- // }
- return this.processingRequired == 0;
- }
- },
- 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);
- }
- },
- async getplannedReleaseRequire(code) {
- parameterGetByCode({ code }).then((res) => {
- if (res) {
- this.isReview = res.value == '1' ? true : false;
- }
- });
- },
- async getProducedData() {
- console.log(111111111111111);
- let query = { ...this.$route.query };
- console.log(query, 'query');
- if (!query.producedList || query.producedList.length == 0) {
- this.producedList = [
- { code: 2, name: 'MBOM' },
- { code: 3, name: 'ABOM' }
- ];
- return;
- }
- const producedList = JSON.parse(this.$route.query.producedList);
- this.producedList = producedList;
- },
- // 初始化时间赋值
- initTime() {
- let data = { ...this.$route.query };
- if (data.startTime) {
- this.$set(this.form, 'startTime', data.startTime);
- }
- if (data.endTime) {
- this.$set(this.form, 'endTime', data.endTime);
- }
- },
- // 是否必填
- mandatoryField() {
- parameterGetByCode({
- code: 'production_plan_code'
- }).then((res) => {
- if (res) {
- this.processingRequired = res.value;
- }
- });
- },
- // 查询库存数量
- inventory(id) {},
- // 验证时间是否超期
- changeDate(item, i) {
- if (this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime)) {
- this.$message.error('客户期望交期大于了要求完成日期');
- }
- },
- isTimeAGreaterThanB(timeA, timeB) {
- return new Date(timeA) > new Date(timeB);
- },
- async getFactoryList() {
- this.factoryList = await getFactoryList();
- this.$nextTick(() => {
- this.form.factoriesId = this.factoryList[0].id;
- });
- },
- async getPlanInfo(id) {
- const data = await getUpdateInfoById(id);
- console.log(data, '订单的data');
- console.log(11111111111111111111111111111);
- this.form = data;
- this.initTime();
- // if (data.startTime) {
- // this.form.startTime = new Date(data.startTime);
- // }
- // if (data.endTime) {
- // this.form.endTime = new Date(data.endTime);
- // }
- if (!data.bomCategoryId || data.bomCategoryId == null) {
- this.form.produceType = '';
- this.selectionRowShow = true;
- } else {
- this.selectionRowShow = false;
- }
- if (data.salesOrders && data.salesOrders.length > 0) {
- this.form.factoriesId = data.salesOrders[0].factoriesId;
- }
- // this.form.factoriesId = data.salesOrders
- // ? data.salesOrders[0].factoriesId
- // : '';
- if (this.clientEnvironmentId != 4) {
- this.bomListVersion();
- // this.getPlanRouting();
- }
- this._getInventory();
- },
- async _getInventory() {
- let code = [this.form.productCode];
- const res = await getInventoryTotalAPI(code);
- this.form.stockCountBase = res[0].stockCountBase;
- },
- getByCodeFn() {
- console.log('78910');
- getByCode('margin_code').then((res) => {
- let _arr = [];
- res.data.map((item) => {
- const key = Object.keys(item)[0];
- const value = item[key];
- _arr.push({ name: key, value: value });
- });
- this.marginList = _arr;
- });
- },
- getPlanRouting() {
- if (this.form.bomCategoryId && this.form.bomCategoryId != 'null') {
- bomRoutingList(this.form.bomCategoryId).then((res) => {
- this.routingList = res || [];
- if (res.length) {
- let id = this.$route.query.produceRoutingId
- ? this.$route.query.produceRoutingId
- : res[0].id;
- this.$nextTick(() => {
- let arr = this.routingList.filter((item) => {
- return item.id == id;
- });
- if (arr.length > 0) {
- this.$set(this.form, 'produceRoutingId', id);
- }
- });
- }
- });
- }
- },
- bomListVersion(type) {
- console.log(type, 'type 传递的参数 33');
- let categoryId = '';
- if (this.form.salesOrders.length) {
- categoryId = this.form.salesOrders[0].categoryId;
- } else if (this.form.categoryId) {
- categoryId = this.form.categoryId;
- } else {
- new Error('缺少产品信息');
- }
- let param = {
- bomType: this.form.produceType || null,
- categoryId: categoryId
- };
- console.log(param, 'param');
- bomListByPlan(param).then((res) => {
- console.log(res, 'res 查出来没');
- this.bomVersionList = res || [];
- if (res.length) {
- let o = res[0];
- if (type == 'init') {
- let query = { ...this.$route.query };
- let id = query.bomCategoryId ? query.bomCategoryId : o.id;
- this.$set(this.form, 'bomCategoryId', id);
- } else {
- this.$set(this.form, 'bomCategoryId', o.id);
- }
- this.changeBomId();
- }
- });
- },
- changeProduceType(type) {
- console.log('111111111111111111111111');
- if (this.clientEnvironmentId == 4) {
- return false;
- }
- this.form.bomCategoryId = null;
- this.form['bomCategoryName'] = '';
- this.form['bomCategoryVersions'] = '';
- this.bomVersionList = [];
- this.routingList = [];
- this.form.produceRoutingId = '';
- this.form.produceRoutingName = '';
- this.form.produceVersionName = '';
- this.selectionRowShow = false; // ****
- if (type == 'init') {
- let queryD = { ...this.$route.query };
- if (queryD.produceRoutingId && !queryD.bomCategoryId) {
- this.form.produceRoutingName = queryD.produceRoutingName;
- this.form.produceRoutingId = queryD.produceRoutingId;
- this.selectionRowShow = true;
- }
- }
- this.bomListVersion(type);
- },
- changeBomId() {
- this.routingList = [];
- this.form.produceRoutingId = '';
- this.form.produceRoutingName = '';
- this.form.produceVersionName = '';
- if (this.bomVersionList.length == 0) {
- this.form.bomCategoryId = '';
- }
- 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, 'produceRoutingName', f.name);
- this.$set(this.form, 'produceVersionName', f.version);
- }
- });
- },
- getSaleInfo() {
- let params = JSON.parse(this.$route.query.selection);
- productionToPlan(params).then((res) => {
- this.form = deepClone(res);
- console.log(222222222222222222222222, '===');
- this.initTime();
- // this.bomListVersion('init');
- this.form.produceRoutingName =
- res.produceRoutingName || this.$route.query.produceRoutingName;
- this.form.produceRoutingId =
- res.produceRoutingId || this.$route.query.produceRoutingId;
- if (
- !this.form.factoriesId &&
- (res.produceRoutingId || this.$route.query.produceRoutingId)
- ) {
- this.form.factoriesId =
- res.factoriesId || this.$route.query.factoriesId;
- }
- // this.form.produceType =
- // res.produceType || this.$route.query.produceType
- // ? parseInt(this.$route.query.produceType)
- // : null;
- this.form.produceType = this.$route.query.produceType
- ? parseInt(this.$route.query.produceType)
- : res.produceType;
- console.log('this.form', this.form, res);
- this.changeProduceType('init');
- this.form.bomCategoryId =
- res.bomCategoryId || this.$route.query.bomCategoryId;
- // this.changeBomId();
- if (this.clientEnvironmentId == '4') {
- if (this.form.salesOrders[0].productName.includes('板材')) {
- this.changeProduct({
- id: '1856970794952372226',
- name: '板材',
- produceVersionName: '板材'
- });
- } else {
- this.changeProduct({
- id: '1857313733642596353',
- name: '砌块',
- produceVersionName: '砌块'
- });
- }
- }
- this.form.salesOrders.map((item, index) => {
- if (this.clientEnvironmentId == '4') {
- this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
- } else {
- item.planProductNum = item.lackNum;
- item.requiredFormingNum = item.lackNum;
- }
- item.slottingType = item.slottingType && item.slottingType + '';
- item.priority = index + 1;
- item.reqMoldTime = item.deliveryTime;
- if (item.colorKey && typeof item.colorKey == 'string') {
- this.$set(
- this.form.salesOrders[index],
- 'colorKey',
- item.colorKey.split(',')
- );
- }
- if (item.modelKey && typeof item.modelKey == 'string') {
- this.$set(
- this.form.salesOrders[index],
- 'modelKey',
- item.modelKey.split(',')
- );
- }
- // dayjs(
- // new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
- // ).format('YYYY-MM-DD');
- });
- if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
- this.form.planType = 2;
- } else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
- this.form.planType = 1;
- } else {
- this.form.planType = 3;
- }
- this._getInventory();
- });
- this.$forceUpdate();
- },
- itemChange() {
- this.form.salesOrders.map((item, index) => {
- this.$set(
- item,
- 'requiredFormingNum',
- item.planProductNum * (this.form.marginCoefficient || 1)
- );
- });
- },
- factoriesIdFn(e) {
- this.$forceUpdate();
- },
- toInt(planProductNum) {
- return planProductNum * (this.form.marginCoefficient || 1);
- },
- cancel() {
- const key = getRouteTabKey();
- // this.$router.go(-1);
- removePageTab({ key });
- this.$emit('cancel');
- },
- toSubmit() {
- if (!this.form.factoriesId) {
- return this.$message.warning('请选择所属工厂');
- }
- this.form.salesOrders.map((v) => {
- let arrTime = v.deliveryTime && v.deliveryTime.split(' ');
- let arrTimeTow =
- v.produceDeliveryDeadline && v.produceDeliveryDeadline.split(' ');
- v.deliveryTime = arrTime && arrTime[0];
- v.produceDeliveryDeadline = arrTimeTow && arrTimeTow[0];
- // if(v.salesOrders)
- });
- if (this.form.produceType) {
- //查询生产类型
- this.form.produceVersionName = this.producedList.find(
- (v) => v.code == this.form.produceType
- )?.name;
- }
- if (this.form.produceRoutingId && !this.form.produceRoutingName) {
- //查询工艺路线
- this.form.produceRoutingName = this.routingList.find(
- (v) => v.id == this.form.produceRoutingId
- ).name;
- }
- if (this.form.factoriesId) {
- //查询工厂名称
- this.form.factoriesIdName = this.factoryList.find(
- (v) => v.id == this.form.factoriesId
- )?.name;
- }
- // let data = this.form.salesOrders[0];
- if (this.form.salesOrders.length > 1) {
- //多条订单时,拼接批次号(订单数量)
- let arr = [];
- this.form.salesOrders.map((v) => {
- if (v.batchNo) {
- arr.push(v.batchNo);
- }
- });
- this.form.batchNo = arr.toString();
- } else {
- // ((data.productSumWeight /contractNum) * data.planProductNum).toFixed(2);
- this.form.batchNo = this.form.salesOrders[0].batchNo;
- }
- let newSumOrderWeight = 0;
- this.form.salesOrders &&
- this.form.salesOrders.map((el) => {
- let total = (
- (el.productSumWeight / el.contractNum) *
- el.planProductNum
- ).toFixed(2);
- newSumOrderWeight = newSumOrderWeight + (total - 0);
- });
- this.form.newSumOrderWeight = newSumOrderWeight;
- let flag = this.parameterVerification();
- // 必填参数校验
- if (!flag) return;
- this.$refs.form.validate((valid) => {
- if (valid) {
- this.mapList();
- this.$refs.submitRefs.open();
- }
- });
- },
- // 参数校验
- parameterVerification() {
- let flag = true;
- if (!this.form.startTime) {
- this.$message.warning('请选择计划开始时间');
- return false;
- }
- if (!this.form.endTime) {
- this.$message.warning('请选择计划结束时间');
- return false;
- }
- if (this.isRequired) {
- if (!this.form.produceType) {
- flag = false;
- this.$message.warning('请选择生产类型');
- return;
- }
- if (!this.form.bomCategoryId) {
- flag = false;
- this.$message.warning('请选择BOM版本');
- return;
- }
- }
- if (!this.form.produceRoutingId) {
- flag = false;
- this.$message.warning('请选择工艺路线');
- return;
- }
- if (!this.form.salesOrders[0]?.reqMoldTime) {
- flag = false;
- this.$message.warning('请选择要求完成日期');
- return;
- }
- return flag;
- },
- // 对比日期,计算要求生产重量
- mapList() {
- var _sumOrderWeight = 0;
- var requiredFormingNum = 0;
- var productNum = 0;
- this.form.salesOrders.map((item, index) => {
- requiredFormingNum =
- Number(requiredFormingNum) + Number(item.requiredFormingNum);
- if (
- this.form.weightUnit == 'G' ||
- this.form.weightUnit == 'g' ||
- this.form.weightUnit == '克'
- ) {
- this.form.newWeightUnit = 'KG';
- _sumOrderWeight = this.form.newSumOrderWeight / 1000;
- // _sumOrderWeight =
- // (this.form.salesOrders[0].requiredFormingNum *
- // Number(this.form.salesOrders[0].productUnitWeight || 1)) /
- // 1000;
- } else {
- this.form.newWeightUnit = this.form.weightUnit;
- _sumOrderWeight = this.form.newSumOrderWeight;
- // _sumOrderWeight =
- // this.form.salesOrders[0].requiredFormingNum *
- // Number(this.form.salesOrders[0].productUnitWeight || 1);
- }
- productNum += Number(item.planProductNum);
- });
- this.form.productNum = productNum;
- this.form.productUnitWeight =
- this.form.salesOrders[0]?.productUnitWeight;
- this.form.newSumOrderWeight = _sumOrderWeight.toFixed(2);
- this.form.requiredFormingNum = requiredFormingNum;
- const collection = deepClone(this.form.salesOrders);
- const sortedCollection = collection.sort(
- (a, b) => new Date(b.reqMoldTime) - new Date(a.reqMoldTime)
- );
- let latestData = {};
- for (let i = 0; i < sortedCollection.length; i++) {
- const data = sortedCollection[i];
- if (
- !latestData.reqMoldTime ||
- new Date(data.reqMoldTime) >= new Date(latestData.reqMoldTime)
- ) {
- latestData = data;
- }
- }
- this.form.reqMoldTime = latestData.reqMoldTime;
- },
- 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);
- },
- 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) {}, 800),
- // 删除产品
- handleDeleteItem(index) {
- this.form.salesOrders.splice(index, 1);
- this.changeData();
- },
- addEquipment() {
- let query = { ...this.$route.query };
- let orderType = query.orderType;
- let arr = this.form.salesOrders;
- if (arr && arr.length > 0) {
- if (!orderType && orderType !== '0') {
- orderType = arr[0].orderType;
- }
- }
- this.$refs.additionalRefs.open(orderType);
- },
- openVersion() {
- this.$refs.versionRefs.open();
- },
- changeProduct(data) {
- this.$set(this.form, 'produceRoutingName', data.name);
- this.$set(this.form, 'produceRoutingId', data.id);
- this.$set(this.form, 'produceVersionName', data.produceVersionName);
- },
- // 表格:模数、数量(方)、块数输入框 输入事件
- tableHandleKeyUp(row, index, e, name) {
- 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') {
- // 模数
- row.moCount = e;
- // 计算块数的公式:
- // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
- // 每一模的块数*模数moCount = 总块数
- if (row.productName.includes('板材')) {
- row.blockCount =
- Math.floor(600 / modelLong) *
- Math.floor(120 / modeHight) *
- Math.floor(60 / modeWide) *
- row.moCount;
- } 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
- );
- row.blockCount =
- Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
- row.moCount;
- }
- row.planProductNum =
- Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
- row.blockCount;
- } else if (name === 'sum') {
- //方数
- row.planProductNum = e;
- row.blockCount = Math.floor(
- e / ((modelLong * modeWide * modeHight) / 1000000)
- );
- if (row.productName.includes('板材')) {
- row.moCount = Math.ceil(
- row.blockCount /
- (Math.floor(600 / modelLong) *
- Math.floor(120 / modeHight) *
- Math.floor(60 / modeWide))
- );
- } 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 = e;
- if (row.productName.includes('板材')) {
- row.moCount = Math.ceil(
- row.blockCount /
- (Math.floor(600 / modelLong) *
- Math.floor(120 / modeHight) *
- Math.floor(60 / modeWide))
- );
- } else if (row.productName.includes('砌块')) {
- row.moCount = Math.ceil(
- row.blockCount /
- Math.floor(
- (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
- )
- );
- }
- row.planProductNum =
- (Number(e) * modelLong * modeWide * modeHight) / 1000000;
- }
- }
- row.requiredFormingNum = Number(
- row.planProductNum * (this.form.marginCoefficient || 1)
- ).toFixed(0);
- },
- confirmChoose(list) {
- // 取出在弹窗中选中并且不在表格中的数据
- const result = list.filter(
- (i) => this.form.salesOrders.findIndex((p) => p.id === i.id) === -1
- );
- // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
- const del = this.form.salesOrders.filter(
- (i) => list.findIndex((p) => p.id === i.id) === -1
- );
- for (let i = this.form.salesOrders.length - 1; i >= 0; i--) {
- for (let j in del) {
- if (this.form.salesOrders[i].id === del[j].id) {
- this.form.salesOrders.splice(i, 1);
- }
- }
- }
- let priority =
- this.form.salesOrders[this.form.salesOrders.length - 1]?.priority ||
- 0;
- this.form.salesOrders = this.form.salesOrders.concat(
- result.map((item, index) => {
- item.priority = ++priority;
- item.planProductNum = item.lackNum;
- item.requiredFormingNum = item.lackNum;
- item.reqMoldTime = dayjs(
- new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
- ).format('YYYY-MM-DD');
- return item;
- })
- );
- this.changeData();
- },
- changeData() {
- var planProductNum = 0;
- var productWeight = 0;
- this.form.salesOrders.map((item, index) => {
- item.priority = index + 1;
- planProductNum = planProductNum + item.requiredFormingNum;
- productWeight = productWeight + Number(item.productSumWeight);
- });
- this.$set(this.form, 'codeNum', this.form.salesOrders.length);
- this.$set(this.form, 'contractNum', planProductNum);
- this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
- },
- async publishData(type) {
- if (!this.form.batchNo && this.clientEnvironmentId == 5) {
- this.$message.warning('批次号不能为空');
- return;
- }
- const key = getRouteTabKey();
- let params = deepClone(this.form);
- params.categoryId = params.salesOrders[0]?.categoryId;
- if (this.$route.query.type != 'edit') {
- delete params.id;
- }
- console.log(params, 'params');
- params.salesOrders.forEach((item) => {
- item.colorKey = item.colorKey.toString();
- item.modelKey = item.modelKey.toString();
- });
- if (type === 2) {
- const titleText = this.isReview
- ? '是否发起流程'
- : '发布工单后不可撤回,确定发布吗?';
- const title = this.isReview ? '流程确认' : '发布确认';
- const text = this.isReview ? '流程发布中...' : '工单发布中...';
- this.$confirm(titleText, title).then(async () => {
- const loading = this.$loading({
- lock: true,
- fullscreen: true,
- text
- });
- try {
- const code = await getCode('product_order_code');
- const data = {
- productionPlan: params,
- workOrder: {
- productionPlanCode: params.code,
- code: code,
- // formingNum: params.contractNum,
- formingNum: this.form.requiredFormingNum,
- formingWeight: params.sumOrderWeight,
- produceRoutingId: params.produceRoutingId,
- status: 4,
- model: params.model,
- brandNo: params.brandNo,
- categoryId: params.categoryId,
- productCode: params.productCode,
- productName: params.productName,
- newWeightUnit: this.form.newWeightUnit,
- newSumOrderWeight: this.form.newSumOrderWeight
- }
- };
- if (this.$route.query.type == 'edit') {
- data.workOrder.productionPlanId = params.id;
- }
- const URL = this.isReview ? planIsReview : releaseSave;
- await URL(data)
- // await releaseSave(data)
- .then((res) => {
- if (res === 1) {
- if (this.isReview) {
- this.$message.success('流程已发布!');
- this.$router.push({
- path: '/productionPlan'
- });
- } else {
- this.$message.success('工单已发布!');
- this.$router.push({
- path: '/workOrder'
- });
- }
- } else {
- if (this.isReview) {
- this.$message.success('流程已发布!');
- this.$router.push({
- path: '/productionPlan'
- });
- } else {
- this.$confirm(
- '生产计划创建成功,但工单发布失败。请前往【生产计划】列表【重新发布】工单',
- '提示',
- {
- confirmButtonText: '返回',
- cancelButtonText: '立即前往',
- type: 'warning'
- }
- )
- .then(() => {
- this.$router.push({
- path: '/productionPlan'
- });
- })
- .catch(() => {
- this.$router.go(-1);
- });
- }
- }
- removePageTab({ key });
- })
- .catch(() => {
- this.$message.error('发布失败,请重新发布!');
- });
- } catch (error) {
- this.$message.error(error.message || '发布失败,请重新发布!');
- }
- loading.close();
- });
- } else {
- let request =
- this.$route.query.type == 'edit'
- ? updateSaleToPlan
- : saveSaleToPlan;
- request(params)
- .then(async (res) => {
- // 提交
- this.$router.push({
- path: '/productionPlan'
- });
- removePageTab({ key });
- })
- .catch(() => {
- this.$message.error('提交失败,请重新提交!');
- });
- }
- },
- // 打开工艺路线
- openDialog() {
- // this.selectIndex = index;
- this.$refs.processRouteRef.open();
- },
- // 选择工艺路线
- changeParent(item) {
- this.routingList = [];
- this.bomVersionList = [];
- this.$set(this.form, 'bomCategoryId', null);
- this.$set(this.form, 'model', '');
- this.$set(this.form, 'produceType', '');
- this.$set(this.form, 'produceRoutingName', item.name);
- this.$set(this.form, 'produceRoutingId', item.id);
- this.form.bomCategoryName = '';
- this.form.bomCategoryVersions = '';
- this.selectionRowShow = true;
- },
- // 【开始时间变化时】触发
- handleStartTimeChange(row) {
- this.checkEndTimeValid(row);
- },
- // 【结束时间变化时】触发
- handleEndTimeChange(row) {
- this.checkEndTimeValid(row);
- },
- checkEndTimeValid(row) {
- const { startTime: start, endTime: 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('结束时间不能早于开始时间,已自动设为开始时间');
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .ele-body {
- background: #fff;
- }
- .body-title {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .title-left {
- font-size: 20px;
- color: #333;
- }
- .formbox {
- margin: 20px auto;
- }
- .row-intro {
- border-bottom: 1px dashed #ccc;
- margin-bottom: 20px;
- }
- .add-product {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- font-size: 30px;
- color: #1890ff;
- margin: 10px 0;
- cursor: pointer;
- }
- .table-item {
- margin-bottom: 0;
- }
- .header_required {
- position: relative;
- }
- .header_required:before {
- content: '*';
- color: #f56c6c;
- position: absolute;
- top: 11px;
- left: 26px;
- }
- .header_time_required {
- position: relative;
- }
- .header_time_required:before {
- content: '*';
- color: #f56c6c;
- position: absolute;
- top: 11px;
- left: 2px;
- }
- ::v-deep .product_info {
- .el-form-item--medium {
- .el-form-item__label {
- line-height: 26px;
- }
- .el-form-item__content {
- line-height: 26px;
- }
- }
- .product_code_name {
- .el-form-item__content {
- white-space: normal;
- word-break: break-all;
- }
- }
- }
- </style>
|